import{j as e,a7 as g,al as x}from"./vendor-mui-core-CDEc-eG6.js";import{i as v,r as T,b as m}from"./vendor-hooks-BrgYeCrj.js";import{I as k}from"./invitation-NVra7-eg.js";import{K as I}from"./landing-page-C9IV5jp5.js";import{W as P,ab as j}from"./vendor-ux-bFYdDLNG.js";import{u as R,b as S,d as W,W as E,H as b}from"./index-DGZk149v.js";import{g as N}from"./get-safe-url-B1bR9jl-.js";import{c as C}from"./passport-sgLXIGRN.js";import{u as F}from"./vendor-react-DX7tU9aY.js";import"./vendor-utils-_C9URqjS.js";import"./index-xYYHLOvz.js";import"./purify.es-HRjpPm7y.js";import"./use-passport-id-B-b-_oYF.js";import"./session-Dxo7LCKC.js";import"./sdk-BxbfHGV5.js";import"./wrap-locale-DSF06-Vj.js";import"./index-91KnTNni.js";import"./use-blocklet-logo-BSClbuwz.js";import"./vendor-arcblock-DY2miJjh.js";import"./create-passport-svg-BYi3UIaq.js";function $(c){const{searchParams:r}=new URL(window.location.href),{api:a,session:f}=R(),d=F(),{t:u}=P(),n=r.get("id"),p=r.get("redirect"),h=v({state:""}),i=T(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),l=m(()=>{if(i.error)throw i.error;return i?.data}),w=m(async(t,o=s=>s)=>{t&&(t.sessionToken&&S(o(t.sessionToken)),t.refreshToken&&W(o(t.refreshToken)),t.visitorId&&j(o(t.visitorId)),await f.refresh()),setTimeout(()=>{if(p){const s=decodeURIComponent(p);s.startsWith(E)?d(s,{replace:!0}):window.location.href=N(s)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.loading?e.jsx(g,{}):e.jsxs(I,{did:window.blocklet?.appPid,children:[e.jsx(b,{children:e.jsxs("title",{children:[u("pageTitle.issuePassport")," | ",window.blocklet?.appName]})}),e.jsx(x,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:e.jsx(k,{...c,action:"issue-passport",getDataFn:l,checkFn:a.get,createPassportSvg:C,onLoginSuccess:w,inService:!0,status:h.state})})]})}export{$ as default};
