import{g as l,V as m,r as c,m as d,j as e,W as u,X as h,Y as f}from"./index-CfKY7XrC.js";import{F as x}from"./full-page-spinner-CSuSQkVy.js";function g(){const{session:i,sessionResult:a}=l(),{invitationId:t}=m.useSearch(),r=c.useRef(!1);return c.useEffect(()=>{a.isPending||i||!t||r.current||(r.current=!0,(async()=>{let n=null;try{const o=await fetch(`${d}/api/invitation-preview?id=${encodeURIComponent(t)}`,{credentials:"omit"});o.ok&&(n=await o.json())}catch{}const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`/auth/accept-invitation?invitationId=${encodeURIComponent(t)}`),n&&(s.searchParams.set("loginHint",n.email),s.searchParams.set("invitationOrg",n.organizationName)),window.location.href=s.toString()})())},[i,a.isPending,t]),i&&!t?e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md text-center",children:[e.jsx(u,{className:"mx-auto h-10 w-10 text-destructive mb-4"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Invitation not found"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"This invitation link is missing its ID. Ask the person who invited you to resend it."})]})}):i?e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx(h,{children:e.jsx(f,{})})}):e.jsx(x,{className:"min-h-[calc(100vh-3.5rem)]"})}export{g as component};
