1import{bj as B,bh as V,aW as r,bp as u,aP as Y,aD as e,ab as z,L as N,w as M,b5 as k,bd as v,b7 as W,bg as o,aR as C}from"./index-8eVMnl04.js";import{B as l}from"./button-DLnadNm-.js";import{L as $}from"./Logo-BAmmjE3v.js";import{l as G,d as H,i as J}from"./access-gateway.functions-CCxelNL7.js";import{P as T}from"./PasswordField-BnzG0MnF.js";import{A as I}from"./arrow-right-DcMnX9qD.js";import{M as K}from"./mail-check-DvKdJGAx.js";import{R as Q}from"./refresh-cw-rvUcgLGi.js";import{C as X}from"./circle-check-D-hKIkxG.js";import{S as Z}from"./shield-check-BTnOF0zr.js";import"./index-B_r-nw40.js";import"./index-BYWyDHmV.js";import"./utils-DclmTqRz.js";import"./tax-office-horizontal-cropped-B9-0-FDc.js";import"./input-DBktsWKB.js";import"./label-D65CGT6m.js";import"./eye-off-BtCr4KQq.js";import"./eye-CdMyXHif.js";function ve(){const m=B(),{isAuthenticated:A,user:S,synchronizeSession:R}=V(),[x,L]=r.useState(""),[d,c]=r.useState("loading"),[O,p]=r.useState(""),[t,E]=r.useState(null),[n,i]=r.useState(!1),[f,P]=r.useState("");r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("token")??"";if(L(a),!a){p("This page needs the private invitation link sent to you by the Tax Office."),c("invalid");return}(async()=>{try{const s=await u(G({data:{token:a}}));if(!s.valid){p(s.message),c("invalid");return}E(s.invitation),c("ready")}catch{p("We could not check that invitation right now. Please try the link again."),c("invalid")}})()},[]);async function D(a){if(a.preventDefault(),!t)return;const s=new FormData(a.currentTarget),g=String(s.get("password")??""),U=String(s.get("confirm")??"");if(g.length<10)return o.error("Use a private password of at least 10 characters.");if(g!==U)return o.error("The two passwords do not match.");i(!0);const{data:_,error:b}=await u(v.auth.signUp({email:t.email,password:g,options:{emailRedirectTo:C(`/invitation/accept?token=${encodeURIComponent(x)}`),data:{registration_context:"tax_office_invitation",requested_portal:t.portalIntent}}}));if(i(!1),b)return o.error(b.message);if(!_.session){P(t.email),c("verification");return}await j()}async function j(){i(!0);try{const a=await u(H({data:{token:x}}));await R();const{data:s}=await u(v.auth.mfa.getAuthenticatorAssuranceLevel());if((a.portalIntent==="founder"||a.portalIntent==="administrator")&&s?.currentLevel!=="aal2"){W(a.landingRoute),m({to:k(a.portalIntent),replace:!0});return}m({to:a.landingRoute,replace:!0})}catch(a){o.error(a instanceof Error?a.message:"The invitation could not be completed.")}finally{i(!1)}}async function q(){if(!(!f||!t)){i(!0);try{const{error:a}=await u(v.auth.resend({type:"signup",email:f,options:{emailRedirectTo:C(`/invitation/accept?token=${encodeURIComponent(x)}`)}}));if(a)throw a;o.success("A new verification message was requested.")}catch(a){o.error(a instanceof Error?a.message:"Verification could not be resent.")}finally{i(!1)}}}async function F(){if(!window.confirm("Decline this invitation? The link will stop working."))return;const a=window.prompt("Optional note for the Tax Office:")??"";i(!0);try{await J({data:{token:x,reason:a.trim()||void 0}}),c("declined")}catch(s){o.error(s instanceof Error?s.message:"The invitation could not be declined.")}finally{i(!1)}}const h=t?Y(t.portalIntent):null,w=t?[...t.onboarding.forms,...t.onboarding.documents,...t.onboarding.training]:[],y=t?.portalIntent==="founder"||t?.portalIntent==="administrator";return e.jsx("main",{className:"min-h-screen overflow-x-hidden bg-background px-4 py-10 text-foreground sm:px-6",children:e.jsx("div",{className:"mx-auto w-full max-w-xl",children:e.jsxs("section",{className:"overflow-hidden rounded-lg border border-gold/30 bg-card/95 shadow-elegant",children:[e.jsx("div",{className:"h-1 bg-burgundy"}),e.jsxs("header",{className:"border-b px-6 py-6 text-center",children:[e.jsx("div",{className:"mx-auto flex w-full max-w-sm items-center justify-center rounded-lg bg-primary-foreground px-5 py-4 shadow-elegant",children:e.jsx($,{size:"xl",asLink:!1,className:"max-w-full"})}),e.jsx("p",{className:"mt-4 text-xs font-semibold uppercase tracking-wide text-gold",children:"Private invitation"})]}),e.jsxs("div",{className:"px-6 py-7",children:[d==="loading"&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking your invitationâ¦"}),d==="invalid"&&e.jsxs("div",{className:"rounded-md border border-burgundy/40 bg-burgundy/5 px-4 py-4 text-sm leading-6",children:[e.jsxs("p",{className:"flex items-start gap-2 font-medium",children:[e.jsx(z,{className:"mt-0.5 h-4 w-4 shrink-0 text-burgundy","aria-hidden":"true"}),"This invitation cannot be used"]}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:O}),e.jsx(N,{to:"/contact",hash:"contact-form",className:"mt-3 inline-block text-xs text-gold hover:underline",children:"Contact the Tax Office team"})]}),d==="ready"&&t&&h&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-2xl",children:h.label}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:[t.personDisplay?`${t.personDisplay}, this`:"This"," invitation was prepared for"," ",e.jsx("strong",{className:"text-foreground",children:t.email})," at ",t.companyLegalEntity,"."]}),e.jsxs("dl",{className:"mt-5 grid gap-2 rounded-md border bg-surface/50 px-4 py-4 text-xs leading-5",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Assigned access"}),e.jsx("dd",{className:"text-right font-medium",children:t.requestedRoles.join(", ")})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Multi-factor policy"}),e.jsx("dd",{className:"text-right font-medium",children:y?"Authenticator app required":"Set by Founder policy"})]}),t.expiresAt&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Link expires"}),e.jsx("dd",{className:"text-right font-medium",children:new Date(t.expiresAt).toLocaleStr
1ing()})]}),t.relationshipCategory&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Invited relationship"}),e.jsx("dd",{className:"text-right font-medium",children:M[t.relationshipCategory]})]})]}),w.length>0&&e.jsxs("div",{className:"mt-4 rounded-md border bg-surface/50 px-4 py-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"What the Tax Office will ask you to complete"}),e.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-5 text-muted-foreground",children:w.map(a=>e.jsx("li",{children:a},a))}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"These requirements come from your invitation. You cannot choose or change your own role or access."})]}),A?e.jsxs("div",{className:"mt-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Signed in as ",e.jsx("strong",{className:"text-foreground",children:S?.email}),". Finish linking this invitation to your account."]}),e.jsxs(l,{className:"mt-4 w-full",variant:"royal",size:"lg",disabled:n,onClick:j,children:[n?"Finishingâ¦":"Accept invitation"," ",e.jsx(I,{className:"ml-1 h-4 w-4"})]})]}):e.jsxs("form",{onSubmit:D,className:"mt-6 space-y-4",children:[e.jsx(T,{label:"Create your private password",id:"password",name:"password",autoComplete:"new-password",required:!0,minLength:10,className:"mt-1.5 h-12 bg-input/30 px-4"}),e.jsx(T,{label:"Confirm password",id:"confirm",name:"confirm",autoComplete:"new-password",required:!0,minLength:10,className:"mt-1.5 h-12 bg-input/30 px-4"}),e.jsxs(l,{type:"submit",variant:"royal",size:"lg",className:"w-full",disabled:n,children:[n?"Please waitâ¦":"Verify email and continue"," ",e.jsx(I,{className:"ml-1 h-4 w-4"})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"You choose your own password. The Tax Office never emails passwords or generated credentials, and this link works exactly once."})]}),e.jsx(l,{variant:"ghost",className:"mt-3 w-full",disabled:n,onClick:F,children:"Decline this invitation"})]}),d==="verification"&&t&&e.jsxs("div",{className:"text-center",role:"status",children:[e.jsx(K,{className:"mx-auto h-11 w-11 text-gold","aria-hidden":"true"}),e.jsx("p",{className:"mt-4 text-xs font-semibold uppercase tracking-wide text-burgundy",children:"Step 2 of 5 · Email verification"}),e.jsx("h1",{className:"mt-2 font-display text-3xl",children:"Verify your Tax Office email"}),e.jsxs("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:["We sent a verification message to ",e.jsx("strong",{className:"text-foreground",children:f}),". Open it before the invitation expires, then return through the secure link to continue."]}),e.jsxs("div",{className:"mt-5 rounded-md border bg-surface/50 p-4 text-left text-xs leading-5 text-muted-foreground",children:["The invitation expires ",t.expiresAt?new Date(t.expiresAt).toLocaleString():"at the time shown in your invitation",". Resend is available below if the first message does not arrive. Your password is hidden and is not retained by this page."]}),e.jsxs("div",{className:"mt-5 grid gap-2 sm:grid-cols-2",children:[e.jsxs(l,{variant:"royal",disabled:n,onClick:()=>{q()},children:[e.jsx(Q,{className:"mr-2 h-4 w-4","aria-hidden":"true"})," ",n?"Requestingâ¦":"Resend verification"]}),e.jsx(l,{variant:"outline",onClick:()=>m({to:"/staff-access",replace:!0}),children:"Return to staff sign in"})]})]}),d==="declined"&&e.jsxs("div",{className:"rounded-md border px-4 py-4 text-sm leading-6",children:[e.jsx("p",{className:"font-medium",children:"Invitation declined"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Thank you â the Tax Office has been notified on the invitation record and this link no longer works."}),e.jsx(N,{to:"/contact",hash:"contact-form",className:"mt-3 inline-block text-xs text-gold hover:underline",children:"Contact the Tax Office team"})]}),d==="done"&&t&&e.jsxs("div",{className:"text-center",children:[e.jsx(X,{className:"mx-auto h-10 w-10 text-gold","aria-hidden":"true"}),e.jsx("h1",{className:"mt-4 font-display text-2xl",children:"Invitation accepted"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:y?"Enrol your authenticator app in the Security Center before using privileged tools.":"You can now open your assigned portal."}),e.jsxs("div",{className:"mt-5 grid gap-2",children:[e.jsx(l,{variant:"royal",onClick:()=>m({to:t.portalIntent==="founder"?"/founder-vault":h?.route}),children:t.portalIntent==="founder"?"Continue to Founder / Owner Portal":`Continue to ${h?.label}`}),e.jsx(l,{variant:"outline",onClick:()=>m({to:k(t.portalIntent)}),children:"Open Security Center"})]})]})]}),e.jsx("footer",{className:"border-t bg-muted/20 px-6 py-4 text-xs leading-5 text-muted-foreground",children:e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx(Z,{className:"mt-0.5 h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),"Ross & Associates MBSP LLC â Ross & Associates Tax Office. Invitations are private, single use and expiring."]})})]})})})}export{ve 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.