1import{r as l,j as e}from"./vendor-react-BTaBH3I0.js";import{F as j,c as h,L as N,G as C}from"./index-pVy5dhMT.js";import{e as S,a as T}from"./vendor-router-DaUSQCqh.js";import"./vendor-helmet-BVAFyVM5.js";import"./vendor-misc-DOep9v2o.js";const I=()=>{const[g]=S(),c=g.get("token")||"",x=T(),{refresh:w}=j(),[i,n]=l.useState("loading"),[s,v]=l.useState(null),[y,b]=l.useState(""),[p,m]=l.useState(null),o=!!(s!=null&&s.returning);l.useEffect(()=>{if(!c){n("invalid");return}let r=!0;return(async()=>{try{const t=await(await h(`/api/auth/invite?token=${encodeURIComponent(c)}`,{cache:"no-store"})).json().catch(()=>({}));if(!r)return;t!=null&&t.valid?(v({email:t.email,kind:t.kind,slug:t.slug,returning:!!t.returning}),n("ready")):n("invalid")}catch{r&&n("invalid")}})(),()=>{r=!1}},[c]);const f=async()=>{var r,u;n("submitting"),m(null);try{const t=await h("/api/auth/accept-invite",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:c,display_name:y.trim()||void 0})}),a=await t.json().catch(()=>({}));if(!t.ok){m((a==null?void 0:a.error)??"Could not complete sign-up. The invite may have expired."),n("ready");return}await w(),n("done");const k=((r=a==null?void 0:a.owns)==null?void 0:r.kind)==="project"?`/project/${a.owns.slug}`:`/org/${((u=a==null?void 0:a.owns)==null?void 0:u.slug)??(s==null?void 0:s.slug)}`;setTimeout(()=>x(k),1400)}catch{m("Network error. Please try again."),n("ready")}},d={maxWidth:460,margin:"8vh auto",padding:32,borderRadius:16,border:"1px solid var(--wystem-hairline)",background:"var(--wystem-surface-plate)",color:"var(--wystem-ink-primary)"};return i==="loading"?e.jsxs("div",{style:d,className:"flex items-center gap-3 text-sm",children:[e.jsx(N,{size:16,className:"animate-spin"})," Checking your invitationâ¦"]}):i==="invalid"?e.jsxs("div",{style:d,children:[e.jsx("p",{className:"text-base font-bold",children:"This invitation isn't valid"}),e.jsx("p",{className:"text-sm mt-2",style:{color:"var(--wystem-ink-secondary)"},children:"The link may have expired, already been used, or be incomplete. Sign in with your email address instead â we will send you a code, and you'll email a new invite."})]}):i==="done"?e.jsx("div",{style:d,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(C,{size:20,className:"mt-0.5 shrink-0",style:{color:"var(--wystem-accent-secondary)"}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-bold",children:"You're all set"}),e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--wystem-ink-secondary)"},children:o?"Signed in. Taking you to your websiteâ¦":"Your account is created and you now manage this page. Taking you thereâ¦"})]})]})}):e.jsxs("div",{style:d,children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest",style:{color:"var(--wystem-accent-secondary)"},children:o?"Wystem":"Wystem · Claim approved"}),e.jsx("p",{className:"text-xl font-bold mt-2",children:o?"Continue to your website":"Create your account"}),e.jsx("p",{className:"text-sm mt-2",style:{color:"var(--wystem-ink-secondary)"},children:o?e.jsxs(e.Fragment,{children:["You will be signed in as ",e.jsx("strong",{children:s==null?void 0:s.email})," when you continue. No password or code needed â opening this link from your inbox is the check."]}):e.jsxs(e.Fragment,{children:["You've been verified to manage ",e.jsx("strong",{children:s==null?void 0:s.slug}),". Finish creating your account for ",e.jsx("strong",{children:s==null?void 0:s.email})," to start editing the page."]})}),!o&&e.jsxs("label",{className:"block mt-5",children:[e.jsxs("span",{className:"block text-[11px] font-bold uppercase tracking-widest mb-1",style:{color:"var(--wystem-ink-secondary)"},children:["Your name ",e.jsx("span",{className:"font-normal normal-case",style:{color:"var(--wystem-ink-faint)"},children:"(optional)"})]}),e.jsx("input",{type:"text",maxLength:120,value:y,onChange:r=>b(r.target.value),placeholder:"e.g. Mithun Sheshagiri",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:[border-color:var(--wystem-accent-secondary)]",style:{borderColor:"var(--wystem-hairline)",background:"var(--wystem-surface-base)",color:"var(--wystem-ink-primary)"}})]}
1),p&&e.jsx("p",{className:"text-xs font-medium mt-3",role:"alert",style:{color:"var(--wystem-accent-primary, #b8341a)"},children:p}),e.jsx("button",{type:"button",onClick:f,disabled:i==="submitting",className:"mt-5 w-full px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-widest transition-opacity disabled:opacity-50",style:{background:"var(--wystem-ink-primary)",color:"var(--wystem-ink-inverse)"},children:i==="submitting"?o?"Signing you inâ¦":"Creating your accountâ¦":o?`Continue as ${s==null?void 0:s.email}`:"Create account & manage page"})]})};export{I as AcceptInvitePage};
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.