import{j as s,a7 as x,al as g}from"./vendor-mui-core-D7t4vMS5.js";import{i as v,r as T,b as c}from"./vendor-hooks-DAZ1H6Va.js";import{I as k}from"./invitation-CUluW5mi.js";import{K as I}from"./landing-page-BJAji-kI.js";import{W as P,ab as j}from"./vendor-ux-Dl3wVbv_.js";import{u as R,b as S,e as E,c as W,H as b}from"./index-Ca33rdd_.js";import{g as N}from"./get-safe-url-D4zRnTpF.js";import{c as C}from"./passport-DKYg_d4G.js";import{u as F}from"./vendor-react-DX7tU9aY.js";import"./vendor-utils-BzQg432x.js";import"./index-_uJPC7_n.js";import"./purify.es-HRjpPm7y.js";import"./use-passport-id-B-b-_oYF.js";import"./session-lE2gmzzF.js";import"./sdk-CXEy5Pgp.js";import"./wrap-locale-BJF_SaOe.js";import"./index-BoJbHOhC.js";import"./use-blocklet-logo-BWPJOOVd.js";import"./vendor-arcblock-ivFYo5vP.js";import"./create-passport-svg-De1vqcmo.js";function $(m){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:""}),o=T(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),l=c(()=>{if(o.error)throw o.error;return o?.data}),w=c(async(t,i=e=>e)=>{t&&(t.sessionToken&&S(i(t.sessionToken)),t.refreshToken&&E(i(t.refreshToken)),t.visitorId&&j(i(t.visitorId)),await f.refresh()),setTimeout(()=>{if(p){const e=decodeURIComponent(p);e.startsWith(W.WELLKNOWN_SERVICE_PATH_PREFIX)?d(e,{replace:!0}):window.location.href=N(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?s.jsx(x,{}):s.jsxs(I,{did:window.blocklet?.appPid,children:[s.jsx(b,{children:s.jsxs("title",{children:[u("pageTitle.issuePassport")," | ",window.blocklet?.appName]})}),s.jsx(g,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:s.jsx(k,{...m,action:"issue-passport",getDataFn:l,checkFn:a.get,createPassportSvg:C,onLoginSuccess:w,inService:!0,status:h.state})})]})}export{$ as default};
