1import{o as I,A as U,r as z}from"./chunk-5KNZJZUH-t5Jm55O_.js";import{r as l,j as e}from"./vendor-react-DdJf4Egy.js";import{P as O}from"./ProgressCircle-BB1xI5cP.js";import{B as m}from"./Button-wCdGW7De.js";import{t as s}from"./design-tokens-CAuwRRjg.js";import{u as R,h as k,j as L,g as M,i as A}from"./auth-provider-B1cVykur.js";import{B}from"./BrandMark-B52NDCmn.js";import{R as _}from"./MemberComponents-1T96Rstz.js";import{u as G}from"./useTranslation-3k6IDLuJ.js";import{m as o,A as W}from"./vendor-motion-Bmd36BSo.js";import{U as Y,S as F,B as J,I as X,T as q,L as H,E as K,e as $,d as f}from"./vendor-icons-DPkFyTAM.js";import"./Hidden-3MErb6c1.js";import"./i18nInstance-9sSdxJ-C.js";import"./branding-provider-Ddn7nXFe.js";import"./accentVars-DpOZ-2wS.js";import"./contrast-Dfu-Vq6F.js";import"./branding-DGlylNEV.js";import"./Dialog-CBx9_chv.js";import"./Heading-Bl7KRf5A.js";import"./useLoadMoreSentinel-Csymzp9x.js";import"./Autocomplete-XEry1DtR.js";import"./useLocalizedStringFormatter-bpmRAK-z.js";import"./useControlledState-BZWUXUYw.js";import"./Text-DVVWaLRA.js";import"./PortalProvider-18m43T5I.js";import"./VisuallyHidden-CC1S3KMp.js";import"./CopyButton-CoKFrKGX.js";import"./Toast-Qqo9yVcc.js";import"./Avatar-Dh_N4fh7.js";import"./Badge-C_IrNkWt.js";import"./TextField-HR0ThDdM.js";import"./TextField-we2_S_fi.js";import"./Field-R0wZYrTl.js";import"./useFormValidation-uBTArqF1.js";import"./useTextField-n2v77w0h.js";import"./Select-C3nRfq1B.js";import"./ListBox-B4iiewgw.js";import"./DragAndDrop-Dnq7Pt7V.js";import"./intlStrings-CyVY4j4k.js";import"./Popover-CK7z2z4d.js";import"./Modal-wyUOALGY.js";import"./Modal-9_qRQgwa.js";import"./Dialog-CDpOlwdO.js";import"./AlertDialog-BHeNDBn3.js";import"./Skeleton-DEfjUMte.js";import"./Menu-lODAEfP-.js";const Q={AGENCY_OWNER:"Full access to the organization and all subaccounts.",AGENCY_ADMIN:"Access to the organization and all subaccounts.",SUBACCOUNT_OWNER:"Owner of a specific subaccount.",SUBACCOUNT_ADMIN:"Admin access to a specific subaccount.",SUBACCOUNT_MANAGER:"Admin access to a specific subaccount, except AI agent configuration.",SUBACCOUNT_USER:"User access to a specific subaccount."},Fe=I(function(){const{t}=G(),{token:a}=U(),r=z(),{user:g,isAuthenticated:p,isLoading:u,logout:C}=R(),[c,n]=l.useState("loading"),[i,E]=l.useState(null),j=l.useRef(!1),[P,S]=l.useState(!1),h=k(),b=L(),v=i?.email&&g?.email&&i.email.toLowerCase()!==g.email.toLowerCase();l.useEffect(()=>{if(!u&&!p&&a){const y=`/invite/member/accept/${a}`;r(`/login?redirect=${encodeURIComponent(y)}`,{replace:!0})}},[p,u,r,a]),l.useEffect(()=>{if(!a||j.current||u||!p)return;j.current=!0,(async()=>{try{const d=await M.get(`/auth/validate-member-invitation/${encodeURIComponent(a)}`),x=d.data?.data??d.data;x?(E(x),n("valid")):n("invalid")}catch(d){const x=A(d)?d.status:void 0,w=A(d)?d.message:"";x===410||w.toLowerCase().includes("expired")?n("expired"):x===409||w.toLowerCase().includes("already")?n("already-used"):n("invalid")}})()},[a,u,p]);const D=()=>{a&&h.mutate({token:a},{onSuccess:()=>{n("accepted"),setTimeout(()=>r("/",{replace:!0}),2500)},onError:()=>{n("invalid")}})},T=()=>{a&&b.mutate({token:a},{onSuccess:()=>{n("declined"),setTimeout(()=>r("/onboarding",{replace:!0}),2500)},onError:()=>{r("/onboarding",{replace:!0})}})},N=h.isPending||b.isPending;return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(o.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:"w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(B,{className:"w-12 h-12"})}),e.jsxs(W,{mode:"wait",children:[c==="loading"&&e.jsxs(o.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(O,{size:"lg",tone:"accent",decorative:!0})}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.loading")}),e.jsx("p",{className:`${s.sm} text-muted-foreground mt-2`,children:t("invites.loadingDesc")})]},"loading"),c==="valid"&&i&&e.jsx(o.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"space-y-4",children:e.jsxs("div",{className:"bg-card border border-border-subtle rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-6 pt-6 pb-5 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-accent/12 flex items-center justify-center mb-4",children:i.organization.logo_url?e.jsx("img",{src:i.organization.logo_url,alt:i.organization.name,className:"w-12 h-12 rounded-xl object-cover"}):e.jsx(Y,{className:"w-8 h-8 text-accent-text"})}),e.jsx("h1",{className:`${s.xl} font-semibold text-foreground`,children:t("invites.invitedToJoin")}),e.jsx("p",{className:`${s.lg} font-semibold text-accent-text mt-1`,children:i.organization.name})]}),e.jsxs("div",{className:"border-t border-border-subtle",children:[e.jsxs("div",{className:"px-6 py-4 flex items-start gap-3 border-b border-border-subtle",children:[e.jsx(F,{size:16,className:"text-accent-text shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`${s.xs} text-muted-foreground`,children:t("invites.yourRole")}),e.jsx("p",{className:`${s.sm} font-medium text-foreground`,children:_[i.role]||i.role}),e.jsx("p",{className:`${s.xs} text-muted-foreground mt-0.5`,children:Q[i.role]})]})]}),i.subaccount&&e.jsxs("div",{className:"px-6 py-4 flex items-start gap-3 border-b border-border-subtle",children:[e.jsx(J,{size:16,className:"text-accent-text shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`${s.xs} text-muted-foreground`,children:t("invites.subaccount")}
1),e.jsx("p",{className:`${s.sm} font-medium text-foreground`,children:i.subaccount.name})]})]}),e.jsxs("div",{className:"px-6 py-4 flex items-start gap-3",children:[e.jsx(X,{size:16,className:"text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`${s.xs} text-muted-foreground`,children:t("invites.invitedAs")}),e.jsx("p",{className:`${s.sm} font-medium text-foreground`,children:i.email})]})]})]}),v&&e.jsx("div",{className:"px-6 py-4 bg-warning/8 border-y border-warning/25",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(q,{size:16,className:"text-badge-warning shrink-0 mt-0.5"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:`${s.sm} font-medium text-badge-warning`,children:t("invites.accountMismatch")}),e.jsx("p",{className:`${s.xs} text-foreground/70`,children:t("invites.mismatchDesc",{inviteEmail:i.email,currentEmail:g?.email})}),e.jsxs(m,{variant:"secondary",className:"mt-1",isPending:P,onPress:async()=>{S(!0),await C(),r(`/login?redirect=${encodeURIComponent(`/invite/member/accept/${a}`)}`,{replace:!0})},children:[e.jsx(H,{size:14,className:"mr-2"}),t("invites.signOutSwitch")]})]})]})}),e.jsx("div",{className:"px-6 py-4 bg-surface border-t border-border-subtle",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(K,{size:14,className:"text-muted-foreground shrink-0 mt-0.5"}),e.jsx("p",{className:`${s.xs} text-muted-foreground`,children:t("invites.visibilityNotice",{org:i.organization.name})})]})}),e.jsxs("div",{className:"px-6 py-4 flex gap-3 border-t border-border-subtle",children:[e.jsx(m,{variant:"secondary",className:"flex-1",onPress:T,isDisabled:N||!!v,children:b.isPending?t("invites.declining"):t("invites.decline")}),e.jsx(m,{variant:"primary",className:"flex-1",onPress:D,isDisabled:N||!!v,children:h.isPending?t("invites.acceptingAction"):t("invites.acceptInvitation")})]})]})},"valid"),c==="accepted"&&e.jsxs(o.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx($,{className:"w-12 h-12 mx-auto text-badge-success"}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.welcomeTo",{org:i?.organization.name})}),e.jsx("p",{className:`${s.sm} text-muted-foreground mt-2`,children:t("invites.joinedDesc")})]},"accepted"),c==="declined"&&e.jsxs(o.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx(f,{className:"w-12 h-12 mx-auto text-muted-foreground"}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.declined")}),e.jsx("p",{className:`${s.sm} text-muted-foreground mt-2`,children:t("invites.declinedDesc")})]},"declined"),c==="expired"&&e.jsxs(o.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx(f,{className:"w-10 h-10 mx-auto text-badge-warning"}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.expired")}),e.jsx("p",{className:`${s.sm} text-muted-foreground mt-2`,children:t("invites.expiredMemberDesc")}),e.jsx(m,{variant:"primary",className:"mt-4",onPress:()=>r("/",{replace:!0}),children:t("common.goToDashboard")})]},"expired"),c==="already-used"&&e.jsxs(o.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx($,{className:"w-10 h-10 mx-auto text-badge-success"}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.alreadyAccepted")}),e.jsx("p",{className:`${s.sm} text-muted-foreground mt-2`,children:t("invites.alreadyAcceptedMemberDesc")}),e.jsx(m,{variant:"primary",className:"mt-4",onPress:()=>r("/",{replace:!0}),children:t("common.goToDashboard")})]},"already-used"),c==="invalid"&&e.jsxs(o.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"bg-card border border-border-subtle rounded-2xl p-8 text-center",children:[e.jsx(f,{className:"w-10 h-10 mx-auto text-destructive-text"}),e.jsx("h1",{className:`${s.lg} font-semibold text-foreground mt-4`,children:t("invites.invalid")}),e.jsx("p",{className:`${s.sm} text-destructive-text mt-2`,children:t("invites.invalidDesc")}),e.jsx(m,{variant:"primary",className:"mt-4",onPress:()=>r("/",{replace:!0}),children:t("common.goToDashboard")})]},"invalid")]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground mt-6",children:t("common.copyright")})]})})});export{Fe 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.