import{j as e,a6 as P,ak as E}from"./vendor-mui-core-CKKG_1TN.js";import{r as k,u as T}from"./vendor-react-CTtPmzVP.js";import{o as j}from"./vendor-arcblock-BCP2x3BR.js";import{V as W,W as d,b8 as C}from"./vendor-ux-DjXlxcvL.js";import{w as I,c as R,m as S,b,e as v}from"./index-BEfIUbZC.js";import{K as U}from"./landing-page-B5QvkHHO.js";import{w as L}from"./wrap-locale-CFhaO2KZ.js";import{g as N}from"./get-safe-url-DxqVk96E.js";import"./vendor-utils-CUs2ebe7.js";import"./vendor-hooks-DQAdyHrE.js";import"./lottie-web-4koyQiv_.js";import"./index-BoLm67SH.js";function _({SessionContext:n,webWalletUrl:r,onSuccess:o}){const{api:t,session:i}=k.useContext(n),{t:s,locale:h}=W(),f=T(),{searchParams:p}=new URL(window.location.href),m=p.get("redirect"),g=async(a,w)=>{o(a,w),await i.refresh(),d.success(s("exchangePassport.success")),setTimeout(()=>{if(m){const c=decodeURIComponent(m);c.startsWith(R.WELLKNOWN_SERVICE_PATH_PREFIX)?f(c,{replace:!0}):window.location.href=N(c)}else window.location.href=window.env.pathPrefix||window.env.apiPrefix||"/"},3e3)},u=a=>{d.error(a.message)},l={},x=p.get("componentId");return x&&(l.componentId=x),i.loading?e.jsx(j,{children:e.jsx(P,{})}):e.jsx(U,{did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(E,{sx:{maxWidth:"100%",height:"100%"},children:e.jsx(I,{popup:!0,open:!0,className:"connect",action:"exchange-passport",checkFn:t.get,checkTimeout:10*60*1e3,webWalletUrl:r,onSuccess:g,onError:u,locale:h,messages:{title:s("exchangePassport.dialog.title"),scan:s("exchangePassport.dialog.scan"),confirm:s("exchangePassport.dialog.confirm"),success:s("exchangePassport.dialog.success")},extraParams:l,extraContent:null,hideCloseButton:!0})})})}const B=L(_);function G(){const n=C(),r=(o,t)=>{o.sessionToken&&(b(t(o.sessionToken)),v(t(o.refreshToken)))};return e.jsx(B,{SessionContext:S,webWalletUrl:n,onSuccess:r})}export{G as default};
