@antseed/gateway-console 0.1.11 → 0.1.12
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/assets/{Activity-UaQeZdKk.js → Activity-BcXN_DqV.js} +1 -1
- package/dist/assets/Audit-nk0K4aQy.js +1 -0
- package/dist/assets/{BrandIcon-dTKznfCA.js → BrandIcon-6gq42Dg-.js} +1 -1
- package/dist/assets/{ChainGate-DpChfDOP.js → ChainGate-Do1wYOPQ.js} +1 -1
- package/dist/assets/{ChannelClose-DpNV5MqB.js → ChannelClose-CdHUKMFm.js} +1 -1
- package/dist/assets/{Charts-C65ZE2xP.js → Charts-BMsoEfDr.js} +1 -1
- package/dist/assets/{Chat-BbM_y6mh.js → Chat-C4DsUQG-.js} +3 -3
- package/dist/assets/{ConnectWallet-CLv0c-JB.js → ConnectWallet-BYdqZipy.js} +1 -1
- package/dist/assets/{DataTable-BkJdorEh.js → DataTable-BCgVRqY6.js} +1 -1
- package/dist/assets/{Disclosure-DMLE7rCw.js → Disclosure-CQMtWM0M.js} +1 -1
- package/dist/assets/{KeyHolder-Cjko0nrs.js → KeyHolder-JK1zjm4r.js} +1 -1
- package/dist/assets/{Keys-DLKN6Sna.js → Keys-BndDLQdj.js} +1 -1
- package/dist/assets/{Logs-DIPNoSb8.js → Logs-DfacvRY6.js} +1 -1
- package/dist/assets/{Members-CgP9OTz9.js → Members-pSSyfBFp.js} +1 -1
- package/dist/assets/{Migrate-DDHZ-rux.js → Migrate-Bqnu-HEP.js} +1 -1
- package/dist/assets/{ModelDetails-CkDNU2Px.js → ModelDetails-Sgq3MjfG.js} +1 -1
- package/dist/assets/{Models-DXbiNymT.js → Models-C6QzCAh4.js} +1 -1
- package/dist/assets/{OperatorActions-BuEpaCiH.js → OperatorActions-DWX4uK6I.js} +1 -1
- package/dist/assets/{OperatorGateAlert-grMRoFdV.js → OperatorGateAlert-cpvsO9yT.js} +1 -1
- package/dist/assets/{Overview-BU9HCltc.js → Overview-C4Bu8z8u.js} +1 -1
- package/dist/assets/{PeerPicker-CfsXTUyK.js → PeerPicker-CcMSXxY3.js} +1 -1
- package/dist/assets/PolicyEditor-COREmE0O.js +1 -0
- package/dist/assets/PolicyField-ldIq_Yw-.js +1 -0
- package/dist/assets/{Presets-szQETQLM.js → Presets-DFKw93HK.js} +2 -2
- package/dist/assets/Providers-D_0V31og.js +1 -0
- package/dist/assets/{RequestLog-DJl6FJhq.js → RequestLog-ChzJA1hM.js} +1 -1
- package/dist/assets/{Rewards-BOfJumNk.js → Rewards-Cgw7r3bc.js} +2 -2
- package/dist/assets/{RewardsClaim-DHvgMfZ4.js → RewardsClaim-Df0QQMHb.js} +1 -1
- package/dist/assets/Routing-KpWxzlwc.js +1 -0
- package/dist/assets/{Segmented-D3e0aBDU.js → Segmented-DYnoemT9.js} +1 -1
- package/dist/assets/{SelectField-Cl4acfcI.js → SelectField-m1sMIgMa.js} +1 -1
- package/dist/assets/Settings-D2MkmqAU.js +7 -0
- package/dist/assets/{SidePanel-D0rNElh3.js → SidePanel-BFQArkoa.js} +1 -1
- package/dist/assets/{Staking-1D2HNu5P.js → Staking-2rSdK2Ob.js} +1 -1
- package/dist/assets/{StakingDashboard-C5Ib_AUs.js → StakingDashboard-DvLxJ1j4.js} +1 -1
- package/dist/assets/{Switch-B2AEvyu7.js → Switch-Db8Sm64J.js} +1 -1
- package/dist/assets/{Tabs-Cv10NtDy.js → Tabs-CCabxVNK.js} +1 -1
- package/dist/assets/{TextAreaField-Dbr655cs.js → TextAreaField-BCi-qMua.js} +1 -1
- package/dist/assets/{UsageByModel-BfvCLwo9.js → UsageByModel-Fb68pvpD.js} +1 -1
- package/dist/assets/{VerificationLinks-CERoRvCR.js → VerificationLinks-CWyl6ZEp.js} +1 -1
- package/dist/assets/{Wallet-CVS_hzu0.js → Wallet-BVuVEAB5.js} +7 -7
- package/dist/assets/{WalletConfirm-C8Kazsh7.js → WalletConfirm-Bs7CFRaa.js} +1 -1
- package/dist/assets/{WalletFunding-BbhXB813.js → WalletFunding-w9MlXB0t.js} +1 -1
- package/dist/assets/{WalletSignIn-Tzs38aME.js → WalletSignIn-CFxQjhbw.js} +1 -1
- package/dist/assets/{Workspaces-DGgrOEZk.js → Workspaces-DktyLm08.js} +1 -1
- package/dist/assets/{add-CdcnAnIQ.js → add-CWU7ACA6.js} +1 -1
- package/dist/assets/{all-wallets-CaMIS0WH.js → all-wallets-C7xN3fay.js} +1 -1
- package/dist/assets/{app-store-BJlWsf36.js → app-store-C9LYdcrl.js} +1 -1
- package/dist/assets/{apple-sOU-w3fg.js → apple-DyeheYaR.js} +1 -1
- package/dist/assets/{arrow-bottom-CTOfZJ7E.js → arrow-bottom-C-Ld0QTs.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-B6IrOSiK.js → arrow-bottom-circle-CBZDZ8Ab.js} +1 -1
- package/dist/assets/{arrow-left-D0Qm9EWX.js → arrow-left-DpJrY7yH.js} +1 -1
- package/dist/assets/{arrow-right-XMSWQLiv.js → arrow-right-C12AYUbo.js} +1 -1
- package/dist/assets/{arrow-top-Bym-ayRK.js → arrow-top-DTpoR1JD.js} +1 -1
- package/dist/assets/{bank-NJF8WYDR.js → bank-Ce19qcX5.js} +1 -1
- package/dist/assets/{basic-bO70Xvle.js → basic-xSJded8g.js} +1 -1
- package/dist/assets/{browser-ucjw1tpv.js → browser-efLjW-nE.js} +1 -1
- package/dist/assets/{bundle-full-idGWmtvy.js → bundle-full-Bo_XusKG.js} +1 -1
- package/dist/assets/{card-DcpyI2qX.js → card-C5hP1T57.js} +1 -1
- package/dist/assets/{ccip-DBXxv0FH.js → ccip-B61TPyfu.js} +1 -1
- package/dist/assets/{checkmark-RFLSeCgj.js → checkmark-D6TDn2nt.js} +1 -1
- package/dist/assets/{checkmark-bold-Dl1q9Kby.js → checkmark-bold-D6Dl_7lL.js} +1 -1
- package/dist/assets/{chevron-bottom-ilycsYd4.js → chevron-bottom-BN93pLQ-.js} +1 -1
- package/dist/assets/{chevron-left-DFK2Xbq1.js → chevron-left-BRtPfxLq.js} +1 -1
- package/dist/assets/{chevron-right-Ew8XV9m9.js → chevron-right-q6ckJ6mb.js} +1 -1
- package/dist/assets/{chevron-top-CxoXH2-q.js → chevron-top-C1AX5sm6.js} +1 -1
- package/dist/assets/{chrome-store-ClmhY3B0.js → chrome-store-Bo_BoLHJ.js} +1 -1
- package/dist/assets/{clock-CCiukNBf.js → clock-BhAO_7G0.js} +1 -1
- package/dist/assets/{close-B0KBYbXe.js → close-BtzdVDHu.js} +1 -1
- package/dist/assets/{code-block-DxUcjw4S.js → code-block-DqMh9vFo.js} +1 -1
- package/dist/assets/{coinPlaceholder-D2ugxr3r.js → coinPlaceholder-Di1b8fYJ.js} +1 -1
- package/dist/assets/{compass-CutyEYmW.js → compass-C10lNmou.js} +1 -1
- package/dist/assets/{copy-CJ0RBt1e.js → copy-B5e38uFc.js} +1 -1
- package/dist/assets/{core-BCJdIbrO.js → core-B0f6zAPS.js} +3 -3
- package/dist/assets/{cursor-transparent-BQ_jwSfb.js → cursor-transparent-DzGICXfN.js} +1 -1
- package/dist/assets/cursor-zACYQT2t.js +3 -0
- package/dist/assets/{desktop-CsfFLaEs.js → desktop-DSb6a3DL.js} +1 -1
- package/dist/assets/{disconnect-B62slDXp.js → disconnect-DRzHq1ok.js} +1 -1
- package/dist/assets/{discord-B8GwtWtL.js → discord-c_RQc3fB.js} +1 -1
- package/dist/assets/{en_US-Y4ZOVFV4-sKQksBWU.js → en_US-Y4ZOVFV4-Bkc-z49M.js} +4 -4
- package/dist/assets/{etherscan-BT9zhNhd.js → etherscan-CQGvGKJu.js} +1 -1
- package/dist/assets/{exclamation-triangle-BSoPK6uq.js → exclamation-triangle-CPWxzsHw.js} +1 -1
- package/dist/assets/{extension-CQxJq6bp.js → extension-ytWXOqXr.js} +1 -1
- package/dist/assets/{external-link-BnfAKGN2.js → external-link-BYoSE2u3.js} +1 -1
- package/dist/assets/{facebook-DiAqdu4i.js → facebook-CMBv0nnN.js} +1 -1
- package/dist/assets/{farcaster-B1y2in5M.js → farcaster-CJmfWTQP.js} +1 -1
- package/dist/assets/{filters-BkVUp9NW.js → filters-DEiNVvyn.js} +1 -1
- package/dist/assets/{github-IRwi-GM-.js → github-CdMwJkf8.js} +1 -1
- package/dist/assets/{google-k2ysL2bi.js → google-CHI5gfH8.js} +1 -1
- package/dist/assets/{help-circle-DLj9trmu.js → help-circle-dA36a8fM.js} +1 -1
- package/dist/assets/highlighted-body-KQOG7T2V-BFlyrf-z.js +1 -0
- package/dist/assets/{id-BY4HWjv7.js → id-Dm0-1g1D.js} +1 -1
- package/dist/assets/{image-BtUeZe1t.js → image-BL3ODVX_.js} +1 -1
- package/dist/assets/{index-DYK1gWhP.css → index-BAcoKUeC.css} +1 -1
- package/dist/assets/{index-DiB9Y59V.js → index-BRgGxCKs.js} +3 -3
- package/dist/assets/{index-Cmb-H95F.js → index-BXzZZOmS.js} +1 -1
- package/dist/assets/{index-BXwAwVaO.js → index-CHeO_lLD.js} +1 -1
- package/dist/assets/{index-DsRX2D_O.js → index-D1OXThJP.js} +1 -1
- package/dist/assets/{index-cESr4Zze.js → index-DPXW_JSn.js} +10 -10
- package/dist/assets/{index.es-DP9EmOYi.js → index.es-XdMmjy3e.js} +3 -3
- package/dist/assets/{info-BaKj81_D.js → info-BbBzpLWs.js} +1 -1
- package/dist/assets/{info-circle-ecoA_B_t.js → info-circle-CKgnYdF-.js} +1 -1
- package/dist/assets/{lightbulb-DGQG-WWk.js → lightbulb-B6Xv9kMK.js} +1 -1
- package/dist/assets/{limits-D2JvFgaN.js → limits-uCwhqY-O.js} +1 -1
- package/dist/assets/{mail-BvEbsX3q.js → mail-BdCMypwE.js} +1 -1
- package/dist/assets/{mermaid-MCJ5UELQ-B8uOykea.js → mermaid-MCJ5UELQ-BaHsArCB.js} +3 -3
- package/dist/assets/{metamask-sdk-BYmYI1f3.js → metamask-sdk-BL7QLxcU.js} +1 -1
- package/dist/assets/{mobile-CwlM4JMX.js → mobile-F_82dhUb.js} +1 -1
- package/dist/assets/{more-CT36TpLm.js → more-CtMTtAsM.js} +1 -1
- package/dist/assets/{network-placeholder-DG1Vvm-U.js → network-placeholder-BRs4Lylz.js} +1 -1
- package/dist/assets/{nftPlaceholder-D6USOn7p.js → nftPlaceholder-DONTHyad.js} +1 -1
- package/dist/assets/{off-BNSO7pY1.js → off-Bwru40fy.js} +1 -1
- package/dist/assets/{play-store-PUfM0qU0.js → play-store-CDeNquGq.js} +1 -1
- package/dist/assets/{plus-C8fnGfp3.js → plus-EcrYfJFM.js} +1 -1
- package/dist/assets/{qr-code-CjdrQ0pR.js → qr-code-CF-SIZQq.js} +1 -1
- package/dist/assets/{recycle-horizontal-BMxBgeB4.js → recycle-horizontal-CQAPujmy.js} +1 -1
- package/dist/assets/{refresh-C2D196Fq.js → refresh-BErGEy2b.js} +1 -1
- package/dist/assets/{reown-logo-CLN2ORKJ.js → reown-logo-Ge2o4AAI.js} +1 -1
- package/dist/assets/{search-C9voC8dq.js → search-Ca88O9BA.js} +1 -1
- package/dist/assets/selection-BV37SUs_.js +1 -0
- package/dist/assets/{send-BAxcrGbA.js → send-VS1TUwft.js} +1 -1
- package/dist/assets/{sendTransaction-Cmz5eiPq.js → sendTransaction-k8aDYfd4.js} +1 -1
- package/dist/assets/stored-e0tX90bC.js +1 -0
- package/dist/assets/{swapHorizontal-CHCTyoP7.js → swapHorizontal-UNJ9wJ3Z.js} +1 -1
- package/dist/assets/{swapHorizontalBold-LQsONWBk.js → swapHorizontalBold-eQTpC4fd.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-BxrBEjrx.js → swapHorizontalMedium-DaFWQu14.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-CEHDoSv1.js → swapHorizontalRoundedBold-BbRZUmJZ.js} +1 -1
- package/dist/assets/{swapVertical-DMylrYB1.js → swapVertical-CrZ6Be2R.js} +1 -1
- package/dist/assets/{telegram-BhVfpln1.js → telegram-CDAYT0ej.js} +1 -1
- package/dist/assets/{three-dots-nkXRRS-E.js → three-dots-CK__4w5S.js} +1 -1
- package/dist/assets/{twitch-CYroZH_7.js → twitch-BS50nSpU.js} +1 -1
- package/dist/assets/{twitterIcon-DpHUqlyA.js → twitterIcon-BtVx5zJI.js} +1 -1
- package/dist/assets/{usage-8BBeTlF-.js → usage-DQGKL0DJ.js} +1 -1
- package/dist/assets/{useInfiniteQuery-zD1WIYBy.js → useInfiniteQuery-CAj47QRO.js} +1 -1
- package/dist/assets/{useTx-DsLsc5bB.js → useTx-DzRlz7Ez.js} +1 -1
- package/dist/assets/{verify-filled-EsNi41IB.js → verify-filled-E4LyUumx.js} +1 -1
- package/dist/assets/{verify-DARDbLiQ.js → verify-hRAQBjoS.js} +1 -1
- package/dist/assets/{w3m-modal-CIUN4uxE.js → w3m-modal-CLSVKDRP.js} +1 -1
- package/dist/assets/{waitForCallsStatus-DlpsNYx1.js → waitForCallsStatus-C51Vv8Tt.js} +1 -1
- package/dist/assets/{wallet-B2vgeP1E.js → wallet-D-TGx4VA.js} +1 -1
- package/dist/assets/{wallet-placeholder-DQsissb3.js → wallet-placeholder-SjwHckDA.js} +1 -1
- package/dist/assets/{walletconnect-DylNgC0Z.js → walletconnect-7nuI2nwG.js} +1 -1
- package/dist/assets/{warning-circle-CVEgsVb4.js → warning-circle-BI2BfSeD.js} +1 -1
- package/dist/assets/{writeContract-Cqg_OlRQ.js → writeContract-CaMlmKcK.js} +1 -1
- package/dist/assets/{x-DSURRh6S.js → x-DoGk7CZD.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/Audit-Cd26xOlL.js +0 -1
- package/dist/assets/PolicyEditor-ptFDJhFh.js +0 -1
- package/dist/assets/PolicyField-CHhm50jF.js +0 -1
- package/dist/assets/Providers-B6xbFeNU.js +0 -1
- package/dist/assets/Routing-DFuhPfzU.js +0 -1
- package/dist/assets/Settings--0bbw1dn.js +0 -7
- package/dist/assets/cursor-Bg_hT9DN.js +0 -3
- package/dist/assets/highlighted-body-KQOG7T2V-CJM-VU3I.js +0 -1
- package/dist/assets/selection-HN8SZ52c.js +0 -1
- package/dist/assets/stored-CETnaQtE.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/basic-
|
|
2
|
-
import{_ as Sc}from"./index-cESr4Zze.js";import{I as mi,t as it,c as q,a as Tt,C as dp,f as Et,d as pp,b as ji,s as fa,e as ih,g as pr,k as hn,A as nh,E as ht,i as fp,h as gp,y as kt,j as Qs,r as wi,O as rc,o as qt,l as mp,m as ic,n as nc,p as io,N as oc,P as Pc,Q as wp,q as yp,u as bp,v as Oc,w as zr,x as oh,z as ps,B as is,D as ah,F as Es,G as Xt}from"./index.es-DP9EmOYi.js";import{at as vp,au as Ep,av as Cp,aw as Ip,ax as Ap,ay as Np,a3 as _p,az as Sp,ao as An,aA as Tc}from"./en_US-Y4ZOVFV4-sKQksBWU.js";function $c(t,e={}){const{key:s="fallback",name:r="Fallback",rank:i=!1,shouldThrow:n=Pp,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:u,...h})=>{let d=t,g=()=>{};const y=vp({key:s,name:r,async request({method:f,params:p}){let m;const w=async(C=0)=>{const O=d[C]({...h,chain:c,retryCount:0,timeout:u});try{const $=await O.request({method:f,params:p});return g({method:f,params:p,response:$,transport:O,status:"success"}),$}catch($){if(g({error:$,method:f,params:p,transport:O,status:"error"}),n($)||C===d.length-1||(m??(m=d.slice(C+1).some(S=>{const{include:N,exclude:T}=S({chain:c}).config.methods||{};return N?N.includes(f):T?!T.includes(f):!0})),!m))throw $;return w(C+1)}};return w()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>g=f,transports:d.map(f=>f({chain:c,retryCount:0}))});if(i){const f=typeof i=="object"?i:{};Op({chain:c,interval:f.interval??l,onTransports:p=>d=p,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:d,weights:f.weights})}return y})}function Pp(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Ep.code||t.code===Cp.code||t.code===Ip.code||Ap.nodeMessage.test(t.message)||t.code===5e3))}function Op({chain:t,interval:e=4e3,onTransports:s,ping:r,sampleCount:i=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],h=async()=>{const d=await Promise.all(o.map(async f=>{const p=f({chain:t,retryCount:0,timeout:n}),m=Date.now();let w,C;try{await(r?r({transport:p}):p.request({method:"net_listening"})),C=1}catch{C=0}finally{w=Date.now()}return{latency:w-m,success:C}}));u.push(d),u.length>i&&u.shift();const g=Math.max(...u.map(f=>Math.max(...f.map(({latency:p})=>p)))),y=o.map((f,p)=>{const m=u.map(S=>S[p].latency),C=1-m.reduce((S,N)=>S+N,0)/m.length/g,O=u.map(S=>S[p].success),$=O.reduce((S,N)=>S+N,0)/O.length;return $===0?[0,p]:[l*C+c*$,p]}).sort((f,p)=>p[0]-f[0]);s(y.map(([,f])=>o[f])),await Np(e),h()};h()}var kc={};const K={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof process<"u"&&typeof kc<"u"?kc.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},ch={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=K.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var Tp=20,$p=1,or=1e6,xc=1e6,kp=-7,xp=21,Rp=!1,dn="[big.js] ",fr=dn+"Invalid ",no=fr+"decimal places",Up=fr+"rounding mode",lh=dn+"Division by zero",Ee={},os=void 0,Dp=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function uh(){function t(e){var s=this;if(!(s instanceof t))return e===os?uh():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(fr+"value");e=e===0&&1/e<0?"-0":String(e)}Lp(s,e)}s.constructor=t}return t.prototype=Ee,t.DP=Tp,t.RM=$p,t.NE=kp,t.PE=xp,t.strict=Rp,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Lp(t,e){var s,r,i;if(!Dp.test(e))throw Error(fr+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(s<0&&(s=r),s+=+e.slice(r+1),e=e.substring(0,r)):s<0&&(s=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=s-r-1,t.c=[],s=0;r<=i;)t.c[s++]=+e.charAt(r++)}return t}function gr(t,e,s,r){var i=t.c;if(s===os&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(Up);if(e<1)r=s===3&&(r||!!i[0])||e===0&&(s===1&&i[0]>=5||s===2&&(i[0]>5||i[0]===5&&(r||i[1]!==os))),i.length=1,r?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(r=s===1&&i[e]>=5||s===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==os||i[e-1]&1))||s===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function mr(t,e,s){var r=t.e,i=t.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>n)for(r-=n;r--;)i+="0";else r<n&&(i=i.slice(0,r)+"."+i.slice(r));else n>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&s?"-"+i:i}Ee.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ee.cmp=function(t){var e,s=this,r=s.c,i=(t=new s.constructor(t)).c,n=s.s,o=t.s,a=s.e,c=t.e;if(!r[0]||!i[0])return r[0]?n:i[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=c)return a>c^e?1:-1;for(o=(a=r.length)<(c=i.length)?a:c,n=-1;++n<o;)if(r[n]!=i[n])return r[n]>i[n]^e?1:-1;return a==c?0:a>c^e?1:-1};Ee.div=function(t){var e=this,s=e.constructor,r=e.c,i=(t=new s(t)).c,n=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>or)throw Error(no);if(!i[0])throw Error(lh);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),g=a=i.length,y=r.length,f=r.slice(0,a),p=f.length,m=t,w=m.c=[],C=0,O=o+(m.e=e.e-t.e)+1;for(m.s=n,n=O<0?0:O,d.unshift(0);p++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(p=f.length))u=a>p?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=f[h]){u=i[h]>f[h]?1:-1;break}if(u<0){for(c=p==a?i:d;p;){if(f[--p]<c[p]){for(h=p;h&&!f[--h];)f[h]=9;--f[h],f[p]+=10}f[p]-=c[p]}for(;!f[0];)f.shift()}else break}w[C++]=u?l:++l,f[0]&&u?f[p]=r[g]||0:f=[r[g]]}while((g++<y||f[0]!==os)&&n--);return!w[0]&&C!=1&&(w.shift(),m.e--,O--),C>O&&gr(m,O,s.RM,f[0]!==os),m};Ee.eq=function(t){return this.cmp(t)===0};Ee.gt=function(t){return this.cmp(t)>0};Ee.gte=function(t){return this.cmp(t)>-1};Ee.lt=function(t){return this.cmp(t)<0};Ee.lte=function(t){return this.cmp(t)<1};Ee.minus=Ee.sub=function(t){var e,s,r,i,n=this,o=n.constructor,a=n.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,n.plus(t);var l=n.c.slice(),u=n.e,h=t.c,d=t.e;if(!l[0]||!h[0])return h[0]?t.s=-c:l[0]?t=new o(n):t.s=1,t;if(a=u-d){for((i=a<0)?(a=-a,r=l):(d=u,r=h),r.reverse(),c=a;c--;)r.push(0);r.reverse()}else for(s=((i=l.length<h.length)?l:h).length,a=c=0;c<s;c++)if(l[c]!=h[c]){i=l[c]<h[c];break}if(i&&(r=l,l=h,h=r,t.s=-t.s),(c=(s=h.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<h[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=h[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t};Ee.mod=function(t){var e,s=this,r=s.constructor,i=s.s,n=(t=new r(t)).s;if(!t.c[0])throw Error(lh);return s.s=t.s=1,e=t.cmp(s)==1,s.s=i,t.s=n,e?new r(s):(i=r.DP,n=r.RM,r.DP=r.RM=0,s=s.div(t),r.DP=i,r.RM=n,this.minus(s.times(t)))};Ee.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ee.plus=Ee.add=function(t){var e,s,r,i=this,n=i.constructor;if(t=new n(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new n(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,r=l):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-l.length<0&&(r=l,l=a,a=r),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};Ee.pow=function(t){var e=this,s=new e.constructor("1"),r=s,i=t<0;if(t!==~~t||t<-xc||t>xc)throw Error(fr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};Ee.prec=function(t,e){if(t!==~~t||t<1||t>or)throw Error(fr+"precision");return gr(new this.constructor(this),t,e)};Ee.round=function(t,e){if(t===os)t=0;else if(t!==~~t||t<-or||t>or)throw Error(no);return gr(new this.constructor(this),t+this.e+1,e)};Ee.sqrt=function(){var t,e,s,r=this,i=r.constructor,n=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(n<0)throw Error(dn+"No square root");n=Math.sqrt(+mr(r,!0,!0)),n===0||n===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):t=new i(n+""),o=t.e+(i.DP+=4);do s=t,t=a.times(s.plus(r.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return gr(t,(i.DP-=4)+t.e+1,i.RM)};Ee.times=Ee.mul=function(t){var e,s=this,r=s.constructor,i=s.c,n=(t=new r(t)).c,o=i.length,a=n.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!i[0]||!n[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=n,n=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+n[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};Ee.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>or)throw Error(no);for(s=gr(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return mr(s,!0,!!r)};Ee.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>or)throw Error(no);for(s=gr(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return mr(s,!1,!!r)};Ee[Symbol.for("nodejs.util.inspect.custom")]=Ee.toJSON=Ee.toString=function(){var t=this,e=t.constructor;return mr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ee.toNumber=function(){var t=+mr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(dn+"Imprecise conversion");return t};Ee.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==os){if(t!==~~t||t<1||t>or)throw Error(fr+"precision");for(s=gr(new r(s),t,e);s.c.length<t;)s.c.push(0)}return mr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};Ee.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(dn+"valueOf disallowed");return mr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Ii=uh();const Bp={bigNumber(t){return t?new Ii(t):new Ii(0)},multiply(t,e){if(t===void 0||e===void 0)return new Ii(0);const s=new Ii(t),r=new Ii(e);return s.times(r)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},Mp=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],qp=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],jp=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Fp={getERC20Abi:t=>K.USDT_CONTRACT_ADDRESSES.includes(t)?jp:Mp,getSwapAbi:()=>qp},Cs={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},re={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function Io(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const se={setItem(t,e){Ri()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Ri())return localStorage.getItem(t)||void 0},removeItem(t){Ri()&&localStorage.removeItem(t)},clear(){Ri()&&localStorage.clear()}};function Ri(){return typeof window<"u"&&typeof localStorage<"u"}function ks(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const Wp=Symbol(),Rc=Object.getPrototypeOf,ga=new WeakMap,Hp=t=>t&&(ga.has(t)?ga.get(t):Rc(t)===Object.prototype||Rc(t)===Array.prototype),zp=t=>Hp(t)&&t[Wp]||null,Uc=(t,e=!0)=>{ga.set(t,e)},Jn={},Ao=t=>typeof t=="object"&&t!==null,Ts=new WeakMap,Ui=new WeakSet,Vp=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>Ao(l)&&!Ui.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,u,h=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const g=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Uc(g,!0),i.set(l,[u,g]),Reflect.ownKeys(l).forEach(y=>{if(Object.getOwnPropertyDescriptor(g,y))return;const f=Reflect.get(l,y),{enumerable:p}=Reflect.getOwnPropertyDescriptor(l,y),m={value:f,enumerable:p,configurable:!0};if(Ui.has(f))Uc(f,!1);else if(f instanceof Promise)delete m.value,m.get=()=>h(f);else if(Ts.has(f)){const[w,C]=Ts.get(f);m.value=n(w,C(),h)}Object.defineProperty(g,y,m)}),Object.preventExtensions(g)},o=new WeakMap,a=[1,1],c=l=>{if(!Ao(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,g=(v,k=++a[0])=>{h!==k&&(h=k,d.forEach(P=>P(v,k)))};let y=a[1];const f=(v=++a[1])=>(y!==v&&!d.size&&(y=v,m.forEach(([k])=>{const P=k[1](v);P>h&&(h=P)})),h),p=v=>(k,P)=>{const R=[...k];R[1]=[v,...R[1]],g(R,P)},m=new Map,w=(v,k)=>{if((Jn?"production":void 0)!=="production"&&m.has(v))throw new Error("prop listener already exists");if(d.size){const P=k[3](p(v));m.set(v,[k,P])}else m.set(v,[k])},C=v=>{var k;const P=m.get(v);P&&(m.delete(v),(k=P[1])==null||k.call(P))},O=v=>(d.add(v),d.size===1&&m.forEach(([P,R],L)=>{if((Jn?"production":void 0)!=="production"&&R)throw new Error("remove already exists");const E=P[3](p(L));m.set(L,[P,E])}),()=>{d.delete(v),d.size===0&&m.forEach(([P,R],L)=>{R&&(R(),m.set(L,[P]))})}),$=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),N=e($,{deleteProperty(v,k){const P=Reflect.get(v,k);C(k);const R=Reflect.deleteProperty(v,k);return R&&g(["delete",[k],P]),R},set(v,k,P,R){const L=Reflect.has(v,k),E=Reflect.get(v,k,R);if(L&&(t(E,P)||o.has(P)&&t(E,o.get(P))))return!0;C(k),Ao(P)&&(P=zp(P)||P);let A=P;if(P instanceof Promise)P.then(I=>{P.status="fulfilled",P.value=I,g(["resolve",[k],I])}).catch(I=>{P.status="rejected",P.reason=I,g(["reject",[k],I])});else{!Ts.has(P)&&s(P)&&(A=c(P));const I=!Ui.has(A)&&Ts.get(A);I&&w(k,I)}return Reflect.set(v,k,A,R),g(["set",[k],P,E]),!0}});o.set(l,N);const T=[$,f,n,O];return Ts.set(N,T),Reflect.ownKeys(l).forEach(v=>{const k=Object.getOwnPropertyDescriptor(l,v);"value"in k&&(N[v]=l[v],delete k.value,delete k.writable),Object.defineProperty($,v,k)}),N})=>[c,Ts,Ui,t,e,s,r,i,n,o,a],[Kp]=Vp();function ke(t={}){return Kp(t)}function nt(t,e,s){const r=Ts.get(t);(Jn?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let i;const n=[],o=r[3];let a=!1;const l=o(u=>{n.push(u),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Qi(t,e){const s=Ts.get(t);(Jn?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function ar(t){return Ui.add(t),t}function ot(t,e,s,r){let i=t[e];return nt(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function Gp(t){const e=ke({data:Array.from([]),has(s){return this.data.some(r=>r[0]===s)},set(s,r){const i=this.data.find(n=>n[0]===s);return i?i[1]=r:this.data.push([s,r]),this},get(s){var r;return(r=this.data.find(i=>i[0]===s))==null?void 0:r[1]},delete(s){const r=this.data.findIndex(i=>i[0]===s);return r===-1?!1:(this.data.splice(r,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(s){this.data.forEach(r=>{s(r[1],r[0],this)})},keys(){return this.data.map(s=>s[0]).values()},values(){return this.data.map(s=>s[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const hh=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],Jp="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Pe={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,ONE_SEC_MS:1e3,BALANCE_SUPPORTED_CHAINS:["eip155","solana"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal"}},z={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=z.getActiveNamespace(),e=z.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,r=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:r}},setWalletConnectDeepLink({name:t,href:e}){try{se.setItem(re.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=se.getItem(re.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{se.removeItem(re.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{se.setItem(re.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{se.setItem(re.ACTIVE_CAIP_NETWORK_ID,t),z.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return se.getItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{se.removeItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=Io(t);se.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=z.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),se.setItem(re.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=se.getItem(re.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Io(t);se.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return se.getItem(re.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Io(t);return se.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{se.setItem(re.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return se.getItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{se.removeItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return se.getItem(re.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=se.getItem(re.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{se.setItem(re.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return se.getItem(re.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=se.getItem(re.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));se.setItem(re.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=z.getConnectedNamespaces();e.includes(t)||(e.push(t),z.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=z.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),z.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return se.getItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{se.setItem(re.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{se.removeItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=se.getItem(re.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=z.getBalanceCache();se.setItem(re.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=z.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;z.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=z.getBalanceCache();e[t.caipAddress]=t,se.setItem(re.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=se.getItem(re.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=z.getBalanceCache();se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=z.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),z.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=z.getNativeBalanceCache();e[t.caipAddress]=t,se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=se.getItem(re.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=z.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;z.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=z.getEnsCache();e[t.address]=t,se.setItem(re.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=z.getEnsCache();se.setItem(re.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=se.getItem(re.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=z.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;z.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=z.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},se.setItem(re.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=z.getIdentityCache();se.setItem(re.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{se.removeItem(re.PORTFOLIO_CACHE),se.removeItem(re.NATIVE_BALANCE_CACHE),se.removeItem(re.ENS_CACHE),se.removeItem(re.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{se.setItem(re.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=se.getItem(re.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s={...z.getConnections(),[e]:t};se.setItem(re.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=se.getItem(re.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},te={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return te.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Pe.TEN_SEC_MS:!0},isAllowedRetry(t,e=Pe.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(te.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Pe.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(te.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t,i=s;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),i&&!(i!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!te.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const r=encodeURIComponent(e);return{redirect:`${s}wc?uri=${r}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?z.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,te.wait(2e3)])},formatBalance(t,e){let s="0.000";if(typeof t=="string"){const r=Number(t);if(r){const i=Math.floor(r*1e3)/1e3;i&&(s=i.toString())}}return`${s}${e?` ${e}`:""}`},formatBalance2(t,e){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return K.W3M_API_URL},getBlockchainApiUrl(){return K.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return K.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?Pe.ADAPTER_TYPES.UNIVERSAL:t.map(n=>n.adapterType).join(",");return`${e}-${i}-${s}`},createAccount(t,e,s,r,i){return{namespace:t,address:e,type:s,publicKey:r,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in K.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function Ai(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class pn{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await Ai(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:s}){const r=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([i,n])=>{n&&r.searchParams.append(i,n)}),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}const Yp={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Pe.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(te.isTelegram()){if(te.isIos())return t.filter(e=>e!=="google");if(te.isMac())return t.filter(e=>e!=="x");if(te.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},Y=ke({features:Pe.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Pe.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),B={state:Y,subscribeKey(t,e){return ot(Y,t,e)},setOptions(t){Object.assign(Y,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...Y.remoteFeatures,...t};Y.remoteFeatures=e,(s=Y.remoteFeatures)!=null&&s.socials&&(Y.remoteFeatures.socials=Yp.filterSocialsByPlatform(Y.remoteFeatures.socials))},setFeatures(t){if(!t)return;Y.features||(Y.features=Pe.DEFAULT_FEATURES);const e={...Y.features,...t};Y.features=e},setProjectId(t){Y.projectId=t},setCustomRpcUrls(t){Y.customRpcUrls=t},setAllWallets(t){Y.allWallets=t},setIncludeWalletIds(t){Y.includeWalletIds=t},setExcludeWalletIds(t){Y.excludeWalletIds=t},setFeaturedWalletIds(t){Y.featuredWalletIds=t},setTokens(t){Y.tokens=t},setTermsConditionsUrl(t){Y.termsConditionsUrl=t},setPrivacyPolicyUrl(t){Y.privacyPolicyUrl=t},setCustomWallets(t){Y.customWallets=t},setIsSiweEnabled(t){Y.isSiweEnabled=t},setIsUniversalProvider(t){Y.isUniversalProvider=t},setSdkVersion(t){Y.sdkVersion=t},setMetadata(t){Y.metadata=t},setDisableAppend(t){Y.disableAppend=t},setEIP6963Enabled(t){Y.enableEIP6963=t},setDebug(t){Y.debug=t},setEnableWalletConnect(t){Y.enableWalletConnect=t},setEnableWalletGuide(t){Y.enableWalletGuide=t},setEnableAuthLogger(t){Y.enableAuthLogger=t},setEnableWallets(t){Y.enableWallets=t},setPreferUniversalLinks(t){Y.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){Y.hasMultipleAddresses=t},setSIWX(t){Y.siwx=t},setConnectMethodsOrder(t){Y.features={...Y.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){Y.features={...Y.features,walletFeaturesOrder:t}},setSocialsOrder(t){Y.remoteFeatures={...Y.remoteFeatures,socials:t}},setCollapseWallets(t){Y.features={...Y.features,collapseWallets:t}},setEnableEmbedded(t){Y.enableEmbedded=t},setAllowUnsupportedChain(t){Y.allowUnsupportedChain=t},setManualWCControl(t){Y.manualWCControl=t},setEnableNetworkSwitch(t){Y.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(Y.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){Y.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return Y.universalProviderConfigOverride},getSnapshot(){return Qi(Y)}},Zp=Object.freeze({enabled:!0,events:[]}),Xp=new pn({baseUrl:te.getAnalyticsUrl(),clientId:null}),Qp=5,ef=60*1e3,Is=ke({...Zp}),tf={state:Is,subscribeKey(t,e){return ot(Is,t,e)},async sendError(t,e){if(!Is.enabled)return;const s=Date.now();if(Is.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<ef}).length>=Qp)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Is.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=B.state;await Xp.post({path:"/e",params:{projectId:n,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:te.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){Is.enabled=!0},disable(){Is.enabled=!1},clearEvents(){Is.events=[]}};class ei extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,ei.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/basic-xSJded8g.js","assets/index-BRgGxCKs.js","assets/index-DPXW_JSn.js","assets/index-BAcoKUeC.css","assets/dijkstra-COg3n3zL.js","assets/index.es-XdMmjy3e.js","assets/events-DQ172AOg.js","assets/en_US-Y4ZOVFV4-Bkc-z49M.js","assets/clsx-B-dksMZM.js","assets/index-BhwNCc8y.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/w3m-modal-CLSVKDRP.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Sc}from"./index-DPXW_JSn.js";import{I as mi,t as it,c as q,a as Tt,C as dp,f as Et,d as pp,b as ji,s as fa,e as ih,g as pr,k as hn,A as nh,E as ht,i as fp,h as gp,y as kt,j as Qs,r as wi,O as rc,o as qt,l as mp,m as ic,n as nc,p as io,N as oc,P as Pc,Q as wp,q as yp,u as bp,v as Oc,w as zr,x as oh,z as ps,B as is,D as ah,F as Es,G as Xt}from"./index.es-XdMmjy3e.js";import{at as vp,au as Ep,av as Cp,aw as Ip,ax as Ap,ay as Np,a3 as _p,az as Sp,ao as An,aA as Tc}from"./en_US-Y4ZOVFV4-Bkc-z49M.js";function $c(t,e={}){const{key:s="fallback",name:r="Fallback",rank:i=!1,shouldThrow:n=Pp,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:u,...h})=>{let d=t,g=()=>{};const y=vp({key:s,name:r,async request({method:f,params:p}){let m;const w=async(C=0)=>{const O=d[C]({...h,chain:c,retryCount:0,timeout:u});try{const $=await O.request({method:f,params:p});return g({method:f,params:p,response:$,transport:O,status:"success"}),$}catch($){if(g({error:$,method:f,params:p,transport:O,status:"error"}),n($)||C===d.length-1||(m??(m=d.slice(C+1).some(S=>{const{include:N,exclude:T}=S({chain:c}).config.methods||{};return N?N.includes(f):T?!T.includes(f):!0})),!m))throw $;return w(C+1)}};return w()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>g=f,transports:d.map(f=>f({chain:c,retryCount:0}))});if(i){const f=typeof i=="object"?i:{};Op({chain:c,interval:f.interval??l,onTransports:p=>d=p,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:d,weights:f.weights})}return y})}function Pp(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Ep.code||t.code===Cp.code||t.code===Ip.code||Ap.nodeMessage.test(t.message)||t.code===5e3))}function Op({chain:t,interval:e=4e3,onTransports:s,ping:r,sampleCount:i=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],h=async()=>{const d=await Promise.all(o.map(async f=>{const p=f({chain:t,retryCount:0,timeout:n}),m=Date.now();let w,C;try{await(r?r({transport:p}):p.request({method:"net_listening"})),C=1}catch{C=0}finally{w=Date.now()}return{latency:w-m,success:C}}));u.push(d),u.length>i&&u.shift();const g=Math.max(...u.map(f=>Math.max(...f.map(({latency:p})=>p)))),y=o.map((f,p)=>{const m=u.map(S=>S[p].latency),C=1-m.reduce((S,N)=>S+N,0)/m.length/g,O=u.map(S=>S[p].success),$=O.reduce((S,N)=>S+N,0)/O.length;return $===0?[0,p]:[l*C+c*$,p]}).sort((f,p)=>p[0]-f[0]);s(y.map(([,f])=>o[f])),await Np(e),h()};h()}var kc={};const K={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof process<"u"&&typeof kc<"u"?kc.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},ch={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=K.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var Tp=20,$p=1,or=1e6,xc=1e6,kp=-7,xp=21,Rp=!1,dn="[big.js] ",fr=dn+"Invalid ",no=fr+"decimal places",Up=fr+"rounding mode",lh=dn+"Division by zero",Ee={},os=void 0,Dp=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function uh(){function t(e){var s=this;if(!(s instanceof t))return e===os?uh():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(fr+"value");e=e===0&&1/e<0?"-0":String(e)}Lp(s,e)}s.constructor=t}return t.prototype=Ee,t.DP=Tp,t.RM=$p,t.NE=kp,t.PE=xp,t.strict=Rp,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Lp(t,e){var s,r,i;if(!Dp.test(e))throw Error(fr+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(s<0&&(s=r),s+=+e.slice(r+1),e=e.substring(0,r)):s<0&&(s=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=s-r-1,t.c=[],s=0;r<=i;)t.c[s++]=+e.charAt(r++)}return t}function gr(t,e,s,r){var i=t.c;if(s===os&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(Up);if(e<1)r=s===3&&(r||!!i[0])||e===0&&(s===1&&i[0]>=5||s===2&&(i[0]>5||i[0]===5&&(r||i[1]!==os))),i.length=1,r?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(r=s===1&&i[e]>=5||s===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==os||i[e-1]&1))||s===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function mr(t,e,s){var r=t.e,i=t.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>n)for(r-=n;r--;)i+="0";else r<n&&(i=i.slice(0,r)+"."+i.slice(r));else n>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&s?"-"+i:i}Ee.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ee.cmp=function(t){var e,s=this,r=s.c,i=(t=new s.constructor(t)).c,n=s.s,o=t.s,a=s.e,c=t.e;if(!r[0]||!i[0])return r[0]?n:i[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=c)return a>c^e?1:-1;for(o=(a=r.length)<(c=i.length)?a:c,n=-1;++n<o;)if(r[n]!=i[n])return r[n]>i[n]^e?1:-1;return a==c?0:a>c^e?1:-1};Ee.div=function(t){var e=this,s=e.constructor,r=e.c,i=(t=new s(t)).c,n=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>or)throw Error(no);if(!i[0])throw Error(lh);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),g=a=i.length,y=r.length,f=r.slice(0,a),p=f.length,m=t,w=m.c=[],C=0,O=o+(m.e=e.e-t.e)+1;for(m.s=n,n=O<0?0:O,d.unshift(0);p++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(p=f.length))u=a>p?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=f[h]){u=i[h]>f[h]?1:-1;break}if(u<0){for(c=p==a?i:d;p;){if(f[--p]<c[p]){for(h=p;h&&!f[--h];)f[h]=9;--f[h],f[p]+=10}f[p]-=c[p]}for(;!f[0];)f.shift()}else break}w[C++]=u?l:++l,f[0]&&u?f[p]=r[g]||0:f=[r[g]]}while((g++<y||f[0]!==os)&&n--);return!w[0]&&C!=1&&(w.shift(),m.e--,O--),C>O&&gr(m,O,s.RM,f[0]!==os),m};Ee.eq=function(t){return this.cmp(t)===0};Ee.gt=function(t){return this.cmp(t)>0};Ee.gte=function(t){return this.cmp(t)>-1};Ee.lt=function(t){return this.cmp(t)<0};Ee.lte=function(t){return this.cmp(t)<1};Ee.minus=Ee.sub=function(t){var e,s,r,i,n=this,o=n.constructor,a=n.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,n.plus(t);var l=n.c.slice(),u=n.e,h=t.c,d=t.e;if(!l[0]||!h[0])return h[0]?t.s=-c:l[0]?t=new o(n):t.s=1,t;if(a=u-d){for((i=a<0)?(a=-a,r=l):(d=u,r=h),r.reverse(),c=a;c--;)r.push(0);r.reverse()}else for(s=((i=l.length<h.length)?l:h).length,a=c=0;c<s;c++)if(l[c]!=h[c]){i=l[c]<h[c];break}if(i&&(r=l,l=h,h=r,t.s=-t.s),(c=(s=h.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<h[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=h[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t};Ee.mod=function(t){var e,s=this,r=s.constructor,i=s.s,n=(t=new r(t)).s;if(!t.c[0])throw Error(lh);return s.s=t.s=1,e=t.cmp(s)==1,s.s=i,t.s=n,e?new r(s):(i=r.DP,n=r.RM,r.DP=r.RM=0,s=s.div(t),r.DP=i,r.RM=n,this.minus(s.times(t)))};Ee.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ee.plus=Ee.add=function(t){var e,s,r,i=this,n=i.constructor;if(t=new n(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new n(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,r=l):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-l.length<0&&(r=l,l=a,a=r),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};Ee.pow=function(t){var e=this,s=new e.constructor("1"),r=s,i=t<0;if(t!==~~t||t<-xc||t>xc)throw Error(fr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};Ee.prec=function(t,e){if(t!==~~t||t<1||t>or)throw Error(fr+"precision");return gr(new this.constructor(this),t,e)};Ee.round=function(t,e){if(t===os)t=0;else if(t!==~~t||t<-or||t>or)throw Error(no);return gr(new this.constructor(this),t+this.e+1,e)};Ee.sqrt=function(){var t,e,s,r=this,i=r.constructor,n=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(n<0)throw Error(dn+"No square root");n=Math.sqrt(+mr(r,!0,!0)),n===0||n===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):t=new i(n+""),o=t.e+(i.DP+=4);do s=t,t=a.times(s.plus(r.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return gr(t,(i.DP-=4)+t.e+1,i.RM)};Ee.times=Ee.mul=function(t){var e,s=this,r=s.constructor,i=s.c,n=(t=new r(t)).c,o=i.length,a=n.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!i[0]||!n[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=n,n=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+n[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};Ee.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>or)throw Error(no);for(s=gr(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return mr(s,!0,!!r)};Ee.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>or)throw Error(no);for(s=gr(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return mr(s,!1,!!r)};Ee[Symbol.for("nodejs.util.inspect.custom")]=Ee.toJSON=Ee.toString=function(){var t=this,e=t.constructor;return mr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ee.toNumber=function(){var t=+mr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(dn+"Imprecise conversion");return t};Ee.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==os){if(t!==~~t||t<1||t>or)throw Error(fr+"precision");for(s=gr(new r(s),t,e);s.c.length<t;)s.c.push(0)}return mr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};Ee.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(dn+"valueOf disallowed");return mr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Ii=uh();const Bp={bigNumber(t){return t?new Ii(t):new Ii(0)},multiply(t,e){if(t===void 0||e===void 0)return new Ii(0);const s=new Ii(t),r=new Ii(e);return s.times(r)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},Mp=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],qp=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],jp=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Fp={getERC20Abi:t=>K.USDT_CONTRACT_ADDRESSES.includes(t)?jp:Mp,getSwapAbi:()=>qp},Cs={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},re={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function Io(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const se={setItem(t,e){Ri()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Ri())return localStorage.getItem(t)||void 0},removeItem(t){Ri()&&localStorage.removeItem(t)},clear(){Ri()&&localStorage.clear()}};function Ri(){return typeof window<"u"&&typeof localStorage<"u"}function ks(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const Wp=Symbol(),Rc=Object.getPrototypeOf,ga=new WeakMap,Hp=t=>t&&(ga.has(t)?ga.get(t):Rc(t)===Object.prototype||Rc(t)===Array.prototype),zp=t=>Hp(t)&&t[Wp]||null,Uc=(t,e=!0)=>{ga.set(t,e)},Jn={},Ao=t=>typeof t=="object"&&t!==null,Ts=new WeakMap,Ui=new WeakSet,Vp=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>Ao(l)&&!Ui.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,u,h=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const g=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Uc(g,!0),i.set(l,[u,g]),Reflect.ownKeys(l).forEach(y=>{if(Object.getOwnPropertyDescriptor(g,y))return;const f=Reflect.get(l,y),{enumerable:p}=Reflect.getOwnPropertyDescriptor(l,y),m={value:f,enumerable:p,configurable:!0};if(Ui.has(f))Uc(f,!1);else if(f instanceof Promise)delete m.value,m.get=()=>h(f);else if(Ts.has(f)){const[w,C]=Ts.get(f);m.value=n(w,C(),h)}Object.defineProperty(g,y,m)}),Object.preventExtensions(g)},o=new WeakMap,a=[1,1],c=l=>{if(!Ao(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,g=(v,k=++a[0])=>{h!==k&&(h=k,d.forEach(P=>P(v,k)))};let y=a[1];const f=(v=++a[1])=>(y!==v&&!d.size&&(y=v,m.forEach(([k])=>{const P=k[1](v);P>h&&(h=P)})),h),p=v=>(k,P)=>{const R=[...k];R[1]=[v,...R[1]],g(R,P)},m=new Map,w=(v,k)=>{if((Jn?"production":void 0)!=="production"&&m.has(v))throw new Error("prop listener already exists");if(d.size){const P=k[3](p(v));m.set(v,[k,P])}else m.set(v,[k])},C=v=>{var k;const P=m.get(v);P&&(m.delete(v),(k=P[1])==null||k.call(P))},O=v=>(d.add(v),d.size===1&&m.forEach(([P,R],L)=>{if((Jn?"production":void 0)!=="production"&&R)throw new Error("remove already exists");const E=P[3](p(L));m.set(L,[P,E])}),()=>{d.delete(v),d.size===0&&m.forEach(([P,R],L)=>{R&&(R(),m.set(L,[P]))})}),$=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),N=e($,{deleteProperty(v,k){const P=Reflect.get(v,k);C(k);const R=Reflect.deleteProperty(v,k);return R&&g(["delete",[k],P]),R},set(v,k,P,R){const L=Reflect.has(v,k),E=Reflect.get(v,k,R);if(L&&(t(E,P)||o.has(P)&&t(E,o.get(P))))return!0;C(k),Ao(P)&&(P=zp(P)||P);let A=P;if(P instanceof Promise)P.then(I=>{P.status="fulfilled",P.value=I,g(["resolve",[k],I])}).catch(I=>{P.status="rejected",P.reason=I,g(["reject",[k],I])});else{!Ts.has(P)&&s(P)&&(A=c(P));const I=!Ui.has(A)&&Ts.get(A);I&&w(k,I)}return Reflect.set(v,k,A,R),g(["set",[k],P,E]),!0}});o.set(l,N);const T=[$,f,n,O];return Ts.set(N,T),Reflect.ownKeys(l).forEach(v=>{const k=Object.getOwnPropertyDescriptor(l,v);"value"in k&&(N[v]=l[v],delete k.value,delete k.writable),Object.defineProperty($,v,k)}),N})=>[c,Ts,Ui,t,e,s,r,i,n,o,a],[Kp]=Vp();function ke(t={}){return Kp(t)}function nt(t,e,s){const r=Ts.get(t);(Jn?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let i;const n=[],o=r[3];let a=!1;const l=o(u=>{n.push(u),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Qi(t,e){const s=Ts.get(t);(Jn?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function ar(t){return Ui.add(t),t}function ot(t,e,s,r){let i=t[e];return nt(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function Gp(t){const e=ke({data:Array.from([]),has(s){return this.data.some(r=>r[0]===s)},set(s,r){const i=this.data.find(n=>n[0]===s);return i?i[1]=r:this.data.push([s,r]),this},get(s){var r;return(r=this.data.find(i=>i[0]===s))==null?void 0:r[1]},delete(s){const r=this.data.findIndex(i=>i[0]===s);return r===-1?!1:(this.data.splice(r,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(s){this.data.forEach(r=>{s(r[1],r[0],this)})},keys(){return this.data.map(s=>s[0]).values()},values(){return this.data.map(s=>s[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const hh=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],Jp="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Pe={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,ONE_SEC_MS:1e3,BALANCE_SUPPORTED_CHAINS:["eip155","solana"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal"}},z={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=z.getActiveNamespace(),e=z.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,r=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:r}},setWalletConnectDeepLink({name:t,href:e}){try{se.setItem(re.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=se.getItem(re.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{se.removeItem(re.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{se.setItem(re.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{se.setItem(re.ACTIVE_CAIP_NETWORK_ID,t),z.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return se.getItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{se.removeItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=Io(t);se.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=z.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),se.setItem(re.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=se.getItem(re.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Io(t);se.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return se.getItem(re.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Io(t);return se.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{se.setItem(re.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return se.getItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{se.removeItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return se.getItem(re.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=se.getItem(re.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{se.setItem(re.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return se.getItem(re.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=se.getItem(re.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));se.setItem(re.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=z.getConnectedNamespaces();e.includes(t)||(e.push(t),z.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=z.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),z.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return se.getItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{se.setItem(re.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{se.removeItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=se.getItem(re.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=z.getBalanceCache();se.setItem(re.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=z.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;z.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=z.getBalanceCache();e[t.caipAddress]=t,se.setItem(re.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=se.getItem(re.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=z.getBalanceCache();se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=z.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),z.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=z.getNativeBalanceCache();e[t.caipAddress]=t,se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=se.getItem(re.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=z.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;z.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=z.getEnsCache();e[t.address]=t,se.setItem(re.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=z.getEnsCache();se.setItem(re.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=se.getItem(re.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=z.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;z.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=z.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},se.setItem(re.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=z.getIdentityCache();se.setItem(re.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{se.removeItem(re.PORTFOLIO_CACHE),se.removeItem(re.NATIVE_BALANCE_CACHE),se.removeItem(re.ENS_CACHE),se.removeItem(re.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{se.setItem(re.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=se.getItem(re.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s={...z.getConnections(),[e]:t};se.setItem(re.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=se.getItem(re.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},te={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return te.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Pe.TEN_SEC_MS:!0},isAllowedRetry(t,e=Pe.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(te.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Pe.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(te.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t,i=s;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),i&&!(i!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!te.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const r=encodeURIComponent(e);return{redirect:`${s}wc?uri=${r}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?z.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,te.wait(2e3)])},formatBalance(t,e){let s="0.000";if(typeof t=="string"){const r=Number(t);if(r){const i=Math.floor(r*1e3)/1e3;i&&(s=i.toString())}}return`${s}${e?` ${e}`:""}`},formatBalance2(t,e){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return K.W3M_API_URL},getBlockchainApiUrl(){return K.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return K.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?Pe.ADAPTER_TYPES.UNIVERSAL:t.map(n=>n.adapterType).join(",");return`${e}-${i}-${s}`},createAccount(t,e,s,r,i){return{namespace:t,address:e,type:s,publicKey:r,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in K.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function Ai(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class pn{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await Ai(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Ai(n,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:s}){const r=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([i,n])=>{n&&r.searchParams.append(i,n)}),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}const Yp={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Pe.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(te.isTelegram()){if(te.isIos())return t.filter(e=>e!=="google");if(te.isMac())return t.filter(e=>e!=="x");if(te.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},Y=ke({features:Pe.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Pe.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),B={state:Y,subscribeKey(t,e){return ot(Y,t,e)},setOptions(t){Object.assign(Y,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...Y.remoteFeatures,...t};Y.remoteFeatures=e,(s=Y.remoteFeatures)!=null&&s.socials&&(Y.remoteFeatures.socials=Yp.filterSocialsByPlatform(Y.remoteFeatures.socials))},setFeatures(t){if(!t)return;Y.features||(Y.features=Pe.DEFAULT_FEATURES);const e={...Y.features,...t};Y.features=e},setProjectId(t){Y.projectId=t},setCustomRpcUrls(t){Y.customRpcUrls=t},setAllWallets(t){Y.allWallets=t},setIncludeWalletIds(t){Y.includeWalletIds=t},setExcludeWalletIds(t){Y.excludeWalletIds=t},setFeaturedWalletIds(t){Y.featuredWalletIds=t},setTokens(t){Y.tokens=t},setTermsConditionsUrl(t){Y.termsConditionsUrl=t},setPrivacyPolicyUrl(t){Y.privacyPolicyUrl=t},setCustomWallets(t){Y.customWallets=t},setIsSiweEnabled(t){Y.isSiweEnabled=t},setIsUniversalProvider(t){Y.isUniversalProvider=t},setSdkVersion(t){Y.sdkVersion=t},setMetadata(t){Y.metadata=t},setDisableAppend(t){Y.disableAppend=t},setEIP6963Enabled(t){Y.enableEIP6963=t},setDebug(t){Y.debug=t},setEnableWalletConnect(t){Y.enableWalletConnect=t},setEnableWalletGuide(t){Y.enableWalletGuide=t},setEnableAuthLogger(t){Y.enableAuthLogger=t},setEnableWallets(t){Y.enableWallets=t},setPreferUniversalLinks(t){Y.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){Y.hasMultipleAddresses=t},setSIWX(t){Y.siwx=t},setConnectMethodsOrder(t){Y.features={...Y.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){Y.features={...Y.features,walletFeaturesOrder:t}},setSocialsOrder(t){Y.remoteFeatures={...Y.remoteFeatures,socials:t}},setCollapseWallets(t){Y.features={...Y.features,collapseWallets:t}},setEnableEmbedded(t){Y.enableEmbedded=t},setAllowUnsupportedChain(t){Y.allowUnsupportedChain=t},setManualWCControl(t){Y.manualWCControl=t},setEnableNetworkSwitch(t){Y.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(Y.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){Y.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return Y.universalProviderConfigOverride},getSnapshot(){return Qi(Y)}},Zp=Object.freeze({enabled:!0,events:[]}),Xp=new pn({baseUrl:te.getAnalyticsUrl(),clientId:null}),Qp=5,ef=60*1e3,Is=ke({...Zp}),tf={state:Is,subscribeKey(t,e){return ot(Is,t,e)},async sendError(t,e){if(!Is.enabled)return;const s=Date.now();if(Is.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<ef}).length>=Qp)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Is.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=B.state;await Xp.post({path:"/e",params:{projectId:n,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:te.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){Is.enabled=!0},disable(){Is.enabled=!1},clearEvents(){Is.events=[]}};class ei extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,ei.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
3
3
|
`);if(o>-1){const a=n.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
4
4
|
${a}`,i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,ei):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Dc(t,e){const s=t instanceof ei?t:new ei(t instanceof Error?t.message:String(t),e,t);throw tf.sendError(s,s.category),s}function xt(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(r=>{const i=t[r];if(typeof i=="function"){let n=i;i.constructor.name==="AsyncFunction"?n=async(...o)=>{try{return await i(...o)}catch(a){return Dc(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return Dc(a,e)}},s[r]=n}else s[r]=i}),s}const ns={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},sf={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===ns.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${ns.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===ns.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${ns.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===K.CHAIN.SOLANA&&t===ns.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${ns.COINBASE.url}/dapp?cb_url=${r}`)}},Ct=ke({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),rf={state:Ct,subscribeNetworkImages(t){return nt(Ct.networkImages,()=>t(Ct.networkImages))},subscribeKey(t,e){return ot(Ct,t,e)},subscribe(t){return nt(Ct,()=>t(Ct))},setWalletImage(t,e){Ct.walletImages[t]=e},setNetworkImage(t,e){Ct.networkImages[t]=e},setChainImage(t,e){Ct.chainImages[t]=e},setConnectorImage(t,e){Ct.connectorImages={...Ct.connectorImages,[t]:e}},setTokenImage(t,e){Ct.tokenImages[t]=e},setCurrencyImage(t,e){Ct.currencyImages[t]=e}},Jt=xt(rf),nf={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},No=ke({networkImagePromises:{}}),dh={async fetchWalletImage(t){if(t)return await J._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(No.networkImagePromises[t]||(No.networkImagePromises[t]=J._fetchNetworkImage(t)),await No.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Jt.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return Jt.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,r;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((r=t==null?void 0:t.assets)!=null&&r.imageId)return Jt.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Jt.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Jt.state.connectorImages[t.imageId]},getChainImage(t){return Jt.state.networkImages[nf[t]]}},As=ke({message:"",variant:"info",open:!1}),of={state:As,subscribeKey(t,e){return ot(As,t,e)},open(t,e){const{debug:s}=B.state,{shortMessage:r,longMessage:i}=t;s&&(As.message=r,As.variant=e,As.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){As.open=!1,As.message="",As.variant="info"}},Gs=xt(of),af=te.getAnalyticsUrl(),cf=new pn({baseUrl:af,clientId:null}),lf=["MODAL_CREATED"],ls=ke({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Ue={state:ls,subscribe(t){return nt(ls,()=>t(ls))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=B.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=V.state.address;if(lf.includes(t.data.event)||typeof window>"u")return;await cf.post({path:"/e",params:Ue.getSdkProperties(),body:{eventId:te.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),ls.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===K.HTTP_STATUS_CODES.FORBIDDEN&&!ls.reportedErrors.FORBIDDEN&&(Gs.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${Ri()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),ls.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;ls.timestamp=Date.now(),ls.data=t,(e=B.state.features)!=null&&e.analytics&&Ue._sendAnalyticsEvent(ls)}},uf=te.getApiUrl(),dt=new pn({baseUrl:uf,clientId:null}),hf=40,Lc=4,df=20,ie=ke({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),J={state:ie,subscribeKey(t,e){return ot(ie,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=B.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return B.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${dt.baseUrl}/getWalletImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${dt.baseUrl}/public/getCurrencyImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${dt.baseUrl}/public/getTokenImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return te.isMobile()?t==null?void 0:t.filter(s=>s.mobile_link||s.id===ns.COINBASE.id?!0:b.state.activeChain==="solana"&&(s.id===ns.SOLFLARE.id||s.id===ns.PHANTOM.id)):t},async fetchProjectConfig(){return(await dt.get({path:"/appkit/v1/config",params:J._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await dt.get({path:"/projects/v1/origins",params:J._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=b.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!dh.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>J._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=H.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>J._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>J._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>J._fetchTokenImage(e)))},async fetchWallets(t){var n;const e=t.exclude??[];J._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(ns).map(o=>o.id));const r=await dt.get({path:"/getWallets",params:{...J._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(n=t.include)==null?void 0:n.join(","),exclude:e.join(",")}});return{data:J._filterWalletsByPlatform(r==null?void 0:r.data)||[],count:r==null?void 0:r.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=B.state;if(t!=null&&t.length){const e={...J._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Lc,include:t},{data:s}=await J.fetchWallets(e),r=[...s].sort((n,o)=>t.indexOf(n.id)-t.indexOf(o.id)),i=r.map(n=>n.image_id).filter(Boolean);await Promise.allSettled(i.map(n=>J._fetchWalletImage(n))),ie.featured=r,ie.allFeatured=r}},async fetchRecommendedWallets(){try{ie.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=B.state,r=[...e??[],...s??[]].filter(Boolean),i=b.getRequestedCaipNetworkIds().join(","),n={page:1,entries:Lc,include:t,exclude:r,chains:i},{data:o,count:a}=await J.fetchWallets(n),c=z.getRecentWallets(),l=o.map(h=>h.image_id).filter(Boolean),u=c.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(h=>J._fetchWalletImage(h))),ie.recommended=o,ie.allRecommended=o,ie.count=a??0}catch{}finally{ie.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=B.state,i=b.getRequestedCaipNetworkIds().join(","),n=[...ie.recommended.map(({id:u})=>u),...s??[],...r??[]].filter(Boolean),o={page:t,entries:hf,include:e,exclude:n,chains:i},{data:a,count:c}=await J.fetchWallets(o),l=a.slice(0,df).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>J._fetchWalletImage(u))),ie.wallets=te.uniqueBy([...ie.wallets,...J._filterOutExtensions(a)],"id").filter(u=>{var h;return(h=u.chains)==null?void 0:h.some(d=>i.includes(d))}),ie.count=c>ie.count?c:ie.count,ie.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await J.fetchWallets(e);s&&s.forEach(r=>{ie.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=B.state,i=b.getRequestedCaipNetworkIds().join(",");ie.search=[];const n={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:r,chains:i},{data:o}=await J.fetchWallets(n);Ue.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>J._fetchWalletImage(c)),te.wait(300)]),ie.search=J._filterOutExtensions(o)},initPromise(t,e){const s=ie.promises[t];return s||(ie.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&J.initPromise("connectorImages",J.fetchConnectorImages),e&&J.initPromise("featuredWallets",J.fetchFeaturedWallets),s&&J.initPromise("recommendedWallets",J.fetchRecommendedWallets),r&&J.initPromise("networkImages",J.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=B.state.features)!=null&&t.analytics&&J.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await dt.get({path:"/getAnalyticsConfig",params:J._getSdkProperties()});B.setFeatures({analytics:t})}catch{B.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){ie.featured=ie.allFeatured,ie.recommended=ie.allRecommended;return}const e=b.getRequestedCaipNetworkIds().join(",");ie.featured=ie.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.recommended=ie.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.filteredWallets=ie.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})},clearFilterByNamespaces(){ie.filteredWallets=[]},setFilterByNamespace(t){if(!t){ie.featured=ie.allFeatured,ie.recommended=ie.allRecommended;return}const e=b.getRequestedCaipNetworkIds().join(",");ie.featured=ie.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.recommended=ie.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.filteredWallets=ie.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})}},Ce=ke({view:"Connect",history:["Connect"],transactionStack:[]}),pf={state:Ce,subscribeKey(t,e){return ot(Ce,t,e)},pushTransactionStack(t){Ce.transactionStack.push(t)},popTransactionStack(t){const e=Ce.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:r,onCancel:i}=e;switch(t){case"success":s==null||s();break;case"error":r==null||r(),ne.goBack();break;case"cancel":i==null||i(),ne.goBack();break}},push(t,e){t!==Ce.view&&(Ce.view=t,Ce.history.push(t),Ce.data=e)},reset(t,e){Ce.view=t,Ce.history=[t],Ce.data=e},replace(t,e){Ce.history.at(-1)===t||(Ce.view=t,Ce.history[Ce.history.length-1]=t,Ce.data=e)},goBack(){var r;const t=b.state.activeCaipAddress,e=ne.state.view==="ConnectingFarcaster",s=!t&&e;if(Ce.history.length>1){Ce.history.pop();const[i]=Ce.history.slice(-1);i&&(t&&i==="Connect"?Ce.view="Account":Ce.view=i)}else Ge.close();(r=Ce.data)!=null&&r.wallet&&(Ce.data.wallet=void 0),setTimeout(()=>{var i,n,o;if(s){V.setFarcasterUrl(void 0,b.state.activeChain);const a=H.getAuthConnector();(i=a==null?void 0:a.provider)==null||i.reload();const c=Qi(B.state);(o=(n=a==null?void 0:a.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:c.metadata,sdkVersion:c.sdkVersion,projectId:c.projectId,sdkType:c.sdkType})}},100)},goBackToIndex(t){if(Ce.history.length>1){Ce.history=Ce.history.slice(0,t+1);const[e]=Ce.history.slice(-1);e&&(Ce.view=e)}},goBackOrCloseModal(){ne.state.history.length>1?ne.goBack():Ge.close()}},ne=xt(pf),us=ke({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),ma={state:us,subscribe(t){return nt(us,()=>t(us))},setThemeMode(t){us.themeMode=t;try{const e=H.getAuthConnector();if(e){const s=ma.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:ks(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){us.themeVariables={...us.themeVariables,...t};try{const e=H.getAuthConnector();if(e){const s=ma.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:ks(us.themeVariables,us.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Qi(us)}},Nt=xt(ma),ph={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},pe=ke({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...ph},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),ff={state:pe,subscribe(t){return nt(pe,()=>{t(pe)})},subscribeKey(t,e){return ot(pe,t,e)},initialize(t){t.forEach(e=>{const s=z.getConnectedConnectorId(e);s&&H.setConnectorId(s,e)})},setActiveConnector(t){t&&(pe.activeConnector=ar(t))},setConnectors(t){t.filter(i=>!pe.allConnectors.some(n=>n.id===i.id&&H.getConnectorName(n.name)===H.getConnectorName(i.name)&&n.chain===i.chain)).forEach(i=>{i.type!=="MULTI_CHAIN"&&pe.allConnectors.push(ar(i))});const s=H.getEnabledNamespaces(),r=H.getEnabledConnectors(s);pe.connectors=H.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(pe.filterByNamespaceMap).forEach(e=>{pe.filterByNamespaceMap[e]=!1}),t.forEach(e=>{pe.filterByNamespaceMap[e]=!0}),H.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){pe.filterByNamespaceMap[t]=e,H.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=H.getEnabledNamespaces(),e=H.getEnabledConnectors(t),s=H.areAllNamespacesEnabled();pe.connectors=H.mergeMultiChainConnectors(e),s?J.clearFilterByNamespaces():J.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(pe.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return pe.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(pe.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=H.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=(i==null?void 0:i.id)===K.CONNECTOR_ID.AUTH;r.length>1&&i?s.push({name:i.name,imageUrl:i.imageUrl,imageId:i.imageId,connectors:[...r],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(i==null?void 0:i.id)||""}):i&&s.push(i)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:r}=s,i=H.getConnectorName(r);if(!i)return;const n=e.get(i)||[];n.find(a=>a.chain===s.chain)||n.push(s),e.set(i,n)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(r=>r.chain===s.chain)||e.push(s)}),e},addConnector(t){var e,s,r;if(t.id===K.CONNECTOR_ID.AUTH){const i=t,n=Qi(B.state),o=Nt.getSnapshot().themeMode,a=Nt.getSnapshot().themeVariables;(s=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(r=i==null?void 0:i.provider)==null||r.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:ks(a,o)}),H.setConnectors([t])}else H.setConnectors([t])},getAuthConnector(t){var r;const e=t||b.state.activeChain,s=pe.connectors.find(i=>i.id===K.CONNECTOR_ID.AUTH);if(s)return(r=s==null?void 0:s.connectors)!=null&&r.length?s.connectors.find(n=>n.chain===e):s},getAnnouncedConnectorRdns(){return pe.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return pe.allConnectors.find(e=>e.id===t)},getConnector(t,e){return pe.allConnectors.filter(r=>r.chain===b.state.activeChain).find(r=>{var i;return r.explorerId===t||((i=r.info)==null?void 0:i.rdns)===e})},syncIfAuthConnector(t){var n,o;if(t.id!=="ID_AUTH")return;const e=t,s=Qi(B.state),r=Nt.getSnapshot().themeMode,i=Nt.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:ks(i,r)})},getConnectorsByNamespace(t){const e=pe.allConnectors.filter(s=>s.chain===t);return H.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=H.getConnector(t.id,t.rdns),s=b.state.activeChain;sf.handleMobileDeeplinkRedirect((e==null?void 0:e.explorerId)||t.id,s),e?ne.push("ConnectingExternal",{connector:e}):ne.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?H.getConnectorsByNamespace(t):H.mergeMultiChainConnectors(pe.allConnectors)},setFilterByNamespace(t){pe.filterByNamespace=t,pe.connectors=H.getConnectors(t),J.setFilterByNamespace(t)},setConnectorId(t,e){t&&(pe.activeConnectorIds={...pe.activeConnectorIds,[e]:t},z.setConnectedConnectorId(e,t))},removeConnectorId(t){pe.activeConnectorIds={...pe.activeConnectorIds,[t]:void 0},z.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return pe.activeConnectorIds[t]},isConnected(t){return t?!!pe.activeConnectorIds[t]:Object.values(pe.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){pe.activeConnectorIds={...ph}}},H=xt(ff),Fi={ACCOUNT_TYPES:{SMART_ACCOUNT:"smartAccount"}},Ks=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Me=ke({...Ks}),gf={state:Me,subscribeKey(t,e){return ot(Me,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=te.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){Me.message=Ks.message,Me.variant=Ks.variant,Me.svg=Ks.svg,Me.open=Ks.open,Me.autoClose=Ks.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=Ks.autoClose}){Me.open?(Me.open=!1,setTimeout(()=>{Me.message=t,Me.variant=s,Me.svg=e,Me.open=!0,Me.autoClose=r},150)):(Me.message=t,Me.variant=s,Me.svg=e,Me.open=!0,Me.autoClose=r)}},Yt=gf,Oe=ke({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),mf={state:Oe,subscribe(t){return nt(Oe,()=>t(Oe))},setLastNetworkInView(t){Oe.lastNetworkInView=t},async fetchTransactions(t,e){var s,r;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Oe.loading=!0;try{const i=await Q.fetchTransactions({account:t,cursor:Oe.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId}),n=Di.filterSpamTransactions(i.data),o=Di.filterByConnectedChain(n),a=[...Oe.transactions,...o];Oe.loading=!1,e==="coinbase"?Oe.coinbaseTransactions=Di.groupTransactionsByYearAndMonth(Oe.coinbaseTransactions,i.data):(Oe.transactions=a,Oe.transactionsByYear=Di.groupTransactionsByYearAndMonth(Oe.transactionsByYear,o)),Oe.empty=a.length===0,Oe.next=i.next?i.next:void 0}catch{const n=b.state.activeChain;Ue.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:B.state.projectId,cursor:Oe.next,isSmartAccount:((r=V.state.preferredAccountTypes)==null?void 0:r[n])===Fi.ACCOUNT_TYPES.SMART_ACCOUNT}}),Yt.showError("Failed to fetch transactions"),Oe.loading=!1,Oe.empty=!0,Oe.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(r=>{const i=new Date(r.metadata.minedAt).getFullYear(),n=new Date(r.metadata.minedAt).getMonth(),o=s[i]??{},c=(o[n]??[]).filter(l=>l.id!==r.id);s[i]={...o,[n]:[...c,r].sort((l,u)=>new Date(u.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){Oe.next=void 0},resetTransactions(){Oe.transactions=[],Oe.transactionsByYear={},Oe.lastNetworkInView=void 0,Oe.loading=!1,Oe.empty=!1,Oe.next=void 0}},Di=xt(mf,"API_ERROR"),Ae=ke({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Ws;const wf={state:Ae,subscribeKey(t,e){return ot(Ae,t,e)},_getClient(){return Ae._client},setClient(t){Ae._client=ar(t)},async connectWalletConnect(){var t,e,s,r;if(te.isTelegram()||te.isSafari()&&te.isIos()){if(Ws){await Ws,Ws=void 0;return}if(!te.isPairingExpired(Ae==null?void 0:Ae.wcPairingExpiry)){const i=Ae.wcUri;Ae.wcUri=i;return}Ws=(e=(t=ee._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),ee.state.status="connecting",await Ws,Ws=void 0,Ae.wcPairingExpiry=void 0,ee.state.status="connected"}else await((r=(s=ee._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:r.call(s))},async connectExternal(t,e,s=!0){var r,i;await((i=(r=ee._getClient())==null?void 0:r.connectExternal)==null?void 0:i.call(r,t)),s&&b.setActiveNamespace(e)},async reconnectExternal(t){var s,r;await((r=(s=ee._getClient())==null?void 0:s.reconnectExternal)==null?void 0:r.call(s,t));const e=t.chain||b.state.activeChain;e&&H.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var r;Ge.setLoading(!0,b.state.activeChain);const s=H.getAuthConnector();s&&(V.setPreferredAccountType(t,e),await s.provider.setPreferredAccount(t),z.setPreferredAccountTypes(V.state.preferredAccountTypes??{[e]:t}),await ee.reconnectExternal(s),Ge.setLoading(!1,b.state.activeChain),Ue.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=ee._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=ee._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=ee._getClient())==null?void 0:s.formatUnits(t,e)},async sendTransaction(t){var e;return(e=ee._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=ee._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=ee._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=ee._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=ee._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=ee._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=ee._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=ee._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=ee._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){Ae.wcUri=void 0,Ae.wcPairingExpiry=void 0,Ae.wcLinking=void 0,Ae.recentWallet=void 0,Ae.status="disconnected",Di.resetTransactions(),z.deleteWalletConnectDeepLink()},resetUri(){Ae.wcUri=void 0,Ae.wcPairingExpiry=void 0,Ws=void 0},finalizeWcConnection(){var s,r;const{wcLinking:t,recentWallet:e}=ee.state;t&&z.setWalletConnectDeepLink(t),e&&z.setAppKitRecent(e),Ue.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((r=(s=ne.state.data)==null?void 0:s.wallet)==null?void 0:r.name)||"Unknown"}})},setWcBasic(t){Ae.wcBasic=t},setUri(t){Ae.wcUri=t,Ae.wcPairingExpiry=te.getPairingExpiry()},setWcLinking(t){Ae.wcLinking=t},setWcError(t){Ae.wcError=t,Ae.buffering=!1},setRecentWallet(t){Ae.recentWallet=t},setBuffering(t){Ae.buffering=t},setStatus(t){Ae.status=t},async disconnect(t){var e;try{await((e=ee._getClient())==null?void 0:e.disconnect(t))}catch(s){throw new ei("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){Ae.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(H.state.activeConnectorIds[s]===t.connectorId){const n=b.state.activeCaipNetwork;if(n){const o=`${s}:${n.id}:${e}`;V.setCaipAddress(o,s)}else console.warn(`No current network found for namespace "${s}"`)}else{const n=H.getConnector(t.connectorId);n?ee.connectExternal(n,s):console.warn(`No connector found for namespace "${s}"`)}}},ee=xt(wf),vr=ke({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Rs={state:vr,subscribe(t){return nt(vr,()=>t(vr))},subscribeOpen(t){return ot(vr,"open",t)},set(t){Object.assign(vr,{...vr,...t})}},_o={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return _p(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],r=parseInt(s,10);return isNaN(r)?"0x0":`0x${r.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}},Bc={async getMyTokensWithBalance(t){const e=V.state.address,s=b.state.activeCaipNetwork;if(!e||!s)return[];if(s.chainNamespace==="eip155"){const i=await this.getEIP155Balances(e,s);if(i)return this.filterLowQualityTokens(i)}const r=await Q.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(r.balances)},async getEIP155Balances(t,e){var s,r;try{const i=_o.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await ee.getCapabilities(t);if(!((r=(s=n==null?void 0:n[i])==null?void 0:s.assetDiscovery)!=null&&r.supported))return null;const o=await ee.walletGetAssets({account:t,chainFilter:[i]});return _o.isWalletGetAssetsResponse(o)?(o[i]||[]).map(c=>_o.createBalance(c,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:b.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},ve=ke({tokenBalances:[],loading:!1}),yf={state:ve,subscribe(t){return nt(ve,()=>t(ve))},subscribeKey(t,e){return ot(ve,t,e)},setToken(t){t&&(ve.token=ar(t))},setTokenAmount(t){ve.sendTokenAmount=t},setReceiverAddress(t){ve.receiverAddress=t},setReceiverProfileImageUrl(t){ve.receiverProfileImageUrl=t},setReceiverProfileName(t){ve.receiverProfileName=t},setNetworkBalanceInUsd(t){ve.networkBalanceInUSD=t},setLoading(t){ve.loading=t},async sendToken(){var t;try{switch(ye.setLoading(!0),(t=b.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await ye.sendEvmToken();return;case"solana":await ye.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}finally{ye.setLoading(!1)}},async sendEvmToken(){var s,r,i,n;const t=b.state.activeChain,e=(s=V.state.preferredAccountTypes)==null?void 0:s[t];if(!ye.state.sendTokenAmount||!ye.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!ye.state.token)throw new Error("A token is required");(r=ye.state.token)!=null&&r.address?(Ue.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Fi.ACCOUNT_TYPES.SMART_ACCOUNT,token:ye.state.token.address,amount:ye.state.sendTokenAmount,network:((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),await ye.sendERC20Token({receiverAddress:ye.state.receiverAddress,tokenAddress:ye.state.token.address,sendTokenAmount:ye.state.sendTokenAmount,decimals:ye.state.token.quantity.decimals})):(Ue.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Fi.ACCOUNT_TYPES.SMART_ACCOUNT,token:ye.state.token.symbol||"",amount:ye.state.sendTokenAmount,network:((n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}),await ye.sendNativeToken({receiverAddress:ye.state.receiverAddress,sendTokenAmount:ye.state.sendTokenAmount,decimals:ye.state.token.quantity.decimals}))},async fetchTokenBalance(t){var n,o;ve.loading=!0;const e=(n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=b.state.activeCaipAddress,i=r?te.getPlainAddress(r):void 0;if(ve.lastRetry&&!te.isAllowedRetry(ve.lastRetry,30*Pe.ONE_SEC_MS))return ve.loading=!1,[];try{if(i&&e&&s){const a=await Bc.getMyTokensWithBalance();return ve.tokenBalances=a,ve.lastRetry=void 0,a}}catch(a){ve.lastRetry=Date.now(),t==null||t(a),Yt.showError("Token Balance Unavailable")}finally{ve.loading=!1}return[]},fetchNetworkBalance(){if(ve.tokenBalances.length===0)return;const t=Bc.mapBalancesToSwapTokens(ve.tokenBalances);if(!t)return;const e=t.find(s=>s.address===b.getActiveNetworkTokenAddress());e&&(ve.networkBalanceInUSD=e?Bp.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var n,o,a,c;ne.pushTransactionStack({});const e=t.receiverAddress,s=V.state.address,r=ee.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));await ee.sendTransaction({chainNamespace:"eip155",to:e,address:s,data:"0x",value:r??BigInt(0)}),Ue.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:((n=V.state.preferredAccountTypes)==null?void 0:n.eip155)===Fi.ACCOUNT_TYPES.SMART_ACCOUNT,token:((o=ye.state.token)==null?void 0:o.symbol)||"",amount:t.sendTokenAmount,network:((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||""}}),(c=ee._getClient())==null||c.updateBalance("eip155"),ye.resetSend()},async sendERC20Token(t){ne.pushTransactionStack({onSuccess(){ne.replace("Account")}});const e=ee.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));if(V.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const s=te.getPlainAddress(t.tokenAddress);await ee.writeContract({fromAddress:V.state.address,tokenAddress:s,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:Fp.getERC20Abi(s),chainNamespace:"eip155"}),ye.resetSend()}},async sendSolanaToken(){var t;if(!ye.state.sendTokenAmount||!ye.state.receiverAddress)throw new Error("An amount and receiver address are required");ne.pushTransactionStack({onSuccess(){ne.replace("Account")}}),await ee.sendTransaction({chainNamespace:"solana",to:ye.state.receiverAddress,value:ye.state.sendTokenAmount}),(t=ee._getClient())==null||t.updateBalance("solana"),ye.resetSend()},resetSend(){ve.token=void 0,ve.sendTokenAmount=void 0,ve.receiverAddress=void 0,ve.receiverProfileImageUrl=void 0,ve.receiverProfileName=void 0,ve.loading=!1,ve.tokenBalances=[]}},ye=xt(yf),So={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},Nn={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},W=ke({chains:Gp(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),bf={state:W,subscribe(t){return nt(W,()=>{t(W)})},subscribeKey(t,e){return ot(W,t,e)},subscribeChainProp(t,e,s){let r;return nt(W.chains,()=>{var n;const i=s||W.activeChain;if(i){const o=(n=W.chains.get(i))==null?void 0:n[t];r!==o&&(r=o,e(o))}})},initialize(t,e,s){const{chainId:r,namespace:i}=z.getActiveNetworkProps(),n=e==null?void 0:e.find(u=>u.id.toString()===(r==null?void 0:r.toString())),a=t.find(u=>(u==null?void 0:u.namespace)===i)||(t==null?void 0:t[0]),c=t.map(u=>u.namespace).filter(u=>u!==void 0),l=B.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(u=>u.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(W.noAdapters=!0),W.noAdapters||(W.activeChain=a==null?void 0:a.namespace,W.activeCaipNetwork=n,b.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),W.activeChain&&Rs.set({activeChain:a==null?void 0:a.namespace})),l.forEach(u=>{const h=e==null?void 0:e.filter(d=>d.chainNamespace===u);b.state.chains.set(u,{namespace:u,networkState:ke({...Nn,caipNetwork:h==null?void 0:h[0]}),accountState:ke(So),caipNetworks:h??[],...s}),b.setRequestedCaipNetworks(h??[],u)})},removeAdapter(t){var e,s;if(W.activeChain===t){const r=Array.from(W.chains.entries()).find(([i])=>i!==t);if(r){const i=(s=(e=r[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];i&&b.setActiveCaipNetwork(i)}}W.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){W.chains.set(t.namespace,{namespace:t.namespace,networkState:{...Nn,caipNetwork:r[0]},accountState:So,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),b.setRequestedCaipNetworks((r==null?void 0:r.filter(i=>i.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=W.chains.get(t.chainNamespace);if(e){const r=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(i=>i.id===t.id)||r.push(t),W.chains.set(t.chainNamespace,{...e,caipNetworks:r}),b.setRequestedCaipNetworks(r,t.chainNamespace),H.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var r,i,n;const s=W.chains.get(t);if(s){const o=((r=W.activeCaipNetwork)==null?void 0:r.id)===e,a=[...((i=s.caipNetworks)==null?void 0:i.filter(c=>c.id!==e))||[]];o&&((n=s==null?void 0:s.caipNetworks)!=null&&n[0])&&b.setActiveCaipNetwork(s.caipNetworks[0]),W.chains.set(t,{...s,caipNetworks:a}),b.setRequestedCaipNetworks(a||[],t),a.length===0&&H.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=W.chains.get(t);s&&(s.networkState={...s.networkState||Nn,...e},W.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const r=W.chains.get(t);if(r){const i={...r.accountState||So,...e};W.chains.set(t,{...r,accountState:i}),(W.chains.size===1||W.activeChain===t)&&(e.caipAddress&&(W.activeCaipAddress=e.caipAddress),V.replaceState(i))}},setChainNetworkData(t,e){if(!t)return;const s=W.chains.get(t);if(s){const r={...s.networkState||Nn,...e};W.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){b.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&H.removeConnectorId(s)},setActiveNamespace(t){var r,i;W.activeChain=t;const e=t?W.chains.get(t):void 0,s=(r=e==null?void 0:e.networkState)==null?void 0:r.caipNetwork;s!=null&&s.id&&t&&(W.activeCaipAddress=(i=e==null?void 0:e.accountState)==null?void 0:i.caipAddress,W.activeCaipNetwork=s,b.setChainNetworkData(t,{caipNetwork:s}),z.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),Rs.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var r,i,n;if(!t)return;W.activeChain!==t.chainNamespace&&b.setIsSwitchingNamespace(!0);const e=W.chains.get(t.chainNamespace);W.activeChain=t.chainNamespace,W.activeCaipNetwork=t,b.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),(r=e==null?void 0:e.accountState)!=null&&r.address?W.activeCaipAddress=`${t.chainNamespace}:${t.id}:${(i=e==null?void 0:e.accountState)==null?void 0:i.address}`:W.activeCaipAddress=void 0,b.setAccountProp("caipAddress",W.activeCaipAddress,t.chainNamespace),e&&V.replaceState(e.accountState),ye.resetSend(),Rs.set({activeChain:W.activeChain,selectedNetworkId:(n=W.activeCaipNetwork)==null?void 0:n.caipNetworkId}),z.setActiveCaipNetworkId(t.caipNetworkId),!b.checkIfSupportedNetwork(t.chainNamespace)&&B.state.enableNetworkSwitch&&!B.state.allowUnsupportedChain&&!ee.state.wcBasic&&b.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=W.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var i;if(!t)return;const e=t!==b.state.activeChain,s=(i=b.getNetworkData(t))==null?void 0:i.caipNetwork,r=b.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&r&&await b.switchActiveNetwork(r)},async switchActiveNetwork(t){var i;const e=b.state.chains.get(b.state.activeChain),s=!((i=e==null?void 0:e.caipNetworks)!=null&&i.some(n=>{var o;return n.id===((o=W.activeCaipNetwork)==null?void 0:o.id)})),r=b.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&Ge.close()}catch{ne.goBack()}Ue.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})}},getNetworkControllerClient(t){const e=t||W.activeChain,s=W.chains.get(e);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(t){const e=t||W.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=W.chains.get(e);if(!(s!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(t,e){var i;let s=W.activeChain;if(e&&(s=e),!s)return;const r=(i=W.chains.get(s))==null?void 0:i.accountState;if(r)return r[t]},getNetworkProp(t,e){var r;const s=(r=W.chains.get(e))==null?void 0:r.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=W.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:r=[]}=(e==null?void 0:e.networkState)||{};return te.sortRequestedNetworks(s,r)},getAllRequestedCaipNetworks(){const t=[];return W.chains.forEach(e=>{const s=b.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){b.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=b.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));H.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return W.chains.forEach(e=>{const s=b.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(){return W.activeCaipNetwork},getActiveCaipAddress(){return W.activeCaipAddress},getApprovedCaipNetworkIds(t){var r;const e=W.chains.get(t);return((r=e==null?void 0:e.networkState)==null?void 0:r.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(t){const e=b.getNetworkControllerClient(),s=await(e==null?void 0:e.getApprovedCaipNetworksData());b.setAdapterNetworkState(t,{approvedCaipNetworkIds:s==null?void 0:s.approvedCaipNetworkIds,supportsAllNetworks:s==null?void 0:s.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||W.activeCaipNetwork,r=b.getRequestedCaipNetworks(t);return r.length?r==null?void 0:r.some(i=>i.id===(s==null?void 0:s.id)):!0},checkIfSupportedChainId(t){if(!W.activeChain)return!0;const e=b.getRequestedCaipNetworks(W.activeChain);return e==null?void 0:e.some(s=>s.id===t)},setSmartAccountEnabledNetworks(t,e){b.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){var r;const t=ch.caipNetworkIdToNumber((r=W.activeCaipNetwork)==null?void 0:r.caipNetworkId),e=W.activeChain;if(!e||!t)return!1;const s=b.getNetworkProp("smartAccountEnabledNetworks",e);return!!(s!=null&&s.includes(Number(t)))},getActiveNetworkTokenAddress(){var r,i;const t=((r=W.activeCaipNetwork)==null?void 0:r.chainNamespace)||"eip155",e=((i=W.activeCaipNetwork)==null?void 0:i.id)||1,s=Pe.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){Ge.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=W.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Pe.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){b.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(t){const e=t;if(!e)throw new Error("Chain is required to set account prop");W.activeCaipAddress=void 0,b.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountTypes:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),H.removeConnectorId(e)},setIsSwitchingNamespace(t){W.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,r;const t=[];let e;if(W.chains.forEach(i=>{K.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===i.namespace)&&i.namespace&&t.push(i.namespace)}),t.length>0){const i=t[0];return e=i?(r=(s=W.chains.get(i))==null?void 0:s.caipNetworks)==null?void 0:r[0]:void 0,e}},getAccountData(t){var e;return t?(e=b.state.chains.get(t))==null?void 0:e.accountState:V.state},getNetworkData(t){var s;const e=t||W.activeChain;if(e)return(s=b.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var i,n,o;if(!t)return;const s=b.state.chains.get(t),r=(i=s==null?void 0:s.caipNetworks)==null?void 0:i.find(a=>a.id===e);return r||((n=s==null?void 0:s.networkState)==null?void 0:n.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=H.state.filterByNamespace;return(t?[W.chains.get(t)]:Array.from(W.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?b.getRequestedCaipNetworks(t):b.getAllRequestedCaipNetworks()}},b=xt(bf),vf={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},fh=te.getBlockchainApiUrl(),pt=ke({clientId:null,api:new pn({baseUrl:fh,clientId:null}),supportedChains:{http:[],ws:[]}}),Q={state:pt,async get(t){const{st:e,sv:s}=Q.getSdkProperties(),r=B.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return pt.api.get({...t,params:i})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=B.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{pt.supportedChains.http.length||await Q.getSupportedNetworks()}catch{return!1}return pt.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await Q.get({path:"v1/supported-chains"});return pt.supportedChains=t,t}catch{return pt.supportedChains}},async fetchIdentity({address:t,caipNetworkId:e}){if(!await Q.isNetworkSupported(e))return{avatar:"",name:""};const r=z.getIdentityFromCacheForAddress(t);if(r)return r;const i=await Q.get({path:`/v1/identity/${t}`,params:{sender:b.state.activeCaipAddress?te.getPlainAddress(b.state.activeCaipAddress):void 0}});return z.updateIdentityCache({address:t,identity:i,timestamp:Date.now()}),i},async fetchTransactions({account:t,cursor:e,onramp:s,signal:r,cache:i,chainId:n}){var a;return await Q.isNetworkSupported((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?Q.get({path:`/v1/account/${t}/history`,params:{cursor:e,onramp:s,chainId:n},signal:r,cache:i}):{data:[],next:void 0}},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:r,gasPrice:i}){var o;return await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?Q.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:r,gasPrice:i}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?pt.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:B.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var r;return await Q.isNetworkSupported((r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?Q.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var i;const{st:e,sv:s}=Q.getSdkProperties();if(!await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId))throw new Error("Network not supported for Gas Price");return Q.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:r,disableEstimate:i}){var o;if(!await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return pt.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Pe.CONVERT_SLIPPAGE_TOLERANCE},projectId:B.state.projectId,from:e,to:s,userAddress:r,disableEstimate:i}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:r,sv:i}=Q.getSdkProperties();if(!await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return Q.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:r,sv:i}})},async getBalance(t,e,s){var l;const{st:r,sv:i}=Q.getSdkProperties();if(!await Q.isNetworkSupported((l=b.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return Yt.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=z.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await Q.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:r,sv:i}});return z.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/reverse/${t}`,params:{sender:V.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:r}){var n;return await Q.isNetworkSupported((n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?pt.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:r},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:r,paymentAmount:i}){var a;return await Q.isNetworkSupported((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await pt.api.post({path:"/v1/generators/onrampurl",params:{projectId:B.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:i}})).url:""},async getOnrampOptions(){var e;if(!await Q.isNetworkSupported((e=b.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await Q.get({path:"/v1/onramp/options"})}catch{return vf}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){var i;try{return await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?await pt.api.post({path:"/v1/onramp/quote",params:{projectId:B.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}}):null}catch{return{coinbaseFee:{amount:s,currency:e.id},networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var i;return await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?pt.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:B.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){pt.clientId=t,pt.api=new pn({baseUrl:fh,clientId:t})}},Rt=ke({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),Ef={state:Rt,replaceState(t){t&&Object.assign(Rt,ar(t))},subscribe(t){return b.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return b.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){b.setAccountProp("status",t,e)},getCaipAddress(t){return b.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?te.getPlainAddress(t):void 0;e===b.state.activeChain&&(b.state.activeCaipAddress=t),b.setAccountProp("caipAddress",t,e),b.setAccountProp("address",s,e)},setBalance(t,e,s){b.setAccountProp("balance",t,s),b.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){b.setAccountProp("profileName",t,e)},setProfileImage(t,e){b.setAccountProp("profileImage",t,e)},setUser(t,e){b.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){b.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){b.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){b.setAccountProp("currentTab",t,b.state.activeChain)},setTokenBalance(t,e){t&&b.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){b.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){b.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=b.getAccountProp("addressLabels",s)||new Map;r.set(t,e),b.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=b.getAccountProp("addressLabels",e)||new Map;s.delete(t),b.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){b.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){b.setAccountProp("preferredAccountTypes",{...Rt.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){Rt.preferredAccountTypes=t},setSocialProvider(t,e){t&&b.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){b.setAccountProp("socialWindow",t?ar(t):void 0,e)},setFarcasterUrl(t,e){b.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){var n,o;Rt.balanceLoading=!0;const e=(n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=b.state.activeCaipAddress,i=r?te.getPlainAddress(r):void 0;if(Rt.lastRetry&&!te.isAllowedRetry(Rt.lastRetry,30*Pe.ONE_SEC_MS))return Rt.balanceLoading=!1,[];try{if(i&&e&&s){const c=(await Q.getBalance(i,e)).balances.filter(l=>l.quantity.decimals!=="0");return V.setTokenBalance(c,s),Rt.lastRetry=void 0,Rt.balanceLoading=!1,c}}catch(a){Rt.lastRetry=Date.now(),t==null||t(a),Yt.showError("Token Balance Unavailable")}finally{Rt.balanceLoading=!1}return[]},resetAccount(t){b.resetAccount(t)}},V=xt(Ef),Cf={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=b.state.activeCaipNetwork,r=ne.state.data;if(t.id===(s==null?void 0:s.id))return;const n=V.getCaipAddress(b.state.activeChain),o=t.chainNamespace!==b.state.activeChain,a=V.getCaipAddress(t.chainNamespace),l=H.getConnectorId(b.state.activeChain)===K.CONNECTOR_ID.AUTH,u=K.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(h=>h===t.chainNamespace);e||l&&u?ne.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?ne.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ne.push("SwitchNetwork",{...r,network:t})}},ft=ke({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),If={state:ft,subscribe(t){return nt(ft,()=>t(ft))},subscribeKey(t,e){return ot(ft,t,e)},async open(t){var o,a;const e=V.state.status==="connected",s=t==null?void 0:t.namespace,r=b.state.activeChain,i=s&&s!==r,n=(o=b.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress;if(ee.state.wcBasic?J.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await J.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),H.setFilterByNamespace(t==null?void 0:t.namespace),Ge.setLoading(!0,s),s&&i){const c=((a=b.getNetworkData(s))==null?void 0:a.caipNetwork)||b.getRequestedCaipNetworks(s)[0];c&&Cf.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0})}else{const c=b.state.noAdapters;B.state.manualWCControl||c&&!n?te.isMobile()?ne.reset("AllWallets"):ne.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?ne.reset(t.view,t.data):n?ne.reset("Account"):ne.reset("Connect")}ft.open=!0,Rs.set({open:!0}),Ue.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=B.state.enableEmbedded,e=!!b.state.activeCaipAddress;ft.open&&Ue.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),ft.open=!1,ne.reset("Connect"),Ge.clearLoading(),t?e?ne.replace("Account"):ne.push("Connect"):Rs.set({open:!1}),ee.resetUri()},setLoading(t,e){e&&ft.loadingNamespaceMap.set(e,t),ft.loading=t,Rs.set({loading:t})},clearLoading(){ft.loadingNamespaceMap.clear(),ft.loading=!1},shake(){ft.shake||(ft.shake=!0,setTimeout(()=>{ft.shake=!1},500))}},Ge=xt(If),Wi={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},wa={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},Af={providers:hh,selectedProvider:null,error:null,purchaseCurrency:Wi,paymentCurrency:wa,purchaseCurrencies:[Wi],paymentCurrencies:[],quotesLoading:!1},de=ke(Af),Nf={state:de,subscribe(t){return nt(de,()=>t(de))},subscribeKey(t,e){return ot(de,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=b.state.activeChain===K.CHAIN.SOLANA?"SOL":"USDC",s=V.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",Jp),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",B.state.projectId),de.selectedProvider={...t,url:r.toString()}}else de.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=hh.filter(r=>e.includes(r.name));de.providers=s}else de.providers=[]},setPurchaseCurrency(t){de.purchaseCurrency=t},setPaymentCurrency(t){de.paymentCurrency=t},setPurchaseAmount(t){ya.state.purchaseAmount=t},setPaymentAmount(t){ya.state.paymentAmount=t},async getAvailableCurrencies(){const t=await Q.getOnrampOptions();de.purchaseCurrencies=t.purchaseCurrencies,de.paymentCurrencies=t.paymentCurrencies,de.paymentCurrency=t.paymentCurrencies[0]||wa,de.purchaseCurrency=t.purchaseCurrencies[0]||Wi,await J.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await J.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;de.quotesLoading=!0;try{const s=await Q.getOnrampQuote({purchaseCurrency:de.purchaseCurrency,paymentCurrency:de.paymentCurrency,amount:((t=de.paymentAmount)==null?void 0:t.toString())||"0",network:(e=de.purchaseCurrency)==null?void 0:e.symbol});return de.quotesLoading=!1,de.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return de.error=s.message,de.quotesLoading=!1,null}finally{de.quotesLoading=!1}},resetState(){de.selectedProvider=null,de.error=null,de.purchaseCurrency=Wi,de.paymentCurrency=wa,de.purchaseCurrencies=[Wi],de.paymentCurrencies=[],de.paymentAmount=void 0,de.purchaseAmount=void 0,de.quotesLoading=!1}},ya=xt(Nf),Mc=2147483648,_f={convertEVMChainIdToCoinType(t){if(t>=Mc)throw new Error("Invalid chainId");return(Mc|t)>>>0}},Ut=ke({suggestions:[],loading:!1}),Sf={state:Ut,subscribe(t){return nt(Ut,()=>t(Ut))},subscribeKey(t,e){return ot(Ut,t,e)},async resolveName(t){var e,s;try{return await Q.lookupEnsName(t)}catch(r){const i=r;throw new Error(((s=(e=i==null?void 0:i.reasons)==null?void 0:e[0])==null?void 0:s.description)||"Error resolving name")}},async isNameRegistered(t){try{return await Q.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{Ut.loading=!0,Ut.suggestions=[];const e=await Q.getEnsNameSuggestions(t);return Ut.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],Ut.suggestions}catch(e){const s=Hi.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Ut.loading=!1}},async getNamesForAddress(t){try{if(!b.state.activeCaipNetwork)return[];const s=z.getEnsFromCacheForAddress(t);if(s)return s;const r=await Q.reverseLookupEnsName({address:t});return z.updateEnsCache({address:t,ens:r,timestamp:Date.now()}),r}catch(e){const s=Hi.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=b.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const s=V.state.address,r=H.getAuthConnector();if(!s||!r)throw new Error("Address or auth connector not found");Ut.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});ne.pushTransactionStack({onCancel(){ne.replace("RegisterAccountName")}});const n=await ee.signMessage(i);Ut.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=_f.convertEVMChainIdToCoinType(Number(o));await Q.registerEnsName({coinType:a,address:s,signature:n,message:i}),V.setProfileName(t,e.chainNamespace),ne.replace("RegisterAccountNameSuccess")}catch(i){const n=Hi.parseEnsApiError(i,`Error registering name ${t}`);throw ne.replace("RegisterAccountName"),new Error(n)}finally{Ut.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){var r,i;const s=t;return((i=(r=s==null?void 0:s.reasons)==null?void 0:r[0])==null?void 0:i.description)||e}},Hi=xt(Sf);var Pf=Object.defineProperty,Of=(t,e,s)=>e in t?Pf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,qc=(t,e,s)=>Of(t,typeof e!="symbol"?e+"":e,s);let Tf=class extends mi{constructor(e){super(),this.opts=e,qc(this,"protocol","wc"),qc(this,"version",2)}};var $f=Object.defineProperty,kf=(t,e,s)=>e in t?$f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xf=(t,e,s)=>kf(t,e+"",s);let Rf=class extends mi{constructor(e,s){super(),this.core=e,this.logger=s,xf(this,"records",new Map)}},Uf=class{constructor(e,s){this.logger=e,this.core=s}},Df=class extends mi{constructor(e,s){super(),this.relayer=e,this.logger=s}},Lf=class extends mi{constructor(e){super()}},Bf=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},Mf=class extends mi{constructor(e,s){super(),this.relayer=e,this.logger=s}},qf=class extends mi{constructor(e,s){super(),this.core=e,this.logger=s}},jf=class{constructor(e,s,r){this.core=e,this.logger=s,this.store=r}},Ff=class{constructor(e,s){this.projectId=e,this.logger=s}},Wf=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var Hf=Object.defineProperty,zf=(t,e,s)=>e in t?Hf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jc=(t,e,s)=>zf(t,typeof e!="symbol"?e+"":e,s);let Vf=class{constructor(e){this.opts=e,jc(this,"protocol","wc"),jc(this,"version",2)}},Kf=class{constructor(e){this.client=e}};var Gf={};const Jf="ReactNative",Zt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Yf="js";function Yn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function wr(){return!Tt.getDocument()&&!!Tt.getNavigator()&&navigator.product===Jf}function Zf(){return wr()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Xf(){return wr()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function fn(){return!Yn()&&!!Tt.getNavigator()&&!!Tt.getDocument()}function oo(){return wr()?Zt.reactNative:Yn()?Zt.node:fn()?Zt.browser:Zt.unknown}function Fc(){var t;try{return wr()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Qf(t,e){const s=new URLSearchParams(t);for(const r of Object.keys(e).sort())if(e.hasOwnProperty(r)){const i=e[r];i!==void 0&&s.set(r,i)}return s.toString()}function eg(){return ih.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function tg(){if(oo()===Zt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:r}=global.Platform;return[s,r].join("-")}const t=pp();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function sg(){var t;const e=oo();return e===Zt.browser?[e,((t=Tt.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function gh(t,e,s){const r=tg(),i=sg();return[[t,e].join("-"),[Yf,s].join("-"),r,i].join("/")}function rg({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=gh(t,e,r),h={auth:i,ua:u,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=Qf(l[1]||"",h);return l[0]+"?"+d}function ba(t){return Object.fromEntries(t.entries())}function va(t){return new Map(Object.entries(t))}function ig(t=q.FIVE_MINUTES,e){const s=q.toMiliseconds(t||q.FIVE_MINUTES);let r,i,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&i&&(clearTimeout(n),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),r=a,i=c})}}function xs(t,e,s){return new Promise(async(r,i)=>{const n=setTimeout(()=>i(new Error(s)),e);try{const o=await t;r(o)}catch(o){i(o)}clearTimeout(n)})}function mh(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function ng(t){return mh("topic",t)}function og(t){return mh("id",t)}function ag(t){const[e,s]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")r.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))r.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return r}function zi(t,e){return q.fromMiliseconds(Date.now()+q.toMiliseconds(t))}function Wc(t){return Date.now()>=q.toMiliseconds(t)}function Po(t,e){return`${t}${e?`:${e}`:""}`}function Hc(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function wh(){return typeof process<"u"&&Gf.IS_VITEST==="true"}function yh(t){return Buffer.from(t,"base64").toString("utf-8")}function cg(t){return new Promise(e=>setTimeout(e,t))}function en(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function lg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function gn(t,...e){if(!lg(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ac(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");en(t.outputLen),en(t.blockLen)}function ti(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bh(t,e){gn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const _n=BigInt(2**32-1),zc=BigInt(32);function ug(t,e=!1){return e?{h:Number(t&_n),l:Number(t>>zc&_n)}:{h:Number(t>>zc&_n)|0,l:Number(t&_n)|0}}function hg(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=ug(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const dg=(t,e,s)=>t<<s|e>>>32-s,pg=(t,e,s)=>e<<s|t>>>32-s,fg=(t,e,s)=>e<<s-32|t>>>64-s,gg=(t,e,s)=>t<<s-32|e>>>64-s,Er=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function mg(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Oo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Qt(t,e){return t<<32-e|t>>>e}const Vc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Kc(t){for(let e=0;e<t.length;e++)t[e]=wg(t[e])}function yg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function si(t){return typeof t=="string"&&(t=yg(t)),gn(t),t}function bg(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];gn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let cc=class{clone(){return this._cloneInto()}};function vh(t){const e=r=>t().update(si(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function yi(t=32){if(Er&&typeof Er.getRandomValues=="function")return Er.getRandomValues(new Uint8Array(t));if(Er&&typeof Er.randomBytes=="function")return Er.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Eh=[],Ch=[],Ih=[],vg=BigInt(0),Ni=BigInt(1),Eg=BigInt(2),Cg=BigInt(7),Ig=BigInt(256),Ag=BigInt(113);for(let t=0,e=Ni,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Eh.push(2*(5*r+s)),Ch.push((t+1)*(t+2)/2%64);let i=vg;for(let n=0;n<7;n++)e=(e<<Ni^(e>>Cg)*Ag)%Ig,e&Eg&&(i^=Ni<<(Ni<<BigInt(n))-Ni);Ih.push(i)}const[Ng,_g]=hg(Ih,!0),Gc=(t,e,s)=>s>32?fg(t,e,s):dg(t,e,s),Jc=(t,e,s)=>s>32?gg(t,e,s):pg(t,e,s);function Sg(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=Gc(l,u,1)^s[a],d=Jc(l,u,1)^s[a+1];for(let g=0;g<50;g+=10)t[o+g]^=h,t[o+g+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Ch[o],c=Gc(i,n,a),l=Jc(i,n,a),u=Eh[o];i=t[u],n=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=Ng[r],t[1]^=_g[r]}s.fill(0)}let Pg=class Ah extends cc{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,en(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=mg(this.state)}keccak(){Vc||Kc(this.state32),Sg(this.state32,this.rounds),Vc||Kc(this.state32),this.posOut=0,this.pos=0}update(e){ti(this);const{blockLen:s,state:r}=this;e=si(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,(s&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ti(this,!1),gn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return en(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(bh(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new Ah(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Og=(t,e,s)=>vh(()=>new Pg(e,t,s));Og(1,136,256/8);function To(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Nh(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pt(t,...e){if(!Nh(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Yc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Tg(t,e){Pt(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Zc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Us=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),$g=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),kg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!kg)throw new Error("Non little-endian hardware is not supported");function xg(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ea(t){if(typeof t=="string")t=xg(t);else if(Nh(t))t=Ca(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Rg(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Ug(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}const Dg=(t,e)=>{function s(r,...i){if(Pt(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?Pt(l):Pt(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&Pt(i[1]);const o=e(r,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");Pt(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Pt(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(Pt(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(s,t),s};function Xc(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!Lg(e))throw new Error("invalid output, must be aligned");return e}function Qc(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n);t.setUint32(e+4,o,r),t.setUint32(e+0,a,r)}function Lg(t){return t.byteOffset%4===0}function Ca(t){return Uint8Array.from(t)}function ri(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const _h=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Bg=_h("expand 16-byte k"),Mg=_h("expand 32-byte k"),qg=Us(Bg),jg=Us(Mg);function fe(t,e){return t<<e|t>>>32-e}function Ia(t){return t.byteOffset%4===0}const Sn=64,Fg=16,Sh=2**32-1,el=new Uint32Array;function Wg(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(Sn),u=Us(l),h=Ia(i)&&Ia(n),d=h?Us(i):el,g=h?Us(n):el;for(let y=0;y<c;o++){if(t(e,s,r,u,o,a),o>=Sh)throw new Error("arx: counter overflow");const f=Math.min(Sn,c-y);if(h&&f===Sn){const p=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let m=0,w;m<Fg;m++)w=p+m,g[w]=d[w]^u[m];y+=Sn;continue}for(let p=0,m;p<f;p++)m=y+p,n[m]=i[m]^l[p];y+=f}}function Hg(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=Rg({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return To(i),To(o),Zc(n),Zc(s),(a,c,l,u,h=0)=>{Pt(a),Pt(c),Pt(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),Pt(u),To(h),h<0||h>=Sh)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const g=[];let y=a.length,f,p;if(y===32)g.push(f=Ca(a)),p=jg;else if(y===16&&s)f=new Uint8Array(32),f.set(a),f.set(a,16),p=qg,g.push(f);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);Ia(c)||g.push(c=Ca(c));const m=Us(f);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,Us(c.subarray(0,16)),m),c=c.subarray(16)}const w=16-i;if(w!==c.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const O=new Uint8Array(12);O.set(c,n?0:12-c.length),c=O,g.push(c)}const C=Us(c);return Wg(t,p,m,C,l,u,h,o),ri(...g),u}}const Xe=(t,e)=>t[e++]&255|(t[e++]&255)<<8;let zg=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Ea(e),Pt(e,32);const s=Xe(e,0),r=Xe(e,2),i=Xe(e,4),n=Xe(e,6),o=Xe(e,8),a=Xe(e,10),c=Xe(e,12),l=Xe(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Xe(e,16+2*u)}process(e,s,r=!1){const i=r?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],g=o[6],y=o[7],f=o[8],p=o[9],m=Xe(e,s+0),w=Xe(e,s+2),C=Xe(e,s+4),O=Xe(e,s+6),$=Xe(e,s+8),S=Xe(e,s+10),N=Xe(e,s+12),T=Xe(e,s+14);let v=n[0]+(m&8191),k=n[1]+((m>>>13|w<<3)&8191),P=n[2]+((w>>>10|C<<6)&8191),R=n[3]+((C>>>7|O<<9)&8191),L=n[4]+((O>>>4|$<<12)&8191),E=n[5]+($>>>1&8191),A=n[6]+(($>>>14|S<<2)&8191),I=n[7]+((S>>>11|N<<5)&8191),x=n[8]+((N>>>8|T<<8)&8191),U=n[9]+(T>>>5|i),_=0,M=_+v*a+k*(5*p)+P*(5*f)+R*(5*y)+L*(5*g);_=M>>>13,M&=8191,M+=E*(5*d)+A*(5*h)+I*(5*u)+x*(5*l)+U*(5*c),_+=M>>>13,M&=8191;let j=_+v*c+k*a+P*(5*p)+R*(5*f)+L*(5*y);_=j>>>13,j&=8191,j+=E*(5*g)+A*(5*d)+I*(5*h)+x*(5*u)+U*(5*l),_+=j>>>13,j&=8191;let F=_+v*l+k*c+P*a+R*(5*p)+L*(5*f);_=F>>>13,F&=8191,F+=E*(5*y)+A*(5*g)+I*(5*d)+x*(5*h)+U*(5*u),_+=F>>>13,F&=8191;let X=_+v*u+k*l+P*c+R*a+L*(5*p);_=X>>>13,X&=8191,X+=E*(5*f)+A*(5*y)+I*(5*g)+x*(5*d)+U*(5*h),_+=X>>>13,X&=8191;let G=_+v*h+k*u+P*l+R*c+L*a;_=G>>>13,G&=8191,G+=E*(5*p)+A*(5*f)+I*(5*y)+x*(5*g)+U*(5*d),_+=G>>>13,G&=8191;let oe=_+v*d+k*h+P*u+R*l+L*c;_=oe>>>13,oe&=8191,oe+=E*a+A*(5*p)+I*(5*f)+x*(5*y)+U*(5*g),_+=oe>>>13,oe&=8191;let le=_+v*g+k*d+P*h+R*u+L*l;_=le>>>13,le&=8191,le+=E*c+A*a+I*(5*p)+x*(5*f)+U*(5*y),_+=le>>>13,le&=8191;let Ie=_+v*y+k*g+P*d+R*h+L*u;_=Ie>>>13,Ie&=8191,Ie+=E*l+A*c+I*a+x*(5*p)+U*(5*f),_+=Ie>>>13,Ie&=8191;let ue=_+v*f+k*y+P*g+R*d+L*h;_=ue>>>13,ue&=8191,ue+=E*u+A*l+I*c+x*a+U*(5*p),_+=ue>>>13,ue&=8191;let he=_+v*p+k*f+P*y+R*g+L*d;_=he>>>13,he&=8191,he+=E*h+A*u+I*l+x*c+U*a,_+=he>>>13,he&=8191,_=(_<<2)+_|0,_=_+M|0,M=_&8191,_=_>>>13,j+=_,n[0]=M,n[1]=j,n[2]=F,n[3]=X,n[4]=G,n[5]=oe,n[6]=le,n[7]=Ie,n[8]=ue,n[9]=he}finalize(){const{h:e,pad:s}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let n=(i^1)-1;for(let a=0;a<10;a++)r[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|r[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;ri(r)}update(e){Yc(this);const{buffer:s,blockLen:r}=this;e=Ea(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){ri(this.h,this.r,this.buffer,this.pad)}digestInto(e){Yc(this),Tg(e,this),this.finished=!0;const{buffer:s,h:r}=this;let{pos:i}=this;if(i){for(s[i++]=1;i<16;i++)s[i]=0;this.process(s,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}};function Vg(t){const e=(r,i)=>t(i).update(Ea(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const Kg=Vg(t=>new zg(t));function Gg(t,e,s,r,i,n=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],g=e[3],y=e[4],f=e[5],p=e[6],m=e[7],w=i,C=s[0],O=s[1],$=s[2],S=o,N=a,T=c,v=l,k=u,P=h,R=d,L=g,E=y,A=f,I=p,x=m,U=w,_=C,M=O,j=$;for(let X=0;X<n;X+=2)S=S+k|0,U=fe(U^S,16),E=E+U|0,k=fe(k^E,12),S=S+k|0,U=fe(U^S,8),E=E+U|0,k=fe(k^E,7),N=N+P|0,_=fe(_^N,16),A=A+_|0,P=fe(P^A,12),N=N+P|0,_=fe(_^N,8),A=A+_|0,P=fe(P^A,7),T=T+R|0,M=fe(M^T,16),I=I+M|0,R=fe(R^I,12),T=T+R|0,M=fe(M^T,8),I=I+M|0,R=fe(R^I,7),v=v+L|0,j=fe(j^v,16),x=x+j|0,L=fe(L^x,12),v=v+L|0,j=fe(j^v,8),x=x+j|0,L=fe(L^x,7),S=S+P|0,j=fe(j^S,16),I=I+j|0,P=fe(P^I,12),S=S+P|0,j=fe(j^S,8),I=I+j|0,P=fe(P^I,7),N=N+R|0,U=fe(U^N,16),x=x+U|0,R=fe(R^x,12),N=N+R|0,U=fe(U^N,8),x=x+U|0,R=fe(R^x,7),T=T+L|0,_=fe(_^T,16),E=E+_|0,L=fe(L^E,12),T=T+L|0,_=fe(_^T,8),E=E+_|0,L=fe(L^E,7),v=v+k|0,M=fe(M^v,16),A=A+M|0,k=fe(k^A,12),v=v+k|0,M=fe(M^v,8),A=A+M|0,k=fe(k^A,7);let F=0;r[F++]=o+S|0,r[F++]=a+N|0,r[F++]=c+T|0,r[F++]=l+v|0,r[F++]=u+k|0,r[F++]=h+P|0,r[F++]=d+R|0,r[F++]=g+L|0,r[F++]=y+E|0,r[F++]=f+A|0,r[F++]=p+I|0,r[F++]=m+x|0,r[F++]=w+U|0,r[F++]=C+_|0,r[F++]=O+M|0,r[F++]=$+j|0}const Jg=Hg(Gg,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Yg=new Uint8Array(16),tl=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(Yg.subarray(s))},Zg=new Uint8Array(32);function sl(t,e,s,r,i){const n=t(e,s,Zg),o=Kg.create(n);i&&tl(o,i),tl(o,r);const a=new Uint8Array(16),c=$g(a);Qc(c,0,BigInt(i?i.length:0),!0),Qc(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return ri(n,a),l}const Xg=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=Xc(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=sl(t,e,s,a,r);return n.set(c,o),ri(c),n},decrypt(i,n){n=Xc(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=sl(t,e,s,o,r);if(!Ug(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),ri(c),n}}),Ph=Dg({blockSize:64,nonceLength:12,tagLength:16},Xg(Jg));let Oh=class extends cc{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,ac(e);const r=si(s);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return ti(this),this.iHash.update(e),this}digestInto(e){ti(this),gn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const ao=(t,e,s)=>new Oh(t,e).update(s).digest();ao.create=(t,e)=>new Oh(t,e);function Qg(t,e,s){return ac(t),s===void 0&&(s=new Uint8Array(t.outputLen)),ao(t,si(s),si(e))}const $o=new Uint8Array([0]),rl=new Uint8Array;function em(t,e,s,r=32){if(ac(t),en(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);s===void 0&&(s=rl);const n=new Uint8Array(i*t.outputLen),o=ao.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)$o[0]=l+1,a.update(l===0?rl:c).update(s).update($o).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),$o.fill(0),n.slice(0,r)}const tm=(t,e,s,r,i)=>em(t,Qg(t,e,s),r,i);function sm(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function rm(t,e,s){return t&e^~t&s}function im(t,e,s){return t&e^t&s^e&s}let nm=class extends cc{constructor(e,s,r,i){super(),this.blockLen=e,this.outputLen=s,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Oo(this.buffer)}update(e){ti(this);const{view:s,buffer:r,blockLen:i}=this;e=si(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(i-this.pos,n-o);if(a===i){const c=Oo(e);for(;i<=n-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ti(this),bh(e,this),this.finished=!0;const{buffer:s,view:r,blockLen:i,isLE:n}=this;let{pos:o}=this;s[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let h=o;h<i;h++)s[h]=0;sm(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=Oo(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],n)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=n,e.destroyed=o,i%s&&e.buffer.set(r),e}};const om=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ns=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_s=new Uint32Array(64);let am=class extends nm{constructor(){super(64,32,8,!1),this.A=Ns[0]|0,this.B=Ns[1]|0,this.C=Ns[2]|0,this.D=Ns[3]|0,this.E=Ns[4]|0,this.F=Ns[5]|0,this.G=Ns[6]|0,this.H=Ns[7]|0}get(){const{A:e,B:s,C:r,D:i,E:n,F:o,G:a,H:c}=this;return[e,s,r,i,n,o,a,c]}set(e,s,r,i,n,o,a,c){this.A=e|0,this.B=s|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let h=0;h<16;h++,s+=4)_s[h]=e.getUint32(s,!1);for(let h=16;h<64;h++){const d=_s[h-15],g=_s[h-2],y=Qt(d,7)^Qt(d,18)^d>>>3,f=Qt(g,17)^Qt(g,19)^g>>>10;_s[h]=f+_s[h-7]+y+_s[h-16]|0}let{A:r,B:i,C:n,D:o,E:a,F:c,G:l,H:u}=this;for(let h=0;h<64;h++){const d=Qt(a,6)^Qt(a,11)^Qt(a,25),g=u+d+rm(a,c,l)+om[h]+_s[h]|0,y=(Qt(r,2)^Qt(r,13)^Qt(r,22))+im(r,i,n)|0;u=l,l=c,c=a,a=o+g|0,o=n,n=i,i=r,r=g+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,n,o,a,c,l,u)}roundClean(){_s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const mn=vh(()=>new am);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const co=BigInt(0),lo=BigInt(1),cm=BigInt(2);function cr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function wn(t){if(!cr(t))throw new Error("Uint8Array expected")}function ii(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const lm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ni(t){wn(t);let e="";for(let s=0;s<t.length;s++)e+=lm[t[s]];return e}function Vr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function lc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?co:BigInt("0x"+t)}const hs={_0:48,_9:57,A:65,F:70,a:97,f:102};function il(t){if(t>=hs._0&&t<=hs._9)return t-hs._0;if(t>=hs.A&&t<=hs.F)return t-(hs.A-10);if(t>=hs.a&&t<=hs.f)return t-(hs.a-10)}function oi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(s);for(let i=0,n=0;i<s;i++,n+=2){const o=il(t.charCodeAt(n)),a=il(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[i]=o*16+a}return r}function sr(t){return lc(ni(t))}function tn(t){return wn(t),lc(ni(Uint8Array.from(t).reverse()))}function ai(t,e){return oi(t.toString(16).padStart(e*2,"0"))}function uo(t,e){return ai(t,e).reverse()}function um(t){return oi(Vr(t))}function _t(t,e,s){let r;if(typeof e=="string")try{r=oi(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(cr(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return r}function sn(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];wn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}function hm(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}function dm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const ko=t=>typeof t=="bigint"&&co<=t;function ho(t,e,s){return ko(t)&&ko(e)&&ko(s)&&e<=t&&t<s}function bs(t,e,s,r){if(!ho(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function Th(t){let e;for(e=0;t>co;t>>=lo,e+=1);return e}function pm(t,e){return t>>BigInt(e)&lo}function fm(t,e,s){return t|(s?lo:co)<<BigInt(e)}const uc=t=>(cm<<BigInt(t-1))-lo,xo=t=>new Uint8Array(t),nl=t=>Uint8Array.from(t);function $h(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");let r=xo(t),i=xo(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=xo())=>{i=a(nl([0]),u),r=a(),u.length!==0&&(i=a(nl([1]),u),r=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u<e;){r=a();const d=r.slice();h.push(d),u+=r.length}return sn(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const gm={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||cr(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function bi(t,e,s={}){const r=(i,n,o)=>{const a=gm[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+n+", got "+c)};for(const[i,n]of Object.entries(e))r(i,n,!1);for(const[i,n]of Object.entries(s))r(i,n,!0);return t}const mm=()=>{throw new Error("not implemented")};function Aa(t){const e=new WeakMap;return(s,...r)=>{const i=e.get(s);if(i!==void 0)return i;const n=t(s,...r);return e.set(s,n),n}}var wm=Object.freeze({__proto__:null,isBytes:cr,abytes:wn,abool:ii,bytesToHex:ni,numberToHexUnpadded:Vr,hexToNumber:lc,hexToBytes:oi,bytesToNumberBE:sr,bytesToNumberLE:tn,numberToBytesBE:ai,numberToBytesLE:uo,numberToVarBytesBE:um,ensureBytes:_t,concatBytes:sn,equalBytes:hm,utf8ToBytes:dm,inRange:ho,aInRange:bs,bitLen:Th,bitGet:pm,bitSet:fm,bitMask:uc,createHmacDrbg:$h,validateObject:bi,notImplemented:mm,memoized:Aa});const Je=BigInt(0),De=BigInt(1),Js=BigInt(2),ym=BigInt(3),Na=BigInt(4),ol=BigInt(5),al=BigInt(8);function yt(t,e){const s=t%e;return s>=Je?s:e+s}function kh(t,e,s){if(e<Je)throw new Error("invalid exponent, negatives unsupported");if(s<=Je)throw new Error("invalid modulus");if(s===De)return Je;let r=De;for(;e>Je;)e&De&&(r=r*t%s),t=t*t%s,e>>=De;return r}function Kt(t,e,s){let r=t;for(;e-- >Je;)r*=r,r%=s;return r}function _a(t,e){if(t===Je)throw new Error("invert: expected non-zero number");if(e<=Je)throw new Error("invert: expected positive modulus, got "+e);let s=yt(t,e),r=e,i=Je,n=De;for(;s!==Je;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==De)throw new Error("invert: does not exist");return yt(i,e)}function bm(t){const e=(t-De)/Js;let s,r,i;for(s=t-De,r=0;s%Js===Je;s/=Js,r++);for(i=Js;i<t&&kh(i,e,t)!==t-De;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+De)/Na;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const n=(s+De)/Js;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,l=o.pow(o.mul(o.ONE,i),s),u=o.pow(a,n),h=o.pow(a,s);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let y=o.sqr(h);d<c&&!o.eql(y,o.ONE);d++)y=o.sqr(y);const g=o.pow(l,De<<BigInt(c-d-1));l=o.sqr(g),u=o.mul(u,g),h=o.mul(h,l),c=d}return u}}function vm(t){if(t%Na===ym){const e=(t+De)/Na;return function(s,r){const i=s.pow(r,e);if(!s.eql(s.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%al===ol){const e=(t-ol)/al;return function(s,r){const i=s.mul(r,Js),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Js),n),c=s.mul(o,s.sub(a,s.ONE));if(!s.eql(s.sqr(c),r))throw new Error("Cannot find square root");return c}}return bm(t)}const Em=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cm(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=Em.reduce((r,i)=>(r[i]="function",r),e);return bi(t,s)}function Im(t,e,s){if(s<Je)throw new Error("invalid exponent, negatives unsupported");if(s===Je)return t.ONE;if(s===De)return e;let r=t.ONE,i=e;for(;s>Je;)s&De&&(r=t.mul(r,i)),i=t.sqr(i),s>>=De;return r}function Am(t,e){const s=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(s[a]=n,t.mul(n,o)),t.ONE),i=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(s[a]=t.mul(n,s[a]),t.mul(n,o)),i),s}function xh(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function Rh(t,e,s=!1,r={}){if(t<=Je)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=xh(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:n,MASK:uc(i),ZERO:Je,ONE:De,create:c=>yt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Je<=c&&c<t},is0:c=>c===Je,isOdd:c=>(c&De)===De,neg:c=>yt(-c,t),eql:(c,l)=>c===l,sqr:c=>yt(c*c,t),add:(c,l)=>yt(c+l,t),sub:(c,l)=>yt(c-l,t),mul:(c,l)=>yt(c*l,t),pow:(c,l)=>Im(a,c,l),div:(c,l)=>yt(c*_a(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>_a(c,t),sqrt:r.sqrt||(c=>(o||(o=vm(t)),o(a,c))),invertBatch:c=>Am(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?uo(c,n):ai(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?tn(c):sr(c)}});return Object.freeze(a)}function Uh(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Dh(t){const e=Uh(t);return e+Math.ceil(e/2)}function Nm(t,e,s=!1){const r=t.length,i=Uh(e),n=Dh(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?tn(t):sr(t),a=yt(o,e-De)+De;return s?uo(a,i):ai(a,i)}const cl=BigInt(0),Pn=BigInt(1);function Ro(t,e){const s=e.negate();return t?s:e}function Lh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Uo(t,e){Lh(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function _m(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,r)=>{if(!(s instanceof e))throw new Error("invalid point at index "+r)})}function Sm(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,r)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+r)})}const Do=new WeakMap,Bh=new WeakMap;function Lo(t){return Bh.get(t)||1}function Pm(t,e){return{constTimeNegate:Ro,hasPrecomputes(s){return Lo(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>cl;)r&Pn&&(i=i.add(n)),n=n.double(),r>>=Pn;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=Uo(r,e),o=[];let a=s,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<n;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,r,i){const{windows:n,windowSize:o}=Uo(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),u=2**s,h=BigInt(s);for(let d=0;d<n;d++){const g=d*o;let y=Number(i&l);i>>=h,y>o&&(y-=u,i+=Pn);const f=g,p=g+Math.abs(y)-1,m=d%2!==0,w=y<0;y===0?c=c.add(Ro(m,r[f])):a=a.add(Ro(w,r[p]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=Uo(s,e),c=BigInt(2**s-1),l=2**s,u=BigInt(s);for(let h=0;h<o;h++){const d=h*a;if(i===cl)break;let g=Number(i&c);if(i>>=u,g>a&&(g-=l,i+=Pn),g===0)continue;let y=r[d+Math.abs(g)-1];g<0&&(y=y.negate()),n=n.add(y)}return n},getPrecomputes(s,r,i){let n=Do.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&Do.set(r,i(n))),n},wNAFCached(s,r,i){const n=Lo(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=Lo(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){Lh(r,e),Bh.set(s,r),Do.delete(s)}}}function Om(t,e,s,r){if(_m(s,t),Sm(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=Th(BigInt(s.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let g=0;g<r.length;g++){const y=r[g],f=Number(y>>BigInt(h)&BigInt(a));c[f]=c[f].add(s[g])}let d=i;for(let g=c.length-1,y=i;g>0;g--)y=y.add(c[g]),d=d.add(y);if(u=u.add(d),h!==0)for(let g=0;g<o;g++)u=u.double()}return u}function Mh(t){return Cm(t.Fp),bi(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Cr=BigInt(0),Bo=BigInt(1);function Tm(t){return bi(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function $m(t){const e=Tm(t),{P:s}=e,r=w=>yt(w,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>kh(w,s-BigInt(2),s));function l(w,C,O){const $=r(w*(C-O));return C=r(C-$),O=r(O+$),[C,O]}const u=(e.a-BigInt(2))/BigInt(4);function h(w,C){bs("u",w,Cr,s),bs("scalar",C,Cr,s);const O=C,$=w;let S=Bo,N=Cr,T=w,v=Bo,k=Cr,P;for(let L=BigInt(i-1);L>=Cr;L--){const E=O>>L&Bo;k^=E,P=l(k,S,T),S=P[0],T=P[1],P=l(k,N,v),N=P[0],v=P[1],k=E;const A=S+N,I=r(A*A),x=S-N,U=r(x*x),_=I-U,M=T+v,j=T-v,F=r(j*A),X=r(M*x),G=F+X,oe=F-X;T=r(G*G),v=r($*r(oe*oe)),S=r(I*U),N=r(_*(I+r(u*_)))}P=l(k,S,T),S=P[0],T=P[1],P=l(k,N,v),N=P[0],v=P[1];const R=c(N);return r(S*R)}function d(w){return uo(r(w),n)}function g(w){const C=_t("u coordinate",w,n);return o===32&&(C[31]&=127),tn(C)}function y(w){const C=_t("scalar",w),O=C.length;if(O!==n&&O!==o){let $=""+n+" or "+o;throw new Error("invalid scalar, expected "+$+" bytes, got "+O)}return tn(a(C))}function f(w,C){const O=g(C),$=y(w),S=h(O,$);if(S===Cr)throw new Error("invalid private or public key received");return d(S)}const p=d(e.Gu);function m(w){return f(w,p)}return{scalarMult:f,scalarMultBase:m,getSharedSecret:(w,C)=>f(w,C),getPublicKey:w=>m(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:p}}const Sa=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const km=BigInt(1),ll=BigInt(2),xm=BigInt(3),Rm=BigInt(5);BigInt(8);function Um(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=Sa,o=t*t%n*t%n,a=Kt(o,ll,n)*o%n,c=Kt(a,km,n)*t%n,l=Kt(c,Rm,n)*c%n,u=Kt(l,e,n)*l%n,h=Kt(u,s,n)*u%n,d=Kt(h,r,n)*h%n,g=Kt(d,i,n)*d%n,y=Kt(g,i,n)*d%n,f=Kt(y,e,n)*l%n;return{pow_p_5_8:Kt(f,ll,n)*t%n,b2:o}}function Dm(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Pa=$m({P:Sa,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Sa,{pow_p_5_8:s,b2:r}=Um(t);return yt(Kt(s,xm,e)*r,e)},adjustScalarBytes:Dm,randomBytes:yi});function ul(t){t.lowS!==void 0&&ii("lowS",t.lowS),t.prehash!==void 0&&ii("prehash",t.prehash)}function Lm(t){const e=Mh(t);bi(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:s,Fp:r,a:i}=e;if(s){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof s!="object"||typeof s.beta!="bigint"||typeof s.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Bm,hexToBytes:Mm}=wm;let qm=class extends Error{constructor(e=""){super(e)}};const gs={Err:qm,_tlv:{encode:(t,e)=>{const{Err:s}=gs;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const r=e.length/2,i=Vr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Vr(i.length/2|128):"";return Vr(t)+n+i+e},decode(t,e){const{Err:s}=gs;let r=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new s("tlv.decode: wrong tlv");const i=e[r++],n=!!(i&128);let o=0;if(!n)o=i;else{const c=i&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(r+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=gs;if(t<ws)throw new e("integer: negative integers are not allowed");let s=Vr(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=gs;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Bm(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=gs,i=typeof t=="string"?Mm(t):t;wn(i);const{v:n,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=gs,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},ws=BigInt(0),We=BigInt(1);BigInt(2);const hl=BigInt(3);BigInt(4);function jm(t){const e=Lm(t),{Fp:s}=e,r=Rh(e.n,e.nBitLength),i=e.toBytes||((f,p,m)=>{const w=p.toAffine();return sn(Uint8Array.from([4]),s.toBytes(w.x),s.toBytes(w.y))}),n=e.fromBytes||(f=>{const p=f.subarray(1),m=s.fromBytes(p.subarray(0,s.BYTES)),w=s.fromBytes(p.subarray(s.BYTES,2*s.BYTES));return{x:m,y:w}});function o(f){const{a:p,b:m}=e,w=s.sqr(f),C=s.mul(w,f);return s.add(s.add(C,s.mul(f,p)),m)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(f){return ho(f,We,e.n)}function c(f){const{allowedPrivateKeyLengths:p,nByteLength:m,wrapPrivateKey:w,n:C}=e;if(p&&typeof f!="bigint"){if(cr(f)&&(f=ni(f)),typeof f!="string"||!p.includes(f.length))throw new Error("invalid private key");f=f.padStart(m*2,"0")}let O;try{O=typeof f=="bigint"?f:sr(_t("private key",f,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof f)}return w&&(O=yt(O,C)),bs("private key",O,We,C),O}function l(f){if(!(f instanceof d))throw new Error("ProjectivePoint expected")}const u=Aa((f,p)=>{const{px:m,py:w,pz:C}=f;if(s.eql(C,s.ONE))return{x:m,y:w};const O=f.is0();p==null&&(p=O?s.ONE:s.inv(C));const $=s.mul(m,p),S=s.mul(w,p),N=s.mul(C,p);if(O)return{x:s.ZERO,y:s.ZERO};if(!s.eql(N,s.ONE))throw new Error("invZ was invalid");return{x:$,y:S}}),h=Aa(f=>{if(f.is0()){if(e.allowInfinityPoint&&!s.is0(f.py))return;throw new Error("bad point: ZERO")}const{x:p,y:m}=f.toAffine();if(!s.isValid(p)||!s.isValid(m))throw new Error("bad point: x or y not FE");const w=s.sqr(m),C=o(p);if(!s.eql(w,C))throw new Error("bad point: equation left != right");if(!f.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(p,m,w){if(this.px=p,this.py=m,this.pz=w,p==null||!s.isValid(p))throw new Error("x required");if(m==null||!s.isValid(m))throw new Error("y required");if(w==null||!s.isValid(w))throw new Error("z required");Object.freeze(this)}static fromAffine(p){const{x:m,y:w}=p||{};if(!p||!s.isValid(m)||!s.isValid(w))throw new Error("invalid affine point");if(p instanceof d)throw new Error("projective point not allowed");const C=O=>s.eql(O,s.ZERO);return C(m)&&C(w)?d.ZERO:new d(m,w,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const m=s.invertBatch(p.map(w=>w.pz));return p.map((w,C)=>w.toAffine(m[C])).map(d.fromAffine)}static fromHex(p){const m=d.fromAffine(n(_t("pointHex",p)));return m.assertValidity(),m}static fromPrivateKey(p){return d.BASE.multiply(c(p))}static msm(p,m){return Om(d,r,p,m)}_setWindowSize(p){y.setWindowSize(this,p)}assertValidity(){h(this)}hasEvenY(){const{y:p}=this.toAffine();if(s.isOdd)return!s.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){l(p);const{px:m,py:w,pz:C}=this,{px:O,py:$,pz:S}=p,N=s.eql(s.mul(m,S),s.mul(O,C)),T=s.eql(s.mul(w,S),s.mul($,C));return N&&T}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:p,b:m}=e,w=s.mul(m,hl),{px:C,py:O,pz:$}=this;let S=s.ZERO,N=s.ZERO,T=s.ZERO,v=s.mul(C,C),k=s.mul(O,O),P=s.mul($,$),R=s.mul(C,O);return R=s.add(R,R),T=s.mul(C,$),T=s.add(T,T),S=s.mul(p,T),N=s.mul(w,P),N=s.add(S,N),S=s.sub(k,N),N=s.add(k,N),N=s.mul(S,N),S=s.mul(R,S),T=s.mul(w,T),P=s.mul(p,P),R=s.sub(v,P),R=s.mul(p,R),R=s.add(R,T),T=s.add(v,v),v=s.add(T,v),v=s.add(v,P),v=s.mul(v,R),N=s.add(N,v),P=s.mul(O,$),P=s.add(P,P),v=s.mul(P,R),S=s.sub(S,v),T=s.mul(P,k),T=s.add(T,T),T=s.add(T,T),new d(S,N,T)}add(p){l(p);const{px:m,py:w,pz:C}=this,{px:O,py:$,pz:S}=p;let N=s.ZERO,T=s.ZERO,v=s.ZERO;const k=e.a,P=s.mul(e.b,hl);let R=s.mul(m,O),L=s.mul(w,$),E=s.mul(C,S),A=s.add(m,w),I=s.add(O,$);A=s.mul(A,I),I=s.add(R,L),A=s.sub(A,I),I=s.add(m,C);let x=s.add(O,S);return I=s.mul(I,x),x=s.add(R,E),I=s.sub(I,x),x=s.add(w,C),N=s.add($,S),x=s.mul(x,N),N=s.add(L,E),x=s.sub(x,N),v=s.mul(k,I),N=s.mul(P,E),v=s.add(N,v),N=s.sub(L,v),v=s.add(L,v),T=s.mul(N,v),L=s.add(R,R),L=s.add(L,R),E=s.mul(k,E),I=s.mul(P,I),L=s.add(L,E),E=s.sub(R,E),E=s.mul(k,E),I=s.add(I,E),R=s.mul(L,I),T=s.add(T,R),R=s.mul(x,I),N=s.mul(A,N),N=s.sub(N,R),R=s.mul(A,L),v=s.mul(x,v),v=s.add(v,R),new d(N,T,v)}subtract(p){return this.add(p.negate())}is0(){return this.equals(d.ZERO)}wNAF(p){return y.wNAFCached(this,p,d.normalizeZ)}multiplyUnsafe(p){const{endo:m,n:w}=e;bs("scalar",p,ws,w);const C=d.ZERO;if(p===ws)return C;if(this.is0()||p===We)return this;if(!m||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,p,d.normalizeZ);let{k1neg:O,k1:$,k2neg:S,k2:N}=m.splitScalar(p),T=C,v=C,k=this;for(;$>ws||N>ws;)$&We&&(T=T.add(k)),N&We&&(v=v.add(k)),k=k.double(),$>>=We,N>>=We;return O&&(T=T.negate()),S&&(v=v.negate()),v=new d(s.mul(v.px,m.beta),v.py,v.pz),T.add(v)}multiply(p){const{endo:m,n:w}=e;bs("scalar",p,We,w);let C,O;if(m){const{k1neg:$,k1:S,k2neg:N,k2:T}=m.splitScalar(p);let{p:v,f:k}=this.wNAF(S),{p:P,f:R}=this.wNAF(T);v=y.constTimeNegate($,v),P=y.constTimeNegate(N,P),P=new d(s.mul(P.px,m.beta),P.py,P.pz),C=v.add(P),O=k.add(R)}else{const{p:$,f:S}=this.wNAF(p);C=$,O=S}return d.normalizeZ([C,O])[0]}multiplyAndAddUnsafe(p,m,w){const C=d.BASE,O=(S,N)=>N===ws||N===We||!S.equals(C)?S.multiplyUnsafe(N):S.multiply(N),$=O(this,m).add(O(p,w));return $.is0()?void 0:$}toAffine(p){return u(this,p)}isTorsionFree(){const{h:p,isTorsionFree:m}=e;if(p===We)return!0;if(m)return m(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:m}=e;return p===We?this:m?m(d,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return ii("isCompressed",p),this.assertValidity(),i(d,this,p)}toHex(p=!0){return ii("isCompressed",p),ni(this.toRawBytes(p))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const g=e.nBitLength,y=Pm(d,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Fm(t){const e=Mh(t);return bi(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Wm(t){const e=Fm(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(E){return yt(E,r)}function a(E){return _a(E,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=jm({...e,toBytes(E,A,I){const x=A.toAffine(),U=s.toBytes(x.x),_=sn;return ii("isCompressed",I),I?_(Uint8Array.from([A.hasEvenY()?2:3]),U):_(Uint8Array.from([4]),U,s.toBytes(x.y))},fromBytes(E){const A=E.length,I=E[0],x=E.subarray(1);if(A===i&&(I===2||I===3)){const U=sr(x);if(!ho(U,We,s.ORDER))throw new Error("Point is not on curve");const _=u(U);let M;try{M=s.sqrt(_)}catch(F){const X=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+X)}const j=(M&We)===We;return(I&1)===1!==j&&(M=s.neg(M)),{x:U,y:M}}else if(A===n&&I===4){const U=s.fromBytes(x.subarray(0,s.BYTES)),_=s.fromBytes(x.subarray(s.BYTES,2*s.BYTES));return{x:U,y:_}}else{const U=i,_=n;throw new Error("invalid Point, expected length of "+U+", or uncompressed "+_+", got "+A)}}}),d=E=>ni(ai(E,e.nByteLength));function g(E){const A=r>>We;return E>A}function y(E){return g(E)?o(-E):E}const f=(E,A,I)=>sr(E.slice(A,I));class p{constructor(A,I,x){this.r=A,this.s=I,this.recovery=x,this.assertValidity()}static fromCompact(A){const I=e.nByteLength;return A=_t("compactSignature",A,I*2),new p(f(A,0,I),f(A,I,2*I))}static fromDER(A){const{r:I,s:x}=gs.toSig(_t("DER",A));return new p(I,x)}assertValidity(){bs("r",this.r,We,r),bs("s",this.s,We,r)}addRecoveryBit(A){return new p(this.r,this.s,A)}recoverPublicKey(A){const{r:I,s:x,recovery:U}=this,_=S(_t("msgHash",A));if(U==null||![0,1,2,3].includes(U))throw new Error("recovery id invalid");const M=U===2||U===3?I+e.n:I;if(M>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(U&1)===0?"02":"03",F=c.fromHex(j+d(M)),X=a(M),G=o(-_*X),oe=o(x*X),le=c.BASE.multiplyAndAddUnsafe(F,G,oe);if(!le)throw new Error("point at infinify");return le.assertValidity(),le}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return oi(this.toDERHex())}toDERHex(){return gs.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return oi(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const E=Dh(e.n);return Nm(e.randomBytes(E),e.n)},precompute(E=8,A=c.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}};function w(E,A=!0){return c.fromPrivateKey(E).toRawBytes(A)}function C(E){const A=cr(E),I=typeof E=="string",x=(A||I)&&E.length;return A?x===i||x===n:I?x===2*i||x===2*n:E instanceof c}function O(E,A,I=!0){if(C(E))throw new Error("first arg must be private key");if(!C(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(l(E)).toRawBytes(I)}const $=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");const A=sr(E),I=E.length*8-e.nBitLength;return I>0?A>>BigInt(I):A},S=e.bits2int_modN||function(E){return o($(E))},N=uc(e.nBitLength);function T(E){return bs("num < 2^"+e.nBitLength,E,ws,N),ai(E,e.nByteLength)}function v(E,A,I=k){if(["recovered","canonical"].some(ue=>ue in I))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:U}=e;let{lowS:_,prehash:M,extraEntropy:j}=I;_==null&&(_=!0),E=_t("msgHash",E),ul(I),M&&(E=_t("prehashed msgHash",x(E)));const F=S(E),X=l(A),G=[T(X),T(F)];if(j!=null&&j!==!1){const ue=j===!0?U(s.BYTES):j;G.push(_t("extraEntropy",ue))}const oe=sn(...G),le=F;function Ie(ue){const he=$(ue);if(!h(he))return;const Ft=a(he),at=c.BASE.multiply(he).toAffine(),qe=o(at.x);if(qe===ws)return;const Ze=o(Ft*o(le+qe*X));if(Ze===ws)return;let ct=(at.x===qe?0:2)|Number(at.y&We),Fs=Ze;return _&&g(Ze)&&(Fs=y(Ze),ct^=1),new p(qe,Fs,ct)}return{seed:oe,k2sig:Ie}}const k={lowS:e.lowS,prehash:!1},P={lowS:e.lowS,prehash:!1};function R(E,A,I=k){const{seed:x,k2sig:U}=v(E,A,I),_=e;return $h(_.hash.outputLen,_.nByteLength,_.hmac)(x,U)}c.BASE._setWindowSize(8);function L(E,A,I,x=P){var Ze;const U=E;A=_t("msgHash",A),I=_t("publicKey",I);const{lowS:_,prehash:M,format:j}=x;if(ul(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const F=typeof U=="string"||cr(U),X=!F&&!j&&typeof U=="object"&&U!==null&&typeof U.r=="bigint"&&typeof U.s=="bigint";if(!F&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,oe;try{if(X&&(G=new p(U.r,U.s)),F){try{j!=="compact"&&(G=p.fromDER(U))}catch(ct){if(!(ct instanceof gs.Err))throw ct}!G&&j!=="der"&&(G=p.fromCompact(U))}oe=c.fromHex(I)}catch{return!1}if(!G||_&&G.hasHighS())return!1;M&&(A=e.hash(A));const{r:le,s:Ie}=G,ue=S(A),he=a(Ie),Ft=o(ue*he),at=o(le*he),qe=(Ze=c.BASE.multiplyAndAddUnsafe(oe,Ft,at))==null?void 0:Ze.toAffine();return qe?o(qe.x)===le:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:O,sign:R,verify:L,ProjectivePoint:c,Signature:p,utils:m}}function Hm(t){return{hash:t,hmac:(e,...s)=>ao(t,e,bg(...s)),randomBytes:yi}}function zm(t,e){const s=r=>Wm({...t,...Hm(r)});return{...s(e),create:s}}const qh=Rh(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Vm=qh.create(BigInt("-3")),Km=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gm=zm({a:Vm,b:Km,Fp:qh,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},mn),jh="base10",ut="base16",rr="base64pad",hc="base64url",yn="utf8",Fh=0,vi=1,po=2,Jm=0,dl=1,Vi=12,dc=32;function Ym(){const t=Pa.utils.randomPrivateKey(),e=Pa.getPublicKey(t);return{privateKey:it(t,ut),publicKey:it(e,ut)}}function Oa(){const t=yi(dc);return it(t,ut)}function Zm(t,e){const s=Pa.getSharedSecret(Et(t,ut),Et(e,ut)),r=tm(mn,s,void 0,void 0,dc);return it(r,ut)}function Xm(t){const e=mn(Et(t,ut));return it(e,ut)}function jn(t){const e=mn(Et(t,yn));return it(e,ut)}function Wh(t){return Et(`${t}`,jh)}function lr(t){return Number(it(t,jh))}function Hh(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function zh(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function Qm(t){const e=Wh(typeof t.type<"u"?t.type:Fh);if(lr(e)===vi&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?Et(t.senderPublicKey,ut):void 0,r=typeof t.iv<"u"?Et(t.iv,ut):yi(Vi),i=Et(t.symKey,ut),n=Ph(i,r).encrypt(Et(t.message,yn)),o=Vh({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===hc?Hh(o):o}function ew(t){const e=Et(t.symKey,ut),{sealed:s,iv:r}=rn({encoded:t.encoded,encoding:t.encoding}),i=Ph(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return it(i,yn)}function tw(t,e){const s=Wh(po),r=yi(Vi),i=Et(t,yn),n=Vh({type:s,sealed:i,iv:r});return e===hc?Hh(n):n}function sw(t,e){const{sealed:s}=rn({encoded:t,encoding:e});return it(s,yn)}function Vh(t){if(lr(t.type)===po)return it(ji([t.type,t.sealed]),rr);if(lr(t.type)===vi){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return it(ji([t.type,t.senderPublicKey,t.iv,t.sealed]),rr)}return it(ji([t.type,t.iv,t.sealed]),rr)}function rn(t){const e=(t.encoding||rr)===hc?zh(t.encoded):t.encoded,s=Et(e,rr),r=s.slice(Jm,dl),i=dl;if(lr(r)===vi){const c=i+dc,l=c+Vi,u=s.slice(i,c),h=s.slice(c,l),d=s.slice(l);return{type:r,sealed:d,iv:h,senderPublicKey:u}}if(lr(r)===po){const c=s.slice(i),l=yi(Vi);return{type:r,sealed:c,iv:l}}const n=i+Vi,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function rw(t,e){const s=rn({encoded:t,encoding:e==null?void 0:e.encoding});return Kh({type:lr(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?it(s.senderPublicKey,ut):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Kh(t){const e=(t==null?void 0:t.type)||Fh;if(e===vi){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function pl(t){return t.type===vi&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function fl(t){return t.type===po}function iw(t){const e=Buffer.from(t.x,"base64"),s=Buffer.from(t.y,"base64");return ji([new Uint8Array([4]),e,s])}function nw(t,e){const[s,r,i]=t.split("."),n=Buffer.from(zh(i),"base64");if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=`${s}.${r}`,l=mn(c),u=iw(e);if(!Gm.verify(ji([o,a]),l,u))throw new Error("Invalid signature");return fa(t).payload}const ow="irn";function Zn(t){return(t==null?void 0:t.relay)||{protocol:ow}}function Li(t){const e=dp[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function aw(t,e="-"){const s={},r="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(r)){const n=i.replace(r,""),o=t[i];s[n]=o}}),s}function gl(t){if(!t.includes("wc:")){const l=yh(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),s=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),i=t.substring(e+1,s).split("@"),n=typeof s<"u"?t.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((l,u)=>{a[u]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:r,topic:cw(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:aw(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function cw(t){return t.startsWith("//")?t.substring(2):t}function lw(t,e="-"){const s="relay",r={};return Object.keys(t).forEach(i=>{const n=i,o=s+e+n;t[n]&&(r[o]=t[n])}),r}function ml(t){const e=new URLSearchParams,s=lw(t.relay);Object.keys(s).sort().forEach(i=>{e.set(i,s[i])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const r=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${r}`}const uw={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},hw={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function be(t,e){const{message:s,code:r}=hw[t];return{message:e?`${s} ${e}`:s,code:r}}function Bi(t,e){const{message:s,code:r}=uw[t];return{message:e?`${s} ${e}`:s,code:r}}function Ta(t){return typeof t>"u"}function Gh(t,e){return typeof t=="string"&&!!t.trim().length}function dw(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(Gh(t,!1)){if(e(t))return!0;const s=yh(t);return e(s)}}catch{}return!1}function pw(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function fw(t){return t==null?void 0:t.topic}function Mo(t){return typeof t<"u"&&typeof t!==null}function wl(){const t=oo();return new Promise(e=>{switch(t){case Zt.browser:e(gw());break;case Zt.reactNative:e(mw());break;case Zt.node:e(ww());break;default:e(!0)}})}function gw(){return fn()&&(navigator==null?void 0:navigator.onLine)}async function mw(){if(wr()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function ww(){return!0}function yw(t){switch(oo()){case Zt.browser:bw(t);break;case Zt.reactNative:vw(t);break}}function bw(t){!wr()&&fn()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function vw(t){wr()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}function Ew(){var t;return fn()&&Tt.getDocument()?((t=Tt.getDocument())==null?void 0:t.visibilityState)==="visible":!0}var Cw={};const Jh="wc",Yh=2,$a="core",cs=`${Jh}@2:${$a}:`,Iw={logger:"error"},Aw={database:":memory:"},Nw="crypto",yl="client_ed25519_seed",_w=q.ONE_DAY,Sw="keychain",Pw="0.3",Ow="messages",Tw="0.3",bl=q.SIX_HOURS,$w="publisher",Zh="irn",kw="error",Xh="wss://relay.walletconnect.org",xw="relayer",Ve={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Rw="_subscription",Dt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Uw=.1,ka="2.21.0",$e={link_mode:"link_mode",relay:"relay"},Fn={inbound:"inbound",outbound:"outbound"},Dw="0.3",Lw="WALLETCONNECT_CLIENT_ID",vl="WALLETCONNECT_LINK_MODE_APPS",At={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Bw="subscription",Mw="0.3",qw="pairing",jw="0.3",_i={wc_pairingDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:q.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:q.ONE_DAY,prompt:!1,tag:0},res:{ttl:q.ONE_DAY,prompt:!1,tag:0}}},Ys={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Wt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Fw="history",Ww="0.3",Hw="expirer",Mt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},zw="0.3",Vw="verify-api",Kw="https://verify.walletconnect.com",Qh="https://verify.walletconnect.org",Ki=Qh,Gw=`${Ki}/v3`,Jw=[Kw,Qh],Yw="echo",Zw="https://echo.walletconnect.com",rs={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},fs={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ht={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Hs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},zs={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},Si={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Xw=.1,Qw="event-client",ey=86400,ty="https://pulse.walletconnect.org/batch";function sy(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),r=0;r<s.length;r++)s[r]=255;for(var i=0;i<t.length;i++){var n=t.charAt(i),o=n.charCodeAt(0);if(s[o]!==255)throw new TypeError(n+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var f=0,p=0,m=0,w=y.length;m!==w&&y[m]===0;)m++,f++;for(var C=(w-m)*u+1>>>0,O=new Uint8Array(C);m!==w;){for(var $=y[m],S=0,N=C-1;($!==0||S<p)&&N!==-1;N--,S++)$+=256*O[N]>>>0,O[N]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");p=S,m++}for(var T=C-p;T!==C&&O[T]===0;)T++;for(var v=c.repeat(f);T<C;++T)v+=t.charAt(O[T]);return v}function d(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var f=0;if(y[f]!==" "){for(var p=0,m=0;y[f]===c;)p++,f++;for(var w=(y.length-f)*l+1>>>0,C=new Uint8Array(w);y[f];){var O=s[y.charCodeAt(f)];if(O===255)return;for(var $=0,S=w-1;(O!==0||$<m)&&S!==-1;S--,$++)O+=a*C[S]>>>0,C[S]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");m=$,f++}if(y[f]!==" "){for(var N=w-m;N!==w&&C[N]===0;)N++;for(var T=new Uint8Array(p+(w-N)),v=p;N!==w;)T[v++]=C[N++];return T}}}function g(y){var f=d(y);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:g}}var ry=sy,iy=ry;const ed=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},ny=t=>new TextEncoder().encode(t),oy=t=>new TextDecoder().decode(t);let ay=class{constructor(e,s,r){this.name=e,this.prefix=s,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},cy=class{constructor(e,s,r){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return td(this,e)}},ly=class{constructor(e){this.decoders=e}or(e){return td(this,e)}decode(e){const s=e[0],r=this.decoders[s];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const td=(t,e)=>new ly({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let uy=class{constructor(e,s,r,i){this.name=e,this.prefix=s,this.baseEncode=r,this.baseDecode=i,this.encoder=new ay(e,s,r),this.decoder=new cy(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const fo=({name:t,prefix:e,encode:s,decode:r})=>new uy(t,e,s,r),bn=({prefix:t,name:e,alphabet:s})=>{const{encode:r,decode:i}=iy(s,e);return fo({prefix:t,name:e,encode:r,decode:n=>ed(i(n))})},hy=(t,e,s,r)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,l=0;for(let u=0;u<n;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<s|h,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},dy=(t,e,s)=>{const r=e[e.length-1]==="=",i=(1<<s)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,n+=e[i&a>>o];if(o&&(n+=e[i&a<<s-o]),r)for(;n.length*s&7;)n+="=";return n},st=({name:t,prefix:e,bitsPerChar:s,alphabet:r})=>fo({prefix:e,name:t,encode(i){return dy(i,r,s)},decode(i){return hy(i,r,s,t)}}),py=fo({prefix:"\0",name:"identity",encode:t=>oy(t),decode:t=>ny(t)});var fy=Object.freeze({__proto__:null,identity:py});const gy=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var my=Object.freeze({__proto__:null,base2:gy});const wy=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var yy=Object.freeze({__proto__:null,base8:wy});const by=bn({prefix:"9",name:"base10",alphabet:"0123456789"});var vy=Object.freeze({__proto__:null,base10:by});const Ey=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cy=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Iy=Object.freeze({__proto__:null,base16:Ey,base16upper:Cy});const Ay=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ny=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_y=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Sy=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Py=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Oy=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ty=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$y=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ky=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xy=Object.freeze({__proto__:null,base32:Ay,base32upper:Ny,base32pad:_y,base32padupper:Sy,base32hex:Py,base32hexupper:Oy,base32hexpad:Ty,base32hexpadupper:$y,base32z:ky});const Ry=bn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Uy=bn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Dy=Object.freeze({__proto__:null,base36:Ry,base36upper:Uy});const Ly=bn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),By=bn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var My=Object.freeze({__proto__:null,base58btc:Ly,base58flickr:By});const qy=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jy=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fy=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wy=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Hy=Object.freeze({__proto__:null,base64:qy,base64pad:jy,base64url:Fy,base64urlpad:Wy});const sd=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),zy=sd.reduce((t,e,s)=>(t[s]=e,t),[]),Vy=sd.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function Ky(t){return t.reduce((e,s)=>(e+=zy[s],e),"")}function Gy(t){const e=[];for(const s of t){const r=Vy[s.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(r)}return new Uint8Array(e)}const Jy=fo({prefix:"🚀",name:"base256emoji",encode:Ky,decode:Gy});var Yy=Object.freeze({__proto__:null,base256emoji:Jy}),Zy=rd,El=128,Xy=-128,Qy=Math.pow(2,31);function rd(t,e,s){e=e||[],s=s||0;for(var r=s;t>=Qy;)e[s++]=t&255|El,t/=128;for(;t&Xy;)e[s++]=t&255|El,t>>>=7;return e[s]=t|0,rd.bytes=s-r+1,e}var eb=xa,tb=128,Cl=127;function xa(t,r){var s=0,r=r||0,i=0,n=r,o,a=t.length;do{if(n>=a)throw xa.bytes=0,new RangeError("Could not decode varint");o=t[n++],s+=i<28?(o&Cl)<<i:(o&Cl)*Math.pow(2,i),i+=7}while(o>=tb);return xa.bytes=n-r,s}var sb=Math.pow(2,7),rb=Math.pow(2,14),ib=Math.pow(2,21),nb=Math.pow(2,28),ob=Math.pow(2,35),ab=Math.pow(2,42),cb=Math.pow(2,49),lb=Math.pow(2,56),ub=Math.pow(2,63),hb=function(t){return t<sb?1:t<rb?2:t<ib?3:t<nb?4:t<ob?5:t<ab?6:t<cb?7:t<lb?8:t<ub?9:10},db={encode:Zy,decode:eb,encodingLength:hb},id=db;const Il=(t,e,s=0)=>(id.encode(t,e,s),e),Al=t=>id.encodingLength(t),Ra=(t,e)=>{const s=e.byteLength,r=Al(t),i=r+Al(s),n=new Uint8Array(i+s);return Il(t,n,0),Il(s,n,r),n.set(e,i),new pb(t,s,e,n)};let pb=class{constructor(e,s,r,i){this.code=e,this.size=s,this.digest=r,this.bytes=i}};const nd=({name:t,code:e,encode:s})=>new fb(t,e,s);class fb{constructor(e,s,r){this.name=e,this.code=s,this.encode=r}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?Ra(this.code,s):s.then(r=>Ra(this.code,r))}else throw Error("Unknown type, must be binary type")}}const od=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),gb=nd({name:"sha2-256",code:18,encode:od("SHA-256")}),mb=nd({name:"sha2-512",code:19,encode:od("SHA-512")});var wb=Object.freeze({__proto__:null,sha256:gb,sha512:mb});const ad=0,yb="identity",cd=ed,bb=t=>Ra(ad,cd(t)),vb={code:ad,name:yb,encode:cd,digest:bb};var Eb=Object.freeze({__proto__:null,identity:vb});new TextEncoder,new TextDecoder;const Nl={...fy,...my,...yy,...vy,...Iy,...xy,...Dy,...My,...Hy,...Yy};({...wb,...Eb});function Cb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ld(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const _l=ld("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),qo=ld("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=Cb(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Ib={utf8:_l,"utf-8":_l,hex:Nl.base16,latin1:qo,ascii:qo,binary:qo,...Nl};function Ab(t,e="utf8"){const s=Ib[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):s.decoder.decode(`${s.prefix}${t}`)}var Nb=Object.defineProperty,_b=(t,e,s)=>e in t?Nb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,es=(t,e,s)=>_b(t,typeof e!="symbol"?e+"":e,s);let Sb=class{constructor(e,s){this.core=e,this.logger=s,es(this,"keychain",new Map),es(this,"name",Sw),es(this,"version",Pw),es(this,"initialized",!1),es(this,"storagePrefix",cs),es(this,"init",async()=>{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),es(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),es(this,"set",async(r,i)=>{this.isInitialized(),this.keychain.set(r,i),await this.persist()}),es(this,"get",r=>{this.isInitialized();const i=this.keychain.get(r);if(typeof i>"u"){const{message:n}=be("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}),es(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=ht(s,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ba(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?va(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var Pb=Object.defineProperty,Ob=(t,e,s)=>e in t?Pb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Qe=(t,e,s)=>Ob(t,typeof e!="symbol"?e+"":e,s);let Tb=class{constructor(e,s,r){this.core=e,this.logger=s,Qe(this,"name",Nw),Qe(this,"keychain"),Qe(this,"randomSessionIdentifier",Oa()),Qe(this,"initialized",!1),Qe(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Qe(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Qe(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),n=Pc(i);return wp(n.publicKey)}),Qe(this,"generateKeyPair",()=>{this.isInitialized();const i=Ym();return this.setPrivateKey(i.publicKey,i.privateKey)}),Qe(this,"signJWT",async i=>{this.isInitialized();const n=await this.getClientSeed(),o=Pc(n),a=this.randomSessionIdentifier;return await yp(a,i,_w,o)}),Qe(this,"generateSharedKey",(i,n,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=Zm(a,n);return this.setSymKey(c,o)}),Qe(this,"setSymKey",async(i,n)=>{this.isInitialized();const o=n||Xm(i);return await this.keychain.set(o,i),o}),Qe(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Qe(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Qe(this,"encode",async(i,n,o)=>{this.isInitialized();const a=Kh(o),c=bp(n);if(fl(a))return tw(c,o==null?void 0:o.encoding);if(pl(a)){const d=a.senderPublicKey,g=a.receiverPublicKey;i=await this.generateSharedKey(d,g)}const l=this.getSymKey(i),{type:u,senderPublicKey:h}=a;return Qm({type:u,symKey:l,message:c,senderPublicKey:h,encoding:o==null?void 0:o.encoding})}),Qe(this,"decode",async(i,n,o)=>{this.isInitialized();const a=rw(n,o);if(fl(a)){const c=sw(n,o==null?void 0:o.encoding);return Oc(c)}if(pl(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=ew({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return Oc(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Qe(this,"getPayloadType",(i,n=rr)=>{const o=rn({encoded:i,encoding:n});return lr(o.type)}),Qe(this,"getPayloadSenderPublicKey",(i,n=rr)=>{const o=rn({encoded:i,encoding:n});return o.senderPublicKey?it(o.senderPublicKey,ut):void 0}),this.core=e,this.logger=ht(s,this.name),this.keychain=r||new Sb(this.core,this.logger)}get context(){return kt(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(yl)}catch{e=Oa(),await this.keychain.set(yl,e)}return Ab(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var $b=Object.defineProperty,kb=Object.defineProperties,xb=Object.getOwnPropertyDescriptors,Sl=Object.getOwnPropertySymbols,Rb=Object.prototype.hasOwnProperty,Ub=Object.prototype.propertyIsEnumerable,Ua=(t,e,s)=>e in t?$b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Db=(t,e)=>{for(var s in e||(e={}))Rb.call(e,s)&&Ua(t,s,e[s]);if(Sl)for(var s of Sl(e))Ub.call(e,s)&&Ua(t,s,e[s]);return t},Lb=(t,e)=>kb(t,xb(e)),It=(t,e,s)=>Ua(t,typeof e!="symbol"?e+"":e,s);let Bb=class extends Uf{constructor(e,s){super(e,s),this.logger=e,this.core=s,It(this,"messages",new Map),It(this,"messagesWithoutClientAck",new Map),It(this,"name",Ow),It(this,"version",Tw),It(this,"initialized",!1),It(this,"storagePrefix",cs),It(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const r=await this.getRelayerMessages();typeof r<"u"&&(this.messages=r);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}finally{this.initialized=!0}}}),It(this,"set",async(r,i,n)=>{this.isInitialized();const o=jn(i);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(r,a),n===Fn.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,Lb(Db({},c),{[o]:i}))}return await this.persist(),o}),It(this,"get",r=>{this.isInitialized();let i=this.messages.get(r);return typeof i>"u"&&(i={}),i}),It(this,"getWithoutAck",r=>{this.isInitialized();const i={};for(const n of r){const o=this.messagesWithoutClientAck.get(n)||{};i[n]=Object.values(o)}return i}),It(this,"has",(r,i)=>{this.isInitialized();const n=this.get(r),o=jn(i);return typeof n[o]<"u"}),It(this,"ack",async(r,i)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=jn(i);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),It(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=ht(e,this.name),this.core=s}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ba(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ba(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?va(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?va(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var Mb=Object.defineProperty,qb=Object.defineProperties,jb=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Fb=Object.prototype.hasOwnProperty,Wb=Object.prototype.propertyIsEnumerable,Da=(t,e,s)=>e in t?Mb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,On=(t,e)=>{for(var s in e||(e={}))Fb.call(e,s)&&Da(t,s,e[s]);if(Pl)for(var s of Pl(e))Wb.call(e,s)&&Da(t,s,e[s]);return t},jo=(t,e)=>qb(t,jb(e)),zt=(t,e,s)=>Da(t,typeof e!="symbol"?e+"":e,s);class Hb extends Df{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,zt(this,"events",new pr.EventEmitter),zt(this,"name",$w),zt(this,"queue",new Map),zt(this,"publishTimeout",q.toMiliseconds(q.ONE_MINUTE)),zt(this,"initialPublishTimeout",q.toMiliseconds(q.ONE_SECOND*15)),zt(this,"needsTransportRestart",!1),zt(this,"publish",async(r,i,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:r,message:i,opts:n}});const a=(n==null?void 0:n.ttl)||bl,c=Zn(n),l=(n==null?void 0:n.prompt)||!1,u=(n==null?void 0:n.tag)||0,h=(n==null?void 0:n.id)||zr().toString(),d={topic:r,message:i,opts:{ttl:a,relay:c,prompt:l,tag:u,id:h,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},g=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const y=new Promise(async f=>{const p=({id:w})=>{d.opts.id===w&&(this.removeRequestFromQueue(w),this.relayer.events.removeListener(Ve.publish,p),f(d))};this.relayer.events.on(Ve.publish,p);const m=xs(new Promise((w,C)=>{this.rpcPublish({topic:r,message:i,ttl:a,prompt:l,tag:u,id:h,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(w).catch(O=>{this.logger.warn(O,O==null?void 0:O.message),C(O)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await m,this.events.removeListener(Ve.publish,p)}catch(w){this.queue.set(h,jo(On({},d),{attempt:1})),this.logger.warn(w,w==null?void 0:w.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:r,message:i,opts:n}}),await xs(y,this.publishTimeout,g)}catch(y){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(y),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw y}finally{this.queue.delete(h)}}),zt(this,"on",(r,i)=>{this.events.on(r,i)}),zt(this,"once",(r,i)=>{this.events.once(r,i)}),zt(this,"off",(r,i)=>{this.events.off(r,i)}),zt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.relayer=e,this.logger=ht(s,this.name),this.registerEventListeners()}get context(){return kt(this.logger)}async rpcPublish(e){var s,r,i,n;const{topic:o,message:a,ttl:c=bl,prompt:l,tag:u,id:h,attestation:d,tvf:g}=e,y={method:Li(Zn().protocol).publish,params:On({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:d},g),id:h};Ta((s=y.params)==null?void 0:s.prompt)&&((r=y.params)==null||delete r.prompt),Ta((i=y.params)==null?void 0:i.tag)&&((n=y.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y});const f=await this.relayer.request(y);return this.relayer.events.emit(Ve.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{const r=e.attempt+1;this.queue.set(s,jo(On({},e),{attempt:r}));const{topic:i,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(jo(On({},e),{topic:i,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(wi.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ve.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ve.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var zb=Object.defineProperty,Vb=(t,e,s)=>e in t?zb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ir=(t,e,s)=>Vb(t,typeof e!="symbol"?e+"":e,s);class Kb{constructor(){Ir(this,"map",new Map),Ir(this,"set",(e,s)=>{const r=this.get(e);this.exists(e,s)||this.map.set(e,[...r,s])}),Ir(this,"get",e=>this.map.get(e)||[]),Ir(this,"exists",(e,s)=>this.get(e).includes(s)),Ir(this,"delete",(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,s))return;const i=r.filter(n=>n!==s);if(!i.length){this.map.delete(e);return}this.map.set(e,i)}),Ir(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Gb=Object.defineProperty,Jb=Object.defineProperties,Yb=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Zb=Object.prototype.hasOwnProperty,Xb=Object.prototype.propertyIsEnumerable,La=(t,e,s)=>e in t?Gb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Pi=(t,e)=>{for(var s in e||(e={}))Zb.call(e,s)&&La(t,s,e[s]);if(Ol)for(var s of Ol(e))Xb.call(e,s)&&La(t,s,e[s]);return t},Fo=(t,e)=>Jb(t,Yb(e)),Ne=(t,e,s)=>La(t,typeof e!="symbol"?e+"":e,s);let Qb=class extends Mf{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Ne(this,"subscriptions",new Map),Ne(this,"topicMap",new Kb),Ne(this,"events",new pr.EventEmitter),Ne(this,"name",Bw),Ne(this,"version",Mw),Ne(this,"pending",new Map),Ne(this,"cached",[]),Ne(this,"initialized",!1),Ne(this,"storagePrefix",cs),Ne(this,"subscribeTimeout",q.toMiliseconds(q.ONE_MINUTE)),Ne(this,"initialSubscribeTimeout",q.toMiliseconds(q.ONE_SECOND*15)),Ne(this,"clientId"),Ne(this,"batchSubscribeTopicsLimit",500),Ne(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ne(this,"subscribe",async(r,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}});try{const n=Zn(i),o={topic:r,relay:n,transportType:i==null?void 0:i.transportType};this.pending.set(r,o);const a=await this.rpcSubscribe(r,n,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),Ne(this,"unsubscribe",async(r,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(r,i.id,i):await this.unsubscribeByTopic(r,i)}),Ne(this,"isSubscribed",r=>new Promise(i=>{i(this.topicMap.topics.includes(r))})),Ne(this,"isKnownTopic",r=>new Promise(i=>{i(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),Ne(this,"on",(r,i)=>{this.events.on(r,i)}),Ne(this,"once",(r,i)=>{this.events.once(r,i)}),Ne(this,"off",(r,i)=>{this.events.off(r,i)}),Ne(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),Ne(this,"start",async()=>{await this.onConnect()}),Ne(this,"stop",async()=>{await this.onDisconnect()}),Ne(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Ne(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}),Ne(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(wi.pulse,async()=>{await this.checkPending()}),this.events.on(At.created,async r=>{const i=At.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(At.deleted,async r=>{const i=At.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}),this.relayer=e,this.logger=ht(s,this.name),this.clientId=""}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,s){let r=!1;try{r=this.getSubscription(e).topic===s}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const r=this.topicMap.get(e);await Promise.all(r.map(async i=>await this.unsubscribeById(e,i,s)))}async unsubscribeById(e,s,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}});try{const i=Zn(r);await this.restartToComplete({topic:e,id:s,relay:i}),await this.rpcUnsubscribe(e,s,i);const n=Bi("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,s,r){var i;(!r||(r==null?void 0:r.transportType)===$e.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const n={method:Li(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((r==null?void 0:r.transportType)===$e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(u=>this.logger.warn(u))},q.toMiliseconds(q.ONE_SECOND)),a;const c=new Promise(async u=>{const h=d=>{d.topic===e&&(this.events.removeListener(At.created,h),u(d.id))};this.events.on(At.created,h);try{const d=await xs(new Promise((g,y)=>{this.relayer.request(n).catch(f=>{this.logger.warn(f,f==null?void 0:f.message),y(f)}).then(g)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(At.created,h),u(d)}catch{}}),l=await xs(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ve.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const s=e[0].relay,r={method:Li(s.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await xs(new Promise(i=>{this.relayer.request(r).catch(n=>this.logger.warn(n)).then(i)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ve.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,r={method:Li(s.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let i;try{i=await await xs(new Promise((n,o)=>{this.relayer.request(r).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ve.connection_stalled)}return i}rpcUnsubscribe(e,s,r){const i={method:Li(r.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,s){this.setSubscription(e,Fo(Pi({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,Pi({},s)),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,r){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,Pi({},s)),this.topicMap.set(s.topic,e),this.events.emit(At.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(At.deleted,Fo(Pi({},r),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(At.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<s;r++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(At.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async s=>Fo(Pi({},s),{id:await this.getSubscriptionId(s.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await cg(q.toMiliseconds(q.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return jn(e+await this.getClientId())}};var e0=Object.defineProperty,Tl=Object.getOwnPropertySymbols,t0=Object.prototype.hasOwnProperty,s0=Object.prototype.propertyIsEnumerable,Ba=(t,e,s)=>e in t?e0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,$l=(t,e)=>{for(var s in e||(e={}))t0.call(e,s)&&Ba(t,s,e[s]);if(Tl)for(var s of Tl(e))s0.call(e,s)&&Ba(t,s,e[s]);return t},ge=(t,e,s)=>Ba(t,typeof e!="symbol"?e+"":e,s);let r0=class extends Lf{constructor(e){super(e),ge(this,"protocol","wc"),ge(this,"version",2),ge(this,"core"),ge(this,"logger"),ge(this,"events",new pr.EventEmitter),ge(this,"provider"),ge(this,"messages"),ge(this,"subscriber"),ge(this,"publisher"),ge(this,"name",xw),ge(this,"transportExplicitlyClosed",!1),ge(this,"initialized",!1),ge(this,"connectionAttemptInProgress",!1),ge(this,"relayUrl"),ge(this,"projectId"),ge(this,"packageName"),ge(this,"bundleId"),ge(this,"hasExperiencedNetworkDisruption",!1),ge(this,"pingTimeout"),ge(this,"heartBeatTimeout",q.toMiliseconds(q.THIRTY_SECONDS+q.FIVE_SECONDS)),ge(this,"reconnectTimeout"),ge(this,"connectPromise"),ge(this,"reconnectInProgress",!1),ge(this,"requestsInFlight",[]),ge(this,"connectTimeout",q.toMiliseconds(q.ONE_SECOND*15)),ge(this,"request",async s=>{var r,i;this.logger.debug("Publishing Request Payload");const n=s.id||zr().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:s.method,topic:(r=s.params)==null?void 0:r.topic},"relayer.request - publishing...");const o=`${n}:${((i=s.params)==null?void 0:i.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),ge(this,"resetPingTimeout",()=>{Yn()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,r,i,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=(s=this.provider)==null?void 0:s.connection)==null?void 0:r.socket)==null?void 0:i.terminate)==null||n.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),ge(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),ge(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Ve.connect)}),ge(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),ge(this,"onProviderErrorHandler",s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(Ve.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),ge(this,"registerProviderListeners",()=>{this.provider.on(Dt.payload,this.onPayloadHandler),this.provider.on(Dt.connect,this.onConnectHandler),this.provider.on(Dt.disconnect,this.onDisconnectHandler),this.provider.on(Dt.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?ht(e.logger,this.name):rc(hn({level:e.logger||kw})),this.messages=new Bb(this.logger,e.core),this.subscriber=new Qb(this,this.logger),this.publisher=new Hb(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Xh,this.projectId=e.projectId,Zf()?this.packageName=Fc():Xf()&&(this.bundleId=Fc()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return kt(this.logger)}get connected(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===1||!1}get connecting(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,s,r){this.isInitialized(),await this.publisher.publish(e,s,r),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:$e.relay},Fn.outbound)}async subscribe(e,s){var r,i,n;this.isInitialized(),(!(s!=null&&s.transportType)||(s==null?void 0:s.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((r=s==null?void 0:s.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(i=s==null?void 0:s.internal)==null?void 0:i.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(At.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(At.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,$l({internal:{throwOnFailedPublish:o}},s)).catch(d=>{o&&h(d)})||a,u()})]),a}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await xs(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(s,r)=>{await this.connect(e).then(s).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await wl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const s=e.sort((r,i)=>r.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const r of s)try{await this.onMessageEvent(r)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:r}=e;if(!s.sessionExists){const i=zi(q.FIVE_MINUTES),n={topic:r,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(Ve.message,e),await this.recordMessageEvent(e,Fn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(r,i)=>{const n=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dt.disconnect,n),await xs(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{i(o)}).finally(()=>{this.provider.off(Dt.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dt.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Dt.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){await this.subscriber.stop();const i=r;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${s}`);break}await new Promise(r=>setTimeout(r,q.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,r,i,n;if(Yn())try{(s=(e=this.provider)==null?void 0:e.connection)!=null&&s.socket&&((n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new qt(new mp(rg({sdkVersion:ka,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,s){const{topic:r,message:i}=e;await this.messages.set(r,i,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:r}=e;if(!r||r.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const i=this.messages.has(s,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),ic(e)){if(!e.method.endsWith(Rw))return;const s=e.params,{topic:r,message:i,publishedAt:n,attestation:o}=s.data,a={topic:r,message:i,publishedAt:n,transportType:$e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace($l({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else nc(e)&&this.events.emit(Ve.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Fn.inbound),this.events.emit(Ve.message,e))}async acknowledgePayload(e){const s=io(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(Dt.payload,this.onPayloadHandler),this.provider.off(Dt.connect,this.onConnectHandler),this.provider.off(Dt.disconnect,this.onDisconnectHandler),this.provider.off(Dt.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await wl();yw(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(r=>this.logger.error(r,r==null?void 0:r.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(wi.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&Ew())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s==null?void 0:s.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Ve.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},q.toMiliseconds(Uw)))))}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}};function i0(){}function kl(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function xl(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Rl(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const n0="[object RegExp]",o0="[object String]",a0="[object Number]",c0="[object Boolean]",Ul="[object Arguments]",l0="[object Symbol]",u0="[object Date]",h0="[object Map]",d0="[object Set]",p0="[object Array]",f0="[object Function]",g0="[object ArrayBuffer]",Wo="[object Object]",m0="[object Error]",w0="[object DataView]",y0="[object Uint8Array]",b0="[object Uint8ClampedArray]",v0="[object Uint16Array]",E0="[object Uint32Array]",C0="[object BigUint64Array]",I0="[object Int8Array]",A0="[object Int16Array]",N0="[object Int32Array]",_0="[object BigInt64Array]",S0="[object Float32Array]",P0="[object Float64Array]";function O0(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function T0(t,e,s){return Mi(t,e,void 0,void 0,void 0,void 0,s)}function Mi(t,e,s,r,i,n,o){const a=o(t,e,s,r,i,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return Gi(t,e,n,o)}return Gi(t,e,n,o)}function Gi(t,e,s,r){if(Object.is(t,e))return!0;let i=Rl(t),n=Rl(e);if(i===Ul&&(i=Wo),n===Ul&&(n=Wo),i!==n)return!1;switch(i){case o0:return t.toString()===e.toString();case a0:{const c=t.valueOf(),l=e.valueOf();return O0(c,l)}case c0:case u0:case l0:return Object.is(t.valueOf(),e.valueOf());case n0:return t.source===e.source&&t.flags===e.flags;case f0:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(i){case h0:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Mi(l,e.get(c),c,t,e,s,r))return!1;return!0}case d0:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let u=0;u<c.length;u++){const h=c[u],d=l.findIndex(g=>Mi(h,g,void 0,t,e,s,r));if(d===-1)return!1;l.splice(d,1)}return!0}case p0:case y0:case b0:case v0:case E0:case C0:case I0:case A0:case N0:case _0:case S0:case P0:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Mi(t[c],e[c],c,t,e,s,r))return!1;return!0}case g0:return t.byteLength!==e.byteLength?!1:Gi(new Uint8Array(t),new Uint8Array(e),s,r);case w0:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Gi(new Uint8Array(t),new Uint8Array(e),s,r);case m0:return t.name===e.name&&t.message===e.message;case Wo:{if(!(Gi(t.constructor,e.constructor,s,r)||kl(t)&&kl(e)))return!1;const c=[...Object.keys(t),...xl(t)],l=[...Object.keys(e),...xl(e)];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){const h=c[u],d=t[h];if(!Object.hasOwn(e,h))return!1;const g=e[h];if(!Mi(d,g,h,t,e,s,r))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function $0(t,e){return T0(t,e,i0)}var k0=Object.defineProperty,Dl=Object.getOwnPropertySymbols,x0=Object.prototype.hasOwnProperty,R0=Object.prototype.propertyIsEnumerable,Ma=(t,e,s)=>e in t?k0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ll=(t,e)=>{for(var s in e||(e={}))x0.call(e,s)&&Ma(t,s,e[s]);if(Dl)for(var s of Dl(e))R0.call(e,s)&&Ma(t,s,e[s]);return t},gt=(t,e,s)=>Ma(t,typeof e!="symbol"?e+"":e,s);let yr=class extends Bf{constructor(e,s,r,i=cs,n=void 0){super(e,s,r,i),this.core=e,this.logger=s,this.name=r,gt(this,"map",new Map),gt(this,"version",Dw),gt(this,"cached",[]),gt(this,"initialized",!1),gt(this,"getKey"),gt(this,"storagePrefix",cs),gt(this,"recentlyDeleted",[]),gt(this,"recentlyDeletedLimit",200),gt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ta(o)?this.map.set(this.getKey(o),o):pw(o)?this.map.set(o.id,o):fw(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),gt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),gt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),gt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>$0(a[c],o[c]))):this.values)),gt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Ll(Ll({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),gt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=ht(s,this.name),this.storagePrefix=i,this.getKey=n}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:i}=be("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}return s}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var U0=Object.defineProperty,D0=(t,e,s)=>e in t?U0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ae=(t,e,s)=>D0(t,typeof e!="symbol"?e+"":e,s);let L0=class{constructor(e,s){this.core=e,this.logger=s,ae(this,"name",qw),ae(this,"version",jw),ae(this,"events",new oc),ae(this,"pairings"),ae(this,"initialized",!1),ae(this,"storagePrefix",cs),ae(this,"ignoredPayloadTypes",[vi]),ae(this,"registeredMethods",[]),ae(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ae(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),ae(this,"create",async r=>{this.isInitialized();const i=Oa(),n=await this.core.crypto.setSymKey(i),o=zi(q.FIVE_MINUTES),a={protocol:Zh},c={topic:n,expiry:o,relay:a,active:!1,methods:r==null?void 0:r.methods},l=ml({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:a,expiryTimestamp:o,methods:r==null?void 0:r.methods});return this.events.emit(Ys.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r==null?void 0:r.transportType}),{topic:n,uri:l}}),ae(this,"pair",async r=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:r==null?void 0:r.uri,trace:[rs.pairing_started]}});this.isValidPair(r,i);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=gl(r.uri);i.props.properties.topic=n,i.addTrace(rs.pairing_uri_validation_success),i.addTrace(rs.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(n)){if(u=this.pairings.get(n),i.addTrace(rs.existing_pairing),u.active)throw i.setError(fs.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);i.addTrace(rs.pairing_not_expired)}const h=c||zi(q.FIVE_MINUTES),d={topic:n,relay:a,expiry:h,active:!1,methods:l};this.core.expirer.set(n,h),await this.pairings.set(n,d),i.addTrace(rs.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(Ys.create,d),i.addTrace(rs.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),i.addTrace(rs.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(fs.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(g){throw i.setError(fs.subscribe_pairing_topic_failure),g}return i.addTrace(rs.subscribe_pairing_topic_success),d}),ae(this,"activate",async({topic:r})=>{this.isInitialized();const i=zi(q.FIVE_MINUTES);this.core.expirer.set(r,i),await this.pairings.update(r,{active:!0,expiry:i})}),ae(this,"ping",async r=>{this.isInitialized(),await this.isValidPing(r),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=r;if(this.pairings.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=ig();this.events.once(Po("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),ae(this,"updateExpiry",async({topic:r,expiry:i})=>{this.isInitialized(),await this.pairings.update(r,{expiry:i})}),ae(this,"updateMetadata",async({topic:r,metadata:i})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:i})}),ae(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ae(this,"disconnect",async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Bi("USER_DISCONNECTED")),await this.deletePairing(i))}),ae(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:i,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(i);return ml({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),ae(this,"sendRequest",async(r,i,n)=>{const o=Qs(i,n),a=await this.core.crypto.encode(r,o),c=_i[i].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),ae(this,"sendResult",async(r,i,n)=>{const o=io(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=_i[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ae(this,"sendError",async(r,i,n)=>{const o=oh(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=_i[c]?_i[c].res:_i.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ae(this,"deletePairing",async(r,i)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,Bi("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),i?Promise.resolve():this.core.expirer.del(r)])}),ae(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(i=>Wc(i.expiry));await Promise.all(r.map(i=>this.deletePairing(i.topic)))}),ae(this,"onRelayEventRequest",async r=>{const{topic:i,payload:n}=r;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,n);default:return await this.onUnknownRpcMethodRequest(i,n)}}),ae(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n}=r,o=(await this.core.history.get(i,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,n);default:return this.onUnknownRpcMethodResponse(o)}}),ae(this,"onPairingPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(Ys.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ae(this,"onPairingPingResponse",(r,i)=>{const{id:n}=i;setTimeout(()=>{ps(i)?this.events.emit(Po("pairing_ping",n),{}):is(i)&&this.events.emit(Po("pairing_ping",n),{error:i.error})},500)}),ae(this,"onPairingDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(Ys.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ae(this,"onUnknownRpcMethodRequest",async(r,i)=>{const{id:n,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Bi("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,r,a),this.logger.error(a)}catch(a){await this.sendError(n,r,a),this.logger.error(a)}}),ae(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(Bi("WC_METHOD_UNSUPPORTED",r))}),ae(this,"isValidPair",(r,i)=>{var n;if(!Mo(r)){const{message:a}=be("MISSING_OR_INVALID",`pair() params: ${r}`);throw i.setError(fs.malformed_pairing_uri),new Error(a)}if(!dw(r.uri)){const{message:a}=be("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw i.setError(fs.malformed_pairing_uri),new Error(a)}const o=gl(r==null?void 0:r.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=be("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(fs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=be("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(fs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&q.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(fs.pairing_expired);const{message:a}=be("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ae(this,"isValidPing",async r=>{if(!Mo(r)){const{message:n}=be("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ae(this,"isValidDisconnect",async r=>{if(!Mo(r)){const{message:n}=be("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ae(this,"isValidPairingTopic",async r=>{if(!Gh(r)){const{message:i}=be("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.pairings.keys.includes(r)){const{message:i}=be("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(Wc(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:i}=be("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}),this.core=e,this.logger=ht(s,this.name),this.pairings=new yr(this.core,this.logger,this.name,this.storagePrefix)}get context(){return kt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ve.message,async e=>{const{topic:s,message:r,transportType:i}=e;if(this.pairings.keys.includes(s)&&i!==$e.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(s,r);ic(n)?(this.core.history.set(s,n),await this.onRelayEventRequest({topic:s,payload:n})):nc(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:s,payload:n}),this.core.history.delete(s,n.id)),await this.core.relayer.messages.ack(s,r)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(Mt.expired,async e=>{const{topic:s}=ag(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(Ys.expire,{topic:s}))})}};var B0=Object.defineProperty,M0=(t,e,s)=>e in t?B0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,et=(t,e,s)=>M0(t,typeof e!="symbol"?e+"":e,s);let q0=class extends Rf{constructor(e,s){super(e,s),this.core=e,this.logger=s,et(this,"records",new Map),et(this,"events",new pr.EventEmitter),et(this,"name",Fw),et(this,"version",Ww),et(this,"cached",[]),et(this,"initialized",!1),et(this,"storagePrefix",cs),et(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.records.set(r.id,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),et(this,"set",(r,i,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:r,request:i,chainId:n}),this.records.has(i.id))return;const o={id:i.id,topic:r,request:{method:i.method,params:i.params||null},chainId:n,expiry:zi(q.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Wt.created,o)}),et(this,"resolve",async r=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:r}),!this.records.has(r.id))return;const i=await this.getRecord(r.id);typeof i.response>"u"&&(i.response=is(r)?{error:r.error}:{result:r.result},this.records.set(i.id,i),this.persist(),this.events.emit(Wt.updated,i))}),et(this,"get",async(r,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:r,id:i}),await this.getRecord(i))),et(this,"delete",(r,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(n=>{if(n.topic===r){if(typeof i<"u"&&n.id!==i)return;this.records.delete(n.id),this.events.emit(Wt.deleted,n)}}),this.persist()}),et(this,"exists",async(r,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===r:!1)),et(this,"on",(r,i)=>{this.events.on(r,i)}),et(this,"once",(r,i)=>{this.events.once(r,i)}),et(this,"off",(r,i)=>{this.events.off(r,i)}),et(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ht(s,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(s=>{if(typeof s.response<"u")return;const r={topic:s.topic,request:Qs(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const s=this.records.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Wt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Wt.created,e=>{const s=Wt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Wt.updated,e=>{const s=Wt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Wt.deleted,e=>{const s=Wt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(wi.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{q.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(Wt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var j0=Object.defineProperty,F0=(t,e,s)=>e in t?j0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,rt=(t,e,s)=>F0(t,typeof e!="symbol"?e+"":e,s);let W0=class extends qf{constructor(e,s){super(e,s),this.core=e,this.logger=s,rt(this,"expirations",new Map),rt(this,"events",new pr.EventEmitter),rt(this,"name",Hw),rt(this,"version",zw),rt(this,"cached",[]),rt(this,"initialized",!1),rt(this,"storagePrefix",cs),rt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.expirations.set(r.target,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),rt(this,"has",r=>{try{const i=this.formatTarget(r);return typeof this.getExpiration(i)<"u"}catch{return!1}}),rt(this,"set",(r,i)=>{this.isInitialized();const n=this.formatTarget(r),o={target:n,expiry:i};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Mt.created,{target:n,expiration:o})}),rt(this,"get",r=>{this.isInitialized();const i=this.formatTarget(r);return this.getExpiration(i)}),rt(this,"del",r=>{if(this.isInitialized(),this.has(r)){const i=this.formatTarget(r),n=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Mt.deleted,{target:i,expiration:n})}}),rt(this,"on",(r,i)=>{this.events.on(r,i)}),rt(this,"once",(r,i)=>{this.events.once(r,i)}),rt(this,"off",(r,i)=>{this.events.off(r,i)}),rt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ht(s,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return ng(e);if(typeof e=="number")return og(e);const{message:s}=be("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Mt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const s=this.expirations.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return s}checkExpiry(e,s){const{expiry:r}=s;q.toMiliseconds(r)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(Mt.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(wi.pulse,()=>this.checkExpirations()),this.events.on(Mt.created,e=>{const s=Mt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(Mt.expired,e=>{const s=Mt.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(Mt.deleted,e=>{const s=Mt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var H0=Object.defineProperty,z0=(t,e,s)=>e in t?H0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Be=(t,e,s)=>z0(t,typeof e!="symbol"?e+"":e,s);let V0=class extends jf{constructor(e,s,r){super(e,s,r),this.core=e,this.logger=s,this.store=r,Be(this,"name",Vw),Be(this,"abortController"),Be(this,"isDevEnv"),Be(this,"verifyUrlV3",Gw),Be(this,"storagePrefix",cs),Be(this,"version",Yh),Be(this,"publicKey"),Be(this,"fetchPromise"),Be(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&q.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Be(this,"register",async i=>{if(!fn()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const l=Tt.getDocument(),u=this.startAbortTimer(q.ONE_SECOND*5),h=await new Promise((d,g)=>{const y=()=>{window.removeEventListener("message",p),l.body.removeChild(f),g("attestation aborted")};this.abortController.signal.addEventListener("abort",y);const f=l.createElement("iframe");f.src=c,f.style.display="none",f.addEventListener("error",y,{signal:this.abortController.signal});const p=m=>{if(m.data&&typeof m.data=="string")try{const w=JSON.parse(m.data);if(w.type==="verify_attestation"){if(fa(w.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(f),this.abortController.signal.removeEventListener("abort",y),window.removeEventListener("message",p),d(w.attestation===null?"":w.attestation)}}catch(w){this.logger.warn(w)}};l.body.appendChild(f),window.addEventListener("message",p,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(l){this.logger.warn(l)}return""}),Be(this,"resolve",async i=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=i;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(fa(n).payload.id!==a)return;const l=await this.isValidJwtAttestation(n);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),Be(this,"fetchAttestation",async(i,n)=>{this.logger.debug(`resolving attestation: ${i} from url: ${n}`);const o=this.startAbortTimer(q.ONE_SECOND*5),a=await fetch(`${n}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),Be(this,"getVerifyUrl",i=>{let n=i||Ki;return Jw.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Ki}`),n=Ki),n}),Be(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(q.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await n.json()}catch(i){this.logger.warn(i)}}),Be(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),Be(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Be(this,"isValidJwtAttestation",async i=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(i,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),Be(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Be(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i}),Be(this,"validateAttestation",(i,n)=>{const o=nw(i,n.publicKey),a={hasExpired:q.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=ht(s,this.name),this.abortController=new AbortController,this.isDevEnv=wh(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return kt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),q.toMiliseconds(e))}};var K0=Object.defineProperty,G0=(t,e,s)=>e in t?K0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Bl=(t,e,s)=>G0(t,typeof e!="symbol"?e+"":e,s);let J0=class extends Ff{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,Bl(this,"context",Yw),Bl(this,"registerDeviceToken",async r=>{const{clientId:i,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${Zw}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:n,always_raw:a})})}),this.logger=ht(s,this.context)}};var Y0=Object.defineProperty,Ml=Object.getOwnPropertySymbols,Z0=Object.prototype.hasOwnProperty,X0=Object.prototype.propertyIsEnumerable,qa=(t,e,s)=>e in t?Y0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Oi=(t,e)=>{for(var s in e||(e={}))Z0.call(e,s)&&qa(t,s,e[s]);if(Ml)for(var s of Ml(e))X0.call(e,s)&&qa(t,s,e[s]);return t},je=(t,e,s)=>qa(t,typeof e!="symbol"?e+"":e,s);class Q0 extends Wf{constructor(e,s,r=!0){super(e,s,r),this.core=e,this.logger=s,je(this,"context",Qw),je(this,"storagePrefix",cs),je(this,"storageVersion",Xw),je(this,"events",new Map),je(this,"shouldPersist",!1),je(this,"init",async()=>{if(!wh())try{const i={eventId:Hc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:gh(this.core.relayer.protocol,this.core.relayer.version,ka)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),je(this,"createEvent",i=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=Hc(),u=this.core.projectId||"",h=Date.now(),d=Oi({eventId:l,timestamp:h,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d}),je(this,"getEvent",i=>{const{eventId:n,topic:o}=i;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Oi(Oi({},a),this.setMethods(a.eventId))}),je(this,"deleteEvent",i=>{const{eventId:n}=i;this.events.delete(n),this.shouldPersist=!0}),je(this,"setEventListeners",()=>{this.core.heartbeat.on(wi.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{q.fromMiliseconds(Date.now())-q.fromMiliseconds(i.timestamp)>ey&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),je(this,"setMethods",i=>({addTrace:n=>this.addTrace(i,n),setError:n=>this.setError(i,n)})),je(this,"addTrace",(i,n)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(n),this.events.set(i,o),this.shouldPersist=!0)}),je(this,"setError",(i,n)=>{const o=this.events.get(i);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)}),je(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),je(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(n=>{this.events.set(n.eventId,Oi(Oi({},n),this.setMethods(n.eventId)))})}catch(i){this.logger.warn(i)}}),je(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[n,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const n of i)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),je(this,"sendEvent",async i=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${ty}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${ka}${n}`,{method:"POST",body:JSON.stringify(i)})}),je(this,"getAppDomain",()=>eg().url),this.logger=ht(s,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var ev=Object.defineProperty,ql=Object.getOwnPropertySymbols,tv=Object.prototype.hasOwnProperty,sv=Object.prototype.propertyIsEnumerable,ja=(t,e,s)=>e in t?ev(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jl=(t,e)=>{for(var s in e||(e={}))tv.call(e,s)&&ja(t,s,e[s]);if(ql)for(var s of ql(e))sv.call(e,s)&&ja(t,s,e[s]);return t},Te=(t,e,s)=>ja(t,typeof e!="symbol"?e+"":e,s);let rv=class ud extends Tf{constructor(e){var s;super(e),Te(this,"protocol",Jh),Te(this,"version",Yh),Te(this,"name",$a),Te(this,"relayUrl"),Te(this,"projectId"),Te(this,"customStoragePrefix"),Te(this,"events",new pr.EventEmitter),Te(this,"logger"),Te(this,"heartbeat"),Te(this,"relayer"),Te(this,"crypto"),Te(this,"storage"),Te(this,"history"),Te(this,"expirer"),Te(this,"pairing"),Te(this,"verify"),Te(this,"echoClient"),Te(this,"linkModeSupportedApps"),Te(this,"eventClient"),Te(this,"initialized",!1),Te(this,"logChunkController"),Te(this,"on",(a,c)=>this.events.on(a,c)),Te(this,"once",(a,c)=>this.events.once(a,c)),Te(this,"off",(a,c)=>this.events.off(a,c)),Te(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Te(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:$e.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const r=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Xh,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=hn({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Iw.logger,name:$a}),{logger:n,chunkLoggerController:o}=nh({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(s=this.logChunkController)!=null&&s.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=ht(n,this.name),this.heartbeat=new fp,this.crypto=new Tb(this,this.logger,e==null?void 0:e.keychain),this.history=new q0(this,this.logger),this.expirer=new W0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new gp(jl(jl({},Aw),e==null?void 0:e.storageOptions)),this.relayer=new r0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new L0(this,this.logger),this.verify=new V0(this,this.logger,this.storage),this.echoClient=new J0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Q0(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new ud(e);await s.initialize();const r=await s.crypto.getClientId();return await s.storage.setItem(Lw,r),s}get context(){return kt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(vl,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(vl)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,r=`${s}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[r]=e}catch(r){console.warn("Failed to set global WalletConnect core",r)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&Cw.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const iv=rv;var nv={};const ov=":";function Zr(t){const[e,s]=t.split(ov);return{namespace:e,reference:s}}function hd(t,e){return t.includes(":")?[t]:e.chains||[]}var av=Object.defineProperty,cv=Object.defineProperties,lv=Object.getOwnPropertyDescriptors,Fl=Object.getOwnPropertySymbols,uv=Object.prototype.hasOwnProperty,hv=Object.prototype.propertyIsEnumerable,Wl=(t,e,s)=>e in t?av(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Hl=(t,e)=>{for(var s in e||(e={}))uv.call(e,s)&&Wl(t,s,e[s]);if(Fl)for(var s of Fl(e))hv.call(e,s)&&Wl(t,s,e[s]);return t},dv=(t,e)=>cv(t,lv(e));const pv="ReactNative",Kr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function dd(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function pd(){return!Tt.getDocument()&&!!Tt.getNavigator()&&navigator.product===pv}function fd(){return!dd()&&!!Tt.getNavigator()&&!!Tt.getDocument()}function fv(){return pd()?Kr.reactNative:dd()?Kr.node:fd()?Kr.browser:Kr.unknown}function gv(t){var e,s;const r=mv();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),dv(Hl(Hl({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),t||r}}function mv(){return ih.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function er(t,e){return t.filter(s=>e.includes(s)).length===t.length}function Ar(t=q.FIVE_MINUTES,e){const s=q.toMiliseconds(t||q.FIVE_MINUTES);let r,i,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&i&&(clearTimeout(n),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),r=a,i=c})}}function wv(t){const[e,s]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")r.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))r.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return r}function mt(t,e){return q.fromMiliseconds(Date.now()+q.toMiliseconds(t))}function Nr(t){return Date.now()>=q.toMiliseconds(t)}function _e(t,e){return`${t}${e?`:${e}`:""}`}function as(t=[],e=[]){return[...new Set([...t,...e])]}async function yv({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i==null?void 0:i.href;if(typeof n!="string")return;const o=bv(n,t,e),a=fv();if(a===Kr.browser){if(!((r=Tt.getDocument())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}vv(o)}else a===Kr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function bv(t,e,s){const r=`requestId=${e}&sessionTopic=${s}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${n}${Nv(r,!0)}`}else i=`${i}/wc?${r}`;return i}function vv(t){let e="_self";Av()?e="_top":(Iv()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Ev(t,e){let s="";try{if(fd()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function zl(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Cv(){return typeof process<"u"&&nv.IS_VITEST==="true"}function Iv(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Av(){try{return window.self!==window.top}catch{return!1}}function Nv(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function Xn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function _v(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function vn(t,...e){if(!_v(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Sv(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Xn(t.outputLen),Xn(t.blockLen)}function ci(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gd(t,e){vn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Tn=BigInt(2**32-1),Vl=BigInt(32);function Pv(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>Vl&Tn)}:{h:Number(t>>Vl&Tn)|0,l:Number(t&Tn)|0}}function Ov(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=Pv(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Tv=(t,e,s)=>t<<s|e>>>32-s,$v=(t,e,s)=>e<<s|t>>>32-s,kv=(t,e,s)=>e<<s-32|t>>>64-s,xv=(t,e,s)=>t<<s-32|e>>>64-s,_r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Rv(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ho(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ts(t,e){return t<<32-e|t>>>e}const Kl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Uv(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Gl(t){for(let e=0;e<t.length;e++)t[e]=Uv(t[e])}function Dv(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function go(t){return typeof t=="string"&&(t=Dv(t)),vn(t),t}function Lv(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];vn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let pc=class{clone(){return this._cloneInto()}};function md(t){const e=r=>t().update(go(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function wd(t=32){if(_r&&typeof _r.getRandomValues=="function")return _r.getRandomValues(new Uint8Array(t));if(_r&&typeof _r.randomBytes=="function")return _r.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const yd=[],bd=[],vd=[],Bv=BigInt(0),Ti=BigInt(1),Mv=BigInt(2),qv=BigInt(7),jv=BigInt(256),Fv=BigInt(113);for(let t=0,e=Ti,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],yd.push(2*(5*r+s)),bd.push((t+1)*(t+2)/2%64);let i=Bv;for(let n=0;n<7;n++)e=(e<<Ti^(e>>qv)*Fv)%jv,e&Mv&&(i^=Ti<<(Ti<<BigInt(n))-Ti);vd.push(i)}const[Wv,Hv]=Ov(vd,!0),Jl=(t,e,s)=>s>32?kv(t,e,s):Tv(t,e,s),Yl=(t,e,s)=>s>32?xv(t,e,s):$v(t,e,s);function zv(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=Jl(l,u,1)^s[a],d=Yl(l,u,1)^s[a+1];for(let g=0;g<50;g+=10)t[o+g]^=h,t[o+g+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=bd[o],c=Jl(i,n,a),l=Yl(i,n,a),u=yd[o];i=t[u],n=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=Wv[r],t[1]^=Hv[r]}s.fill(0)}class fc extends pc{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Xn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Rv(this.state)}keccak(){Kl||Gl(this.state32),zv(this.state32,this.rounds),Kl||Gl(this.state32),this.posOut=0,this.pos=0}update(e){ci(this);const{blockLen:s,state:r}=this;e=go(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,(s&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ci(this,!1),vn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Xn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new fc(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Vv=(t,e,s)=>md(()=>new fc(e,t,s)),Kv=Vv(1,136,256/8),Gv="https://rpc.walletconnect.org/v1";function Ed(t){const e=`Ethereum Signed Message:
|
|
5
5
|
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(Kv(s)).toString("hex")}async function Jv(t,e,s,r,i,n){switch(s.t){case"eip191":return await Yv(t,e,s.s);case"eip1271":return await Zv(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function Yv(t,e,s){return(await Sp({hash:Ed(e),signature:s})).toLowerCase()===t.toLowerCase()}async function Zv(t,e,s,r,i,n){const o=Zr(r);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=s.substring(2),h=Ed(e).substring(2),d=a+h+c+l+u,g=await fetch(`${n||Gv}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:Xv(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:y}=await g.json();return y?y.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Xv(){return Date.now()+Math.floor(Math.random()*1e3)}function Qv(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const r=s[0];if(r===0)throw new Error("No signatures found");const i=1+r*64;if(s.length<i)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return ah.encode(n)}var eE=Object.defineProperty,tE=Object.defineProperties,sE=Object.getOwnPropertyDescriptors,Zl=Object.getOwnPropertySymbols,rE=Object.prototype.hasOwnProperty,iE=Object.prototype.propertyIsEnumerable,Xl=(t,e,s)=>e in t?eE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,nE=(t,e)=>{for(var s in e||(e={}))rE.call(e,s)&&Xl(t,s,e[s]);if(Zl)for(var s of Zl(e))iE.call(e,s)&&Xl(t,s,e[s]);return t},oE=(t,e)=>tE(t,sE(e));const aE="did:pkh:",gc=t=>t==null?void 0:t.split(":"),cE=t=>{const e=t&&gc(t);if(e)return t.includes(aE)?e[3]:e[1]},Fa=t=>{const e=t&&gc(t);if(e)return e[2]+":"+e[3]},Qn=t=>{const e=t&&gc(t);if(e)return e.pop()};async function Ql(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=Cd(i,i.iss),o=Qn(i.iss);return await Jv(o,n,r,Fa(i.iss),s)}const Cd=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=Qn(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${cE(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,g=t.resources?`Resources:${t.resources.map(f=>`
|
|
@@ -904,4 +904,4 @@ ${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(Kv(s)).toStr
|
|
|
904
904
|
.wui-color-fg-350 {
|
|
905
905
|
background-color: var(--wui-color-fg-350);
|
|
906
906
|
}
|
|
907
|
-
`,qi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"]};function In(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const eh=In({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),th=In({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"});In({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});In({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});In({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const BA={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},Gn={getMethodsByChainNamespace(t){return BA[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const s={...t},r=new Set;if(e.methods&&Object.keys(e.methods).forEach(i=>r.add(i)),e.chains&&Object.keys(e.chains).forEach(i=>r.add(i)),e.events&&Object.keys(e.events).forEach(i=>r.add(i)),e.rpcMap&&Object.keys(e.rpcMap).forEach(i=>{const[n]=i.split(":");n&&r.add(n)}),r.forEach(i=>{s[i]||(s[i]=this.createDefaultNamespace(i))}),e.methods&&Object.entries(e.methods).forEach(([i,n])=>{s[i]&&(s[i].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([i,n])=>{s[i]&&(s[i].chains=n)}),e.events&&Object.entries(e.events).forEach(([i,n])=>{s[i]&&(s[i].events=n)}),e.rpcMap){const i=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!s[a]||(s[a].rpcMap||(s[a].rpcMap={}),i.has(a)||(s[a].rpcMap={},i.add(a)),s[a].rpcMap[c]=o)})}return s},createNamespaces(t,e){const s=t.reduce((r,i)=>{const{id:n,chainNamespace:o,rpcUrls:a}=i,c=a.default.http[0];r[o]||(r[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,u=r[o];switch(u.chains.push(l),l){case eh.caipNetworkId:u.chains.push(eh.deprecatedCaipNetworkId);break;case th.caipNetworkId:u.chains.push(th.deprecatedCaipNetworkId);break}return u!=null&&u.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await Hi.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class up{constructor({provider:e,namespace:s}){this.id=K.CONNECTOR_ID.WALLET_CONNECT,this.name=to.ConnectorNamesMap[K.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=to.ConnectorImageIds[K.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=b.getCaipNetworks.bind(b),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=s}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const s=this.getCaipNetworks(),r=B.state.universalProviderConfigOverride,i=Gn.createNamespaces(s,r);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(s=>s.caipNetworkId);return Ji.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:MA})}}const MA=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class qA{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>b.getCaipNetworks(s),e&&this.construct(e)}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.getCaipNetworks(this.namespace)}setAuthProvider(e){this.addConnector({id:K.CONNECTOR_ID.AUTH,type:"AUTH",name:K.CONNECTOR_NAMES.AUTH,provider:e,imageId:to.ConnectorImageIds[K.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const s=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(r=>s.has(r.id)?!1:(s.add(r.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,s){V.setStatus(e,s)}on(e,s){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=V.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof up);if(!e)throw new Error("WalletConnectConnector not found");return e}}class jA extends qA{setUniversalProvider(e){this.addConnector(new up({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,u)=>u.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Pe.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(V.state.balanceLoading&&e.chainId===((c=b.state.activeCaipNetwork)==null?void 0:c.id))return{balance:V.state.balance||"0.00",symbol:V.state.balanceSymbol||""};const i=(await V.fetchTokenBalance()).find(u=>{var h,d;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===K.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:ah.encode(new TextEncoder().encode(r)),pubkey:i}},(a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=b.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===K.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:Tc(s.id)}]}))}catch(u){if(u.code===qi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===qi.ERROR_INVALID_CHAIN_ID||u.code===qi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===qi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Tc(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const FA=["email","socials","swaps","onramp","activity","reownBranding"],qn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},WA={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=qn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=qn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return qn[t].processApi(e)},processFallbackFeature(t,e){return qn[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let r=null,i=!1;try{r=await J.fetchProjectConfig(),i=r!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=i&&!e?Pe.DEFAULT_REMOTE_FEATURES:Pe.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of FA){const a=this.processFeature(o,s,r,i,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Pe.DEFAULT_REMOTE_FEATURES}if(i&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Gs.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${o}`},"warning")}return n}};class HA{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=b.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(h=>h.id===r);if(c)return c;const l=(o=b.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=b.getRequestedCaipNetworks(s).filter(h=>h.chainNamespace===s))==null?void 0:a[0])}return b.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>b.getCaipNetworks(s),this.getActiveChainNamespace=()=>b.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{b.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>b.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>b.state.activeChain===s||!s?b.state.activeCaipAddress:b.getAccountProp("caipAddress",s),this.setClientId=s=>{Q.setClientId(s)},this.getProvider=s=>xe.getProvider(s),this.getProviderType=s=>xe.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=V.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{V.setCaipAddress(s,r),s&&B.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{V.setBalance(s,r,i)},this.setProfileName=(s,r)=>{V.setProfileName(s,r)},this.setProfileImage=(s,r)=>{V.setProfileImage(s,r)},this.setUser=(s,r)=>{V.setUser(s,r)},this.resetAccount=s=>{V.resetAccount(s)},this.setCaipNetwork=s=>{b.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{b.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{V.setAllAccounts(s,r),B.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{V.setStatus(s,r),H.isConnected()?z.setConnectionStatus("connected"):z.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>b.getAccountProp("address",s),this.setConnectors=s=>{const r=[...H.state.allConnectors,...s];H.setConnectors(r)},this.setConnections=(s,r)=>{ee.setConnections(s,r)},this.fetchIdentity=s=>Q.fetchIdentity(s),this.getReownName=s=>Hi.getNamesForAddress(s),this.getConnectors=()=>H.getConnectors(),this.getConnectorImage=s=>dh.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=xe.getProviderId(r),n=s?{...s,type:i}:void 0;V.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!b.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{V.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{V.removeAddressLabel(s,r)},this.getAddress=s=>b.state.activeChain===s||!s?V.state.address:b.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>b.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{b.resetNetwork(s)},this.addConnector=s=>{H.addConnector(s)},this.resetWcConnection=()=>{ee.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{V.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{V.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{b.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{V.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{B.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await WA.fetchRemoteFeatures(e),B.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&ya.setOnrampProviders(this.remoteFeatures.onramp),((s=B.state.remoteFeatures)!=null&&s.email||Array.isArray((r=B.state.remoteFeatures)==null?void 0:r.socials)&&((i=B.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await J.fetchAllowedOrigins();if(e&&te.isClient()){const s=window.location.origin;Gn.isOriginAllowed(s,e,qi.DEFAULT_ALLOWED_ANCESTORS)||Gs.open(jr.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else Gs.open(jr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Ue.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Nt.setThemeMode(e.themeMode),e.themeVariables&&Nt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");b.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&b.setActiveCaipNetwork(s)}initializeConnectionController(e){ee.setWcBasic(e.basic??!1)}initializeConnectorController(){H.initialize(this.chainNamespaces)}initializeProjectSettings(e){B.setProjectId(e.projectId),B.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;B.setDebug(e.debug!==!1),B.setEnableWalletConnect(e.enableWalletConnect!==!1),B.setEnableWalletGuide(e.enableWalletGuide!==!1),B.setEnableWallets(e.enableWallets!==!1),B.setEIP6963Enabled(e.enableEIP6963!==!1),B.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),B.setEnableAuthLogger(e.enableAuthLogger!==!1),B.setCustomRpcUrls(e.customRpcUrls),B.setEnableEmbedded(e.enableEmbedded),B.setAllWallets(e.allWallets),B.setIncludeWalletIds(e.includeWalletIds),B.setExcludeWalletIds(e.excludeWalletIds),B.setFeaturedWalletIds(e.featuredWalletIds),B.setTokens(e.tokens),B.setTermsConditionsUrl(e.termsConditionsUrl),B.setPrivacyPolicyUrl(e.privacyPolicyUrl),B.setCustomWallets(e.customWallets),B.setFeatures(e.features),B.setAllowUnsupportedChain(e.allowUnsupportedChain),B.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),B.setPreferUniversalLinks(e.experimental_preferUniversalLinks),B.setDefaultAccountTypes(e.defaultAccountTypes);const s=z.getPreferredAccountTypes()||{},r={...B.state.defaultAccountTypes,...s};V.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),B.setMetadata(e.metadata),B.setDisableAppend(e.disableAppend),B.setEnableEmbedded(e.enableEmbedded),B.setSIWX(e.siwx),!e.projectId){Gs.open(jr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===K.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");B.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return te.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=Wr.getUnsupportedNetwork(`${s}:${e}`);b.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Wr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Wr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Wr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?Wr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=xe.getProvider(e),i=xe.getProviderId(e),{caipAddress:n}=b.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),z.removeConnectedNamespace(e),xe.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),H.removeConnectorId(e),b.resetAccount(e),b.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=b.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),z.setConnectedNamespaces([...b.state.chains.keys()]),this.chainNamespaces.forEach(o=>{H.setConnectorId(Os.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var f,p,m,w,C,O;const c=b.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const $=this.getCaipNetworks().find(S=>S.chainNamespace===n);$&&this.setCaipNetwork($)}if(!u)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),d=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((m=(p=(f=o==null?void 0:o.rpcUrls)==null?void 0:f.default)==null?void 0:p.http)==null?void 0:m[0])||((O=(C=(w=h==null?void 0:h.rpcUrls)==null?void 0:w.default)==null?void 0:C.http)==null?void 0:O[0])});if(!d)return;z.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const g=V.state.allAccounts,{accounts:y}=(g==null?void 0:g.length)>0?{accounts:[...g]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(y,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=b.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),z.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=gA(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));ye.resetSend(),ee.resetWcConnection(),await Ji.clearSessions(),H.setFilterByNamespace(void 0);const i=r.filter(n=>n.status==="rejected");if(i.length>0)throw new Error(i.map(n=>n.reason.message).join(", "));z.deleteConnectedSocialProvider(),Ue.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(b.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:V.state.address,provider:xe.getProvider(b.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Pe.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(b.state.activeChain),i=xe.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===K.CHAIN.EVM){const s=this.getAdapter(b.state.activeChain),r=xe.getProvider(b.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:V.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:b.state.activeChain}),V.state.profileImage||!1},getEnsAddress:async e=>await Gn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(b.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=xe.getProvider(b.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!V.state.address||this.updateNativeBalance(V.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ee.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(xe.getProviderId(b.state.activeChain)===Os.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=xe.getProvider(s),n=xe.getProviderId(s);if(e.chainNamespace===b.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===Os.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(s);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const r=s.chains||[],i=s.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Cs.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...r,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,r)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new jA({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=z.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(z.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=b.state.activeChain===e,c=b.getAccountProp("address",e);if(o){const l=a&&i?i:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),s.on("disconnect",this.disconnect.bind(this,e)),s.on("connections",i=>{this.setConnections(i,e)}),s.on("pendingTransactions",()=>{const i=V.state.address,n=b.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=b.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=b.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=b.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===K.CHAIN.EVM&&te.isSafeApp()&&H.setConnectorId(K.CONNECTOR_ID.SAFE,e);const s=H.getConnectorId(e);switch(this.setStatus("connecting",e),s){case K.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case K.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var a,c,l;const s=this.getAdapter(e),r=H.getConnectorId(e),i=this.getCaipNetwork(e),o=H.getConnectors(e).find(u=>u.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const u=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(u){const h=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([te.createAccount(e,u.address,"eoa")],e),this.syncProvider({...u,chainNamespace:e}),await this.syncAccount({...u,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,u,h;const r=this.getAdapter(s),i=((u=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:u.accounts)||[],n=(h=b.state.activeCaipNetwork)==null?void 0:h.id,o=i.find(d=>{const{chainId:g}=Cs.parseCaipAddress(d);return g===(n==null?void 0:n.toString())})||i[0];if(o){const d=Cs.validateCaipAddress(o),{chainId:g,address:y}=Cs.parseCaipAddress(d);if(xe.setProviderId(s,Os.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&b.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==K.CHAIN.EVM){const f=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:b.state.activeCaipNetwork});xe.setProvider(s,f)}else xe.setProvider(s,this.universalProvider);H.setConnectorId(K.CONNECTOR_ID.WALLET_CONNECT,s),z.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:y,chainId:g,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await b.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=Cs.parseCaipAddress(c);return l}).filter((c,l,u)=>u.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){xe.setProviderId(i,e),xe.setProvider(i,s),H.setConnectorId(r,i)}async syncAllAccounts(e){const s=H.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var h,d;const s=e.chainNamespace===b.state.activeChain,r=b.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=z.getActiveNetworkProps(),c=n||a,l=((h=b.state.activeCaipNetwork)==null?void 0:h.name)===K.UNSUPPORTED_NETWORK_NAME,u=b.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let g=this.getCaipNetworks().find(p=>p.id.toString()===c.toString()),y=this.getCaipNetworks().find(p=>p.chainNamespace===o);if(!u&&!g&&!y){const p=this.getApprovedCaipNetworkIds()||[],m=p.find(C=>{var O;return((O=Cs.parseCaipNetworkId(C))==null?void 0:O.chainId)===c.toString()}),w=p.find(C=>{var O;return((O=Cs.parseCaipNetworkId(C))==null?void 0:O.chainNamespace)===o});g=this.getCaipNetworks().find(C=>C.caipNetworkId===m),y=this.getCaipNetworks().find(C=>C.caipNetworkId===w||"deprecatedCaipNetworkId"in C&&C.deprecatedCaipNetworkId===w)}const f=g||y;(f==null?void 0:f.chainNamespace)===b.state.activeChain?B.state.enableNetworkSwitch&&!B.state.allowUnsupportedChain&&((d=b.state.activeCaipNetwork)==null?void 0:d.name)===K.UNSUPPORTED_NETWORK_NAME?b.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),Ic.isLowerCaseMatch(i,V.state.address)||this.syncAccountInfo(i,f==null?void 0:f.id,o),s?await this.syncBalance({address:i,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=H.getConnectorId(e),r=xe.getProviderId(e);if(r===Os.CONNECTOR_TYPE_ANNOUNCED||r===Os.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===Os.CONNECTOR_TYPE_WALLET_CONNECT){const n=xe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===K.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===K.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!ch.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=b.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,u,h,d;const e=wA.createLogger((g,...y)=>{g&&this.handleAlertError(g),console.error(...y)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};B.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await fA.init(s),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ee.setUri(e)}),this.universalProvider.on("connect",ee.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ee.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const s=this.getCaipNetworks().find(i=>i.id==e),r=this.getCaipNetwork();if(!s){this.setUnsupportedNetwork(e);return}(r==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(Gn.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&te.isCaipAddress(r[0])&&this.syncAccount(Cs.parseCaipAddress(r[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&te.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Ue.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const s=Object.entries(jr.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=jr.ALERT_ERRORS[o];a&&(Gs.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&ee.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return Ge.open({...e,data:{swap:e.arguments}})}return Ge.open(e)}async close(){await this.injectModalUi(),Ge.close()}setLoading(e,s){Ge.setLoading(e,s)}async disconnect(e){await ee.disconnect(e)}getSIWX(){return B.state.siwx}getError(){return""}getChainId(){var e;return(e=b.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){Gs.open(jr.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await b.switchActiveNetwork(s)}getWalletProvider(){return b.state.activeChain?xe.state.providers[b.state.activeChain]:null}getWalletProviderType(){return xe.getProviderId(b.state.activeChain)}subscribeProviders(e){return xe.subscribeProviders(e)}getThemeMode(){return Nt.state.themeMode}getThemeVariables(){return Nt.state.themeVariables}setThemeMode(e){Nt.setThemeMode(e),lp(Nt.state.themeMode)}setTermsConditionsUrl(e){B.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){B.setPrivacyPolicyUrl(e)}setThemeVariables(e){Nt.setThemeVariables(e),LA(Nt.state.themeVariables)}subscribeTheme(e){return Nt.subscribe(e)}getWalletInfo(){return V.state.connectedWalletInfo}getAccount(e){var o;const s=H.getAuthConnector(e),r=b.getAccountData(e),i=b.state.activeChain,n=z.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:te.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:s&&n===K.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:z.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?b.subscribeChainProp("accountState",r,s):b.subscribe(r),H.subscribe(r)}subscribeNetwork(e){return b.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return V.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){V.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){b.subscribeKey("activeCaipNetwork",e)}getState(){return Rs.state}subscribeState(e){return Rs.subscribe(e)}showErrorMessage(e){Yt.showError(e)}showSuccessMessage(e){Yt.showSuccess(e)}getEvent(){return{...Ue.state}}subscribeEvents(e){return Ue.subscribe(e)}replace(e){ne.replace(e)}redirect(e){ne.push(e)}popTransactionStack(e){ne.popTransactionStack(e)}isOpen(){return Ge.state.open}isTransactionStackEmpty(){return ne.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){B.setFeatures(e)}updateRemoteFeatures(e){B.setRemoteFeatures(e)}updateOptions(e){const r={...B.state||{},...e};B.setOptions(r)}setConnectMethodsOrder(e){B.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){B.setWalletFeaturesOrder(e)}setCollapseWallets(e){B.setCollapseWallets(e)}setSocialsOrder(e){B.setSocialsOrder(e)}getConnectMethodsOrder(){return tc.getConnectOrderMethod(B.state.features,H.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const r=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(i=>i.id===r.id)||b.addNetwork(r)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(i=>i.id===s)&&b.removeNetwork(e,s)}}let sh=!1;class hp extends HA{async open(e){H.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ee.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!sh&&te.isClient()){if(await Sc(()=>import("./basic-bO70Xvle.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),await Sc(()=>import("./w3m-modal-CIUN4uxE.js"),__vite__mapDeps([11,1,2,3,5,6,7,8,9,10])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!B.state.disableAppend&&!B.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}sh=!0}}}const zA="1.7.8";function VA(t){return new hp({...t,basic:!0,sdkVersion:`html-core-${zA}`})}const FN=Object.freeze(Object.defineProperty({__proto__:null,AppKit:hp,createAppKit:VA},Symbol.toStringTag,{value:"Module"}));export{Gs as A,ee as B,b as C,z as D,Ue as E,Pe as F,FN as G,Ge as M,B as O,ne as R,Ji as S,Nt as T,tc as W,xt as a,nt as b,Kn as c,DN as d,qN as e,jN as f,dh as g,Jt as h,Xr as i,bA as j,H as k,V as l,Yt as m,J as n,BN as o,ke as p,te as q,MN as r,ot as s,K as t,rp as u,sc as v,LN as w,Ke as x,fi as y,zn as z};
|
|
907
|
+
`,qi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"]};function In(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const eh=In({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),th=In({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"});In({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});In({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});In({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const BA={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},Gn={getMethodsByChainNamespace(t){return BA[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const s={...t},r=new Set;if(e.methods&&Object.keys(e.methods).forEach(i=>r.add(i)),e.chains&&Object.keys(e.chains).forEach(i=>r.add(i)),e.events&&Object.keys(e.events).forEach(i=>r.add(i)),e.rpcMap&&Object.keys(e.rpcMap).forEach(i=>{const[n]=i.split(":");n&&r.add(n)}),r.forEach(i=>{s[i]||(s[i]=this.createDefaultNamespace(i))}),e.methods&&Object.entries(e.methods).forEach(([i,n])=>{s[i]&&(s[i].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([i,n])=>{s[i]&&(s[i].chains=n)}),e.events&&Object.entries(e.events).forEach(([i,n])=>{s[i]&&(s[i].events=n)}),e.rpcMap){const i=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!s[a]||(s[a].rpcMap||(s[a].rpcMap={}),i.has(a)||(s[a].rpcMap={},i.add(a)),s[a].rpcMap[c]=o)})}return s},createNamespaces(t,e){const s=t.reduce((r,i)=>{const{id:n,chainNamespace:o,rpcUrls:a}=i,c=a.default.http[0];r[o]||(r[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,u=r[o];switch(u.chains.push(l),l){case eh.caipNetworkId:u.chains.push(eh.deprecatedCaipNetworkId);break;case th.caipNetworkId:u.chains.push(th.deprecatedCaipNetworkId);break}return u!=null&&u.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await Hi.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class up{constructor({provider:e,namespace:s}){this.id=K.CONNECTOR_ID.WALLET_CONNECT,this.name=to.ConnectorNamesMap[K.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=to.ConnectorImageIds[K.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=b.getCaipNetworks.bind(b),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=s}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const s=this.getCaipNetworks(),r=B.state.universalProviderConfigOverride,i=Gn.createNamespaces(s,r);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(s=>s.caipNetworkId);return Ji.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:MA})}}const MA=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class qA{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>b.getCaipNetworks(s),e&&this.construct(e)}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.getCaipNetworks(this.namespace)}setAuthProvider(e){this.addConnector({id:K.CONNECTOR_ID.AUTH,type:"AUTH",name:K.CONNECTOR_NAMES.AUTH,provider:e,imageId:to.ConnectorImageIds[K.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const s=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(r=>s.has(r.id)?!1:(s.add(r.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,s){V.setStatus(e,s)}on(e,s){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=V.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof up);if(!e)throw new Error("WalletConnectConnector not found");return e}}class jA extends qA{setUniversalProvider(e){this.addConnector(new up({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,u)=>u.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Pe.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(V.state.balanceLoading&&e.chainId===((c=b.state.activeCaipNetwork)==null?void 0:c.id))return{balance:V.state.balance||"0.00",symbol:V.state.balanceSymbol||""};const i=(await V.fetchTokenBalance()).find(u=>{var h,d;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===K.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:ah.encode(new TextEncoder().encode(r)),pubkey:i}},(a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=b.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===K.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:Tc(s.id)}]}))}catch(u){if(u.code===qi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===qi.ERROR_INVALID_CHAIN_ID||u.code===qi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===qi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Tc(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const FA=["email","socials","swaps","onramp","activity","reownBranding"],qn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},WA={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=qn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=qn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return qn[t].processApi(e)},processFallbackFeature(t,e){return qn[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let r=null,i=!1;try{r=await J.fetchProjectConfig(),i=r!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=i&&!e?Pe.DEFAULT_REMOTE_FEATURES:Pe.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of FA){const a=this.processFeature(o,s,r,i,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Pe.DEFAULT_REMOTE_FEATURES}if(i&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Gs.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${o}`},"warning")}return n}};class HA{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=b.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(h=>h.id===r);if(c)return c;const l=(o=b.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=b.getRequestedCaipNetworks(s).filter(h=>h.chainNamespace===s))==null?void 0:a[0])}return b.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>b.getCaipNetworks(s),this.getActiveChainNamespace=()=>b.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{b.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>b.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>b.state.activeChain===s||!s?b.state.activeCaipAddress:b.getAccountProp("caipAddress",s),this.setClientId=s=>{Q.setClientId(s)},this.getProvider=s=>xe.getProvider(s),this.getProviderType=s=>xe.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=V.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{V.setCaipAddress(s,r),s&&B.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{V.setBalance(s,r,i)},this.setProfileName=(s,r)=>{V.setProfileName(s,r)},this.setProfileImage=(s,r)=>{V.setProfileImage(s,r)},this.setUser=(s,r)=>{V.setUser(s,r)},this.resetAccount=s=>{V.resetAccount(s)},this.setCaipNetwork=s=>{b.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{b.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{V.setAllAccounts(s,r),B.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{V.setStatus(s,r),H.isConnected()?z.setConnectionStatus("connected"):z.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>b.getAccountProp("address",s),this.setConnectors=s=>{const r=[...H.state.allConnectors,...s];H.setConnectors(r)},this.setConnections=(s,r)=>{ee.setConnections(s,r)},this.fetchIdentity=s=>Q.fetchIdentity(s),this.getReownName=s=>Hi.getNamesForAddress(s),this.getConnectors=()=>H.getConnectors(),this.getConnectorImage=s=>dh.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=xe.getProviderId(r),n=s?{...s,type:i}:void 0;V.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!b.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{V.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{V.removeAddressLabel(s,r)},this.getAddress=s=>b.state.activeChain===s||!s?V.state.address:b.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>b.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{b.resetNetwork(s)},this.addConnector=s=>{H.addConnector(s)},this.resetWcConnection=()=>{ee.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{V.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{V.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{b.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{V.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{B.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await WA.fetchRemoteFeatures(e),B.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&ya.setOnrampProviders(this.remoteFeatures.onramp),((s=B.state.remoteFeatures)!=null&&s.email||Array.isArray((r=B.state.remoteFeatures)==null?void 0:r.socials)&&((i=B.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await J.fetchAllowedOrigins();if(e&&te.isClient()){const s=window.location.origin;Gn.isOriginAllowed(s,e,qi.DEFAULT_ALLOWED_ANCESTORS)||Gs.open(jr.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else Gs.open(jr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Ue.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Nt.setThemeMode(e.themeMode),e.themeVariables&&Nt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");b.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&b.setActiveCaipNetwork(s)}initializeConnectionController(e){ee.setWcBasic(e.basic??!1)}initializeConnectorController(){H.initialize(this.chainNamespaces)}initializeProjectSettings(e){B.setProjectId(e.projectId),B.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;B.setDebug(e.debug!==!1),B.setEnableWalletConnect(e.enableWalletConnect!==!1),B.setEnableWalletGuide(e.enableWalletGuide!==!1),B.setEnableWallets(e.enableWallets!==!1),B.setEIP6963Enabled(e.enableEIP6963!==!1),B.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),B.setEnableAuthLogger(e.enableAuthLogger!==!1),B.setCustomRpcUrls(e.customRpcUrls),B.setEnableEmbedded(e.enableEmbedded),B.setAllWallets(e.allWallets),B.setIncludeWalletIds(e.includeWalletIds),B.setExcludeWalletIds(e.excludeWalletIds),B.setFeaturedWalletIds(e.featuredWalletIds),B.setTokens(e.tokens),B.setTermsConditionsUrl(e.termsConditionsUrl),B.setPrivacyPolicyUrl(e.privacyPolicyUrl),B.setCustomWallets(e.customWallets),B.setFeatures(e.features),B.setAllowUnsupportedChain(e.allowUnsupportedChain),B.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),B.setPreferUniversalLinks(e.experimental_preferUniversalLinks),B.setDefaultAccountTypes(e.defaultAccountTypes);const s=z.getPreferredAccountTypes()||{},r={...B.state.defaultAccountTypes,...s};V.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),B.setMetadata(e.metadata),B.setDisableAppend(e.disableAppend),B.setEnableEmbedded(e.enableEmbedded),B.setSIWX(e.siwx),!e.projectId){Gs.open(jr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===K.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");B.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return te.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=Wr.getUnsupportedNetwork(`${s}:${e}`);b.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Wr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Wr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Wr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?Wr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=xe.getProvider(e),i=xe.getProviderId(e),{caipAddress:n}=b.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),z.removeConnectedNamespace(e),xe.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),H.removeConnectorId(e),b.resetAccount(e),b.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=b.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),z.setConnectedNamespaces([...b.state.chains.keys()]),this.chainNamespaces.forEach(o=>{H.setConnectorId(Os.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var f,p,m,w,C,O;const c=b.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const $=this.getCaipNetworks().find(S=>S.chainNamespace===n);$&&this.setCaipNetwork($)}if(!u)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),d=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((m=(p=(f=o==null?void 0:o.rpcUrls)==null?void 0:f.default)==null?void 0:p.http)==null?void 0:m[0])||((O=(C=(w=h==null?void 0:h.rpcUrls)==null?void 0:w.default)==null?void 0:C.http)==null?void 0:O[0])});if(!d)return;z.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const g=V.state.allAccounts,{accounts:y}=(g==null?void 0:g.length)>0?{accounts:[...g]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(y,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=b.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),z.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=gA(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));ye.resetSend(),ee.resetWcConnection(),await Ji.clearSessions(),H.setFilterByNamespace(void 0);const i=r.filter(n=>n.status==="rejected");if(i.length>0)throw new Error(i.map(n=>n.reason.message).join(", "));z.deleteConnectedSocialProvider(),Ue.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(b.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:V.state.address,provider:xe.getProvider(b.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Pe.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(b.state.activeChain),i=xe.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===K.CHAIN.EVM){const s=this.getAdapter(b.state.activeChain),r=xe.getProvider(b.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:V.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:b.state.activeChain}),V.state.profileImage||!1},getEnsAddress:async e=>await Gn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(b.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=xe.getProvider(b.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!V.state.address||this.updateNativeBalance(V.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ee.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(xe.getProviderId(b.state.activeChain)===Os.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=xe.getProvider(s),n=xe.getProviderId(s);if(e.chainNamespace===b.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===Os.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(s);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const r=s.chains||[],i=s.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Cs.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...r,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,r)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new jA({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=z.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(z.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=b.state.activeChain===e,c=b.getAccountProp("address",e);if(o){const l=a&&i?i:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),s.on("disconnect",this.disconnect.bind(this,e)),s.on("connections",i=>{this.setConnections(i,e)}),s.on("pendingTransactions",()=>{const i=V.state.address,n=b.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=b.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=b.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=b.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===K.CHAIN.EVM&&te.isSafeApp()&&H.setConnectorId(K.CONNECTOR_ID.SAFE,e);const s=H.getConnectorId(e);switch(this.setStatus("connecting",e),s){case K.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case K.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var a,c,l;const s=this.getAdapter(e),r=H.getConnectorId(e),i=this.getCaipNetwork(e),o=H.getConnectors(e).find(u=>u.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const u=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(u){const h=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([te.createAccount(e,u.address,"eoa")],e),this.syncProvider({...u,chainNamespace:e}),await this.syncAccount({...u,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,u,h;const r=this.getAdapter(s),i=((u=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:u.accounts)||[],n=(h=b.state.activeCaipNetwork)==null?void 0:h.id,o=i.find(d=>{const{chainId:g}=Cs.parseCaipAddress(d);return g===(n==null?void 0:n.toString())})||i[0];if(o){const d=Cs.validateCaipAddress(o),{chainId:g,address:y}=Cs.parseCaipAddress(d);if(xe.setProviderId(s,Os.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&b.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==K.CHAIN.EVM){const f=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:b.state.activeCaipNetwork});xe.setProvider(s,f)}else xe.setProvider(s,this.universalProvider);H.setConnectorId(K.CONNECTOR_ID.WALLET_CONNECT,s),z.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:y,chainId:g,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await b.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=Cs.parseCaipAddress(c);return l}).filter((c,l,u)=>u.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){xe.setProviderId(i,e),xe.setProvider(i,s),H.setConnectorId(r,i)}async syncAllAccounts(e){const s=H.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var h,d;const s=e.chainNamespace===b.state.activeChain,r=b.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=z.getActiveNetworkProps(),c=n||a,l=((h=b.state.activeCaipNetwork)==null?void 0:h.name)===K.UNSUPPORTED_NETWORK_NAME,u=b.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let g=this.getCaipNetworks().find(p=>p.id.toString()===c.toString()),y=this.getCaipNetworks().find(p=>p.chainNamespace===o);if(!u&&!g&&!y){const p=this.getApprovedCaipNetworkIds()||[],m=p.find(C=>{var O;return((O=Cs.parseCaipNetworkId(C))==null?void 0:O.chainId)===c.toString()}),w=p.find(C=>{var O;return((O=Cs.parseCaipNetworkId(C))==null?void 0:O.chainNamespace)===o});g=this.getCaipNetworks().find(C=>C.caipNetworkId===m),y=this.getCaipNetworks().find(C=>C.caipNetworkId===w||"deprecatedCaipNetworkId"in C&&C.deprecatedCaipNetworkId===w)}const f=g||y;(f==null?void 0:f.chainNamespace)===b.state.activeChain?B.state.enableNetworkSwitch&&!B.state.allowUnsupportedChain&&((d=b.state.activeCaipNetwork)==null?void 0:d.name)===K.UNSUPPORTED_NETWORK_NAME?b.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),Ic.isLowerCaseMatch(i,V.state.address)||this.syncAccountInfo(i,f==null?void 0:f.id,o),s?await this.syncBalance({address:i,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=H.getConnectorId(e),r=xe.getProviderId(e);if(r===Os.CONNECTOR_TYPE_ANNOUNCED||r===Os.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===Os.CONNECTOR_TYPE_WALLET_CONNECT){const n=xe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===K.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===K.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!ch.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=b.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,u,h,d;const e=wA.createLogger((g,...y)=>{g&&this.handleAlertError(g),console.error(...y)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};B.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await fA.init(s),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ee.setUri(e)}),this.universalProvider.on("connect",ee.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ee.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const s=this.getCaipNetworks().find(i=>i.id==e),r=this.getCaipNetwork();if(!s){this.setUnsupportedNetwork(e);return}(r==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(Gn.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&te.isCaipAddress(r[0])&&this.syncAccount(Cs.parseCaipAddress(r[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&te.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Ue.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const s=Object.entries(jr.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=jr.ALERT_ERRORS[o];a&&(Gs.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&ee.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return Ge.open({...e,data:{swap:e.arguments}})}return Ge.open(e)}async close(){await this.injectModalUi(),Ge.close()}setLoading(e,s){Ge.setLoading(e,s)}async disconnect(e){await ee.disconnect(e)}getSIWX(){return B.state.siwx}getError(){return""}getChainId(){var e;return(e=b.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){Gs.open(jr.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await b.switchActiveNetwork(s)}getWalletProvider(){return b.state.activeChain?xe.state.providers[b.state.activeChain]:null}getWalletProviderType(){return xe.getProviderId(b.state.activeChain)}subscribeProviders(e){return xe.subscribeProviders(e)}getThemeMode(){return Nt.state.themeMode}getThemeVariables(){return Nt.state.themeVariables}setThemeMode(e){Nt.setThemeMode(e),lp(Nt.state.themeMode)}setTermsConditionsUrl(e){B.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){B.setPrivacyPolicyUrl(e)}setThemeVariables(e){Nt.setThemeVariables(e),LA(Nt.state.themeVariables)}subscribeTheme(e){return Nt.subscribe(e)}getWalletInfo(){return V.state.connectedWalletInfo}getAccount(e){var o;const s=H.getAuthConnector(e),r=b.getAccountData(e),i=b.state.activeChain,n=z.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:te.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:s&&n===K.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:z.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?b.subscribeChainProp("accountState",r,s):b.subscribe(r),H.subscribe(r)}subscribeNetwork(e){return b.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return V.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){V.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){b.subscribeKey("activeCaipNetwork",e)}getState(){return Rs.state}subscribeState(e){return Rs.subscribe(e)}showErrorMessage(e){Yt.showError(e)}showSuccessMessage(e){Yt.showSuccess(e)}getEvent(){return{...Ue.state}}subscribeEvents(e){return Ue.subscribe(e)}replace(e){ne.replace(e)}redirect(e){ne.push(e)}popTransactionStack(e){ne.popTransactionStack(e)}isOpen(){return Ge.state.open}isTransactionStackEmpty(){return ne.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){B.setFeatures(e)}updateRemoteFeatures(e){B.setRemoteFeatures(e)}updateOptions(e){const r={...B.state||{},...e};B.setOptions(r)}setConnectMethodsOrder(e){B.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){B.setWalletFeaturesOrder(e)}setCollapseWallets(e){B.setCollapseWallets(e)}setSocialsOrder(e){B.setSocialsOrder(e)}getConnectMethodsOrder(){return tc.getConnectOrderMethod(B.state.features,H.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const r=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(i=>i.id===r.id)||b.addNetwork(r)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(i=>i.id===s)&&b.removeNetwork(e,s)}}let sh=!1;class hp extends HA{async open(e){H.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ee.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!sh&&te.isClient()){if(await Sc(()=>import("./basic-xSJded8g.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),await Sc(()=>import("./w3m-modal-CLSVKDRP.js"),__vite__mapDeps([11,1,2,3,5,6,7,8,9,10])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!B.state.disableAppend&&!B.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}sh=!0}}}const zA="1.7.8";function VA(t){return new hp({...t,basic:!0,sdkVersion:`html-core-${zA}`})}const FN=Object.freeze(Object.defineProperty({__proto__:null,AppKit:hp,createAppKit:VA},Symbol.toStringTag,{value:"Module"}));export{Gs as A,ee as B,b as C,z as D,Ue as E,Pe as F,FN as G,Ge as M,B as O,ne as R,Ji as S,Nt as T,tc as W,xt as a,nt as b,Kn as c,DN as d,qN as e,jN as f,dh as g,Jt as h,Xr as i,bA as j,H as k,V as l,Yt as m,J as n,BN as o,ke as p,te as q,MN as r,ot as s,K as t,rp as u,sc as v,LN as w,Ke as x,fi as y,zn as z};
|