1import{a as n,j as e,af as I,u as N,c as k,r as s,ag as w,ah as R,ai as E}from"./index-BTfcerCQ.js";import{B as p}from"./Button-x8yPDsbX.js";import{L as C}from"./legal-meta-AIF9S-vp.js";function O({expected:i}){const d=N(),t=n(r=>r.user?.uid),c=k(()=>n.getState().user?.uid===t),o=n(r=>r.reloadClaims),m=n(r=>r.signOut),[x,u]=s.useState(!1),[f,l]=s.useState(!1),g=async()=>{if(!(x||!c.begin())){u(!0),l(!1);try{if(await o(),!c.isCurrent())return;const r=n.getState().claims;if(r?.userId===i.userId&&r.orgId===i.orgId){d("/onboarding",{replace:!0});return}l(!0)}catch{c.isCurrent()&&l(!0)}finally{c.finish(),c.isCurrent()&&u(!1)}}};return e.jsx("main",{className:"min-h-screen flex items-center justify-center p-6",style:{background:"var(--surface)"},children:e.jsxs("div",{className:"w-full max-w-md space-y-4 rounded-xl border border-[var(--border)] p-6 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--text)"},children:"Workspace created"}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Your account access is still updating. Retry to continue."}),f&&e.jsx("p",{role:"alert",className:"text-sm text-red-500",children:"Account access is not ready yet. Please retry."}),e.jsxs("div",{className:"flex justify-center gap-3",children:[e.jsx(p,{type:"button",onClick:()=>void g(),loading:x,loadingText:"Retrying...",children:"Retry"}),e.jsx(p,{type:"button",variant:"outline",onClick:()=>void m().catch(()=>{c.isCurrent()&&l(!0)}),children:"Sign out"})]})]})})}function S({children:i}){return e.jsx("main",{className:"min-h-screen flex items-center justify-center p-6",style:{background:"var(--surface)"}
1,children:e.jsx("div",{className:"w-full max-w-md space-y-5 rounded-xl border border-[var(--border)] p-6 text-center",children:i})})}function A(){const i=N(),d=n(a=>a.user?.uid),t=k(()=>n.getState().user?.uid===d),c=n(a=>a.reloadClaims),[o]=s.useState(()=>w(C)),[m,x]=s.useState(!1),[u,f]=s.useState(null),[l,g]=s.useState(null),[r,v]=s.useState(null),[P,j]=s.useState(o),y=s.useRef(!1),h=s.useCallback(async()=>{if(!y.current){y.current=!0,j(!0),g(null);try{const a=await R({consent:{legalVersion:C,accepted:!0}});if(!t.isCurrent())return;E();try{await c()}catch{if(!t.isCurrent())return;v(a);return}if(!t.isCurrent())return;const b=n.getState().claims;if(b?.userId!==a.userId||b.orgId!==a.orgId){v(a);return}i("/onboarding",{replace:!0})}catch{if(!t.isCurrent())return;g("We could not finish setting up your workspace. Please retry."),y.current=!1,j(!1)}}},[i,c,t.isCurrent]);return s.useEffect(()=>{o&&h()},[o,h]),r?e.jsx(O,{expected:r}):!o&&!P?e.jsxs(S,{children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--text)"},children:"One last thing"}),l&&e.jsx("p",{role:"alert",className:"text-sm text-red-500",children:l}),e.jsxs("label",{className:"flex items-start gap-2.5 text-left text-sm",style:{color:"var(--text-muted)"},children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>x(a.target.checked)}),e.jsxs("span",{children:["I am 18 or older and agree to Kalcend's ",e.jsx("a",{href:"/terms",target:"_blank",rel:"noreferrer",className:"underline",children:"Terms of Service"})," and ",e.jsx("a",{href:"/privacy",target:"_blank",rel:"noreferrer",className:"underline",children:"Privacy Policy"}),"."]})]}),u&&e.jsx("p",{className:"text-sm text-red-500",children:u}),e.jsx(p,{type:"button",size:"lg",className:"w-full",onClick:()=>{if(!m){f("You must be 18+ and accept the Terms and Privacy Policy.");return}f(null),h()},children:"Continue"})]}):e.jsxs(S,{children:[e.jsx("h1",{className:"text-xl font-semibold",style:{color:"var(--text)"},children:"Setting up your workspace"}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"This only takes a moment."}),l&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",className:"text-sm text-red-500",children:l}),e.jsx(p,{type:"button",onClick:()=>void h(),children:"Retry"})]})]})}function L(){const i=n(t=>t.user?.uid);return n(t=>t.claims?.claimsUnavailable===!0)?e.jsx(I,{}):e.jsx(A,{},i)}export{L as default};
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.