import{Au as e,Cd as t,Dd as n,Eu as r,Ml as i,Od as a,Pd as o,ql as s,ra as c,vi as l,yi as u,zd as d}from"./index-Q5R6-AeA.js";var f=d(o(),1),p=`acceptInvitation`,m=()=>{let[{fetching:e,error:t},n]=i(c);return{fetching:e,error:t,acceptInvitation:(0,f.useCallback)(async e=>{let t=`Error accepting invitation`,r=p;u.loading(`Accepting invitation`,{id:r});try{let i=l(await n({token:e}),t,r);if(i)return u.success(`Success`,{id:r,description:`Invitation accepted successfully`}),i.acceptInvitation}catch(e){console.error(t,e),u.error(`Error`,{id:r,description:t,duration:1e4,closeButton:!0})}},[n])}},h=r();function g(){let{token:r}=a(),{isAuthenticated:i,isLoading:o,loginWithRedirect:c}=t(),l=n(),{fetching:u,error:d,acceptInvitation:f}=m();return r?o?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-screen`,children:(0,h.jsxs)(`div`,{className:`text-center max-w-sm space-y-4`,children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Loading invitation...`}),(0,h.jsx)(`p`,{className:`text-muted-foreground`,children:`Please wait while we check your authentication status.`})]})}):i?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-screen`,children:(0,h.jsxs)(`div`,{className:`text-center max-w-sm space-y-4`,children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Accept Invitation`}),d&&(0,h.jsx)(`p`,{className:`text-destructive`,children:d.graphQLErrors?.[0]?.message===`TOKEN_EXPIRED`?`This invitation link has expired. Please request a new one.`:d.graphQLErrors?.[0]?.message??`An error occurred`}),(0,h.jsx)(s,{onClick:async()=>{(await f(r))?.success&&l(e.HOME,{replace:!0})},disabled:u,children:u?`Accepting...`:`Accept Invitation`})]})}):(0,h.jsx)(`div`,{className:`flex items-center justify-center h-screen`,children:(0,h.jsxs)(`div`,{className:`text-center max-w-sm space-y-4`,children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold`,children:`You've been invited!`}),(0,h.jsx)(`p`,{className:`text-muted-foreground`,children:`Please log in or create an account to accept this invitation.`}),(0,h.jsx)(s,{onClick:()=>{let t=e.ACCEPT_INVITATION(r);return sessionStorage.setItem(`auth:returnTo`,t),sessionStorage.setItem(`auth:invitationReturnTo`,t),c({authorizationParams:{audience:void 0,scope:`openid profile email offline_access`,redirect_uri:`${window.location.origin}${e.AUTH_CALLBACK}`},appState:{returnTo:t}})},children:`Login / Create Account`})]})}):(0,h.jsx)(`div`,{className:`flex items-center justify-center h-screen`,children:(0,h.jsxs)(`div`,{className:`text-center max-w-sm space-y-4`,children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Invalid invitation link`}),(0,h.jsx)(`p`,{className:`text-muted-foreground`,children:`This invitation link is incomplete. Please use the full link from your email.`})]})})}export{g as AcceptInvitationPage};