@nexus-cross/connect-kit-react 1.5.0-beta.3 → 1.5.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var yt="1.5.0-beta.3";var Rt="__nexusCrossAppLauncherRuntime";function er(){if(typeof window>"u")return null;let e=window;return e[Rt]??(e[Rt]={mode:"dapp-ui"}),e[Rt]}function tr(e){if(e.scheduled)return;e.scheduled=!0;let t=()=>{if(e.scheduled=!1,e.loggedMode!==e.mode){if(e.mode==="connect-kit-react"){let n=e.connectKitVersion??yt;console.info(`[CROSSx App Launcher] connect-kit-react v${n} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${yt}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${yt} \uCD08\uAE30\uD654 \uC644\uB8CC (\uC0AC\uC6A9 \uBAA8\uB4DC: dapp-ui only)`);e.loggedMode=e.mode}};typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)}function wn(){let e=er();e&&(e.mode="connect-kit-react",e.connectKitVersion=yt,tr(e))}import{useCallback as Ne,useEffect as oe,useMemo as Fe,useRef as be,useState as Ye}from"react";import{WagmiProvider as pr,useAccount as mr,useChainId as fr,useConnect as gr,useDisconnect as yr,useSwitchChain as br}from"wagmi";import{QueryClient as hr,QueryClientProvider as Cr}from"@tanstack/react-query";import{attachEmbeddedAuthSync as wr,clearWalletSessionStorage as Sn,onOpenOtherWallets as kr,pickInitialState as Ir,resolveCurrentWallet as xr}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as vr}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as Tr}from"@nexus-cross/crossx-design-system";import{OnRampProvider as Pr}from"@nexus-cross/onramp/react";import{KycProvider as Sr}from"@nexus-cross/kyc/react";import{createContext as nr,useContext as or}from"react";var jt=nr(null);function Oe(){let e=or(jt);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}var rr=Oe;import{createContext as sr,useContext as kn}from"react";var At=sr(null);function In(){let e=kn(At);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function ut(){return kn(At)}var ir=In,ar=ut;import{createContext as cr}from"react";var Ot=cr(null);function xn(){let e=new Set,t=n=>{for(let s of[...e])try{s(n)}catch(o){console.debug("[crossx-kit] analytics handler threw",o)}};return{track:t,emit:n=>t({...n,timestamp:Date.now()}),subscribe:n=>(e.add(n),()=>{e.delete(n)})}}import{useCallback as dr,useMemo as vn}from"react";import{WalletConnectModal as Tn}from"@nexus-cross/dapp-ui";import{jsx as Pn}from"react/jsx-runtime";var lr=new Set(["cross_wallet","cross_extension","metamask","binance"]);function Et({open:e,onOpenChange:t}){let{connect:n,availableWallets:s,oauth:o,extraWallets:a,walletAllowlist:u,kitConfig:g}=Oe(),r=ut()?.mode??"dark",f=vn(()=>{let m=u?new Set(u):null,I={};for(let w of s){if(!lr.has(w.walletId)||m&&!m.has(w.walletId))continue;let T=w.walletId;I[T]=()=>{n(w.walletId)}}for(let[w,T]of Object.entries(a))T&&(m&&!m.has(w)||(I[w]=T));return I},[s,n,a,u]),b=vn(()=>{if(o)return{apple:()=>{o.signIn("apple")},google:()=>{o.signIn("google")}}},[o]),C=dr(m=>t(m),[t]);return Pn(Tn,{wallets:f,socialProviders:b,termsUrl:g.legal?.termsUrl,privacyUrl:g.legal?.privacyUrl,theme:r,open:e,onOpenChange:C,children:Pn(Tn.Content,{})})}var ur=Et;import{jsx as Je,jsxs as En}from"react/jsx-runtime";var Rr=new hr,Qt="crossx-kit:last-wallet-intent",Ar=15e3,Or=1500,Er=3;function Rn(e,t){return Promise.race([e.then(()=>{},()=>{}),new Promise(n=>setTimeout(n,t))])}function _r(e){let t=[],n=e,s=0;for(;n&&s<5;){let o=n;typeof o.message=="string"&&t.push(o.message),n=o.cause,s+=1}return t.some(o=>/external wallet connection/i.test(o))}function Br(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Qt)??null}catch{return null}}function An(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Qt,e):window.localStorage.removeItem(Qt)}catch{}}function Nr(e,t){if(typeof window>"u")return t;try{let n=window.localStorage.getItem(e);return n==="cross"||n==="reown"?n:t}catch{return t}}function Wr(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function Dr({children:e,config:t,activeProvider:n,onRequestProviderSwap:s,pendingConnectWalletId:o,clearPending:a,themeMode:u,themeTokens:g,extraWallets:d,walletAllowlist:r,emit:f}){let[b,C]=Ye(!1),[m,I]=Ye(()=>Br()),[w,T]=Ye(null),{address:U,isConnected:x,isConnecting:G,isReconnecting:A,connector:E}=mr(),{connectors:H,connectAsync:q}=gr(),{disconnectAsync:_}=yr(),{kitConfig:O,connectorRegistry:W,crossProvider:ee,reownProvider:re}=t,D=n==="cross"?ee:re,S=Fe(()=>!x||!E?null:xr(W,E.id,m),[x,E,W,m]),j=Fe(()=>W.entries.filter(p=>p.type!=="embedded"),[W]),te=Ne(p=>W.getEntry(p)?.type??"external",[W]),Qe=be(null);Qe.current=w;let Ce=be(S);Ce.current=S;let ge=be(U);ge.current=U;let le=O.embeddedProjectId?.trim()||O.crossProjectId?.trim(),we=!!O.onRampEnabled&&!!le,ze=Fe(()=>!we||!le?null:{projectId:le,walletState:{getAddress:()=>ge.current}},[we,le]),ke=be(E);ke.current=E;let _e=O.embeddedProjectId?.trim()||O.crossProjectId?.trim(),De=!!O.kycEnabled&&!!_e,Pe=Fe(()=>!De||!_e?null:{projectId:_e,getAccessToken:async()=>{let p=ke.current;if(!(!p||typeof p.getProvider!="function"))try{return(await(await p.getProvider())?.sdk?.getUserInfo?.())?.data?.accessToken||void 0}catch{return}}},[De,_e]);oe(()=>kr(()=>C(!0)),[]),oe(()=>{if(!b||typeof document>"u")return;let p=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(h=>h.remove())},50);return()=>clearTimeout(p)},[b]);let Se=be(x),nt=be(x);Se.current=x;let Ke=be(!1);oe(()=>{console.debug("[crossx-kit] state",{activeProvider:n,isConnected:x,isConnecting:G,isReconnecting:A,activeConnectorId:E?.id,currentWallet:S,lastIntent:m})},[n,x,G,A,E?.id,S,m]),oe(()=>{x&&!nt.current&&D?.closeModal?.({kitConfig:O}),nt.current=x},[x,D,O]),oe(()=>{x&&T(null)},[x]);let $e=fr(),{switchChainAsync:ct}=br(),Le=be(null);oe(()=>{if(!O.enforceDefaultNetworkOnConnect)return;let p=O.defaultNetwork?.id;if(!p)return;if(!x||!U||!E){Le.current=null;return}let h=`${E.id}:${U}`;Le.current!==h&&(Le.current=h,$e!==p&&ct({chainId:p}).catch(()=>{}))},[O.enforceDefaultNetworkOnConnect,O.defaultNetwork,x,U,E,$e,ct]);let ye=be(b);oe(()=>{b&&!ye.current?f({name:"connect_modal_opened"}):!b&&ye.current&&f({name:"connect_modal_closed",completed:Se.current}),ye.current=b},[b,f]);let Be=be(x);oe(()=>{if(x&&!Be.current){let p=Qe.current;p&&f({name:"connect_succeeded",walletId:p,walletType:te(p),chainId:$e})}Be.current=x},[x,$e,f,te]);let i=Ne(p=>H.find(h=>h.id===p),[H]);oe(()=>{let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;let v=!1;return(async()=>{try{let R=await h.getProvider();if(v)return;R?.sdk?.applyTheme?.(u,g??void 0)}catch(R){console.debug("[crossx-kit] applyTheme skipped:",R)}})(),()=>{v=!0}},[W,i,u,g]);let c=Ne(p=>{I(p),An(p)},[]),l=Ne(()=>{I(null),An(null),T(null)},[]);oe(()=>{if(!D?.subscribeModalState)return;let p=!1;return D.subscribeModalState({kitConfig:O},h=>{if(Ke.current=h,h){p=!0;return}p&&(p=!1,setTimeout(()=>{if(Se.current)return;let v=Qe.current;v&&f({name:"connect_cancelled",walletId:v,stage:"popup"}),(async()=>{try{await _()}catch{}l()})()},250))})},[D,O,_,l,f]),oe(()=>{if(!w||x||typeof window>"u"||w==="cross_embedded")return;let p=typeof document<"u"&&!document.hasFocus(),h=null,v=()=>{p=!0},R=()=>{p&&(h&&clearTimeout(h),h=setTimeout(()=>{if(Se.current||Ke.current)return;let N=Qe.current;N&&f({name:"connect_cancelled",walletId:N,stage:"popup"}),(async()=>{try{await _()}catch{}l()})()},1e3))};return window.addEventListener("blur",v),window.addEventListener("focus",R),()=>{window.removeEventListener("blur",v),window.removeEventListener("focus",R),h&&clearTimeout(h)}},[w,x,_,l,f]);let y=Ne(async p=>{console.debug("[crossx-kit] runConnect enter",{walletId:p,activeProvider:n,isConnected:x,activeConnectorId:E?.id});let h=W.getEntry(p);if(!h){if((p==="metamask"||p==="binance")&&!re){console.error(`[crossx-kit] "${p}" requires the Reown adapter, but it is not configured. Pass \`reownProjectId\` (and ensure \`reown\` is not set to \`false\`) when calling createConnectKitConfig() or createCrossxConfig() to enable WalletConnect-based wallets.`);return}console.error(`[crossx-kit] Unknown walletId: "${p}"`);return}if(T(p),h.providerKind!==n){console.debug("[crossx-kit] provider swap needed",{from:n,to:h.providerKind,walletId:p}),c(p);try{await _()}catch{}await new Promise(N=>setTimeout(N,0)),s(h.providerKind,p);return}let v=te(p);if(f({name:"wallet_selected",walletId:p,walletType:v}),f({name:"connect_started",walletId:p,walletType:v}),c(p),D?.beforeConnect)try{let N=await D.beforeConnect({kitConfig:O,themeMode:u},p);if(console.debug("[crossx-kit] beforeConnect result",{walletId:p,result:N}),N==="handled")return}catch(N){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',p,N)}let R=i(h.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:h.connectorId,found:R?.id,availableIds:H.map(N=>N.id)}),!R){console.error(`[crossx-kit] Connector "${h.connectorId}" not found on provider "${h.providerKind}". Available: ${H.map(N=>N.id).join(", ")}`),f({name:"connect_failed",walletId:p,reason:"connector_not_found"}),l();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:R.id});let N=await q({connector:R});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:N.accounts.length,chainId:N.chainId});return}catch(N){let Re=_r(N);if(!Re){console.error('[crossx-kit] connectAsync error for "%s":',p,N);try{await _()}catch{}}if(!h.fallbackConnectorId){Re||f({name:"connect_failed",walletId:p,reason:"connector_error"}),l();return}}if(h.fallbackConnectorId){let N=i(h.fallbackConnectorId);if(N)try{await q({connector:N})}catch(Re){console.error('[crossx-kit] Fallback connect failed for "%s":',p,Re);try{await _()}catch{}f({name:"connect_failed",walletId:p,reason:"fallback_failed"}),l()}else f({name:"connect_failed",walletId:p,reason:"fallback_failed"}),l()}},[W,H,i,q,_,c,l,D,n,O,s,u,f,te]);oe(()=>{if(!o)return;let p=o;a(),y(p)},[o,n]);let k=Ne(async()=>{C(!0)},[]),L=Ne(async()=>{f({name:"disconnected",walletId:Ce.current});try{await _()}catch(p){console.error("[crossx-kit] wagmi disconnect error:",p)}if(D?.teardown)try{await D.teardown({kitConfig:O})}catch(p){console.error("[crossx-kit] adapter teardown error:",p)}Sn(),l()},[_,D,O,l,f]),F=Ne(async()=>{await Rn(_(),3e3);try{let p=W.getEntry("cross_embedded"),h=p&&i(p.connectorId);if(h?.getProvider){let v=await Promise.race([h.getProvider(),new Promise(N=>setTimeout(N,3e3))]),R=v?.sdk?.signOut;typeof R=="function"&&await Rn(R.call(v.sdk),3e3)}}catch{}Sn()},[W,i,_]),B=Ne(async()=>{let p=W.getEntry("cross_embedded");if(!p)return null;let h=i(p.connectorId);if(!h)return null;try{let v=await h.getProvider(),R=v?.sdk;if(!R?.selectWallet)return null;let N=await R.selectWallet(R.currentAddress??void 0);return N?.address&&v.notifyAccountsChanged&&v.notifyAccountsChanged([N.address]),N&&f({name:"wallet_switched",index:N.index}),N}catch{return null}},[W,i,f]),K=Fe(()=>{let p=t.oauth;return p?{signIn:async h=>{T("cross_embedded"),f({name:"wallet_selected",walletId:"cross_embedded",walletType:"embedded"}),f({name:"connect_started",walletId:"cross_embedded",walletType:"embedded"});try{await p.signIn(h)}catch(v){let R=v?.code==="EMBEDDED_CONNECT_NOT_ESTABLISHED";throw f({name:"connect_cancelled",walletId:"cross_embedded",stage:R?"stalled":"popup"}),T(null),v}}}:null},[t.oauth,f]),Y=be(!1);oe(()=>{if(n!=="cross"||x||G||A||w!=null||Y.current)return;let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;Y.current=!0;let v=!1;return(async()=>{try{let R=await h.isAuthorized?.();if(v||!R)return;await q({connector:h})}catch{}})(),()=>{v=!0}},[n,x,G,A,w,W,i,q]);let P=be(0);oe(()=>{if(n!=="cross"||x||!G&&!A||P.current>=Er)return;let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;let v=!1,R=setInterval(()=>{(async()=>{if(v||Se.current)return;let N=await Promise.resolve(h.isAuthorized?.()).catch(()=>!1);if(!(v||!N||Se.current)){P.current+=1,console.warn("[crossx-kit] wagmi reconnect stalled while the SDK holds a session \u2014 forcing an explicit connect to realign");try{await q({connector:h})}catch{}}})()},Or);return()=>{v=!0,clearInterval(R)}},[n,x,G,A,W,i,q]),oe(()=>{if(w!=="cross_embedded"||x||typeof window>"u")return;let p=!document.hasFocus(),h=()=>{p=!0};window.addEventListener("blur",h);let v=setTimeout(()=>{Se.current||p||(console.warn("[crossx-kit] embedded sign-in stalled before the OAuth popup opened \u2014 clearing the stale session so a retry starts clean"),f({name:"connect_cancelled",walletId:"cross_embedded",stage:"stalled"}),l(),F())},Ar);return()=>{window.removeEventListener("blur",h),clearTimeout(v)}},[w,x,l,F,f]);let M=w!=null&&!x,Q=Fe(()=>({kitConfig:O,connectorRegistry:W,availableWallets:j,connect:y,connectWallet:k,disconnect:L,selectWallet:B,currentWallet:S,lastIntent:m,isConnecting:M,connectingWalletId:w,openOtherWallets:()=>C(!0),closeOtherWallets:()=>C(!1),otherWalletsOpen:b,oauth:K,extraWallets:d,walletAllowlist:r,onRampEnabled:we}),[O,W,j,y,k,L,B,S,m,M,w,b,K,d,r,we]),V=En(jt.Provider,{value:Q,children:[e,Je(Et,{open:b,onOpenChange:C})]});return Pe&&(V=Je(Sr,{config:Pe,children:V})),ze&&(V=Je(Pr,{config:ze,children:V})),V}var Lr=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function Fr(e){let t=e?.message;return typeof t!="string"?!1:Lr.some(n=>n.test(t))}var Ur={};function Mr(e){return e&&{...e,connections:new Map,current:null}}function On({children:e,config:t,initialState:n,extraWallets:s=Ur,walletAllowlist:o}){let[a,u]=Ye(()=>Nr(t.activeProviderStorageKey,t.defaultProvider)),[g,d]=Ye(null),r=be(!1),f=be(null);f.current||(f.current=xn());let b=f.current,C=Fe(()=>({subscribe:b.subscribe}),[b]),{kitConfig:m}=t,[I,w]=Ye(null),[T,U]=Ye(null),[x,G]=Ye(0),A=Fe(()=>vr(m.theme,m.autoDetectTheme),[m.theme,m.autoDetectTheme,x]),E=I??A,H=T??m.themeTokens;oe(()=>{if(!m.autoDetectTheme||I||typeof window>"u"||!window.matchMedia)return;let S=window.matchMedia("(prefers-color-scheme: dark)"),j=()=>G(te=>te+1);try{return S.addEventListener("change",j),()=>S.removeEventListener("change",j)}catch{return S.addListener(j),()=>S.removeListener(j)}},[m.autoDetectTheme,I]),oe(()=>{if(typeof document>"u")return;let S=document.documentElement,j=S.getAttribute("data-ds-theme"),te=S.getAttribute("data-theme");return S.setAttribute("data-ds-theme",E),te||S.setAttribute("data-theme",E),()=>{j==null?S.removeAttribute("data-ds-theme"):S.setAttribute("data-ds-theme",j),te==null&&S.removeAttribute("data-theme")}},[E]);let q=Fe(()=>Tr(t.designSystem),[t.designSystem]),_=Fe(()=>({mode:E,tokens:H,setThemeMode:S=>w(S),setThemeTokens:S=>U(S)}),[E,H]);oe(()=>{if(typeof window>"u")return;let S=j=>{Fr(j.reason)&&j.preventDefault()};return window.addEventListener("unhandledrejection",S),()=>window.removeEventListener("unhandledrejection",S)},[]),oe(()=>{if(a!=="cross")return;let S=t.crossWagmiConfig;if(S)return wr(S)},[a,t.crossWagmiConfig]);let O=Ne((S,j)=>{r.current||(r.current=!0,d(j),u(S),Wr(t.activeProviderStorageKey,S),queueMicrotask(()=>{r.current=!1}))},[t.activeProviderStorageKey]),W=Ne(()=>d(null),[]),ee=a==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,re=Mr(Ir(n,a));if(!ee){if(!(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let j=a==="cross"?"reown":"cross";queueMicrotask(()=>u(j))}let D=ee??(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return Je(Ot.Provider,{value:C,children:En(At.Provider,{value:_,children:[Je("style",{"data-crossx-design-system":"",children:q}),Je(pr,{config:D,initialState:re,children:Je(Cr,{client:Rr,children:Je(Dr,{config:t,activeProvider:a,onRequestProviderSwap:O,pendingConnectWalletId:g,clearPending:W,themeMode:E,themeTokens:H,extraWallets:s,walletAllowlist:o??t.kitConfig.wallets??null,emit:b.emit,children:e})})},a)]})})}var Gr=On;import{WalletInfo as pn}from"@nexus-cross/dapp-ui";import{APPLE_ICON as zi}from"@nexus-cross/connect-kit-wagmi";import{useCallback as je,useEffect as Si,useMemo as xt,useState as Ri}from"react";import{useQueryClient as Ai}from"@tanstack/react-query";import{useAccount as Oi,useChainId as Ei,useConfig as _i,useSendTransaction as Bi,useSwitchChain as Ni}from"wagmi";import{getPublicClient as dn,readContracts as yo}from"wagmi/actions";import{ConnectorId as tt,OnePopGetTokenTrigger as Wi,resolveEnvironment as Di,WALLET_REGISTRY as Li}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as Fi,useOptionalOnRampEligibility as Ui}from"@nexus-cross/onramp/react";import{APPLE_ICON as bo,BINANCE_ICON as ho,CROSSX_ICON as un,EXTENSION_ICON as Mi,GOOGLE_ICON as Co,METAMASK_ICON as wo}from"@nexus-cross/connect-kit-wagmi";import{WALLET_LABELS as vt}from"@nexus-cross/crossx-design-system";import{useCallback as si,useMemo as kt}from"react";import{useAccount as oo,useConfig as ro,useSwitchChain as ii,useWriteContract as ai}from"wagmi";import{readContract as ci,waitForTransactionReceipt as so}from"wagmi/actions";import{GetOneUsd as di,resolveEnvironment as li}from"@nexus-cross/dapp-ui";import{useCallback as ie,useMemo as Te,useRef as Kr}from"react";import{useQueries as Nn,useQuery as Ze}from"@tanstack/react-query";import{encodeFunctionData as bt,formatUnits as Lt,parseSignature as $r,parseUnits as Hr}from"viem";import{getChainId as zt,getPublicClient as Qn,readContract as We,signTypedData as qr,switchChain as Wn,waitForTransactionReceipt as Vr,writeContract as Dn}from"wagmi/actions";import{useConfig as jr}from"wagmi";async function _t(e,t,n){if(!(!n||t===void 0))try{if(e.getChainId()===t)return;await e.switchChain(t)}catch{}}var pt=10000n;function _n(e){let t=e==="auto"?1:Number(e||"1");return!Number.isFinite(t)||t<0?100n:BigInt(Math.min(1e4,Math.floor(t*100)))}function Bt(e,t){let n=_n(t);return n>=pt?0n:e*(pt-n)/pt}function Bn(e,t){let n=_n(t);return(e*(pt+n)+(pt-1n))/pt}function Qr(e){return e!=="bridge"}var Ve="0x0000000000000000000000000000000000000000",Ee=100,ft=18,zr=180000n,Xr=500000n,zn=new Set([56,97]),Yr=130n,Jr=100n,Zr={dev:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",stage:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",production:"https://contents.crosstoken.io/frontend/game-token/json/hidden-path.json"},es={dev:"dev",stage:"stg",production:"prod"};function ts(e,t){let n=e?.[es[t]]?.hiddenPairs;if(!Array.isArray(n))return null;let s=n.filter(o=>!!o&&typeof o=="object"&&typeof o.fromKey=="string"&&typeof o.toKey=="string");return s.length>0?s:null}var ns={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",production:"https://contents.crosstoken.io/frontend/common/app-launcher/contracts.json"},os=["BSC_CROSS","W_CROSS","NATIVE_CROSS","USDTX","CROSSD","USDTB","SWAP_BRIDGE_ROUTER"],rs={BSC_CROSS:Ve,W_CROSS:Ve,NATIVE_CROSS:Ve,USDTX:Ve,CROSSD:Ve,USDTB:Ve,SWAP_BRIDGE_ROUTER:Ve},ss=/^0x[0-9a-fA-F]{40}$/;function is(e,t){let n=typeof e=="string"?e:e?.[t];return typeof n=="string"&&ss.test(n)?n:null}function as(e,t){if(!e?.bridge)return null;let n=e.envToNetwork?.[t]??(t==="production"?"mainnet":"testnet"),s={};for(let o of os){let a=is(e.bridge[o],n);if(!a)return null;s[o]=a}return s}var cs={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56}}},rt=[{type:"function",name:"quoter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"swapRouter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"getAmountSwapBridgeOut",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"swapAmountOut",type:"uint256"},{name:"bridgeValue",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"getAmountSwapBridgeIn",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"bridgeValue",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"amountIn",type:"uint256"},{name:"swapAmountOut",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"swapBridgeExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"swapBridgeExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountOut",type:"uint256"},{name:"amountInMaximum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountIn",type:"uint256"}]}],Xt=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Ln=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Fn=[{type:"function",name:"quoteExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amountIn",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]},{type:"function",name:"quoteExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]}],ds=[{type:"function",name:"slot0",stateMutability:"view",inputs:[],outputs:[{name:"sqrtPriceX96",type:"uint160"},{name:"tick",type:"int24"},{name:"observationIndex",type:"uint16"},{name:"observationCardinality",type:"uint16"},{name:"observationCardinalityNext",type:"uint16"},{name:"feeProtocol",type:"uint8"},{name:"unlocked",type:"bool"}]}],He=[{type:"function",name:"exactInputSingle",stateMutability:"payable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"recipient",type:"address"},{name:"deadline",type:"uint256"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"multicall",stateMutability:"payable",inputs:[{name:"data",type:"bytes[]"}],outputs:[{name:"results",type:"bytes[]"}]},{type:"function",name:"unwrapWETH9",stateMutability:"payable",inputs:[{name:"amountMinimum",type:"uint256"},{name:"recipient",type:"address"}],outputs:[]},{type:"function",name:"refundETH",stateMutability:"payable",inputs:[],outputs:[]}],ls=[{type:"function",name:"bridgeToken",stateMutability:"payable",inputs:[{name:"toChainID",type:"uint256"},{name:"fromToken",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gasFee",type:"uint256"},{name:"exFee",type:"uint256"},{name:"extraData",type:"bytes"}],outputs:[{name:"",type:"bool"}]}];async function Xn(e){let t="";try{t=await e.text()}catch{}if(t){try{let n=JSON.parse(t),s=typeof n.data=="string"&&n.data||typeof n.message=="string"&&n.message||"";if(s)return`${s} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function Ue(e,t){let n=await fetch(e,{cache:"no-store",signal:t});if(!n.ok)throw new Error(`CrossD bridge adapter request failed: ${await Xn(n)}`);let s=await n.json();if(s&&typeof s=="object"&&"code"in s&&typeof s.code=="number"&&s.code!==200)throw new Error(s.message||`CrossD bridge adapter API error: ${s.code}`);return s&&typeof s=="object"&&"data"in s?s.data:s}async function Un(e,t,n){let s=await fetch(e,{method:"POST",cache:"no-store",signal:n,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`CrossD bridge adapter request failed: ${await Xn(s)}`);let o=await s.json();if(o&&typeof o=="object"&&"code"in o&&typeof o.code=="number"&&o.code!==200)throw new Error(o.message||`CrossD bridge adapter API error: ${o.code}`);return o&&typeof o=="object"&&"data"in o?o.data:o}function us(e){return new Promise(t=>setTimeout(t,e))}async function ps(e,t,{attempts:n=60,intervalMs:s=2e3}={}){for(let o=0;o<n;o+=1){try{let a=await Ue(`${e}/permit-hash/${t}`);if(Zt(a))return a}catch{}await us(s)}return null}function ce(e,t){return`${e}-${t.toLowerCase()}`}function me(e){return ce(e.chainId,e.address)}function Me(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function ms(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"",n=t.toLowerCase();return n.includes("quoteexactinputsingle")||n.includes("quoteexactoutputsingle")||n.includes("getamountswapbridgeout")||n.includes("getamountswapbridgein")||n.includes("execution reverted")?"Amount is too large for this route.":t.split(`
1
+ var yt="1.5.1-beta.1";var Rt="__nexusCrossAppLauncherRuntime";function er(){if(typeof window>"u")return null;let e=window;return e[Rt]??(e[Rt]={mode:"dapp-ui"}),e[Rt]}function tr(e){if(e.scheduled)return;e.scheduled=!0;let t=()=>{if(e.scheduled=!1,e.loggedMode!==e.mode){if(e.mode==="connect-kit-react"){let n=e.connectKitVersion??yt;console.info(`[CROSSx App Launcher] connect-kit-react v${n} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${yt}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${yt} \uCD08\uAE30\uD654 \uC644\uB8CC (\uC0AC\uC6A9 \uBAA8\uB4DC: dapp-ui only)`);e.loggedMode=e.mode}};typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)}function wn(){let e=er();e&&(e.mode="connect-kit-react",e.connectKitVersion=yt,tr(e))}import{useCallback as Ne,useEffect as oe,useMemo as Fe,useRef as be,useState as Ye}from"react";import{WagmiProvider as pr,useAccount as mr,useChainId as fr,useConnect as gr,useDisconnect as yr,useSwitchChain as br}from"wagmi";import{QueryClient as hr,QueryClientProvider as Cr}from"@tanstack/react-query";import{attachEmbeddedAuthSync as wr,clearWalletSessionStorage as Sn,onOpenOtherWallets as kr,pickInitialState as Ir,resolveCurrentWallet as xr}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as vr}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as Tr}from"@nexus-cross/crossx-design-system";import{OnRampProvider as Pr}from"@nexus-cross/onramp/react";import{KycProvider as Sr}from"@nexus-cross/kyc/react";import{createContext as nr,useContext as or}from"react";var jt=nr(null);function Oe(){let e=or(jt);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}var rr=Oe;import{createContext as sr,useContext as kn}from"react";var At=sr(null);function In(){let e=kn(At);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function ut(){return kn(At)}var ir=In,ar=ut;import{createContext as cr}from"react";var Ot=cr(null);function xn(){let e=new Set,t=n=>{for(let s of[...e])try{s(n)}catch(o){console.debug("[crossx-kit] analytics handler threw",o)}};return{track:t,emit:n=>t({...n,timestamp:Date.now()}),subscribe:n=>(e.add(n),()=>{e.delete(n)})}}import{useCallback as dr,useMemo as vn}from"react";import{WalletConnectModal as Tn}from"@nexus-cross/dapp-ui";import{jsx as Pn}from"react/jsx-runtime";var lr=new Set(["cross_wallet","cross_extension","metamask","binance"]);function Et({open:e,onOpenChange:t}){let{connect:n,availableWallets:s,oauth:o,extraWallets:a,walletAllowlist:u,kitConfig:g}=Oe(),r=ut()?.mode??"dark",f=vn(()=>{let m=u?new Set(u):null,I={};for(let w of s){if(!lr.has(w.walletId)||m&&!m.has(w.walletId))continue;let T=w.walletId;I[T]=()=>{n(w.walletId)}}for(let[w,T]of Object.entries(a))T&&(m&&!m.has(w)||(I[w]=T));return I},[s,n,a,u]),b=vn(()=>{if(o)return{apple:()=>{o.signIn("apple")},google:()=>{o.signIn("google")}}},[o]),C=dr(m=>t(m),[t]);return Pn(Tn,{wallets:f,socialProviders:b,termsUrl:g.legal?.termsUrl,privacyUrl:g.legal?.privacyUrl,theme:r,open:e,onOpenChange:C,children:Pn(Tn.Content,{})})}var ur=Et;import{jsx as Je,jsxs as En}from"react/jsx-runtime";var Rr=new hr,Qt="crossx-kit:last-wallet-intent",Ar=15e3,Or=1500,Er=3;function Rn(e,t){return Promise.race([e.then(()=>{},()=>{}),new Promise(n=>setTimeout(n,t))])}function _r(e){let t=[],n=e,s=0;for(;n&&s<5;){let o=n;typeof o.message=="string"&&t.push(o.message),n=o.cause,s+=1}return t.some(o=>/external wallet connection/i.test(o))}function Br(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Qt)??null}catch{return null}}function An(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Qt,e):window.localStorage.removeItem(Qt)}catch{}}function Nr(e,t){if(typeof window>"u")return t;try{let n=window.localStorage.getItem(e);return n==="cross"||n==="reown"?n:t}catch{return t}}function Wr(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function Dr({children:e,config:t,activeProvider:n,onRequestProviderSwap:s,pendingConnectWalletId:o,clearPending:a,themeMode:u,themeTokens:g,extraWallets:d,walletAllowlist:r,emit:f}){let[b,C]=Ye(!1),[m,I]=Ye(()=>Br()),[w,T]=Ye(null),{address:U,isConnected:x,isConnecting:G,isReconnecting:A,connector:E}=mr(),{connectors:H,connectAsync:q}=gr(),{disconnectAsync:_}=yr(),{kitConfig:O,connectorRegistry:W,crossProvider:ee,reownProvider:re}=t,D=n==="cross"?ee:re,S=Fe(()=>!x||!E?null:xr(W,E.id,m),[x,E,W,m]),j=Fe(()=>W.entries.filter(p=>p.type!=="embedded"),[W]),te=Ne(p=>W.getEntry(p)?.type??"external",[W]),Qe=be(null);Qe.current=w;let Ce=be(S);Ce.current=S;let ge=be(U);ge.current=U;let le=O.embeddedProjectId?.trim()||O.crossProjectId?.trim(),we=!!O.onRampEnabled&&!!le,ze=Fe(()=>!we||!le?null:{projectId:le,walletState:{getAddress:()=>ge.current}},[we,le]),ke=be(E);ke.current=E;let _e=O.embeddedProjectId?.trim()||O.crossProjectId?.trim(),De=!!O.kycEnabled&&!!_e,Pe=Fe(()=>!De||!_e?null:{projectId:_e,getAccessToken:async()=>{let p=ke.current;if(!(!p||typeof p.getProvider!="function"))try{return(await(await p.getProvider())?.sdk?.getUserInfo?.())?.data?.accessToken||void 0}catch{return}}},[De,_e]);oe(()=>kr(()=>C(!0)),[]),oe(()=>{if(!b||typeof document>"u")return;let p=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(h=>h.remove())},50);return()=>clearTimeout(p)},[b]);let Se=be(x),nt=be(x);Se.current=x;let Ke=be(!1);oe(()=>{console.debug("[crossx-kit] state",{activeProvider:n,isConnected:x,isConnecting:G,isReconnecting:A,activeConnectorId:E?.id,currentWallet:S,lastIntent:m})},[n,x,G,A,E?.id,S,m]),oe(()=>{x&&!nt.current&&D?.closeModal?.({kitConfig:O}),nt.current=x},[x,D,O]),oe(()=>{x&&T(null)},[x]);let $e=fr(),{switchChainAsync:ct}=br(),Le=be(null);oe(()=>{if(!O.enforceDefaultNetworkOnConnect)return;let p=O.defaultNetwork?.id;if(!p)return;if(!x||!U||!E){Le.current=null;return}let h=`${E.id}:${U}`;Le.current!==h&&(Le.current=h,$e!==p&&ct({chainId:p}).catch(()=>{}))},[O.enforceDefaultNetworkOnConnect,O.defaultNetwork,x,U,E,$e,ct]);let ye=be(b);oe(()=>{b&&!ye.current?f({name:"connect_modal_opened"}):!b&&ye.current&&f({name:"connect_modal_closed",completed:Se.current}),ye.current=b},[b,f]);let Be=be(x);oe(()=>{if(x&&!Be.current){let p=Qe.current;p&&f({name:"connect_succeeded",walletId:p,walletType:te(p),chainId:$e})}Be.current=x},[x,$e,f,te]);let i=Ne(p=>H.find(h=>h.id===p),[H]);oe(()=>{let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;let v=!1;return(async()=>{try{let R=await h.getProvider();if(v)return;R?.sdk?.applyTheme?.(u,g??void 0)}catch(R){console.debug("[crossx-kit] applyTheme skipped:",R)}})(),()=>{v=!0}},[W,i,u,g]);let c=Ne(p=>{I(p),An(p)},[]),l=Ne(()=>{I(null),An(null),T(null)},[]);oe(()=>{if(!D?.subscribeModalState)return;let p=!1;return D.subscribeModalState({kitConfig:O},h=>{if(Ke.current=h,h){p=!0;return}p&&(p=!1,setTimeout(()=>{if(Se.current)return;let v=Qe.current;v&&f({name:"connect_cancelled",walletId:v,stage:"popup"}),(async()=>{try{await _()}catch{}l()})()},250))})},[D,O,_,l,f]),oe(()=>{if(!w||x||typeof window>"u"||w==="cross_embedded")return;let p=typeof document<"u"&&!document.hasFocus(),h=null,v=()=>{p=!0},R=()=>{p&&(h&&clearTimeout(h),h=setTimeout(()=>{if(Se.current||Ke.current)return;let N=Qe.current;N&&f({name:"connect_cancelled",walletId:N,stage:"popup"}),(async()=>{try{await _()}catch{}l()})()},1e3))};return window.addEventListener("blur",v),window.addEventListener("focus",R),()=>{window.removeEventListener("blur",v),window.removeEventListener("focus",R),h&&clearTimeout(h)}},[w,x,_,l,f]);let y=Ne(async p=>{console.debug("[crossx-kit] runConnect enter",{walletId:p,activeProvider:n,isConnected:x,activeConnectorId:E?.id});let h=W.getEntry(p);if(!h){if((p==="metamask"||p==="binance")&&!re){console.error(`[crossx-kit] "${p}" requires the Reown adapter, but it is not configured. Pass \`reownProjectId\` (and ensure \`reown\` is not set to \`false\`) when calling createConnectKitConfig() or createCrossxConfig() to enable WalletConnect-based wallets.`);return}console.error(`[crossx-kit] Unknown walletId: "${p}"`);return}if(T(p),h.providerKind!==n){console.debug("[crossx-kit] provider swap needed",{from:n,to:h.providerKind,walletId:p}),c(p);try{await _()}catch{}await new Promise(N=>setTimeout(N,0)),s(h.providerKind,p);return}let v=te(p);if(f({name:"wallet_selected",walletId:p,walletType:v}),f({name:"connect_started",walletId:p,walletType:v}),c(p),D?.beforeConnect)try{let N=await D.beforeConnect({kitConfig:O,themeMode:u},p);if(console.debug("[crossx-kit] beforeConnect result",{walletId:p,result:N}),N==="handled")return}catch(N){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',p,N)}let R=i(h.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:h.connectorId,found:R?.id,availableIds:H.map(N=>N.id)}),!R){console.error(`[crossx-kit] Connector "${h.connectorId}" not found on provider "${h.providerKind}". Available: ${H.map(N=>N.id).join(", ")}`),f({name:"connect_failed",walletId:p,reason:"connector_not_found"}),l();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:R.id});let N=await q({connector:R});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:N.accounts.length,chainId:N.chainId});return}catch(N){let Re=_r(N);if(!Re){console.error('[crossx-kit] connectAsync error for "%s":',p,N);try{await _()}catch{}}if(!h.fallbackConnectorId){Re||f({name:"connect_failed",walletId:p,reason:"connector_error"}),l();return}}if(h.fallbackConnectorId){let N=i(h.fallbackConnectorId);if(N)try{await q({connector:N})}catch(Re){console.error('[crossx-kit] Fallback connect failed for "%s":',p,Re);try{await _()}catch{}f({name:"connect_failed",walletId:p,reason:"fallback_failed"}),l()}else f({name:"connect_failed",walletId:p,reason:"fallback_failed"}),l()}},[W,H,i,q,_,c,l,D,n,O,s,u,f,te]);oe(()=>{if(!o)return;let p=o;a(),y(p)},[o,n]);let k=Ne(async()=>{C(!0)},[]),L=Ne(async()=>{f({name:"disconnected",walletId:Ce.current});try{await _()}catch(p){console.error("[crossx-kit] wagmi disconnect error:",p)}if(D?.teardown)try{await D.teardown({kitConfig:O})}catch(p){console.error("[crossx-kit] adapter teardown error:",p)}Sn(),l()},[_,D,O,l,f]),F=Ne(async()=>{await Rn(_(),3e3);try{let p=W.getEntry("cross_embedded"),h=p&&i(p.connectorId);if(h?.getProvider){let v=await Promise.race([h.getProvider(),new Promise(N=>setTimeout(N,3e3))]),R=v?.sdk?.signOut;typeof R=="function"&&await Rn(R.call(v.sdk),3e3)}}catch{}Sn()},[W,i,_]),B=Ne(async()=>{let p=W.getEntry("cross_embedded");if(!p)return null;let h=i(p.connectorId);if(!h)return null;try{let v=await h.getProvider(),R=v?.sdk;if(!R?.selectWallet)return null;let N=await R.selectWallet(R.currentAddress??void 0);return N?.address&&v.notifyAccountsChanged&&v.notifyAccountsChanged([N.address]),N&&f({name:"wallet_switched",index:N.index}),N}catch{return null}},[W,i,f]),K=Fe(()=>{let p=t.oauth;return p?{signIn:async h=>{T("cross_embedded"),f({name:"wallet_selected",walletId:"cross_embedded",walletType:"embedded"}),f({name:"connect_started",walletId:"cross_embedded",walletType:"embedded"});try{await p.signIn(h)}catch(v){let R=v?.code==="EMBEDDED_CONNECT_NOT_ESTABLISHED";throw f({name:"connect_cancelled",walletId:"cross_embedded",stage:R?"stalled":"popup"}),T(null),v}}}:null},[t.oauth,f]),Y=be(!1);oe(()=>{if(n!=="cross"||x||G||A||w!=null||Y.current)return;let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;Y.current=!0;let v=!1;return(async()=>{try{let R=await h.isAuthorized?.();if(v||!R)return;await q({connector:h})}catch{}})(),()=>{v=!0}},[n,x,G,A,w,W,i,q]);let P=be(0);oe(()=>{if(n!=="cross"||x||!G&&!A||P.current>=Er)return;let p=W.getEntry("cross_embedded");if(!p)return;let h=i(p.connectorId);if(!h)return;let v=!1,R=setInterval(()=>{(async()=>{if(v||Se.current)return;let N=await Promise.resolve(h.isAuthorized?.()).catch(()=>!1);if(!(v||!N||Se.current)){P.current+=1,console.warn("[crossx-kit] wagmi reconnect stalled while the SDK holds a session \u2014 forcing an explicit connect to realign");try{await q({connector:h})}catch{}}})()},Or);return()=>{v=!0,clearInterval(R)}},[n,x,G,A,W,i,q]),oe(()=>{if(w!=="cross_embedded"||x||typeof window>"u")return;let p=!document.hasFocus(),h=()=>{p=!0};window.addEventListener("blur",h);let v=setTimeout(()=>{Se.current||p||(console.warn("[crossx-kit] embedded sign-in stalled before the OAuth popup opened \u2014 clearing the stale session so a retry starts clean"),f({name:"connect_cancelled",walletId:"cross_embedded",stage:"stalled"}),l(),F())},Ar);return()=>{window.removeEventListener("blur",h),clearTimeout(v)}},[w,x,l,F,f]);let M=w!=null&&!x,Q=Fe(()=>({kitConfig:O,connectorRegistry:W,availableWallets:j,connect:y,connectWallet:k,disconnect:L,selectWallet:B,currentWallet:S,lastIntent:m,isConnecting:M,connectingWalletId:w,openOtherWallets:()=>C(!0),closeOtherWallets:()=>C(!1),otherWalletsOpen:b,oauth:K,extraWallets:d,walletAllowlist:r,onRampEnabled:we}),[O,W,j,y,k,L,B,S,m,M,w,b,K,d,r,we]),V=En(jt.Provider,{value:Q,children:[e,Je(Et,{open:b,onOpenChange:C})]});return Pe&&(V=Je(Sr,{config:Pe,children:V})),ze&&(V=Je(Pr,{config:ze,children:V})),V}var Lr=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function Fr(e){let t=e?.message;return typeof t!="string"?!1:Lr.some(n=>n.test(t))}var Ur={};function Mr(e){return e&&{...e,connections:new Map,current:null}}function On({children:e,config:t,initialState:n,extraWallets:s=Ur,walletAllowlist:o}){let[a,u]=Ye(()=>Nr(t.activeProviderStorageKey,t.defaultProvider)),[g,d]=Ye(null),r=be(!1),f=be(null);f.current||(f.current=xn());let b=f.current,C=Fe(()=>({subscribe:b.subscribe}),[b]),{kitConfig:m}=t,[I,w]=Ye(null),[T,U]=Ye(null),[x,G]=Ye(0),A=Fe(()=>vr(m.theme,m.autoDetectTheme),[m.theme,m.autoDetectTheme,x]),E=I??A,H=T??m.themeTokens;oe(()=>{if(!m.autoDetectTheme||I||typeof window>"u"||!window.matchMedia)return;let S=window.matchMedia("(prefers-color-scheme: dark)"),j=()=>G(te=>te+1);try{return S.addEventListener("change",j),()=>S.removeEventListener("change",j)}catch{return S.addListener(j),()=>S.removeListener(j)}},[m.autoDetectTheme,I]),oe(()=>{if(typeof document>"u")return;let S=document.documentElement,j=S.getAttribute("data-ds-theme"),te=S.getAttribute("data-theme");return S.setAttribute("data-ds-theme",E),te||S.setAttribute("data-theme",E),()=>{j==null?S.removeAttribute("data-ds-theme"):S.setAttribute("data-ds-theme",j),te==null&&S.removeAttribute("data-theme")}},[E]);let q=Fe(()=>Tr(t.designSystem),[t.designSystem]),_=Fe(()=>({mode:E,tokens:H,setThemeMode:S=>w(S),setThemeTokens:S=>U(S)}),[E,H]);oe(()=>{if(typeof window>"u")return;let S=j=>{Fr(j.reason)&&j.preventDefault()};return window.addEventListener("unhandledrejection",S),()=>window.removeEventListener("unhandledrejection",S)},[]),oe(()=>{if(a!=="cross")return;let S=t.crossWagmiConfig;if(S)return wr(S)},[a,t.crossWagmiConfig]);let O=Ne((S,j)=>{r.current||(r.current=!0,d(j),u(S),Wr(t.activeProviderStorageKey,S),queueMicrotask(()=>{r.current=!1}))},[t.activeProviderStorageKey]),W=Ne(()=>d(null),[]),ee=a==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,re=Mr(Ir(n,a));if(!ee){if(!(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let j=a==="cross"?"reown":"cross";queueMicrotask(()=>u(j))}let D=ee??(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return Je(Ot.Provider,{value:C,children:En(At.Provider,{value:_,children:[Je("style",{"data-crossx-design-system":"",children:q}),Je(pr,{config:D,initialState:re,children:Je(Cr,{client:Rr,children:Je(Dr,{config:t,activeProvider:a,onRequestProviderSwap:O,pendingConnectWalletId:g,clearPending:W,themeMode:E,themeTokens:H,extraWallets:s,walletAllowlist:o??t.kitConfig.wallets??null,emit:b.emit,children:e})})},a)]})})}var Gr=On;import{WalletInfo as pn}from"@nexus-cross/dapp-ui";import{APPLE_ICON as zi}from"@nexus-cross/connect-kit-wagmi";import{useCallback as je,useEffect as Si,useMemo as xt,useState as Ri}from"react";import{useQueryClient as Ai}from"@tanstack/react-query";import{useAccount as Oi,useChainId as Ei,useConfig as _i,useSendTransaction as Bi,useSwitchChain as Ni}from"wagmi";import{getPublicClient as dn,readContracts as yo}from"wagmi/actions";import{ConnectorId as tt,OnePopGetTokenTrigger as Wi,resolveEnvironment as Di,WALLET_REGISTRY as Li}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as Fi,useOptionalOnRampEligibility as Ui}from"@nexus-cross/onramp/react";import{APPLE_ICON as bo,BINANCE_ICON as ho,CROSSX_ICON as un,EXTENSION_ICON as Mi,GOOGLE_ICON as Co,METAMASK_ICON as wo}from"@nexus-cross/connect-kit-wagmi";import{WALLET_LABELS as vt}from"@nexus-cross/crossx-design-system";import{useCallback as si,useMemo as kt}from"react";import{useAccount as oo,useConfig as ro,useSwitchChain as ii,useWriteContract as ai}from"wagmi";import{readContract as ci,waitForTransactionReceipt as so}from"wagmi/actions";import{GetOneUsd as di,resolveEnvironment as li}from"@nexus-cross/dapp-ui";import{useCallback as ie,useMemo as Te,useRef as Kr}from"react";import{useQueries as Nn,useQuery as Ze}from"@tanstack/react-query";import{encodeFunctionData as bt,formatUnits as Lt,parseSignature as $r,parseUnits as Hr}from"viem";import{getChainId as zt,getPublicClient as Qn,readContract as We,signTypedData as qr,switchChain as Wn,waitForTransactionReceipt as Vr,writeContract as Dn}from"wagmi/actions";import{useConfig as jr}from"wagmi";async function _t(e,t,n){if(!(!n||t===void 0))try{if(e.getChainId()===t)return;await e.switchChain(t)}catch{}}var pt=10000n;function _n(e){let t=e==="auto"?1:Number(e||"1");return!Number.isFinite(t)||t<0?100n:BigInt(Math.min(1e4,Math.floor(t*100)))}function Bt(e,t){let n=_n(t);return n>=pt?0n:e*(pt-n)/pt}function Bn(e,t){let n=_n(t);return(e*(pt+n)+(pt-1n))/pt}function Qr(e){return e!=="bridge"}var Ve="0x0000000000000000000000000000000000000000",Ee=100,ft=18,zr=180000n,Xr=500000n,zn=new Set([56,97]),Yr=130n,Jr=100n,Zr={dev:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",stage:"https://stg-contents.crosstoken.io/frontend/game-token/json/hidden-path.json",production:"https://contents.crosstoken.io/frontend/game-token/json/hidden-path.json"},es={dev:"dev",stage:"stg",production:"prod"};function ts(e,t){let n=e?.[es[t]]?.hiddenPairs;if(!Array.isArray(n))return null;let s=n.filter(o=>!!o&&typeof o=="object"&&typeof o.fromKey=="string"&&typeof o.toKey=="string");return s.length>0?s:null}var ns={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/contracts.json",production:"https://contents.crosstoken.io/frontend/common/app-launcher/contracts.json"},os=["BSC_CROSS","W_CROSS","NATIVE_CROSS","USDTX","CROSSD","USDTB","SWAP_BRIDGE_ROUTER"],rs={BSC_CROSS:Ve,W_CROSS:Ve,NATIVE_CROSS:Ve,USDTX:Ve,CROSSD:Ve,USDTB:Ve,SWAP_BRIDGE_ROUTER:Ve},ss=/^0x[0-9a-fA-F]{40}$/;function is(e,t){let n=typeof e=="string"?e:e?.[t];return typeof n=="string"&&ss.test(n)?n:null}function as(e,t){if(!e?.bridge)return null;let n=e.envToNetwork?.[t]??(t==="production"?"mainnet":"testnet"),s={};for(let o of os){let a=is(e.bridge[o],n);if(!a)return null;s[o]=a}return s}var cs={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97}},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56}}},rt=[{type:"function",name:"quoter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"swapRouter",stateMutability:"view",inputs:[],outputs:[{name:"",type:"address"}]},{type:"function",name:"getAmountSwapBridgeOut",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"swapAmountOut",type:"uint256"},{name:"bridgeValue",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"getAmountSwapBridgeIn",stateMutability:"view",inputs:[{name:"toChainID",type:"uint256"},{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"bridgeValue",type:"uint256"}],outputs:[{name:"ok",type:"bool"},{name:"amountIn",type:"uint256"},{name:"swapAmountOut",type:"uint256"},{name:"networkFee",type:"uint256"},{name:"exFee",type:"uint256"}]},{type:"function",name:"swapBridgeExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"swapBridgeExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"amountOut",type:"uint256"},{name:"amountInMaximum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"bridgeParams",type:"tuple",components:[{name:"toChainID",type:"uint256"},{name:"recipient",type:"address"},{name:"extraData",type:"bytes"}]}]},{name:"deadline",type:"uint256"}],outputs:[{name:"amountIn",type:"uint256"}]}],Xt=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Ln=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Fn=[{type:"function",name:"quoteExactInputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amountIn",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]},{type:"function",name:"quoteExactOutputSingle",stateMutability:"nonpayable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"amount",type:"uint256"},{name:"fee",type:"uint24"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountIn",type:"uint256"},{name:"sqrtPriceX96After",type:"uint160"},{name:"initializedTicksCrossed",type:"uint32"},{name:"gasEstimate",type:"uint256"}]}],ds=[{type:"function",name:"slot0",stateMutability:"view",inputs:[],outputs:[{name:"sqrtPriceX96",type:"uint160"},{name:"tick",type:"int24"},{name:"observationIndex",type:"uint16"},{name:"observationCardinality",type:"uint16"},{name:"observationCardinalityNext",type:"uint16"},{name:"feeProtocol",type:"uint8"},{name:"unlocked",type:"bool"}]}],He=[{type:"function",name:"exactInputSingle",stateMutability:"payable",inputs:[{name:"params",type:"tuple",components:[{name:"tokenIn",type:"address"},{name:"tokenOut",type:"address"},{name:"fee",type:"uint24"},{name:"recipient",type:"address"},{name:"deadline",type:"uint256"},{name:"amountIn",type:"uint256"},{name:"amountOutMinimum",type:"uint256"},{name:"sqrtPriceLimitX96",type:"uint160"}]}],outputs:[{name:"amountOut",type:"uint256"}]},{type:"function",name:"multicall",stateMutability:"payable",inputs:[{name:"data",type:"bytes[]"}],outputs:[{name:"results",type:"bytes[]"}]},{type:"function",name:"unwrapWETH9",stateMutability:"payable",inputs:[{name:"amountMinimum",type:"uint256"},{name:"recipient",type:"address"}],outputs:[]},{type:"function",name:"refundETH",stateMutability:"payable",inputs:[],outputs:[]}],ls=[{type:"function",name:"bridgeToken",stateMutability:"payable",inputs:[{name:"toChainID",type:"uint256"},{name:"fromToken",type:"address"},{name:"to",type:"address"},{name:"value",type:"uint256"},{name:"gasFee",type:"uint256"},{name:"exFee",type:"uint256"},{name:"extraData",type:"bytes"}],outputs:[{name:"",type:"bool"}]}];async function Xn(e){let t="";try{t=await e.text()}catch{}if(t){try{let n=JSON.parse(t),s=typeof n.data=="string"&&n.data||typeof n.message=="string"&&n.message||"";if(s)return`${s} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function Ue(e,t){let n=await fetch(e,{cache:"no-store",signal:t});if(!n.ok)throw new Error(`CrossD bridge adapter request failed: ${await Xn(n)}`);let s=await n.json();if(s&&typeof s=="object"&&"code"in s&&typeof s.code=="number"&&s.code!==200)throw new Error(s.message||`CrossD bridge adapter API error: ${s.code}`);return s&&typeof s=="object"&&"data"in s?s.data:s}async function Un(e,t,n){let s=await fetch(e,{method:"POST",cache:"no-store",signal:n,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`CrossD bridge adapter request failed: ${await Xn(s)}`);let o=await s.json();if(o&&typeof o=="object"&&"code"in o&&typeof o.code=="number"&&o.code!==200)throw new Error(o.message||`CrossD bridge adapter API error: ${o.code}`);return o&&typeof o=="object"&&"data"in o?o.data:o}function us(e){return new Promise(t=>setTimeout(t,e))}async function ps(e,t,{attempts:n=60,intervalMs:s=2e3}={}){for(let o=0;o<n;o+=1){try{let a=await Ue(`${e}/permit-hash/${t}`);if(Zt(a))return a}catch{}await us(s)}return null}function ce(e,t){return`${e}-${t.toLowerCase()}`}function me(e){return ce(e.chainId,e.address)}function Me(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function ms(e){let t=e instanceof Error?e.message:typeof e=="string"?e:"",n=t.toLowerCase();return n.includes("quoteexactinputsingle")||n.includes("quoteexactoutputsingle")||n.includes("getamountswapbridgeout")||n.includes("getamountswapbridgein")||n.includes("execution reverted")?"Amount is too large for this route.":t.split(`
2
2
  `)[0]?.trim()||"Failed to quote bridge."}function Mn(e){return e===56||e===97?"BSC":e===612044||e===612055?"ONEchain":`Chain ${e}`}function ae(e,t){return t?t.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()?e.contracts.W_CROSS:t:Ve}function st(e){let t=Lt(e,ft);return t.includes(".")?t.replace(/\.?0+$/,""):t}function Ct(e){return Hr(e||"0",ft)}function he(e){try{return Ct(e||"0")}catch{return 0n}}function et(e){if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(Math.trunc(e));if(!e)return 0n;try{return BigInt(e)}catch{return 0n}}function Yt(e){let t=Lt(e,9);return(t.includes(".")?t.replace(/\.?0+$/,""):t)||"0"}function Nt(e){return e==="bridge"?zr:Xr}function Gn(e,t){if(!e||!t)return"0";let n=e*e;if(n===0n)return"0";let s=t*t,o=s>n?s-n:n-s;if(o===0n)return"0";let a=(o*100000000n+n/2n)/n;if(a>=100000000n)return"100";let u=a/1000000n,g=(a%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return g?`${u}.${g}`:`${u}`}function fs(e){if(!e||Number(e)===0)return"0%";let[t,n=""]=e.split("."),s=n.length>4?n.slice(0,4):n;return s?`${t}.${s}%`:`${t}%`}async function Kn(e,t,n,s,o,a=!1){let u=Qn(e,{chainId:t}),g=n;try{let r=await u?.estimateContractGas?.({account:o.account,address:o.address,abi:o.abi,functionName:o.functionName,args:o.args,value:o.value});typeof r=="bigint"&&r>0n&&(g=s?r*Yr/Jr:r)}catch{}let d={gas:g};if(zn.has(t))try{let r=await u?.getGasPrice?.();typeof r=="bigint"&&r>0n&&(d.gasPrice=r)}catch{}else if(a)try{let r=await u?.estimateFeesPerGas?.();typeof r?.maxFeePerGas=="bigint"&&(d.maxFeePerGas=r.maxFeePerGas),typeof r?.maxPriorityFeePerGas=="bigint"&&(d.maxPriorityFeePerGas=r.maxPriorityFeePerGas)}catch{}return d}function ht(){return BigInt(Math.floor(Date.now()/1e3)+1800)}var gs={100:"0.01%",500:"0.05%",3e3:"0.3%",1e4:"1%"};function ys(e){return gs[e]??`${e/1e4}%`}function bs(e,t){let n=Number(e||"0");return!Number.isFinite(n)||n<=0?"0":(n*t/1e6).toFixed(8).replace(/\.?0+$/,"")}function $n(e){return st(e)}function Hn(e,t){let n=Number(t??"0");return!Number.isFinite(n)||n<=0?0n:e*BigInt(Math.floor(n))/1000n}function Wt(e,t){if(!e)return!1;let n=e.toLowerCase();return t.some(s=>s.toLowerCase()===n)}function hs(e,t,n){return[{from:[e.contracts.USDTX],to:[e.contracts.CROSSD]},{from:[e.contracts.BSC_CROSS],to:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS]},{from:[e.contracts.NATIVE_CROSS,e.contracts.W_CROSS],to:[e.contracts.CROSSD]}].some(o=>Wt(t,o.from)&&Wt(n,o.to)||Wt(t,o.to)&&Wt(n,o.from))}function Cs(e){if(Me(e.type))return null;if(e.type==="swap-bridge"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}if(e.type==="bridge-swap"){let t=e.steps.find(n=>n.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}return{from:e.from.chainId,to:e.to.chainId,token:e.from.address}}function ws({input:e,path:t,config:n}){if(!n||Me(t.type))return"";let s=et(n.minimumValue),o=et(n.gasFee??n.gas_fee),a=t.type==="swap-bridge"?s+o*12n/10n:s;return a<=0n?"":e.fromAmount&&he(e.fromAmount)<a&&t.type!=="swap"?`Minimum ${$n(a)}`:t.type==="swap-bridge"&&e.toAmount&&he(e.toAmount)<a?`Available ${$n(a)} or more.`:""}function ks({input:e,path:t,config:n}){if(!n||t.type!=="bridge"&&t.type!=="bridge-swap")return"";let s=et(n.gasFee??n.gas_fee);if(s<=0n||!e.fromAmount)return"";let o=he(e.fromToken.balance||"0"),a=he(e.fromAmount);return o-s<a?`Insufficient network fee(${e.fromToken.symbol})`:""}function Is(e,t){let n=new Set;return e?.list?.forEach(s=>{let o=s.localChain??s.local_chain;o&&Object.entries(s.pairs||{}).forEach(([a,u])=>{u.forEach(g=>{g.localToken&&n.add(ce(o,g.localToken)),g.remoteToken&&n.add(ce(Number(a),g.remoteToken))})})}),Object.entries(t?.swapPools||t?.swap_pools||{}).forEach(([s,o])=>{o.forEach(a=>{a.token0&&n.add(ce(Number(s),a.token0)),a.token1&&n.add(ce(Number(s),a.token1))})}),n}function xs(e,t){return!e||!t?null:ce(e,t)}function vs({envConfig:e,bridgePairList:t,swapPools:n,tokenInfo:s,tokenStats:o}){let a=Is(t,n),u=new Map;o?.forEach(d=>{let r=xs(Number(d.chainId??d.chain_id),d.address);r&&u.set(r,d)});let g={};return a.forEach(d=>{let[r,f]=d.split("-"),b=Number(r),C=s?.find(I=>Number(I.chainId??I.chain_id)===b&&I.address?.toLowerCase()===f);if(!C?.symbol||!C.name)return;let m=u.get(d);g[d]={key:d,chainId:b,address:f,symbol:C.symbol,name:C.name,decimals:C.decimals||ft,image:C.image||C.icon_url,price:m?.price?Number(m.price):void 0,isNativeToken:f.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()}}),g}function Yn(e,t){return t?.list?.find(n=>(n.localChain??n.local_chain)===e)?.bridge||""}function Jn(e,t,n){let[s,o]=e.split("-"),[a,u]=t.split("-"),g=Number(s),d=Number(a);for(let r of n?.list||[]){if((r.localChain??r.local_chain)!==g)continue;let f=r.pairs?.[a];if(f){for(let b of f)if(b.localToken?.toLowerCase()===o&&b.remoteToken?.toLowerCase()===u)return{type:"bridge",fromChain:g,fromToken:o,toChain:d,toToken:u,bridgeAddress:Yn(g,n)}}}return null}function Zn(e,t,n,s){let o,a=1/0;for(let u of e||[]){let g=s(u.token0),d=s(u.token1);if(g===t&&d===n||d===t&&g===n){let r=u.fee??Ee;r<a&&(o=u,a=r)}}return o?{fee:a,poolAddress:o.poolAddress||o.pool_address||""}:null}function eo(e,t,n,s){let[o,a]=e.split("-"),[u,g]=t.split("-");if(o!==u)return null;let d=Number(o),r=(n?.swapPools||n?.swap_pools)?.[o];if(!r)return null;let f=s.contracts.W_CROSS.toLowerCase(),b=s.contracts.NATIVE_CROSS.toLowerCase(),m=Zn(r,a,g,w=>w?.toLowerCase()===f?b:w?.toLowerCase());if(!m)return null;let I="swap";return d===s.chainIds.cross&&(a===b&&(I="deposit-swap"),g===b&&(I="swap-withdraw")),{pathType:I,step:{type:"swap",chain:d,fromToken:a,toToken:g,fee:m.fee,poolAddress:m.poolAddress}}}function Ts(e,t,n,s){let[o,a]=e.split("-"),[u]=t.split("-");if(o===u)return null;let g=(n?.swapPools||n?.swap_pools)?.[o]||[],d=r=>r?.toLowerCase();for(let r of g){let f=d(r.token0),b=d(r.token1),C=f===a?b:b===a?f:null;if(!C)continue;let m=Jn(ce(Number(o),C),t,s);if(!m)continue;let I=Zn(g,a,C,d);return[{type:"swap",chain:Number(o),fromToken:a,toToken:C,fee:I?.fee??Ee,poolAddress:I?.poolAddress??""},m]}return null}function Ps(e,t,n,s,o){let[a,u]=e.split("-"),[g]=t.split("-");if(a===g)return null;for(let d of n?.list||[])if((d.localChain??d.local_chain)===Number(a))for(let r of d.pairs?.[g]||[]){if(r.localToken?.toLowerCase()!==u)continue;let f=r.remoteToken?.toLowerCase();if(!f)continue;let b=eo(ce(Number(g),f),t,s,o);if(b)return[{type:"bridge",fromChain:Number(a),fromToken:u,toChain:Number(g),toToken:f,bridgeAddress:Yn(Number(a),n)},b.step]}return null}function Ss({envConfig:e,bridgePairList:t,swapPools:n,enrichedTokens:s}){return(o,a)=>{let u=s[o],g=s[a];if(!u||!g||o===a)return null;let d=Jn(o,a,t);if(d)return{type:"bridge",steps:[d],from:u,to:g};let r=eo(o,a,n,e);if(r)return{type:r.pathType,steps:[r.step],from:u,to:g};let f=Ts(o,a,n,t);if(f)return{type:"swap-bridge",steps:f,from:u,to:g};let b=Ps(o,a,t,n,e);return b?{type:"bridge-swap",steps:b,from:u,to:g}:null}}function qn(e,t){return{name:e.name,symbol:e.symbol,chainId:e.chainId,address:e.address,decimals:e.decimals,balance:t.get(e.key)||"0",iconUrl:e.image,priceUsd:e.price}}function Rs(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function As(e){return e.includes(".")?e.replace(/\.?0+$/,"")||"0":e}function Os(e,t){let n=e.startsWith("-"),s=n?e.slice(1):e,[o,a=""]=s.split("."),u=a.slice(0,t).replace(/0+$/,""),g=u?`${o}.${u}`:o;return n?`-${g}`:g}function Es(e){let t=e.startsWith("-"),n=t?e.slice(1):e,[s,o]=n.split("."),a=s.replace(/\B(?=(\d{3})+(?!\d))/g,","),u=o?`${a}.${o}`:a;return t?`-${u}`:u}function Jt(e){if(e==null||e==="")return"0";let t=String(e),n=Number(t);return!Number.isFinite(n)||n===0?"0":Es(Os(t,4))}function Vn(e,t){if(e==null||e==="")return"0";try{return As(Lt(BigInt(String(e)),t.decimals))}catch{return"0"}}function Zt(e){return!!(e&&/^0x[0-9a-fA-F]+$/.test(e))}function _s(e){return e?new Date(e*1e3).toISOString():new Date().toISOString()}function Bs(e,t){return t.toLowerCase()===e.contracts.W_CROSS.toLowerCase()?e.contracts.NATIVE_CROSS:t}function Ns(e,t){let n=Rs(t);return{name:n,symbol:n,chainId:e,address:t,decimals:ft,balance:"0"}}function jn({envConfig:e,tokenByBridgeKey:t,chainId:n,address:s}){if(!s)return null;let o=Bs(e,s);return t.get(ce(n,o))||t.get(ce(n,s))||Ns(n,o)}function Dt(e){return e?.toLowerCase()||""}function Ws(e){if(e.source==="swap")return"swap";let t=Dt(e.fromToken??e.from_token),n=Dt(e.toToken??e.to_token),s=Dt(e.swapTokenIn??e.swap_token_in),o=Dt(e.swapTokenOut??e.swap_token_out);return n&&s&&n===s?"bridge-swap":t&&o&&t===o?"swap-bridge":"bridge"}function Ds(e,t){let n=e.status??0,s=e.extracallSuccess??e.extracall_success??!1;return t==="bridge-swap"&&n===1&&!s?"failed":n===1?"success":"pending"}function Ls({envConfig:e,item:t,tokenByBridgeKey:n}){let s=Number(t.fromChainID??t.from_chain_id??0),o=Number(t.toChainID??t.to_chain_id??0);if(!s||!o)return null;let a=Ws(t),u=t.swapTokenIn??t.swap_token_in,g=t.swapTokenOut??t.swap_token_out,d=t.swapAmountIn??t.swap_amount_in,r=t.swapAmountOut??t.swap_amount_out,f=t.fromToken??t.from_token,b=t.toToken??t.to_token,C=t.value,m=t.value;a==="swap"?(f=u,b=g,C=d,m=r):a==="swap-bridge"?(f=u,C=d,m=t.value):a==="bridge-swap"&&(b=g,C=d,m=r);let I=jn({envConfig:e,tokenByBridgeKey:n,chainId:s,address:f}),w=jn({envConfig:e,tokenByBridgeKey:n,chainId:o,address:b}),T=t.initiatedTxHash??t.initiated_tx_hash;return!I||!w||!Zt(T)?null:{id:`${T}-${t.index??""}`,timestamp:_s(t.initiatedTime??t.initiated_time),txHash:T,fromToken:I,toToken:w,fromAmount:Vn(C,I),toAmount:Vn(m,w),summary:{pathType:a},status:Ds(t,a)}}function Fs(e){let t=new Map;return e.flat().forEach(n=>{let s=Number(n.chainId??n.chain_id),o=n.address?.toLowerCase();if(!s||!o)return;let a=n.quantity?.numeric??n.balance??"0",u=n.quantity?.decimals??n.decimals??ft;try{t.set(ce(s,o),Lt(BigInt(a||"0"),u))}catch{t.set(ce(s,o),"0")}}),t}function qe(e,t="first"){let n=e.steps.filter(s=>s.type==="swap");return t==="last"?n[n.length-1]:n[0]}function Us(e,t){let n=(e?.swapPools||e?.swap_pools)?.[String(t.chainIds.cross)];if(!n?.length)return"";let s=t.contracts.CROSSD.toLowerCase(),o=t.contracts.USDTX.toLowerCase(),a=n.find(u=>{let g=u.token0?.toLowerCase(),d=u.token1?.toLowerCase();return g===s&&d===o||g===o&&d===s});return a?.poolAddress||a?.pool_address||""}function Ms(e,t){return e.from.chainId===t.chainIds.cross&&e.from.address.toLowerCase()===t.contracts.CROSSD.toLowerCase()&&e.to.chainId===t.chainIds.bsc&&e.to.address.toLowerCase()===t.contracts.USDTB.toLowerCase()}function Gs(e){if(e===void 0)return;let t=10n**BigInt(ft),n=e>=50000n*t?"normal":e>10000n*t?"low":"rebalancing",s=Number(e>0n?e*100n/(100000n*t):0n);return{label:"Available Liquidity",status:n,percentage:Math.min(s,100)}}function mt(e,t,n,s){let o=[e.from,e.to].find(a=>a.chainId===t&&a.address.toLowerCase()===n.toLowerCase())??s?.[ce(t,n)];return{symbol:o?.symbol||n.slice(0,6),iconUrl:o?.image}}function Ks(e,t){let n=[];for(let o of e.steps)o.type==="swap"?(n.push({chain:o.chain,address:o.fromToken}),n.push({chain:o.chain,address:o.toToken})):(n.push({chain:o.fromChain,address:o.fromToken}),n.push({chain:o.toChain,address:o.toToken}));let s=n.filter((o,a)=>a===0||!(o.chain===n[a-1].chain&&o.address.toLowerCase()===n[a-1].address.toLowerCase()));return s.length===0?[{symbol:e.from.symbol,iconUrl:e.from.image},{symbol:e.to.symbol,iconUrl:e.to.image}]:s.map(o=>mt(e,o.chain,o.address,t))}function $s({input:e,path:t,amountData:n,gasInfo:s,liquidity:o,enrichedTokens:a,priceImpact:u}){let g=e.fromAmount||"0",d=e.toAmount||"0",r=qe(t),f=t.steps.find(G=>G.type==="bridge"),b=t.type!=="bridge",C=!Me(t.type),m=r?bs(g,r.fee):"0",I=Number(g)>0||Number(d)>0,w=r?mt(t,r.chain,r.fromToken,a):{symbol:e.fromToken.symbol,iconUrl:e.fromToken.iconUrl},T=r?mt(t,r.chain,r.toToken,a):{symbol:e.toToken.symbol,iconUrl:e.toToken.iconUrl},U=f?mt(t,f.fromChain,f.fromToken,a):void 0,x=(G,A,E)=>I?A&&A>0n?{label:G,value:st(A),tone:"default",valueToken:E}:{label:G,value:"Free",tone:"accent"}:{label:G,value:"0"};return{pathType:t.type,priceImpact:u,liquidity:o,bridgeInfo:C&&f?[{label:"Route",value:`${Mn(f.fromChain)} \u2192 ${Mn(f.toChain)}`},x("Validator Fee",n?.exFee,U),x("Network Fee",n?.networkFee,U)]:void 0,swapInfo:b&&r?[{label:"Route",value:"",routeTokens:[mt(t,r.chain,r.fromToken,a),mt(t,r.chain,r.toToken,a)]},{label:"Price Impact",value:fs(u)},{label:"In Amount",value:Jt(g),valueToken:w},{label:r&&Me(t.type)?`Swap Fee (${ys(r.fee??Ee)})`:"Swap Fee",value:Jt(m),valueToken:w},{label:"Out Amount",value:Jt(d),valueToken:T}]:void 0,txFee:[...s?.gasPrice?[{label:"Gas Price",value:`${s.gasPrice} Gwei`}]:[{label:"Priority Fee Per Gas",value:`${s?.priorityFeePerGas||"0"} Gwei`},{label:"Max Fee Per Gas",value:`${s?.maxFeePerGas||"0"} Gwei`}],{label:"Gas Limit",value:s?.gasLimit||"0"}],txFeeInfo:s?{estTxFee:s.estTxFee,isDelegateFee:s.isDelegateFee,tokenIconUrl:s.gasCurrencyIconUrl,tokenSymbol:s.gasCurrencySymbol}:{estTxFee:"0",isDelegateFee:!1}}}function wt({env:e,walletAddress:t,enabled:n=!0,restoreChainAfterSwitch:s=!0}){let o=jr(),a=Kr(new Map),g=Ze({queryKey:["crossd-bridge-adapter",e,"remote-contracts"],queryFn:async({signal:i})=>{let c=as(await Ue(ns[e],i),e);if(!c)throw new Error("CrossD bridge adapter: invalid contracts.json");return c},enabled:n,staleTime:5*6e4}).data??null,d=n&&!!g,r=Te(()=>({...cs[e],contracts:g??rs}),[e,g]),f=Ze({queryKey:["crossd-bridge-adapter",e,"pairs"],queryFn:({signal:i})=>Ue(`${r.bridgeApi}/pairs`,i),enabled:d,staleTime:3e4}),b=Ze({queryKey:["crossd-bridge-adapter",e,"swap-pools"],queryFn:({signal:i})=>Ue(`${r.bridgeApi}/swap-pools`,i),enabled:d,staleTime:3e4}),C=Te(()=>Us(b.data,r),[r,b.data]),m=Ze({queryKey:["crossd-bridge-adapter",e,"available-liquidity",C],queryFn:async()=>await We(o,{address:r.contracts.USDTX,abi:Xt,functionName:"balanceOf",args:[C],chainId:r.chainIds.cross}),enabled:d&&!!C,staleTime:3e4}),I=Ze({queryKey:["crossd-bridge-adapter",e,"token-info"],queryFn:({signal:i})=>Ue(`${r.walletApi}/v1/public/token/info`,i),enabled:d,staleTime:3e4}),w=Ze({queryKey:["crossd-bridge-adapter",e,"token-stats"],queryFn:({signal:i})=>Ue(`${r.walletApi}/v1/public/token/stats`,i),enabled:d,staleTime:3e4}),T=Nn({queries:[r.chainIds.cross,r.chainIds.bsc].map(i=>({queryKey:["crossd-bridge-adapter",e,"balance",t,i],queryFn:({signal:c})=>{let l=new URLSearchParams({networkId:`eip155:${i}`,account:t||""});return Ue(`${r.walletApi}/v1/public/token/balance?${l}`,c)},enabled:d&&!!t,staleTime:0,refetchInterval:d&&t?5e3:!1}))}),U=Nn({queries:[r.chainIds.cross,r.chainIds.bsc].map(i=>({queryKey:["crossd-bridge-adapter",e,"gas-suggestion",i],queryFn:async({signal:c})=>{try{let k=await Qn(o,{chainId:i})?.estimateFeesPerGas?.();if(k?.maxFeePerGas||k?.gasPrice)return{fast:{maxFee:k.maxFeePerGas?.toString()||k.gasPrice?.toString(),maxPriorityFee:k.maxPriorityFeePerGas?.toString()||"0"}}}catch{}let l=new URLSearchParams({chain_id:String(i),without_gas_limit:"false"});return Ue(`${r.walletApi}/v1/public/transaction/gas-suggestion/dynamic?${l}`,c)},enabled:d,staleTime:1e4,retry:1}))}),x=Ze({queryKey:["crossd-bridge-adapter",e,"hidden-pairs"],queryFn:async({signal:i})=>ts(await Ue(Zr[e],i),e),enabled:d,staleTime:5*6e4,retry:1}),G=Te(()=>x.data??[],[x.data]),A=Te(()=>vs({envConfig:r,bridgePairList:f.data,swapPools:b.data,tokenInfo:I.data,tokenStats:w.data}),[f.data,r,b.data,I.data,w.data]),E=Te(()=>Ss({envConfig:r,bridgePairList:f.data,swapPools:b.data,enrichedTokens:A}),[f.data,A,r,b.data]),H=Te(()=>Fs(T.map(i=>i.data).filter(i=>Array.isArray(i))),[T]),q=Te(()=>{let i=new Map;return Object.values(A).forEach(c=>{let l=qn(c,H);i.set(c.key,l)}),i},[H,A]),_=Te(()=>{let i=new Map,c=q.get(ce(r.chainIds.cross,r.contracts.NATIVE_CROSS));c&&i.set(r.chainIds.cross,{symbol:c.symbol,iconUrl:c.iconUrl});let l=I.data?.find(y=>Number(y.chainId??y.chain_id)===r.chainIds.bsc&&(y.symbol??"").toUpperCase()==="BNB");return l&&i.set(r.chainIds.bsc,{symbol:l.symbol??"BNB",iconUrl:l.image??l.icon_url}),i},[r,q,I.data]),O=Ze({queryKey:["crossd-bridge-adapter",e,"history",t],queryFn:({signal:i})=>Un(`${r.bridgeApi}/history`,{owner:t,page:1,size:20,sort:"desc",status:"all"},i),enabled:d&&!!t,staleTime:0,refetchInterval:d&&t?5e3:!1}),W=Te(()=>(O.data?.histories||[]).map(i=>Ls({envConfig:r,item:i,tokenByBridgeKey:q})).filter(i=>!!i),[O.data?.histories,r,q]),ee=Te(()=>Gs(m.data),[m.data]),re=U[0]?.data,D=U[1]?.data,S=Te(()=>{let i=new Map;return re&&i.set(r.chainIds.cross,re),D&&i.set(r.chainIds.bsc,D),i},[D,re,r.chainIds.bsc,r.chainIds.cross]),j=ie((i,c,l)=>{let y=S.get(i.from.chainId)?.fast,k=c?l?.gasLimit??Nt(i.type):0n,L=l?.gasPrice&&l.gasPrice>0n?l.gasPrice:0n,F=l?.maxFeePerGas&&l.maxFeePerGas>0n?l.maxFeePerGas:0n,B=l?.maxPriorityFeePerGas&&l.maxPriorityFeePerGas>0n?l.maxPriorityFeePerGas:0n,K=et(y?.maxFee??y?.max_fee),Y=et(y?.maxPriorityFee??y?.max_priority_fee),P=F>0n?F:K>0n?K:L,M=B>0n?B:Y>0n?Y:P,Q=L>0n?L:P,X=zn.has(i.from.chainId)&&Q>0n,p=k*(X?Q:P),h=q.get(ce(i.from.chainId,r.contracts.NATIVE_CROSS)),v=i.type!=="swap-bridge",R=_.get(i.from.chainId);return{estTxFee:c?st(p):"0",priorityFeePerGas:c&&!X?Yt(M):"0",maxFeePerGas:c&&!X?Yt(P):"0",gasLimit:c?k.toString():"0",gasPrice:c&&X?Yt(Q):void 0,isDelegateFee:i.type==="swap-bridge"?!1:hs(r,i.from.address,i.to.address),tokenIconUrl:v?h?.iconUrl:void 0,tokenSymbol:v?h?.symbol:void 0,gasCurrencyIconUrl:R?.iconUrl,gasCurrencySymbol:R?.symbol}},[r,S,_,q]),te=ie(async i=>{let c=Cs(i);if(!c)return null;let l=`${e}:${c.from}:${c.to}:${c.token.toLowerCase()}`,y=a.current.get(l);if(y)return y;let k=(async()=>{let L=new URLSearchParams({from:String(c.from),to:String(c.to),token:c.token});try{return(await Ue(`${r.bridgeApi}/token-config?${L}`)).config??null}catch{return null}})();return a.current.set(l,k),k},[e,r.bridgeApi]),Qe=Te(()=>{let i=Object.values(A).map(l=>qn(l,H)),c=ce(r.chainIds.cross,r.contracts.CROSSD);return i.sort((l,y)=>{let k=me(l).toLowerCase()===c.toLowerCase(),L=me(y).toLowerCase()===c.toLowerCase();return k!==L?k?-1:1:me(l).localeCompare(me(y))})},[H,A,r]),Ce=Te(()=>{if(g)return{target:{chainId:r.chainIds.cross,address:r.contracts.CROSSD},swap:{from:{chainId:r.chainIds.cross,address:r.contracts.NATIVE_CROSS},feeDelegated:!0},bridge:{from:[{chainId:r.chainIds.bsc,address:r.contracts.USDTB},{chainId:r.chainIds.cross,address:r.contracts.USDTX}]}}},[r,g]),ge=ie(i=>{let c=me(i),l=c.toLowerCase(),y=[];Object.keys(A).forEach(F=>{let B=F.toLowerCase();if(l===B||G.some(P=>P.fromKey===l&&P.toKey===B))return;let K=E(c,F);if(!K)return;let Y=q.get(F);Y&&y.push({token:Y,path:K})});let k=ce(r.chainIds.cross,r.contracts.CROSSD),L=ce(r.chainIds.cross,r.contracts.NATIVE_CROSS);return y.sort((F,B)=>{if(l===k.toLowerCase()){let Q=me(F.token).toLowerCase()===L.toLowerCase(),X=me(B.token).toLowerCase()===L.toLowerCase();if(Q!==X)return Q?-1:1}let K=Me(F.path.type),Y=Me(B.path.type);if(K!==Y)return K?-1:1;let P=F.token.chainId===i.chainId,M=B.token.chainId===i.chainId;return P!==M?P?-1:1:me(F.token).localeCompare(me(B.token))}),y.map(F=>F.token)},[A,r,E,G,q]),le=ie(async i=>await We(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"quoter",chainId:i}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),we=ie(async i=>{zt(o)!==i&&await Wn(o,{chainId:i})},[o]),ze=ie(i=>_t({getChainId:()=>zt(o),switchChain:c=>Wn(o,{chainId:c})},i,s),[s,o]),ke=ie(async i=>await We(o,{address:r.contracts.SWAP_BRIDGE_ROUTER,abi:rt,functionName:"swapRouter",chainId:i}),[r.contracts.SWAP_BRIDGE_ROUTER,o]),_e=ie(async({path:i,step:c,amount:l,source:y})=>{let k=await le(c.chain),L=c.poolAddress?We(o,{address:c.poolAddress,abi:ds,functionName:"slot0",chainId:c.chain}).then(K=>K?.[0]).catch(()=>{}):Promise.resolve(void 0);if(y==="from"){let K=await We(o,{address:k,abi:Fn,functionName:"quoteExactInputSingle",args:[{tokenIn:ae(r,c.fromToken),tokenOut:ae(r,c.toToken),amountIn:Ct(l),fee:c.fee??Ee,sqrtPriceLimitX96:0n}],chainId:c.chain}),Y=Gn(await L,K[1]);return{amount:st(K[0]),path:i,priceImpact:Y}}let F=await We(o,{address:k,abi:Fn,functionName:"quoteExactOutputSingle",args:[{tokenIn:ae(r,c.fromToken),tokenOut:ae(r,c.toToken),amount:Ct(l),fee:c.fee??Ee,sqrtPriceLimitX96:0n}],chainId:c.chain}),B=Gn(await L,F[1]);return{amount:st(F[0]),path:i,priceImpact:B}},[r,le,o]),De=ie(async(i,c)=>{if(!t)throw new Error("Wallet is not connected.");let l=Nt(c.type);if(Me(c.type)){let P=qe(c,"first");if(!P)throw new Error("Swap route is not available.");let M=he(i.fromAmount),Q=he(i.toAmount);if(M<=0n)throw new Error("Bridge amount is empty.");if(Q<=0n)throw new Error("Bridge quote is not ready.");let X=await ke(P.chain),V=Bt(Q,i.slippage),p=c.type==="swap-withdraw"?Ve:t,h={tokenIn:ae(r,P.fromToken),tokenOut:ae(r,P.toToken),fee:P.fee??Ee,recipient:p,deadline:ht(),amountIn:M,amountOutMinimum:V,sqrtPriceLimitX96:0n};if(c.type==="swap-withdraw"){let v=bt({abi:He,functionName:"exactInputSingle",args:[h]}),R=bt({abi:He,functionName:"unwrapWETH9",args:[V,t]});return{address:X,abi:He,functionName:"multicall",args:[[v,R]],chainId:P.chain,fallbackGasLimit:l}}if(c.type==="deposit-swap"){let v=bt({abi:He,functionName:"exactInputSingle",args:[h]}),R=bt({abi:He,functionName:"refundETH",args:[]});return{address:X,abi:He,functionName:"multicall",args:[[v,R]],value:M,chainId:P.chain,fallbackGasLimit:l}}return{address:X,abi:He,functionName:"exactInputSingle",args:[h],chainId:P.chain,fallbackGasLimit:l}}if(c.type==="swap-bridge"){let P=qe(c,"first");if(!P)throw new Error("Swap bridge route is not available.");let M=he(i.fromAmount),Q=he(i.toAmount);if(M<=0n)throw new Error("Bridge amount is empty.");if(Q<=0n)throw new Error("Bridge quote is not ready.");let X=r.contracts.SWAP_BRIDGE_ROUTER,V=ht(),p={toChainID:BigInt(c.to.chainId),recipient:t,extraData:"0x"},h={tokenIn:ae(r,c.from.address),tokenOut:ae(r,P.toToken),fee:P.fee??Ee,sqrtPriceLimitX96:0n,bridgeParams:p};if(i.lastChangedBy==="to"){let R={...h,amountOut:Q,amountInMaximum:Bn(M,i.slippage)};return{address:X,abi:rt,functionName:"swapBridgeExactOutputSingle",args:[R,V],value:c.from.isNativeToken?R.amountInMaximum:void 0,chainId:c.from.chainId,fallbackGasLimit:l}}let v={...h,amountIn:M,amountOutMinimum:Bt(Q,i.slippage)};return{address:X,abi:rt,functionName:"swapBridgeExactInputSingle",args:[v,V],value:c.from.isNativeToken?M:void 0,chainId:c.from.chainId,fallbackGasLimit:l}}let y=c.steps.find(P=>P.type==="bridge");if(!y?.bridgeAddress)throw new Error("Bridge route is not available.");let k=he(i.fromAmount);if(k<=0n)throw new Error("Bridge amount is empty.");let L=await te(c),F=et(L?.gasFee??L?.gas_fee),B=Hn(k,L?.exFeeRate??L?.ex_fee_rate),K="0x";if(c.type==="bridge-swap"){let P=qe(c,"last");if(!P)throw new Error("Bridge swap route is not available.");let M=he(i.toAmount);if(M<=0n)throw new Error("Bridge quote is not ready.");let Q=await ke(c.to.chainId),X=Bt(M,i.slippage),V=bt({abi:He,functionName:"exactInputSingle",args:[{tokenIn:ae(r,P.fromToken),tokenOut:ae(r,P.toToken),fee:P.fee??Ee,recipient:t,deadline:ht(),amountIn:k,amountOutMinimum:X,sqrtPriceLimitX96:0n}]});K=`${Q}${V.slice(2)}`}let Y=[BigInt(c.to.chainId),c.from.address,t,k,F,B,K];return{address:y.bridgeAddress,abi:ls,functionName:"bridgeToken",args:Y,value:c.from.isNativeToken?k+B+F:void 0,chainId:c.from.chainId,fallbackGasLimit:l}},[r,te,ke,t]),Pe=ie(async(i,c)=>{if(c.type==="bridge"||c.type==="bridge-swap")return De(i,c);if(!t)throw new Error("Wallet is not connected.");let l=he(i.fromAmount);if(l<=0n)throw new Error("Bridge amount is empty.");if(c.type==="swap-bridge"){let F=qe(c,"first");if(!F)throw new Error("Swap bridge route is not available.");let B=r.contracts.SWAP_BRIDGE_ROUTER,K={tokenIn:ae(r,c.from.address),tokenOut:ae(r,F.toToken),fee:F.fee??Ee,sqrtPriceLimitX96:0n,bridgeParams:{toChainID:BigInt(c.to.chainId),recipient:t,extraData:"0x"},amountIn:l,amountOutMinimum:0n};return{address:B,abi:rt,functionName:"swapBridgeExactInputSingle",args:[K,ht()],value:c.from.isNativeToken?l:void 0,chainId:c.from.chainId,fallbackGasLimit:Nt(c.type)}}let y=qe(c,"first");if(!y)throw new Error("Swap route is not available.");let k=await ke(y.chain),L={tokenIn:ae(r,y.fromToken),tokenOut:ae(r,y.toToken),fee:y.fee??Ee,recipient:t,deadline:ht(),amountIn:l,amountOutMinimum:0n,sqrtPriceLimitX96:0n};return{address:k,abi:He,functionName:"exactInputSingle",args:[L],value:c.from.isNativeToken?l:void 0,chainId:y.chain,fallbackGasLimit:Nt(c.type)}},[De,r,ke,t]),Se=ie(async(i,c)=>{if(!t)return null;try{let l=await Pe(i,c),y=Me(c.type)||c.type==="swap-bridge",k=await Kn(o,l.chainId,l.fallbackGasLimit,y,{account:t,address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value},!0);return{gasLimit:k.gas,gasPrice:k.gasPrice,maxFeePerGas:k.maxFeePerGas,maxPriorityFeePerGas:k.maxPriorityFeePerGas}}catch{return null}},[Pe,o,t]),nt=ie(async i=>{let c=me(i.fromToken),l=me(i.toToken),y=E(c,l);if(!y)return{error:"Route is not available."};let k=i.lastChangedBy==="to"?i.toAmount:i.fromAmount,L=!!k&&Number(k)>0,F=Ms(y,r)?ee:void 0,B=async(V,p,h)=>{let v=L?await Se(V,y):null,R=j(y,L,v);return $s({input:V,path:y,gasInfo:R,amountData:p,liquidity:F,enrichedTokens:A,priceImpact:h})};if(!k||Number(k)<=0)return{fromAmount:i.fromAmount,toAmount:i.toAmount,summary:await B(i)};let K=await te(y),Y=et(K?.gasFee??K?.gas_fee),P=y.type==="bridge"||y.type==="bridge-swap"?{networkFee:Y}:void 0,M=y.type==="bridge"?i.lastChangedBy==="to"?{...i,fromAmount:i.toAmount}:{...i,toAmount:i.fromAmount}:i,Q=ws({input:M,path:y,config:K});if(Q)return{fromAmount:M.fromAmount,toAmount:M.toAmount,summary:await B(M,P),error:Q};let X=ks({input:M,path:y,config:K});if(X)return{fromAmount:M.fromAmount,toAmount:M.toAmount,summary:await B(M,P),error:X};if(y.type==="bridge")return{fromAmount:M.fromAmount,toAmount:M.toAmount,summary:await B(M,P)};try{if(y.type==="swap-bridge"){let v=qe(y,"first"),R=r.contracts.SWAP_BRIDGE_ROUTER;if(!v)return{error:"Swap bridge route is not ready."};let N=Ie=>_e({path:y,step:v,amount:Ie,source:"from"}).then(Xe=>Xe.priceImpact).catch(()=>{});if(i.lastChangedBy==="from"){let Ie=await We(o,{address:R,abi:rt,functionName:"getAmountSwapBridgeOut",args:[BigInt(y.to.chainId),ae(r,y.from.address),ae(r,v.toToken),v.fee??Ee,Ct(i.fromAmount)],chainId:y.from.chainId}),Xe=st(Ie[1]),Pt={...i,toAmount:Xe};return{toAmount:Xe,summary:await B(Pt,{networkFee:Ie[3],exFee:Ie[4]},await N(i.fromAmount))}}let Re=await We(o,{address:R,abi:rt,functionName:"getAmountSwapBridgeIn",args:[BigInt(y.to.chainId),ae(r,y.from.address),ae(r,v.toToken),v.fee??Ee,Ct(i.toAmount)],chainId:y.from.chainId}),ue=st(Re[1]),dt={...i,fromAmount:ue};return{fromAmount:ue,summary:await B(dt,{networkFee:Re[3],exFee:Re[4]},await N(ue))}}let V=y.type==="bridge-swap"?qe(y,"last"):qe(y,"first");if(!V)return{error:"Swap route is not available."};let p=await _e({path:y,step:V,amount:k,source:i.lastChangedBy});if(i.lastChangedBy==="from"){let v={...i,toAmount:p.amount};return{toAmount:p.amount,summary:await B(v,P,p.priceImpact)}}let h={...i,fromAmount:p.amount};return{fromAmount:p.amount,summary:await B(h,P,p.priceImpact)}}catch(V){return{fromAmount:i.fromAmount,toAmount:i.toAmount,summary:await B(i,P),error:ms(V)}}},[ee,j,A,r,Se,E,te,_e,o]),Ke=ie(async i=>{if(i.from.isNativeToken)return null;if(i.type==="swap"||i.type==="deposit-swap"||i.type==="swap-withdraw")return ke(i.from.chainId);if(i.type==="swap-bridge")return r.contracts.SWAP_BRIDGE_ROUTER;let c=i.steps.find(l=>l.type==="bridge");return c?.bridgeAddress?c.bridgeAddress:null},[r.contracts.SWAP_BRIDGE_ROUTER,ke]),$e=ie(async i=>{if(!t)throw new Error("Wallet is not connected.");let c=me(i.fromToken),l=me(i.toToken),y=E(c,l);if(!y)throw new Error("Route is not available.");if(!Me(y.type)&&y.type!=="swap-bridge"||y.from.isNativeToken)return null;let k=he(i.fromAmount);if(k<=0n)return null;let L=await Ke(y);return!L||await We(o,{address:y.from.address,abi:Xt,functionName:"allowance",args:[t,L],chainId:y.from.chainId})>=k?null:{token:i.fromToken,tokenAddress:y.from.address,spenderAddress:L,amount:i.fromAmount}},[E,Ke,o,t]),ct=ie(async(i,c)=>{let l=he(c.amount||i.fromAmount);if(l<=0n)throw new Error("Approval amount is empty.");await we(c.token.chainId);let y=await Dn(o,{address:c.tokenAddress,abi:Xt,functionName:"approve",args:[c.spenderAddress,l],chainId:c.token.chainId});await Vr(o,{hash:y,chainId:c.token.chainId})},[we,o]),Le=ie(async(i,c)=>{let l=await De(i,c);await we(l.chainId);let y=await Kn(o,l.chainId,l.fallbackGasLimit,Qr(c.type),{account:t,address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value});return{txHash:await Dn(o,{address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value,chainId:l.chainId,...y}),fromToken:i.fromToken,toToken:i.toToken,fromAmount:i.fromAmount,toAmount:i.toAmount}},[De,we,o,t]),ye=ie(async(i,c)=>{let l=t;if(!l)throw new Error("Wallet is not connected.");let y=c.steps.find(Xe=>Xe.type==="bridge");if(!y?.bridgeAddress)throw new Error("Bridge route is not available.");let k=c.from.address,L=c.from.chainId,F=he(i.fromAmount);if(F<=0n)throw new Error("Bridge amount is empty.");let B=await te(c),K=et(B?.gasFee??B?.gas_fee),Y=Hn(F,B?.exFeeRate??B?.ex_fee_rate),P=F+Y+K,[M,Q]=await Promise.all([We(o,{address:k,abi:Ln,functionName:"name",chainId:L}),We(o,{address:k,abi:Ln,functionName:"nonces",args:[l],chainId:L})]),X=BigInt(Math.floor(Date.now()/1e3)+300),V=await qr(o,{domain:{name:M,version:"1",chainId:L,verifyingContract:k},types:{Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:l,spender:y.bridgeAddress,value:P,nonce:Q,deadline:X}}),{r:p,s:h,v,yParity:R}=$r(V),N=v!==void 0?Number(v):R+27,Re={exFee:Y.toString(),from:L,fromToken:k,nonce:Number(Q),gasFee:K.toString(),permitArgs:{account:l,deadline:X.toString(),r:p,s:h,token:k,v:N,value:P.toString()},to:l,toChainID:String(c.to.chainId),value:P.toString()},ue=await Un(`${r.bridgeApi}/permit`,Re),dt=ue?.requestId??ue?.request_id;if(!dt)throw new Error("Bridge permit request failed.");let Ie=await ps(r.bridgeApi,dt);if(!Zt(Ie))throw new Error("Bridge submitted, but confirmation timed out. Check History shortly.");return{txHash:Ie,fromToken:i.fromToken,toToken:i.toToken,fromAmount:i.fromAmount,toAmount:i.toAmount}},[r,te,o,t]),Be=ie(async i=>{let c=zt(o),l=me(i.fromToken),y=me(i.toToken),k=E(l,y);if(!k)throw new Error("Route is not available.");if(!(Me(k.type)||k.type==="swap-bridge"||k.type==="bridge-swap"||k.type==="bridge"))throw new Error("This bridge route is not supported yet.");let B=k.type==="bridge"&&k.from.chainId===r.chainIds.bsc&&k.from.address.toLowerCase()===r.contracts.BSC_CROSS.toLowerCase()?await ye(i,k):await Le(i,k);return await ze(c),{...B,pathType:k.type,routeTokens:Ks(k,A)}},[A,r,E,ze,ye,Le,o]);return{bridgeTokens:Qe,bridgeHistory:W,getBridgeApproval:$e,approveBridge:ct,getBridgeQuote:nt,getBridgeToTokens:ge,submitBridge:Be,oneUsdPairs:Ce,isLoading:f.isLoading||b.isLoading||I.isLoading||w.isLoading||T.some(i=>i.isLoading)}}import{useEffect as Hs,useMemo as to}from"react";import{useAccount as qs,useConfig as Vs,useSendTransaction as js,useSwitchChain as Qs,useWriteContract as zs}from"wagmi";import{getBalance as Xs,readContract as Ys,readContracts as Js,waitForTransactionReceipt as Zs}from"wagmi/actions";import{RelayDeposit as en}from"@nexus-cross/dapp-ui";import{jsx as ri}from"react/jsx-runtime";var ei=56,ti=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{name:"",type:"string"}]}],it=e=>e,no=!1;function gt(){let{address:e,chainId:t}=qs(),n=Vs(),{sendTransactionAsync:s}=js(),{writeContractAsync:o}=zs(),{switchChainAsync:a}=Qs(),u=n.chains.some(d=>d.id===ei);Hs(()=>{u||no||(no=!0,console.warn("[connect-kit] CrossRelayDeposit: BNB Smart Chain (56) is not in the wagmi config \u2014 one-click deposit verification and fund recovery are disabled. Add `bsc` to `createCrossxConfig({ networks })` to enable them."))},[u]);let g=to(()=>({sendTransaction:async({chainId:d,to:r,value:f,data:b})=>s({chainId:it(d),to:r,value:f,data:b}),writeContract:async({chainId:d,address:r,abi:f,functionName:b,args:C})=>o({chainId:it(d),address:r,abi:f,functionName:b,args:C}),readContract:u?async({chainId:d,address:r,abi:f,functionName:b,args:C})=>Ys(n,{chainId:it(d),address:r,abi:f,functionName:b,args:C}):void 0,switchChain:async d=>{await a({chainId:it(d)})},waitForReceipt:async({chainId:d,hash:r})=>({status:(await Zs(n,{chainId:it(d),hash:r})).status==="success"?"success":"reverted"}),getBalance:async({chainId:d,address:r,token:f})=>{if(!f){let T=await Xs(n,{chainId:it(d),address:r});return{value:T.value,decimals:T.decimals,symbol:T.symbol}}let b={address:f,abi:ti,chainId:it(d)},C=await Js(n,{contracts:[{...b,functionName:"balanceOf",args:[r]},{...b,functionName:"decimals"},{...b,functionName:"symbol"}],allowFailure:!1}),[m,I,w]=C;return{value:m,decimals:I,symbol:w}}}),[n,u,s,o,a]);return to(()=>({walletAddress:e,walletChainId:t,...g}),[e,t,g])}function ni(e){let t=gt();return ri(en,{...t,...e,requireWalletConnection:!0})}var oi=Object.assign(ni,{Trigger:en.Trigger,Content:en.Content});import{jsx as ui}from"react/jsx-runtime";var Ft=e=>e;function io(){let{chainId:e}=oo(),t=ro(),{writeContractAsync:n}=ai(),{switchChainAsync:s}=ii(),o=kt(()=>({readContract:async({chainId:a,address:u,abi:g,functionName:d,args:r})=>ci(t,{chainId:Ft(a),address:u,abi:g,functionName:d,args:r}),writeContract:async({chainId:a,address:u,abi:g,functionName:d,args:r})=>n({chainId:Ft(a),address:u,abi:g,functionName:d,args:r}),switchChain:async a=>{await s({chainId:Ft(a)})},waitForReceipt:async({chainId:a,hash:u})=>({status:(await so(t,{chainId:Ft(a),hash:u})).status==="success"?"success":"reverted"})}),[t,s,n]);return kt(()=>({...o,walletChainId:e}),[e,o])}function tn({env:e,pairs:t,bridgeOptions:n,relay:s,stake:o,restoreChainAfterSwitch:a=!0,waitForTransaction:u,onRequestConnect:g,...d}){let r=li(e),{address:f}=oo(),b=ro(),{connectWallet:C}=Oe(),m=gt(),I=io(),w=wt({env:r,walletAddress:f,enabled:!0,restoreChainAfterSwitch:a}),{bridgeHistory:T,getBridgeQuote:U,getBridgeToTokens:x,getBridgeApproval:G,approveBridge:A,submitBridge:E}=w,H=kt(()=>({...n,history:T,getQuote:U,getToTokens:x,getApproval:G,approveBridge:A,submitBridge:E}),[A,T,n,G,U,x,E]),q=kt(()=>({...s,...m}),[s,m]),_=kt(()=>({...o,...I}),[o,I]),O=si(async W=>{if((await so(b,{hash:W.txHash,chainId:W.fromToken.chainId})).status!=="success")throw new Error("Transaction reverted.")},[b]);return ui(di,{...d,env:r,walletAddress:f,tokens:w.bridgeTokens,pairs:t??w.oneUsdPairs,loading:w.isLoading,bridge:H,relay:q,stake:_,waitForTransaction:u??O,onRequestConnect:g??C})}import{useEffect as ao,useRef as pi,useState as co}from"react";import{useAccount as mi}from"wagmi";function Ut(e){let{address:t,connector:n}=mi(),{currentWallet:s}=Oe(),o=e?.walletId!==void 0?e.walletId:s,a=e?.connector!==void 0?e.connector:n,u=e?.address!==void 0?e.address:t,[g,d]=co({loginType:null,accountName:null,accounts:[],isResolved:!1}),r=pi(new Map),[f,b]=co(0);return ao(()=>{let C=!1;if(o!=="cross_embedded")return d({loginType:null,accountName:null,accounts:[],isResolved:!0}),()=>{C=!0};if(!a)return d({loginType:null,accountName:null,accounts:[],isResolved:!1}),()=>{C=!0};d(T=>({...T,isResolved:!1}));let m=20,I=300,w=async()=>{if(typeof a.getProvider!="function")return"retry";let T;try{T=await a.getProvider()}catch{return"retry"}let U=T?.sdk;if(!U)return"giveup";try{let D=U.getRNBridgeActiveWallet?.(),S=D?.walletName?.trim();D&&S&&r.current.set(D.address.toLowerCase(),S)}catch{}let[x,G]=await Promise.all([U.getUserInfo?.().catch(()=>null)??null,U.getAddresses?.().catch(()=>null)??null]);if(C)return"done";let A=x?.loginType,E=A==="google"||A==="apple"?A:null;if(!E)return"retry";let H=u?.toLowerCase(),q=H&&Array.isArray(G)?G.find(D=>D.address.toLowerCase()===H):null,_=Array.isArray(G)?G.filter(D=>/^0x[a-fA-F0-9]{40}$/.test(D.address)).map(D=>({address:D.address.toLowerCase(),...Number.isFinite(D.index)?{index:D.index}:{},...D.name?.trim()?{name:D.name.trim()}:{}})):[],O=H?r.current.get(H)?.trim():void 0,W=!q&&H&&/^0x[a-fA-F0-9]{40}$/.test(H)?[..._,{address:H,index:_.length,...O?{name:O}:{}}]:_,re=O||q?.name?.trim()||(typeof q?.index=="number"?`Account ${q.index+1}`:u?`${u.slice(0,6)}\u2026${u.slice(-4)}`:null);return d({loginType:E,accountName:re,accounts:W,isResolved:!0}),"done"};return(async()=>{for(let T=0;T<m;T++){if(C)return;let U=await w();if(U==="done")return;if(U==="giveup"){C||d({loginType:null,accountName:null,accounts:[],isResolved:!0});return}await new Promise(x=>setTimeout(x,I))}C||d({loginType:null,accountName:null,accounts:[],isResolved:!0})})(),()=>{C=!0}},[o,a,u,f]),ao(()=>{if(o!=="cross_embedded"||!a||typeof a.getProvider!="function")return;let C=!1,m;return(async()=>{let I;try{I=await a.getProvider()}catch{return}if(C)return;let w=I?.sdk;w?.on&&(m=w.on("addressChanged",({address:T,walletName:U})=>{let x=U?.trim();x&&(r.current.set(T.toLowerCase(),x),b(G=>G+1))}))})(),()=>{C=!0,m?.()}},[o,a]),g}var fi=Ut;import{useCallback as mo,useMemo as Gt,useRef as bi,useState as hi}from"react";import{useQuery as Ci}from"@tanstack/react-query";import{useAccount as wi,useSignMessage as ki}from"wagmi";import{CrossAuthClient as Ii,getPopContractsForEnvironment as xi,HttpSafeDropApiAdapter as vi,resolvePopEnvironment as Ti}from"@nexus-cross/pop/api";function lo(e,t){let n=[];for(let s of t)s.rejected||n.push({id:`pending-${s.claimAddress}`,direction:"received",handle:s.sender.handle||s.sender.address,...s.sender.profileImageUrl?{avatarUrl:s.sender.profileImageUrl}:{},amountRaw:s.amount.toString(),decimals:18,timestamp:Date.parse(s.depositedAt)||0,status:"ready"});for(let s of e){let o=s.status.toLowerCase(),a=(s.resolvedAt?Date.parse(s.resolvedAt):0)||Date.parse(s.depositedAt)||0,u={id:`${s.type}-${s.id}`,amountRaw:s.amount.toString(),decimals:18,timestamp:a};if(s.type==="sent"){n.push({...u,direction:"sent",handle:s.receiver.displayHandle||s.receiver.handle||s.receiver.address||"",...s.receiver.profileImageUrl?{avatarUrl:s.receiver.profileImageUrl}:{},status:o==="claimed"?"claimed":o==="refunded"?"refunded":"waiting"});continue}o==="claimed"&&n.push({...u,direction:"received",handle:s.sender.displayHandle||s.sender.handle||s.sender.address,...s.sender.profileImageUrl?{avatarUrl:s.sender.profileImageUrl}:{},status:"claimed"})}return n.sort((s,o)=>o.timestamp-s.timestamp),n}var nn="one-pop:replies-seen:";function on(e){let t=[],n=new Set;for(let s of e)s.type==="sent"&&(!s.feedback||!s.feedback.trim()||n.has(s.id)||(n.add(s.id),t.push(s.id)));return t}function rn(e,t){let n=0;for(let s of e)t.has(s)||(n+=1);return n}function sn(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function an(e){return`${nn}${e.toLowerCase()}`}function gi(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="number"&&Number.isFinite(n)):[]}catch{return[]}}function Mt(e){if(!e)return new Set;let t=sn();if(!t)return new Set;try{return new Set(gi(t.getItem(an(e))))}catch{return new Set}}function uo(e,t){let n=Mt(e);if(!e||t.length===0)return n;let s=n.size;for(let u of t)n.add(u);if(n.size===s)return n;let o=Array.from(n).slice(-200),a=sn();if(a)try{a.setItem(an(e),JSON.stringify(o))}catch{}return new Set(o)}function yi(e){let t=sn();if(t)try{if(e){t.removeItem(an(e));return}let n=[];for(let s=0;s<t.length;s++){let o=t.key(s);o?.startsWith(nn)&&n.push(o)}for(let s of n)t.removeItem(s)}catch{}}var go="one-pop-summary",fo=20,It=new Map;function Pi(e){e?It.delete(e.toLowerCase()):It.clear()}function cn(e={}){let{enabled:t=!1,environment:n,token:s,apiBaseUrl:o,authBaseUrl:a,getJwt:u,repliesWaitingCount:g}=e,d=Gt(()=>{if(s)return s;let _=Ti(n);return xi(_).permitErc20},[s,n]),{address:r,chainId:f}=wi(),{signMessageAsync:b}=ki(),C=bi(null),m=mo(async()=>{if(u)return u();if(!r||!f)return;let _=r.toLowerCase(),O=It.get(_);if(O)return O;if(C.current)return C.current;let W=(async()=>{let ee=new Ii(a?{baseUrl:a}:{}),{message:re}=await ee.unsignedHash(f,r),D=await b({message:re}),{token:S}=await ee.siweToken(r,D);return It.set(_,S),S})();C.current=W;try{return await W}catch(ee){throw It.delete(_),ee}finally{C.current=null}},[u,r,f,a,b]),I=Gt(()=>new vi({...o?{baseUrl:o}:{},getJwt:m}),[o,m]),w=Ci({queryKey:[go,r?.toLowerCase()??null,d.toLowerCase()],enabled:t&&!!r,retry:!1,refetchOnWindowFocus:!1,staleTime:6e4,queryFn:async()=>{let[_,O,W,ee]=await Promise.all([I.listDrops({token:d}).catch(()=>null),I.listHistories({type:"sent",page:1,pageSize:fo}).catch(()=>null),I.listHistories({type:"received",page:1,pageSize:fo}).catch(()=>null),I.getXConnection().catch(()=>null)]),re=O?.items??[];return{drops:_,items:[...re,...W?.items??[]],replyIds:on(re),xConnected:!!ee}}}),[T,U]=hi(0),x=r?.toLowerCase(),G=Gt(()=>Mt(x),[x,T]),A=w.data?.replyIds,E=mo(()=>{!x||!A?.length||(uo(x,A),U(_=>_+1))},[x,A]),H=g??(A?rn(A,G):0);return{summary:Gt(()=>{if(!t||!r)return;if(!w.data)return w.isLoading?{claimableCount:0,claimableTotalRaw:"0",claimableDecimals:18,repliesWaitingCount:H,activity:[],xConnected:!1,isLoading:!0}:void 0;let{drops:_,items:O,xConnected:W}=w.data;return{claimableCount:_?.count??0,claimableTotalRaw:(_?.totalAmount??0n).toString(),claimableDecimals:18,repliesWaitingCount:H,activity:lo(O,_?.items??[]),xConnected:W,isLoading:!1}},[t,r,w.data,w.isLoading,H]),isLoading:w.isLoading,error:w.error??null,refetch:w.refetch,markRepliesSeen:E}}import{jsx as Qi}from"react/jsx-runtime";var Gi=[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]}],Ki=[{type:"function",name:"earned",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"posaActive",stateMutability:"view",inputs:[],outputs:[{name:"",type:"bool"}]},{type:"function",name:"lastRewardBlock",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"totalStaked",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint256"}]}],$i={dev:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},stage:{poolAddress:"0x0000000c5BB5C7B081237B5efaFC753D61201b94",crossChainId:612044,networkStatsUrl:"https://stg-posa-api.crosstoken.io/api/v1/network/stats"},production:{poolAddress:"0x000000068122d9bB43B4BCF5497A10EdfA9F5E93",crossChainId:612055,networkStatsUrl:"https://posa-api.crosstoken.io/api/v1/network/stats"}},ln=10n**18n,Hi={google:{name:"Google",iconUrl:Co,connectorId:tt.CROSSx},apple:{name:"Apple",iconUrl:bo,connectorId:tt.CROSSx},cross:{name:vt.default,iconUrl:un,connectorId:tt.CROSSx},metamask:{name:"MetaMask",iconUrl:wo,connectorId:tt.MetaMask},binance:{name:"Binance Wallet",iconUrl:ho,connectorId:tt.Binance}};function qi(e){switch(e){case"cross_embedded":return tt.CROSSx;case"metamask":return tt.MetaMask;case"binance":return tt.Binance;default:return}}function Vi(e,t){switch(e){case"cross_embedded":return t==="google"?{name:"Google",iconUrl:Co}:t==="apple"?{name:"Apple",iconUrl:bo}:{name:vt.default,iconUrl:un};case"cross_wallet":return{name:vt.default,iconUrl:un};case"cross_extension":return{name:vt.extension,iconUrl:Mi};case"metamask":return{name:"MetaMask",iconUrl:wo};case"binance":return{name:"Binance Wallet",iconUrl:ho};default:return null}}function ji(e){if(e)return e==="cross_embedded"?vt.default:Li[e]?.name}function Kt({user:e,enablePortfolio:t,portfolio:n,theme:s,accountName:o,connectorId:a,showPortfolio:u,sendAccounts:g,getTransactionReceipt:d,sendTransaction:r,estimateGas:f,onDisconnect:b,onSelectWallet:C,onBuy:m,onRampRedirectUrl:I,onePopSummary:w,onOnePopOpen:T,onePopGetTokenSlot:U,onePopGetTokenOptions:x,showOnePop:G,bridgeTokens:A,bridgeHistory:E,getBridgeQuote:H,getBridgeToTokens:q,getBridgeApproval:_,approveBridge:O,submitBridge:W,showBalance:ee=!0,env:re,...D},{page:S=!1}={}){let{address:j,isConnected:te,connector:Qe,chain:Ce}=Oi(),ge=_i(),le=Ei(),{switchChainAsync:we}=Ni(),{sendTransactionAsync:ze}=Bi(),{connectWallet:ke,disconnect:_e,selectWallet:De,currentWallet:Pe,isConnecting:Se,kitConfig:nt}=Oe(),Ke=nt?.restoreChainAfterSwitch!==!1,$e=!!nt?.onePopEnabled,ct=ut(),Le=s??ct?.mode??"dark",ye=xt(()=>Di(re),[re]),Be=e?.address??j,i=e?Hi[e.provider]:null,{loginType:c,accountName:l,accounts:y}=Ut({walletId:Pe,connector:Qe,address:Be}),k=xt(()=>i?{name:i.name,iconUrl:i.iconUrl}:Vi(Pe,c),[i,Pe,c]),L=o??e?.name??l??void 0,F=D.connectorName??(i?i.name:ji(Pe)),B=i?i.connectorId:qi(Pe),K=a??B,Y=n??u??!!t,P=wt({env:ye,walletAddress:Be,enabled:!S&&te&&!!Be&&ee,restoreChainAfterSwitch:Ke}),M=A??P.bridgeTokens,Q=E??P.bridgeHistory,X=H??P.getBridgeQuote,V=q??P.getBridgeToTokens,p=_??P.getBridgeApproval,h=O??P.approveBridge,v=W??P.submitBridge,R=je(()=>{ke().catch($=>{console.error("[crossx-kit] connectWallet error:",$)})},[ke]),N=je(()=>{_e()},[_e]),Re=b??N,ue=Fi(),{eligibility:dt}=Ui({network:Ce?String(Ce.id):void 0}),Ie=dt?.allowed===!0,Xe=xt(()=>{if(m)return m;if(!(!ue||!Ce||!Ie))return()=>ue.open({crypto:Ce.nativeCurrency?.symbol??"USDT",network:String(Ce.id),...I?{redirectUrl:I}:{}}).then(()=>{}).catch($=>{throw console.warn("[crossx-kit] onramp open failed:",$),$})},[m,ue,Ce,Ie,I]),Pt=Ai();Si(()=>{if(ue?.onStatus)return ue.onStatus(()=>{Pt.invalidateQueries()})},[ue,Pt]);let Ro=xt(()=>{if(!m&&!(!ue||!Ce)&&!Ie)return"On-ramp is not available in your region."},[m,ue,Ce,Ie]),[Ao,Oo]=Ri(!1),Eo=je(()=>{Oo(!0),T?.()},[T]),{summary:_o,markRepliesSeen:Bo}=cn({enabled:$e&&!w&&Ao,environment:ye}),No=w??_o,Wo=w?void 0:Bo,$t=G??$e,Do=xt(()=>{if(U!==void 0)return U;if($t)return Qi(tn,{...x,env:ye,theme:Le,mode:"button",buttonComponent:Wi})},[x,U,ye,$t,Le]),Lo=D.onBridgeDisabledMessage,Fo=D.onSendDisabledMessage,Uo=e?e.provider==="google"||e.provider==="apple":Pe==="cross_embedded",Mo=je(()=>{De().catch($=>{console.error("[crossx-kit] selectWallet error:",$)})},[De]),bn=C??(Uo?Mo:void 0),Go=je(async({hash:$,chainId:ne})=>{let se=dn(ge,ne?{chainId:ne}:void 0);if(!se)return null;try{return await se.getTransactionReceipt({hash:$})}catch{return null}},[ge]),Ko=je(async $=>{let ne=le,se=!1;$.chainId!==void 0&&$.chainId!==le&&(await we({chainId:$.chainId}),se=!0);let pe=$.chainId===56||$.chainId===97?{...$,type:"legacy"}:$,J=await(r??ze)(pe);return await _t({getChainId:()=>se?$.chainId:ne,switchChain:ve=>we({chainId:ve})},ne,Ke),J},[r,ze,le,we,Ke]),$o=S||Y||r?Ko:void 0,Ho=je(async $=>{let ne=$.chainId??le,se=dn(ge,ne?{chainId:ne}:void 0);if(!se)throw new Error(`publicClient for chainId ${ne??"unknown"} is not available \u2014 register the chain in createCrossxConfig({ networks }).`);let xe=ne===56||ne===97,[pe,Ae]=await Promise.all([se.estimateGas({account:$.from,to:$.to,value:$.value,data:$.data}),(async()=>{if(xe)return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await se.getGasPrice()};try{let J=await se.estimateFeesPerGas();return{maxFeePerGas:J.maxFeePerGas,maxPriorityFeePerGas:J.maxPriorityFeePerGas,gasPrice:void 0}}catch{return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await se.getGasPrice()}}})()]);return{gasLimit:pe,maxFeePerGas:Ae.maxFeePerGas,maxPriorityFeePerGas:Ae.maxPriorityFeePerGas,gasPrice:Ae.gasPrice}},[ge,le]),qo=f??Ho,Vo=je(async $=>{let ne={};if(!j||$.length===0)return ne;let se=$.flatMap(pe=>{let J={address:pe,abi:Gi,chainId:le};return[{...J,functionName:"balanceOf",args:[j]},{...J,functionName:"totalSupply"},{...J,functionName:"decimals"}]}),xe;try{xe=await yo(ge,{contracts:se,allowFailure:!0})}catch{return ne}return $.forEach((pe,Ae)=>{let J=Ae*3,ve=xe[J],St=xe[J+1],lt=xe[J+2];!ve||ve.status!=="success"||(ne[pe.toLowerCase()]={balance:ve.result,totalSupply:St&&St.status==="success"?St.result:void 0,decimals:lt&&lt.status==="success"?Number(lt.result):void 0})}),ne},[ge,j,le]),jo=je(async $=>{let ne={earnedWei:0n,stakedWei:0n};if(!$)return ne;let se=$i[ye],xe={address:se.poolAddress,abi:Ki,chainId:se.crossChainId},pe;try{pe=await yo(ge,{allowFailure:!0,contracts:[{...xe,functionName:"earned",args:[$]},{...xe,functionName:"balanceOf",args:[$]},{...xe,functionName:"posaActive"},{...xe,functionName:"lastRewardBlock"},{...xe,functionName:"totalStaked"}]})}catch{return ne}let Ae=ot=>pe[ot]&&pe[ot].status==="success"?pe[ot].result:0n,J=Ae(0),ve=Ae(1);if(pe[2]&&pe[2].status==="success"?pe[2].result:!1)return{earnedWei:J,stakedWei:ve};let lt=Ae(3),hn=Ae(4);if(hn===0n)return{earnedWei:J,stakedWei:ve};let Ht=0n;try{Ht=await dn(ge,{chainId:se.crossChainId})?.getBlockNumber?.()??0n}catch{return{earnedWei:J,stakedWei:ve}}if(Ht<=lt)return{earnedWei:J,stakedWei:ve};let qt=0n;try{let ot=await fetch(se.networkStatsUrl).then(Vt=>Vt.json()),Cn=ot?.data?.block_reward??ot?.block_reward;if(Cn){let[Vt,Jo=""]=String(Cn).split("."),Zo=(Jo+"0".repeat(18)).slice(0,18);qt=BigInt(Vt||"0")*ln+BigInt(Zo||"0")}}catch{}if(qt===0n)return{earnedWei:J,stakedWei:ve};let Xo=(Ht-lt)*qt*ln/hn,Yo=ve*Xo/ln;return{earnedWei:J+Yo,stakedWei:ve}},[ge,ye]),Qo=!bn,zo=Be?{...D,env:ye,theme:Le,showBalance:ee,walletAddress:Be,accountName:L,sendAccounts:g??y,connectorName:F,connectorId:K,showPortfolio:Y,showOnePop:$t,onePopSummary:No,onOnePopOpen:Eo,onOnePopRepliesSeen:Wo,onePopGetTokenSlot:Do,onDisconnect:Re,onSelectWallet:bn,onBuy:Xe,onBuyDisabledMessage:Ro,onBridgeDisabledMessage:Lo,onSendDisabledMessage:Fo,sendTransaction:$o,getTransactionReceipt:d??Go,estimateGas:qo,lpBalanceReader:Vo,stakingRewardsReader:jo,bridgeTokens:M,bridgeHistory:Q,getBridgeQuote:X,getBridgeToTokens:V,getBridgeApproval:p,approveBridge:h,submitBridge:v}:null;return{isConnected:te,isConnecting:Se,address:Be,triggerDisplay:k,hideSelectWalletChevron:Qo,handleConnectClick:R,walletInfoProps:zo}}import{Fragment as Io,jsx as fe,jsxs as at}from"react/jsx-runtime";function Xi({label:e="Connect Wallet",className:t,style:n,walletInfoStyle:s,...o}){let{isConnected:a,isConnecting:u,address:g,triggerDisplay:d,hideSelectWalletChevron:r,handleConnectClick:f,walletInfoProps:b}=Kt(o),C=t?`cb-button ${t}`:"cb-button",m=t?`cb-pill ${t}`:"cb-pill";return u&&!a?at(Io,{children:[fe("style",{children:mn}),at("button",{type:"button",disabled:!0,className:C,style:n,"aria-busy":"true",children:[fe("span",{className:"cb-spinner","aria-hidden":"true"}),fe("span",{className:"cb-button-label",children:"Connecting..."})]})]}):a&&g&&b?at("span",{"data-crossx-wallet-info":r?"external":"embedded",children:[fe("style",{children:mn}),r&&fe("style",{children:Ji}),at(pn,{...b,style:s,children:[fe(pn.Trigger,{asChild:!0,children:at("button",{type:"button",className:m,style:n,"aria-label":`Connected with ${d?.name??"wallet"}: ${ko(g)}`,children:[d?.iconUrl?fe("img",{src:d.iconUrl,alt:"",width:20,height:20,className:"cb-pill-icon","data-provider":d.iconUrl===zi?"apple":void 0}):fe("span",{className:"cb-pill-icon-placeholder","aria-hidden":"true"}),fe("span",{className:"cb-pill-address",children:ko(g)})]})}),fe(pn.Content,{align:"end",sideOffset:8})]})]}):at(Io,{children:[fe("style",{children:mn}),at("button",{type:"button",onClick:f,className:C,style:n,"aria-label":typeof e=="string"?e:"Connect Wallet",children:[fe(Yi,{}),fe("span",{className:"cb-button-label",children:e})]})]})}function Yi(){return fe("svg",{className:"cb-button-icon",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:fe("path",{d:"M11.4368 10.5007C11.4368 9.9538 11.6544 9.42855 12.041 9.04175C12.4278 8.65492 12.9529 8.4375 13.5 8.4375H15.1875V6.00073L15.1732 5.92822C15.1639 5.90585 15.15 5.88528 15.1326 5.8678C15.0973 5.83263 15.0494 5.81287 14.9996 5.81287H3.74963C3.4787 5.81287 3.21001 5.75949 2.95972 5.65576C2.90937 5.63488 2.86089 5.61017 2.8125 5.58545V14.2504C2.8125 14.4989 2.91141 14.7371 3.08716 14.9128C3.2629 15.0886 3.50109 15.1875 3.74963 15.1875H15.0007C15.0252 15.1875 15.0495 15.1826 15.0721 15.1732C15.0948 15.1638 15.1152 15.1499 15.1326 15.1326C15.1499 15.1152 15.1638 15.0948 15.1732 15.0721C15.1826 15.0495 15.1875 15.0252 15.1875 15.0007V12.5629H13.5C12.9529 12.5629 12.4278 12.3454 12.041 11.9586C11.6545 11.5719 11.4369 11.0475 11.4368 10.5007ZM12.5618 10.5007C12.5619 10.7491 12.6609 10.9875 12.8364 11.1632C13.0123 11.3391 13.2513 11.4379 13.5 11.4379H15.75C15.7998 11.4379 15.8477 11.4182 15.8829 11.3829C15.9182 11.3477 15.9379 11.2998 15.9379 11.25V9.75037C15.9379 9.70054 15.9182 9.65266 15.8829 9.61743C15.8477 9.5822 15.7998 9.5625 15.75 9.5625H13.5C13.2513 9.5625 13.0123 9.66131 12.8364 9.83716C12.6607 10.013 12.5618 10.2522 12.5618 10.5007ZM13.6879 3.00037C13.6879 2.95054 13.6682 2.90266 13.6329 2.86743C13.5977 2.8322 13.5498 2.8125 13.5 2.8125H3.74963C3.50109 2.8125 3.2629 2.91141 3.08716 3.08716C2.91141 3.2629 2.8125 3.50109 2.8125 3.74963L2.81689 3.84192C2.82585 3.93354 2.8486 4.02351 2.88391 4.10889C2.93096 4.22263 3.00015 4.32614 3.08716 4.41321C3.17403 4.50009 3.2769 4.56936 3.39038 4.61646C3.50412 4.66359 3.62651 4.68787 3.74963 4.68787H13.6879V3.00037ZM14.8129 4.68787H14.9996C15.3473 4.68787 15.6808 4.82576 15.9269 5.07129C16.173 5.31702 16.3119 5.65077 16.3125 5.99854V8.56494C16.4469 8.62873 16.5711 8.7148 16.6783 8.82202C16.9246 9.06823 17.0629 9.40217 17.0629 9.75037V11.25C17.0629 11.5982 16.9246 11.9321 16.6783 12.1783C16.5712 12.2855 16.4468 12.3706 16.3125 12.4343V14.9985L16.3059 15.1282C16.2934 15.2564 16.2619 15.3822 16.2125 15.5017C16.1466 15.6612 16.05 15.806 15.928 15.928C15.806 16.05 15.6612 16.1466 15.5017 16.2125C15.3425 16.2783 15.1719 16.3126 14.9996 16.3125H3.74963C3.20272 16.3125 2.67847 16.095 2.29175 15.7083C1.90502 15.3215 1.6875 14.7973 1.6875 14.2504V3.74963C1.6875 3.20272 1.90502 2.67847 2.29175 2.29175C2.67847 1.90502 3.20272 1.6875 3.74963 1.6875H13.5C13.8482 1.6875 14.1821 1.82581 14.4283 2.07202C14.6746 2.31823 14.8129 2.65217 14.8129 3.00037V4.68787Z",fill:"currentColor"})})}var Ji=`
3
3
  [data-crossx-wallet-info="external"] .wi-select-wallet-btn {
4
4
  display: none !important;
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- import{$ as _e,A as ie,B as se,C as de,D as pe,E as ce,F as le,G as ue,H as fe,I as Ce,J as we,K as me,L as ge,M as ye,N as Ne,O as ve,P as xe,Q as Ee,R as ke,S as Oe,T as Ae,U as Me,V as Pe,W as Ie,X as Ke,Y as Re,Z as Te,_ as be,a as S,aa as Se,b as V,ba as Ve,c as W,d as X,e as L,f as h,g as j,h as B,i as F,j as D,k as U,l as q,m as z,n as $,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as ee,v as ne,w as te,x as oe,y as re,z as ae}from"./chunk-GW5PEUTB.js";import{bscMainnetNetwork as v,bscTestnetNetwork as x,createCrossxConfig as E,crossMainnetNetwork as k,crossTestnetNetwork as O}from"@nexus-cross/connect-kit-wagmi";import{toNexusAdapter as A}from"@nexus-cross/connect-kit-wagmi/to-nexus";import{reownAdapter as M}from"@nexus-cross/connect-kit-wagmi/reown";import{embeddedConnectorFactory as P}from"@nexus-cross/connect-kit-wagmi/embedded";import{WALLET_BRAND_NAME as I}from"@nexus-cross/crossx-design-system";function d(e){try{return import.meta.env?.[e]}catch{return}}function p(e){if(!(typeof process>"u"))return process.env?.[e]}function K(){return d("VITE_CROSSX_ENVIRONMENT")??d("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("CROSSX_ENVIRONMENT")}function R(e){switch(e?.toLowerCase()){case"dev":case"development":return"development";case"stage":case"staging":case"stg":return"staging";default:return"production"}}function T(e){return e==="production"?[k,v]:[O,x]}function b(){let e=typeof window<"u"&&window.location?.origin?window.location.origin:"https://example.com";return{name:`${I} DApp`,url:e}}function _(e){let{app:c,appMetadata:l,networks:u,defaultNetwork:f,wallets:n,embedded:C=!0,environment:w,toNexus:t,reown:o,...r}=e,m=R(w??K()),i=u??T(m),a=Array.isArray(n)?null:n??"all",s=a!=="external-only"&&t!==!1,g=a!=="cross-only"&&o!==!1&&!!r.reownProjectId,y=t===!1?void 0:t,N=o===!1?void 0:o;if(a==="external-only"&&!r.reownProjectId)throw new Error('[crossx-kit] createConnectKitConfig({ wallets: "external-only" }) requires `reownProjectId`.');return E({...r,appMetadata:l??c??b(),networks:i,defaultNetwork:f??i[0],...Array.isArray(n)?{wallets:n}:{},...s?{crossProvider:A(y)}:{},...g?{reownProvider:M(N)}:{},...s&&C?{embeddedConnectorFactory:P}:{}})}export{xe as AppLauncher,ke as AppLauncherContent,Ee as AppLauncherTrigger,ae as ConnectButton,_e as ConnectionStatus,ve as ConnectorId,F as CrossConnectKitProvider,j as CrossConnectModal,G as CrossGetOneUsd,z as CrossRelayDeposit,de as CrossRelayHistory,pe as CrossRelayRecovery,Ie as DEFAULT_TRUSTED_FACTORIES,ge as KycError,me as KycProvider,Q as ONE_POP_REPLIES_SEEN_KEY_PREFIX,te as ONE_POP_SUMMARY_QUERY_KEY,ie as ONEpocket,D as ONEpocketConnectKitProvider,B as ONEpocketConnectModal,be as OnRampError,fe as OnRampProvider,se as OtherWalletsModal,Pe as RelayApiError,Ae as SkillsButton,Ne as WalletInfo,oe as clearOnePopJwtCache,ne as clearOnePopRepliesSeen,Y as collectOnePopReplyIds,Z as countUnseenOnePopReplies,_ as createConnectKitConfig,Me as createRelayClient,Se as formatBalance,Ve as formatWei,ye as launchKycVerification,ee as readOnePopRepliesSeen,ce as useConnectKitAnalytics,S as useCrossConnectKit,W as useCrossConnectKitTheme,U as useCrossdBridgeAdapter,H as useCrossxEmbeddedInfo,$ as useGetOneUsdStakeProps,Oe as useGlobalMenu,Ce as useKyc,V as useONEpocketConnectKit,L as useONEpocketConnectKitTheme,J as useONEpocketEmbeddedInfo,le as useOnRamp,ue as useOnRampEligibility,re as useOnePopSummary,X as useOptionalCrossConnectKitTheme,we as useOptionalKyc,h as useOptionalONEpocketConnectKitTheme,Ke as useRelayConfig,Re as useRelayOrders,Te as useRelayRecovery,q as useRelayWalletProps};
1
+ import{$ as _e,A as ie,B as se,C as de,D as pe,E as ce,F as le,G as ue,H as fe,I as Ce,J as we,K as me,L as ge,M as ye,N as Ne,O as ve,P as xe,Q as Ee,R as ke,S as Oe,T as Ae,U as Me,V as Pe,W as Ie,X as Ke,Y as Re,Z as Te,_ as be,a as S,aa as Se,b as V,ba as Ve,c as W,d as X,e as L,f as h,g as j,h as B,i as F,j as D,k as U,l as q,m as z,n as $,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as ee,v as ne,w as te,x as oe,y as re,z as ae}from"./chunk-ZATNOZGK.js";import{bscMainnetNetwork as v,bscTestnetNetwork as x,createCrossxConfig as E,crossMainnetNetwork as k,crossTestnetNetwork as O}from"@nexus-cross/connect-kit-wagmi";import{toNexusAdapter as A}from"@nexus-cross/connect-kit-wagmi/to-nexus";import{reownAdapter as M}from"@nexus-cross/connect-kit-wagmi/reown";import{embeddedConnectorFactory as P}from"@nexus-cross/connect-kit-wagmi/embedded";import{WALLET_BRAND_NAME as I}from"@nexus-cross/crossx-design-system";function d(e){try{return import.meta.env?.[e]}catch{return}}function p(e){if(!(typeof process>"u"))return process.env?.[e]}function K(){return d("VITE_CROSSX_ENVIRONMENT")??d("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("CROSSX_ENVIRONMENT")}function R(e){switch(e?.toLowerCase()){case"dev":case"development":return"development";case"stage":case"staging":case"stg":return"staging";default:return"production"}}function T(e){return e==="production"?[k,v]:[O,x]}function b(){let e=typeof window<"u"&&window.location?.origin?window.location.origin:"https://example.com";return{name:`${I} DApp`,url:e}}function _(e){let{app:c,appMetadata:l,networks:u,defaultNetwork:f,wallets:n,embedded:C=!0,environment:w,toNexus:t,reown:o,...r}=e,m=R(w??K()),i=u??T(m),a=Array.isArray(n)?null:n??"all",s=a!=="external-only"&&t!==!1,g=a!=="cross-only"&&o!==!1&&!!r.reownProjectId,y=t===!1?void 0:t,N=o===!1?void 0:o;if(a==="external-only"&&!r.reownProjectId)throw new Error('[crossx-kit] createConnectKitConfig({ wallets: "external-only" }) requires `reownProjectId`.');return E({...r,appMetadata:l??c??b(),networks:i,defaultNetwork:f??i[0],...Array.isArray(n)?{wallets:n}:{},...s?{crossProvider:A(y)}:{},...g?{reownProvider:M(N)}:{},...s&&C?{embeddedConnectorFactory:P}:{}})}export{xe as AppLauncher,ke as AppLauncherContent,Ee as AppLauncherTrigger,ae as ConnectButton,_e as ConnectionStatus,ve as ConnectorId,F as CrossConnectKitProvider,j as CrossConnectModal,G as CrossGetOneUsd,z as CrossRelayDeposit,de as CrossRelayHistory,pe as CrossRelayRecovery,Ie as DEFAULT_TRUSTED_FACTORIES,ge as KycError,me as KycProvider,Q as ONE_POP_REPLIES_SEEN_KEY_PREFIX,te as ONE_POP_SUMMARY_QUERY_KEY,ie as ONEpocket,D as ONEpocketConnectKitProvider,B as ONEpocketConnectModal,be as OnRampError,fe as OnRampProvider,se as OtherWalletsModal,Pe as RelayApiError,Ae as SkillsButton,Ne as WalletInfo,oe as clearOnePopJwtCache,ne as clearOnePopRepliesSeen,Y as collectOnePopReplyIds,Z as countUnseenOnePopReplies,_ as createConnectKitConfig,Me as createRelayClient,Se as formatBalance,Ve as formatWei,ye as launchKycVerification,ee as readOnePopRepliesSeen,ce as useConnectKitAnalytics,S as useCrossConnectKit,W as useCrossConnectKitTheme,U as useCrossdBridgeAdapter,H as useCrossxEmbeddedInfo,$ as useGetOneUsdStakeProps,Oe as useGlobalMenu,Ce as useKyc,V as useONEpocketConnectKit,L as useONEpocketConnectKitTheme,J as useONEpocketEmbeddedInfo,le as useOnRamp,ue as useOnRampEligibility,re as useOnePopSummary,X as useOptionalCrossConnectKitTheme,we as useOptionalKyc,h as useOptionalONEpocketConnectKitTheme,Ke as useRelayConfig,Re as useRelayOrders,Te as useRelayRecovery,q as useRelayWalletProps};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-GW5PEUTB.js";export{P as AppLauncher,R as AppLauncherContent,Q as AppLauncherTrigger,z as ConnectButton,$ as ConnectionStatus,O as ConnectorId,i as CrossConnectKitProvider,g as CrossConnectModal,o as CrossGetOneUsd,m as CrossRelayDeposit,C as CrossRelayHistory,D as CrossRelayRecovery,W as DEFAULT_TRUSTED_FACTORIES,L as KycError,K as KycProvider,r as ONE_POP_REPLIES_SEEN_KEY_PREFIX,w as ONE_POP_SUMMARY_QUERY_KEY,A as ONEpocket,j as ONEpocketConnectKitProvider,h as ONEpocketConnectModal,_ as OnRampError,H as OnRampProvider,B as OtherWalletsModal,V as RelayApiError,T as SkillsButton,N as WalletInfo,x as clearOnePopJwtCache,v as clearOnePopRepliesSeen,s as collectOnePopReplyIds,t as countUnseenOnePopReplies,U as createRelayClient,aa as formatBalance,ba as formatWei,M as launchKycVerification,u as readOnePopRepliesSeen,E as useConnectKitAnalytics,a as useCrossConnectKit,c as useCrossConnectKitTheme,k as useCrossdBridgeAdapter,p as useCrossxEmbeddedInfo,n as useGetOneUsdStakeProps,S as useGlobalMenu,I as useKyc,b as useONEpocketConnectKit,e as useONEpocketConnectKitTheme,q as useONEpocketEmbeddedInfo,F as useOnRamp,G as useOnRampEligibility,y as useOnePopSummary,d as useOptionalCrossConnectKitTheme,J as useOptionalKyc,f as useOptionalONEpocketConnectKitTheme,X as useRelayConfig,Y as useRelayOrders,Z as useRelayRecovery,l as useRelayWalletProps};
1
+ import{$,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-ZATNOZGK.js";export{P as AppLauncher,R as AppLauncherContent,Q as AppLauncherTrigger,z as ConnectButton,$ as ConnectionStatus,O as ConnectorId,i as CrossConnectKitProvider,g as CrossConnectModal,o as CrossGetOneUsd,m as CrossRelayDeposit,C as CrossRelayHistory,D as CrossRelayRecovery,W as DEFAULT_TRUSTED_FACTORIES,L as KycError,K as KycProvider,r as ONE_POP_REPLIES_SEEN_KEY_PREFIX,w as ONE_POP_SUMMARY_QUERY_KEY,A as ONEpocket,j as ONEpocketConnectKitProvider,h as ONEpocketConnectModal,_ as OnRampError,H as OnRampProvider,B as OtherWalletsModal,V as RelayApiError,T as SkillsButton,N as WalletInfo,x as clearOnePopJwtCache,v as clearOnePopRepliesSeen,s as collectOnePopReplyIds,t as countUnseenOnePopReplies,U as createRelayClient,aa as formatBalance,ba as formatWei,M as launchKycVerification,u as readOnePopRepliesSeen,E as useConnectKitAnalytics,a as useCrossConnectKit,c as useCrossConnectKitTheme,k as useCrossdBridgeAdapter,p as useCrossxEmbeddedInfo,n as useGetOneUsdStakeProps,S as useGlobalMenu,I as useKyc,b as useONEpocketConnectKit,e as useONEpocketConnectKitTheme,q as useONEpocketEmbeddedInfo,F as useOnRamp,G as useOnRampEligibility,y as useOnePopSummary,d as useOptionalCrossConnectKitTheme,J as useOptionalKyc,f as useOptionalONEpocketConnectKitTheme,X as useRelayConfig,Y as useRelayOrders,Z as useRelayRecovery,l as useRelayWalletProps};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cross/connect-kit-react",
3
- "version": "1.5.0-beta.3",
3
+ "version": "1.5.1-beta.1",
4
4
  "description": "React components and hooks for @nexus-cross/connect-kit wallet connection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,13 +24,13 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@nexus-cross/connect-kit-core": "1.5.0-beta.3",
28
- "@nexus-cross/connect-kit-wagmi": "1.5.0-beta.3",
29
- "@nexus-cross/crossx-design-system": "1.5.0-beta.3",
30
- "@nexus-cross/dapp-ui": "1.5.0-beta.3",
31
- "@nexus-cross/kyc": "1.5.0-beta.3",
32
- "@nexus-cross/onramp": "1.5.0-beta.3",
33
- "@nexus-cross/pop": "1.5.0-beta.3"
27
+ "@nexus-cross/connect-kit-core": "1.5.1-beta.1",
28
+ "@nexus-cross/connect-kit-wagmi": "1.5.1-beta.1",
29
+ "@nexus-cross/dapp-ui": "1.5.1-beta.1",
30
+ "@nexus-cross/crossx-design-system": "1.5.1-beta.1",
31
+ "@nexus-cross/kyc": "1.5.1-beta.1",
32
+ "@nexus-cross/onramp": "1.5.1-beta.1",
33
+ "@nexus-cross/pop": "1.5.1-beta.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@tanstack/react-query": "^5.60.0",