import{r as P,V as E,u as W,j as e,b3 as C,C as b,b4 as j,B as I,A as T,H as u,W as k,b as S,D as U,b5 as v,s as N}from"./index-DR3HTfO6.js";import{w as R}from"./wrap-locale-C0doVwDy.js";import{g as L}from"./get-safe-url-CU6gs6Gc.js";import"./index-DxwXPhQP.js";function B({SessionContext:n,webWalletUrl:a,onSuccess:r}){const{api:o,session:t}=P.useContext(n),{t:s,locale:g}=E(),h=W(),{searchParams:l}=new URL(window.location.href),p=l.get("redirect"),m=async(c,w)=>{r(c,w),await t.refresh(),u.success(s("exchangePassport.success")),setTimeout(()=>{if(p){const i=decodeURIComponent(p);i.startsWith(k)?h(i,{replace:!0}):window.location.href=L(i)}else window.location.href=window.env.pathPrefix||window.env.apiPrefix||"/"},3e3)},f=c=>{u.error(c.message)},d={},x=l.get("componentId");return x&&(d.componentId=x),t.loading?e.jsx(C,{children:e.jsx(b,{})}):e.jsx(j,{did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(I,{sx:{maxWidth:"100%",height:"100%"},children:e.jsx(T,{popup:!0,open:!0,className:"connect",action:"exchange-passport",checkFn:o.get,checkTimeout:600*1e3,webWalletUrl:a,onSuccess:m,onError:f,locale:g,messages:{title:s("exchangePassport.dialog.title"),scan:s("exchangePassport.dialog.scan"),confirm:s("exchangePassport.dialog.confirm"),success:s("exchangePassport.dialog.success")},extraParams:d,extraContent:null,hideCloseButton:!0})})})}const _=R(B);function K(){const{info:n}=S(),a=U(n),r=(o,t)=>{o.sessionToken&&N(t(o.sessionToken))};return e.jsx(_,{SessionContext:v,webWalletUrl:a,onSuccess:r})}export{K as default};
