1import{d as B,r as a,u as H,j as e,S as M}from"./index-pnw7vN9z.js";import{H as Q,F as R}from"./Footer-BJxCwxzn.js";import{C as c,a as d,b as g,c as v,d as w}from"./card-DYfi2lB_.js";import{B as u}from"./button-B9_AU6ak.js";import{I as y}from"./input-CU8NR_7l.js";import{L as N}from"./label-BsF_0be7.js";import{L as b}from"./loader-circle-CVgwkkQV.js";import{S as $}from"./shield-zkv2iy0o.js";import{a as Y,E as G}from"./eye-DVJl0gnl.js";import{C as J}from"./circle-check-big-DoxPMSOG.js";function re(){const l=B().token,[i,o]=a.useState("loading"),[m,P]=a.useState(null),[p,k]=a.useState(""),[C,I]=a.useState(""),[h,E]=a.useState(!1),[F,A]=a.useState(""),[L,T]=a.useState(""),[j,q]=a.useState(""),[V,S]=a.useState(""),[x,f]=a.useState(!1),{toast:n}=H();a.useEffect(()=>{async function t(){try{const r=await fetch(`/api/investor/setup/${l}`),s=await r.json();if(!r.ok||!s.success){S(s.message||"Invalid or expired setup link."),o("error");return}P(s),o("password")}catch{S("Unable to validate your setup link. Please try again."),o("error")}}l&&t()},[l]);const D=async t=>{if(t.preventDefault(),p.length<8){n({title:"Password too short",description:"Password must be at least 8 characters.",variant:"destructive"});return}if(p!==C){n({title:"Passwords don't match",description:"Please make sure both passwords match.",variant:"destructive"});return}f(!0);try{const r=await fetch(`/api/investor/setup/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:p})}),s=await r.json();if(!r.ok||!s.success){n({title:"Setup failed",description:s.message||"Please try again.",variant:"destructive"});return}A(s.qrCode),T(s.secret),o("scan-qr")}catch{n({title:"Error",description:"Something went wrong. Please try again.",variant:"destructive"})}finally{f(!1)}},O=async t=>{if(t.preventDefault(),j.length!==6){n({title:"Invalid code",description:"Please enter the 6-digit code from your authenticator app.",variant:"destructive"});return}f(!0);try{const r=await fetch(`/api/investor/setup/${l}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:j})}),s=await r.json();if(!r.ok||!s.success){n({title:"Verification failed",description:s.message||"Invalid code. Please try again.",variant:"destructive"});return}o("complete")}catch{n({title:"Error",description:"Something went wrong. Please try again.",variant:"destructive"})}finally{f(!1)}};return e.jsxs("div",{className:"min-h-screen bg-background","data-testid":"page-investor-setup",children:[e.jsx(M,{title:"Account Setup - LV5 Capital Investor Portal",description:"Set up your LV5 Capital investor portal account.",path:"/investor-setup",noindex:!1}),e.jsx(Q,{}),e.jsx("main",{className:"pt-24 pb-20",children:e.jsxs("div",{className:"max-w-lg mx-auto px-6",children:[i==="loading"&&e.jsx(c,{className:"text-center",children:e.jsxs(d,{className:"py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-primary mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Validating your setup link..."})]})}),i==="error"&&e.jsx(c,{className:"text-center",children:e.jsxs(d,{className:"py-12",children:[e.jsx($,{className:"w-12 h-12 text-destructive mx-auto mb-4"}),e.jsx("h2",{className:"font-heading font-bold text-xl mb-2",children:"Setup Link Invalid"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:V}),e.jsx(u,{onClick:()=>window.location.href="/investor-portal","data-testid":"button-go-to-portal",children:"Go to Investor Portal"})]})}),i==="password"&&m&&e.jsxs(c,{children:[e.jsxs(g,{className:"text-center pb-4",children:[e.jsx(v,{className:"font-heading text-2xl",children:"Welcome to LV5 Capital"}),e.jsxs(w,{children:["Set up your investor portal account",m.firstName?`, ${m.firstName}`:"","."]})]}),e.jsxs(d,{children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 mb-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Investor ID"}),e.jsx("p",{className:"font-mono font-bold text-lg text-foreground","data-testid":"text-investor-id",children:m.investorId})]}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(N,{htmlFor:"password",children:"Create Password"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(y,{id:"password",type:h?"text":"password",value:p,onChange:t=>k(t.target.value),placeholder:"Minimum 8 characters",required:!0,minLength:8,"data-testid":"input-setup-password"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>E(!h),children:h?e.jsx(Y,{className:"w-4 h-4"}):e.jsx(G,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx(N,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(y,{id:"confirmPassword",type:h?"text":"password",value:C,onChange:t=>I(t.target.value),placeholder:"Confirm your password",required:!0,className:"mt-1.5","data-testid":"input-setup-confirm-password"})]}),e.jsxs(u,{type:"submit",className:"w-full",disabled:x,"data-testid":"button-setup-password",children:[x?e.jsx(b,{className:"w-4 h-4 animate-spin mr-2"}):null,"Continue to 2FA Setup"]})]})]})]}),i==="scan-qr"&&e.jsxs(c,{children:[e.jsxs(g,{className:"text-center pb-4",children:[e.jsx(v,{className:"font-heading text-2xl",children:"Set Up Two-Factor Authentication"}),e.jsx(w,{children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"})]}),e.jsxs(d,{className:"space-y-6",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:F,alt:"2FA QR Code",className:"w-48 h-48","data-testid":"img-qr-code"})}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Can't scan? Enter this code manually:"}),e.jsx("p",{className:"font-mono text-sm break-all select-all text-foreground","data-testid":"text-totp-secret",children:L})]}),e.jsx(u,{className:"w-full",onClick:()=>o("verify"),"data-testid":"button-continue-verify",children:"I've Scanned the Code"})]})]}),i==="verify"&&e.jsxs(c,{children:[e.jsxs(g,{className:"text-center pb-4",children:[e.jsx(v,{className:"font-heading text-2xl",children:"Verify 2FA Code"}),e.jsx(w,{children:"Enter the 6-digit code from your authenticator app to complete setup."})]}),e.jsx(d,{children:e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(N,{htmlFor:"totpCode",children:"Authentication Code"}),e.jsx(y,{id:"totpCode",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:j,onChange:t=>q(t.target.value.replace(/\D/g,"")),placeholder:"000000",className:"mt-1.5 text-center text-2xl tracking-[0.5em] font-mono",autoF
1ocus:!0,"data-testid":"input-setup-totp"})]}),e.jsxs(u,{type:"submit",className:"w-full",disabled:x,"data-testid":"button-verify-setup",children:[x?e.jsx(b,{className:"w-4 h-4 animate-spin mr-2"}):null,"Complete Setup"]}),e.jsx("button",{type:"button",className:"w-full text-sm text-muted-foreground hover:text-foreground",onClick:()=>o("scan-qr"),children:"Back to QR code"})]})})]}),i==="complete"&&e.jsx(c,{className:"text-center",children:e.jsxs(d,{className:"py-12",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto mb-5",children:e.jsx(J,{className:"w-8 h-8 text-green-600"})}),e.jsx("h2",{className:"font-heading font-bold text-2xl mb-2","data-testid":"text-setup-complete",children:"Account Setup Complete"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your investor portal account is ready. You can now sign in with your Investor ID, password, and authenticator app."}),e.jsx(u,{onClick:()=>window.location.href="/investor-portal","data-testid":"button-go-to-login",children:"Sign In to Portal"})]})})]})}),e.jsx(R,{})]})}export{re 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.