1import{u as F,b as Y,R as H,r,s as I,j as e,L as m,B as A,t as o}from"./index-BRvF9KL5.js";import{g as z}from"./gtag-CcwGvwVJ.js";import{L as n,I as l}from"./label-DUNkUgV8.js";import{P as J}from"./password-input-r-V8R4B2.js";import{C as B}from"./card-DvO89iRO.js";import{L as P}from"./logo-Djfh2_9Z.js";import"./createLucideIcon-DEyJk1z8.js";function ee(){const{user:N}=F(),C=Y(),{invite:d}=H.useSearch(),[a,D]=r.useState(null),[w,p]=r.useState(null),[c,_]=r.useState(""),[u,S]=r.useState(""),[x,R]=r.useState(""),[h,k]=r.useState(""),[L,O]=r.useState(""),[g,T]=r.useState(""),[s,v]=r.useState("employer"),[y,$]=r.useState(""),[j,G]=r.useState(""),[E,f]=r.useState(!1);r.useEffect(()=>{N&&C({to:"/dashboard"})},[N,C]),r.useEffect(()=>{d&&(async()=>{const{data:t,error:b}=await I.rpc("get_invite_by_token",{_token:d}),i=Array.isArray(t)?t[0]:t;if(b||!i){p("Invite not found or already used");return}if(i.accepted_at){p("This invite was already accepted â please sign in instead");return}if(new Date(i.expires_at)<new Date){p("This invite has expired");return}D(i),v("employee"),_(i.first_name),S(i.last_name),k(i.email)})()},[d]);async function U(t){if(t.preventDefault(),!c.trim()||!u.trim()){o.error("First and last name are required");return}if(!/^[+\d][\d\s()-]{6,20}$/.test(x.trim())){o.error("Enter a valid phone number");return}if(/[<>]/.test(c)||/[<>]/.test(u)||/[<>]/.test(g)){o.error("Inputs may not contain < or >");return}if(!a){if(s==="employer"&&!y.trim()){o.error("Business name is required");return}if(s==="employee"&&!j.trim()){o.error("Company invite code is required");return}}f(!0);const b=`${c.trim()} ${u.trim()}`.trim(),{data:i,error:q}=await I.auth.signUp({email:h,password:g,options:{emailRedirectTo:window.location.origin,data:{display_name:b,first_name:c.trim(),last_name:u.trim(),phone:x.trim(),gmail_address:L.trim()||h,pending_role:a?"employee":s,pending_company_name:!a&&s==="employer"?y.trim():null,pending_invite_code:!a&&s==="employee"?j.trim().toUpperCase():null,pending_invite_token:a?d:null}}});if(q){f(!1),o.error(q.message);return}z("sign_up",{method:a?"invite":s}),f(!1),o.success("Account created â check your email to confirm, then sign in to finish setup.")}return d&&w?e.jsx("div",{className:"min-h-screen grid place-items-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"mb-6 flex justify-center",children:e.jsx(m,{to:"/","aria-label":"Back",children:e.jsx(P,{})})}),e.jsxs(B,{className:"p-7 shadow-xl text-center",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Invite unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3",children:w}),e.jsx(m,{to:"/login",children:e.jsx(A,{className:"mt-6 w-full",variant:"outline",children:"Go to sign in"})})]})]})}):e.jsx("div",{className:"min-h-screen grid place-items-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"mb-6 flex justify-center",children:e.jsx(m,{to:"/","aria-label":"Back to landing page",children:e.jsx(P,{})})}),e.jsxs(B,{className:"p-7 shadow-xl",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Create your account"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Start sending smarter outreach."}),e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[a?e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-3 text-sm",children:["You've been invited to join as ",e.jsx("span",{className:"font-semibold",children:a.role_title||a.level}),". Your name and email are pre-filled below."]}):e.jsxs("div",{children:[e.jsx(n,{children:"I am signing up as"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsx("button",{type:"button",onClick:()=>v("employer"),className:`rounded-lg border px-3 py-2 text-sm font-medium transition ${s==="employer"?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"}`,children:"Employer / Owner"}),e.jsx("button",{type:"button",onClick:()=>v("employee"),className:`rounded-lg border px-3 py-2 text-sm font-medium transition ${s==="employee"?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"}`,children:"Employee"})]})]}),!a&&(s==="employer"?e.jsxs("div",{children:[e.jsx(n,{children:"Business name"}),e.jsx(l,{required:!0,value:y,onChange:t=>$(t.target.value),maxLength:100,placeholder:"Acme Outreach"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"You'll get a company invite code to share with your team."})]}):e.jsxs("div",{children:[e.jsx(n,{children:"Company invite code"}),e.jsx(l,{required:!0,value:j,onChange:t=>G(t.target.value.toUpperCase()),maxLength:16,placeholder:"e.g. ABCD2345",className:"font-mono"})]})),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(n,{children:"First name"}),e.jsx(l,{required:!0,value:c,onChange:t=>_(t.target.value),maxLength:50,autoComplete:"given-name",readOnly:!!a})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Last name"}),e.jsx(l,{required:!0,value:u,onChange:t=>S(t.target.value),maxLength:50,autoComplete:"family-name",readOnly:!!a})]})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Phone number"}),e.jsx(l,{required:!0,type:"tel",value:x,onChange:t=>R(t.target.value),placeholder:"+1 555 123 4567",maxLength:22,autoComplete:"tel"})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Account email"}),e.jsx(l,{type:"email",required:!0,value:h,onChange:t=>k(t.target.value),autoComplete:"email",readOnly:!!a})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Gmail address used for sending"}),e.jsx(l,{type:"email",value:L,onChange:t=>O(t.target.value),placeholder:"[email protected] (leave blank to use account email)"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"This is the Gmail address Replikatie will track sends from in your reports."})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Password"}),e.jsx(J,{required:!0,minLength:8,value:g,onChange:t=>T(t.target.value),autoComplete:"new-password"})]}),e.jsx(A,{type:"submit",className:"w-full",disabled:E,children:E?"Creatingâ¦":"Create account"})]}),e.jsxs("p",{className:"mt-4 text-sm text-muted-foreground text-center",children:["Have an account? ",e.jsx(m,{to:"/login",className:"text-primary font-medium hover:underline",children:"Sign in"})]})]}),e.jsxs("p",{className:"mt-4 text-center text-[11px] text-muted-foreground",children:["By creating an account you agree to our"," ",e.jsx(m,{to:"/terms",className:"text-primary hover:underline",children:"Terms of Service"})," and"," ",e.jsx(m,{to:"/privacy",className:"text-primary hover:underline",children:"Privacy Policy"}),"."]})]})})}export{ee as component};
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.