{"version":3,"file":"ConfirmEmailBanner.Dj9FZGD4.mjs","names":["React.useState","React.useRef","createClient","__esmMin","init_ssg_sandbox_shims","window","_e","p","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","addPropertyControls","RenderTarget","init_framer_BWFVvmND","ControlType","init_supabase_js_2","Oe","ConfirmEmailBanner","props","email","setEmail","resending","setResending","notice","setNotice","canvas","isInFramerEditor","supabaseRef","supabaseUrl","supabaseAnonKey","supabase","cancelled","check","stash","STASH_KEY","sess","t","POLL_INTERVAL_MS","handleResend","error","handleDismiss","BANNER_STYLE","paddingY","paddingX","bg","textColor","radius","borderColor","fontFamily","position","accentColor","fontSize","buttonBg","buttonText","init_ConfirmEmailBanner"],"sources":["https:/framerusercontent.com/modules/SIFeNZN4eaDd2YOCUFEj/0ggMI6H25L0W8ooEjAnG/ConfirmEmailBanner.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{createClient}from\"https://esm.sh/@supabase/supabase-js@2\";// Connect-4Care — Confirm Email Banner\n// ------------------------------------\n// Fixes the UX hole left by turning Confirm Email ON (Task #49 / D-081):\n//\n// After `supabase.auth.signUp` with Confirm Email ON, Supabase does NOT\n// return a session until the user clicks the confirmation link in\n// their inbox. The careseeker onboarding submit handler finishes the\n// trigger-driven writes server-side but the browser is still\n// unauthenticated. The configured post-signup destination is\n// `/caregivers`, so the user lands on the marketplace looking like a\n// logged-out visitor — top nav shows Login, no account chip, no\n// indication they just created an account. They'd try to log in,\n// Supabase would reject with \"Email not confirmed\", confusion,\n// churn.\n//\n// This component plugs the gap. It's a sticky banner the designer drops\n// once per public page (home, /caregivers, /caregivers/[slug], etc.);\n// when the signup submit handler stashed a pending email in\n// sessionStorage (key `c4c-pending-confirmation-email`), the banner\n// reveals itself with:\n//\n//   \"Thanks for signing up! We've sent a confirmation link to\n//    you@example.com. Click it to activate your account.\n//    [Resend] [Dismiss]\"\n//\n// Lifecycle:\n//\n//   * On mount, reads the stashed email and the Supabase session.\n//   * If no stashed email → banner stays hidden (nothing to confirm).\n//   * If session exists (user has confirmed and signed in) → banner\n//     stays hidden, clears the stash.\n//   * Otherwise shows the banner and starts a 10s polling loop\n//     watching for the session; the moment it appears, hides itself\n//     and clears the stash.\n//\n// Resend button calls `supabase.auth.resend({ type: 'signup', email })`\n// and shows a brief \"Sent.\" confirmation. Rate-limited by Supabase\n// (default 60s between resends) — the handler surfaces that error\n// inline if it fires.\n//\n// Dismiss removes the stash key and hides the banner. Not persisted\n// across page loads with a different stash key — if a NEW signup\n// happens later, the new stash re-reveals the banner. That's by\n// design: the banner is a signup-aftermath nudge, not a global\n// \"please confirm\" state.\n//\n// Framer canvas: skipped so the design preview isn't cluttered\n// by the banner in editor mode.\nconst STASH_KEY=\"c4c-pending-confirmation-email\";const POLL_INTERVAL_MS=1e4;const isInFramerEditor=()=>{try{const t=RenderTarget.current();return t===RenderTarget.canvas||t===RenderTarget.thumbnail;}catch{return false;}};/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 1200\n * @framerIntrinsicHeight 56\n */export default function ConfirmEmailBanner(props){const{supabaseUrl,supabaseAnonKey,bg,textColor,accentColor,borderColor,buttonBg,buttonText,radius,paddingY,paddingX,fontFamily,fontSize,position}=props;const[email,setEmail]=React.useState(null);const[resending,setResending]=React.useState(false);const[notice,setNotice]=React.useState(\"\");const canvas=isInFramerEditor();const supabaseRef=React.useRef(null);React.useEffect(()=>{if(canvas){// Design-time preview: show the banner with placeholder\n// email so the designer can style it.\nsetEmail(\"you@example.com\");return;}if(typeof window===\"undefined\")return;if(!supabaseUrl||!supabaseAnonKey)return;const supabase=createClient(supabaseUrl,supabaseAnonKey);supabaseRef.current=supabase;let cancelled=false;const check=async()=>{try{const stash=typeof sessionStorage!==\"undefined\"?sessionStorage.getItem(STASH_KEY):null;if(!stash){if(!cancelled)setEmail(null);return;}const{data:sess}=await supabase.auth.getSession();if(cancelled)return;if(sess?.session?.user){// User signed in → confirmation worked. Clear\n// the stash so the banner doesn't come back if\n// they bounce around.\ntry{sessionStorage.removeItem(STASH_KEY);}catch{}setEmail(null);return;}setEmail(stash);}catch{// getSession can throw on torn-down pages; ignore.\n}};check();const t=setInterval(check,POLL_INTERVAL_MS);return()=>{cancelled=true;clearInterval(t);};},[canvas,supabaseUrl,supabaseAnonKey]);const handleResend=async()=>{if(!email||!supabaseRef.current||canvas)return;setResending(true);setNotice(\"\");try{const{error}=await supabaseRef.current.auth.resend({type:\"signup\",email});if(error){setNotice(error.message.toLowerCase().includes(\"rate\")?\"Please wait a minute before resending.\":\"Couldn't resend. Try again in a moment.\");}else{setNotice(\"Confirmation email sent.\");}}catch{setNotice(\"Couldn't resend. Try again in a moment.\");}finally{setResending(false);setTimeout(()=>setNotice(\"\"),4e3);}};const handleDismiss=()=>{try{sessionStorage.removeItem(STASH_KEY);}catch{}setEmail(null);};if(!email){// Nothing to confirm — render a 1×1 no-op so Framer's layout\n// engine doesn't get confused by an element that varies\n// between 0 and nonzero height.\nreturn /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,overflow:\"hidden\",pointerEvents:\"none\"},\"aria-hidden\":\"true\"});}const BANNER_STYLE={display:\"flex\",alignItems:\"center\",gap:16,flexWrap:\"wrap\",justifyContent:\"space-between\",width:\"100%\",boxSizing:\"border-box\",padding:`${paddingY}px ${paddingX}px`,background:bg,color:textColor,borderRadius:radius,border:borderColor?`1px solid ${borderColor}`:\"none\",fontFamily:fontFamily||\"Inter, system-ui, sans-serif\",fontSize,lineHeight:1.45,position:position===\"top\"?\"sticky\":\"static\",top:position===\"top\"?0:undefined,zIndex:50,...props.style||{}};return /*#__PURE__*/_jsxs(\"div\",{role:\"status\",\"aria-live\":\"polite\",style:BANNER_STYLE,children:[/*#__PURE__*/_jsxs(\"div\",{style:{flex:1,minWidth:240},children:[/*#__PURE__*/_jsx(\"strong\",{style:{color:accentColor},children:\"Confirm your email to finish signing up.\"}),\" \",\"We sent a link to\",\" \",/*#__PURE__*/_jsx(\"span\",{style:{color:accentColor,fontWeight:600},children:email}),\". Click it to activate your account and start using Connect-4Care.\",notice&&/*#__PURE__*/_jsx(\"div\",{style:{marginTop:6,fontSize:fontSize-1,opacity:.85},children:notice})]}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:8,flexShrink:0},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleResend,disabled:resending,style:{all:\"unset\",cursor:resending?\"default\":\"pointer\",padding:\"8px 16px\",borderRadius:999,background:buttonBg,color:buttonText,fontWeight:600,fontFamily:fontFamily||\"Inter, system-ui, sans-serif\",fontSize:fontSize-1,opacity:resending?.65:1},children:resending?\"Sending…\":\"Resend\"}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Dismiss\",onClick:handleDismiss,style:{all:\"unset\",cursor:\"pointer\",padding:\"6px 10px\",color:textColor,opacity:.6,fontSize:fontSize+4,lineHeight:1},children:\"\\xd7\"})]})]});}ConfirmEmailBanner.defaultProps={supabaseUrl:\"https://xkatbssxeyumhfieshcu.supabase.co\",supabaseAnonKey:\"\",bg:\"#FFF8E1\",textColor:\"#5A4A1E\",accentColor:\"#8C6B10\",borderColor:\"#F0E0A0\",buttonBg:\"#155259\",buttonText:\"#FFFFFF\",radius:10,paddingY:12,paddingX:20,fontFamily:\"Inter, system-ui, sans-serif\",fontSize:14,position:\"top\"};addPropertyControls(ConfirmEmailBanner,{supabaseUrl:{type:ControlType.String,title:\"Supabase URL\",defaultValue:\"https://xkatbssxeyumhfieshcu.supabase.co\"},supabaseAnonKey:{type:ControlType.String,title:\"Supabase Anon Key\",defaultValue:\"\",description:\"Public anon key. Safe in the browser.\"},position:{type:ControlType.Enum,title:\"Position\",options:[\"top\",\"bottom\"],optionTitles:[\"Sticky top\",\"Static (flows with content)\"]},bg:{type:ControlType.Color,title:\"Background\"},textColor:{type:ControlType.Color,title:\"Text\"},accentColor:{type:ControlType.Color,title:\"Accent\",description:\"Used for the bold intro + the email address.\"},borderColor:{type:ControlType.Color,title:\"Border\",description:\"Leave empty for no border.\"},buttonBg:{type:ControlType.Color,title:\"Button Bg\"},buttonText:{type:ControlType.Color,title:\"Button Text\"},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:40,step:1,unit:\"px\"},paddingX:{type:ControlType.Number,title:\"Padding X\",min:0,max:80,step:1,unit:\"px\"},paddingY:{type:ControlType.Number,title:\"Padding Y\",min:0,max:60,step:1,unit:\"px\"},fontFamily:{type:ControlType.String,title:\"Font Family\"},fontSize:{type:ControlType.Number,title:\"Font Size\",min:10,max:24,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ConfirmEmailBanner\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"56\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"1200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ConfirmEmailBanner.map"],"mappings":"A,6QAqDG,SAAwBmB,EAAmB,EAAM,CAAC,GAAK,CAAC,cAAY,kBAAgB,KAAG,YAAU,cAAY,cAAY,WAAS,aAAW,SAAO,WAAS,WAAS,aAAW,WAAS,YAAUC,EAAW,CAACC,EAAMC,GAAUtB,EAAe,IAAI,EAAO,CAACuB,EAAUC,GAAcxB,EAAe,EAAK,EAAO,CAACyB,EAAOC,GAAW1B,EAAe,EAAE,EAAQ2B,EAAOC,EAAiB,EAAQC,EAAY5B,EAAa,IAAI,EAAES,MAAoB,CAAC,GAAGiB,EAAO,CAE3bL,EAAS,iBAAiB,EAAE,MAAO,CAAuC,GAA5BjB,IAAS,QAAsB,CAACyB,GAAa,CAACC,EAAgB,OAAO,IAAMC,EAAS9B,EAAa4B,EAAYC,CAAe,EAAE,EAAY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