import{b as f,j as s,C as d,u as x,h as v,i as C,k as u,s as j,W as I,B as P,l as S}from"./index-DR3HTfO6.js";import{I as k}from"./invitation-CIinv2Of.js";import{g as R}from"./get-safe-url-CU6gs6Gc.js";import"./index-6zqs-c3t.js";import"./index-aa4ujRU0.js";import"./emotion-cache.browser.esm-DHWVBIJA.js";import"./sdk-ByxTU3LQ.js";import"./wrap-locale-C0doVwDy.js";import"./index-DxwXPhQP.js";function T(n){const{searchParams:i}=new URL(window.location.href),g=x(),{api:a,session:r}=v(),{info:l}=f(),c=i.get("redirect"),p=i.get("id"),o=C(async()=>{if(!p)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:p,mode:"issue-passport"}});return t}),m=u(()=>{if(o.error)throw o.error;return o?.data}),h=u(async(t,w=e=>e)=>{t&&(t.sessionToken&&j(w(t.sessionToken)),await r.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(I)?g(e,{replace:!0}):window.location.href=R(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?s.jsx(d,{}):s.jsx(P,{className:"page-invite",sx:{width:"100vw",height:"100%",minHeight:"100vh",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"#f6f8fa",overflow:"auto",padding:"20px"},children:s.jsx(k,{...n,action:"issue-passport",getDataFn:m,createPassportSvg:t=>S(t,l),checkFn:a.get,onLoginSuccess:h,passportColor:"default",onLogin:r.login})})}function B(){return f().loading?s.jsx(d,{}):s.jsx(T,{})}export{B as default};
