@nexus-cross/connect-kit-react 1.3.3-beta.3 → 1.3.3-beta.5
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.
- package/dist/chunk-5EKJPAF3.js +143 -0
- package/dist/client.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-RRDG2DCB.js +0 -143
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var st="1.3.3";var ut="__nexusCrossAppLauncherRuntime";function Vn(){if(typeof window>"u")return null;let e=window;return e[ut]??(e[ut]={mode:"dapp-ui"}),e[ut]}function Hn(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 o=e.connectKitVersion??st;console.info(`[CROSSx App Launcher] connect-kit-react v${o} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${st}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${st} \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 $t(){let e=Vn();e&&(e.mode="connect-kit-react",e.connectKitVersion=st,Hn(e))}import{useCallback as Oe,useEffect as fe,useMemo as Le,useRef as Je,useState as Me}from"react";import{WagmiProvider as Jn,useAccount as eo,useConnect as to,useDisconnect as no}from"wagmi";import{QueryClient as oo,QueryClientProvider as ro}from"@tanstack/react-query";import{clearWalletSessionStorage as so,onOpenOtherWallets as io,pickInitialState as ao,resolveCurrentWallet as co}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as lo}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as uo}from"@nexus-cross/crossx-design-system";import{OnRampProvider as mo}from"@nexus-cross/onramp/react";import{createContext as zn,useContext as Qn}from"react";var kt=zn(null);function Ee(){let e=Qn(kt);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}import{createContext as jn,useContext as qt}from"react";var mt=jn(null);function Xn(){let e=qt(mt);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function it(){return qt(mt)}import{useCallback as Yn,useMemo as Vt}from"react";import{WalletConnectModal as Ht}from"@nexus-cross/dapp-ui";import{jsx as zt}from"react/jsx-runtime";var Zn=new Set(["cross_wallet","cross_extension","metamask","binance"]);function xt({open:e,onOpenChange:t}){let{connect:o,availableWallets:s,oauth:n,extraWallets:a,walletAllowlist:f}=Ee(),b=it()?.mode??"dark",u=Vt(()=>{let x=f?new Set(f):null,m={};for(let C of s){if(!Zn.has(C.walletId)||x&&!x.has(C.walletId))continue;let P=C.walletId;m[P]=()=>{o(C.walletId)}}for(let[C,P]of Object.entries(a))P&&(x&&!x.has(C)||(m[C]=P));return m},[s,o,a,f]),w=Vt(()=>{if(n)return{apple:()=>{n.signIn("apple")},google:()=>{n.signIn("google")}}},[n]),I=Yn(x=>t(x),[t]);return zt(Ht,{wallets:u,socialProviders:w,theme:b,open:e,onOpenChange:I,children:zt(Ht.Content,{})})}import{jsx as et,jsxs as jt}from"react/jsx-runtime";var po=new oo,Tt="crossx-kit:last-wallet-intent";function fo(e){let t=[],o=e,s=0;for(;o&&s<5;){let n=o;typeof n.message=="string"&&t.push(n.message),o=n.cause,s+=1}return t.some(n=>/external wallet connection/i.test(n))}function go(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Tt)??null}catch{return null}}function Qt(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Tt,e):window.localStorage.removeItem(Tt)}catch{}}function bo(e,t){if(typeof window>"u")return t;try{let o=window.localStorage.getItem(e);return o==="cross"||o==="reown"?o:t}catch{return t}}function yo(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function wo({children:e,config:t,activeProvider:o,onRequestProviderSwap:s,pendingConnectWalletId:n,clearPending:a,themeMode:f,themeTokens:p,extraWallets:b,walletAllowlist:u}){let[w,I]=Me(!1),[x,m]=Me(()=>go()),[C,P]=Me(null),{address:v,isConnected:T,isConnecting:R,isReconnecting:_,connector:q}=eo(),{connectors:te,connectAsync:H}=to(),{disconnectAsync:U}=no(),{kitConfig:F,connectorRegistry:W,crossProvider:ye,reownProvider:B}=t,A=o==="cross"?ye:B,E=Le(()=>!T||!q?null:co(W,q.id,x),[T,q,W,x]),we=Le(()=>W.entries.filter(l=>l.type!=="embedded"),[W]),qe=Je(v);qe.current=v;let X=F.embeddedProjectId?.trim()||F.crossProjectId?.trim(),K=!!F.onRampEnabled&&!!X,le=Le(()=>!K||!X?null:{projectId:X,walletState:{getAddress:()=>qe.current}},[K,X]);fe(()=>io(()=>I(!0)),[]),fe(()=>{if(!w||typeof document>"u")return;let l=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(g=>g.remove())},50);return()=>clearTimeout(l)},[w]);let he=Je(T),We=Je(T);he.current=T;let De=Je(!1);fe(()=>{console.debug("[crossx-kit] state",{activeProvider:o,isConnected:T,isConnecting:R,isReconnecting:_,activeConnectorId:q?.id,currentWallet:E,lastIntent:x})},[o,T,R,_,q?.id,E,x]),fe(()=>{T&&!We.current&&A?.closeModal?.({kitConfig:F}),We.current=T},[T,A,F]),fe(()=>{T&&P(null)},[T]);let ce=Oe(l=>te.find(g=>g.id===l),[te]);fe(()=>{let l=W.getEntry("cross_embedded");if(!l)return;let g=ce(l.connectorId);if(!g)return;let k=!1;return(async()=>{try{let y=await g.getProvider();if(k)return;y?.sdk?.applyTheme?.(f,p??void 0)}catch(y){console.debug("[crossx-kit] applyTheme skipped:",y)}})(),()=>{k=!0}},[W,ce,f,p]);let Ae=Oe(l=>{m(l),Qt(l)},[]),z=Oe(()=>{m(null),Qt(null),P(null)},[]);fe(()=>{if(!A?.subscribeModalState)return;let l=!1;return A.subscribeModalState({kitConfig:F},g=>{if(De.current=g,g){l=!0;return}l&&(l=!1,setTimeout(()=>{he.current||(async()=>{try{await U()}catch{}z()})()},250))})},[A,F,U,z]),fe(()=>{if(!C||T||typeof window>"u"||C==="cross_embedded")return;let l=typeof document<"u"&&!document.hasFocus(),g=null,k=()=>{l=!0},y=()=>{l&&(g&&clearTimeout(g),g=setTimeout(()=>{he.current||De.current||(async()=>{try{await U()}catch{}z()})()},1e3))};return window.addEventListener("blur",k),window.addEventListener("focus",y),()=>{window.removeEventListener("blur",k),window.removeEventListener("focus",y),g&&clearTimeout(g)}},[C,T,U,z]);let Ve=Oe(async l=>{console.debug("[crossx-kit] runConnect enter",{walletId:l,activeProvider:o,isConnected:T,activeConnectorId:q?.id});let g=W.getEntry(l);if(!g){if((l==="metamask"||l==="binance")&&!B){console.error(`[crossx-kit] "${l}" 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: "${l}"`);return}if(P(l),g.providerKind!==o){console.debug("[crossx-kit] provider swap needed",{from:o,to:g.providerKind,walletId:l}),Ae(l);try{await U()}catch{}await new Promise(y=>setTimeout(y,0)),s(g.providerKind,l);return}if(Ae(l),A?.beforeConnect)try{let y=await A.beforeConnect({kitConfig:F,themeMode:f},l);if(console.debug("[crossx-kit] beforeConnect result",{walletId:l,result:y}),y==="handled")return}catch(y){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',l,y)}let k=ce(g.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:g.connectorId,found:k?.id,availableIds:te.map(y=>y.id)}),!k){console.error(`[crossx-kit] Connector "${g.connectorId}" not found on provider "${g.providerKind}". Available: ${te.map(y=>y.id).join(", ")}`),z();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:k.id});let y=await H({connector:k});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:y.accounts.length,chainId:y.chainId});return}catch(y){if(!fo(y)){console.error('[crossx-kit] connectAsync error for "%s":',l,y);try{await U()}catch{}}if(!g.fallbackConnectorId){z();return}}if(g.fallbackConnectorId){let y=ce(g.fallbackConnectorId);if(y)try{await H({connector:y})}catch(D){console.error('[crossx-kit] Fallback connect failed for "%s":',l,D);try{await U()}catch{}z()}else z()}},[W,te,ce,H,U,Ae,z,A,o,F,s,f]);fe(()=>{if(!n)return;let l=n;a(),Ve(l)},[n,o]);let He=Oe(async()=>{I(!0)},[]),ze=Oe(async()=>{try{await U()}catch(l){console.error("[crossx-kit] wagmi disconnect error:",l)}if(A?.teardown)try{await A.teardown({kitConfig:F})}catch(l){console.error("[crossx-kit] adapter teardown error:",l)}so(),z()},[U,A,F,z]),Re=Oe(async()=>{let l=W.getEntry("cross_embedded");if(!l)return null;let g=ce(l.connectorId);if(!g)return null;try{let k=await g.getProvider(),y=k?.sdk;if(!y?.selectWallet)return null;let D=await y.selectWallet(y.currentAddress??void 0);return D?.address&&k.notifyAccountsChanged&&k.notifyAccountsChanged([D.address]),D}catch{return null}},[W,ce]),r=Le(()=>{let l=t.oauth;return l?{signIn:async g=>{P("cross_embedded");try{await l.signIn(g)}catch(k){throw P(null),k}}}:null},[t.oauth]),i=Je(!1);fe(()=>{if(o!=="cross"||T||R||_||C!=null||i.current)return;let l=W.getEntry("cross_embedded");if(!l)return;let g=ce(l.connectorId);if(!g)return;i.current=!0;let k=!1;return(async()=>{try{let y=await g.isAuthorized?.();if(k||!y)return;await H({connector:g})}catch{}})(),()=>{k=!0}},[o,T,R,_,C,W,ce,H]);let c=C!=null&&!T,d=Le(()=>({kitConfig:F,connectorRegistry:W,availableWallets:we,connect:Ve,connectWallet:He,disconnect:ze,selectWallet:Re,currentWallet:E,lastIntent:x,isConnecting:c,connectingWalletId:C,openOtherWallets:()=>I(!0),closeOtherWallets:()=>I(!1),otherWalletsOpen:w,oauth:r,extraWallets:b,walletAllowlist:u,onRampEnabled:K}),[F,W,we,Ve,He,ze,Re,E,x,c,C,w,r,b,u,K]),h=jt(kt.Provider,{value:d,children:[e,et(xt,{open:w,onOpenChange:I})]});return le?et(mo,{config:le,children:h}):h}var ho=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function Co(e){let t=e?.message;return typeof t!="string"?!1:ho.some(o=>o.test(t))}var ko={};function xo(e){return e&&{...e,connections:new Map,current:null}}function To({children:e,config:t,initialState:o,extraWallets:s=ko,walletAllowlist:n}){let[a,f]=Me(()=>bo(t.activeProviderStorageKey,t.defaultProvider)),[p,b]=Me(null),u=Je(!1),{kitConfig:w}=t,[I,x]=Me(null),[m,C]=Me(null),[P,v]=Me(0),T=Le(()=>lo(w.theme,w.autoDetectTheme),[w.theme,w.autoDetectTheme,P]),R=I??T,_=m??w.themeTokens;fe(()=>{if(!w.autoDetectTheme||I||typeof window>"u"||!window.matchMedia)return;let B=window.matchMedia("(prefers-color-scheme: dark)"),A=()=>v(E=>E+1);try{return B.addEventListener("change",A),()=>B.removeEventListener("change",A)}catch{return B.addListener(A),()=>B.removeListener(A)}},[w.autoDetectTheme,I]),fe(()=>{if(typeof document>"u")return;let B=document.documentElement,A=B.getAttribute("data-ds-theme"),E=B.getAttribute("data-theme");return B.setAttribute("data-ds-theme",R),E||B.setAttribute("data-theme",R),()=>{A==null?B.removeAttribute("data-ds-theme"):B.setAttribute("data-ds-theme",A),E==null&&B.removeAttribute("data-theme")}},[R]);let q=Le(()=>uo(t.designSystem),[t.designSystem]),te=Le(()=>({mode:R,tokens:_,setThemeMode:B=>x(B),setThemeTokens:B=>C(B)}),[R,_]);fe(()=>{if(typeof window>"u")return;let B=A=>{Co(A.reason)&&A.preventDefault()};return window.addEventListener("unhandledrejection",B),()=>window.removeEventListener("unhandledrejection",B)},[]);let H=Oe((B,A)=>{u.current||(u.current=!0,b(A),f(B),yo(t.activeProviderStorageKey,B),queueMicrotask(()=>{u.current=!1}))},[t.activeProviderStorageKey]),U=Oe(()=>b(null),[]),F=a==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,W=xo(ao(o,a));if(!F){if(!(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let A=a==="cross"?"reown":"cross";queueMicrotask(()=>f(A))}let ye=F??(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return jt(mt.Provider,{value:te,children:[et("style",{"data-crossx-design-system":"",children:q}),et(Jn,{config:ye,initialState:W,children:et(ro,{client:po,children:et(wo,{config:t,activeProvider:a,onRequestProviderSwap:H,pendingConnectWalletId:p,clearPending:U,themeMode:R,themeTokens:_,extraWallets:s,walletAllowlist:n??t.kitConfig.wallets??null,children:e})})},a)]})}import{useCallback as Ke,useEffect as kr,useMemo as yt}from"react";import{useQueryClient as xr}from"@tanstack/react-query";import{useAccount as Tr,useChainId as Ir,useConfig as Sr,useSendTransaction as vr,useSwitchChain as Pr}from"wagmi";import{getPublicClient as _t,readContracts as Cn}from"wagmi/actions";import{WalletInfo as Et,ConnectorId as $e,resolveEnvironment as Ar}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as Rr,useOptionalOnRampEligibility as Br}from"@nexus-cross/onramp/react";import{APPLE_ICON as Wt,BINANCE_ICON as Tn,CROSSX_ICON as Ft,EXTENSION_ICON as _r,GOOGLE_ICON as In,METAMASK_ICON as Sn}from"@nexus-cross/connect-kit-wagmi";import{useCallback as re,useMemo as Se,useRef as Io}from"react";import{useQueries as Xt,useQuery as tt}from"@tanstack/react-query";import{encodeFunctionData as at,formatUnits as bt,parseSignature as So,parseUnits as vo}from"viem";import{getChainId as Po,getPublicClient as ln,readContract as Te,signTypedData as Ao,switchChain as Ro,waitForTransactionReceipt as Bo,writeContract as Yt}from"wagmi/actions";import{useConfig as _o}from"wagmi";function Eo(e){return e!=="bridge"}var un="0x0000000000000000000000000000000000000000",be=100,ot=18,Oo=180000n,No=250000n,mn=new Set([56,97]),Fo=130n,Wo=100n,Do={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97},contracts:{BSC_CROSS:"0x26ca2a92ea9659e073621bb85b9117dc5944cff1",W_CROSS:"0xda37a3B60E6b97E8CB44b460130d40331efc566b",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x9f85c7b5d7637e18f946cc8af9c131318c6833d9",CROSSD:"0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",USDTB:"0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",SWAP_BRIDGE_ROUTER:"0x337071C06416f13b568eE644c1D714edd65509eB"},hiddenPairs:[{fromKey:"97-0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"97-0x26ca2a92ea9659e073621bb85b9117dc5944cff1",toKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb"}]},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97},contracts:{BSC_CROSS:"0x26ca2a92ea9659e073621bb85b9117dc5944cff1",W_CROSS:"0xda37a3B60E6b97E8CB44b460130d40331efc566b",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x9f85c7b5d7637e18f946cc8af9c131318c6833d9",CROSSD:"0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",USDTB:"0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",SWAP_BRIDGE_ROUTER:"0x337071C06416f13b568eE644c1D714edd65509eB"},hiddenPairs:[{fromKey:"97-0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"97-0x26ca2a92ea9659e073621bb85b9117dc5944cff1",toKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb"}]},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56},contracts:{BSC_CROSS:"0x6bf62ca91e397b5a7d1d6bce97d9092065d7a510",W_CROSS:"0x731a104a4461ae45bfef520468b43c262d35e682",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x1c37d4f44ed3ec86d96868001cfa89e97112a85c",CROSSD:"0xff42c13d927a6b9265236619161accb227b6d452",USDTB:"0x55d398326f99059ff775485246999027b3197955",SWAP_BRIDGE_ROUTER:"0xB298C340816fee45cfB39B1e6EE4DB4D5739e357"},hiddenPairs:[{fromKey:"56-0x55d398326f99059ff775485246999027b3197955",toKey:"612055-0x1c37d4f44ed3ec86d96868001cfa89e97112a85c"},{fromKey:"612055-0xff42c13d927a6b9265236619161accb227b6d452",toKey:"612055-0x1c37d4f44ed3ec86d96868001cfa89e97112a85c"},{fromKey:"56-0x6bf62ca91e397b5a7d1d6bce97d9092065d7a510",toKey:"612055-0xff42c13d927a6b9265236619161accb227b6d452"}]}},je=[{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"}]}],It=[{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"}]}],Zt=[{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"}]}],Jt=[{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"}]}],Lo=[{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"}]}],Ne=[{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:[]}],Mo=[{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 pn(e){let t="";try{t=await e.text()}catch{}if(t){try{let o=JSON.parse(t),s=typeof o.data=="string"&&o.data||typeof o.message=="string"&&o.message||"";if(s)return`${s} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function Ge(e,t){let o=await fetch(e,{cache:"no-store",signal:t});if(!o.ok)throw new Error(`CrossD bridge adapter request failed: ${await pn(o)}`);let s=await o.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 en(e,t,o){let s=await fetch(e,{method:"POST",cache:"no-store",signal:o,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`CrossD bridge adapter request failed: ${await pn(s)}`);let n=await s.json();if(n&&typeof n=="object"&&"code"in n&&typeof n.code=="number"&&n.code!==200)throw new Error(n.message||`CrossD bridge adapter API error: ${n.code}`);return n&&typeof n=="object"&&"data"in n?n.data:n}function Go(e){return new Promise(t=>setTimeout(t,e))}async function Uo(e,t,{attempts:o=60,intervalMs:s=2e3}={}){for(let n=0;n<o;n+=1){try{let a=await Ge(`${e}/permit-hash/${t}`);if(At(a))return a}catch{}await Go(s)}return null}function ee(e,t){return`${e}-${t.toLowerCase()}`}function ie(e){return ee(e.chainId,e.address)}function ve(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function tn(e){return e===56||e===97?"BSC":e===612044||e===612055?"CROSS":`Chain ${e}`}function J(e,t){return t?t.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()?e.contracts.W_CROSS:t:un}function Xe(e){let t=bt(e,ot);return t.includes(".")?t.replace(/\.?0+$/,""):t}function dt(e){return vo(e||"0",ot)}function de(e){try{return dt(e||"0")}catch{return 0n}}function Ue(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 St(e){let t=bt(e,9);return(t.includes(".")?t.replace(/\.?0+$/,""):t)||"0"}function pt(e){return e==="bridge"?Oo:No}function nn(e,t){if(!e||!t)return"0";let o=e*e;if(o===0n)return"0";let s=t*t,n=s>o?s-o:o-s;if(n===0n)return"0";let a=(n*100000000n+o/2n)/o;if(a>=100000000n)return"100";let f=a/1000000n,p=(a%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return p?`${f}.${p}`:`${f}`}function Ko(e){if(!e||Number(e)===0)return"0%";let[t,o=""]=e.split("."),s=o.length>4?o.slice(0,4):o;return s?`${t}.${s}%`:`${t}%`}async function on(e,t,o,s,n,a=!1){let f=ln(e,{chainId:t}),p=o;try{let u=await f?.estimateContractGas?.({account:n.account,address:n.address,abi:n.abi,functionName:n.functionName,args:n.args,value:n.value});typeof u=="bigint"&&u>0n&&(p=s?u*Fo/Wo:u)}catch{}let b={gas:p};if(mn.has(t))try{let u=await f?.getGasPrice?.();typeof u=="bigint"&&u>0n&&(b.gasPrice=u)}catch{}else if(a)try{let u=await f?.estimateFeesPerGas?.();typeof u?.maxFeePerGas=="bigint"&&(b.maxFeePerGas=u.maxFeePerGas),typeof u?.maxPriorityFeePerGas=="bigint"&&(b.maxPriorityFeePerGas=u.maxPriorityFeePerGas)}catch{}return b}function fn(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 vt(e,t){let o=fn(t);return o>=10000n?0n:e*(10000n-o)/10000n}function $o(e,t){let o=fn(t);return(e*(10000n+o)+9999n)/10000n}function ct(){return BigInt(Math.floor(Date.now()/1e3)+1800)}var qo={100:"0.01%",500:"0.05%",3e3:"0.3%",1e4:"1%"};function Vo(e){return qo[e]??`${e/1e4}%`}function Ho(e,t){let o=Number(e||"0");return!Number.isFinite(o)||o<=0?"0":(o*t/1e6).toFixed(8).replace(/\.?0+$/,"")}function rn(e){return Xe(e)}function sn(e,t){let o=Number(t??"0");return!Number.isFinite(o)||o<=0?0n:e*BigInt(Math.floor(o))/1000n}function ft(e,t){if(!e)return!1;let o=e.toLowerCase();return t.some(s=>s.toLowerCase()===o)}function zo(e,t,o){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(n=>ft(t,n.from)&&ft(o,n.to)||ft(t,n.to)&&ft(o,n.from))}function Qo(e){if(ve(e.type))return null;if(e.type==="swap-bridge"){let t=e.steps.find(o=>o.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}if(e.type==="bridge-swap"){let t=e.steps.find(o=>o.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 jo({input:e,path:t,config:o}){if(!o||ve(t.type))return"";let s=Ue(o.minimumValue),n=Ue(o.gasFee??o.gas_fee),a=t.type==="swap-bridge"?s+n*12n/10n:s;return a<=0n?"":e.fromAmount&&de(e.fromAmount)<a&&t.type!=="swap"?`Minimum ${rn(a)}`:t.type==="swap-bridge"&&e.toAmount&&de(e.toAmount)<a?`Available ${rn(a)} or more.`:""}function Xo({input:e,path:t,config:o}){if(!o||t.type!=="bridge"&&t.type!=="bridge-swap")return"";let s=Ue(o.gasFee??o.gas_fee);if(s<=0n||!e.fromAmount)return"";let n=de(e.fromToken.balance||"0"),a=de(e.fromAmount);return n-s<a?`Insufficient network fee(${e.fromToken.symbol})`:""}function Yo(e,t){let o=new Set;return e?.list?.forEach(s=>{let n=s.localChain??s.local_chain;n&&Object.entries(s.pairs||{}).forEach(([a,f])=>{f.forEach(p=>{p.localToken&&o.add(ee(n,p.localToken)),p.remoteToken&&o.add(ee(Number(a),p.remoteToken))})})}),Object.entries(t?.swapPools||t?.swap_pools||{}).forEach(([s,n])=>{n.forEach(a=>{a.token0&&o.add(ee(Number(s),a.token0)),a.token1&&o.add(ee(Number(s),a.token1))})}),o}function Zo(e,t){return!e||!t?null:ee(e,t)}function Jo({envConfig:e,bridgePairList:t,swapPools:o,tokenInfo:s,tokenStats:n}){let a=Yo(t,o),f=new Map;n?.forEach(b=>{let u=Zo(Number(b.chainId??b.chain_id),b.address);u&&f.set(u,b)});let p={};return a.forEach(b=>{let[u,w]=b.split("-"),I=Number(u),x=s?.find(C=>Number(C.chainId??C.chain_id)===I&&C.address?.toLowerCase()===w);if(!x?.symbol||!x.name)return;let m=f.get(b);p[b]={key:b,chainId:I,address:w,symbol:x.symbol,name:x.name,decimals:x.decimals||ot,image:x.image||x.icon_url,price:m?.price?Number(m.price):void 0,isNativeToken:w.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()}}),p}function gn(e,t){return t?.list?.find(o=>(o.localChain??o.local_chain)===e)?.bridge||""}function bn(e,t,o){let[s,n]=e.split("-"),[a,f]=t.split("-"),p=Number(s),b=Number(a);for(let u of o?.list||[]){if((u.localChain??u.local_chain)!==p)continue;let w=u.pairs?.[a];if(w){for(let I of w)if(I.localToken?.toLowerCase()===n&&I.remoteToken?.toLowerCase()===f)return{type:"bridge",fromChain:p,fromToken:n,toChain:b,toToken:f,bridgeAddress:gn(p,o)}}}return null}function yn(e,t,o,s){let[n,a]=e.split("-"),[f,p]=t.split("-");if(n!==f)return null;let b=Number(n),u=(o?.swapPools||o?.swap_pools)?.[n];if(!u)return null;let w=s.contracts.W_CROSS.toLowerCase(),I=s.contracts.NATIVE_CROSS.toLowerCase(),x=m=>m?.toLowerCase()===w?I:m?.toLowerCase();for(let m of u){let C=x(m.token0),P=x(m.token1);if(C===a&&P===p||P===a&&C===p){let v="swap";return b===s.chainIds.cross&&(a===I&&(v="deposit-swap"),p===I&&(v="swap-withdraw")),{pathType:v,step:{type:"swap",chain:b,fromToken:a,toToken:p,fee:m.fee||be,poolAddress:m.poolAddress||m.pool_address||""}}}}return null}function er(e,t,o,s){let[n,a]=e.split("-"),[f]=t.split("-");if(n===f)return null;for(let p of(o?.swapPools||o?.swap_pools)?.[n]||[]){let b=p.token0?.toLowerCase(),u=p.token1?.toLowerCase(),w=b===a?u:u===a?b:null;if(!w)continue;let I=bn(ee(Number(n),w),t,s);if(I)return[{type:"swap",chain:Number(n),fromToken:a,toToken:w,fee:p.fee||be,poolAddress:p.poolAddress||p.pool_address||""},I]}return null}function tr(e,t,o,s,n){let[a,f]=e.split("-"),[p]=t.split("-");if(a===p)return null;for(let b of o?.list||[])if((b.localChain??b.local_chain)===Number(a))for(let u of b.pairs?.[p]||[]){if(u.localToken?.toLowerCase()!==f)continue;let w=u.remoteToken?.toLowerCase();if(!w)continue;let I=yn(ee(Number(p),w),t,s,n);if(I)return[{type:"bridge",fromChain:Number(a),fromToken:f,toChain:Number(p),toToken:w,bridgeAddress:gn(Number(a),o)},I.step]}return null}function nr({envConfig:e,bridgePairList:t,swapPools:o,enrichedTokens:s}){return(n,a)=>{let f=s[n],p=s[a];if(!f||!p||n===a)return null;let b=bn(n,a,t);if(b)return{type:"bridge",steps:[b],from:f,to:p};let u=yn(n,a,o,e);if(u)return{type:u.pathType,steps:[u.step],from:f,to:p};let w=er(n,a,o,t);if(w)return{type:"swap-bridge",steps:w,from:f,to:p};let I=tr(n,a,t,o,e);return I?{type:"bridge-swap",steps:I,from:f,to:p}:null}}function an(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 or(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function rr(e){return e.includes(".")?e.replace(/\.?0+$/,"")||"0":e}function sr(e,t){let o=e.startsWith("-"),s=o?e.slice(1):e,[n,a=""]=s.split("."),f=a.slice(0,t).replace(/0+$/,""),p=f?`${n}.${f}`:n;return o?`-${p}`:p}function ir(e){let t=e.startsWith("-"),o=t?e.slice(1):e,[s,n]=o.split("."),a=s.replace(/\B(?=(\d{3})+(?!\d))/g,","),f=n?`${a}.${n}`:a;return t?`-${f}`:f}function Pt(e){if(e==null||e==="")return"0";let t=String(e),o=Number(t);return!Number.isFinite(o)||o===0?"0":ir(sr(t,4))}function cn(e,t){if(e==null||e==="")return"0";try{return rr(bt(BigInt(String(e)),t.decimals))}catch{return"0"}}function At(e){return!!(e&&/^0x[0-9a-fA-F]+$/.test(e))}function ar(e){return e?new Date(e*1e3).toISOString():new Date().toISOString()}function cr(e,t){return t.toLowerCase()===e.contracts.W_CROSS.toLowerCase()?e.contracts.NATIVE_CROSS:t}function dr(e,t){let o=or(t);return{name:o,symbol:o,chainId:e,address:t,decimals:ot,balance:"0"}}function dn({envConfig:e,tokenByBridgeKey:t,chainId:o,address:s}){if(!s)return null;let n=cr(e,s);return t.get(ee(o,n))||t.get(ee(o,s))||dr(o,n)}function gt(e){return e?.toLowerCase()||""}function lr(e){if(e.source==="swap")return"swap";let t=gt(e.fromToken??e.from_token),o=gt(e.toToken??e.to_token),s=gt(e.swapTokenIn??e.swap_token_in),n=gt(e.swapTokenOut??e.swap_token_out);return o&&s&&o===s?"bridge-swap":t&&n&&t===n?"swap-bridge":"bridge"}function ur(e,t){let o=e.status??0,s=e.extracallSuccess??e.extracall_success??!1;return t==="bridge-swap"&&o===1&&!s?"failed":o===1?"success":"pending"}function mr({envConfig:e,item:t,tokenByBridgeKey:o}){let s=Number(t.fromChainID??t.from_chain_id??0),n=Number(t.toChainID??t.to_chain_id??0);if(!s||!n)return null;let a=lr(t),f=t.swapTokenIn??t.swap_token_in,p=t.swapTokenOut??t.swap_token_out,b=t.swapAmountIn??t.swap_amount_in,u=t.swapAmountOut??t.swap_amount_out,w=t.fromToken??t.from_token,I=t.toToken??t.to_token,x=t.value,m=t.value;a==="swap"?(w=f,I=p,x=b,m=u):a==="swap-bridge"?(w=f,x=b,m=t.value):a==="bridge-swap"&&(I=p,x=b,m=u);let C=dn({envConfig:e,tokenByBridgeKey:o,chainId:s,address:w}),P=dn({envConfig:e,tokenByBridgeKey:o,chainId:n,address:I}),v=t.initiatedTxHash??t.initiated_tx_hash;return!C||!P||!At(v)?null:{id:`${v}-${t.index??""}`,timestamp:ar(t.initiatedTime??t.initiated_time),txHash:v,fromToken:C,toToken:P,fromAmount:cn(x,C),toAmount:cn(m,P),summary:{pathType:a},status:ur(t,a)}}function pr(e){let t=new Map;return e.flat().forEach(o=>{let s=Number(o.chainId??o.chain_id),n=o.address?.toLowerCase();if(!s||!n)return;let a=o.quantity?.numeric??o.balance??"0",f=o.quantity?.decimals??o.decimals??ot;try{t.set(ee(s,n),bt(BigInt(a||"0"),f))}catch{t.set(ee(s,n),"0")}}),t}function Fe(e,t="first"){let o=e.steps.filter(s=>s.type==="swap");return t==="last"?o[o.length-1]:o[0]}function fr(e,t){let o=(e?.swapPools||e?.swap_pools)?.[String(t.chainIds.cross)];if(!o?.length)return"";let s=t.contracts.CROSSD.toLowerCase(),n=t.contracts.USDTX.toLowerCase(),a=o.find(f=>{let p=f.token0?.toLowerCase(),b=f.token1?.toLowerCase();return p===s&&b===n||p===n&&b===s});return a?.poolAddress||a?.pool_address||""}function gr(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 br(e){if(e===void 0)return;let t=10n**BigInt(ot),o=e>=50000n*t?"normal":e>10000n*t?"low":"rebalancing",s=Number(e>0n?e*100n/(100000n*t):0n);return{label:"Available Liquidity",status:o,percentage:Math.min(s,100)}}function nt(e,t,o,s){let n=[e.from,e.to].find(a=>a.chainId===t&&a.address.toLowerCase()===o.toLowerCase())??s?.[ee(t,o)];return{symbol:n?.symbol||o.slice(0,6),iconUrl:n?.image}}function yr(e,t){let o=[];for(let n of e.steps)n.type==="swap"?(o.push({chain:n.chain,address:n.fromToken}),o.push({chain:n.chain,address:n.toToken})):(o.push({chain:n.fromChain,address:n.fromToken}),o.push({chain:n.toChain,address:n.toToken}));let s=o.filter((n,a)=>a===0||!(n.chain===o[a-1].chain&&n.address.toLowerCase()===o[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(n=>nt(e,n.chain,n.address,t))}function wr({input:e,path:t,amountData:o,gasInfo:s,liquidity:n,enrichedTokens:a,priceImpact:f}){let p=e.fromAmount||"0",b=e.toAmount||"0",u=Fe(t),w=t.steps.find(_=>_.type==="bridge"),I=t.type!=="bridge",x=!ve(t.type),m=u?Ho(p,u.fee):"0",C=Number(p)>0||Number(b)>0,P=u?nt(t,u.chain,u.fromToken,a):{symbol:e.fromToken.symbol,iconUrl:e.fromToken.iconUrl},v=u?nt(t,u.chain,u.toToken,a):{symbol:e.toToken.symbol,iconUrl:e.toToken.iconUrl},T=w?nt(t,w.fromChain,w.fromToken,a):void 0,R=(_,q,te)=>C?q&&q>0n?{label:_,value:Xe(q),tone:"default",valueToken:te}:{label:_,value:"Free",tone:"accent"}:{label:_,value:"0"};return{pathType:t.type,priceImpact:f,liquidity:n,bridgeInfo:x&&w?[{label:"Route",value:`${tn(w.fromChain)} \u2192 ${tn(w.toChain)}`},R("Validator Fee",o?.exFee,T),R("Network Fee",o?.networkFee,T)]:void 0,swapInfo:I&&u?[{label:"Route",value:"",routeTokens:[nt(t,u.chain,u.fromToken,a),nt(t,u.chain,u.toToken,a)]},{label:"Price Impact",value:Ko(f)},{label:"In Amount",value:Pt(p),valueToken:P},{label:u&&ve(t.type)?`Swap Fee (${Vo(u.fee||be)})`:"Swap Fee",value:Pt(m),valueToken:P},{label:"Out Amount",value:Pt(b),valueToken:v}]: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 Rt({env:e,walletAddress:t,enabled:o=!0}){let s=_o(),n=Do[e],a=o,f=Io(new Map),p=tt({queryKey:["crossd-bridge-adapter",e,"pairs"],queryFn:({signal:r})=>Ge(`${n.bridgeApi}/pairs`,r),enabled:a,staleTime:3e4}),b=tt({queryKey:["crossd-bridge-adapter",e,"swap-pools"],queryFn:({signal:r})=>Ge(`${n.bridgeApi}/swap-pools`,r),enabled:a,staleTime:3e4}),u=Se(()=>fr(b.data,n),[n,b.data]),w=tt({queryKey:["crossd-bridge-adapter",e,"available-liquidity",u],queryFn:async()=>await Te(s,{address:n.contracts.USDTX,abi:It,functionName:"balanceOf",args:[u],chainId:n.chainIds.cross}),enabled:a&&!!u,staleTime:3e4}),I=tt({queryKey:["crossd-bridge-adapter",e,"token-info"],queryFn:({signal:r})=>Ge(`${n.walletApi}/v1/public/token/info`,r),enabled:a,staleTime:3e4}),x=tt({queryKey:["crossd-bridge-adapter",e,"token-stats"],queryFn:({signal:r})=>Ge(`${n.walletApi}/v1/public/token/stats`,r),enabled:a,staleTime:3e4}),m=Xt({queries:[n.chainIds.cross,n.chainIds.bsc].map(r=>({queryKey:["crossd-bridge-adapter",e,"balance",t,r],queryFn:({signal:i})=>{let c=new URLSearchParams({networkId:`eip155:${r}`,account:t||""});return Ge(`${n.walletApi}/v1/public/token/balance?${c}`,i)},enabled:a&&!!t,staleTime:0,refetchInterval:a&&t?5e3:!1}))}),C=Xt({queries:[n.chainIds.cross,n.chainIds.bsc].map(r=>({queryKey:["crossd-bridge-adapter",e,"gas-suggestion",r],queryFn:async({signal:i})=>{try{let h=await ln(s,{chainId:r})?.estimateFeesPerGas?.();if(h?.maxFeePerGas||h?.gasPrice)return{fast:{maxFee:h.maxFeePerGas?.toString()||h.gasPrice?.toString(),maxPriorityFee:h.maxPriorityFeePerGas?.toString()||"0"}}}catch{}let c=new URLSearchParams({chain_id:String(r),without_gas_limit:"false"});return Ge(`${n.walletApi}/v1/public/transaction/gas-suggestion/dynamic?${c}`,i)},enabled:a,staleTime:1e4,retry:1}))}),P=n.hiddenPairs,v=Se(()=>Jo({envConfig:n,bridgePairList:p.data,swapPools:b.data,tokenInfo:I.data,tokenStats:x.data}),[p.data,n,b.data,I.data,x.data]),T=Se(()=>nr({envConfig:n,bridgePairList:p.data,swapPools:b.data,enrichedTokens:v}),[p.data,v,n,b.data]),R=Se(()=>pr(m.map(r=>r.data).filter(r=>Array.isArray(r))),[m]),_=Se(()=>{let r=new Map;return Object.values(v).forEach(i=>{let c=an(i,R);r.set(i.key,c)}),r},[R,v]),q=Se(()=>{let r=new Map,i=_.get(ee(n.chainIds.cross,n.contracts.NATIVE_CROSS));i&&r.set(n.chainIds.cross,{symbol:i.symbol,iconUrl:i.iconUrl});let c=I.data?.find(d=>Number(d.chainId??d.chain_id)===n.chainIds.bsc&&(d.symbol??"").toUpperCase()==="BNB");return c&&r.set(n.chainIds.bsc,{symbol:c.symbol??"BNB",iconUrl:c.image??c.icon_url}),r},[n,_,I.data]),te=tt({queryKey:["crossd-bridge-adapter",e,"history",t],queryFn:({signal:r})=>en(`${n.bridgeApi}/history`,{owner:t,page:1,size:20,sort:"desc",status:"all"},r),enabled:a&&!!t,staleTime:0,refetchInterval:a&&t?5e3:!1}),H=Se(()=>(te.data?.histories||[]).map(r=>mr({envConfig:n,item:r,tokenByBridgeKey:_})).filter(r=>!!r),[te.data?.histories,n,_]),U=Se(()=>br(w.data),[w.data]),F=C[0]?.data,W=C[1]?.data,ye=Se(()=>{let r=new Map;return F&&r.set(n.chainIds.cross,F),W&&r.set(n.chainIds.bsc,W),r},[W,F,n.chainIds.bsc,n.chainIds.cross]),B=re((r,i,c)=>{let d=ye.get(r.from.chainId)?.fast,h=i?c?.gasLimit??pt(r.type):0n,l=c?.gasPrice&&c.gasPrice>0n?c.gasPrice:0n,g=c?.maxFeePerGas&&c.maxFeePerGas>0n?c.maxFeePerGas:0n,k=c?.maxPriorityFeePerGas&&c.maxPriorityFeePerGas>0n?c.maxPriorityFeePerGas:0n,y=Ue(d?.maxFee??d?.max_fee),D=Ue(d?.maxPriorityFee??d?.max_priority_fee),S=g>0n?g:y>0n?y:l,M=k>0n?k:D>0n?D:S,$=l>0n?l:S,G=mn.has(r.from.chainId)&&$>0n,Ce=h*(G?$:S),N=_.get(ee(r.from.chainId,n.contracts.NATIVE_CROSS)),Y=r.type!=="swap-bridge",Z=q.get(r.from.chainId);return{estTxFee:i?Xe(Ce):"0",priorityFeePerGas:i&&!G?St(M):"0",maxFeePerGas:i&&!G?St(S):"0",gasLimit:i?h.toString():"0",gasPrice:i&&G?St($):void 0,isDelegateFee:r.type==="swap-bridge"?!1:zo(n,r.from.address,r.to.address),tokenIconUrl:Y?N?.iconUrl:void 0,tokenSymbol:Y?N?.symbol:void 0,gasCurrencyIconUrl:Z?.iconUrl,gasCurrencySymbol:Z?.symbol}},[n,ye,q,_]),A=re(async r=>{let i=Qo(r);if(!i)return null;let c=`${e}:${i.from}:${i.to}:${i.token.toLowerCase()}`,d=f.current.get(c);if(d)return d;let h=(async()=>{let l=new URLSearchParams({from:String(i.from),to:String(i.to),token:i.token});try{return(await Ge(`${n.bridgeApi}/token-config?${l}`)).config??null}catch{return null}})();return f.current.set(c,h),h},[e,n.bridgeApi]),E=Se(()=>{let r=Object.values(v).map(c=>an(c,R)),i=ee(n.chainIds.cross,n.contracts.CROSSD);return r.sort((c,d)=>{let h=ie(c).toLowerCase()===i.toLowerCase(),l=ie(d).toLowerCase()===i.toLowerCase();return h!==l?h?-1:1:ie(c).localeCompare(ie(d))})},[R,v,n]),we=re(r=>{let i=ie(r),c=i.toLowerCase(),d=[];Object.keys(v).forEach(g=>{let k=g.toLowerCase();if(c===k||P.some(S=>S.fromKey===c&&S.toKey===k))return;let y=T(i,g);if(!y)return;let D=_.get(g);D&&d.push({token:D,path:y})});let h=ee(n.chainIds.cross,n.contracts.CROSSD),l=ee(n.chainIds.cross,n.contracts.NATIVE_CROSS);return d.sort((g,k)=>{if(c===h.toLowerCase()){let $=ie(g.token).toLowerCase()===l.toLowerCase(),G=ie(k.token).toLowerCase()===l.toLowerCase();if($!==G)return $?-1:1}let y=ve(g.path.type),D=ve(k.path.type);if(y!==D)return y?-1:1;let S=g.token.chainId===r.chainId,M=k.token.chainId===r.chainId;return S!==M?S?-1:1:ie(g.token).localeCompare(ie(k.token))}),d.map(g=>g.token)},[v,n,T,P,_]),qe=re(async r=>await Te(s,{address:n.contracts.SWAP_BRIDGE_ROUTER,abi:je,functionName:"quoter",chainId:r}),[n.contracts.SWAP_BRIDGE_ROUTER,s]),X=re(async r=>{Po(s)!==r&&await Ro(s,{chainId:r})},[s]),K=re(async r=>await Te(s,{address:n.contracts.SWAP_BRIDGE_ROUTER,abi:je,functionName:"swapRouter",chainId:r}),[n.contracts.SWAP_BRIDGE_ROUTER,s]),le=re(async({path:r,step:i,amount:c,source:d})=>{let h=await qe(i.chain),l=i.poolAddress?Te(s,{address:i.poolAddress,abi:Lo,functionName:"slot0",chainId:i.chain}).then(y=>y?.[0]).catch(()=>{}):Promise.resolve(void 0);if(d==="from"){let y=await Te(s,{address:h,abi:Jt,functionName:"quoteExactInputSingle",args:[{tokenIn:J(n,i.fromToken),tokenOut:J(n,i.toToken),amountIn:dt(c),fee:i.fee||be,sqrtPriceLimitX96:0n}],chainId:i.chain}),D=nn(await l,y[1]);return{amount:Xe(y[0]),path:r,priceImpact:D}}let g=await Te(s,{address:h,abi:Jt,functionName:"quoteExactOutputSingle",args:[{tokenIn:J(n,i.fromToken),tokenOut:J(n,i.toToken),amount:dt(c),fee:i.fee||be,sqrtPriceLimitX96:0n}],chainId:i.chain}),k=nn(await l,g[1]);return{amount:Xe(g[0]),path:r,priceImpact:k}},[n,qe,s]),he=re(async(r,i)=>{if(!t)throw new Error("Wallet is not connected.");let c=pt(i.type);if(ve(i.type)){let S=Fe(i,"first");if(!S)throw new Error("Swap route is not available.");let M=de(r.fromAmount),$=de(r.toAmount);if(M<=0n)throw new Error("Bridge amount is empty.");if($<=0n)throw new Error("Bridge quote is not ready.");let G=await K(S.chain),Q=vt($,r.slippage),Ce=i.type==="swap-withdraw"?un:t,N={tokenIn:J(n,S.fromToken),tokenOut:J(n,S.toToken),fee:S.fee||be,recipient:Ce,deadline:ct(),amountIn:M,amountOutMinimum:Q,sqrtPriceLimitX96:0n};if(i.type==="swap-withdraw"){let Y=at({abi:Ne,functionName:"exactInputSingle",args:[N]}),Z=at({abi:Ne,functionName:"unwrapWETH9",args:[Q,t]});return{address:G,abi:Ne,functionName:"multicall",args:[[Y,Z]],chainId:S.chain,fallbackGasLimit:c}}if(i.type==="deposit-swap"){let Y=at({abi:Ne,functionName:"exactInputSingle",args:[N]}),Z=at({abi:Ne,functionName:"refundETH",args:[]});return{address:G,abi:Ne,functionName:"multicall",args:[[Y,Z]],value:M,chainId:S.chain,fallbackGasLimit:c}}return{address:G,abi:Ne,functionName:"exactInputSingle",args:[N],chainId:S.chain,fallbackGasLimit:c}}if(i.type==="swap-bridge"){let S=Fe(i,"first");if(!S)throw new Error("Swap bridge route is not available.");let M=de(r.fromAmount),$=de(r.toAmount);if(M<=0n)throw new Error("Bridge amount is empty.");if($<=0n)throw new Error("Bridge quote is not ready.");let G=n.contracts.SWAP_BRIDGE_ROUTER,Q=ct(),Ce={toChainID:BigInt(i.to.chainId),recipient:t,extraData:"0x"},N={tokenIn:J(n,i.from.address),tokenOut:J(n,S.toToken),fee:S.fee||be,sqrtPriceLimitX96:0n,bridgeParams:Ce};if(r.lastChangedBy==="to"){let Z={...N,amountOut:$,amountInMaximum:$o(M,r.slippage)};return{address:G,abi:je,functionName:"swapBridgeExactOutputSingle",args:[Z,Q],value:i.from.isNativeToken?Z.amountInMaximum:void 0,chainId:i.from.chainId,fallbackGasLimit:c}}let Y={...N,amountIn:M,amountOutMinimum:vt(M,r.slippage)};return{address:G,abi:je,functionName:"swapBridgeExactInputSingle",args:[Y,Q],value:i.from.isNativeToken?M:void 0,chainId:i.from.chainId,fallbackGasLimit:c}}let d=i.steps.find(S=>S.type==="bridge");if(!d?.bridgeAddress)throw new Error("Bridge route is not available.");let h=de(r.fromAmount);if(h<=0n)throw new Error("Bridge amount is empty.");let l=await A(i),g=Ue(l?.gasFee??l?.gas_fee),k=sn(h,l?.exFeeRate??l?.ex_fee_rate),y="0x";if(i.type==="bridge-swap"){let S=Fe(i,"last");if(!S)throw new Error("Bridge swap route is not available.");let M=de(r.toAmount);if(M<=0n)throw new Error("Bridge quote is not ready.");let $=await K(i.to.chainId),G=vt(M,r.slippage),Q=at({abi:Ne,functionName:"exactInputSingle",args:[{tokenIn:J(n,S.fromToken),tokenOut:J(n,S.toToken),fee:S.fee||be,recipient:t,deadline:ct(),amountIn:h,amountOutMinimum:G,sqrtPriceLimitX96:0n}]});y=`${$}${Q.slice(2)}`}let D=[BigInt(i.to.chainId),i.from.address,t,h,g,k,y];return{address:d.bridgeAddress,abi:Mo,functionName:"bridgeToken",args:D,value:i.from.isNativeToken?h+k+g:void 0,chainId:i.from.chainId,fallbackGasLimit:c}},[n,A,K,t]),We=re(async(r,i)=>{if(i.type==="bridge"||i.type==="bridge-swap")return he(r,i);if(!t)throw new Error("Wallet is not connected.");let c=de(r.fromAmount);if(c<=0n)throw new Error("Bridge amount is empty.");if(i.type==="swap-bridge"){let g=Fe(i,"first");if(!g)throw new Error("Swap bridge route is not available.");let k=n.contracts.SWAP_BRIDGE_ROUTER,y={tokenIn:J(n,i.from.address),tokenOut:J(n,g.toToken),fee:g.fee||be,sqrtPriceLimitX96:0n,bridgeParams:{toChainID:BigInt(i.to.chainId),recipient:t,extraData:"0x"},amountIn:c,amountOutMinimum:0n};return{address:k,abi:je,functionName:"swapBridgeExactInputSingle",args:[y,ct()],value:i.from.isNativeToken?c:void 0,chainId:i.from.chainId,fallbackGasLimit:pt(i.type)}}let d=Fe(i,"first");if(!d)throw new Error("Swap route is not available.");let h=await K(d.chain),l={tokenIn:J(n,d.fromToken),tokenOut:J(n,d.toToken),fee:d.fee||be,recipient:t,deadline:ct(),amountIn:c,amountOutMinimum:0n,sqrtPriceLimitX96:0n};return{address:h,abi:Ne,functionName:"exactInputSingle",args:[l],value:i.from.isNativeToken?c:void 0,chainId:d.chain,fallbackGasLimit:pt(i.type)}},[he,n,K,t]),De=re(async(r,i)=>{if(!t)return null;try{let c=await We(r,i),d=ve(i.type)||i.type==="swap-bridge",h=await on(s,c.chainId,c.fallbackGasLimit,d,{account:t,address:c.address,abi:c.abi,functionName:c.functionName,args:c.args,value:c.value},!0);return{gasLimit:h.gas,gasPrice:h.gasPrice,maxFeePerGas:h.maxFeePerGas,maxPriorityFeePerGas:h.maxPriorityFeePerGas}}catch{return null}},[We,s,t]),ce=re(async r=>{let i=ie(r.fromToken),c=ie(r.toToken),d=T(i,c);if(!d)return{error:"Route is not available."};let h=r.lastChangedBy==="to"?r.toAmount:r.fromAmount,l=!!h&&Number(h)>0,g=gr(d,n)?U:void 0,k=async(N,Y,Z)=>{let Be=l?await De(N,d):null,_e=B(d,l,Be);return wr({input:N,path:d,gasInfo:_e,amountData:Y,liquidity:g,enrichedTokens:v,priceImpact:Z})};if(!h||Number(h)<=0)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r)};let y=await A(d),D=Ue(y?.gasFee??y?.gas_fee),S=d.type==="bridge"||d.type==="bridge-swap"?{networkFee:D}:void 0,M=jo({input:r,path:d,config:y});if(M)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r,S),error:M};let $=Xo({input:r,path:d,config:y});if($)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r,S),error:$};if(d.type==="bridge"){let N=r.lastChangedBy==="to"?{...r,fromAmount:r.toAmount}:{...r,toAmount:r.fromAmount};return{fromAmount:N.fromAmount,toAmount:N.toAmount,summary:await k(N,S)}}if(d.type==="swap-bridge"){let N=Fe(d,"first"),Y=n.contracts.SWAP_BRIDGE_ROUTER;if(!N)return{error:"Swap bridge route is not ready."};let Z=Ie=>le({path:d,step:N,amount:Ie,source:"from"}).then(ge=>ge.priceImpact).catch(()=>{});if(r.lastChangedBy==="from"){let Ie=await Te(s,{address:Y,abi:je,functionName:"getAmountSwapBridgeOut",args:[BigInt(d.to.chainId),J(n,d.from.address),J(n,N.toToken),N.fee||be,dt(r.fromAmount)],chainId:d.from.chainId}),ge=Xe(Ie[1]),rt={...r,toAmount:ge};return{toAmount:ge,summary:await k(rt,{networkFee:Ie[3],exFee:Ie[4]},await Z(r.fromAmount))}}let Be=await Te(s,{address:Y,abi:je,functionName:"getAmountSwapBridgeIn",args:[BigInt(d.to.chainId),J(n,d.from.address),J(n,N.toToken),N.fee||be,dt(r.toAmount)],chainId:d.from.chainId}),_e=Xe(Be[1]),ue={...r,fromAmount:_e};return{fromAmount:_e,summary:await k(ue,{networkFee:Be[3],exFee:Be[4]},await Z(_e))}}let G=d.type==="bridge-swap"?Fe(d,"last"):Fe(d,"first");if(!G)return{error:"Swap route is not available."};let Q=await le({path:d,step:G,amount:h,source:r.lastChangedBy});if(r.lastChangedBy==="from"){let N={...r,toAmount:Q.amount};return{toAmount:Q.amount,summary:await k(N,S,Q.priceImpact)}}let Ce={...r,fromAmount:Q.amount};return{fromAmount:Q.amount,summary:await k(Ce,S,Q.priceImpact)}},[U,B,v,n,De,T,A,le,s]),Ae=re(async r=>{if(r.from.isNativeToken)return null;if(r.type==="swap"||r.type==="deposit-swap"||r.type==="swap-withdraw")return K(r.from.chainId);if(r.type==="swap-bridge")return n.contracts.SWAP_BRIDGE_ROUTER;let i=r.steps.find(c=>c.type==="bridge");return i?.bridgeAddress?i.bridgeAddress:null},[n.contracts.SWAP_BRIDGE_ROUTER,K]),z=re(async r=>{if(!t)throw new Error("Wallet is not connected.");let i=ie(r.fromToken),c=ie(r.toToken),d=T(i,c);if(!d)throw new Error("Route is not available.");if(!ve(d.type)&&d.type!=="swap-bridge"||d.from.isNativeToken)return null;let h=de(r.fromAmount);if(h<=0n)return null;let l=await Ae(d);return!l||await Te(s,{address:d.from.address,abi:It,functionName:"allowance",args:[t,l],chainId:d.from.chainId})>=h?null:{token:r.fromToken,tokenAddress:d.from.address,spenderAddress:l,amount:r.fromAmount}},[T,Ae,s,t]),Ve=re(async(r,i)=>{let c=de(i.amount||r.fromAmount);if(c<=0n)throw new Error("Approval amount is empty.");await X(i.token.chainId);let d=await Yt(s,{address:i.tokenAddress,abi:It,functionName:"approve",args:[i.spenderAddress,c],chainId:i.token.chainId});await Bo(s,{hash:d,chainId:i.token.chainId})},[X,s]),He=re(async(r,i)=>{let c=await he(r,i);await X(c.chainId);let d=await on(s,c.chainId,c.fallbackGasLimit,Eo(i.type),{account:t,address:c.address,abi:c.abi,functionName:c.functionName,args:c.args,value:c.value});return{txHash:await Yt(s,{address:c.address,abi:c.abi,functionName:c.functionName,args:c.args,value:c.value,chainId:c.chainId,...d}),fromToken:r.fromToken,toToken:r.toToken,fromAmount:r.fromAmount,toAmount:r.toAmount}},[he,X,s,t]),ze=re(async(r,i)=>{let c=t;if(!c)throw new Error("Wallet is not connected.");let d=i.steps.find(rt=>rt.type==="bridge");if(!d?.bridgeAddress)throw new Error("Bridge route is not available.");let h=i.from.address,l=i.from.chainId,g=de(r.fromAmount);if(g<=0n)throw new Error("Bridge amount is empty.");let k=await A(i),y=Ue(k?.gasFee??k?.gas_fee),D=sn(g,k?.exFeeRate??k?.ex_fee_rate),S=g+D+y,[M,$]=await Promise.all([Te(s,{address:h,abi:Zt,functionName:"name",chainId:l}),Te(s,{address:h,abi:Zt,functionName:"nonces",args:[c],chainId:l})]),G=BigInt(Math.floor(Date.now()/1e3)+300),Q=await Ao(s,{domain:{name:M,version:"1",chainId:l,verifyingContract:h},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:c,spender:d.bridgeAddress,value:S,nonce:$,deadline:G}}),{r:Ce,s:N,v:Y,yParity:Z}=So(Q),Be=Y!==void 0?Number(Y):Z+27,_e={exFee:D.toString(),from:l,fromToken:h,nonce:Number($),gasFee:y.toString(),permitArgs:{account:c,deadline:G.toString(),r:Ce,s:N,token:h,v:Be,value:S.toString()},to:c,toChainID:String(i.to.chainId),value:S.toString()},ue=await en(`${n.bridgeApi}/permit`,_e),Ie=ue?.requestId??ue?.request_id;if(!Ie)throw new Error("Bridge permit request failed.");let ge=await Uo(n.bridgeApi,Ie);if(!At(ge))throw new Error("Bridge submitted, but confirmation timed out. Check History shortly.");return{txHash:ge,fromToken:r.fromToken,toToken:r.toToken,fromAmount:r.fromAmount,toAmount:r.toAmount}},[n,A,s,t]),Re=re(async r=>{let i=ie(r.fromToken),c=ie(r.toToken),d=T(i,c);if(!d)throw new Error("Route is not available.");if(!(ve(d.type)||d.type==="swap-bridge"||d.type==="bridge-swap"||d.type==="bridge"))throw new Error("This bridge route is not supported yet.");return{...d.type==="bridge"&&d.from.chainId===n.chainIds.bsc&&d.from.address.toLowerCase()===n.contracts.BSC_CROSS.toLowerCase()?await ze(r,d):await He(r,d),pathType:d.type,routeTokens:yr(d,v)}},[v,n,T,ze,He]);return{bridgeTokens:E,bridgeHistory:H,getBridgeApproval:z,approveBridge:Ve,getBridgeQuote:ce,getBridgeToTokens:we,submitBridge:Re,isLoading:p.isLoading||b.isLoading||I.isLoading||x.isLoading||m.some(r=>r.isLoading)}}import{useEffect as wn,useRef as hr,useState as hn}from"react";import{useAccount as Cr}from"wagmi";function Bt(e){let{address:t,connector:o}=Cr(),{currentWallet:s}=Ee(),n=e?.walletId!==void 0?e.walletId:s,a=e?.connector!==void 0?e.connector:o,f=e?.address!==void 0?e.address:t,[p,b]=hn({loginType:null,accountName:null,accounts:[],isResolved:!1}),u=hr(new Map),[w,I]=hn(0);return wn(()=>{let x=!1;if(n!=="cross_embedded")return b({loginType:null,accountName:null,accounts:[],isResolved:!0}),()=>{x=!0};if(!a)return b({loginType:null,accountName:null,accounts:[],isResolved:!1}),()=>{x=!0};b(v=>({...v,isResolved:!1}));let m=20,C=300,P=async()=>{if(typeof a.getProvider!="function")return"retry";let v;try{v=await a.getProvider()}catch{return"retry"}let T=v?.sdk;if(!T)return"giveup";try{let E=T.getRNBridgeActiveWallet?.(),we=E?.walletName?.trim();E&&we&&u.current.set(E.address.toLowerCase(),we)}catch{}let[R,_]=await Promise.all([T.getUserInfo?.().catch(()=>null)??null,T.getAddresses?.().catch(()=>null)??null]);if(x)return"done";let q=R?.loginType,te=q==="google"||q==="apple"?q:null;if(!te)return"retry";let H=f?.toLowerCase(),U=H&&Array.isArray(_)?_.find(E=>E.address.toLowerCase()===H):null,F=Array.isArray(_)?_.filter(E=>/^0x[a-fA-F0-9]{40}$/.test(E.address)).map(E=>({address:E.address.toLowerCase(),...Number.isFinite(E.index)?{index:E.index}:{},...E.name?.trim()?{name:E.name.trim()}:{}})):[],W=H?u.current.get(H)?.trim():void 0,ye=!U&&H&&/^0x[a-fA-F0-9]{40}$/.test(H)?[...F,{address:H,index:F.length,...W?{name:W}:{}}]:F,A=W||U?.name?.trim()||(typeof U?.index=="number"?`Account ${U.index+1}`:f?`${f.slice(0,6)}\u2026${f.slice(-4)}`:null);return b({loginType:te,accountName:A,accounts:ye,isResolved:!0}),"done"};return(async()=>{for(let v=0;v<m;v++){if(x)return;let T=await P();if(T==="done")return;if(T==="giveup"){x||b({loginType:null,accountName:null,accounts:[],isResolved:!0});return}await new Promise(R=>setTimeout(R,C))}x||b({loginType:null,accountName:null,accounts:[],isResolved:!0})})(),()=>{x=!0}},[n,a,f,w]),wn(()=>{if(n!=="cross_embedded"||!a||typeof a.getProvider!="function")return;let x=!1,m;return(async()=>{let C;try{C=await a.getProvider()}catch{return}if(x)return;let P=C?.sdk;P?.on&&(m=P.on("addressChanged",({address:v,walletName:T})=>{let R=T?.trim();R&&(u.current.set(v.toLowerCase(),R),I(_=>_+1))}))})(),()=>{x=!0,m?.()}},[n,a]),p}import{Fragment as xn,jsx as ae,jsxs as Ye}from"react/jsx-runtime";var Er=[{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"}]}],Or=[{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"}]}],Nr={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"}},Ot=10n**18n,Fr={google:{name:"Google",iconUrl:In,connectorId:$e.CROSSx},apple:{name:"Apple",iconUrl:Wt,connectorId:$e.CROSSx},cross:{name:"CROSSx",iconUrl:Ft,connectorId:$e.CROSSx},metamask:{name:"MetaMask",iconUrl:Sn,connectorId:$e.MetaMask},binance:{name:"Binance Wallet",iconUrl:Tn,connectorId:$e.Binance}};function Wr(e){switch(e){case"cross_embedded":return $e.CROSSx;case"metamask":return $e.MetaMask;case"binance":return $e.Binance;default:return}}function Dr(e,t){switch(e){case"cross_embedded":return t==="google"?{name:"Google",iconUrl:In}:t==="apple"?{name:"Apple",iconUrl:Wt}:{name:"CROSSx",iconUrl:Ft};case"cross_wallet":return{name:"CROSSx Wallet",iconUrl:Ft};case"cross_extension":return{name:"CROSSx Extension",iconUrl:_r};case"metamask":return{name:"MetaMask",iconUrl:Sn};case"binance":return{name:"Binance Wallet",iconUrl:Tn};default:return null}}function Lr({label:e="Connect Wallet",className:t,style:o,walletInfoStyle:s,user:n,enablePortfolio:a,portfolio:f,theme:p,accountName:b,connectorId:u,showPortfolio:w,sendAccounts:I,getTransactionReceipt:x,sendTransaction:m,estimateGas:C,onDisconnect:P,onSelectWallet:v,onBuy:T,onRampRedirectUrl:R,bridgeTokens:_,bridgeHistory:q,getBridgeQuote:te,getBridgeToTokens:H,getBridgeApproval:U,approveBridge:F,submitBridge:W,showBalance:ye=!0,env:B,...A}){let{address:E,isConnected:we,connector:qe,chain:X}=Tr(),K=Sr(),le=Ir(),{switchChainAsync:he}=Pr(),{sendTransactionAsync:We}=vr(),{connectWallet:De,disconnect:ce,selectWallet:Ae,currentWallet:z,isConnecting:Ve}=Ee(),He=it(),ze=p??He?.mode??"dark",Re=yt(()=>Ar(B),[B]),r=n?.address??E,i=n?Fr[n.provider]:null,{loginType:c,accountName:d,accounts:h}=Bt({walletId:z,connector:qe,address:r}),l=yt(()=>i?{name:i.name,iconUrl:i.iconUrl}:Dr(z,c),[i,z,c]),g=b??n?.name??d??void 0,k=i?i.connectorId:Wr(z),y=u??k,D=f??w??!!a,S=Rt({env:Re,walletAddress:r,enabled:we&&!!r&&ye}),M=_??S.bridgeTokens,$=q??S.bridgeHistory,G=te??S.getBridgeQuote,Q=H??S.getBridgeToTokens,Ce=U??S.getBridgeApproval,N=F??S.approveBridge,Y=W??S.submitBridge,Z=Ke(()=>{De().catch(O=>{console.error("[crossx-kit] connectWallet error:",O)})},[De]),Be=Ke(()=>{ce()},[ce]),_e=P??Be,ue=Rr(),{eligibility:Ie}=Br({network:X?String(X.id):void 0}),ge=Ie?.allowed===!0,rt=yt(()=>{if(T)return T;if(!(!ue||!X||!ge))return()=>ue.open({crypto:X.nativeCurrency?.symbol??"USDT",network:String(X.id),...R?{redirectUrl:R}:{}}).then(()=>{}).catch(O=>{throw console.warn("[crossx-kit] onramp open failed:",O),O})},[T,ue,X,ge,R]),Dt=xr();kr(()=>{if(ue?.onStatus)return ue.onStatus(()=>{Dt.invalidateQueries()})},[ue,Dt]);let Bn=yt(()=>{if(!T&&!(!ue||!X)&&!ge)return"On-ramp is not available in your region."},[T,ue,X,ge]),_n=n?n.provider==="google"||n.provider==="apple":z==="cross_embedded",En=Ke(()=>{Ae().catch(O=>{console.error("[crossx-kit] selectWallet error:",O)})},[Ae]),Lt=v??(_n?En:void 0),On=Ke(async({hash:O,chainId:ne})=>{let oe=_t(K,ne?{chainId:ne}:void 0);if(!oe)return null;try{return await oe.getTransactionReceipt({hash:O})}catch{return null}},[K]),Nn=Ke(async O=>{O.chainId!==void 0&&O.chainId!==le&&await he({chainId:O.chainId});let oe=O.chainId===56||O.chainId===97?{...O,type:"legacy"}:O;return(m??We)(oe)},[m,We,le,he]),Fn=D?Nn:m,Wn=Ke(async O=>{let ne=O.chainId??le,oe=_t(K,ne?{chainId:ne}:void 0);if(!oe)throw new Error(`publicClient for chainId ${ne??"unknown"} is not available \u2014 register the chain in createCrossxConfig({ networks }).`);let me=ne===56||ne===97,[pe,ke]=await Promise.all([oe.estimateGas({account:O.from,to:O.to,value:O.value,data:O.data}),(async()=>{if(me)return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await oe.getGasPrice()};try{let j=await oe.estimateFeesPerGas();return{maxFeePerGas:j.maxFeePerGas,maxPriorityFeePerGas:j.maxPriorityFeePerGas,gasPrice:void 0}}catch{return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await oe.getGasPrice()}}})()]);return{gasLimit:pe,maxFeePerGas:ke.maxFeePerGas,maxPriorityFeePerGas:ke.maxPriorityFeePerGas,gasPrice:ke.gasPrice}},[K,le]),Dn=C??Wn,Ln=Ke(async O=>{let ne={};if(!E||O.length===0)return ne;let oe=O.flatMap(pe=>{let j={address:pe,abi:Er,chainId:le};return[{...j,functionName:"balanceOf",args:[E]},{...j,functionName:"totalSupply"},{...j,functionName:"decimals"}]}),me;try{me=await Cn(K,{contracts:oe,allowFailure:!0})}catch{return ne}return O.forEach((pe,ke)=>{let j=ke*3,xe=me[j],lt=me[j+1],Ze=me[j+2];!xe||xe.status!=="success"||(ne[pe.toLowerCase()]={balance:xe.result,totalSupply:lt&<.status==="success"?lt.result:void 0,decimals:Ze&&Ze.status==="success"?Number(Ze.result):void 0})}),ne},[K,E,le]),Mn=Ke(async O=>{let ne={earnedWei:0n,stakedWei:0n};if(!O)return ne;let oe=Nr[Re],me={address:oe.poolAddress,abi:Or,chainId:oe.crossChainId},pe;try{pe=await Cn(K,{allowFailure:!0,contracts:[{...me,functionName:"earned",args:[O]},{...me,functionName:"balanceOf",args:[O]},{...me,functionName:"posaActive"},{...me,functionName:"lastRewardBlock"},{...me,functionName:"totalStaked"}]})}catch{return ne}let ke=Qe=>pe[Qe]&&pe[Qe].status==="success"?pe[Qe].result:0n,j=ke(0),xe=ke(1);if(pe[2]&&pe[2].status==="success"?pe[2].result:!1)return{earnedWei:j,stakedWei:xe};let Ze=ke(3),Ut=ke(4);if(Ut===0n)return{earnedWei:j,stakedWei:xe};let wt=0n;try{wt=await _t(K,{chainId:oe.crossChainId})?.getBlockNumber?.()??0n}catch{return{earnedWei:j,stakedWei:xe}}if(wt<=Ze)return{earnedWei:j,stakedWei:xe};let ht=0n;try{let Qe=await fetch(oe.networkStatsUrl).then(Ct=>Ct.json()),Kt=Qe?.data?.block_reward??Qe?.block_reward;if(Kt){let[Ct,$n=""]=String(Kt).split("."),qn=($n+"0".repeat(18)).slice(0,18);ht=BigInt(Ct||"0")*Ot+BigInt(qn||"0")}}catch{}if(ht===0n)return{earnedWei:j,stakedWei:xe};let Un=(wt-Ze)*ht*Ot/Ut,Kn=xe*Un/Ot;return{earnedWei:j+Kn,stakedWei:xe}},[K,Re]),Mt=!Lt,Gt=t?`cb-button ${t}`:"cb-button",Gn=t?`cb-pill ${t}`:"cb-pill";return Ve&&!we?Ye(xn,{children:[ae("style",{children:Nt}),Ye("button",{type:"button",disabled:!0,className:Gt,style:o,"aria-busy":"true",children:[ae("span",{className:"cb-spinner","aria-hidden":"true"}),ae("span",{className:"cb-button-label",children:"Connecting..."})]})]}):we&&r?Ye("span",{"data-crossx-wallet-info":Mt?"external":"embedded",children:[ae("style",{children:Nt}),Mt&&ae("style",{children:Gr}),Ye(Et,{...A,env:Re,theme:ze,showBalance:ye,walletAddress:r,accountName:g,sendAccounts:I??h,connectorId:y,showPortfolio:D,onDisconnect:_e,onSelectWallet:Lt,onBuy:rt,onBuyDisabledMessage:Bn,sendTransaction:Fn,getTransactionReceipt:x??On,estimateGas:Dn,lpBalanceReader:Ln,stakingRewardsReader:Mn,bridgeTokens:M,bridgeHistory:$,getBridgeQuote:G,getBridgeToTokens:Q,getBridgeApproval:Ce,approveBridge:N,submitBridge:Y,style:s,children:[ae(Et.Trigger,{asChild:!0,children:Ye("button",{type:"button",className:Gn,style:o,"aria-label":`Connected with ${l?.name??"wallet"}: ${kn(r)}`,children:[l?.iconUrl?ae("img",{src:l.iconUrl,alt:"",width:20,height:20,className:"cb-pill-icon","data-provider":l.iconUrl===Wt?"apple":void 0}):ae("span",{className:"cb-pill-icon-placeholder","aria-hidden":"true"}),ae("span",{className:"cb-pill-address",children:kn(r)})]})}),ae(Et.Content,{align:"end",sideOffset:8})]})]}):Ye(xn,{children:[ae("style",{children:Nt}),Ye("button",{type:"button",onClick:Z,className:Gt,style:o,"aria-label":typeof e=="string"?e:"Connect Wallet",children:[ae(Mr,{}),ae("span",{className:"cb-button-label",children:e})]})]})}function Mr(){return ae("svg",{className:"cb-button-icon",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:ae("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 Gr=`
|
|
2
|
+
[data-crossx-wallet-info="external"] .wi-select-wallet-btn {
|
|
3
|
+
display: none !important;
|
|
4
|
+
}
|
|
5
|
+
`;function kn(e){return`${e.slice(0,6)}...${e.slice(-4)}`}var Nt=`
|
|
6
|
+
.cb-button {
|
|
7
|
+
-webkit-font-smoothing: antialiased;
|
|
8
|
+
--cb-bg: var(--ds-accent-primary-default, #00D5AA);
|
|
9
|
+
--cb-bg-hover: var(--ds-accent-primary-high, #00a0a2);
|
|
10
|
+
--cb-color: var(--ds-accent-primary-on, #000);
|
|
11
|
+
--cb-border: none;
|
|
12
|
+
--cb-radius: 8px;
|
|
13
|
+
--cb-height: 36px;
|
|
14
|
+
--cb-padding: 0 16px;
|
|
15
|
+
--cb-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
16
|
+
--cb-font-size: 14px;
|
|
17
|
+
--cb-font-weight: 500;
|
|
18
|
+
--cb-gap: 8px;
|
|
19
|
+
--cb-transition: background-color 0.15s ease, transform 0.1s ease;
|
|
20
|
+
--cb-loading-opacity: 0.7;
|
|
21
|
+
--cb-press-scale: 0.95;
|
|
22
|
+
--cb-spinner-size: 14px;
|
|
23
|
+
--cb-spinner-thumb: currentColor;
|
|
24
|
+
--cb-spinner-track: color-mix(in srgb, currentColor 20%, transparent);
|
|
25
|
+
--cb-icon-size: 18px;
|
|
26
|
+
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
height: var(--cb-height);
|
|
32
|
+
gap: var(--cb-gap);
|
|
33
|
+
padding: var(--cb-padding);
|
|
34
|
+
border-radius: var(--cb-radius);
|
|
35
|
+
border: var(--cb-border);
|
|
36
|
+
background: var(--cb-bg);
|
|
37
|
+
color: var(--cb-color);
|
|
38
|
+
font-family: var(--cb-font-family);
|
|
39
|
+
font-size: var(--cb-font-size);
|
|
40
|
+
font-weight: var(--cb-font-weight);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
transition: var(--cb-transition);
|
|
43
|
+
}
|
|
44
|
+
.cb-button:hover:not(:disabled) { background: var(--cb-bg-hover); }
|
|
45
|
+
.cb-button:active:not(:disabled) { transform: scale(var(--cb-press-scale)); }
|
|
46
|
+
.cb-button:disabled, .cb-button[aria-busy="true"] {
|
|
47
|
+
cursor: default;
|
|
48
|
+
opacity: var(--cb-loading-opacity);
|
|
49
|
+
}
|
|
50
|
+
.cb-spinner {
|
|
51
|
+
display: inline-block;
|
|
52
|
+
width: var(--cb-spinner-size);
|
|
53
|
+
height: var(--cb-spinner-size);
|
|
54
|
+
border: 2px solid var(--cb-spinner-track);
|
|
55
|
+
border-top-color: var(--cb-spinner-thumb);
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
animation: cck-cb-spin 0.6s linear infinite;
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
}
|
|
60
|
+
.cb-button-icon {
|
|
61
|
+
width: var(--cb-icon-size);
|
|
62
|
+
height: var(--cb-icon-size);
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
}
|
|
65
|
+
.cb-button-label { white-space: nowrap; }
|
|
66
|
+
.cb-pill {
|
|
67
|
+
--cb-pill-bg: var(--ds-surface-default, #1e232e);
|
|
68
|
+
--cb-pill-bg-hover: var(--ds-surface-medium, #252b39);
|
|
69
|
+
--cb-pill-color: var(--ds-content-high, #ffffffd9);
|
|
70
|
+
--cb-pill-border: 1px solid var(--ds-border-default, #ffffff12);
|
|
71
|
+
--cb-pill-border-hover: 1px solid var(--ds-border-medium, #ffffff2e);
|
|
72
|
+
--cb-pill-radius: 8px;
|
|
73
|
+
--cb-pill-height: 36px;
|
|
74
|
+
--cb-pill-padding: 0 12px;
|
|
75
|
+
--cb-pill-press-scale: 0.95;
|
|
76
|
+
--cb-pill-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
77
|
+
--cb-pill-font-size: 14px;
|
|
78
|
+
--cb-pill-font-weight: 500;
|
|
79
|
+
--cb-pill-gap: 8px;
|
|
80
|
+
--cb-pill-icon-size: 20px;
|
|
81
|
+
--cb-pill-icon-placeholder-bg: var(--ds-surface-high, #2a2d3a);
|
|
82
|
+
--cb-pill-address-font: Inter, system-ui, -apple-system, sans-serif;
|
|
83
|
+
--cb-pill-address-font-size: 14px;
|
|
84
|
+
--cb-pill-address-letter-spacing: -0.01em;
|
|
85
|
+
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
box-sizing: border-box;
|
|
89
|
+
height: var(--cb-pill-height);
|
|
90
|
+
gap: var(--cb-pill-gap);
|
|
91
|
+
padding: var(--cb-pill-padding);
|
|
92
|
+
border-radius: var(--cb-pill-radius);
|
|
93
|
+
border: var(--cb-pill-border);
|
|
94
|
+
background: var(--cb-pill-bg);
|
|
95
|
+
color: var(--cb-pill-color);
|
|
96
|
+
font-family: var(--cb-pill-font-family);
|
|
97
|
+
font-size: var(--cb-pill-font-size);
|
|
98
|
+
font-weight: var(--cb-pill-font-weight);
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
.cb-pill:hover,
|
|
102
|
+
.cb-pill[data-state="open"] { background: var(--cb-pill-bg-hover); border: var(--cb-pill-border-hover, 1px solid var(--ds-border-medium, #ffffff2e)); }
|
|
103
|
+
.cb-pill:active:not(:disabled) { transform: scale(var(--cb-pill-press-scale)); }
|
|
104
|
+
.cb-pill-icon {
|
|
105
|
+
width: var(--cb-pill-icon-size);
|
|
106
|
+
height: var(--cb-pill-icon-size);
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
object-fit: contain;
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
background: transparent;
|
|
111
|
+
}
|
|
112
|
+
/* Apple is a monochrome black logomark in an <img> data URI (can't follow
|
|
113
|
+
theme via currentColor). Flip it to white in dark mode so it stays
|
|
114
|
+
visible on the dark pill; multicolor marks (Google/MetaMask/Binance/
|
|
115
|
+
CROSSx) are untouched. */
|
|
116
|
+
[data-theme="dark"] .cb-pill-icon[data-provider="apple"] {
|
|
117
|
+
filter: invert(1);
|
|
118
|
+
}
|
|
119
|
+
.cb-pill-icon-placeholder {
|
|
120
|
+
display: inline-block;
|
|
121
|
+
width: var(--cb-pill-icon-size);
|
|
122
|
+
height: var(--cb-pill-icon-size);
|
|
123
|
+
border-radius: 50%;
|
|
124
|
+
background: var(--cb-pill-icon-placeholder-bg);
|
|
125
|
+
flex-shrink: 0;
|
|
126
|
+
}
|
|
127
|
+
.cb-pill-address {
|
|
128
|
+
font-family: var(--cb-pill-address-font);
|
|
129
|
+
font-size: var(--cb-pill-address-font-size);
|
|
130
|
+
letter-spacing: var(--cb-pill-address-letter-spacing);
|
|
131
|
+
}
|
|
132
|
+
@media (max-width: 767.98px) {
|
|
133
|
+
.cb-button, .cb-pill {
|
|
134
|
+
width: 36px;
|
|
135
|
+
min-width: 36px;
|
|
136
|
+
padding: 0;
|
|
137
|
+
}
|
|
138
|
+
.cb-button-label, .cb-pill-address { display: none; }
|
|
139
|
+
}
|
|
140
|
+
@keyframes cck-cb-spin {
|
|
141
|
+
to { transform: rotate(360deg); }
|
|
142
|
+
}
|
|
143
|
+
`;import{useCallback as vn,useEffect as Ur,useMemo as Pn,useState as Kr}from"react";import{detectWallets as An,DEFAULT_WALLET_REGISTRY as Rn}from"@nexus-cross/connect-kit-wagmi";import{jsx as se,jsxs as Pe}from"react/jsx-runtime";var $r=["Ensure your wallet extension is installed and unlocked","Try refreshing the page","Some wallets may require you to first open the extension","You can try clicking the wallet anyway"],qr="Connect with one of our available wallet providers to continue.";function Vr({open:e,onClose:t,onSelect:o,title:s="Connect Wallet",description:n=qr,troubleshootingTips:a=$r}){let{availableWallets:f}=Ee(),[p,b]=Kr({});Ur(()=>{if(!e)return;let m=An(Rn),C={};for(let v of m)v.installed!==void 0&&(C[v.id]=v.installed);b(C);let P=setTimeout(()=>{let v=An(Rn),T={};for(let R of v)R.installed!==void 0&&(T[R.id]=R.installed);b(T)},1e3);return()=>clearTimeout(P)},[e]);let u=Pn(()=>typeof navigator>"u"?!1:/Mobi|Android/i.test(navigator.userAgent),[]),w=Pn(()=>u?f.filter(m=>m.type!=="extension"):f,[f,u]),I=vn(m=>{if(!p[m.walletId]&&m.installUrl&&m.type==="extension"){window.open(m.installUrl,"_blank");return}t(),o(m.walletId)},[t,o,p]),x=vn((m,C)=>{m.stopPropagation(),t(),window.open(C,"_blank")},[t]);return e?se("div",{style:L.overlay,onClick:t,children:Pe("div",{style:L.modal,onClick:m=>m.stopPropagation(),children:[Pe("div",{style:L.header,children:[se("h2",{style:L.title,children:s}),se("button",{type:"button",onClick:t,style:L.closeBtn,"aria-label":"Close",children:Pe("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[se("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),se("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),se("p",{style:L.desc,children:n}),se("div",{style:L.walletList,children:w.map(m=>{let C=p[m.walletId],P=C===!1&&m.type==="extension"&&!!m.installUrl;return Pe("div",{style:L.walletGroup,children:[Pe("button",{type:"button",onClick:()=>I(m),style:{...L.walletItem,...m.walletId==="cross_wallet"?L.walletItemAccent:{}},"aria-label":`Connect with ${m.name}`,children:[m.iconUrl?se("img",{src:m.iconUrl,alt:"",style:L.walletIcon}):se("div",{style:L.walletIconPlaceholder}),Pe("div",{style:L.walletInfo,children:[Pe("div",{style:L.walletNameRow,children:[se("span",{style:L.walletName,children:m.name}),C!==void 0&&se("span",{style:{...L.badge,...C?L.badgeInstalled:L.badgeNotInstalled},children:C?"Installed":"Not Installed"})]}),se("span",{style:L.walletDesc,children:P?"Extension not detected \u2014 click to install":m.type==="extension"?"Browser extension approval is required":m.walletId==="cross_wallet"?"App approval is required":m.walletId==="binance"?"Mobile app only \u2014 Add CROSS network first":C?"Connect with browser extension":"Scan QR code with app"})]})]}),m.guideUrl&&Pe("button",{type:"button",onClick:v=>x(v,m.guideUrl),style:L.guideBtn,children:[se("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),m.guideLabel??"Required Settings"]})]},m.walletId)})}),Pe("div",{style:L.troubleshoot,children:[se("h3",{style:L.troubleshootTitle,children:"Wallet not detected?"}),se("ul",{style:L.troubleshootList,children:a.map(m=>Pe("li",{style:L.troubleshootItem,children:[se("span",{style:L.troubleshootDot,"aria-hidden":"true"}),se("span",{children:m})]},m))})]})]})}):null}var V={surfaceBg:"var(--wi-surface-bg, #121212)",surfaceDefault:"var(--wi-surface-default, rgba(255,255,255,0.05))",surfaceSubtle:"var(--wi-surface-subtle, rgba(255,255,255,0.1))",borderDefault:"var(--wi-border-default, rgba(255,255,255,0.05))",textPrimary:"var(--wi-texticon-primary, #ffffff)",textSecondary:"var(--wi-texticon-secondary, rgba(255,255,255,0.7))",textTertiary:"var(--wi-texticon-tertiary, rgba(255,255,255,0.5))",primary:"var(--wi-primary, #019d92)",primarySoft:"var(--crossx-kit-primary-soft, rgba(1,157,146,0.15))",accentGradient:"var(--crossx-kit-accent-gradient, linear-gradient(113deg, rgba(255,255,255,0.05) 0%, rgba(1,157,146,0.12) 70%, rgba(255,255,255,0.05) 70%, rgba(1,157,146,0.12) 80%, rgba(255,255,255,0.05) 80%))",warningBg:"var(--crossx-kit-warning-bg, rgba(245,158,11,0.1))",warningBorder:"var(--crossx-kit-warning-border, rgba(245,158,11,0.25))",warningText:"var(--crossx-kit-warning-text, #fbbf24)"},L={overlay:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"},modal:{width:"100%",maxWidth:"420px",margin:"16px",background:V.surfaceBg,border:`1px solid ${V.borderDefault}`,borderRadius:"20px",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 0"},title:{fontSize:"18px",fontWeight:700,color:V.textPrimary,margin:0},closeBtn:{background:"none",border:"none",color:V.textTertiary,cursor:"pointer",padding:"4px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},desc:{padding:"8px 24px 16px",fontSize:"13px",color:V.textTertiary,margin:0,lineHeight:1.5},walletList:{display:"flex",flexDirection:"column",gap:"6px",padding:"0 12px 12px"},walletGroup:{display:"flex",flexDirection:"column",borderRadius:"12px",overflow:"hidden",background:V.surfaceDefault},walletItem:{display:"flex",alignItems:"center",gap:"14px",width:"100%",padding:"14px",background:"transparent",border:"none",color:V.textPrimary,cursor:"pointer",textAlign:"left"},walletItemAccent:{background:V.accentGradient},walletIcon:{width:"40px",height:"40px",borderRadius:"10px",flexShrink:0},walletIconPlaceholder:{width:"40px",height:"40px",borderRadius:"10px",background:V.surfaceSubtle,flexShrink:0},walletInfo:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"3px"},walletNameRow:{display:"flex",alignItems:"center",gap:"8px"},walletName:{fontSize:"15px",fontWeight:700,lineHeight:1.3,color:V.textPrimary},badge:{fontSize:"10px",fontWeight:600,padding:"2px 7px",borderRadius:"99px",lineHeight:1},badgeInstalled:{background:V.primarySoft,color:V.primary},badgeNotInstalled:{background:"rgba(255,255,255,0.05)",color:V.textTertiary},walletDesc:{fontSize:"11px",color:V.textSecondary,lineHeight:1.3},guideBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",margin:"0 14px 14px",padding:"10px 12px",borderRadius:"10px",border:`1px solid ${V.warningBorder}`,background:V.warningBg,color:V.warningText,fontWeight:600,fontSize:"13px",cursor:"pointer"},troubleshoot:{margin:"0 12px 16px",background:V.surfaceDefault,borderRadius:"12px",padding:"14px 16px"},troubleshootTitle:{fontSize:"12px",fontWeight:700,color:V.textPrimary,margin:"0 0 8px"},troubleshootList:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"8px"},troubleshootItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"11px",color:V.textSecondary,lineHeight:1.5},troubleshootDot:{flexShrink:0,width:"4px",height:"4px",marginTop:"6px",borderRadius:"50%",background:V.textSecondary}};import{useOnRamp as oi,useOnRampEligibility as ri,OnRampProvider as si}from"@nexus-cross/onramp/react";import{WalletInfo as ai,ConnectorId as ci}from"@nexus-cross/dapp-ui";import{AppLauncher as li,AppLauncherTrigger as ui,AppLauncherContent as mi,useGlobalMenu as pi}from"@nexus-cross/dapp-ui";import{SkillsButton as gi}from"@nexus-cross/dapp-ui";import{OnRampError as yi}from"@nexus-cross/connect-kit-core";import{ConnectionStatus as hi,formatBalance as Ci,formatWei as ki}from"@nexus-cross/connect-kit-core";$t();export{Ee as a,Xn as b,it as c,xt as d,To as e,Rt as f,Bt as g,Lr as h,Vr as i,oi as j,ri as k,si as l,ai as m,ci as n,li as o,ui as p,mi as q,pi as r,gi as s,yi as t,hi as u,Ci as v,ki as w};
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S,b as _,c as V,d as X,e as W,f as h,g as j,h as F,i as L,j as B,k as U,l as q,m as z,n as D,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as $,v as ee,w as ne}from"./chunk-
|
|
1
|
+
import{a as S,b as _,c as V,d as X,e as W,f as h,g as j,h as F,i as L,j as B,k as U,l as q,m as z,n as D,o as G,p as H,q as J,r as Q,s as Y,t as Z,u as $,v as ee,w as ne}from"./chunk-5EKJPAF3.js";import{bscMainnetNetwork as v,bscTestnetNetwork as x,createCrossxConfig as E,crossMainnetNetwork as O,crossTestnetNetwork as k}from"@nexus-cross/connect-kit-wagmi";import{toNexusAdapter as M}from"@nexus-cross/connect-kit-wagmi/to-nexus";import{reownAdapter as P}from"@nexus-cross/connect-kit-wagmi/reown";import{embeddedConnectorFactory as A}from"@nexus-cross/connect-kit-wagmi/embedded";function d(e){try{return import.meta.env?.[e]}catch{return}}function p(e){if(!(typeof process>"u"))return process.env?.[e]}function I(){return d("VITE_CROSSX_ENVIRONMENT")??d("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("NEXT_PUBLIC_CROSSX_ENVIRONMENT")??p("CROSSX_ENVIRONMENT")}function K(e){switch(e?.toLowerCase()){case"dev":case"development":return"development";case"stage":case"staging":case"stg":return"staging";default:return"production"}}function R(e){return e==="production"?[O,v]:[k,x]}function T(){return{name:"CROSSx DApp",url:typeof window<"u"&&window.location?.origin?window.location.origin:"https://example.com"}}function b(e){let{app:c,appMetadata:l,networks:u,defaultNetwork:f,wallets:n,embedded:C=!0,environment:w,toNexus:t,reown:o,...r}=e,g=K(w??I()),i=u??R(g),a=Array.isArray(n)?null:n??"all",s=a!=="external-only"&&t!==!1,m=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??T(),networks:i,defaultNetwork:f??i[0],...Array.isArray(n)?{wallets:n}:{},...s?{crossProvider:M(y)}:{},...m?{reownProvider:P(N)}:{},...s&&C?{embeddedConnectorFactory:A}:{}})}export{G as AppLauncher,J as AppLauncherContent,H as AppLauncherTrigger,F as ConnectButton,$ as ConnectionStatus,D as ConnectorId,W as CrossConnectKitProvider,X as CrossConnectModal,Z as OnRampError,q as OnRampProvider,L as OtherWalletsModal,Y as SkillsButton,z as WalletInfo,b as createConnectKitConfig,ee as formatBalance,ne as formatWei,S as useCrossConnectKit,_ as useCrossConnectKitTheme,h as useCrossdBridgeAdapter,j as useCrossxEmbeddedInfo,Q as useGlobalMenu,B as useOnRamp,U as useOnRampEligibility,V as useOptionalCrossConnectKitTheme};
|
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}from"./chunk-
|
|
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}from"./chunk-5EKJPAF3.js";export{o as AppLauncher,q as AppLauncherContent,p as AppLauncherTrigger,h as ConnectButton,u as ConnectionStatus,n as ConnectorId,e as CrossConnectKitProvider,d as CrossConnectModal,t as OnRampError,l as OnRampProvider,i as OtherWalletsModal,s as SkillsButton,m as WalletInfo,v as formatBalance,w as formatWei,a as useCrossConnectKit,b as useCrossConnectKitTheme,f as useCrossdBridgeAdapter,g as useCrossxEmbeddedInfo,r as useGlobalMenu,j as useOnRamp,k as useOnRampEligibility,c as useOptionalCrossConnectKitTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/connect-kit-react",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.5",
|
|
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,11 +24,11 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nexus-cross/connect-kit-core": "1.3.3-beta.
|
|
28
|
-
"@nexus-cross/connect-kit-wagmi": "1.3.3-beta.
|
|
29
|
-
"@nexus-cross/crossx-design-system": "1.3.3-beta.
|
|
30
|
-
"@nexus-cross/
|
|
31
|
-
"@nexus-cross/
|
|
27
|
+
"@nexus-cross/connect-kit-core": "1.3.3-beta.5",
|
|
28
|
+
"@nexus-cross/connect-kit-wagmi": "1.3.3-beta.5",
|
|
29
|
+
"@nexus-cross/crossx-design-system": "1.3.3-beta.5",
|
|
30
|
+
"@nexus-cross/dapp-ui": "1.3.3-beta.5",
|
|
31
|
+
"@nexus-cross/onramp": "1.3.3-beta.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@tanstack/react-query": "^5.60.0",
|
package/dist/chunk-RRDG2DCB.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
var ot="1.3.3";var dt="__nexusCrossAppLauncherRuntime";function Vn(){if(typeof window>"u")return null;let e=window;return e[dt]??(e[dt]={mode:"dapp-ui"}),e[dt]}function Hn(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 o=e.connectKitVersion??ot;console.info(`[CROSSx App Launcher] connect-kit-react v${o} \uCD08\uAE30\uD654 \uC644\uB8CC (dapp-ui v${ot}, \uC0AC\uC6A9 \uBAA8\uB4DC: connect-kit)`)}else console.info(`[CROSSx App Launcher] dapp-ui v${ot} \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 $t(){let e=Vn();e&&(e.mode="connect-kit-react",e.connectKitVersion=ot,Hn(e))}import{useCallback as Re,useEffect as pe,useMemo as We,useRef as Ze,useState as De}from"react";import{WagmiProvider as Jn,useAccount as eo,useConnect as to,useDisconnect as no}from"wagmi";import{QueryClient as oo,QueryClientProvider as ro}from"@tanstack/react-query";import{clearWalletSessionStorage as so,onOpenOtherWallets as io,pickInitialState as ao,resolveCurrentWallet as co}from"@nexus-cross/connect-kit-wagmi";import{resolveThemeMode as lo}from"@nexus-cross/connect-kit-core";import{buildDesignSystemCss as uo}from"@nexus-cross/crossx-design-system";import{OnRampProvider as mo}from"@nexus-cross/onramp/react";import{createContext as zn,useContext as Qn}from"react";var Ct=zn(null);function Pe(){let e=Qn(Ct);if(!e)throw new Error("useCrossConnectKit must be used within <CrossConnectKitProvider>");return e}import{createContext as jn,useContext as qt}from"react";var lt=jn(null);function Xn(){let e=qt(lt);if(!e)throw new Error("useCrossConnectKitTheme must be used within <CrossConnectKitProvider>");return e}function rt(){return qt(lt)}import{useCallback as Yn,useMemo as Vt}from"react";import{WalletConnectModal as Ht}from"@nexus-cross/dapp-ui";import{jsx as zt}from"react/jsx-runtime";var Zn=new Set(["cross_wallet","cross_extension","metamask","binance"]);function kt({open:e,onOpenChange:t}){let{connect:o,availableWallets:s,oauth:n,extraWallets:a,walletAllowlist:f}=Pe(),p=rt()?.mode??"dark",b=Vt(()=>{let C=f?new Set(f):null,u={};for(let h of s){if(!Zn.has(h.walletId)||C&&!C.has(h.walletId))continue;let A=h.walletId;u[A]=()=>{o(h.walletId)}}for(let[h,A]of Object.entries(a))A&&(C&&!C.has(h)||(u[h]=A));return u},[s,o,a,f]),w=Vt(()=>{if(n)return{apple:()=>{n.signIn("apple")},google:()=>{n.signIn("google")}}},[n]),I=Yn(C=>t(C),[t]);return zt(Ht,{wallets:b,socialProviders:w,theme:p,open:e,onOpenChange:I,children:zt(Ht.Content,{})})}import{jsx as Je,jsxs as jt}from"react/jsx-runtime";var po=new oo,Tt="crossx-kit:last-wallet-intent";function fo(e){let t=[],o=e,s=0;for(;o&&s<5;){let n=o;typeof n.message=="string"&&t.push(n.message),o=n.cause,s+=1}return t.some(n=>/external wallet connection/i.test(n))}function go(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Tt)??null}catch{return null}}function Qt(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Tt,e):window.localStorage.removeItem(Tt)}catch{}}function bo(e,t){if(typeof window>"u")return t;try{let o=window.localStorage.getItem(e);return o==="cross"||o==="reown"?o:t}catch{return t}}function yo(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function ho({children:e,config:t,activeProvider:o,onRequestProviderSwap:s,pendingConnectWalletId:n,clearPending:a,themeMode:f,themeTokens:m,extraWallets:p,walletAllowlist:b}){let[w,I]=De(!1),[C,u]=De(()=>go()),[h,A]=De(null),{address:S,isConnected:T,isConnecting:R,isReconnecting:_,connector:K}=eo(),{connectors:Z,connectAsync:H}=to(),{disconnectAsync:G}=no(),{kitConfig:W,connectorRegistry:D,crossProvider:be,reownProvider:B}=t,P=o==="cross"?be:B,E=We(()=>!T||!K?null:co(D,K.id,C),[T,K,D,C]),ye=We(()=>D.entries.filter(d=>d.type!=="embedded"),[D]),Ke=Ze(S);Ke.current=S;let X=W.embeddedProjectId?.trim()||W.crossProjectId?.trim(),U=!!W.onRampEnabled&&!!X,fe=We(()=>!U||!X?null:{projectId:X,walletState:{getAddress:()=>Ke.current}},[U,X]);pe(()=>io(()=>I(!0)),[]),pe(()=>{if(!w||typeof document>"u")return;let d=setTimeout(()=>{document.querySelectorAll("#__crossx-confirm-overlay").forEach(g=>g.remove())},50);return()=>clearTimeout(d)},[w]);let he=Ze(T),Ee=Ze(T);he.current=T;let Oe=Ze(!1);pe(()=>{console.debug("[crossx-kit] state",{activeProvider:o,isConnected:T,isConnecting:R,isReconnecting:_,activeConnectorId:K?.id,currentWallet:E,lastIntent:C})},[o,T,R,_,K?.id,E,C]),pe(()=>{T&&!Ee.current&&P?.closeModal?.({kitConfig:W}),Ee.current=T},[T,P,W]),pe(()=>{T&&A(null)},[T]);let de=Re(d=>Z.find(g=>g.id===d),[Z]);pe(()=>{let d=D.getEntry("cross_embedded");if(!d)return;let g=de(d.connectorId);if(!g)return;let k=!1;return(async()=>{try{let y=await g.getProvider();if(k)return;y?.sdk?.applyTheme?.(f,m??void 0)}catch(y){console.debug("[crossx-kit] applyTheme skipped:",y)}})(),()=>{k=!0}},[D,de,f,m]);let Se=Re(d=>{u(d),Qt(d)},[]),z=Re(()=>{u(null),Qt(null),A(null)},[]);pe(()=>{if(!P?.subscribeModalState)return;let d=!1;return P.subscribeModalState({kitConfig:W},g=>{if(Oe.current=g,g){d=!0;return}d&&(d=!1,setTimeout(()=>{he.current||(async()=>{try{await G()}catch{}z()})()},250))})},[P,W,G,z]),pe(()=>{if(!h||T||typeof window>"u"||h==="cross_embedded")return;let d=typeof document<"u"&&!document.hasFocus(),g=null,k=()=>{d=!0},y=()=>{d&&(g&&clearTimeout(g),g=setTimeout(()=>{he.current||Oe.current||(async()=>{try{await G()}catch{}z()})()},1e3))};return window.addEventListener("blur",k),window.addEventListener("focus",y),()=>{window.removeEventListener("blur",k),window.removeEventListener("focus",y),g&&clearTimeout(g)}},[h,T,G,z]);let $e=Re(async d=>{console.debug("[crossx-kit] runConnect enter",{walletId:d,activeProvider:o,isConnected:T,activeConnectorId:K?.id});let g=D.getEntry(d);if(!g){if((d==="metamask"||d==="binance")&&!B){console.error(`[crossx-kit] "${d}" 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: "${d}"`);return}if(A(d),g.providerKind!==o){console.debug("[crossx-kit] provider swap needed",{from:o,to:g.providerKind,walletId:d}),Se(d);try{await G()}catch{}await new Promise(y=>setTimeout(y,0)),s(g.providerKind,d);return}if(Se(d),P?.beforeConnect)try{let y=await P.beforeConnect({kitConfig:W,themeMode:f},d);if(console.debug("[crossx-kit] beforeConnect result",{walletId:d,result:y}),y==="handled")return}catch(y){console.warn('[crossx-kit] adapter.beforeConnect threw for "%s":',d,y)}let k=de(g.connectorId);if(console.debug("[crossx-kit] findConnector",{lookupId:g.connectorId,found:k?.id,availableIds:Z.map(y=>y.id)}),!k){console.error(`[crossx-kit] Connector "${g.connectorId}" not found on provider "${g.providerKind}". Available: ${Z.map(y=>y.id).join(", ")}`),z();return}try{console.debug("[crossx-kit] connectAsync start",{connectorId:k.id});let y=await H({connector:k});console.debug("[crossx-kit] connectAsync resolved",{accountsLen:y.accounts.length,chainId:y.chainId});return}catch(y){if(!fo(y)){console.error('[crossx-kit] connectAsync error for "%s":',d,y);try{await G()}catch{}}if(!g.fallbackConnectorId){z();return}}if(g.fallbackConnectorId){let y=de(g.fallbackConnectorId);if(y)try{await H({connector:y})}catch(F){console.error('[crossx-kit] Fallback connect failed for "%s":',d,F);try{await G()}catch{}z()}else z()}},[D,Z,de,H,G,Se,z,P,o,W,s,f]);pe(()=>{if(!n)return;let d=n;a(),$e(d)},[n,o]);let qe=Re(async()=>{I(!0)},[]),Ve=Re(async()=>{try{await G()}catch(d){console.error("[crossx-kit] wagmi disconnect error:",d)}if(P?.teardown)try{await P.teardown({kitConfig:W})}catch(d){console.error("[crossx-kit] adapter teardown error:",d)}so(),z()},[G,P,W,z]),ve=Re(async()=>{let d=D.getEntry("cross_embedded");if(!d)return null;let g=de(d.connectorId);if(!g)return null;try{let k=await g.getProvider(),y=k?.sdk;if(!y?.selectWallet)return null;let F=await y.selectWallet(y.currentAddress??void 0);return F?.address&&k.notifyAccountsChanged&&k.notifyAccountsChanged([F.address]),F}catch{return null}},[D,de]),r=We(()=>{let d=t.oauth;return d?{signIn:async g=>{A("cross_embedded");try{await d.signIn(g)}catch(k){throw A(null),k}}}:null},[t.oauth]),i=Ze(!1);pe(()=>{if(o!=="cross"||T||R||_||h!=null||i.current)return;let d=D.getEntry("cross_embedded");if(!d)return;let g=de(d.connectorId);if(!g)return;let k=!1;return(async()=>{try{let y=await g.isAuthorized?.();if(k||!y||i.current)return;i.current=!0,await H({connector:g})}catch{}})(),()=>{k=!0}},[o,T,R,_,h,D,de,H]);let l=h!=null&&!T,c=We(()=>({kitConfig:W,connectorRegistry:D,availableWallets:ye,connect:$e,connectWallet:qe,disconnect:Ve,selectWallet:ve,currentWallet:E,lastIntent:C,isConnecting:l,connectingWalletId:h,openOtherWallets:()=>I(!0),closeOtherWallets:()=>I(!1),otherWalletsOpen:w,oauth:r,extraWallets:p,walletAllowlist:b,onRampEnabled:U}),[W,D,ye,$e,qe,Ve,ve,E,C,l,h,w,r,p,b,U]),x=jt(Ct.Provider,{value:c,children:[e,Je(kt,{open:w,onOpenChange:I})]});return fe?Je(mo,{config:fe,children:x}):x}var wo=[/Connection interrupted while trying to subscribe/i,/No matching key\. subscription:/i,/Proposal expired/i];function Co(e){let t=e?.message;return typeof t!="string"?!1:wo.some(o=>o.test(t))}var ko={};function To(e){return e&&{...e,connections:new Map,current:null}}function xo({children:e,config:t,initialState:o,extraWallets:s=ko,walletAllowlist:n}){let[a,f]=De(()=>bo(t.activeProviderStorageKey,t.defaultProvider)),[m,p]=De(null),b=Ze(!1),{kitConfig:w}=t,[I,C]=De(null),[u,h]=De(null),[A,S]=De(0),T=We(()=>lo(w.theme,w.autoDetectTheme),[w.theme,w.autoDetectTheme,A]),R=I??T,_=u??w.themeTokens;pe(()=>{if(!w.autoDetectTheme||I||typeof window>"u"||!window.matchMedia)return;let B=window.matchMedia("(prefers-color-scheme: dark)"),P=()=>S(E=>E+1);try{return B.addEventListener("change",P),()=>B.removeEventListener("change",P)}catch{return B.addListener(P),()=>B.removeListener(P)}},[w.autoDetectTheme,I]),pe(()=>{if(typeof document>"u")return;let B=document.documentElement,P=B.getAttribute("data-ds-theme"),E=B.getAttribute("data-theme");return B.setAttribute("data-ds-theme",R),E||B.setAttribute("data-theme",R),()=>{P==null?B.removeAttribute("data-ds-theme"):B.setAttribute("data-ds-theme",P),E==null&&B.removeAttribute("data-theme")}},[R]);let K=We(()=>uo(t.designSystem),[t.designSystem]),Z=We(()=>({mode:R,tokens:_,setThemeMode:B=>C(B),setThemeTokens:B=>h(B)}),[R,_]);pe(()=>{if(typeof window>"u")return;let B=P=>{Co(P.reason)&&P.preventDefault()};return window.addEventListener("unhandledrejection",B),()=>window.removeEventListener("unhandledrejection",B)},[]);let H=Re((B,P)=>{b.current||(b.current=!0,p(P),f(B),yo(t.activeProviderStorageKey,B),queueMicrotask(()=>{b.current=!1}))},[t.activeProviderStorageKey]),G=Re(()=>p(null),[]),W=a==="cross"?t.crossWagmiConfig:t.reownWagmiConfig,D=To(ao(o,a));if(!W){if(!(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig))throw new Error("[crossx-kit] createCrossxConfig returned no wagmi Config for either side");let P=a==="cross"?"reown":"cross";queueMicrotask(()=>f(P))}let be=W??(a==="cross"?t.reownWagmiConfig:t.crossWagmiConfig);return jt(lt.Provider,{value:Z,children:[Je("style",{"data-crossx-design-system":"",children:K}),Je(Jn,{config:be,initialState:D,children:Je(ro,{client:po,children:Je(ho,{config:t,activeProvider:a,onRequestProviderSwap:H,pendingConnectWalletId:m,clearPending:G,themeMode:R,themeTokens:_,extraWallets:s,walletAllowlist:n??t.kitConfig.wallets??null,children:e})})},a)]})}import{useCallback as Ge,useEffect as kr,useMemo as gt}from"react";import{useQueryClient as Tr}from"@tanstack/react-query";import{useAccount as xr,useChainId as Ir,useConfig as Sr,useSendTransaction as vr,useSwitchChain as Ar}from"wagmi";import{getPublicClient as _t,readContracts as Cn}from"wagmi/actions";import{WalletInfo as Et,ConnectorId as Ue,resolveEnvironment as Pr}from"@nexus-cross/dapp-ui";import{useOptionalOnRamp as Rr,useOptionalOnRampEligibility as Br}from"@nexus-cross/onramp/react";import{APPLE_ICON as Dt,BINANCE_ICON as xn,CROSSX_ICON as Wt,EXTENSION_ICON as _r,GOOGLE_ICON as In,METAMASK_ICON as Sn}from"@nexus-cross/connect-kit-wagmi";import{useCallback as te,useMemo as xe,useRef as Io}from"react";import{useQueries as Xt,useQuery as et}from"@tanstack/react-query";import{encodeFunctionData as st,formatUnits as ft,parseSignature as So,parseUnits as vo}from"viem";import{getChainId as Ao,getPublicClient as ln,readContract as ke,signTypedData as Po,switchChain as Ro,waitForTransactionReceipt as Bo,writeContract as Yt}from"wagmi/actions";import{useConfig as _o}from"wagmi";function Eo(e){return e!=="bridge"}var un="0x0000000000000000000000000000000000000000",Te=100,nt=18,Oo=180000n,No=250000n,mn=new Set([56,97]),Wo=130n,Do=100n,Lo={dev:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97},contracts:{BSC_CROSS:"0x26ca2a92ea9659e073621bb85b9117dc5944cff1",W_CROSS:"0xda37a3B60E6b97E8CB44b460130d40331efc566b",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x9f85c7b5d7637e18f946cc8af9c131318c6833d9",CROSSD:"0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",USDTB:"0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",SWAP_BRIDGE_ROUTER:"0x337071C06416f13b568eE644c1D714edd65509eB"},hiddenPairs:[{fromKey:"97-0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"97-0x26ca2a92ea9659e073621bb85b9117dc5944cff1",toKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb"}]},stage:{bridgeApi:"https://stg-bridge-api.crosstoken.io/bridge",walletApi:"https://stg-wallet-server.crosstoken.io/api",chainIds:{cross:612044,bsc:97},contracts:{BSC_CROSS:"0x26ca2a92ea9659e073621bb85b9117dc5944cff1",W_CROSS:"0xda37a3B60E6b97E8CB44b460130d40331efc566b",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x9f85c7b5d7637e18f946cc8af9c131318c6833d9",CROSSD:"0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",USDTB:"0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",SWAP_BRIDGE_ROUTER:"0x337071C06416f13b568eE644c1D714edd65509eB"},hiddenPairs:[{fromKey:"97-0xbb188503c32fa7f61e019c3b3ae61ae6b0b3b492",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb",toKey:"612044-0x9f85c7b5d7637e18f946cc8af9c131318c6833d9"},{fromKey:"97-0x26ca2a92ea9659e073621bb85b9117dc5944cff1",toKey:"612044-0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb"}]},production:{bridgeApi:"https://bridge-api.crosstoken.io/bridge",walletApi:"https://wallet-server.crosstoken.io/api",chainIds:{cross:612055,bsc:56},contracts:{BSC_CROSS:"0x6bf62ca91e397b5a7d1d6bce97d9092065d7a510",W_CROSS:"0x731a104a4461ae45bfef520468b43c262d35e682",NATIVE_CROSS:"0x0000000000000000000000000000000000000001",USDTX:"0x1c37d4f44ed3ec86d96868001cfa89e97112a85c",CROSSD:"0xff42c13d927a6b9265236619161accb227b6d452",USDTB:"0x55d398326f99059ff775485246999027b3197955",SWAP_BRIDGE_ROUTER:"0xB298C340816fee45cfB39B1e6EE4DB4D5739e357"},hiddenPairs:[{fromKey:"56-0x55d398326f99059ff775485246999027b3197955",toKey:"612055-0x1c37d4f44ed3ec86d96868001cfa89e97112a85c"},{fromKey:"612055-0xff42c13d927a6b9265236619161accb227b6d452",toKey:"612055-0x1c37d4f44ed3ec86d96868001cfa89e97112a85c"},{fromKey:"56-0x6bf62ca91e397b5a7d1d6bce97d9092065d7a510",toKey:"612055-0xff42c13d927a6b9265236619161accb227b6d452"}]}},tt=[{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"}]}],Zt=[{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"}]}],Jt=[{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"}]}],Fo=[{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"}]}],Be=[{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:[]}],Mo=[{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 pn(e){let t="";try{t=await e.text()}catch{}if(t){try{let o=JSON.parse(t),s=typeof o.data=="string"&&o.data||typeof o.message=="string"&&o.message||"";if(s)return`${s} (status ${e.status})`}catch{}return`${t.slice(0,300)} (status ${e.status})`}return`status ${e.status}`}async function Le(e,t){let o=await fetch(e,{cache:"no-store",signal:t});if(!o.ok)throw new Error(`CrossD bridge adapter request failed: ${await pn(o)}`);let s=await o.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 en(e,t,o){let s=await fetch(e,{method:"POST",cache:"no-store",signal:o,headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`CrossD bridge adapter request failed: ${await pn(s)}`);let n=await s.json();if(n&&typeof n=="object"&&"code"in n&&typeof n.code=="number"&&n.code!==200)throw new Error(n.message||`CrossD bridge adapter API error: ${n.code}`);return n&&typeof n=="object"&&"data"in n?n.data:n}function Go(e){return new Promise(t=>setTimeout(t,e))}async function Uo(e,t,{attempts:o=60,intervalMs:s=2e3}={}){for(let n=0;n<o;n+=1){try{let a=await Le(`${e}/permit-hash/${t}`);if(Pt(a))return a}catch{}await Go(s)}return null}function Y(e,t){return`${e}-${t.toLowerCase()}`}function ae(e){return Y(e.chainId,e.address)}function _e(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function tn(e){return e===56||e===97?"BSC":e===612044||e===612055?"CROSS":`Chain ${e}`}function re(e,t){return t?t.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()?e.contracts.W_CROSS:t:un}function je(e){let t=ft(e,nt);return t.includes(".")?t.replace(/\.?0+$/,""):t}function it(e){return vo(e||"0",nt)}function le(e){try{return it(e||"0")}catch{return 0n}}function Me(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 It(e){let t=ft(e,9);return(t.includes(".")?t.replace(/\.?0+$/,""):t)||"0"}function St(e){return e==="bridge"?Oo:No}function nn(e,t){if(!e||!t)return"0";let o=e*e;if(o===0n)return"0";let s=t*t,n=s>o?s-o:o-s;if(n===0n)return"0";let a=n*100000000n/o;if(a>=100000000n)return"100";let f=a/1000000n,m=(a%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return m?`${f}.${m}`:`${f}`}function Ko(e){if(!e||Number(e)===0)return"0%";let[t,o=""]=e.split("."),s=o.length>4?o.slice(0,4):o;return s?`${t}.${s}%`:`${t}%`}async function on(e,t,o,s,n){let a=ln(e,{chainId:t}),f=o;try{let p=await a?.estimateContractGas?.({account:n.account,address:n.address,abi:n.abi,functionName:n.functionName,args:n.args,value:n.value});typeof p=="bigint"&&p>0n&&(f=s?p*Wo/Do:p)}catch{}let m={gas:f};if(mn.has(t))try{let p=await a?.getGasPrice?.();typeof p=="bigint"&&p>0n&&(m.gasPrice=p)}catch{}return m}function fn(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 vt(e,t){let o=fn(t);return o>=10000n?0n:e*(10000n-o)/10000n}function $o(e,t){let o=fn(t);return(e*(10000n+o)+9999n)/10000n}function ut(){return BigInt(Math.floor(Date.now()/1e3)+1800)}var qo={100:"0.01%",500:"0.05%",3e3:"0.3%",1e4:"1%"};function Vo(e){return qo[e]??`${e/1e4}%`}function Ho(e,t){let o=Number(e||"0");return!Number.isFinite(o)||o<=0?"0":(o*t/1e6).toFixed(8).replace(/\.?0+$/,"")}function rn(e){return je(e)}function sn(e,t){let o=Number(t??"0");return!Number.isFinite(o)||o<=0?0n:e*BigInt(Math.floor(o))/1000n}function mt(e,t){if(!e)return!1;let o=e.toLowerCase();return t.some(s=>s.toLowerCase()===o)}function zo(e,t,o){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(n=>mt(t,n.from)&&mt(o,n.to)||mt(t,n.to)&&mt(o,n.from))}function Qo(e){if(_e(e.type))return null;if(e.type==="swap-bridge"){let t=e.steps.find(o=>o.type==="bridge");return t?{from:t.fromChain,to:t.toChain,token:t.fromToken}:null}if(e.type==="bridge-swap"){let t=e.steps.find(o=>o.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 jo({input:e,path:t,config:o}){if(!o||_e(t.type))return"";let s=Me(o.minimumValue),n=Me(o.gasFee??o.gas_fee),a=t.type==="swap-bridge"?s+n*12n/10n:s;return a<=0n?"":e.fromAmount&&le(e.fromAmount)<a&&t.type!=="swap"?`Minimum ${rn(a)}`:t.type==="swap-bridge"&&e.toAmount&&le(e.toAmount)<a?`Available ${rn(a)} or more.`:""}function Xo({input:e,path:t,config:o}){if(!o||t.type!=="bridge"&&t.type!=="bridge-swap")return"";let s=Me(o.gasFee??o.gas_fee);if(s<=0n||!e.fromAmount)return"";let n=le(e.fromToken.balance||"0"),a=le(e.fromAmount);return n-s<a?`Insufficient network fee(${e.fromToken.symbol})`:""}function Yo(e,t){let o=new Set;return e?.list?.forEach(s=>{let n=s.localChain??s.local_chain;n&&Object.entries(s.pairs||{}).forEach(([a,f])=>{f.forEach(m=>{m.localToken&&o.add(Y(n,m.localToken)),m.remoteToken&&o.add(Y(Number(a),m.remoteToken))})})}),Object.entries(t?.swapPools||t?.swap_pools||{}).forEach(([s,n])=>{n.forEach(a=>{a.token0&&o.add(Y(Number(s),a.token0)),a.token1&&o.add(Y(Number(s),a.token1))})}),o}function Zo(e,t){return!e||!t?null:Y(e,t)}function Jo({envConfig:e,bridgePairList:t,swapPools:o,tokenInfo:s,tokenStats:n}){let a=Yo(t,o),f=new Map;n?.forEach(p=>{let b=Zo(Number(p.chainId??p.chain_id),p.address);b&&f.set(b,p)});let m={};return a.forEach(p=>{let[b,w]=p.split("-"),I=Number(b),C=s?.find(h=>Number(h.chainId??h.chain_id)===I&&h.address?.toLowerCase()===w);if(!C?.symbol||!C.name)return;let u=f.get(p);m[p]={key:p,chainId:I,address:w,symbol:C.symbol,name:C.name,decimals:C.decimals||nt,image:C.image||C.icon_url,price:u?.price?Number(u.price):void 0,isNativeToken:w.toLowerCase()===e.contracts.NATIVE_CROSS.toLowerCase()}}),m}function gn(e,t){return t?.list?.find(o=>(o.localChain??o.local_chain)===e)?.bridge||""}function bn(e,t,o){let[s,n]=e.split("-"),[a,f]=t.split("-"),m=Number(s),p=Number(a);for(let b of o?.list||[]){if((b.localChain??b.local_chain)!==m)continue;let w=b.pairs?.[a];if(w){for(let I of w)if(I.localToken?.toLowerCase()===n&&I.remoteToken?.toLowerCase()===f)return{type:"bridge",fromChain:m,fromToken:n,toChain:p,toToken:f,bridgeAddress:gn(m,o)}}}return null}function yn(e,t,o,s){let[n,a]=e.split("-"),[f,m]=t.split("-");if(n!==f)return null;let p=Number(n),b=(o?.swapPools||o?.swap_pools)?.[n];if(!b)return null;let w=s.contracts.W_CROSS.toLowerCase(),I=s.contracts.NATIVE_CROSS.toLowerCase(),C=u=>u?.toLowerCase()===w?I:u?.toLowerCase();for(let u of b){let h=C(u.token0),A=C(u.token1);if(h===a&&A===m||A===a&&h===m){let S="swap";return p===s.chainIds.cross&&(a===I&&(S="deposit-swap"),m===I&&(S="swap-withdraw")),{pathType:S,step:{type:"swap",chain:p,fromToken:a,toToken:m,fee:u.fee||Te,poolAddress:u.poolAddress||u.pool_address||""}}}}return null}function er(e,t,o,s){let[n,a]=e.split("-"),[f]=t.split("-");if(n===f)return null;for(let m of(o?.swapPools||o?.swap_pools)?.[n]||[]){let p=m.token0?.toLowerCase(),b=m.token1?.toLowerCase(),w=p===a?b:b===a?p:null;if(!w)continue;let I=bn(Y(Number(n),w),t,s);if(I)return[{type:"swap",chain:Number(n),fromToken:a,toToken:w,fee:m.fee||Te,poolAddress:m.poolAddress||m.pool_address||""},I]}return null}function tr(e,t,o,s,n){let[a,f]=e.split("-"),[m]=t.split("-");if(a===m)return null;for(let p of o?.list||[])if((p.localChain??p.local_chain)===Number(a))for(let b of p.pairs?.[m]||[]){if(b.localToken?.toLowerCase()!==f)continue;let w=b.remoteToken?.toLowerCase();if(!w)continue;let I=yn(Y(Number(m),w),t,s,n);if(I)return[{type:"bridge",fromChain:Number(a),fromToken:f,toChain:Number(m),toToken:w,bridgeAddress:gn(Number(a),o)},I.step]}return null}function nr({envConfig:e,bridgePairList:t,swapPools:o,enrichedTokens:s}){return(n,a)=>{let f=s[n],m=s[a];if(!f||!m||n===a)return null;let p=bn(n,a,t);if(p)return{type:"bridge",steps:[p],from:f,to:m};let b=yn(n,a,o,e);if(b)return{type:b.pathType,steps:[b.step],from:f,to:m};let w=er(n,a,o,t);if(w)return{type:"swap-bridge",steps:w,from:f,to:m};let I=tr(n,a,t,o,e);return I?{type:"bridge-swap",steps:I,from:f,to:m}:null}}function an(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 or(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function rr(e){return e.includes(".")?e.replace(/\.?0+$/,"")||"0":e}function sr(e,t){let o=e.startsWith("-"),s=o?e.slice(1):e,[n,a=""]=s.split("."),f=a.slice(0,t).replace(/0+$/,""),m=f?`${n}.${f}`:n;return o?`-${m}`:m}function ir(e){let t=e.startsWith("-"),o=t?e.slice(1):e,[s,n]=o.split("."),a=s.replace(/\B(?=(\d{3})+(?!\d))/g,","),f=n?`${a}.${n}`:a;return t?`-${f}`:f}function At(e){if(e==null||e==="")return"0";let t=String(e),o=Number(t);return!Number.isFinite(o)||o===0?"0":ir(sr(t,4))}function cn(e,t){if(e==null||e==="")return"0";try{return rr(ft(BigInt(String(e)),t.decimals))}catch{return"0"}}function Pt(e){return!!(e&&/^0x[0-9a-fA-F]+$/.test(e))}function ar(e){return e?new Date(e*1e3).toISOString():new Date().toISOString()}function cr(e,t){return t.toLowerCase()===e.contracts.W_CROSS.toLowerCase()?e.contracts.NATIVE_CROSS:t}function dr(e,t){let o=or(t);return{name:o,symbol:o,chainId:e,address:t,decimals:nt,balance:"0"}}function dn({envConfig:e,tokenByBridgeKey:t,chainId:o,address:s}){if(!s)return null;let n=cr(e,s);return t.get(Y(o,n))||t.get(Y(o,s))||dr(o,n)}function pt(e){return e?.toLowerCase()||""}function lr(e){if(e.source==="swap")return"swap";let t=pt(e.fromToken??e.from_token),o=pt(e.toToken??e.to_token),s=pt(e.swapTokenIn??e.swap_token_in),n=pt(e.swapTokenOut??e.swap_token_out);return o&&s&&o===s?"bridge-swap":t&&n&&t===n?"swap-bridge":"bridge"}function ur(e,t){let o=e.status??0,s=e.extracallSuccess??e.extracall_success??!1;return t==="bridge-swap"&&o===1&&!s?"failed":o===1?"success":"pending"}function mr({envConfig:e,item:t,tokenByBridgeKey:o}){let s=Number(t.fromChainID??t.from_chain_id??0),n=Number(t.toChainID??t.to_chain_id??0);if(!s||!n)return null;let a=lr(t),f=t.swapTokenIn??t.swap_token_in,m=t.swapTokenOut??t.swap_token_out,p=t.swapAmountIn??t.swap_amount_in,b=t.swapAmountOut??t.swap_amount_out,w=t.fromToken??t.from_token,I=t.toToken??t.to_token,C=t.value,u=t.value;a==="swap"?(w=f,I=m,C=p,u=b):a==="swap-bridge"?(w=f,C=p,u=t.value):a==="bridge-swap"&&(I=m,C=p,u=b);let h=dn({envConfig:e,tokenByBridgeKey:o,chainId:s,address:w}),A=dn({envConfig:e,tokenByBridgeKey:o,chainId:n,address:I}),S=t.initiatedTxHash??t.initiated_tx_hash;return!h||!A||!Pt(S)?null:{id:`${S}-${t.index??""}`,timestamp:ar(t.initiatedTime??t.initiated_time),txHash:S,fromToken:h,toToken:A,fromAmount:cn(C,h),toAmount:cn(u,A),summary:{pathType:a},status:ur(t,a)}}function pr(e){let t=new Map;return e.flat().forEach(o=>{let s=Number(o.chainId??o.chain_id),n=o.address?.toLowerCase();if(!s||!n)return;let a=o.quantity?.numeric??o.balance??"0",f=o.quantity?.decimals??o.decimals??nt;try{t.set(Y(s,n),ft(BigInt(a||"0"),f))}catch{t.set(Y(s,n),"0")}}),t}function Fe(e,t="first"){let o=e.steps.filter(s=>s.type==="swap");return t==="last"?o[o.length-1]:o[0]}function fr(e,t){let o=(e?.swapPools||e?.swap_pools)?.[String(t.chainIds.cross)];if(!o?.length)return"";let s=t.contracts.CROSSD.toLowerCase(),n=t.contracts.USDTX.toLowerCase(),a=o.find(f=>{let m=f.token0?.toLowerCase(),p=f.token1?.toLowerCase();return m===s&&p===n||m===n&&p===s});return a?.poolAddress||a?.pool_address||""}function gr(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 br(e){if(e===void 0)return;let t=10n**BigInt(nt),o=e>=50000n*t?"normal":e>10000n*t?"low":"rebalancing",s=Number(e>0n?e*100n/(100000n*t):0n);return{label:"Available Liquidity",status:o,percentage:Math.min(s,100)}}function at(e,t,o,s){let n=[e.from,e.to].find(a=>a.chainId===t&&a.address.toLowerCase()===o.toLowerCase())??s?.[Y(t,o)];return{symbol:n?.symbol||o.slice(0,6),iconUrl:n?.image}}function yr(e,t){let o=[];for(let n of e.steps)n.type==="swap"?(o.push({chain:n.chain,address:n.fromToken}),o.push({chain:n.chain,address:n.toToken})):(o.push({chain:n.fromChain,address:n.fromToken}),o.push({chain:n.toChain,address:n.toToken}));let s=o.filter((n,a)=>a===0||!(n.chain===o[a-1].chain&&n.address.toLowerCase()===o[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(n=>at(e,n.chain,n.address,t))}function hr({input:e,path:t,amountData:o,gasInfo:s,liquidity:n,enrichedTokens:a,priceImpact:f}){let m=e.fromAmount||"0",p=e.toAmount||"0",b=Fe(t),w=t.steps.find(_=>_.type==="bridge"),I=t.type!=="bridge",C=!_e(t.type),u=b?Ho(m,b.fee):"0",h=Number(m)>0||Number(p)>0,A=b?at(t,b.chain,b.fromToken,a):{symbol:e.fromToken.symbol,iconUrl:e.fromToken.iconUrl},S=b?at(t,b.chain,b.toToken,a):{symbol:e.toToken.symbol,iconUrl:e.toToken.iconUrl},T=s?.tokenSymbol?{symbol:s.tokenSymbol,iconUrl:s.tokenIconUrl}:void 0,R=(_,K,Z)=>h?K&&K>0n?{label:_,value:je(K),tone:"default",valueToken:Z}:{label:_,value:"Free",tone:"accent"}:{label:_,value:"0"};return{pathType:t.type,priceImpact:f,liquidity:n,bridgeInfo:C&&w?[{label:"Route",value:`${tn(w.fromChain)} \u2192 ${tn(w.toChain)}`},R("Validator Fee",o?.exFee),R("Network Fee",o?.networkFee,T)]:void 0,swapInfo:I&&b?[{label:"Route",value:"",routeTokens:[at(t,b.chain,b.fromToken,a),at(t,b.chain,b.toToken,a)]},{label:"Price Impact",value:Ko(f)},{label:"In Amount",value:At(m),valueToken:A},{label:b&&_e(t.type)?`Swap Fee (${Vo(b.fee||Te)})`:"Swap Fee",value:At(u),valueToken:A},{label:"Out Amount",value:At(p),valueToken:S}]: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 Rt({env:e,walletAddress:t,enabled:o=!0}){let s=_o(),n=Lo[e],a=o,f=Io(new Map),m=et({queryKey:["crossd-bridge-adapter",e,"pairs"],queryFn:({signal:r})=>Le(`${n.bridgeApi}/pairs`,r),enabled:a,staleTime:3e4}),p=et({queryKey:["crossd-bridge-adapter",e,"swap-pools"],queryFn:({signal:r})=>Le(`${n.bridgeApi}/swap-pools`,r),enabled:a,staleTime:3e4}),b=xe(()=>fr(p.data,n),[n,p.data]),w=et({queryKey:["crossd-bridge-adapter",e,"available-liquidity",b],queryFn:async()=>await ke(s,{address:n.contracts.USDTX,abi:xt,functionName:"balanceOf",args:[b],chainId:n.chainIds.cross}),enabled:a&&!!b,staleTime:3e4}),I=et({queryKey:["crossd-bridge-adapter",e,"token-info"],queryFn:({signal:r})=>Le(`${n.walletApi}/v1/public/token/info`,r),enabled:a,staleTime:3e4}),C=et({queryKey:["crossd-bridge-adapter",e,"token-stats"],queryFn:({signal:r})=>Le(`${n.walletApi}/v1/public/token/stats`,r),enabled:a,staleTime:3e4}),u=Xt({queries:[n.chainIds.cross,n.chainIds.bsc].map(r=>({queryKey:["crossd-bridge-adapter",e,"balance",t,r],queryFn:({signal:i})=>{let l=new URLSearchParams({networkId:`eip155:${r}`,account:t||""});return Le(`${n.walletApi}/v1/public/token/balance?${l}`,i)},enabled:a&&!!t,staleTime:0,refetchInterval:a&&t?5e3:!1}))}),h=Xt({queries:[n.chainIds.cross,n.chainIds.bsc].map(r=>({queryKey:["crossd-bridge-adapter",e,"gas-suggestion",r],queryFn:async({signal:i})=>{try{let x=await ln(s,{chainId:r})?.estimateFeesPerGas?.();if(x?.maxFeePerGas||x?.gasPrice)return{fast:{maxFee:x.maxFeePerGas?.toString()||x.gasPrice?.toString(),maxPriorityFee:x.maxPriorityFeePerGas?.toString()||"0"}}}catch{}let l=new URLSearchParams({chain_id:String(r),without_gas_limit:"false"});return Le(`${n.walletApi}/v1/public/transaction/gas-suggestion/dynamic?${l}`,i)},enabled:a,staleTime:1e4,retry:1}))}),A=n.hiddenPairs,S=xe(()=>Jo({envConfig:n,bridgePairList:m.data,swapPools:p.data,tokenInfo:I.data,tokenStats:C.data}),[m.data,n,p.data,I.data,C.data]),T=xe(()=>nr({envConfig:n,bridgePairList:m.data,swapPools:p.data,enrichedTokens:S}),[m.data,S,n,p.data]),R=xe(()=>pr(u.map(r=>r.data).filter(r=>Array.isArray(r))),[u]),_=xe(()=>{let r=new Map;return Object.values(S).forEach(i=>{let l=an(i,R);r.set(i.key,l)}),r},[R,S]),K=xe(()=>{let r=new Map,i=_.get(Y(n.chainIds.cross,n.contracts.NATIVE_CROSS));i&&r.set(n.chainIds.cross,{symbol:i.symbol,iconUrl:i.iconUrl});let l=I.data?.find(c=>Number(c.chainId??c.chain_id)===n.chainIds.bsc&&(c.symbol??"").toUpperCase()==="BNB");return l&&r.set(n.chainIds.bsc,{symbol:l.symbol??"BNB",iconUrl:l.image??l.icon_url}),r},[n,_,I.data]),Z=et({queryKey:["crossd-bridge-adapter",e,"history",t],queryFn:({signal:r})=>en(`${n.bridgeApi}/history`,{owner:t,page:1,size:20,sort:"desc",status:"all"},r),enabled:a&&!!t,staleTime:0,refetchInterval:a&&t?5e3:!1}),H=xe(()=>(Z.data?.histories||[]).map(r=>mr({envConfig:n,item:r,tokenByBridgeKey:_})).filter(r=>!!r),[Z.data?.histories,n,_]),G=xe(()=>br(w.data),[w.data]),W=h[0]?.data,D=h[1]?.data,be=xe(()=>{let r=new Map;return W&&r.set(n.chainIds.cross,W),D&&r.set(n.chainIds.bsc,D),r},[D,W,n.chainIds.bsc,n.chainIds.cross]),B=te((r,i,l)=>{let c=be.get(r.from.chainId)?.fast,x=i?l?.gasLimit??St(r.type):0n,d=l?.gasPrice&&l.gasPrice>0n?l.gasPrice:0n,g=Me(c?.maxFee??c?.max_fee),k=Me(c?.maxPriorityFee??c?.max_priority_fee),y=g>0n?g:d,F=k>0n?k:y,v=d>0n?d:y,L=mn.has(r.from.chainId)&&v>0n,V=x*(L?v:y),$=_.get(Y(r.from.chainId,n.contracts.NATIVE_CROSS)),ge=r.type!=="swap-bridge",N=K.get(r.from.chainId);return{estTxFee:i?je(V):"0",priorityFeePerGas:i&&!L?It(F):"0",maxFeePerGas:i&&!L?It(y):"0",gasLimit:i?x.toString():"0",gasPrice:i&&L?It(v):void 0,isDelegateFee:r.type==="swap-bridge"?!1:zo(n,r.from.address,r.to.address),tokenIconUrl:ge?$?.iconUrl:void 0,tokenSymbol:ge?$?.symbol:void 0,gasCurrencyIconUrl:N?.iconUrl,gasCurrencySymbol:N?.symbol}},[n,be,K,_]),P=te(async r=>{let i=Qo(r);if(!i)return null;let l=`${e}:${i.from}:${i.to}:${i.token.toLowerCase()}`,c=f.current.get(l);if(c)return c;let x=(async()=>{let d=new URLSearchParams({from:String(i.from),to:String(i.to),token:i.token});try{return(await Le(`${n.bridgeApi}/token-config?${d}`)).config??null}catch{return null}})();return f.current.set(l,x),x},[e,n.bridgeApi]),E=xe(()=>{let r=Object.values(S).map(l=>an(l,R)),i=Y(n.chainIds.cross,n.contracts.CROSSD);return r.sort((l,c)=>{let x=ae(l).toLowerCase()===i.toLowerCase(),d=ae(c).toLowerCase()===i.toLowerCase();return x!==d?x?-1:1:ae(l).localeCompare(ae(c))})},[R,S,n]),ye=te(r=>{let i=ae(r),l=i.toLowerCase(),c=[];Object.keys(S).forEach(g=>{let k=g.toLowerCase();if(l===k||A.some(v=>v.fromKey===l&&v.toKey===k))return;let y=T(i,g);if(!y)return;let F=_.get(g);F&&c.push({token:F,path:y})});let x=Y(n.chainIds.cross,n.contracts.CROSSD),d=Y(n.chainIds.cross,n.contracts.NATIVE_CROSS);return c.sort((g,k)=>{if(l===x.toLowerCase()){let Q=ae(g.token).toLowerCase()===d.toLowerCase(),V=ae(k.token).toLowerCase()===d.toLowerCase();if(Q!==V)return Q?-1:1}let y=_e(g.path.type),F=_e(k.path.type);if(y!==F)return y?-1:1;let v=g.token.chainId===r.chainId,L=k.token.chainId===r.chainId;return v!==L?v?-1:1:ae(g.token).localeCompare(ae(k.token))}),c.map(g=>g.token)},[S,n,T,A,_]),Ke=te(async r=>await ke(s,{address:n.contracts.SWAP_BRIDGE_ROUTER,abi:tt,functionName:"quoter",chainId:r}),[n.contracts.SWAP_BRIDGE_ROUTER,s]),X=te(async r=>{Ao(s)!==r&&await Ro(s,{chainId:r})},[s]),U=te(async r=>await ke(s,{address:n.contracts.SWAP_BRIDGE_ROUTER,abi:tt,functionName:"swapRouter",chainId:r}),[n.contracts.SWAP_BRIDGE_ROUTER,s]),fe=te(async({path:r,step:i,amount:l,source:c})=>{let x=await Ke(i.chain),d=i.poolAddress?ke(s,{address:i.poolAddress,abi:Fo,functionName:"slot0",chainId:i.chain}).then(y=>y?.[0]).catch(()=>{}):Promise.resolve(void 0);if(c==="from"){let y=await ke(s,{address:x,abi:Jt,functionName:"quoteExactInputSingle",args:[{tokenIn:re(n,i.fromToken),tokenOut:re(n,i.toToken),amountIn:it(l),fee:i.fee||Te,sqrtPriceLimitX96:0n}],chainId:i.chain}),F=nn(await d,y[1]);return{amount:je(y[0]),path:r,priceImpact:F}}let g=await ke(s,{address:x,abi:Jt,functionName:"quoteExactOutputSingle",args:[{tokenIn:re(n,i.fromToken),tokenOut:re(n,i.toToken),amount:it(l),fee:i.fee||Te,sqrtPriceLimitX96:0n}],chainId:i.chain}),k=nn(await d,g[1]);return{amount:je(g[0]),path:r,priceImpact:k}},[n,Ke,s]),he=te(async(r,i)=>{if(!t)throw new Error("Wallet is not connected.");let l=St(i.type);if(_e(i.type)){let v=Fe(i,"first");if(!v)throw new Error("Swap route is not available.");let L=le(r.fromAmount),Q=le(r.toAmount);if(L<=0n)throw new Error("Bridge amount is empty.");if(Q<=0n)throw new Error("Bridge quote is not ready.");let V=await U(v.chain),$=vt(Q,r.slippage),ge=i.type==="swap-withdraw"?un:t,N={tokenIn:re(n,v.fromToken),tokenOut:re(n,v.toToken),fee:v.fee||Te,recipient:ge,deadline:ut(),amountIn:L,amountOutMinimum:$,sqrtPriceLimitX96:0n};if(i.type==="swap-withdraw"){let se=st({abi:Be,functionName:"exactInputSingle",args:[N]}),oe=st({abi:Be,functionName:"unwrapWETH9",args:[$,t]});return{address:V,abi:Be,functionName:"multicall",args:[[se,oe]],chainId:v.chain,fallbackGasLimit:l}}if(i.type==="deposit-swap"){let se=st({abi:Be,functionName:"exactInputSingle",args:[N]}),oe=st({abi:Be,functionName:"refundETH",args:[]});return{address:V,abi:Be,functionName:"multicall",args:[[se,oe]],value:L,chainId:v.chain,fallbackGasLimit:l}}return{address:V,abi:Be,functionName:"exactInputSingle",args:[N],chainId:v.chain,fallbackGasLimit:l}}if(i.type==="swap-bridge"){let v=Fe(i,"first");if(!v)throw new Error("Swap bridge route is not available.");let L=le(r.fromAmount),Q=le(r.toAmount);if(L<=0n)throw new Error("Bridge amount is empty.");if(Q<=0n)throw new Error("Bridge quote is not ready.");let V=n.contracts.SWAP_BRIDGE_ROUTER,$=ut(),ge={toChainID:BigInt(i.to.chainId),recipient:t,extraData:"0x"},N={tokenIn:re(n,i.from.address),tokenOut:re(n,v.toToken),fee:v.fee||Te,sqrtPriceLimitX96:0n,bridgeParams:ge};if(r.lastChangedBy==="to"){let oe={...N,amountOut:Q,amountInMaximum:$o(L,r.slippage)};return{address:V,abi:tt,functionName:"swapBridgeExactOutputSingle",args:[oe,$],value:i.from.isNativeToken?oe.amountInMaximum:void 0,chainId:i.from.chainId,fallbackGasLimit:l}}let se={...N,amountIn:L,amountOutMinimum:vt(L,r.slippage)};return{address:V,abi:tt,functionName:"swapBridgeExactInputSingle",args:[se,$],value:i.from.isNativeToken?L:void 0,chainId:i.from.chainId,fallbackGasLimit:l}}let c=i.steps.find(v=>v.type==="bridge");if(!c?.bridgeAddress)throw new Error("Bridge route is not available.");let x=le(r.fromAmount);if(x<=0n)throw new Error("Bridge amount is empty.");let d=await P(i),g=Me(d?.gasFee??d?.gas_fee),k=sn(x,d?.exFeeRate??d?.ex_fee_rate),y="0x";if(i.type==="bridge-swap"){let v=Fe(i,"last");if(!v)throw new Error("Bridge swap route is not available.");let L=le(r.toAmount);if(L<=0n)throw new Error("Bridge quote is not ready.");let Q=await U(i.to.chainId),V=vt(L,r.slippage),$=st({abi:Be,functionName:"exactInputSingle",args:[{tokenIn:re(n,v.fromToken),tokenOut:re(n,v.toToken),fee:v.fee||Te,recipient:t,deadline:ut(),amountIn:x,amountOutMinimum:V,sqrtPriceLimitX96:0n}]});y=`${Q}${$.slice(2)}`}let F=[BigInt(i.to.chainId),i.from.address,t,x,g,k,y];return{address:c.bridgeAddress,abi:Mo,functionName:"bridgeToken",args:F,value:i.from.isNativeToken?x+k+g:void 0,chainId:i.from.chainId,fallbackGasLimit:l}},[n,P,U,t]),Ee=te(async(r,i)=>{if(i.type==="bridge"||i.type==="bridge-swap")return he(r,i);if(!t)throw new Error("Wallet is not connected.");let l=le(r.fromAmount);if(l<=0n)throw new Error("Bridge amount is empty.");let c=Fe(i,"first");if(!c)throw new Error("Swap route is not available.");let x=await U(c.chain),d={tokenIn:re(n,c.fromToken),tokenOut:re(n,c.toToken),fee:c.fee||Te,recipient:t,deadline:ut(),amountIn:l,amountOutMinimum:0n,sqrtPriceLimitX96:0n};return{address:x,abi:Be,functionName:"exactInputSingle",args:[d],value:i.from.isNativeToken?l:void 0,chainId:c.chain,fallbackGasLimit:St(i.type)}},[he,n,U,t]),Oe=te(async(r,i)=>{if(!t||i.type==="swap-bridge")return null;try{let l=await Ee(r,i),c=await on(s,l.chainId,l.fallbackGasLimit,!1,{account:t,address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value});return{gasLimit:c.gas,gasPrice:c.gasPrice}}catch{return null}},[Ee,s,t]),de=te(async r=>{let i=ae(r.fromToken),l=ae(r.toToken),c=T(i,l);if(!c)return{error:"Route is not available."};let x=r.lastChangedBy==="to"?r.toAmount:r.fromAmount,d=!!x&&Number(x)>0,g=gr(c,n)?G:void 0,k=async(N,se,oe)=>{let Ne=d?await Oe(N,c):null,He=B(c,d,Ne);return hr({input:N,path:c,gasInfo:He,amountData:se,liquidity:g,enrichedTokens:S,priceImpact:oe})};if(!x||Number(x)<=0)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r)};let y=await P(c),F=Me(y?.gasFee??y?.gas_fee),v=c.type==="bridge"||c.type==="bridge-swap"?{networkFee:F}:void 0,L=jo({input:r,path:c,config:y});if(L)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r,v),error:L};let Q=Xo({input:r,path:c,config:y});if(Q)return{fromAmount:r.fromAmount,toAmount:r.toAmount,summary:await k(r,v),error:Q};if(c.type==="bridge"){let N=r.lastChangedBy==="to"?{...r,fromAmount:r.toAmount}:{...r,toAmount:r.fromAmount};return{fromAmount:N.fromAmount,toAmount:N.toAmount,summary:await k(N,v)}}if(c.type==="swap-bridge"){let N=Fe(c,"first"),se=n.contracts.SWAP_BRIDGE_ROUTER;if(!N)return{error:"Swap bridge route is not ready."};if(r.lastChangedBy==="from"){let ie=await ke(s,{address:se,abi:tt,functionName:"getAmountSwapBridgeOut",args:[BigInt(c.to.chainId),re(n,c.from.address),re(n,N.toToken),N.fee||Te,it(r.fromAmount)],chainId:c.from.chainId}),ze=je(ie[1]),Ae={...r,toAmount:ze};return{toAmount:ze,summary:await k(Ae,{networkFee:ie[3],exFee:ie[4]})}}let oe=await ke(s,{address:se,abi:tt,functionName:"getAmountSwapBridgeIn",args:[BigInt(c.to.chainId),re(n,c.from.address),re(n,N.toToken),N.fee||Te,it(r.toAmount)],chainId:c.from.chainId}),Ne=je(oe[1]),He={...r,fromAmount:Ne};return{fromAmount:Ne,summary:await k(He,{networkFee:oe[3],exFee:oe[4]})}}let V=c.type==="bridge-swap"?Fe(c,"last"):Fe(c,"first");if(!V)return{error:"Swap route is not available."};let $=await fe({path:c,step:V,amount:x,source:r.lastChangedBy});if(r.lastChangedBy==="from"){let N={...r,toAmount:$.amount};return{toAmount:$.amount,summary:await k(N,v,$.priceImpact)}}let ge={...r,fromAmount:$.amount};return{fromAmount:$.amount,summary:await k(ge,v,$.priceImpact)}},[G,B,S,n,Oe,T,P,fe,s]),Se=te(async r=>{if(r.from.isNativeToken)return null;if(r.type==="swap"||r.type==="deposit-swap"||r.type==="swap-withdraw")return U(r.from.chainId);if(r.type==="swap-bridge")return n.contracts.SWAP_BRIDGE_ROUTER;let i=r.steps.find(l=>l.type==="bridge");return i?.bridgeAddress?i.bridgeAddress:null},[n.contracts.SWAP_BRIDGE_ROUTER,U]),z=te(async r=>{if(!t)throw new Error("Wallet is not connected.");let i=ae(r.fromToken),l=ae(r.toToken),c=T(i,l);if(!c)throw new Error("Route is not available.");if(!_e(c.type)&&c.type!=="swap-bridge"||c.from.isNativeToken)return null;let x=le(r.fromAmount);if(x<=0n)return null;let d=await Se(c);return!d||await ke(s,{address:c.from.address,abi:xt,functionName:"allowance",args:[t,d],chainId:c.from.chainId})>=x?null:{token:r.fromToken,tokenAddress:c.from.address,spenderAddress:d,amount:r.fromAmount}},[T,Se,s,t]),$e=te(async(r,i)=>{let l=le(i.amount||r.fromAmount);if(l<=0n)throw new Error("Approval amount is empty.");await X(i.token.chainId);let c=await Yt(s,{address:i.tokenAddress,abi:xt,functionName:"approve",args:[i.spenderAddress,l],chainId:i.token.chainId});await Bo(s,{hash:c,chainId:i.token.chainId})},[X,s]),qe=te(async(r,i)=>{let l=await he(r,i);await X(l.chainId);let c=await on(s,l.chainId,l.fallbackGasLimit,Eo(i.type),{account:t,address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value});return{txHash:await Yt(s,{address:l.address,abi:l.abi,functionName:l.functionName,args:l.args,value:l.value,chainId:l.chainId,...c}),fromToken:r.fromToken,toToken:r.toToken,fromAmount:r.fromAmount,toAmount:r.toAmount}},[he,X,s,t]),Ve=te(async(r,i)=>{let l=t;if(!l)throw new Error("Wallet is not connected.");let c=i.steps.find(bt=>bt.type==="bridge");if(!c?.bridgeAddress)throw new Error("Bridge route is not available.");let x=i.from.address,d=i.from.chainId,g=le(r.fromAmount);if(g<=0n)throw new Error("Bridge amount is empty.");let k=await P(i),y=Me(k?.gasFee??k?.gas_fee),F=sn(g,k?.exFeeRate??k?.ex_fee_rate),v=g+F+y,[L,Q]=await Promise.all([ke(s,{address:x,abi:Zt,functionName:"name",chainId:d}),ke(s,{address:x,abi:Zt,functionName:"nonces",args:[l],chainId:d})]),V=BigInt(Math.floor(Date.now()/1e3)+300),$=await Po(s,{domain:{name:L,version:"1",chainId:d,verifyingContract:x},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:c.bridgeAddress,value:v,nonce:Q,deadline:V}}),{r:ge,s:N,v:se,yParity:oe}=So($),Ne=se!==void 0?Number(se):oe+27,He={exFee:F.toString(),from:d,fromToken:x,nonce:Number(Q),gasFee:y.toString(),permitArgs:{account:l,deadline:V.toString(),r:ge,s:N,token:x,v:Ne,value:v.toString()},to:l,toChainID:String(i.to.chainId),value:v.toString()},ie=await en(`${n.bridgeApi}/permit`,He),ze=ie?.requestId??ie?.request_id;if(!ze)throw new Error("Bridge permit request failed.");let Ae=await Uo(n.bridgeApi,ze);if(!Pt(Ae))throw new Error("Bridge submitted, but confirmation timed out. Check History shortly.");return{txHash:Ae,fromToken:r.fromToken,toToken:r.toToken,fromAmount:r.fromAmount,toAmount:r.toAmount}},[n,P,s,t]),ve=te(async r=>{let i=ae(r.fromToken),l=ae(r.toToken),c=T(i,l);if(!c)throw new Error("Route is not available.");if(!(_e(c.type)||c.type==="swap-bridge"||c.type==="bridge-swap"||c.type==="bridge"))throw new Error("This bridge route is not supported yet.");return{...c.type==="bridge"&&c.from.chainId===n.chainIds.bsc&&c.from.address.toLowerCase()===n.contracts.BSC_CROSS.toLowerCase()?await Ve(r,c):await qe(r,c),pathType:c.type,routeTokens:yr(c,S)}},[S,n,T,Ve,qe]);return{bridgeTokens:E,bridgeHistory:H,getBridgeApproval:z,approveBridge:$e,getBridgeQuote:de,getBridgeToTokens:ye,submitBridge:ve,isLoading:m.isLoading||p.isLoading||I.isLoading||C.isLoading||u.some(r=>r.isLoading)}}import{useEffect as hn,useRef as wr,useState as wn}from"react";import{useAccount as Cr}from"wagmi";function Bt(e){let{address:t,connector:o}=Cr(),{currentWallet:s}=Pe(),n=e?.walletId!==void 0?e.walletId:s,a=e?.connector!==void 0?e.connector:o,f=e?.address!==void 0?e.address:t,[m,p]=wn({loginType:null,accountName:null,accounts:[],isResolved:!1}),b=wr(new Map),[w,I]=wn(0);return hn(()=>{let C=!1;if(n!=="cross_embedded")return p({loginType:null,accountName:null,accounts:[],isResolved:!0}),()=>{C=!0};if(!a)return p({loginType:null,accountName:null,accounts:[],isResolved:!1}),()=>{C=!0};p(S=>({...S,isResolved:!1}));let u=20,h=300,A=async()=>{if(typeof a.getProvider!="function")return"retry";let S;try{S=await a.getProvider()}catch{return"retry"}let T=S?.sdk;if(!T)return"giveup";try{let E=T.getRNBridgeActiveWallet?.(),ye=E?.walletName?.trim();E&&ye&&b.current.set(E.address.toLowerCase(),ye)}catch{}let[R,_]=await Promise.all([T.getUserInfo?.().catch(()=>null)??null,T.getAddresses?.().catch(()=>null)??null]);if(C)return"done";let K=R?.loginType,Z=K==="google"||K==="apple"?K:null;if(!Z)return"retry";let H=f?.toLowerCase(),G=H&&Array.isArray(_)?_.find(E=>E.address.toLowerCase()===H):null,W=Array.isArray(_)?_.filter(E=>/^0x[a-fA-F0-9]{40}$/.test(E.address)).map(E=>({address:E.address.toLowerCase(),...Number.isFinite(E.index)?{index:E.index}:{},...E.name?.trim()?{name:E.name.trim()}:{}})):[],D=H?b.current.get(H)?.trim():void 0,be=!G&&H&&/^0x[a-fA-F0-9]{40}$/.test(H)?[...W,{address:H,index:W.length,...D?{name:D}:{}}]:W,P=D||G?.name?.trim()||(typeof G?.index=="number"?`Account ${G.index+1}`:f?`${f.slice(0,6)}\u2026${f.slice(-4)}`:null);return p({loginType:Z,accountName:P,accounts:be,isResolved:!0}),"done"};return(async()=>{for(let S=0;S<u;S++){if(C)return;let T=await A();if(T==="done")return;if(T==="giveup"){C||p({loginType:null,accountName:null,accounts:[],isResolved:!0});return}await new Promise(R=>setTimeout(R,h))}C||p({loginType:null,accountName:null,accounts:[],isResolved:!0})})(),()=>{C=!0}},[n,a,f,w]),hn(()=>{if(n!=="cross_embedded"||!a||typeof a.getProvider!="function")return;let C=!1,u;return(async()=>{let h;try{h=await a.getProvider()}catch{return}if(C)return;let A=h?.sdk;A?.on&&(u=A.on("addressChanged",({address:S,walletName:T})=>{let R=T?.trim();R&&(b.current.set(S.toLowerCase(),R),I(_=>_+1))}))})(),()=>{C=!0,u?.()}},[n,a]),m}import{Fragment as Tn,jsx as ce,jsxs as Xe}from"react/jsx-runtime";var Er=[{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"}]}],Or=[{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"}]}],Nr={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"}},Ot=10n**18n,Wr={google:{name:"Google",iconUrl:In,connectorId:Ue.CROSSx},apple:{name:"Apple",iconUrl:Dt,connectorId:Ue.CROSSx},cross:{name:"CROSSx",iconUrl:Wt,connectorId:Ue.CROSSx},metamask:{name:"MetaMask",iconUrl:Sn,connectorId:Ue.MetaMask},binance:{name:"Binance Wallet",iconUrl:xn,connectorId:Ue.Binance}};function Dr(e){switch(e){case"cross_embedded":return Ue.CROSSx;case"metamask":return Ue.MetaMask;case"binance":return Ue.Binance;default:return}}function Lr(e,t){switch(e){case"cross_embedded":return t==="google"?{name:"Google",iconUrl:In}:t==="apple"?{name:"Apple",iconUrl:Dt}:{name:"CROSSx",iconUrl:Wt};case"cross_wallet":return{name:"CROSSx Wallet",iconUrl:Wt};case"cross_extension":return{name:"CROSSx Extension",iconUrl:_r};case"metamask":return{name:"MetaMask",iconUrl:Sn};case"binance":return{name:"Binance Wallet",iconUrl:xn};default:return null}}function Fr({label:e="Connect Wallet",className:t,style:o,walletInfoStyle:s,user:n,enablePortfolio:a,portfolio:f,theme:m,accountName:p,connectorId:b,showPortfolio:w,sendAccounts:I,getTransactionReceipt:C,sendTransaction:u,estimateGas:h,onDisconnect:A,onSelectWallet:S,onBuy:T,onRampRedirectUrl:R,bridgeTokens:_,bridgeHistory:K,getBridgeQuote:Z,getBridgeToTokens:H,getBridgeApproval:G,approveBridge:W,submitBridge:D,showBalance:be=!0,env:B,...P}){let{address:E,isConnected:ye,connector:Ke,chain:X}=xr(),U=Sr(),fe=Ir(),{switchChainAsync:he}=Ar(),{sendTransactionAsync:Ee}=vr(),{connectWallet:Oe,disconnect:de,selectWallet:Se,currentWallet:z,isConnecting:$e}=Pe(),qe=rt(),Ve=m??qe?.mode??"dark",ve=gt(()=>Pr(B),[B]),r=n?.address??E,i=n?Wr[n.provider]:null,{loginType:l,accountName:c,accounts:x}=Bt({walletId:z,connector:Ke,address:r}),d=gt(()=>i?{name:i.name,iconUrl:i.iconUrl}:Lr(z,l),[i,z,l]),g=p??n?.name??c??void 0,k=i?i.connectorId:Dr(z),y=b??k,F=f??w??!!a,v=Rt({env:ve,walletAddress:r,enabled:ye&&!!r&&be}),L=_??v.bridgeTokens,Q=K??v.bridgeHistory,V=Z??v.getBridgeQuote,$=H??v.getBridgeToTokens,ge=G??v.getBridgeApproval,N=W??v.approveBridge,se=D??v.submitBridge,oe=Ge(()=>{Oe().catch(O=>{console.error("[crossx-kit] connectWallet error:",O)})},[Oe]),Ne=Ge(()=>{de()},[de]),He=A??Ne,ie=Rr(),{eligibility:ze}=Br({network:X?String(X.id):void 0}),Ae=ze?.allowed===!0,bt=gt(()=>{if(T)return T;if(!(!ie||!X||!Ae))return()=>ie.open({crypto:X.nativeCurrency?.symbol??"USDT",network:String(X.id),...R?{redirectUrl:R}:{}}).then(()=>{}).catch(O=>{throw console.warn("[crossx-kit] onramp open failed:",O),O})},[T,ie,X,Ae,R]),Lt=Tr();kr(()=>{if(ie?.onStatus)return ie.onStatus(()=>{Lt.invalidateQueries()})},[ie,Lt]);let Bn=gt(()=>{if(!T&&!(!ie||!X)&&!Ae)return"On-ramp is not available in your region."},[T,ie,X,Ae]),_n=n?n.provider==="google"||n.provider==="apple":z==="cross_embedded",En=Ge(()=>{Se().catch(O=>{console.error("[crossx-kit] selectWallet error:",O)})},[Se]),Ft=S??(_n?En:void 0),On=Ge(async({hash:O,chainId:J})=>{let ee=_t(U,J?{chainId:J}:void 0);if(!ee)return null;try{return await ee.getTransactionReceipt({hash:O})}catch{return null}},[U]),Nn=Ge(async O=>{O.chainId!==void 0&&O.chainId!==fe&&await he({chainId:O.chainId});let ee=O.chainId===56||O.chainId===97?{...O,type:"legacy"}:O;return(u??Ee)(ee)},[u,Ee,fe,he]),Wn=F?Nn:u,Dn=Ge(async O=>{let J=O.chainId??fe,ee=_t(U,J?{chainId:J}:void 0);if(!ee)throw new Error(`publicClient for chainId ${J??"unknown"} is not available \u2014 register the chain in createCrossxConfig({ networks }).`);let ue=J===56||J===97,[me,we]=await Promise.all([ee.estimateGas({account:O.from,to:O.to,value:O.value,data:O.data}),(async()=>{if(ue)return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await ee.getGasPrice()};try{let j=await ee.estimateFeesPerGas();return{maxFeePerGas:j.maxFeePerGas,maxPriorityFeePerGas:j.maxPriorityFeePerGas,gasPrice:void 0}}catch{return{maxFeePerGas:void 0,maxPriorityFeePerGas:void 0,gasPrice:await ee.getGasPrice()}}})()]);return{gasLimit:me,maxFeePerGas:we.maxFeePerGas,maxPriorityFeePerGas:we.maxPriorityFeePerGas,gasPrice:we.gasPrice}},[U,fe]),Ln=h??Dn,Fn=Ge(async O=>{let J={};if(!E||O.length===0)return J;let ee=O.flatMap(me=>{let j={address:me,abi:Er,chainId:fe};return[{...j,functionName:"balanceOf",args:[E]},{...j,functionName:"totalSupply"},{...j,functionName:"decimals"}]}),ue;try{ue=await Cn(U,{contracts:ee,allowFailure:!0})}catch{return J}return O.forEach((me,we)=>{let j=we*3,Ce=ue[j],ct=ue[j+1],Ye=ue[j+2];!Ce||Ce.status!=="success"||(J[me.toLowerCase()]={balance:Ce.result,totalSupply:ct&&ct.status==="success"?ct.result:void 0,decimals:Ye&&Ye.status==="success"?Number(Ye.result):void 0})}),J},[U,E,fe]),Mn=Ge(async O=>{let J={earnedWei:0n,stakedWei:0n};if(!O)return J;let ee=Nr[ve],ue={address:ee.poolAddress,abi:Or,chainId:ee.crossChainId},me;try{me=await Cn(U,{allowFailure:!0,contracts:[{...ue,functionName:"earned",args:[O]},{...ue,functionName:"balanceOf",args:[O]},{...ue,functionName:"posaActive"},{...ue,functionName:"lastRewardBlock"},{...ue,functionName:"totalStaked"}]})}catch{return J}let we=Qe=>me[Qe]&&me[Qe].status==="success"?me[Qe].result:0n,j=we(0),Ce=we(1);if(me[2]&&me[2].status==="success"?me[2].result:!1)return{earnedWei:j,stakedWei:Ce};let Ye=we(3),Ut=we(4);if(Ut===0n)return{earnedWei:j,stakedWei:Ce};let yt=0n;try{yt=await _t(U,{chainId:ee.crossChainId})?.getBlockNumber?.()??0n}catch{return{earnedWei:j,stakedWei:Ce}}if(yt<=Ye)return{earnedWei:j,stakedWei:Ce};let ht=0n;try{let Qe=await fetch(ee.networkStatsUrl).then(wt=>wt.json()),Kt=Qe?.data?.block_reward??Qe?.block_reward;if(Kt){let[wt,$n=""]=String(Kt).split("."),qn=($n+"0".repeat(18)).slice(0,18);ht=BigInt(wt||"0")*Ot+BigInt(qn||"0")}}catch{}if(ht===0n)return{earnedWei:j,stakedWei:Ce};let Un=(yt-Ye)*ht*Ot/Ut,Kn=Ce*Un/Ot;return{earnedWei:j+Kn,stakedWei:Ce}},[U,ve]),Mt=!Ft,Gt=t?`cb-button ${t}`:"cb-button",Gn=t?`cb-pill ${t}`:"cb-pill";return $e&&!ye?Xe(Tn,{children:[ce("style",{children:Nt}),Xe("button",{type:"button",disabled:!0,className:Gt,style:o,"aria-busy":"true",children:[ce("span",{className:"cb-spinner","aria-hidden":"true"}),ce("span",{className:"cb-button-label",children:"Connecting..."})]})]}):ye&&r?Xe("span",{"data-crossx-wallet-info":Mt?"external":"embedded",children:[ce("style",{children:Nt}),Mt&&ce("style",{children:Gr}),Xe(Et,{...P,env:ve,theme:Ve,showBalance:be,walletAddress:r,accountName:g,sendAccounts:I??x,connectorId:y,showPortfolio:F,onDisconnect:He,onSelectWallet:Ft,onBuy:bt,onBuyDisabledMessage:Bn,sendTransaction:Wn,getTransactionReceipt:C??On,estimateGas:Ln,lpBalanceReader:Fn,stakingRewardsReader:Mn,bridgeTokens:L,bridgeHistory:Q,getBridgeQuote:V,getBridgeToTokens:$,getBridgeApproval:ge,approveBridge:N,submitBridge:se,style:s,children:[ce(Et.Trigger,{asChild:!0,children:Xe("button",{type:"button",className:Gn,style:o,"aria-label":`Connected with ${d?.name??"wallet"}: ${kn(r)}`,children:[d?.iconUrl?ce("img",{src:d.iconUrl,alt:"",width:20,height:20,className:"cb-pill-icon","data-provider":d.iconUrl===Dt?"apple":void 0}):ce("span",{className:"cb-pill-icon-placeholder","aria-hidden":"true"}),ce("span",{className:"cb-pill-address",children:kn(r)})]})}),ce(Et.Content,{align:"end",sideOffset:8})]})]}):Xe(Tn,{children:[ce("style",{children:Nt}),Xe("button",{type:"button",onClick:oe,className:Gt,style:o,"aria-label":typeof e=="string"?e:"Connect Wallet",children:[ce(Mr,{}),ce("span",{className:"cb-button-label",children:e})]})]})}function Mr(){return ce("svg",{className:"cb-button-icon",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:ce("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 Gr=`
|
|
2
|
-
[data-crossx-wallet-info="external"] .wi-select-wallet-btn {
|
|
3
|
-
display: none !important;
|
|
4
|
-
}
|
|
5
|
-
`;function kn(e){return`${e.slice(0,6)}...${e.slice(-4)}`}var Nt=`
|
|
6
|
-
.cb-button {
|
|
7
|
-
-webkit-font-smoothing: antialiased;
|
|
8
|
-
--cb-bg: var(--ds-accent-primary-default, #00D5AA);
|
|
9
|
-
--cb-bg-hover: var(--ds-accent-primary-high, #00a0a2);
|
|
10
|
-
--cb-color: var(--ds-accent-primary-on, #000);
|
|
11
|
-
--cb-border: none;
|
|
12
|
-
--cb-radius: 8px;
|
|
13
|
-
--cb-height: 36px;
|
|
14
|
-
--cb-padding: 0 16px;
|
|
15
|
-
--cb-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
16
|
-
--cb-font-size: 14px;
|
|
17
|
-
--cb-font-weight: 500;
|
|
18
|
-
--cb-gap: 8px;
|
|
19
|
-
--cb-transition: background-color 0.15s ease, transform 0.1s ease;
|
|
20
|
-
--cb-loading-opacity: 0.7;
|
|
21
|
-
--cb-press-scale: 0.95;
|
|
22
|
-
--cb-spinner-size: 14px;
|
|
23
|
-
--cb-spinner-thumb: currentColor;
|
|
24
|
-
--cb-spinner-track: color-mix(in srgb, currentColor 20%, transparent);
|
|
25
|
-
--cb-icon-size: 18px;
|
|
26
|
-
|
|
27
|
-
display: inline-flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
height: var(--cb-height);
|
|
32
|
-
gap: var(--cb-gap);
|
|
33
|
-
padding: var(--cb-padding);
|
|
34
|
-
border-radius: var(--cb-radius);
|
|
35
|
-
border: var(--cb-border);
|
|
36
|
-
background: var(--cb-bg);
|
|
37
|
-
color: var(--cb-color);
|
|
38
|
-
font-family: var(--cb-font-family);
|
|
39
|
-
font-size: var(--cb-font-size);
|
|
40
|
-
font-weight: var(--cb-font-weight);
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
transition: var(--cb-transition);
|
|
43
|
-
}
|
|
44
|
-
.cb-button:hover:not(:disabled) { background: var(--cb-bg-hover); }
|
|
45
|
-
.cb-button:active:not(:disabled) { transform: scale(var(--cb-press-scale)); }
|
|
46
|
-
.cb-button:disabled, .cb-button[aria-busy="true"] {
|
|
47
|
-
cursor: default;
|
|
48
|
-
opacity: var(--cb-loading-opacity);
|
|
49
|
-
}
|
|
50
|
-
.cb-spinner {
|
|
51
|
-
display: inline-block;
|
|
52
|
-
width: var(--cb-spinner-size);
|
|
53
|
-
height: var(--cb-spinner-size);
|
|
54
|
-
border: 2px solid var(--cb-spinner-track);
|
|
55
|
-
border-top-color: var(--cb-spinner-thumb);
|
|
56
|
-
border-radius: 50%;
|
|
57
|
-
animation: cck-cb-spin 0.6s linear infinite;
|
|
58
|
-
flex-shrink: 0;
|
|
59
|
-
}
|
|
60
|
-
.cb-button-icon {
|
|
61
|
-
width: var(--cb-icon-size);
|
|
62
|
-
height: var(--cb-icon-size);
|
|
63
|
-
flex-shrink: 0;
|
|
64
|
-
}
|
|
65
|
-
.cb-button-label { white-space: nowrap; }
|
|
66
|
-
.cb-pill {
|
|
67
|
-
--cb-pill-bg: var(--ds-surface-default, #1e232e);
|
|
68
|
-
--cb-pill-bg-hover: var(--ds-surface-medium, #252b39);
|
|
69
|
-
--cb-pill-color: var(--ds-content-high, #ffffffd9);
|
|
70
|
-
--cb-pill-border: 1px solid var(--ds-border-default, #ffffff12);
|
|
71
|
-
--cb-pill-border-hover: 1px solid var(--ds-border-medium, #ffffff2e);
|
|
72
|
-
--cb-pill-radius: 8px;
|
|
73
|
-
--cb-pill-height: 36px;
|
|
74
|
-
--cb-pill-padding: 0 12px;
|
|
75
|
-
--cb-pill-press-scale: 0.95;
|
|
76
|
-
--cb-pill-font-family: Inter, system-ui, -apple-system, sans-serif;
|
|
77
|
-
--cb-pill-font-size: 14px;
|
|
78
|
-
--cb-pill-font-weight: 500;
|
|
79
|
-
--cb-pill-gap: 8px;
|
|
80
|
-
--cb-pill-icon-size: 20px;
|
|
81
|
-
--cb-pill-icon-placeholder-bg: var(--ds-surface-high, #2a2d3a);
|
|
82
|
-
--cb-pill-address-font: Inter, system-ui, -apple-system, sans-serif;
|
|
83
|
-
--cb-pill-address-font-size: 14px;
|
|
84
|
-
--cb-pill-address-letter-spacing: -0.01em;
|
|
85
|
-
|
|
86
|
-
display: inline-flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
box-sizing: border-box;
|
|
89
|
-
height: var(--cb-pill-height);
|
|
90
|
-
gap: var(--cb-pill-gap);
|
|
91
|
-
padding: var(--cb-pill-padding);
|
|
92
|
-
border-radius: var(--cb-pill-radius);
|
|
93
|
-
border: var(--cb-pill-border);
|
|
94
|
-
background: var(--cb-pill-bg);
|
|
95
|
-
color: var(--cb-pill-color);
|
|
96
|
-
font-family: var(--cb-pill-font-family);
|
|
97
|
-
font-size: var(--cb-pill-font-size);
|
|
98
|
-
font-weight: var(--cb-pill-font-weight);
|
|
99
|
-
cursor: pointer;
|
|
100
|
-
}
|
|
101
|
-
.cb-pill:hover,
|
|
102
|
-
.cb-pill[data-state="open"] { background: var(--cb-pill-bg-hover); border: var(--cb-pill-border-hover, 1px solid var(--ds-border-medium, #ffffff2e)); }
|
|
103
|
-
.cb-pill:active:not(:disabled) { transform: scale(var(--cb-pill-press-scale)); }
|
|
104
|
-
.cb-pill-icon {
|
|
105
|
-
width: var(--cb-pill-icon-size);
|
|
106
|
-
height: var(--cb-pill-icon-size);
|
|
107
|
-
border-radius: 50%;
|
|
108
|
-
object-fit: contain;
|
|
109
|
-
flex-shrink: 0;
|
|
110
|
-
background: transparent;
|
|
111
|
-
}
|
|
112
|
-
/* Apple is a monochrome black logomark in an <img> data URI (can't follow
|
|
113
|
-
theme via currentColor). Flip it to white in dark mode so it stays
|
|
114
|
-
visible on the dark pill; multicolor marks (Google/MetaMask/Binance/
|
|
115
|
-
CROSSx) are untouched. */
|
|
116
|
-
[data-theme="dark"] .cb-pill-icon[data-provider="apple"] {
|
|
117
|
-
filter: invert(1);
|
|
118
|
-
}
|
|
119
|
-
.cb-pill-icon-placeholder {
|
|
120
|
-
display: inline-block;
|
|
121
|
-
width: var(--cb-pill-icon-size);
|
|
122
|
-
height: var(--cb-pill-icon-size);
|
|
123
|
-
border-radius: 50%;
|
|
124
|
-
background: var(--cb-pill-icon-placeholder-bg);
|
|
125
|
-
flex-shrink: 0;
|
|
126
|
-
}
|
|
127
|
-
.cb-pill-address {
|
|
128
|
-
font-family: var(--cb-pill-address-font);
|
|
129
|
-
font-size: var(--cb-pill-address-font-size);
|
|
130
|
-
letter-spacing: var(--cb-pill-address-letter-spacing);
|
|
131
|
-
}
|
|
132
|
-
@media (max-width: 767.98px) {
|
|
133
|
-
.cb-button, .cb-pill {
|
|
134
|
-
width: 36px;
|
|
135
|
-
min-width: 36px;
|
|
136
|
-
padding: 0;
|
|
137
|
-
}
|
|
138
|
-
.cb-button-label, .cb-pill-address { display: none; }
|
|
139
|
-
}
|
|
140
|
-
@keyframes cck-cb-spin {
|
|
141
|
-
to { transform: rotate(360deg); }
|
|
142
|
-
}
|
|
143
|
-
`;import{useCallback as vn,useEffect as Ur,useMemo as An,useState as Kr}from"react";import{detectWallets as Pn,DEFAULT_WALLET_REGISTRY as Rn}from"@nexus-cross/connect-kit-wagmi";import{jsx as ne,jsxs as Ie}from"react/jsx-runtime";var $r=["Ensure your wallet extension is installed and unlocked","Try refreshing the page","Some wallets may require you to first open the extension","You can try clicking the wallet anyway"],qr="Connect with one of our available wallet providers to continue.";function Vr({open:e,onClose:t,onSelect:o,title:s="Connect Wallet",description:n=qr,troubleshootingTips:a=$r}){let{availableWallets:f}=Pe(),[m,p]=Kr({});Ur(()=>{if(!e)return;let u=Pn(Rn),h={};for(let S of u)S.installed!==void 0&&(h[S.id]=S.installed);p(h);let A=setTimeout(()=>{let S=Pn(Rn),T={};for(let R of S)R.installed!==void 0&&(T[R.id]=R.installed);p(T)},1e3);return()=>clearTimeout(A)},[e]);let b=An(()=>typeof navigator>"u"?!1:/Mobi|Android/i.test(navigator.userAgent),[]),w=An(()=>b?f.filter(u=>u.type!=="extension"):f,[f,b]),I=vn(u=>{if(!m[u.walletId]&&u.installUrl&&u.type==="extension"){window.open(u.installUrl,"_blank");return}t(),o(u.walletId)},[t,o,m]),C=vn((u,h)=>{u.stopPropagation(),t(),window.open(h,"_blank")},[t]);return e?ne("div",{style:M.overlay,onClick:t,children:Ie("div",{style:M.modal,onClick:u=>u.stopPropagation(),children:[Ie("div",{style:M.header,children:[ne("h2",{style:M.title,children:s}),ne("button",{type:"button",onClick:t,style:M.closeBtn,"aria-label":"Close",children:Ie("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[ne("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ne("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ne("p",{style:M.desc,children:n}),ne("div",{style:M.walletList,children:w.map(u=>{let h=m[u.walletId],A=h===!1&&u.type==="extension"&&!!u.installUrl;return Ie("div",{style:M.walletGroup,children:[Ie("button",{type:"button",onClick:()=>I(u),style:{...M.walletItem,...u.walletId==="cross_wallet"?M.walletItemAccent:{}},"aria-label":`Connect with ${u.name}`,children:[u.iconUrl?ne("img",{src:u.iconUrl,alt:"",style:M.walletIcon}):ne("div",{style:M.walletIconPlaceholder}),Ie("div",{style:M.walletInfo,children:[Ie("div",{style:M.walletNameRow,children:[ne("span",{style:M.walletName,children:u.name}),h!==void 0&&ne("span",{style:{...M.badge,...h?M.badgeInstalled:M.badgeNotInstalled},children:h?"Installed":"Not Installed"})]}),ne("span",{style:M.walletDesc,children:A?"Extension not detected \u2014 click to install":u.type==="extension"?"Browser extension approval is required":u.walletId==="cross_wallet"?"App approval is required":u.walletId==="binance"?"Mobile app only \u2014 Add CROSS network first":h?"Connect with browser extension":"Scan QR code with app"})]})]}),u.guideUrl&&Ie("button",{type:"button",onClick:S=>C(S,u.guideUrl),style:M.guideBtn,children:[ne("span",{"aria-hidden":"true",children:"\u26A0\uFE0F"}),u.guideLabel??"Required Settings"]})]},u.walletId)})}),Ie("div",{style:M.troubleshoot,children:[ne("h3",{style:M.troubleshootTitle,children:"Wallet not detected?"}),ne("ul",{style:M.troubleshootList,children:a.map(u=>Ie("li",{style:M.troubleshootItem,children:[ne("span",{style:M.troubleshootDot,"aria-hidden":"true"}),ne("span",{children:u})]},u))})]})]})}):null}var q={surfaceBg:"var(--wi-surface-bg, #121212)",surfaceDefault:"var(--wi-surface-default, rgba(255,255,255,0.05))",surfaceSubtle:"var(--wi-surface-subtle, rgba(255,255,255,0.1))",borderDefault:"var(--wi-border-default, rgba(255,255,255,0.05))",textPrimary:"var(--wi-texticon-primary, #ffffff)",textSecondary:"var(--wi-texticon-secondary, rgba(255,255,255,0.7))",textTertiary:"var(--wi-texticon-tertiary, rgba(255,255,255,0.5))",primary:"var(--wi-primary, #019d92)",primarySoft:"var(--crossx-kit-primary-soft, rgba(1,157,146,0.15))",accentGradient:"var(--crossx-kit-accent-gradient, linear-gradient(113deg, rgba(255,255,255,0.05) 0%, rgba(1,157,146,0.12) 70%, rgba(255,255,255,0.05) 70%, rgba(1,157,146,0.12) 80%, rgba(255,255,255,0.05) 80%))",warningBg:"var(--crossx-kit-warning-bg, rgba(245,158,11,0.1))",warningBorder:"var(--crossx-kit-warning-border, rgba(245,158,11,0.25))",warningText:"var(--crossx-kit-warning-text, #fbbf24)"},M={overlay:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"},modal:{width:"100%",maxWidth:"420px",margin:"16px",background:q.surfaceBg,border:`1px solid ${q.borderDefault}`,borderRadius:"20px",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px 0"},title:{fontSize:"18px",fontWeight:700,color:q.textPrimary,margin:0},closeBtn:{background:"none",border:"none",color:q.textTertiary,cursor:"pointer",padding:"4px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},desc:{padding:"8px 24px 16px",fontSize:"13px",color:q.textTertiary,margin:0,lineHeight:1.5},walletList:{display:"flex",flexDirection:"column",gap:"6px",padding:"0 12px 12px"},walletGroup:{display:"flex",flexDirection:"column",borderRadius:"12px",overflow:"hidden",background:q.surfaceDefault},walletItem:{display:"flex",alignItems:"center",gap:"14px",width:"100%",padding:"14px",background:"transparent",border:"none",color:q.textPrimary,cursor:"pointer",textAlign:"left"},walletItemAccent:{background:q.accentGradient},walletIcon:{width:"40px",height:"40px",borderRadius:"10px",flexShrink:0},walletIconPlaceholder:{width:"40px",height:"40px",borderRadius:"10px",background:q.surfaceSubtle,flexShrink:0},walletInfo:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"3px"},walletNameRow:{display:"flex",alignItems:"center",gap:"8px"},walletName:{fontSize:"15px",fontWeight:700,lineHeight:1.3,color:q.textPrimary},badge:{fontSize:"10px",fontWeight:600,padding:"2px 7px",borderRadius:"99px",lineHeight:1},badgeInstalled:{background:q.primarySoft,color:q.primary},badgeNotInstalled:{background:"rgba(255,255,255,0.05)",color:q.textTertiary},walletDesc:{fontSize:"11px",color:q.textSecondary,lineHeight:1.3},guideBtn:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",margin:"0 14px 14px",padding:"10px 12px",borderRadius:"10px",border:`1px solid ${q.warningBorder}`,background:q.warningBg,color:q.warningText,fontWeight:600,fontSize:"13px",cursor:"pointer"},troubleshoot:{margin:"0 12px 16px",background:q.surfaceDefault,borderRadius:"12px",padding:"14px 16px"},troubleshootTitle:{fontSize:"12px",fontWeight:700,color:q.textPrimary,margin:"0 0 8px"},troubleshootList:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"8px"},troubleshootItem:{display:"flex",alignItems:"flex-start",gap:"8px",fontSize:"11px",color:q.textSecondary,lineHeight:1.5},troubleshootDot:{flexShrink:0,width:"4px",height:"4px",marginTop:"6px",borderRadius:"50%",background:q.textSecondary}};import{useOnRamp as oi,useOnRampEligibility as ri,OnRampProvider as si}from"@nexus-cross/onramp/react";import{WalletInfo as ai,ConnectorId as ci}from"@nexus-cross/dapp-ui";import{AppLauncher as li,AppLauncherTrigger as ui,AppLauncherContent as mi,useGlobalMenu as pi}from"@nexus-cross/dapp-ui";import{SkillsButton as gi}from"@nexus-cross/dapp-ui";import{OnRampError as yi}from"@nexus-cross/connect-kit-core";import{ConnectionStatus as wi,formatBalance as Ci,formatWei as ki}from"@nexus-cross/connect-kit-core";$t();export{Pe as a,Xn as b,rt as c,kt as d,xo as e,Rt as f,Bt as g,Fr as h,Vr as i,oi as j,ri as k,si as l,ai as m,ci as n,li as o,ui as p,mi as q,pi as r,gi as s,yi as t,wi as u,Ci as v,ki as w};
|