import{u,j as s,C as d,A as w,ay as v,cv as C,F as f,af as j,aH as I,J as P,bB as S}from"./index-DQhyMeoV.js";import{I as E}from"./invitation-DBHFAKTZ.js";import{g as R}from"./get-safe-url-D0pcxgUJ.js";import"./index-BazbEWXv.js";import"./index-bAcW8HYF.js";import"./emotion-cache.browser.esm-CO4m2LjK.js";import"./sdk-B0lvz_Iz.js";import"./wrap-locale-pkCcV7CX.js";import"./index-BaJk36L1.js";function T(n){const{searchParams:a}=new URL(window.location.href),g=w(),{api:i,session:r}=v(),{info:l}=u(),c=a.get("redirect"),p=a.get("id"),o=C(async()=>{if(!p)return null;const{data:t}=await i.get("/api/invitation",{params:{inviteId:p,mode:"issue-passport"}});return t}),m=f(()=>{if(o.error)throw o.error;return o?.data}),h=f(async(t,x=e=>e)=>{t&&(t.sessionToken&&j(x(t.sessionToken)),await r.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(I.WELLKNOWN_SERVICE_PATH_PREFIX)?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(E,{...n,action:"issue-passport",getDataFn:m,createPassportSvg:t=>S(t,l),checkFn:i.get,onLoginSuccess:h,passportColor:"default",onLogin:r.login})})}function b(){return u().loading?s.jsx(d,{}):s.jsx(T,{})}export{b as default};
