1import{r as i,j as e}from"./vendor-radix-DLGwGdby.js";import{i as N,u as S,f as _,j as C,k as b,t as h,H as x,S as P,l as w,m as j,B as A,n as I}from"./index-Cz1Nuibl.js";import{M as L,L as M}from"./vendor-lucide-BWW0XcuW.js";import"./vendor-recharts-dzgay_RI.js";import"./vendor-datefns-CU7NMMYW.js";const k="Email address not provided",O="provider";function T(s){if(!s||s.startsWith("//"))return null;try{const c=s.includes("%")?decodeURIComponent(s):s,t=new URL(c,"https://startupgate.local");return t.origin!=="https://startupgate.local"||t.pathname!=="/dashboard/settings"||t.hash||t.searchParams.get("email_change")!==O?null:"/dashboard/settings?tab=profile&email_change=provider"}catch{return null}}function $(){const{user:s,refreshUser:c}=N(),t=S(),[l]=_(),f=i.useRef(!1),[m,R]=i.useState(!1),d=l.get("return_to"),p=T(d),E=i.useRef(p),u=p??E.current,v=C(d),a=b(d),n=v!==null,o=u??(a?`/auth?return_to=${encodeURIComponent(a)}`:"/auth"),g=n?{...w,background:P}:void 0;return i.useEffect(()=>{const r=l.get("error_description")||l.get("error");if(r){if(r.includes(k)){R(!0);return}h.error("Sign in failed",{description:r}),t(o,{replace:!0});return}f.current||(f.current=!0,c())},[t,c,o,l]),i.useEffect(()=>{if(s){if(h.success("Welcome!",{description:"You have successfully signed in."}),u){t(u,{replace:!0});return}if(s.roles.length===0){const y=a?`?return_to=${encodeURIComponent(a)}`:"";t(`/signup/application${y}`,{replace:!0});return}const r=a??"/dashboard";r.startsWith("/oauth/")||r.startsWith("/insurance/")?window.location.assign(r):t(r,{replace:!0})}},[s,t,a,u]),i.useEffect(()=>{if(m)return;const r=setTimeout(()=>{s||(h.error("Sign in timed out",{description:"Please try again."}),t(o,{replace:!0}))},1e4);return()=>clearTimeout(r)},[s,t,m,o]),m?e.jsxs(e.Fragment,{children:[e.jsx(x,{children:e.jsx("meta",{name:"robots",content:"noindex, nofollow"})}),e.jsx("div",{"data-testid":n?"sso-identity":void 0,className:"flex min-h-screen items-center justify-center bg-background px-4",style:g,children:e.jsxs("div",{className:"text-center space-y-4 max-w-sm",children:[n&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(j,{size:"md",variant:"sso"})}),e.jsx(L,{className:"h-10 w-10 text-destructive mx-auto"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Email access required"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your sign-in provider did not share your email address. Please allow email access when prompted and try again."}),e.jsx(A,{onClick:()=>t(o,{replace:!0}),children:"Try again"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{children:e.jsx("meta",{name:"robots",content:"noindex, nofollow"})}),e.jsx("div",{"data-testid":n?"sso-identity":void 0,className:"flex min-h-screen items-center justify-center bg-background",style:g,children:e.jsxs("div",{className:"text-center space-y-4",children:[n&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(j,{size:"md",variant:"sso"})}),e.jsx(M,{className:"h-8 w-8 animate-spin text-primary mx-auto"}),e.jsx("p",{className:"text-muted-foreground",children:n?`Completing sign in to ${I.name}...`:"Completing sign in..."})]})})]})}export{$ as default,T as getEmailChangeResumePath};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.