import{j as i,al as w}from"./vendor-mui-core-CDEc-eG6.js";import{u as g,r as v}from"./vendor-react-DX7tU9aY.js";import{b as x}from"./vendor-hooks-Ca2cSNuD.js";import{I as u}from"./invitation-CcqRXA0x.js";import{K as I}from"./landing-page-BvgQ3gcP.js";import{aa as k,ao as T}from"./vendor-ux-PO0jFgJf.js";import{u as S,m as j,W as c,b as E,d as P,H as R}from"./index-CgSpL7jz.js";import{g as W}from"./get-safe-url-uxJSMQTF.js";import{c as b}from"./passport-2AVRJTQK.js";import"./vendor-utils-_C9URqjS.js";import"./index-BvUXcJcd.js";import"./purify.es-HRjpPm7y.js";import"./use-passport-id-B-b-_oYF.js";import"./session-BEf_KK-i.js";import"./sdk-CuoW9qgj.js";import"./wrap-locale-AxlzuLIu.js";import"./index-C2_MQP4T.js";import"./use-blocklet-logo-nVOJALp0.js";import"./vendor-arcblock-BVQTtbN-.js";import"./create-passport-svg-DNOT-xbE.js";function J(m){const p=g(),{searchParams:n}=new URL(window.location.href),{api:d,session:s}=S(),{t:f}=k(),r=n.get("inviteId"),a=n.get("redirect"),h=v.useCallback(async()=>{const{data:o}=await j.get("invitation",{params:{inviteId:r}});if(!!o?.orgId&&!s.user){const t=encodeURIComponent(`${window.location.pathname}${window.location.search}`);window.location.href=`${c}/login?redirect=${t}`}return o},[r,s.user]),l=x(async(o,e=t=>t)=>{o&&o.sessionToken&&o.refreshToken&&(E(e(o.sessionToken)),P(e(o.refreshToken)),o.visitorId&&T(e(o.visitorId))),await s.refresh(),setTimeout(()=>{if(a){const t=decodeURIComponent(a);t.startsWith(c)?p(t,{replace:!0}):window.location.href=W(t)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(I,{did:window.blocklet?.appPid,children:[i.jsx(R,{children:i.jsxs("title",{children:[f("pageTitle.invite")," | ",window.blocklet?.appName]})}),i.jsx(w,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(u,{...m,getDataFn:h,checkFn:d.get,createPassportSvg:o=>b({...o}),onLoginSuccess:l,inService:!0})})]})}export{J as default};
