@dcl/explorer-website 2.6.1-25865517797.commit-b7a7cba → 2.7.0

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.
Files changed (141) hide show
  1. package/assets/{ConstantsUtil-ByjAYmvC.js → ConstantsUtil-BYRHWuZV.js} +1 -1
  2. package/assets/{ExchangeController-Bp8ztJrX.js → ExchangeController-N42lbf3C.js} +1 -1
  3. package/assets/{HelpersUtil-Dp4e1zvd.js → HelpersUtil-DFmhrbIH.js} +1 -1
  4. package/assets/{NetworkUtil-DqGcuBfF.js → NetworkUtil-DM5H1DOt.js} +1 -1
  5. package/assets/{SwapController-DUCq2f7d.js → SwapController-SgAc8zJM.js} +1 -1
  6. package/assets/{W3MFrameProviderSingleton-9eitOT0j.js → W3MFrameProviderSingleton-dGwr0u32.js} +3 -3
  7. package/assets/{basic-C7tUDecp.js → basic-CDUVa7W3.js} +1 -1
  8. package/assets/{biconomy-plHCR2Qq.js → biconomy-Dj37CYYZ.js} +1 -1
  9. package/assets/{browser-VYI7gorG.js → browser-h4rN6CV4.js} +1 -1
  10. package/assets/browser-ponyfill-LG9Rjmfj.js +1 -0
  11. package/assets/{ccip-Bldffu31.js → ccip-Cv_5kGJ0.js} +1 -1
  12. package/assets/{ccip-CrAifiNa.js → ccip-TlIoUAte.js} +1 -1
  13. package/assets/{chains-DTVDhUwv.js → chains-CsuV2rnE.js} +1 -1
  14. package/assets/{common-BEf2T7Hi.js → common-C9wbti_7.js} +1 -1
  15. package/assets/{controller-B8Iy-6V9.js → controller-DpEeOSLx.js} +2 -2
  16. package/assets/{core-XFvzSI58.js → core-BGvtiIgG.js} +4 -4
  17. package/assets/{custom-cPmISGcH.js → custom-BbQhcg55.js} +1 -1
  18. package/assets/{data-capture-DnvAEYWK.js → data-capture-C5UoNnMk.js} +1 -1
  19. package/assets/decimals-DA8L6Gte.js +1 -0
  20. package/assets/{decimals-8g2-fBFa.js → decimals-mBEEumco.js} +1 -1
  21. package/assets/{detectExtension-yvI5WWZb.js → detectExtension-oDT7CrDk.js} +1 -1
  22. package/assets/{email-C8DRQjTT.js → email-CUatRSQC.js} +1 -1
  23. package/assets/{embedded-wallet-BxgtT1uV.js → embedded-wallet-DZAeJhJN.js} +1 -1
  24. package/assets/{engine-BERe87yT.js → engine-AXDB-0h6.js} +1 -1
  25. package/assets/{estimate-l1-fee-BTeKvFv5.js → estimate-l1-fee-Bxwscz8f.js} +1 -1
  26. package/assets/eth_estimateGas-DFXalA2X.js +1 -0
  27. package/assets/{eth_getStorageAt-SbVMAQY-.js → eth_getStorageAt-Dr4zmiJF.js} +1 -1
  28. package/assets/{eth_getTransactionCount-qv0oO1Md.js → eth_getTransactionCount-cZacEETx.js} +1 -1
  29. package/assets/{ethereum-BP59xYBe.js → ethereum-CIBzGnJl.js} +1 -1
  30. package/assets/{extractIPFS-BOFlZk7U.js → extractIPFS-Czsz8-sO.js} +1 -1
  31. package/assets/{features-DVWd8_kC.js → features-fx-atM_l.js} +1 -1
  32. package/assets/{fetchTokenMetadata-BaJXN6RH.js → fetchTokenMetadata-uG4nb_Kh.js} +2 -2
  33. package/assets/{fortmatic-DARkeYTE.js → fortmatic-boxtmFta.js} +1 -1
  34. package/assets/get-ecosystem-wallet-info-BI2Fd0Vd.js +1 -0
  35. package/assets/{getBalance-D6wpo61w.js → getBalance-CC2S0qtL.js} +2 -2
  36. package/assets/{getInstalledModules-Dkj379ys.js → getInstalledModules-53n5UYt2.js} +1 -1
  37. package/assets/{getNFT-HMkoXD7L.js → getNFT-C3FPakLN.js} +2 -2
  38. package/assets/{getNFT-Drn4rxrk.js → getNFT-CnaK4j2q.js} +1 -1
  39. package/assets/{hashTypedData-CMDSWYgs.js → hashTypedData-C4JiqOxU.js} +1 -1
  40. package/assets/{hashTypedData-B5shS-rs.js → hashTypedData-D1Ievn97.js} +1 -1
  41. package/assets/{in-app-wallet-calls-l9-2W_Em.js → in-app-wallet-calls-khLeeKNu.js} +1 -1
  42. package/assets/{index-BIPd_vR5.js → index-0P32tQWj.js} +1 -1
  43. package/assets/{index-DIlwNfpB.js → index-1quVm3wk.js} +1 -1
  44. package/assets/{index-DbAu4Peg.js → index-B2PoGJRP.js} +3 -3
  45. package/assets/{index-BaGjqMte.js → index-B5w_jZpc.js} +2 -2
  46. package/assets/{index-CE5G6IEJ.js → index-B6j-Tckn.js} +1 -1
  47. package/assets/{index-CjiwjbqL.js → index-BCiKer83.js} +1 -1
  48. package/assets/{index-C8NSq3HK.js → index-BCqrDgyR.js} +1 -1
  49. package/assets/{index-BXAxcybX.js → index-BE5nQY53.js} +1 -1
  50. package/assets/{index-C51HwlD0.js → index-BF9Yx_yV.js} +1 -1
  51. package/assets/{index-CWGeCZBJ.js → index-BJCYEGPg.js} +1 -1
  52. package/assets/{index-Cy1X3n_C.js → index-BT0xQ-Xd.js} +1 -1
  53. package/assets/{index-0ShVRzxt.js → index-BVi4iI8y.js} +1 -1
  54. package/assets/{index-BDgZ3gDE.js → index-BVvMg9ZB.js} +1 -1
  55. package/assets/{index-DFE6t65x.js → index-BpxeqYFx.js} +1 -1
  56. package/assets/{index-B5ECjSS9.js → index-Bv6LvzLS.js} +1 -1
  57. package/assets/{index-i4VBSYqA.js → index-BvCGPTHO.js} +1 -1
  58. package/assets/index-Bzi38pjx.css +1 -0
  59. package/assets/{index-CH0zI801.js → index-C5oPclal.js} +1 -1
  60. package/assets/{index-D2ZBQG8w.js → index-C6-AvlPm.js} +1 -1
  61. package/assets/{index-CWnFK_-0.js → index-C9EMW8qD.js} +1 -1
  62. package/assets/{index-C-uqursN.js → index-C9vcJp9T.js} +1 -1
  63. package/assets/{index-DK-ZMNLh.js → index-CO3lXLzl.js} +1 -1
  64. package/assets/{index-DS2Lm9tG.js → index-CYBDya_s.js} +1 -1
  65. package/assets/{index-okvlQSs2.js → index-Coj3uG35.js} +1 -1
  66. package/assets/{index-Cu4ZjLNb.js → index-CqbvjyBi.js} +5 -5
  67. package/assets/{index-wds8TuUm.js → index-CwfOYq8B.js} +1 -1
  68. package/assets/{index-aoxVkzFE.js → index-Cz0JdeQb.js} +1 -1
  69. package/assets/{index-C5ciuua_.js → index-D-YuFp2i.js} +1 -1
  70. package/assets/{index-I68folnJ.js → index-D4NLrlUn.js} +1 -1
  71. package/assets/{index-B7Jt3b4d.js → index-D8PaxcsI.js} +1 -1
  72. package/assets/{index-r_1z0VI_.js → index-D9ey6cqT.js} +1 -1
  73. package/assets/{index-B-vyBZw9.js → index-DRYOQXZX.js} +1 -1
  74. package/assets/{index-DOnRCLNP.js → index-DT1PkdGa.js} +2 -2
  75. package/assets/{index-DWRq2SN_.js → index-DXCSroqX.js} +1 -1
  76. package/assets/{index-mZa0UiRt.js → index-DXs78xw9.js} +1 -1
  77. package/assets/{index-kXKMGszW.js → index-DZ0punK7.js} +1 -1
  78. package/assets/{index-B9U0GcYk.js → index-D_m5AL3D.js} +1 -1
  79. package/assets/{index-BxdNwV86.js → index-Dc148hav.js} +1 -1
  80. package/assets/{index-DP1DuCnR.js → index-DgDxBH9m.js} +1 -1
  81. package/assets/{index-DfWsAOhN.js → index-Dm7tCcMc.js} +3 -3
  82. package/assets/{index-D0LvjNIX.js → index-DmIGOG39.js} +1 -1
  83. package/assets/{index-JfVynEph.js → index-DmK5ktNw.js} +1 -1
  84. package/assets/{index-Cp7mdTuR.js → index-Eyans5--.js} +1 -1
  85. package/assets/{index-DPxCDCvr.js → index-KK8ZylE4.js} +1 -1
  86. package/assets/{index-DvJmANzU.js → index-TUD0QlWP.js} +1 -1
  87. package/assets/{index-TBthDmkl.js → index-ak5cSl-l.js} +1 -1
  88. package/assets/{index-8M7OkBFm.js → index-bVr8-SEv.js} +1 -1
  89. package/assets/{index-BlykZ8Gp.js → index-prLj8b2x.js} +1 -1
  90. package/assets/{index-BKL7nv1p.js → index-vajj2FBo.js} +1 -1
  91. package/assets/{index.es-YpI01v2I.js → index.es-C85F8NOj.js} +1 -1
  92. package/assets/{index.es-CkxUaFYS.js → index.es-DYgSAVrd.js} +1 -1
  93. package/assets/{index.es-cEGj7JU0.js → index.es-XXBqJXMm.js} +4 -4
  94. package/assets/{localBatchGatewayRequest-CNIOIq-Z.js → localBatchGatewayRequest-DbQn1s0J.js} +1 -1
  95. package/assets/{networks-DJ72puSk.js → networks-DMqekeph.js} +1 -1
  96. package/assets/{onramp--l5ZLxWE.js → onramp-qvbxoSMm.js} +1 -1
  97. package/assets/{openzeppelin-CqtRqxtF.js → openzeppelin-B6Und3LJ.js} +1 -1
  98. package/assets/{ownerOf-cWkgEtd8.js → ownerOf-CUoSe2c5.js} +1 -1
  99. package/assets/{parseEventLogs-D1xiFnCH.js → parseEventLogs-BxtEI7tW.js} +3 -3
  100. package/assets/{parseNft-DH5KlHPI.js → parseNft-DB_pGzOu.js} +2 -2
  101. package/assets/{parseSignature-HAlgOHnm.js → parseSignature-Csyua1uA.js} +3 -3
  102. package/assets/{parseSignature-BYhcrVdX.js → parseSignature-O0fAqZoB.js} +1 -1
  103. package/assets/{pay-with-exchange-CiXPJJ6-.js → pay-with-exchange-1MlV9x6H.js} +1 -1
  104. package/assets/{qr-overlay-CmFgwJBd.js → qr-overlay-DA6htUdY.js} +3 -3
  105. package/assets/{receive-t2TxUItI.js → receive-JnpfZY7d.js} +1 -1
  106. package/assets/{resolveImplementation-iG9WRRnW.js → resolveImplementation-B8d2Q-Ro.js} +1 -1
  107. package/assets/{rpc-sIdV4wiJ.js → rpc-DkFFCBh9.js} +1 -1
  108. package/assets/{secp256k1-Rk5k9i7o.js → secp256k1-BCPsQ5nJ.js} +1 -1
  109. package/assets/{secp256k1-Co_Jve4c.js → secp256k1-BZmrY8e3.js} +1 -1
  110. package/assets/{secp256k1-Bg2aUJRs.js → secp256k1-TIizaas9.js} +1 -1
  111. package/assets/{send-ByB5fOtm.js → send-DsnDja5n.js} +1 -1
  112. package/assets/{send-batch-transaction-D79MC_wr.js → send-batch-transaction-jNcvidMH.js} +1 -1
  113. package/assets/{send-eip712-transaction-CB6qLgks.js → send-eip712-transaction-DDJVOUpU.js} +2 -2
  114. package/assets/{send-gasless-transaction-Dt1qtUR8.js → send-gasless-transaction-DXjarWmh.js} +2 -2
  115. package/assets/{session-proposal-CY0k9Jnm.js → session-proposal-xJguSOgr.js} +1 -1
  116. package/assets/{session-request-B_2glC9e.js → session-request-BhD4eDPG.js} +2 -2
  117. package/assets/{sha256-Dy8KQE_5.js → sha256-CbjS9vFa.js} +1 -1
  118. package/assets/{signing-gNn6SJWz.js → signing-tKzVzr3v.js} +5 -5
  119. package/assets/{socials-Dx84-PrV.js → socials-CER945jA.js} +1 -1
  120. package/assets/{swaps-CK9Sfcew.js → swaps-Dy4hNTFm.js} +1 -1
  121. package/assets/{thirdweb-Bx5V_C1s.js → thirdweb-CNCkvOQU.js} +3 -3
  122. package/assets/{totalSupply-O-VFDoRO.js → totalSupply-BQvZy7Uc.js} +1 -1
  123. package/assets/{transactionReceipt-BqEjx5q-.js → transactionReceipt-DA1xo-2g.js} +1 -1
  124. package/assets/{transactions-BLOC2qYE.js → transactions-CwEfhngY.js} +1 -1
  125. package/assets/{utils-h8VUSGPW.js → utils-BUWGRgBa.js} +1 -1
  126. package/assets/{verifyHash-CNJ6t8Wp.js → verifyHash-CX9Livyx.js} +1 -1
  127. package/assets/{w3m-modal-nzPxg0Fr.js → w3m-modal-B1spewtI.js} +1 -1
  128. package/assets/{w3m-modal-CCQuGDus.js → w3m-modal-B6M729n4.js} +1 -1
  129. package/assets/{wait-for-tx-receipt-5pSBMNe2.js → wait-for-tx-receipt-BLruoSfj.js} +1 -1
  130. package/assets/{wallets-Bz03-Btm.js → wallets-vCTTbbau.js} +6 -6
  131. package/assets/{web-connector-CAOe_uvv.js → web-connector-h9SB5qXs.js} +3 -3
  132. package/assets/{writeContract-CCar3Ocq.js → writeContract-C9KDDivM.js} +1 -1
  133. package/assets/{zora-sepolia-D6mjhB5j.js → zora-sepolia-pCyxGzqm.js} +1 -1
  134. package/assets/{zoraTestnet-WLSFziQl.js → zoraTestnet-ChmlUfs6.js} +1 -1
  135. package/index.html +4 -4
  136. package/package.json +3 -3
  137. package/assets/browser-ponyfill-BmgQyNz0.js +0 -1
  138. package/assets/decimals-DR6jraOc.js +0 -1
  139. package/assets/eth_estimateGas-DKKwG-Ue.js +0 -1
  140. package/assets/get-ecosystem-wallet-info-Cvjz8DFX.js +0 -1
  141. package/assets/index-829Uxa3Y.css +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-DVWd8_kC.js","assets/W3MFrameProviderSingleton-9eitOT0j.js","assets/index-DS2Lm9tG.js","assets/index-Cu4ZjLNb.js","assets/index-829Uxa3Y.css","assets/browser-ponyfill-BmgQyNz0.js","assets/NetworkUtil-DqGcuBfF.js","assets/sha2-D3ryOfi3.js","assets/embedded-wallet-BxgtT1uV.js","assets/lit-element-Cn7T8F1W.js","assets/class-map-mFRv1nW8.js","assets/index-wds8TuUm.js","assets/index-i4VBSYqA.js","assets/if-defined-DsPifBxM.js","assets/ref-CYZXcxoe.js","assets/async-directive-DJs0ey8-.js","assets/index-B9U0GcYk.js","assets/HelpersUtil-Dp4e1zvd.js","assets/ConstantsUtil-ByjAYmvC.js","assets/index-JfVynEph.js","assets/index-C51HwlD0.js","assets/index-DP1DuCnR.js","assets/index-C5ciuua_.js","assets/index-aoxVkzFE.js","assets/NavigationUtil-DmfK5sOV.js","assets/index-B-vyBZw9.js","assets/index-nibyPLVP.js","assets/index-r_1z0VI_.js","assets/hmac-BMnSt9Ou.js","assets/index.es-CkxUaFYS.js","assets/email-C8DRQjTT.js","assets/index-DK-ZMNLh.js","assets/index-CWnFK_-0.js","assets/socials-Dx84-PrV.js","assets/index-DFE6t65x.js","assets/index-8M7OkBFm.js","assets/index-0ShVRzxt.js","assets/browser-VYI7gorG.js","assets/index-TBthDmkl.js","assets/swaps-CK9Sfcew.js","assets/index-B5ECjSS9.js","assets/SwapController-DUCq2f7d.js","assets/index-I68folnJ.js","assets/MathUtil-BGCe3rZ3.js","assets/send-ByB5fOtm.js","assets/index-CE5G6IEJ.js","assets/index-CWGeCZBJ.js","assets/index-DWRq2SN_.js","assets/index-BxdNwV86.js","assets/receive-t2TxUItI.js","assets/onramp--l5ZLxWE.js","assets/index-CjiwjbqL.js","assets/index-DPxCDCvr.js","assets/index-DvJmANzU.js","assets/pay-with-exchange-CiXPJJ6-.js","assets/ExchangeController-Bp8ztJrX.js","assets/transactions-BLOC2qYE.js","assets/index-BKL7nv1p.js","assets/index-CH0zI801.js","assets/index-mZa0UiRt.js","assets/index-BIPd_vR5.js","assets/data-capture-DnvAEYWK.js","assets/index-okvlQSs2.js","assets/index-B7Jt3b4d.js","assets/w3m-modal-CCQuGDus.js"])))=>i.map(i=>d[i]);
2
- import{b as $i,h as od,B as se,e as Ws,N as Lo,_ as Ge}from"./index-Cu4ZjLNb.js";import{j as ad,B as Cr,z as xs,ad as Ml,C as P,ae as cd,O as K,e as ld,i as hd,p as ud,af as Mo,ag as ql,ah as ht,ai as ut,a1 as ks,a8 as dd,ac as fd,b as _e,d as be,A as Le,F as Me,$ as de,l as Hn,o as ce,t as ne,k as me,K as pd,q as gd,aj as Ea,ak as md,M as ls,J as Ia,a7 as nn,E as Bt,_ as yd,T as kt,a9 as wi,Z as wr,y as Je,a3 as Ar,R as $s,al as _r,S as xa,am as wd,u as on,W as Sa,H as bd,a5 as vd,a6 as Ed}from"./W3MFrameProviderSingleton-9eitOT0j.js";import{l as tr,a as Pr,s as qo,I as pi,e as Id,g as j,h as os,C as xd,j as Wn,m as Sd,c as Dt,r as gi,o as jo,n as Cd,q as Fo,t as zo,b as qi,P as Ca,Q as Ad,u as _d,v as Ds,f as jl,w as Wt,x as Rt,y as hs,k as Pd}from"./index-B-vyBZw9.js";import{c as Nd,a as Td,k as Od,d as kd,s as $d,g as Aa}from"./index-nibyPLVP.js";import{f as bt,t as it,c as Ri,b as Hi,a as Rd,d as Ud}from"./index-r_1z0VI_.js";import{e as Bd,r as Dd,f as Ld,s as Md}from"./sha2-D3ryOfi3.js";import{h as qd}from"./hmac-BMnSt9Ou.js";import{ap as J,av as jd,an as _a,ax as Fd}from"./NetworkUtil-DqGcuBfF.js";import"./index-DS2Lm9tG.js";import{f as Fl}from"./index.es-CkxUaFYS.js";import{a as vs,r as Ut}from"./lit-element-Cn7T8F1W.js";const Ui={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"}]},Gn={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},zd={providers:Ml,selectedProvider:null,error:null,purchaseCurrency:Ui,paymentCurrency:Gn,purchaseCurrencies:[Ui],paymentCurrencies:[],quotesLoading:!1},te=ud(zd),Kd={state:te,subscribe(s){return hd(te,()=>s(te))},subscribeKey(s,e){return ld(te,s,e)},setSelectedProvider(s){if(s&&s.name==="meld"){const e=P.state.activeChain,t=e===J.CHAIN.SOLANA?"SOL":"USDC",i=e?P.state.chains.get(e)?.accountState?.address??"":"",r=new URL(s.url);r.searchParams.append("publicKey",cd),r.searchParams.append("destinationCurrencyCode",t),r.searchParams.append("walletAddress",i),r.searchParams.append("externalCustomerId",K.state.projectId),te.selectedProvider={...s,url:r.toString()}}else te.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=Ml.filter(i=>e.includes(i.name));te.providers=t}else te.providers=[]},setPurchaseCurrency(s){te.purchaseCurrency=s},setPaymentCurrency(s){te.paymentCurrency=s},setPurchaseAmount(s){Yn.state.purchaseAmount=s},setPaymentAmount(s){Yn.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Cr.getOnrampOptions();te.purchaseCurrencies=s.purchaseCurrencies,te.paymentCurrencies=s.paymentCurrencies,te.paymentCurrency=s.paymentCurrencies[0]||Gn,te.purchaseCurrency=s.purchaseCurrencies[0]||Ui,await xs.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await xs.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){te.quotesLoading=!0;try{const s=await Cr.getOnrampQuote({purchaseCurrency:te.purchaseCurrency,paymentCurrency:te.paymentCurrency,amount:te.paymentAmount?.toString()||"0",network:te.purchaseCurrency?.symbol});return te.quotesLoading=!1,te.purchaseAmount=Number(s?.purchaseAmount.amount),s}catch(s){return te.error=s.message,te.quotesLoading=!1,null}finally{te.quotesLoading=!1}},resetState(){te.selectedProvider=null,te.error=null,te.purchaseCurrency=Ui,te.paymentCurrency=Gn,te.purchaseCurrencies=[Ui],te.paymentCurrencies=[],te.paymentAmount=void 0,te.purchaseAmount=void 0,te.quotesLoading=!1}},Yn=ad(Kd);function Vd(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function Ce(s,...e){try{return Vd(s(...e))}catch(t){return Promise.reject(t)}}function Hd(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function Wd(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function br(s){if(Hd(s))return String(s);if(Wd(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return br(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Zn="base64:";function Gd(s){return typeof s=="string"?s:Zn+Jd(s)}function Yd(s){return typeof s!="string"||!s.startsWith(Zn)?s:Zd(s.slice(Zn.length))}function Zd(s){return globalThis.Buffer?Buffer.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Jd(s){return globalThis.Buffer?Buffer.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Ye(s){return s&&s.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function Xd(...s){return Ye(s.join(":"))}function sr(s){return s=Ye(s),s?s+":":""}function Qd(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function ef(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const tf="memory",sf=()=>{const s=new Map;return{name:tf,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function rf(s={}){const e={mounts:{"":s.driver||sf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Ye(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Pa(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",y=Ye(g?p:p.key),N=g?void 0:p.value,$=g||!p.options?h:{...h,...p.options},S=t(y);f(S).items.push({key:y,value:N,relativeKey:S.relativeKey,options:$})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.hasItem,u,h)},getItem(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.getItem,u,h).then(f=>tr(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?Ce(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Xd(u.base,f.key),value:tr(f.value)}))):Promise.all(u.items.map(d=>Ce(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:tr(f)})))))},getItemRaw(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?Ce(d.getItemRaw,u,h):Ce(d.getItem,u,h).then(f=>Yd(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Ye(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await Ce(f.setItem,d,br(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return Ce(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:br(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>Ce(u.driver.setItem,d.relativeKey,br(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Ye(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await Ce(f.setItemRaw,d,h,u);else if(f.setItem)await Ce(f.setItem,d,Gd(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Ye(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await Ce(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await Ce(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Ye(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await Ce(d.getMeta,u,h)),!h.nativeOnly){const p=await Ce(d.getItem,u+"$",h).then(g=>tr(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){l=sr(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const y of u){y.driver.flags?.maxDepth||(p=!1);const N=await Ce(y.driver.getKeys,y.relativeBase,h);for(const $ of N){const S=y.mountpoint+Ye($);d.some(I=>S.startsWith(I))||f.push(S)}d=[y.mountpoint,...d.filter($=>!$.startsWith(y.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(y=>(!g||Qd(y,h.maxDepth))&&ef(y,l))},async clear(l,h={}){l=sr(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return Ce(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Na(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=sr(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(Pa(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){l=sr(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l]?.(),delete e.unwatch[l]),h&&await Na(e.mounts[l]),e.mountpoints=e.mountpoints.filter(u=>u!==l),delete e.mounts[l])},getMount(l=""){l=Ye(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Ye(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function Pa(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Na(s){typeof s.dispose=="function"&&await Ce(s.dispose)}const nf="idb-keyval";var of=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=Nd(s.dbName,s.storeName)),{name:nf,options:s,async hasItem(r){return!(typeof await Aa(t(r),i)>"u")},async getItem(r){return await Aa(t(r),i)??null},setItem(r,n){return $d(t(r),n,i)},removeItem(r){return kd(t(r),i)},getKeys(){return Od(i)},clear(){return Td(i)}}};const af="WALLET_CONNECT_V2_INDEXED_DB",cf="keyvaluestorage";let lf=class{constructor(){this.indexedDb=rf({driver:of({dbName:af,storeName:cf})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,qo(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var an=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},vr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof an<"u"&&an.localStorage?vr.exports=an.localStorage:typeof window<"u"&&window.localStorage?vr.exports=window.localStorage:vr.exports=new e})();function hf(s){var e;return[s[0],Pr((e=s[1])!=null?e:"")]}let uf=class{constructor(){this.localStorage=vr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(hf)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return Pr(t)}async setItem(e,t){this.localStorage.setItem(e,qo(t))}async removeItem(e){this.localStorage.removeItem(e)}};const df="wc_storage_version",Ta=1,ff=async(s,e,t)=>{const i=df,r=await e.getItem(i);if(r&&r>=Ta){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Ta),t(e),pf(s,o)},pf=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let gf=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new uf;this.storage=e;try{const t=new lf;ff(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var mf=Object.defineProperty,yf=(s,e,t)=>e in s?mf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Oa=(s,e,t)=>yf(s,typeof e!="symbol"?e+"":e,t);class wf extends pi{constructor(e){super(),this.opts=e,Oa(this,"protocol","wc"),Oa(this,"version",2)}}var bf=Object.defineProperty,vf=(s,e,t)=>e in s?bf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ef=(s,e,t)=>vf(s,e+"",t);class If extends pi{constructor(e,t){super(),this.core=e,this.logger=t,Ef(this,"records",new Map)}}let xf=class{constructor(e,t){this.logger=e,this.core=t}};class Sf extends pi{constructor(e,t){super(),this.relayer=e,this.logger=t}}let Cf=class extends pi{constructor(e){super()}},Af=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_f=class extends pi{constructor(e,t){super(),this.relayer=e,this.logger=t}},Pf=class extends pi{constructor(e,t){super(),this.core=e,this.logger=t}},Nf=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class Tf{constructor(e,t){this.projectId=e,this.logger=t}}class Of{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var kf=Object.defineProperty,$f=(s,e,t)=>e in s?kf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ka=(s,e,t)=>$f(s,typeof e!="symbol"?e+"":e,t);let Rf=class{constructor(e){this.opts=e,ka(this,"protocol","wc"),ka(this,"version",2)}},Uf=class{constructor(e){this.client=e}};const Bf="0.1.1";function Df(){return Bf}class ge extends Error{constructor(e,t={}){const i=(()=>{if(t.cause instanceof ge){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof ge&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-fx-atM_l.js","assets/W3MFrameProviderSingleton-dGwr0u32.js","assets/index-CYBDya_s.js","assets/index-CqbvjyBi.js","assets/index-Bzi38pjx.css","assets/browser-ponyfill-LG9Rjmfj.js","assets/NetworkUtil-DM5H1DOt.js","assets/sha2-D3ryOfi3.js","assets/embedded-wallet-DZAeJhJN.js","assets/lit-element-Cn7T8F1W.js","assets/class-map-mFRv1nW8.js","assets/index-CwfOYq8B.js","assets/index-BvCGPTHO.js","assets/if-defined-DsPifBxM.js","assets/ref-CYZXcxoe.js","assets/async-directive-DJs0ey8-.js","assets/index-D_m5AL3D.js","assets/HelpersUtil-DFmhrbIH.js","assets/ConstantsUtil-BYRHWuZV.js","assets/index-DmK5ktNw.js","assets/index-BF9Yx_yV.js","assets/index-DgDxBH9m.js","assets/index-D-YuFp2i.js","assets/index-Cz0JdeQb.js","assets/NavigationUtil-DmfK5sOV.js","assets/index-DRYOQXZX.js","assets/index-nibyPLVP.js","assets/index-D9ey6cqT.js","assets/hmac-BMnSt9Ou.js","assets/index.es-DYgSAVrd.js","assets/email-CUatRSQC.js","assets/index-CO3lXLzl.js","assets/index-C9EMW8qD.js","assets/socials-CER945jA.js","assets/index-BpxeqYFx.js","assets/index-bVr8-SEv.js","assets/index-BVi4iI8y.js","assets/browser-h4rN6CV4.js","assets/index-ak5cSl-l.js","assets/swaps-Dy4hNTFm.js","assets/index-Bv6LvzLS.js","assets/SwapController-SgAc8zJM.js","assets/index-D4NLrlUn.js","assets/MathUtil-BGCe3rZ3.js","assets/send-DsnDja5n.js","assets/index-B6j-Tckn.js","assets/index-BJCYEGPg.js","assets/index-DXCSroqX.js","assets/index-Dc148hav.js","assets/receive-JnpfZY7d.js","assets/onramp-qvbxoSMm.js","assets/index-BCiKer83.js","assets/index-KK8ZylE4.js","assets/index-TUD0QlWP.js","assets/pay-with-exchange-1MlV9x6H.js","assets/ExchangeController-N42lbf3C.js","assets/transactions-CwEfhngY.js","assets/index-vajj2FBo.js","assets/index-C5oPclal.js","assets/index-DXs78xw9.js","assets/index-0P32tQWj.js","assets/data-capture-C5UoNnMk.js","assets/index-Coj3uG35.js","assets/index-D8PaxcsI.js","assets/w3m-modal-B6M729n4.js"])))=>i.map(i=>d[i]);
2
+ import{b as $i,h as od,B as se,e as Ws,N as Lo,_ as Ge}from"./index-CqbvjyBi.js";import{j as ad,B as Cr,z as xs,ad as Ml,C as P,ae as cd,O as K,e as ld,i as hd,p as ud,af as Mo,ag as ql,ah as ht,ai as ut,a1 as ks,a8 as dd,ac as fd,b as _e,d as be,A as Le,F as Me,$ as de,l as Hn,o as ce,t as ne,k as me,K as pd,q as gd,aj as Ea,ak as md,M as ls,J as Ia,a7 as nn,E as Bt,_ as yd,T as kt,a9 as wi,Z as wr,y as Je,a3 as Ar,R as $s,al as _r,S as xa,am as wd,u as on,W as Sa,H as bd,a5 as vd,a6 as Ed}from"./W3MFrameProviderSingleton-dGwr0u32.js";import{l as tr,a as Pr,s as qo,I as pi,e as Id,g as j,h as os,C as xd,j as Wn,m as Sd,c as Dt,r as gi,o as jo,n as Cd,q as Fo,t as zo,b as qi,P as Ca,Q as Ad,u as _d,v as Ds,f as jl,w as Wt,x as Rt,y as hs,k as Pd}from"./index-DRYOQXZX.js";import{c as Nd,a as Td,k as Od,d as kd,s as $d,g as Aa}from"./index-nibyPLVP.js";import{f as bt,t as it,c as Ri,b as Hi,a as Rd,d as Ud}from"./index-D9ey6cqT.js";import{e as Bd,r as Dd,f as Ld,s as Md}from"./sha2-D3ryOfi3.js";import{h as qd}from"./hmac-BMnSt9Ou.js";import{ap as J,av as jd,an as _a,ax as Fd}from"./NetworkUtil-DM5H1DOt.js";import"./index-CYBDya_s.js";import{f as Fl}from"./index.es-DYgSAVrd.js";import{a as vs,r as Ut}from"./lit-element-Cn7T8F1W.js";const Ui={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"}]},Gn={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},zd={providers:Ml,selectedProvider:null,error:null,purchaseCurrency:Ui,paymentCurrency:Gn,purchaseCurrencies:[Ui],paymentCurrencies:[],quotesLoading:!1},te=ud(zd),Kd={state:te,subscribe(s){return hd(te,()=>s(te))},subscribeKey(s,e){return ld(te,s,e)},setSelectedProvider(s){if(s&&s.name==="meld"){const e=P.state.activeChain,t=e===J.CHAIN.SOLANA?"SOL":"USDC",i=e?P.state.chains.get(e)?.accountState?.address??"":"",r=new URL(s.url);r.searchParams.append("publicKey",cd),r.searchParams.append("destinationCurrencyCode",t),r.searchParams.append("walletAddress",i),r.searchParams.append("externalCustomerId",K.state.projectId),te.selectedProvider={...s,url:r.toString()}}else te.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=Ml.filter(i=>e.includes(i.name));te.providers=t}else te.providers=[]},setPurchaseCurrency(s){te.purchaseCurrency=s},setPaymentCurrency(s){te.paymentCurrency=s},setPurchaseAmount(s){Yn.state.purchaseAmount=s},setPaymentAmount(s){Yn.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Cr.getOnrampOptions();te.purchaseCurrencies=s.purchaseCurrencies,te.paymentCurrencies=s.paymentCurrencies,te.paymentCurrency=s.paymentCurrencies[0]||Gn,te.purchaseCurrency=s.purchaseCurrencies[0]||Ui,await xs.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await xs.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){te.quotesLoading=!0;try{const s=await Cr.getOnrampQuote({purchaseCurrency:te.purchaseCurrency,paymentCurrency:te.paymentCurrency,amount:te.paymentAmount?.toString()||"0",network:te.purchaseCurrency?.symbol});return te.quotesLoading=!1,te.purchaseAmount=Number(s?.purchaseAmount.amount),s}catch(s){return te.error=s.message,te.quotesLoading=!1,null}finally{te.quotesLoading=!1}},resetState(){te.selectedProvider=null,te.error=null,te.purchaseCurrency=Ui,te.paymentCurrency=Gn,te.purchaseCurrencies=[Ui],te.paymentCurrencies=[],te.paymentAmount=void 0,te.purchaseAmount=void 0,te.quotesLoading=!1}},Yn=ad(Kd);function Vd(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function Ce(s,...e){try{return Vd(s(...e))}catch(t){return Promise.reject(t)}}function Hd(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function Wd(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function br(s){if(Hd(s))return String(s);if(Wd(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return br(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Zn="base64:";function Gd(s){return typeof s=="string"?s:Zn+Jd(s)}function Yd(s){return typeof s!="string"||!s.startsWith(Zn)?s:Zd(s.slice(Zn.length))}function Zd(s){return globalThis.Buffer?Buffer.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Jd(s){return globalThis.Buffer?Buffer.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Ye(s){return s&&s.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function Xd(...s){return Ye(s.join(":"))}function sr(s){return s=Ye(s),s?s+":":""}function Qd(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function ef(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const tf="memory",sf=()=>{const s=new Map;return{name:tf,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function rf(s={}){const e={mounts:{"":s.driver||sf()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Ye(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Pa(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",y=Ye(g?p:p.key),N=g?void 0:p.value,$=g||!p.options?h:{...h,...p.options},S=t(y);f(S).items.push({key:y,value:N,relativeKey:S.relativeKey,options:$})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.hasItem,u,h)},getItem(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.getItem,u,h).then(f=>tr(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?Ce(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Xd(u.base,f.key),value:tr(f.value)}))):Promise.all(u.items.map(d=>Ce(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:tr(f)})))))},getItemRaw(l,h={}){l=Ye(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?Ce(d.getItemRaw,u,h):Ce(d.getItem,u,h).then(f=>Yd(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Ye(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await Ce(f.setItem,d,br(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return Ce(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:br(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>Ce(u.driver.setItem,d.relativeKey,br(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Ye(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await Ce(f.setItemRaw,d,h,u);else if(f.setItem)await Ce(f.setItem,d,Gd(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Ye(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await Ce(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await Ce(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Ye(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await Ce(d.getMeta,u,h)),!h.nativeOnly){const p=await Ce(d.getItem,u+"$",h).then(g=>tr(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){l=sr(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const y of u){y.driver.flags?.maxDepth||(p=!1);const N=await Ce(y.driver.getKeys,y.relativeBase,h);for(const $ of N){const S=y.mountpoint+Ye($);d.some(I=>S.startsWith(I))||f.push(S)}d=[y.mountpoint,...d.filter($=>!$.startsWith(y.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(y=>(!g||Qd(y,h.maxDepth))&&ef(y,l))},async clear(l,h={}){l=sr(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return Ce(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Na(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=sr(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(Pa(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){l=sr(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l]?.(),delete e.unwatch[l]),h&&await Na(e.mounts[l]),e.mountpoints=e.mountpoints.filter(u=>u!==l),delete e.mounts[l])},getMount(l=""){l=Ye(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Ye(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function Pa(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Na(s){typeof s.dispose=="function"&&await Ce(s.dispose)}const nf="idb-keyval";var of=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=Nd(s.dbName,s.storeName)),{name:nf,options:s,async hasItem(r){return!(typeof await Aa(t(r),i)>"u")},async getItem(r){return await Aa(t(r),i)??null},setItem(r,n){return $d(t(r),n,i)},removeItem(r){return kd(t(r),i)},getKeys(){return Od(i)},clear(){return Td(i)}}};const af="WALLET_CONNECT_V2_INDEXED_DB",cf="keyvaluestorage";let lf=class{constructor(){this.indexedDb=rf({driver:of({dbName:af,storeName:cf})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,qo(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var an=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},vr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof an<"u"&&an.localStorage?vr.exports=an.localStorage:typeof window<"u"&&window.localStorage?vr.exports=window.localStorage:vr.exports=new e})();function hf(s){var e;return[s[0],Pr((e=s[1])!=null?e:"")]}let uf=class{constructor(){this.localStorage=vr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(hf)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return Pr(t)}async setItem(e,t){this.localStorage.setItem(e,qo(t))}async removeItem(e){this.localStorage.removeItem(e)}};const df="wc_storage_version",Ta=1,ff=async(s,e,t)=>{const i=df,r=await e.getItem(i);if(r&&r>=Ta){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,Ta),t(e),pf(s,o)},pf=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let gf=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new uf;this.storage=e;try{const t=new lf;ff(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var mf=Object.defineProperty,yf=(s,e,t)=>e in s?mf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Oa=(s,e,t)=>yf(s,typeof e!="symbol"?e+"":e,t);class wf extends pi{constructor(e){super(),this.opts=e,Oa(this,"protocol","wc"),Oa(this,"version",2)}}var bf=Object.defineProperty,vf=(s,e,t)=>e in s?bf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ef=(s,e,t)=>vf(s,e+"",t);class If extends pi{constructor(e,t){super(),this.core=e,this.logger=t,Ef(this,"records",new Map)}}let xf=class{constructor(e,t){this.logger=e,this.core=t}};class Sf extends pi{constructor(e,t){super(),this.relayer=e,this.logger=t}}let Cf=class extends pi{constructor(e){super()}},Af=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_f=class extends pi{constructor(e,t){super(),this.relayer=e,this.logger=t}},Pf=class extends pi{constructor(e,t){super(),this.core=e,this.logger=t}},Nf=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class Tf{constructor(e,t){this.projectId=e,this.logger=t}}class Of{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var kf=Object.defineProperty,$f=(s,e,t)=>e in s?kf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ka=(s,e,t)=>$f(s,typeof e!="symbol"?e+"":e,t);let Rf=class{constructor(e){this.opts=e,ka(this,"protocol","wc"),ka(this,"version",2)}},Uf=class{constructor(e){this.client=e}};const Bf="0.1.1";function Df(){return Bf}class ge extends Error{constructor(e,t={}){const i=(()=>{if(t.cause instanceof ge){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof ge&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
3
3
  `);super(a,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Df()}`}),this.cause=t.cause,this.details=i,this.docs=o,this.docsPath=r,this.shortMessage=e}walk(e){return zl(this,e)}}function zl(s,e){return e?.(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause?zl(s.cause,e):e?null:s}const Ko=BigInt(0),Jn=BigInt(1);function Wi(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Vo(s){if(!Wi(s))throw new Error("Uint8Array expected")}function ji(s,e){if(typeof e!="boolean")throw new Error(s+" boolean expected, got "+e)}function ir(s){const e=s.toString(16);return e.length&1?"0"+e:e}function Kl(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?Ko:BigInt("0x"+s)}const Vl=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Lf=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Fi(s){if(Vo(s),Vl)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=Lf[s[t]];return e}const Kt={_0:48,_9:57,A:65,F:70,a:97,f:102};function $a(s){if(s>=Kt._0&&s<=Kt._9)return s-Kt._0;if(s>=Kt.A&&s<=Kt.F)return s-(Kt.A-10);if(s>=Kt.a&&s<=Kt.f)return s-(Kt.a-10)}function Nr(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(Vl)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=$a(s.charCodeAt(n)),a=$a(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function Ks(s){return Kl(Fi(s))}function Hl(s){return Vo(s),Kl(Fi(Uint8Array.from(s).reverse()))}function Gi(s,e){return Nr(s.toString(16).padStart(e*2,"0"))}function Wl(s,e){return Gi(s,e).reverse()}function yt(s,e,t){let i;if(typeof e=="string")try{i=Nr(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(Wi(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}function Tr(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Vo(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}const cn=s=>typeof s=="bigint"&&Ko<=s;function Ho(s,e,t){return cn(s)&&cn(e)&&cn(t)&&e<=s&&s<t}function oi(s,e,t,i){if(!Ho(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}function Mf(s){let e;for(e=0;s>Ko;s>>=Jn,e+=1);return e}const zr=s=>(Jn<<BigInt(s))-Jn,ln=s=>new Uint8Array(s),Ra=s=>Uint8Array.from(s);function qf(s,e,t){if(typeof s!="number"||s<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 t!="function")throw new Error("hmacFn must be a function");let i=ln(s),r=ln(s),n=0;const o=()=>{i.fill(1),r.fill(0),n=0},a=(...u)=>t(r,i,...u),c=(u=ln(0))=>{r=a(Ra([0]),u),i=a(),u.length!==0&&(r=a(Ra([1]),u),i=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){i=a();const f=i.slice();d.push(f),u+=i.length}return Tr(...d)};return(u,d)=>{o(),c(u);let f;for(;!(f=d(l()));)c();return o(),f}}const jf={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||Wi(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function Kr(s,e,t={}){const i=(r,n,o)=>{const a=jf[n];if(typeof a!="function")throw new Error("invalid validator function");const c=s[r];if(!(o&&c===void 0)&&!a(c,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+c)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}function Ua(s){const e=new WeakMap;return(t,...i)=>{const r=e.get(t);if(r!==void 0)return r;const n=s(t,...i);return e.set(t,n),n}}function Ff(s,e){if(Ma(s)>e)throw new lp({givenSize:Ma(s),maxSize:e})}const Vt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ba(s){if(s>=Vt.zero&&s<=Vt.nine)return s-Vt.zero;if(s>=Vt.A&&s<=Vt.F)return s-(Vt.A-10);if(s>=Vt.a&&s<=Vt.f)return s-(Vt.a-10)}function zf(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;if(s.length>i)throw new hp({size:s.length,targetSize:i,type:"Bytes"});const r=new Uint8Array(i);for(let n=0;n<i;n++){const o=t==="right";r[o?n:i-n-1]=s[o?n:s.length-n-1]}return r}function Gl(s,e){if(Cs(s)>e)throw new Qf({givenSize:Cs(s),maxSize:e})}function Kf(s,e){if(typeof e=="number"&&e>0&&e>Cs(s)-1)throw new Jl({offset:e,position:"start",size:Cs(s)})}function Vf(s,e,t){if(typeof e=="number"&&typeof t=="number"&&Cs(s)!==t-e)throw new Jl({offset:t,position:"end",size:Cs(s)})}function Yl(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;const r=s.replace("0x","");if(r.length>i*2)throw new ep({size:Math.ceil(r.length/2),targetSize:i,type:"Hex"});return`0x${r[t==="right"?"padEnd":"padStart"](i*2,"0")}`}const Hf="#__bigint";function Wo(s,e,t){return JSON.stringify(s,(i,r)=>typeof r=="bigint"?r.toString()+Hf:r,t)}const Wf=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Gf(s,e={}){const{strict:t=!1}=e;if(!s)throw new Da(s);if(typeof s!="string")throw new Da(s);if(t&&!/^0x[0-9a-fA-F]*$/.test(s))throw new La(s);if(!s.startsWith("0x"))throw new La(s)}function Yf(...s){return`0x${s.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Go(s){return s instanceof Uint8Array?Or(s):Array.isArray(s)?Or(new Uint8Array(s)):s}function Or(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=Wf[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Gl(i,e.size),Zl(i,e.size)):i}function hn(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new Xf({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const c=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Zf(c,i):c}function Zf(s,e){return Yl(s,{dir:"left",size:e})}function Zl(s,e){return Yl(s,{dir:"right",size:e})}function Jt(s,e,t,i={}){const{strict:r}=i;Kf(s,e);const n=`0x${s.replace("0x","").slice((e??0)*2,(t??s.length)*2)}`;return r&&Vf(n,e,t),n}function Cs(s){return Math.ceil((s.length-2)/2)}function Jf(s,e={}){const{strict:t=!1}=e;try{return Gf(s,{strict:t}),!0}catch{return!1}}class Xf extends ge{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number \`${n}\` is not in safe${r?` ${r*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Da extends ge{constructor(e){super(`Value \`${typeof e=="object"?Wo(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class La extends ge{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let Qf=class extends ge{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class Jl extends ge{constructor({offset:e,position:t,size:i}){super(`Slice ${t==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${i}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let ep=class extends ge{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const tp=new TextEncoder;function sp(s){if(!(s instanceof Uint8Array)){if(!s)throw new rr(s);if(typeof s!="object")throw new rr(s);if(!("BYTES_PER_ELEMENT"in s))throw new rr(s);if(s.BYTES_PER_ELEMENT!==1||s.constructor.name!=="Uint8Array")throw new rr(s)}}function ip(s){return s instanceof Uint8Array?s:typeof s=="string"?np(s):rp(s)}function rp(s){return s instanceof Uint8Array?s:new Uint8Array(s)}function np(s,e={}){const{size:t}=e;let i=s;t&&(Gl(s,t),i=Zl(s,t));let r=i.slice(2);r.length%2&&(r=`0${r}`);const n=r.length/2,o=new Uint8Array(n);for(let a=0,c=0;a<n;a++){const l=Ba(r.charCodeAt(c++)),h=Ba(r.charCodeAt(c++));if(l===void 0||h===void 0)throw new ge(`Invalid byte sequence ("${r[c-2]}${r[c-1]}" in "${r}").`);o[a]=l*16+h}return o}function op(s,e={}){const{size:t}=e,i=tp.encode(s);return typeof t=="number"?(Ff(i,t),ap(i,t)):i}function ap(s,e){return zf(s,{dir:"right",size:e})}function Ma(s){return s.length}function cp(s){try{return sp(s),!0}catch{return!1}}class rr extends ge{constructor(e){super(`Value \`${typeof e=="object"?Wo(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class lp extends ge{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class hp extends ge{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function Xl(s,e={}){const{as:t=typeof s=="string"?"Hex":"Bytes"}=e,i=jd(ip(s));return t==="Bytes"?i:Or(i)}class up extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const dp={checksum:new up(8192)},un=dp.checksum;function Ql(s,e={}){const{compressed:t}=e,{prefix:i,x:r,y:n}=s;if(t===!1||typeof r=="bigint"&&typeof n=="bigint"){if(i!==4)throw new qa({prefix:i,cause:new wp});return}if(t===!0||typeof r=="bigint"&&typeof n>"u"){if(i!==3&&i!==2)throw new qa({prefix:i,cause:new yp});return}throw new mp({publicKey:s})}function fp(s){const e=(()=>{if(Jf(s))return eh(s);if(cp(s))return pp(s);const{prefix:t,x:i,y:r}=s;return typeof i=="bigint"&&typeof r=="bigint"?{prefix:t??4,x:i,y:r}:{prefix:t,x:i}})();return Ql(e),e}function pp(s){return eh(Or(s))}function eh(s){if(s.length!==132&&s.length!==130&&s.length!==68)throw new bp({publicKey:s});if(s.length===130){const i=BigInt(Jt(s,0,32)),r=BigInt(Jt(s,32,64));return{prefix:4,x:i,y:r}}if(s.length===132){const i=Number(Jt(s,0,1)),r=BigInt(Jt(s,1,33)),n=BigInt(Jt(s,33,65));return{prefix:i,x:r,y:n}}const e=Number(Jt(s,0,1)),t=BigInt(Jt(s,1,33));return{prefix:e,x:t}}function gp(s,e={}){Ql(s);const{prefix:t,x:i,y:r}=s,{includePrefix:n=!0}=e;return Yf(n?hn(t,{size:1}):"0x",hn(i,{size:32}),typeof r=="bigint"?hn(r,{size:32}):"0x")}class mp extends ge{constructor({publicKey:e}){super(`Value \`${Wo(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class qa extends ge{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class yp extends ge{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class wp extends ge{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let bp=class extends ge{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Cs(Go(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const vp=/^0x[a-fA-F0-9]{40}$/;function th(s,e={}){const{strict:t=!0}=e;if(!vp.test(s))throw new ja({address:s,cause:new xp});if(t){if(s.toLowerCase()===s)return;if(sh(s)!==s)throw new ja({address:s,cause:new Sp})}}function sh(s){if(un.has(s))return un.get(s);th(s,{strict:!1});const e=s.substring(2).toLowerCase(),t=Xl(op(e),{as:"Bytes"}),i=e.split("");for(let n=0;n<40;n+=2)t[n>>1]>>4>=8&&i[n]&&(i[n]=i[n].toUpperCase()),(t[n>>1]&15)>=8&&i[n+1]&&(i[n+1]=i[n+1].toUpperCase());const r=`0x${i.join("")}`;return un.set(s,r),r}function Ep(s,e={}){const{checksum:t=!1}=e;return th(s),t?sh(s):s}function Ip(s,e={}){const t=Xl(`0x${gp(s).slice(4)}`).substring(26);return Ep(`0x${t}`,e)}class ja extends ge{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class xp extends ge{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Sp extends ge{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const tt=BigInt(0),ze=BigInt(1),Ls=BigInt(2),Cp=BigInt(3),ih=BigInt(4),rh=BigInt(5),nh=BigInt(8);function Xe(s,e){const t=s%e;return t>=tt?t:e+t}function ft(s,e,t){let i=s;for(;e-- >tt;)i*=i,i%=t;return i}function Xn(s,e){if(s===tt)throw new Error("invert: expected non-zero number");if(e<=tt)throw new Error("invert: expected positive modulus, got "+e);let t=Xe(s,e),i=e,r=tt,n=ze;for(;t!==tt;){const a=i/t,c=i%t,l=r-n*a;i=t,t=c,r=n,n=l}if(i!==ze)throw new Error("invert: does not exist");return Xe(r,e)}function oh(s,e){const t=(s.ORDER+ze)/ih,i=s.pow(e,t);if(!s.eql(s.sqr(i),e))throw new Error("Cannot find square root");return i}function Ap(s,e){const t=(s.ORDER-rh)/nh,i=s.mul(e,Ls),r=s.pow(i,t),n=s.mul(e,r),o=s.mul(s.mul(n,Ls),r),a=s.mul(n,s.sub(o,s.ONE));if(!s.eql(s.sqr(a),e))throw new Error("Cannot find square root");return a}function _p(s){if(s<BigInt(3))throw new Error("sqrt is not defined for small field");let e=s-ze,t=0;for(;e%Ls===tt;)e/=Ls,t++;let i=Ls;const r=Yo(s);for(;Fa(r,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return oh;let n=r.pow(i,e);const o=(e+ze)/Ls;return function(c,l){if(c.is0(l))return l;if(Fa(c,l)!==1)throw new Error("Cannot find square root");let h=t,u=c.mul(c.ONE,n),d=c.pow(l,e),f=c.pow(l,o);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let p=1,g=c.sqr(d);for(;!c.eql(g,c.ONE);)if(p++,g=c.sqr(g),p===h)throw new Error("Cannot find square root");const y=ze<<BigInt(h-p-1),N=c.pow(u,y);h=p,u=c.sqr(N),d=c.mul(d,u),f=c.mul(f,N)}return f}}function Pp(s){return s%ih===Cp?oh:s%nh===rh?Ap:_p(s)}const Np=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Tp(s){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Np.reduce((i,r)=>(i[r]="function",i),e);return Kr(s,t)}function Op(s,e,t){if(t<tt)throw new Error("invalid exponent, negatives unsupported");if(t===tt)return s.ONE;if(t===ze)return e;let i=s.ONE,r=e;for(;t>tt;)t&ze&&(i=s.mul(i,r)),r=s.sqr(r),t>>=ze;return i}function ah(s,e,t=!1){const i=new Array(e.length).fill(t?s.ZERO:void 0),r=e.reduce((o,a,c)=>s.is0(a)?o:(i[c]=o,s.mul(o,a)),s.ONE),n=s.inv(r);return e.reduceRight((o,a,c)=>s.is0(a)?o:(i[c]=s.mul(o,i[c]),s.mul(o,a)),n),i}function Fa(s,e){const t=(s.ORDER-ze)/Ls,i=s.pow(e,t),r=s.eql(i,s.ONE),n=s.eql(i,s.ZERO),o=s.eql(i,s.neg(s.ONE));if(!r&&!n&&!o)throw new Error("invalid Legendre symbol result");return r?1:n?0:-1}function ch(s,e){e!==void 0&&Bd(e);const t=e!==void 0?e:s.toString(2).length,i=Math.ceil(t/8);return{nBitLength:t,nByteLength:i}}function Yo(s,e,t=!1,i={}){if(s<=tt)throw new Error("invalid field: expected ORDER > 0, got "+s);const{nBitLength:r,nByteLength:n}=ch(s,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:s,isLE:t,BITS:r,BYTES:n,MASK:zr(r),ZERO:tt,ONE:ze,create:c=>Xe(c,s),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return tt<=c&&c<s},is0:c=>c===tt,isOdd:c=>(c&ze)===ze,neg:c=>Xe(-c,s),eql:(c,l)=>c===l,sqr:c=>Xe(c*c,s),add:(c,l)=>Xe(c+l,s),sub:(c,l)=>Xe(c-l,s),mul:(c,l)=>Xe(c*l,s),pow:(c,l)=>Op(a,c,l),div:(c,l)=>Xe(c*Xn(l,s),s),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Xn(c,s),sqrt:i.sqrt||(c=>(o||(o=Pp(s)),o(a,c))),toBytes:c=>t?Wl(c,n):Gi(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return t?Hl(c):Ks(c)},invertBatch:c=>ah(a,c),cmov:(c,l,h)=>h?l:c});return Object.freeze(a)}function lh(s){if(typeof s!="bigint")throw new Error("field order must be bigint");const e=s.toString(2).length;return Math.ceil(e/8)}function hh(s){const e=lh(s);return e+Math.ceil(e/2)}function kp(s,e,t=!1){const i=s.length,r=lh(e),n=hh(e);if(i<16||i<n||i>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+i);const o=t?Hl(s):Ks(s),a=Xe(o,e-ze)+ze;return t?Wl(a,r):Gi(a,r)}const za=BigInt(0),Qn=BigInt(1);function dn(s,e){const t=e.negate();return s?t:e}function uh(s,e){if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+s)}function fn(s,e){uh(s,e);const t=Math.ceil(e/s)+1,i=2**(s-1),r=2**s,n=zr(s),o=BigInt(s);return{windows:t,windowSize:i,mask:n,maxNumber:r,shiftBy:o}}function Ka(s,e,t){const{windowSize:i,mask:r,maxNumber:n,shiftBy:o}=t;let a=Number(s&r),c=s>>o;a>i&&(a-=n,c+=Qn);const l=e*i,h=l+Math.abs(a)-1,u=a===0,d=a<0,f=e%2!==0;return{nextN:c,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:l}}function $p(s,e){if(!Array.isArray(s))throw new Error("array expected");s.forEach((t,i)=>{if(!(t instanceof e))throw new Error("invalid point at index "+i)})}function Rp(s,e){if(!Array.isArray(s))throw new Error("array of scalars expected");s.forEach((t,i)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+i)})}const pn=new WeakMap,dh=new WeakMap;function gn(s){return dh.get(s)||1}function Up(s,e){return{constTimeNegate:dn,hasPrecomputes(t){return gn(t)!==1},unsafeLadder(t,i,r=s.ZERO){let n=t;for(;i>za;)i&Qn&&(r=r.add(n)),n=n.double(),i>>=Qn;return r},precomputeWindow(t,i){const{windows:r,windowSize:n}=fn(i,e),o=[];let a=t,c=a;for(let l=0;l<r;l++){c=a,o.push(c);for(let h=1;h<n;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(t,i,r){let n=s.ZERO,o=s.BASE;const a=fn(t,e);for(let c=0;c<a.windows;c++){const{nextN:l,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:p}=Ka(r,c,a);r=l,u?o=o.add(dn(f,i[p])):n=n.add(dn(d,i[h]))}return{p:n,f:o}},wNAFUnsafe(t,i,r,n=s.ZERO){const o=fn(t,e);for(let a=0;a<o.windows&&r!==za;a++){const{nextN:c,offset:l,isZero:h,isNeg:u}=Ka(r,a,o);if(r=c,!h){const d=i[l];n=n.add(u?d.negate():d)}}return n},getPrecomputes(t,i,r){let n=pn.get(i);return n||(n=this.precomputeWindow(i,t),t!==1&&pn.set(i,r(n))),n},wNAFCached(t,i,r){const n=gn(t);return this.wNAF(n,this.getPrecomputes(n,t,r),i)},wNAFCachedUnsafe(t,i,r,n){const o=gn(t);return o===1?this.unsafeLadder(t,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,r),i,n)},setWindowSize(t,i){uh(i,e),dh.set(t,i),pn.delete(t)}}}function Bp(s,e,t,i){$p(t,s),Rp(i,e);const r=t.length,n=i.length;if(r!==n)throw new Error("arrays of points and scalars must have equal length");const o=s.ZERO,a=Mf(BigInt(r));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=zr(c),h=new Array(Number(l)+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let d=o;for(let f=u;f>=0;f-=c){h.fill(o);for(let g=0;g<n;g++){const y=i[g],N=Number(y>>BigInt(f)&l);h[N]=h[N].add(t[g])}let p=o;for(let g=h.length-1,y=o;g>0;g--)y=y.add(h[g]),p=p.add(y);if(d=d.add(p),f!==0)for(let g=0;g<c;g++)d=d.double()}return d}function fh(s){return Tp(s.Fp),Kr(s,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ch(s.n,s.nBitLength),...s,p:s.Fp.ORDER})}function Va(s){s.lowS!==void 0&&ji("lowS",s.lowS),s.prehash!==void 0&&ji("prehash",s.prehash)}function Dp(s){const e=fh(s);Kr(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:i,a:r}=e;if(t){if(!i.eql(r,i.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class Lp extends Error{constructor(e=""){super(e)}}const Qt={Err:Lp,_tlv:{encode:(s,e)=>{const{Err:t}=Qt;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const i=e.length/2,r=ir(i);if(r.length/2&128)throw new t("tlv.encode: long form length too big");const n=i>127?ir(r.length/2|128):"";return ir(s)+n+r+e},decode(s,e){const{Err:t}=Qt;let i=0;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[i++]!==s)throw new t("tlv.decode: wrong tlv");const r=e[i++],n=!!(r&128);let o=0;if(!n)o=r;else{const c=r&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(i,i+c);if(l.length!==c)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(i+=c,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(s){const{Err:e}=Qt;if(s<ts)throw new e("integer: negative integers are not allowed");let t=ir(s);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(s){const{Err:e}=Qt;if(s[0]&128)throw new e("invalid signature integer: negative");if(s[0]===0&&!(s[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ks(s)}},toSig(s){const{Err:e,_int:t,_tlv:i}=Qt,r=yt("signature",s),{v:n,l:o}=i.decode(48,r);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,n),{v:l,l:h}=i.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(s){const{_tlv:e,_int:t}=Qt,i=e.encode(2,t.encode(s.r)),r=e.encode(2,t.encode(s.s)),n=i+r;return e.encode(48,n)}};function mn(s,e){return Fi(Gi(s,e))}const ts=BigInt(0),Ae=BigInt(1);BigInt(2);const yn=BigInt(3),Mp=BigInt(4);function qp(s){const e=Dp(s),{Fp:t}=e,i=Yo(e.n,e.nBitLength),r=e.toBytes||((S,I,O)=>{const k=I.toAffine();return Tr(Uint8Array.from([4]),t.toBytes(k.x),t.toBytes(k.y))}),n=e.fromBytes||(S=>{const I=S.subarray(1),O=t.fromBytes(I.subarray(0,t.BYTES)),k=t.fromBytes(I.subarray(t.BYTES,2*t.BYTES));return{x:O,y:k}});function o(S){const{a:I,b:O}=e,k=t.sqr(S),U=t.mul(k,S);return t.add(t.add(U,t.mul(S,I)),O)}function a(S,I){const O=t.sqr(I),k=o(S);return t.eql(O,k)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=t.mul(t.pow(e.a,yn),Mp),l=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(c,l)))throw new Error("bad curve params: a or b");function h(S){return Ho(S,Ae,e.n)}function u(S){const{allowedPrivateKeyLengths:I,nByteLength:O,wrapPrivateKey:k,n:U}=e;if(I&&typeof S!="bigint"){if(Wi(S)&&(S=Fi(S)),typeof S!="string"||!I.includes(S.length))throw new Error("invalid private key");S=S.padStart(O*2,"0")}let L;try{L=typeof S=="bigint"?S:Ks(yt("private key",S,O))}catch{throw new Error("invalid private key, expected hex or "+O+" bytes, got "+typeof S)}return k&&(L=Xe(L,U)),oi("private key",L,Ae,U),L}function d(S){if(!(S instanceof g))throw new Error("ProjectivePoint expected")}const f=Ua((S,I)=>{const{px:O,py:k,pz:U}=S;if(t.eql(U,t.ONE))return{x:O,y:k};const L=S.is0();I==null&&(I=L?t.ONE:t.inv(U));const A=t.mul(O,I),B=t.mul(k,I),M=t.mul(U,I);if(L)return{x:t.ZERO,y:t.ZERO};if(!t.eql(M,t.ONE))throw new Error("invZ was invalid");return{x:A,y:B}}),p=Ua(S=>{if(S.is0()){if(e.allowInfinityPoint&&!t.is0(S.py))return;throw new Error("bad point: ZERO")}const{x:I,y:O}=S.toAffine();if(!t.isValid(I)||!t.isValid(O))throw new Error("bad point: x or y not FE");if(!a(I,O))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(I,O,k){if(I==null||!t.isValid(I))throw new Error("x required");if(O==null||!t.isValid(O)||t.is0(O))throw new Error("y required");if(k==null||!t.isValid(k))throw new Error("z required");this.px=I,this.py=O,this.pz=k,Object.freeze(this)}static fromAffine(I){const{x:O,y:k}=I||{};if(!I||!t.isValid(O)||!t.isValid(k))throw new Error("invalid affine point");if(I instanceof g)throw new Error("projective point not allowed");const U=L=>t.eql(L,t.ZERO);return U(O)&&U(k)?g.ZERO:new g(O,k,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(I){const O=ah(t,I.map(k=>k.pz));return I.map((k,U)=>k.toAffine(O[U])).map(g.fromAffine)}static fromHex(I){const O=g.fromAffine(n(yt("pointHex",I)));return O.assertValidity(),O}static fromPrivateKey(I){return g.BASE.multiply(u(I))}static msm(I,O){return Bp(g,i,I,O)}_setWindowSize(I){$.setWindowSize(this,I)}assertValidity(){p(this)}hasEvenY(){const{y:I}=this.toAffine();if(t.isOdd)return!t.isOdd(I);throw new Error("Field doesn't support isOdd")}equals(I){d(I);const{px:O,py:k,pz:U}=this,{px:L,py:A,pz:B}=I,M=t.eql(t.mul(O,B),t.mul(L,U)),_=t.eql(t.mul(k,B),t.mul(A,U));return M&&_}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:I,b:O}=e,k=t.mul(O,yn),{px:U,py:L,pz:A}=this;let B=t.ZERO,M=t.ZERO,_=t.ZERO,b=t.mul(U,U),E=t.mul(L,L),m=t.mul(A,A),w=t.mul(U,L);return w=t.add(w,w),_=t.mul(U,A),_=t.add(_,_),B=t.mul(I,_),M=t.mul(k,m),M=t.add(B,M),B=t.sub(E,M),M=t.add(E,M),M=t.mul(B,M),B=t.mul(w,B),_=t.mul(k,_),m=t.mul(I,m),w=t.sub(b,m),w=t.mul(I,w),w=t.add(w,_),_=t.add(b,b),b=t.add(_,b),b=t.add(b,m),b=t.mul(b,w),M=t.add(M,b),m=t.mul(L,A),m=t.add(m,m),b=t.mul(m,w),B=t.sub(B,b),_=t.mul(m,E),_=t.add(_,_),_=t.add(_,_),new g(B,M,_)}add(I){d(I);const{px:O,py:k,pz:U}=this,{px:L,py:A,pz:B}=I;let M=t.ZERO,_=t.ZERO,b=t.ZERO;const E=e.a,m=t.mul(e.b,yn);let w=t.mul(O,L),x=t.mul(k,A),T=t.mul(U,B),v=t.add(O,k),C=t.add(L,A);v=t.mul(v,C),C=t.add(w,x),v=t.sub(v,C),C=t.add(O,U);let D=t.add(L,B);return C=t.mul(C,D),D=t.add(w,T),C=t.sub(C,D),D=t.add(k,U),M=t.add(A,B),D=t.mul(D,M),M=t.add(x,T),D=t.sub(D,M),b=t.mul(E,C),M=t.mul(m,T),b=t.add(M,b),M=t.sub(x,b),b=t.add(x,b),_=t.mul(M,b),x=t.add(w,w),x=t.add(x,w),T=t.mul(E,T),C=t.mul(m,C),x=t.add(x,T),T=t.sub(w,T),T=t.mul(E,T),C=t.add(C,T),w=t.mul(x,C),_=t.add(_,w),w=t.mul(D,C),M=t.mul(v,M),M=t.sub(M,w),w=t.mul(v,x),b=t.mul(D,b),b=t.add(b,w),new g(M,_,b)}subtract(I){return this.add(I.negate())}is0(){return this.equals(g.ZERO)}wNAF(I){return $.wNAFCached(this,I,g.normalizeZ)}multiplyUnsafe(I){const{endo:O,n:k}=e;oi("scalar",I,ts,k);const U=g.ZERO;if(I===ts)return U;if(this.is0()||I===Ae)return this;if(!O||$.hasPrecomputes(this))return $.wNAFCachedUnsafe(this,I,g.normalizeZ);let{k1neg:L,k1:A,k2neg:B,k2:M}=O.splitScalar(I),_=U,b=U,E=this;for(;A>ts||M>ts;)A&Ae&&(_=_.add(E)),M&Ae&&(b=b.add(E)),E=E.double(),A>>=Ae,M>>=Ae;return L&&(_=_.negate()),B&&(b=b.negate()),b=new g(t.mul(b.px,O.beta),b.py,b.pz),_.add(b)}multiply(I){const{endo:O,n:k}=e;oi("scalar",I,Ae,k);let U,L;if(O){const{k1neg:A,k1:B,k2neg:M,k2:_}=O.splitScalar(I);let{p:b,f:E}=this.wNAF(B),{p:m,f:w}=this.wNAF(_);b=$.constTimeNegate(A,b),m=$.constTimeNegate(M,m),m=new g(t.mul(m.px,O.beta),m.py,m.pz),U=b.add(m),L=E.add(w)}else{const{p:A,f:B}=this.wNAF(I);U=A,L=B}return g.normalizeZ([U,L])[0]}multiplyAndAddUnsafe(I,O,k){const U=g.BASE,L=(B,M)=>M===ts||M===Ae||!B.equals(U)?B.multiplyUnsafe(M):B.multiply(M),A=L(this,O).add(L(I,k));return A.is0()?void 0:A}toAffine(I){return f(this,I)}isTorsionFree(){const{h:I,isTorsionFree:O}=e;if(I===Ae)return!0;if(O)return O(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:I,clearCofactor:O}=e;return I===Ae?this:O?O(g,this):this.multiplyUnsafe(e.h)}toRawBytes(I=!0){return ji("isCompressed",I),this.assertValidity(),r(g,this,I)}toHex(I=!0){return ji("isCompressed",I),Fi(this.toRawBytes(I))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:y,nBitLength:N}=e,$=Up(g,y?Math.ceil(N/2):N);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:h}}function jp(s){const e=fh(s);return Kr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Fp(s){const e=jp(s),{Fp:t,n:i,nByteLength:r,nBitLength:n}=e,o=t.BYTES+1,a=2*t.BYTES+1;function c(m){return Xe(m,i)}function l(m){return Xn(m,i)}const{ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=qp({...e,toBytes(m,w,x){const T=w.toAffine(),v=t.toBytes(T.x),C=Tr;return ji("isCompressed",x),x?C(Uint8Array.from([w.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,t.toBytes(T.y))},fromBytes(m){const w=m.length,x=m[0],T=m.subarray(1);if(w===o&&(x===2||x===3)){const v=Ks(T);if(!Ho(v,Ae,t.ORDER))throw new Error("Point is not on curve");const C=d(v);let D;try{D=t.sqrt(C)}catch(H){const V=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+V)}const q=(D&Ae)===Ae;return(x&1)===1!==q&&(D=t.neg(D)),{x:v,y:D}}else if(w===a&&x===4){const v=t.fromBytes(T.subarray(0,t.BYTES)),C=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:v,y:C}}else{const v=o,C=a;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+w)}}});function p(m){const w=i>>Ae;return m>w}function g(m){return p(m)?c(-m):m}const y=(m,w,x)=>Ks(m.slice(w,x));class N{constructor(w,x,T){oi("r",w,Ae,i),oi("s",x,Ae,i),this.r=w,this.s=x,T!=null&&(this.recovery=T),Object.freeze(this)}static fromCompact(w){const x=r;return w=yt("compactSignature",w,x*2),new N(y(w,0,x),y(w,x,2*x))}static fromDER(w){const{r:x,s:T}=Qt.toSig(yt("DER",w));return new N(x,T)}assertValidity(){}addRecoveryBit(w){return new N(this.r,this.s,w)}recoverPublicKey(w){const{r:x,s:T,recovery:v}=this,C=U(yt("msgHash",w));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");const D=v===2||v===3?x+e.n:x;if(D>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=(v&1)===0?"02":"03",G=h.fromHex(q+mn(D,t.BYTES)),H=l(D),V=c(-C*H),Z=c(T*H),W=h.BASE.multiplyAndAddUnsafe(G,V,Z);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new N(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Nr(this.toDERHex())}toDERHex(){return Qt.hexFromSig(this)}toCompactRawBytes(){return Nr(this.toCompactHex())}toCompactHex(){const w=r;return mn(this.r,w)+mn(this.s,w)}}const $={isValidPrivateKey(m){try{return u(m),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const m=hh(e.n);return kp(e.randomBytes(m),e.n)},precompute(m=8,w=h.BASE){return w._setWindowSize(m),w.multiply(BigInt(3)),w}};function S(m,w=!0){return h.fromPrivateKey(m).toRawBytes(w)}function I(m){if(typeof m=="bigint")return!1;if(m instanceof h)return!0;const x=yt("key",m).length,T=t.BYTES,v=T+1,C=2*T+1;if(!(e.allowedPrivateKeyLengths||r===v))return x===v||x===C}function O(m,w,x=!0){if(I(m)===!0)throw new Error("first arg must be private key");if(I(w)===!1)throw new Error("second arg must be public key");return h.fromHex(w).multiply(u(m)).toRawBytes(x)}const k=e.bits2int||function(m){if(m.length>8192)throw new Error("input is too large");const w=Ks(m),x=m.length*8-n;return x>0?w>>BigInt(x):w},U=e.bits2int_modN||function(m){return c(k(m))},L=zr(n);function A(m){return oi("num < 2^"+n,m,ts,L),Gi(m,r)}function B(m,w,x=M){if(["recovered","canonical"].some(Y=>Y in x))throw new Error("sign() legacy options not supported");const{hash:T,randomBytes:v}=e;let{lowS:C,prehash:D,extraEntropy:q}=x;C==null&&(C=!0),m=yt("msgHash",m),Va(x),D&&(m=yt("prehashed msgHash",T(m)));const G=U(m),H=u(w),V=[A(H),A(G)];if(q!=null&&q!==!1){const Y=q===!0?v(t.BYTES):q;V.push(yt("extraEntropy",Y))}const Z=Tr(...V),W=G;function oe(Y){const le=k(Y);if(!f(le))return;const je=l(le),He=h.BASE.multiply(le).toAffine(),Fe=c(He.x);if(Fe===ts)return;const dt=c(je*c(W+Fe*H));if(dt===ts)return;let cs=(He.x===Fe?0:2)|Number(He.y&Ae),va=dt;return C&&p(dt)&&(va=g(dt),cs^=1),new N(Fe,va,cs)}return{seed:Z,k2sig:oe}}const M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function b(m,w,x=M){const{seed:T,k2sig:v}=B(m,w,x),C=e;return qf(C.hash.outputLen,C.nByteLength,C.hmac)(T,v)}h.BASE._setWindowSize(8);function E(m,w,x,T=_){const v=m;w=yt("msgHash",w),x=yt("publicKey",x);const{lowS:C,prehash:D,format:q}=T;if(Va(T),"strict"in T)throw new Error("options.strict was renamed to lowS");if(q!==void 0&&q!=="compact"&&q!=="der")throw new Error("format must be compact or der");const G=typeof v=="string"||Wi(v),H=!G&&!q&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!G&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,Z;try{if(H&&(V=new N(v.r,v.s)),G){try{q!=="compact"&&(V=N.fromDER(v))}catch(cs){if(!(cs instanceof Qt.Err))throw cs}!V&&q!=="der"&&(V=N.fromCompact(v))}Z=h.fromHex(x)}catch{return!1}if(!V||C&&V.hasHighS())return!1;D&&(w=e.hash(w));const{r:W,s:oe}=V,Y=U(w),le=l(oe),je=c(Y*le),He=c(W*le),Fe=h.BASE.multiplyAndAddUnsafe(Z,je,He)?.toAffine();return Fe?c(Fe.x)===W:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:O,sign:b,verify:E,ProjectivePoint:h,Signature:N,utils:$}}function zp(s){return{hash:s,hmac:(e,...t)=>qd(s,e,Ld(...t)),randomBytes:Dd}}function Kp(s,e){const t=i=>Fp({...s,...zp(i)});return{...t(e),create:t}}const ph=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ha=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Vp=BigInt(0),Hp=BigInt(1),eo=BigInt(2),Wa=(s,e)=>(s+e/eo)/e;function Wp(s){const e=ph,t=BigInt(3),i=BigInt(6),r=BigInt(11),n=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=s*s*s%e,h=l*l*s%e,u=ft(h,t,e)*h%e,d=ft(u,t,e)*h%e,f=ft(d,eo,e)*l%e,p=ft(f,r,e)*f%e,g=ft(p,n,e)*p%e,y=ft(g,a,e)*g%e,N=ft(y,c,e)*y%e,$=ft(N,a,e)*g%e,S=ft($,t,e)*h%e,I=ft(S,o,e)*p%e,O=ft(I,i,e)*l%e,k=ft(O,eo,e);if(!to.eql(to.sqr(k),s))throw new Error("Cannot find square root");return k}const to=Yo(ph,void 0,void 0,{sqrt:Wp}),Gp=Kp({a:Vp,b:BigInt(7),Fp:to,n:Ha,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:s=>{const e=Ha,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Hp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=t,o=BigInt("0x100000000000000000000000000000000"),a=Wa(n*s,e),c=Wa(-i*s,e);let l=Xe(s-a*t-c*r,e),h=Xe(-a*i-c*n,e);const u=l>o,d=h>o;if(u&&(l=e-l),d&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+s);return{k1neg:u,k1:l,k2neg:d,k2:h}}}},Md);function Yp(s){if(s.length!==130&&s.length!==132)throw new Jp({signature:s});const e=BigInt(Jt(s,0,32)),t=BigInt(Jt(s,32,64)),i=(()=>{const r=+`0x${s.slice(130)}`;if(!Number.isNaN(r))try{return Zp(r)}catch{throw new Xp({value:r})}})();return typeof i>"u"?{r:e,s:t}:{r:e,s:t,yParity:i}}function Zp(s){if(s===0||s===27)return 0;if(s===1||s===28)return 1;if(s>=35)return s%2===0?1:0;throw new Qp({value:s})}class Jp extends ge{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Cs(Go(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Xp extends ge{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class Qp extends ge{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function eg(s){return Ip(tg(s))}function tg(s){const{payload:e,signature:t}=s,{r:i,s:r,yParity:n}=t,a=new Gp.Signature(BigInt(i),BigInt(r)).addRecoveryBit(n).recoverPublicKey(Go(e).substring(2));return fp(a)}function sg(s){const e=s.length;let t=0,i=0;for(;i<e;){let r=s.charCodeAt(i++);if((r&4294967168)===0){t++;continue}else if((r&4294965248)===0)t+=2;else{if(r>=55296&&r<=56319&&i<e){const n=s.charCodeAt(i);(n&64512)===56320&&(++i,r=((r&1023)<<10)+(n&1023)+65536)}(r&4294901760)===0?t+=3:t+=4}}return t}function ig(s,e,t){const i=s.length;let r=t,n=0;for(;n<i;){let o=s.charCodeAt(n++);if((o&4294967168)===0){e[r++]=o;continue}else if((o&4294965248)===0)e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&n<i){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128):(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128)}e[r++]=o&63|128}}const rg=new TextEncoder,ng=50;function og(s,e,t){rg.encodeInto(s,e.subarray(t))}function ag(s,e,t){s.length>ng?og(s,e,t):ig(s,e,t)}const cg=4096;function gh(s,e,t){let i=e;const r=i+t,n=[];let o="";for(;i<r;){const a=s[i++];if((a&128)===0)n.push(a);else if((a&224)===192){const c=s[i++]&63;n.push((a&31)<<6|c)}else if((a&240)===224){const c=s[i++]&63,l=s[i++]&63;n.push((a&31)<<12|c<<6|l)}else if((a&248)===240){const c=s[i++]&63,l=s[i++]&63,h=s[i++]&63;let u=(a&7)<<18|c<<12|l<<6|h;u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u)}else n.push(a);n.length>=cg&&(o+=String.fromCharCode(...n),n.length=0)}return n.length>0&&(o+=String.fromCharCode(...n)),o}const lg=new TextDecoder,hg=200;function ug(s,e,t){const i=s.subarray(e,e+t);return lg.decode(i)}function dg(s,e,t){return t>hg?ug(s,e,t):gh(s,e,t)}class nr{type;data;constructor(e,t){this.type=e,this.data=t}}class at extends Error{constructor(e){super(e);const t=Object.create(at.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:at.name})}}const bi=4294967295;function fg(s,e,t){const i=t/4294967296,r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function mh(s,e,t){const i=Math.floor(t/4294967296),r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function yh(s,e){const t=s.getInt32(e),i=s.getUint32(e+4);return t*4294967296+i}function pg(s,e){const t=s.getUint32(e),i=s.getUint32(e+4);return t*4294967296+i}const gg=-1,mg=4294967296-1,yg=17179869184-1;function wg({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=yg)if(e===0&&s<=mg){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,i=s&4294967295,r=new Uint8Array(8),n=new DataView(r.buffer);return n.setUint32(0,e<<2|t&3),n.setUint32(4,i),r}else{const t=new Uint8Array(12),i=new DataView(t.buffer);return i.setUint32(0,e),mh(i,4,s),t}}function bg(s){const e=s.getTime(),t=Math.floor(e/1e3),i=(e-t*1e3)*1e6,r=Math.floor(i/1e9);return{sec:t+r,nsec:i-r*1e9}}function vg(s){if(s instanceof Date){const e=bg(s);return wg(e)}else return null}function Eg(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),i=e.getUint32(4),r=(t&3)*4294967296+i,n=t>>>2;return{sec:r,nsec:n}}case 12:{const t=yh(e,4),i=e.getUint32(0);return{sec:t,nsec:i}}default:throw new at(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Ig(s){const e=Eg(s);return new Date(e.sec*1e3+e.nsec/1e6)}const xg={type:gg,encode:vg,decode:Ig};class Vr{static defaultCodec=new Vr;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(xg)}register({type:e,encode:t,decode:i}){if(e>=0)this.encoders[e]=t,this.decoders[e]=i;else{const r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=i}}tryToEncode(e,t){for(let i=0;i<this.builtInEncoders.length;i++){const r=this.builtInEncoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=-1-i;return new nr(o,n)}}}for(let i=0;i<this.encoders.length;i++){const r=this.encoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=i;return new nr(o,n)}}}return e instanceof nr?e:null}decode(e,t,i){const r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,i):new nr(t,e)}}function Sg(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function so(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Sg(s)?new Uint8Array(s):Uint8Array.from(s)}const Cg=100,Ag=2048;class Zo{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Vr.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Cg,this.initialBufferSize=e?.initialBufferSize??Ag,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Zo({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),i=new Uint8Array(t),r=new DataView(t);i.set(this.bytes),this.view=r,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const i=sg(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),ag(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,t){const i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const i=so(e);this.writeU8a(i)}encodeArray(e,t){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let i=0;for(const r of t)e[r]!==void 0&&i++;return i}encodeMap(e,t){const i=Object.keys(e);this.sortKeys&&i.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const n of i){const o=e[n];this.ignoreUndefined&&o===void 0||(this.encodeString(n),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const i=e.data(this.pos+6),r=i.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(i);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),fg(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),mh(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function _g(s,e){return new Zo(e).encodeSharedRef(s)}function wn(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Pg=16,Ng=16;class Tg{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Pg,t=Ng){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,i){const r=this.caches[i-1];e:for(const n of r){const o=n.bytes;for(let a=0;a<i;a++)if(o[a]!==e[t+a])continue e;return n.str}return null}store(e,t){const i=this.caches[e.length-1],r={bytes:e,str:t};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=r:i.push(r)}decode(e,t,i){const r=this.find(e,t,i);if(r!=null)return this.hit++,r;this.miss++;const n=gh(e,t,i),o=Uint8Array.prototype.slice.call(e,t,t+i);return this.store(o,n),n}}const io="array",Bi="map_key",wh="map_value",Og=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new at("The type of key must be string or number but "+typeof s)};class kg{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=io,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=Bi,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===io){const i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Bi||e.type===wh){const i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const vi=-1,Jo=new DataView(new ArrayBuffer(0)),$g=new Uint8Array(Jo.buffer);try{Jo.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Ga=new RangeError("Insufficient data"),Rg=new Tg;class Xo{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Jo;bytes=$g;headByte=vi;stack=new kg;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Vr.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??bi,this.maxBinLength=e?.maxBinLength??bi,this.maxArrayLength=e?.maxArrayLength??bi,this.maxMapLength=e?.maxMapLength??bi,this.maxExtLength=e?.maxExtLength??bi,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Rg,this.mapKeyConverter=e?.mapKeyConverter??Og}clone(){return new Xo({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=vi,this.stack.reset()}setBuffer(e){const t=so(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===vi&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),i=so(e),r=new Uint8Array(t.length+i.length);r.set(t),r.set(i,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:i}=this;return new RangeError(`Extra ${t.byteLength-i} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,i;for await(const a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),t=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}const{headByte:r,pos:n,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${wn(r)} at ${o} (${n} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let i=t,r=-1;for await(const n of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(n),i&&(r=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new at(`Unrecognized type byte: ${wn(e)}`);this.complete();const i=this.stack;for(;i.length>0;){const r=i.top();if(r.type===io)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,i.release(r);else continue e;else if(r.type===Bi){if(t==="__proto__")throw new at("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=wh;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,i.release(r);else{r.key=null,r.type=Bi;continue e}}return t}}readHeadByte(){return this.headByte===vi&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=vi}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new at(`Unrecognized array type byte: ${wn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new at(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new at(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new at(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ga;const i=this.pos+t;let r;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?r=this.keyDecoder.decode(this.bytes,i,e):r=dg(this.bytes,i,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Bi:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new at(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ga;const i=this.pos+t,r=this.bytes.subarray(i,i+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new at(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=pg(this.view,this.pos);return this.pos+=8,e}readI64(){const e=yh(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function Ug(s,e){return new Xo(e).decode(s)}var Bg={};const Dg=":";function is(s){const[e,t]=s.split(Dg);return{namespace:e,reference:t}}function bh(s,e){return s.includes(":")?[s]:e.chains||[]}const Lg={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}},Mg={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 F(s,e){const{message:t,code:i}=Mg[s];return{message:e?`${t} ${e}`:t,code:i}}function pe(s,e){const{message:t,code:i}=Lg[s];return{message:e?`${t} ${e}`:t,code:i}}var qg=Object.defineProperty,jg=Object.defineProperties,Fg=Object.getOwnPropertyDescriptors,Ya=Object.getOwnPropertySymbols,zg=Object.prototype.hasOwnProperty,Kg=Object.prototype.propertyIsEnumerable,ro=(s,e,t)=>e in s?qg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Za=(s,e)=>{for(var t in e||(e={}))zg.call(e,t)&&ro(s,t,e[t]);if(Ya)for(var t of Ya(e))Kg.call(e,t)&&ro(s,t,e[t]);return s},Vg=(s,e)=>jg(s,Fg(e)),Ja=(s,e,t)=>ro(s,typeof e!="symbol"?e+"":e,t);const Hg="ReactNative",lt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Wg="js";function kr(){return typeof $i<"u"&&typeof $i.versions<"u"&&typeof $i.versions.node<"u"}function _s(){return!os.getDocument()&&!!os.getNavigator()&&navigator.product===Hg}function Gg(){return _s()&&typeof globalThis<"u"&&typeof globalThis?.Platform<"u"&&globalThis?.Platform.OS==="android"}function Yg(){return _s()&&typeof globalThis<"u"&&typeof globalThis?.Platform<"u"&&globalThis?.Platform.OS==="ios"}function mi(){return!kr()&&!!os.getNavigator()&&!!os.getDocument()}function Yi(){return _s()?lt.reactNative:kr()?lt.node:mi()?lt.browser:lt.unknown}function Xa(){var s;try{return _s()&&typeof globalThis<"u"&&typeof globalThis?.Application<"u"?(s=globalThis.Application)==null?void 0:s.applicationId:void 0}catch{return}}function Zg(s,e){const t=new URLSearchParams(s);return Object.entries(e).sort(([i],[r])=>i.localeCompare(r)).forEach(([i,r])=>{r!=null&&t.set(i,String(r))}),t.toString()}function Jg(s){var e,t;const i=vh();try{return s!=null&&s.url&&i.url&&new URL(s.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${s.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),s.url=i.url),(e=s?.icons)!=null&&e.length&&s.icons.length>0&&(s.icons=s.icons.filter(r=>r!=="")),Vg(Za(Za({},i),s),{url:s?.url||i.url,name:s?.name||i.name,description:s?.description||i.description,icons:(t=s?.icons)!=null&&t.length&&s.icons.length>0?s.icons:i.icons})}catch(r){return console.warn("Error populating app metadata",r),s||i}}function vh(){return Id.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function Xg(){if(Yi()===lt.reactNative&&typeof globalThis<"u"&&typeof globalThis?.Platform<"u"){const{OS:t,Version:i}=globalThis.Platform;return[t,i].join("-")}const s=od();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function Qg(){var s;const e=Yi();return e===lt.browser?[e,((s=os.getLocation())==null?void 0:s.host)||"unknown"].join(":"):e}function Eh(s,e,t){const i=Xg(),r=Qg();return[[s,e].join("-"),[Wg,t].join("-"),i,r].join("/")}function em({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=Eh(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=Zg(l[1]||"",u);return l[0]+"?"+d}function Ms(s,e){return s.filter(t=>e.includes(t)).length===s.length}function no(s){return Object.fromEntries(s.entries())}function oo(s){return new Map(Object.entries(s))}function Rs(s=j.FIVE_MINUTES,e){const t=j.toMiliseconds(s||j.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=F("EXPIRED"),h=new Error(e||l.message);h.code=l.code,c(h)},t),i=a,r=c})}}function Mt(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Ih(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.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: ${s}`)}function tm(s){return Ih("topic",s)}function sm(s){return Ih("id",s)}function xh(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ve(s,e){return j.fromMiliseconds(Date.now()+j.toMiliseconds(s))}function Lt(s){return Date.now()>=j.toMiliseconds(s)}function ae(s,e){return`${s}${e?`:${e}`:""}`}function jt(s=[],e=[]){return[...new Set([...s,...e])]}async function im({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r?.href;if(typeof n!="string")return;const o=rm(n,s,e),a=Yi();if(a===lt.browser){if(!((i=os.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}nm(o)}else a===lt.reactNative&&typeof globalThis?.Linking<"u"&&await globalThis.Linking.openURL(o)}catch(r){console.error(r)}}function rm(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${lm(i,!0)}`}else r=`${r}/wc?${i}`;return r}function nm(s){let e="_self";cm()?e="_top":(am()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function om(s,e){let t="";try{if(mi()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Qa(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function ec(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function Qo(){return typeof $i<"u"&&Bg.IS_VITEST==="true"}function am(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function cm(){try{return window.self!==window.top}catch{return!1}}function lm(s,e=!1){const t=se.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function Sh(s){return se.from(s,"base64").toString("utf-8")}function hm(s){return new Promise(e=>setTimeout(e,s))}let um=class{constructor({limit:e}){Ja(this,"limit"),Ja(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const t=this.set.values().next().value;t&&this.set.delete(t)}this.set.add(e)}}has(e){return this.set.has(e)}};const or=BigInt(2**32-1),tc=BigInt(32);function Ch(s,e=!1){return e?{h:Number(s&or),l:Number(s>>tc&or)}:{h:Number(s>>tc&or)|0,l:Number(s&or)|0}}function Ah(s,e=!1){const t=s.length;let i=new Uint32Array(t),r=new Uint32Array(t);for(let n=0;n<t;n++){const{h:o,l:a}=Ch(s[n],e);[i[n],r[n]]=[o,a]}return[i,r]}const sc=(s,e,t)=>s>>>t,ic=(s,e,t)=>s<<32-t|e>>>t,ys=(s,e,t)=>s>>>t|e<<32-t,ws=(s,e,t)=>s<<32-t|e>>>t,Ni=(s,e,t)=>s<<64-t|e>>>t-32,Ti=(s,e,t)=>s>>>t-32|e<<64-t,dm=(s,e)=>e,fm=(s,e)=>s,pm=(s,e,t)=>s<<t|e>>>32-t,gm=(s,e,t)=>e<<t|s>>>32-t,mm=(s,e,t)=>e<<t-32|s>>>64-t,ym=(s,e,t)=>s<<t-32|e>>>64-t;function St(s,e,t,i){const r=(e>>>0)+(i>>>0);return{h:s+t+(r/2**32|0)|0,l:r|0}}const ea=(s,e,t)=>(s>>>0)+(e>>>0)+(t>>>0),ta=(s,e,t,i)=>e+t+i+(s/2**32|0)|0,wm=(s,e,t,i)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0),bm=(s,e,t,i,r)=>e+t+i+r+(s/2**32|0)|0,vm=(s,e,t,i,r)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),Em=(s,e,t,i,r,n)=>e+t+i+r+n+(s/2**32|0)|0,Zs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Hr(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function as(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Pt(s,...e){if(!Hr(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Wr(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");as(s.outputLen),as(s.blockLen)}function As(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function sa(s,e){Pt(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function zi(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function vt(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}function bn(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Nt(s,e){return s<<32-e|s>>>e}const _h=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ph(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}const Gt=_h?s=>s:s=>Ph(s);function Im(s){for(let e=0;e<s.length;e++)s[e]=Ph(s[e]);return s}const bs=_h?s=>s:Im,Nh=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",xm=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function ai(s){if(Pt(s),Nh)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=xm[s[t]];return e}const Ht={_0:48,_9:57,A:65,F:70,a:97,f:102};function rc(s){if(s>=Ht._0&&s<=Ht._9)return s-Ht._0;if(s>=Ht.A&&s<=Ht.F)return s-(Ht.A-10);if(s>=Ht.a&&s<=Ht.f)return s-(Ht.a-10)}function $r(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(Nh)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=rc(s.charCodeAt(n)),a=rc(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function Th(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function _t(s){return typeof s=="string"&&(s=Th(s)),Pt(s),s}function Es(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Pt(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let Gr=class{};function Zi(s){const e=i=>s().update(_t(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Sm(s){const e=(i,r)=>s(r).update(_t(i)).digest(),t=s({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}function Gs(s=32){if(Zs&&typeof Zs.getRandomValues=="function")return Zs.getRandomValues(new Uint8Array(s));if(Zs&&typeof Zs.randomBytes=="function")return Uint8Array.from(Zs.randomBytes(s));throw new Error("crypto.getRandomValues must be defined")}const Cm=BigInt(0),Ei=BigInt(1),Am=BigInt(2),_m=BigInt(7),Pm=BigInt(256),Nm=BigInt(113),Oh=[],kh=[],$h=[];for(let s=0,e=Ei,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Oh.push(2*(5*i+t)),kh.push((s+1)*(s+2)/2%64);let r=Cm;for(let n=0;n<7;n++)e=(e<<Ei^(e>>_m)*Nm)%Pm,e&Am&&(r^=Ei<<(Ei<<BigInt(n))-Ei);$h.push(r)}const Rh=Ah($h,!0),Tm=Rh[0],Om=Rh[1],nc=(s,e,t)=>t>32?mm(s,e,t):pm(s,e,t),oc=(s,e,t)=>t>32?ym(s,e,t):gm(s,e,t);function km(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],u=nc(l,h,1)^t[a],d=oc(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=u,s[o+f+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=kh[o],c=nc(r,n,a),l=oc(r,n,a),h=Oh[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=Tm[i],s[1]^=Om[i]}vt(t)}let $m=class Uh extends Gr{constructor(e,t,i,r=!1,n=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,as(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=zi(this.state)}clone(){return this._cloneInto()}keccak(){bs(this.state32),km(this.state32,this.rounds),bs(this.state32),this.posOut=0,this.pos=0}update(e){As(this),e=_t(e),Pt(e);const{blockLen:t,state:i}=this,r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,(t&128)!==0&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){As(this,!1),Pt(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=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 as(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(sa(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,vt(this.state)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Uh(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Rm=(s,e,t)=>Zi(()=>new $m(e,s,t)),Um=Rm(1,136,256/8);function Bm(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function Dm(s,e,t){return s&e^~s&t}function Lm(s,e,t){return s&e^s&t^e&t}let Bh=class extends Gr{constructor(e,t,i,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=bn(this.buffer)}update(e){As(this),e=_t(e),Pt(e);const{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=bn(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){As(this),sa(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,vt(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;Bm(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=bn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=r,e.pos=a,r%t&&e.buffer.set(i),e}clone(){return this._cloneInto()}};const us=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Re=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Ue=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Mm=Uint32Array.from([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]),ds=new Uint32Array(64);class qm extends Bh{constructor(e=32){super(64,e,8,!1),this.A=us[0]|0,this.B=us[1]|0,this.C=us[2]|0,this.D=us[3]|0,this.E=us[4]|0,this.F=us[5]|0,this.G=us[6]|0,this.H=us[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)ds[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ds[u-15],f=ds[u-2],p=Nt(d,7)^Nt(d,18)^d>>>3,g=Nt(f,17)^Nt(f,19)^f>>>10;ds[u]=g+ds[u-7]+p+ds[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Nt(a,6)^Nt(a,11)^Nt(a,25),f=h+d+Dm(a,c,l)+Mm[u]+ds[u]|0,p=(Nt(i,2)^Nt(i,13)^Nt(i,22))+Lm(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+p|0}i=i+this.A|0,r=r+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,h=h+this.H|0,this.set(i,r,n,o,a,c,l,h)}roundClean(){vt(ds)}destroy(){this.set(0,0,0,0,0,0,0,0),vt(this.buffer)}}const Dh=Ah(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),jm=Dh[0],Fm=Dh[1],fs=new Uint32Array(80),ps=new Uint32Array(80);let ia=class extends Bh{constructor(e=64){super(128,e,16,!1),this.Ah=Ue[0]|0,this.Al=Ue[1]|0,this.Bh=Ue[2]|0,this.Bl=Ue[3]|0,this.Ch=Ue[4]|0,this.Cl=Ue[5]|0,this.Dh=Ue[6]|0,this.Dl=Ue[7]|0,this.Eh=Ue[8]|0,this.El=Ue[9]|0,this.Fh=Ue[10]|0,this.Fl=Ue[11]|0,this.Gh=Ue[12]|0,this.Gl=Ue[13]|0,this.Hh=Ue[14]|0,this.Hl=Ue[15]|0}get(){const{Ah:e,Al:t,Bh:i,Bl:r,Ch:n,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:f,Gl:p,Hh:g,Hl:y}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y){this.Ah=e|0,this.Al=t|0,this.Bh=i|0,this.Bl=r|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=g|0,this.Hl=y|0}process(e,t){for(let S=0;S<16;S++,t+=4)fs[S]=e.getUint32(t),ps[S]=e.getUint32(t+=4);for(let S=16;S<80;S++){const I=fs[S-15]|0,O=ps[S-15]|0,k=ys(I,O,1)^ys(I,O,8)^sc(I,O,7),U=ws(I,O,1)^ws(I,O,8)^ic(I,O,7),L=fs[S-2]|0,A=ps[S-2]|0,B=ys(L,A,19)^Ni(L,A,61)^sc(L,A,6),M=ws(L,A,19)^Ti(L,A,61)^ic(L,A,6),_=wm(U,M,ps[S-7],ps[S-16]),b=bm(_,k,B,fs[S-7],fs[S-16]);fs[S]=b|0,ps[S]=_|0}let{Ah:i,Al:r,Bh:n,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:f,Fl:p,Gh:g,Gl:y,Hh:N,Hl:$}=this;for(let S=0;S<80;S++){const I=ys(u,d,14)^ys(u,d,18)^Ni(u,d,41),O=ws(u,d,14)^ws(u,d,18)^Ti(u,d,41),k=u&f^~u&g,U=d&p^~d&y,L=vm($,O,U,Fm[S],ps[S]),A=Em(L,N,I,k,jm[S],fs[S]),B=L|0,M=ys(i,r,28)^Ni(i,r,34)^Ni(i,r,39),_=ws(i,r,28)^Ti(i,r,34)^Ti(i,r,39),b=i&n^i&a^n&a,E=r&o^r&c^o&c;N=g|0,$=y|0,g=f|0,y=p|0,f=u|0,p=d|0,{h:u,l:d}=St(l|0,h|0,A|0,B|0),l=a|0,h=c|0,a=n|0,c=o|0,n=i|0,o=r|0;const m=ea(B,_,E);i=ta(m,A,M,b),r=m|0}({h:i,l:r}=St(this.Ah|0,this.Al|0,i|0,r|0)),{h:n,l:o}=St(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:c}=St(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=St(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=St(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=St(this.Fh|0,this.Fl|0,f|0,p|0),{h:g,l:y}=St(this.Gh|0,this.Gl|0,g|0,y|0),{h:N,l:$}=St(this.Hh|0,this.Hl|0,N|0,$|0),this.set(i,r,n,o,a,c,l,h,u,d,f,p,g,y,N,$)}roundClean(){vt(fs,ps)}destroy(){vt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class zm extends ia{constructor(){super(48),this.Ah=Re[0]|0,this.Al=Re[1]|0,this.Bh=Re[2]|0,this.Bl=Re[3]|0,this.Ch=Re[4]|0,this.Cl=Re[5]|0,this.Dh=Re[6]|0,this.Dl=Re[7]|0,this.Eh=Re[8]|0,this.El=Re[9]|0,this.Fh=Re[10]|0,this.Fl=Re[11]|0,this.Gh=Re[12]|0,this.Gl=Re[13]|0,this.Hh=Re[14]|0,this.Hl=Re[15]|0}}const Be=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class Km extends ia{constructor(){super(32),this.Ah=Be[0]|0,this.Al=Be[1]|0,this.Bh=Be[2]|0,this.Bl=Be[3]|0,this.Ch=Be[4]|0,this.Cl=Be[5]|0,this.Dh=Be[6]|0,this.Dl=Be[7]|0,this.Eh=Be[8]|0,this.El=Be[9]|0,this.Fh=Be[10]|0,this.Fl=Be[11]|0,this.Gh=Be[12]|0,this.Gl=Be[13]|0,this.Hh=Be[14]|0,this.Hl=Be[15]|0}}const Yr=Zi(()=>new qm),Vm=Zi(()=>new ia),Hm=Zi(()=>new zm),Wm=Zi(()=>new Km),Gm=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),Ie=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),z=new Uint32Array(32);function gs(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=z[2*s],l=z[2*s+1],h=z[2*e],u=z[2*e+1],d=z[2*t],f=z[2*t+1],p=z[2*i],g=z[2*i+1],y=ea(c,h,o);l=ta(y,l,u,a),c=y|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:dm(g,p),Dl:fm(g)},{h:f,l:d}=St(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:ys(u,h,24),Bl:ws(u,h,24)},z[2*s]=c,z[2*s+1]=l,z[2*e]=h,z[2*e+1]=u,z[2*t]=d,z[2*t+1]=f,z[2*i]=p,z[2*i+1]=g}function ms(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=z[2*s],l=z[2*s+1],h=z[2*e],u=z[2*e+1],d=z[2*t],f=z[2*t+1],p=z[2*i],g=z[2*i+1],y=ea(c,h,o);l=ta(y,l,u,a),c=y|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:ys(g,p,16),Dl:ws(g,p,16)},{h:f,l:d}=St(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:Ni(u,h,63),Bl:Ti(u,h,63)},z[2*s]=c,z[2*s+1]=l,z[2*e]=h,z[2*e+1]=u,z[2*t]=d,z[2*t+1]=f,z[2*i]=p,z[2*i+1]=g}function Ym(s,e={},t,i,r){if(as(t),s<0||s>t)throw new Error("outputLen bigger than keyLen");const{key:n,salt:o,personalization:a}=e;if(n!==void 0&&(n.length<1||n.length>t))throw new Error("key length must be undefined or 1.."+t);if(o!==void 0&&o.length!==i)throw new Error("salt must be undefined or "+i);if(a!==void 0&&a.length!==r)throw new Error("personalization must be undefined or "+r)}class Zm extends Gr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,as(e),as(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=zi(this.buffer)}update(e){As(this),e=_t(e),Pt(e);const{blockLen:t,buffer:i,buffer32:r}=this,n=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<n;){this.pos===t&&(bs(r),this.compress(r,0,!1),bs(r),this.pos=0);const l=Math.min(t-this.pos,n-c),h=o+c;if(l===t&&!(h%4)&&c+l<n){const u=new Uint32Array(a,h,Math.floor((n-c)/4));bs(u);for(let d=0;c+t<n;d+=r.length,c+=t)this.length+=t,this.compress(u,d,!1);bs(u);continue}i.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){As(this),sa(e,this);const{pos:t,buffer32:i}=this;this.finished=!0,vt(this.buffer.subarray(t)),bs(i),this.compress(i,0,!0),bs(i);const r=zi(e);this.get().forEach((n,o)=>r[o]=Gt(n))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){const{buffer:t,length:i,finished:r,destroyed:n,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(t),e.destroyed=n,e.finished=r,e.length=i,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class Jm extends Zm{constructor(e={}){const t=e.dkLen===void 0?64:e.dkLen;super(128,t),this.v0l=Ie[0]|0,this.v0h=Ie[1]|0,this.v1l=Ie[2]|0,this.v1h=Ie[3]|0,this.v2l=Ie[4]|0,this.v2h=Ie[5]|0,this.v3l=Ie[6]|0,this.v3h=Ie[7]|0,this.v4l=Ie[8]|0,this.v4h=Ie[9]|0,this.v5l=Ie[10]|0,this.v5h=Ie[11]|0,this.v6l=Ie[12]|0,this.v6h=Ie[13]|0,this.v7l=Ie[14]|0,this.v7h=Ie[15]|0,Ym(t,e,64,16,16);let{key:i,personalization:r,salt:n}=e,o=0;if(i!==void 0&&(i=_t(i),o=i.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,n!==void 0){n=_t(n);const a=zi(n);this.v4l^=Gt(a[0]),this.v4h^=Gt(a[1]),this.v5l^=Gt(a[2]),this.v5h^=Gt(a[3])}if(r!==void 0){r=_t(r);const a=zi(r);this.v6l^=Gt(a[0]),this.v6h^=Gt(a[1]),this.v7l^=Gt(a[2]),this.v7h^=Gt(a[3])}if(i!==void 0){const a=new Uint8Array(this.blockLen);a.set(i),this.update(a)}}get(){let{v0l:e,v0h:t,v1l:i,v1h:r,v2l:n,v2h:o,v3l:a,v3h:c,v4l:l,v4h:h,v5l:u,v5h:d,v6l:f,v6h:p,v7l:g,v7h:y}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y){this.v0l=e|0,this.v0h=t|0,this.v1l=i|0,this.v1h=r|0,this.v2l=n|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=h|0,this.v5l=u|0,this.v5h=d|0,this.v6l=f|0,this.v6h=p|0,this.v7l=g|0,this.v7h=y|0}compress(e,t,i){this.get().forEach((c,l)=>z[l]=c),z.set(Ie,16);let{h:r,l:n}=Ch(BigInt(this.length));z[24]=Ie[8]^n,z[25]=Ie[9]^r,i&&(z[28]=~z[28],z[29]=~z[29]);let o=0;const a=Gm;for(let c=0;c<12;c++)gs(0,4,8,12,e,t+2*a[o++]),ms(0,4,8,12,e,t+2*a[o++]),gs(1,5,9,13,e,t+2*a[o++]),ms(1,5,9,13,e,t+2*a[o++]),gs(2,6,10,14,e,t+2*a[o++]),ms(2,6,10,14,e,t+2*a[o++]),gs(3,7,11,15,e,t+2*a[o++]),ms(3,7,11,15,e,t+2*a[o++]),gs(0,5,10,15,e,t+2*a[o++]),ms(0,5,10,15,e,t+2*a[o++]),gs(1,6,11,12,e,t+2*a[o++]),ms(1,6,11,12,e,t+2*a[o++]),gs(2,7,8,13,e,t+2*a[o++]),ms(2,7,8,13,e,t+2*a[o++]),gs(3,4,9,14,e,t+2*a[o++]),ms(3,4,9,14,e,t+2*a[o++]);this.v0l^=z[0]^z[16],this.v0h^=z[1]^z[17],this.v1l^=z[2]^z[18],this.v1h^=z[3]^z[19],this.v2l^=z[4]^z[20],this.v2h^=z[5]^z[21],this.v3l^=z[6]^z[22],this.v3h^=z[7]^z[23],this.v4l^=z[8]^z[24],this.v4h^=z[9]^z[25],this.v5l^=z[10]^z[26],this.v5h^=z[11]^z[27],this.v6l^=z[12]^z[28],this.v6h^=z[13]^z[29],this.v7l^=z[14]^z[30],this.v7h^=z[15]^z[31],vt(z)}destroy(){this.destroyed=!0,vt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Xm=Sm(s=>new Jm(s)),Qm="https://rpc.walletconnect.org/v1";function Lh(s){const e=`Ethereum Signed Message:
4
4
  ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+se.from(Um(t)).toString("hex")}async function ey(s,e,t,i,r,n){switch(t.t){case"eip191":return await ty(s,e,t.s);case"eip1271":return await sy(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function ty(s,e,t){const i=Yp(t);return eg({payload:Lh(e),signature:i}).toLowerCase()===s.toLowerCase()}async function sy(s,e,t,i,r,n){const o=is(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=t.substring(2),h=(l.length/2).toString(16).padStart(64,"0"),u=(e.startsWith("0x")?e:Lh(e)).substring(2),d=a+u+c+h+l,f=await fetch(`${n||Qm}/?chainId=${i}&projectId=${r}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:iy(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function iy(){return Date.now()+Math.floor(Math.random()*1e3)}function ry(s){const e=atob(s),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);const i=t[0];if(i===0)throw new Error("No signatures found");const r=1+i*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const n=se.from(s,"base64").slice(1,65);return Hi.encode(n)}function ny(s){const e=new Uint8Array(se.from(s,"base64")),t=Array.from("TransactionData::").map(n=>n.charCodeAt(0)),i=new Uint8Array(t.length+e.length);i.set(t),i.set(e,t.length);const r=Xm(i,{dkLen:32});return Hi.encode(r)}function ac(s){const e=new Uint8Array(Yr(oy(s)));return Hi.encode(e)}function oy(s){if(s instanceof Uint8Array)return s;if(Array.isArray(s))return new Uint8Array(s);if(typeof s=="object"&&s!=null&&s.data)return new Uint8Array(Object.values(s.data));if(typeof s=="object"&&s)return new Uint8Array(Object.values(s));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function cc(s){const e=se.from(s,"base64"),t=Ug(e).txn;if(!t)throw new Error("Invalid signed transaction: missing 'txn' field");const i=_g(t),r=se.from("TX"),n=se.concat([r,se.from(i)]),o=Wm(n);return Rd.encode(o).replace(/=+$/,"")}function vn(s){const e=[];let t=BigInt(s);for(;t>=BigInt(128);)e.push(Number(t&BigInt(127)|BigInt(128))),t>>=BigInt(7);return e.push(Number(t)),se.from(e)}function ay(s){const e=se.from(s.signed.bodyBytes,"base64"),t=se.from(s.signed.authInfoBytes,"base64"),i=se.from(s.signature.signature,"base64"),r=[];r.push(se.from([10])),r.push(vn(e.length)),r.push(e),r.push(se.from([18])),r.push(vn(t.length)),r.push(t),r.push(se.from([26])),r.push(vn(i.length)),r.push(i);const n=se.concat(r),o=Yr(n);return se.from(o).toString("hex").toUpperCase()}function cy(s){var e,t;const i=[];try{if(typeof s=="string")return i.push(s),i;if(typeof s!="object")return i;s!=null&&s.id&&i.push(s.id);const r=(t=(e=s?.capabilities)==null?void 0:e.caip345)==null?void 0:t.transactionHashes;r&&i.push(...r)}catch(r){console.warn("getWalletSendCallsHashes failed: ",r)}return i}var ly=Object.defineProperty,hy=Object.defineProperties,uy=Object.getOwnPropertyDescriptors,lc=Object.getOwnPropertySymbols,dy=Object.prototype.hasOwnProperty,fy=Object.prototype.propertyIsEnumerable,hc=(s,e,t)=>e in s?ly(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,py=(s,e)=>{for(var t in e||(e={}))dy.call(e,t)&&hc(s,t,e[t]);if(lc)for(var t of lc(e))fy.call(e,t)&&hc(s,t,e[t]);return s},gy=(s,e)=>hy(s,uy(e));const Mh="did:pkh:",my={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},yy=s=>s?my[s]||s:"",Zr=s=>s?.split(":"),wy=s=>{const e=s&&Zr(s);if(e)return s.includes(Mh)?e[3]:e[1]},by=s=>{const e=s&&Zr(s);if(e)return s.includes(Mh)?e[2]:e[0]},ao=s=>{const e=s&&Zr(s);if(e)return e[2]+":"+e[3]},Rr=s=>{const e=s&&Zr(s);if(e)return e.pop()};async function uc(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=qh(r,r.iss),o=Rr(r.iss);return await ey(o,n,i,ao(r.iss),t)}const qh=(s,e)=>{const t=by(e);if(!t)throw new Error("Invalid issuer: "+e);const i=`${s.domain} wants you to sign in with your ${yy(t)} account:`,r=Rr(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=s.statement||void 0;const o=`URI: ${s.aud||s.uri}`,a=`Version: ${s.version}`,c=`Chain ID: ${wy(e)}`,l=`Nonce: ${s.nonce}`,h=`Issued At: ${s.iat}`,u=s.exp?`Expiration Time: ${s.exp}`:void 0,d=s.nbf?`Not Before: ${s.nbf}`:void 0,f=s.requestId?`Request ID: ${s.requestId}`:void 0,p=s.resources?`Resources:${s.resources.map(y=>`
5
5
  - ${y}`).join("")}`:void 0,g=Er(s.resources);if(g){const y=Ki(g);n=Py(n,y)}return[i,r,"",n,"",o,a,c,l,h,u,d,f,p].filter(y=>y!=null).join(`
@@ -205,4 +205,4 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+se.from(Um(t)).toString(
205
205
  outline: none;
206
206
  appearance: none;
207
207
  }
208
- `,ki={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class wx extends dd{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new fd({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){const i=(this.provider?.session?.namespaces?.[e]?.accounts||[]).filter((r,n,o)=>o.indexOf(r)===n);return Promise.resolve({accounts:i.map(r=>_e.createAccount({caipAddress:r,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&be.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};const i=P.getAccountData();if(i?.balanceLoading&&e.chainId===P.state.activeCaipNetwork?.id)return{balance:i?.balance||"0.00",symbol:i?.balanceSymbol||""};const n=(await P.fetchTokenBalance()).find(o=>o.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&o.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:n?.quantity.numeric||"0.00",symbol:n?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return P.state.activeCaipNetwork?.chainNamespace===J.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Pd.encode(new TextEncoder().encode(i)),pubkey:r}},P.state.activeCaipNetwork?.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},P.state.activeCaipNetwork?.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:""})}emitFirstAvailableConnection(){}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){const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===J.CHAIN.EVM)try{await i.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:_a(t.id)}]})}catch(r){if(r.code===ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||r.code===ki.ERROR_INVALID_CHAIN_ID||r.code===ki.ERROR_CODE_DEFAULT||r?.data?.originalError?.code===ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await i.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:_a(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]})}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){return this.connectors.find(i=>i.type==="WALLET_CONNECT")?.provider}}const bx=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],yr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?be.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.headless}},vx={localSettingsOverridden:new Set,getApiConfig(s,e){return e?.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=yr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=yr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return a?.config===null?this.processFallbackFeature(s,o):a?.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return yr[s].processApi(e)},processFallbackFeature(s,e){return yr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await xs.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?be.DEFAULT_REMOTE_FEATURES:be.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of bx){const a=this.processFeature(o,t,i,r,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),be.DEFAULT_REMOTE_FEATURES}if(r&&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.`;Le.open({debugMessage:Me.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class Ex{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{if(t){const r=P.getCaipNetworks(t)?.find(a=>a.id===i);if(r)return r;const n=P.getNetworkData(t)?.caipNetwork;return n||P.getRequestedCaipNetworks(t).filter(a=>a.chainNamespace===t)?.[0]}return P.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>P.getCaipNetworks(t),this.getActiveChainNamespace=()=>P.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{P.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>P.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>P.state.activeChain===t||!t?P.state.activeCaipAddress:P.state.chains.get(t)?.accountState?.caipAddress,this.setClientId=t=>{Cr.setClientId(t)},this.getProvider=t=>de.getProvider(t),this.getProviderType=t=>de.getProviderId(t),this.getPreferredAccountType=t=>Hn(t),this.setCaipAddress=(t,i,r=!1)=>{P.setAccountProp("caipAddress",t,i,r),P.setAccountProp("address",_e.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{P.setAccountProp("balance",t,r),P.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{P.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{P.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{P.setAccountProp("user",t,i)},this.resetAccount=t=>{P.resetAccount(t)},this.setCaipNetwork=t=>{P.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{P.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{P.setAccountProp("status",t,i),ce.isConnected()?ne.setConnectionStatus("connected"):ne.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>P.getAccountData(t)?.address,this.setConnectors=t=>{const i=[...ce.state.allConnectors,...t];ce.setConnectors(i)},this.setConnections=(t,i)=>{ne.setConnections(t,i),me.setConnections(t,i)},this.fetchIdentity=t=>Cr.fetchIdentity(t),this.getReownName=t=>pd.getNamesForAddress(t),this.getConnectors=()=>ce.getConnectors(),this.getConnectorImage=t=>gd.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?Ea.getConnectionsData(t).connections:(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?Ea.getConnectionsData(t).recentConnections:(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await me.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ne.deleteAddressFromConnection(t),me.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=de.getProviderId(i),n=t?{...t,type:r}:void 0;P.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!P.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{const n=P.getAccountData(r)?.addressLabels||{};P.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{const r=P.getAccountData(i)?.addressLabels||{};P.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{const i=t||P.state.activeChain;return P.getAccountData(i)?.address},this.resetNetwork=t=>{P.resetNetwork(t)},this.addConnector=t=>{ce.addConnector(t)},this.resetWcConnection=()=>{me.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{P.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{P.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{P.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{K.setEIP6963Enabled(t)},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,t){const i=e?.map(n=>n.namespace).filter(n=>!!n);if(i?.length)return[...new Set(i)];const r=t?.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),e.features?.headless&&!md.hasInjectedConnectors()&&xs.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),K.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await vx.fetchRemoteFeatures(e)),await xs.fetchUsage(),K.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Yn.setOnrampProviders(this.remoteFeatures.onramp),(K.state.remoteFeatures?.email||Array.isArray(K.state.remoteFeatures?.socials)&&K.state.remoteFeatures?.socials.length>0)&&await this.checkAllowedOrigins(),K.state.features?.reownAuthentication||K.state.remoteFeatures?.reownAuthentication){const{ReownAuthentication:t}=await Ge(async()=>{const{ReownAuthentication:r}=await import("./features-DVWd8_kC.js");return{ReownAuthentication:r}},__vite__mapDeps([0,1,2,3,4,5,6,7])),i=K.state.siwx;i instanceof t||(i&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),K.setSIWX(new t))}}async openSend(e){const t=e.namespace||P.state.activeChain,i=this.getCaipAddress(t),r=this.getCaipNetwork(t)?.id;if(!i)throw new Error("openSend: caipAddress not found");if(r?.toString()!==e.chainId.toString()){const n=P.getCaipNetworkById(e.chainId,t);if(!n)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(n,{throwOnFailure:!0})}try{const n=rd.getTokenSymbolByAddress(e.assetAddress);n&&await xs.fetchTokenImages([n])}catch{}return await ls.open({view:"WalletSend",data:{send:e}}),new Promise((n,o)=>{const a=Ia.subscribeKey("hash",h=>{h&&(l(),n({hash:h}))}),c=ls.subscribe(h=>{h.open||(l(),o(new Error("Modal closed")))}),l=this.createCleanupHandler([a,c])})}toModalOptions(){function e(i){return i?.view==="Swap"}function t(i){return i?.view==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await xs.fetchAllowedOrigins();if(!_e.isClient())return;const t=window.location.origin;nn.isOriginAllowed(t,e,J.DEFAULT_ALLOWED_ANCESTORS)||Le.open(Me.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":Le.open(Me.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;Le.open({displayMessage:Me.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Me.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){const{...t}=e;delete t.adapters,delete t.universalProvider,Bt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(i=>i.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){yd.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&kt.setThemeMode(e.themeMode),e.themeVariables&&kt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");P.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&P.setActiveCaipNetwork(t)}initializeConnectionController(e){me.initialize(e.adapters??[]),me.setWcBasic(e.basic??!1)}initializeConnectorController(){ce.initialize(this.chainNamespaces)}initializeProjectSettings(e){K.setProjectId(e.projectId),K.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){K.setDebug(e.debug!==!1),K.setEnableWalletGuide(e.enableWalletGuide!==!1),K.setEnableWallets(e.enableWallets!==!1),K.setEIP6963Enabled(e.enableEIP6963!==!1),K.setEnableCoinbase(e.enableCoinbase!==!1),K.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),K.setEnableReconnect(e.enableReconnect!==!1),K.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),K.setCoinbasePreference(e.coinbasePreference),K.setEnableAuthLogger(e.enableAuthLogger!==!1),K.setCustomRpcUrls(e.customRpcUrls),K.setEnableEmbedded(e.enableEmbedded),K.setAllWallets(e.allWallets),K.setIncludeWalletIds(e.includeWalletIds),K.setExcludeWalletIds(e.excludeWalletIds),K.setFeaturedWalletIds(e.featuredWalletIds),K.setTokens(e.tokens),K.setTermsConditionsUrl(e.termsConditionsUrl),K.setPrivacyPolicyUrl(e.privacyPolicyUrl),K.setCustomWallets(e.customWallets),K.setFeatures(e.features),K.setAllowUnsupportedChain(e.allowUnsupportedChain),K.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),K.setPreferUniversalLinks(e.experimental_preferUniversalLinks),K.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),K.setMetadata(e.metadata),K.setDisableAppend(e.disableAppend),K.setEnableEmbedded(e.enableEmbedded),K.setSIWX(e.siwx),this.features=K.state.features??{},!e.projectId){Le.open(Me.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(e.adapters?.find(r=>r.namespace===J.CHAIN.EVM)&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");K.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return _e.isClient()?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=wi.getUnsupportedNetwork(`${t}:${e}`);P.setActiveCaipNetwork(i)}}getDefaultNetwork(){return wi.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return wi.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return wi.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>r.id===e.defaultNetwork?.id);return t?wi.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){try{this.setLoading(!0,e);let i={connections:[]};const r=this.getAdapter(e);return(P.state.chains.get(e)?.accountState?.caipAddress||!K.state.enableReconnect)&&r?.disconnect&&(i=await r.disconnect({id:t})),this.setLoading(!1,e),i}catch(i){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${i.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=P.state.activeChain,t=this.getAdapter(e),i=this.getCaipNetwork(e)?.id,r=me.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId(a?.clientId||null),ne.setConnectedNamespaces([...P.state.chains.keys()]),await this.syncWalletConnectAccount(),await wr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{const n=P.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o?.reconnect&&(await o?.reconnect({id:e,info:t,type:i,provider:r,chainId:this.getCaipNetwork()?.id}),ne.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||P.state.activeChain,o=ce.getConnectorId(n),a=t===J.CONNECTOR_ID.AUTH||o===J.CONNECTOR_ID.AUTH,c=t===J.CONNECTOR_ID.WALLET_CONNECT||o===J.CONNECTOR_ID.WALLET_CONNECT;try{const l=Array.from(P.state.chains.keys());let h=i?[i]:l;(c||a)&&(h=l);const u=h.map(async p=>{const g=ce.getConnectorId(p),y=t||g,N=await this.disconnectConnector(p,y);N&&(a&&ne.deleteConnectedSocialProvider(),N.connections.forEach($=>{ne.addDisconnectedConnectorId($.connectorId,p)})),r&&this.onDisconnectNamespace({chainNamespace:p,closeModal:!1})}),d=await Promise.allSettled(u);Ia.resetSend(),me.resetWcConnection(),wr.getSIWX()?.signOutOnDisconnect&&await wr.clearSessions(),ce.setFilterByNamespace(void 0),me.syncStorageConnections();const f=d.filter(p=>p.status==="rejected");if(f.length>0)throw new Error(f.map(p=>p.reason.message).join(", "));Bt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(l){throw new Error(`Failed to disconnect chains: ${l.message}`)}},checkInstalled:e=>e?e.some(t=>!!window.ethereum?.[String(t)]):!!window.ethereum,signMessage:async e=>{const t=P.state.activeChain,i=this.getAdapter(P.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");return(await i?.signMessage({message:e,address:r,provider:de.getProvider(t)}))?.signature||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(be.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=de.getProvider(t);return(await i?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}))?.hash||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===J.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=de.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");return(await i?.estimateGas({...e,provider:r,caipNetwork:n}))?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=P.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");return await this.syncIdentity({address:t,chainId:Number(this.getCaipNetwork()?.id),chainNamespace:e}),P.getAccountData()?.profileImage||!1},getEnsAddress:async e=>await nn.resolveReownName(e),writeContract:async e=>{const t=P.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=de.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");return(await i?.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}))?.hash},writeSolanaTransaction:async e=>{const t=P.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=de.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");return(await i?.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}))?.hash},parseUnits:(e,t)=>{const i=this.getAdapter(P.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return i?.parseUnits({value:e,decimals:t})??0n},formatUnits:(e,t)=>{const i=this.getAdapter(P.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return i?.formatUnits({value:e,decimals:t})??"0"},getCapabilities:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await t?.getCapabilities(e)},grantPermissions:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await t?.grantPermissions(e)},revokePermissions:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await t?.walletGetAssets(e)??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i?.id,e)}},me.setClient(this.connectionControllerClient)}async onConnectExternal(e){const t=P.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===Je.CONNECTOR_TYPE_AUTH&&J.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(u=>ce.getConnectorId(u)===J.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const l=this.getCaipNetworks().find(h=>h.chainNamespace===e.chain);l&&n&&this.setCaipNetwork(l)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:e.caipNetwork?.id||o?.id,rpcUrl:e.caipNetwork?.rpcUrls?.default?.http?.[0]||o?.rpcUrls?.default?.http?.[0]});if(c)return ne.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ne.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){const i=e.type===Je.CONNECTOR_TYPE_AUTH,r=Ar.getOtherAuthNamespaces(t?.connectedCaipNetwork?.chainNamespace),n=P.state.activeCaipNetwork,o=this.getAdapter(n?.chainNamespace);i&&(await Promise.all(r.map(async a=>{try{const c=de.getProvider(a),l=this.getCaipNetwork(a);await this.getAdapter(a)?.connect({...e,provider:c,socialUri:void 0,chainId:l?.id,rpcUrl:l?.rpcUrls?.default?.http?.[0]})&&(ne.addConnectedNamespace(a),ne.removeDisconnectedConnectorId(e.id,a),this.setStatus("connected",a),this.syncConnectedWalletInfo(a))}catch(c){Le.warn(Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(a,c instanceof Error?c.message:void 0),Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await o?.switchNetwork({caipNetwork:n}))}getApprovedCaipNetworksData(){if(de.getProviderId(P.state.activeChain)===Je.CONNECTOR_TYPE_WALLET_CONNECT){const t=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:this.universalProvider?.session?.peer?.metadata.name==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(t)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=de.getProviderId(t);if(e.chainNamespace===P.state.activeChain)await this.getAdapter(t)?.switchNetwork({caipNetwork:e});else if(this.setCaipNetwork(e),r===Je.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=ks.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{const r=e?.find(n=>n.namespace===i);return r?(r.construct({namespace:i,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:n})=>n===i)}),t[i]=r):t[i]=new wx({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){this.getAdapter(e)?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ne.getConnectionStatus();K.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ne.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id.toString()===n.toString()||l.caipNetworkId.toString()===n.toString()),a=P.state.activeChain===e,c=P.state.chains.get(e)?.accountState?.address;if(o){const l=a&&r?r:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(me.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=P.state.activeCaipNetwork;!r||!n?.id||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{this.handlePreviousConnectorConnection(o);const a=P.state.activeChain===e;o?.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o?.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=P.getNetworkData(e)?.caipNetwork?.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,n,e),ne.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){const t=e?.chain,i=e?.id,r=ce.getConnectorId(t),n=K.state.remoteFeatures?.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await me.disconnect({id:r,namespace:t})}catch(c){console.warn("Error disconnecting previous connector",c)}}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&await this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>me.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ne.deleteRecentWallet();const t=ne.getRecentWallet();Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:_e.isMobile()?"mobile":"qrcode",name:t?.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:t?.order}})}async syncNamespaceConnection(e){try{e===J.CHAIN.EVM&&_e.isSafeApp()&&ce.setConnectorId(J.CONNECTOR_ID.SAFE,e);const t=ce.getConnectorId(e);switch(this.setStatus("connecting",e),t){case J.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case J.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};P.resetAccount(t),P.resetNetwork(t),ne.removeConnectedNamespace(t);const r=Array.from(P.state.chains.keys());(t?[t]:r).forEach(o=>ne.addDisconnectedConnectorId(ce.getConnectorId(o)||"",o)),ce.removeConnectorId(t),de.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&ls.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t?.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=ce.getConnectorId(e),o=ce.getConnectors(e).find(a=>a.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const a=await t?.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]});a?(this.syncProvider({...a,chainNamespace:e}),await this.syncAccount({...a,chainNamespace:e}),this.setStatus("connected",e),Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:a.address,properties:{method:"browser",name:o.info?.name||o.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:o?.explorerWallet?.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){const e=Object.keys(this.universalProvider?.session?.namespaces||{}),t=this.chainNamespaces.map(async i=>{const r=this.getAdapter(i);if(!r)return;const n=this.universalProvider?.session?.namespaces?.[i]?.accounts||[],o=P.state.activeCaipNetwork?.id,a=n.find(l=>{const{chainId:h}=ks.parseCaipAddress(l);return h===o?.toString()})||n[0];if(a){const l=ks.validateCaipAddress(a),{chainId:h,address:u}=ks.parseCaipAddress(l);if(de.setProviderId(i,Je.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&P.state.activeCaipNetwork&&r.namespace!==J.CHAIN.EVM){const d=r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:P.state.activeCaipNetwork});de.setProvider(i,d)}else de.setProvider(i,this.universalProvider);ce.setConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,i),ne.addConnectedNamespace(i),await this.syncAccount({address:u,chainId:h,chainNamespace:i})}else e.includes(i)&&this.setStatus("disconnected",i);const c=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(i),P.setApprovedCaipNetworksData(i,{approvedCaipNetworkIds:c.approvedCaipNetworkIds,supportsAllNetworks:c.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){de.setProviderId(r,e),de.setProvider(r,t),ce.setConnectorId(i,r)}async syncAccount(e){const t=e.chainNamespace===P.state.activeChain,i=P.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ne.getActiveNetworkProps(),c=i?.id||a,l=P.state.activeCaipNetwork?.name===J.UNSUPPORTED_NETWORK_NAME,h=P.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let u=this.getCaipNetworks().find(g=>g.id.toString()===c.toString()),d=this.getCaipNetworks().find(g=>g.chainNamespace===o);if(!h&&!u&&!d){const g=this.getApprovedCaipNetworkIds()||[],y=g.find($=>ks.parseCaipNetworkId($)?.chainId===c.toString()),N=g.find($=>ks.parseCaipNetworkId($)?.chainNamespace===o);u=this.getCaipNetworks().find($=>$.caipNetworkId===y),d=this.getCaipNetworks().find($=>$.caipNetworkId===N||"deprecatedCaipNetworkId"in $&&$.deprecatedCaipNetworkId===N)}const f=u||d;f?.chainNamespace===P.state.activeChain?K.state.enableNetworkSwitch&&!K.state.allowUnsupportedChain&&P.state.activeCaipNetwork?.name===J.UNSUPPORTED_NETWORK_NAME?P.showUnsupportedChainUI():this.setCaipNetwork(f):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const p=this.getAddress(o);Ar.isLowerCaseMatch(r,p)||this.syncAccountInfo(r,f?.id,o),t?await this.syncBalance({address:r,chainId:f?.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i?.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||r?.split(":")[1];if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=ce.getConnectorId(e),i=de.getProviderId(e);if(i===Je.CONNECTOR_TYPE_ANNOUNCED||i===Je.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>{const a=o.id===t,c=o.info?.rdns===t,l=o.connectors?.some(h=>h.id===t||h.info?.rdns===t);return a||c||!!l});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(i===Je.CONNECTOR_TYPE_WALLET_CONNECT){const r=de.getProvider(e);r?.session&&this.setConnectedWalletInfo({...r.session.peer.metadata,name:r.session.peer.metadata.name,icon:r.session.peer.metadata.icons?.[0]},e)}else if(t&&(t===J.CONNECTOR_ID.COINBASE_SDK||t===J.CONNECTOR_ID.COINBASE)){const r=this.getConnectors().find(c=>c.id===t),n=r?.name||"Coinbase Wallet",o=r?.imageUrl||this.getConnectorImage(r),a=r?.info;this.setConnectedWalletInfo({...a,name:n,icon:o},e)}}async syncBalance(e){!Fd.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>i.id.toString()===e.chainId?.toString())||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=P.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){const e=ox.createLogger((r,...n)=>{r&&this.handleAlertError(r),console.error(...n)}),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};K.setManualWCControl(!!this.options?.manualWCControl),this.universalProvider=this.options.universalProvider??await wa.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(r){if(r instanceof Error&&r.message.includes("Missing or invalid. Record was recently deleted"))return;throw r}},K.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{nn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{me.setUri(t)},onConnect:t=>{const{address:i}=_e.getAccount(t[0]);for(const r of this.chainNamespaces)ne.removeDisconnectedConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,r);me.finalizeWcConnection(i)},onDisconnect:()=>{P.state.noAdapters&&this.resetAccount(e),me.resetWcConnection()},onChainChanged:t=>{const i=P.state.activeChain,r=i&&ce.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(P.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}o?.id.toString()!==n?.id.toString()&&o?.chainNamespace===n?.chainNamespace&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=P.state.activeChain,r=i&&ce.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(P.state.noAdapters||r)){const n=t?.[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){return!this.universalProviderInitPromise&&_e.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Bt.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}getDisabledCaipNetworks(){const e=P.getAllApprovedCaipNetworkIds(),t=P.getAllRequestedCaipNetworks();return _e.sortRequestedNetworks(e,t).filter(r=>P.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(Me.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Me.ALERT_ERRORS[o];a&&(Le.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:r})=>r===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e?.uri&&me.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?ls.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):ls.open(e)}async close(){await this.injectModalUi(),ls.close()}setLoading(e,t){ls.setLoading(e,t)}async disconnect(e){await me.disconnect({namespace:e})}getSIWX(){return K.state.siwx}getError(){return""}getChainId(){return P.state.activeCaipNetwork?.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){Le.open(Me.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await P.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return P.state.activeChain?de.state.providers[P.state.activeChain]:null}getWalletProviderType(){return de.getProviderId(P.state.activeChain)}subscribeProviders(e){return de.subscribeProviders(e)}getThemeMode(){return kt.state.themeMode}getThemeVariables(){return kt.state.themeVariables}setThemeMode(e){kt.setThemeMode(e),Do(kt.state.themeMode)}setTermsConditionsUrl(e){K.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){K.setPrivacyPolicyUrl(e)}setThemeVariables(e){kt.setThemeVariables(e),yx(kt.state.themeVariables)}subscribeTheme(e){return kt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?me.subscribe(e):(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){return e?P.state.chains.get(e)?.accountState?.connectedWalletInfo:P.getAccountData()?.connectedWalletInfo}getAccount(e){const t=e||P.state.activeChain,i=ce.getAuthConnector(t),r=P.getAccountData(t),n=ne.getConnectedConnectorId(P.state.activeChain),o=me.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>{const{caipNetwork:l}=c;return l?c.accounts.map(({address:h,type:u,publicKey:d})=>_e.createAccount({caipAddress:`${l.caipNetworkId}:${h}`,type:u||"eoa",publicKey:d})):[]});if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:_e.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===J.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ne.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:Hn(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=P.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=P.subscribe(r);i.push(o)}const n=ce.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return P.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})})}subscribeWalletInfo(e,t){return t?P.subscribeChainProp("accountState",i=>e(i?.connectedWalletInfo),t):P.subscribeChainProp("accountState",i=>e(i?.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return P.subscribeChainProp("accountState",t=>e(t?.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return P.subscribeKey("activeCaipNetwork",e)}getState(){return _r.state}getRemoteFeatures(){return K.state.remoteFeatures}subscribeState(e){return _r.subscribe(e)}subscribeRemoteFeatures(e){return K.subscribeKey("remoteFeatures",e)}showErrorMessage(e){xa.showError(e)}showSuccessMessage(e){xa.showSuccess(e)}getEvent(){return{...Bt.state}}subscribeEvents(e){return Bt.subscribe(e)}replace(e){$s.replace(e)}redirect(e){$s.push(e)}popTransactionStack(e){$s.popTransactionStack(e)}isOpen(){return ls.state.open}isTransactionStackEmpty(){return $s.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){K.setFeatures(e)}updateRemoteFeatures(e){K.setRemoteFeatures(e)}updateOptions(e){const i={...K.state||{},...e};K.setOptions(i)}setConnectMethodsOrder(e){K.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){K.setWalletFeaturesOrder(e)}setCollapseWallets(e){K.setCollapseWallets(e)}setSocialsOrder(e){K.setSocialsOrder(e)}getConnectMethodsOrder(){return wd.getConnectOrderMethod(K.state.features,ce.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||P.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&P.removeNetwork(e,t)}}let Ll=!1;class nd extends Ex{async onAuthProviderConnected(e){const t=Ar.userChainIdToChainNamespace(e?.chainId);if(e.message&&e.signature&&e.siwxMessage&&await wr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===J.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=K.state.defaultAccountTypes[t],n=Hn(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=P.getAccountData(t);this.setUser({...u?.user||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{on.checkIfRequestExists(t)?on.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(Sa.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(Sa.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=on.checkIfRequestIsSafe(i),n=this.getAddress(),o=P.state.activeCaipNetwork;r||(n&&o?.id&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=P.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");ce.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=P.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=kt.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:bd(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){const i=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===P.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=P.getAccountData(t)?.user||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&this.connectionControllerClient?.connectExternal){await e.init(),await this.syncAuthConnectorTheme(e),await this.connectionControllerClient?.connectExternal({id:J.CONNECTOR_ID.AUTH,info:{name:J.CONNECTOR_ID.AUTH},type:Je.CONNECTOR_TYPE_AUTH,provider:e,chainId:P.getNetworkData(t)?.caipNetwork?.id,chain:t}),this.setStatus("connected",t);const h=ne.getConnectedSocialProvider();h?Bt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:h,reconnect:!0}}):Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:this.universalProvider?.session?.peer?.metadata?.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:void 0}})}else ce.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ne.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){try{if(!_e.isTelegram())return;const t=ne.getTelegramSocialProvider();if(!t||!_e.isClient())return;const r=new URL(window.location.href).searchParams.get("result_uri");if(!r)return;t&&P.setAccountProp("socialProvider",t,e),await this.authProvider?.init();const n=ce.getAuthConnector();t&&n&&(this.setLoading(!0,e),await me.connectExternal({id:n.id,type:n.type,socialUri:r},n.chain),ne.setConnectedSocialProvider(t),ne.removeTelegramSocialProvider(),Bt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:t}}))}catch(t){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",t)}try{const t=new URL(window.location.href);t.searchParams.delete("result_uri"),window.history.replaceState({},document.title,t.toString())}catch(t){console.error("tma social login failed",t)}}createAuthProvider(e){if(!J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=this.remoteFeatures?.email,r=Array.isArray(this.remoteFeatures?.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Ar.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&this.options?.projectId&&n&&(this.authProvider=vd.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:this.getCaipNetwork(a)?.caipNetworkId,abortController:Me.EmbeddedWalletAbortController,onTimeout:l=>{l==="iframe_load_failed"?Le.open(Me.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):l==="iframe_request_timeout"?Le.open(Me.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):l==="unverified_domain"&&Le.open(Me.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:l=>Ed(l),getCaipNetworks:l=>P.getCaipNetworks(l)}),_r.subscribeOpen(l=>{!l&&this.isTransactionStackEmpty()&&this.authProvider?.rejectRpcRequests()}));const c=e===P.state.activeChain&&K.state.enableReconnect;K.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){this.createAuthProvider(e),this.authProvider&&this.chainAdapters?.[e]?.setAuthProvider?.(this.authProvider)}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&xs.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){if(!e)return;const t=P.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&P.getAccountData(i)?.caipAddress)await this.getAdapter(i)?.switchNetwork({caipNetwork:e}),this.setCaipNetwork(e);else{const a=de.getProviderId(t)===Je.CONNECTOR_TYPE_AUTH,c=de.getProviderId(i),l=c===Je.CONNECTOR_TYPE_AUTH,h=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((a&&c===void 0||l)&&h)try{P.state.activeChain=e.chainNamespace,r?await this.getAdapter(i)?.switchNetwork({caipNetwork:e}):await this.connectionControllerClient?.connectExternal?.({id:J.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:Je.CONNECTOR_TYPE_AUTH,caipNetwork:e}),this.setCaipNetwork(e)}catch{await this.getAdapter(i)?.switchNetwork({caipNetwork:e})}else c===Je.CONNECTOR_TYPE_WALLET_CONNECT?(P.state.noAdapters||await this.getAdapter(i)?.switchNetwork({caipNetwork:e}),this.setCaipNetwork(e),this.syncWalletConnectAccount()):(this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i}))}}async initialize(e){await super.initialize(e),this.chainNamespaces?.forEach(t=>{this.createAuthProviderForAdapter(t)}),await this.injectModalUi(),_r.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){if(i!==J.CHAIN.EVM)return;const r=`${i}:${t}`;if(this.caipNetworks?.find(a=>a.caipNetworkId===r)?.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=ce.getConnectorId(i)===J.CONNECTOR_ID.AUTH;try{const{name:a,avatar:c}=await this.fetchIdentity({address:e});!a&&o?await this.syncReownName(e,i):(this.setProfileName(a,i),this.setProfileImage(c,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=de.getProviderId(e);if(t===Je.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ne.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!_e.isClient())return;const e={...be.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!Ll)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),_e.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!K.state.disableAppend&&!K.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}Ll=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!_e.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Ge(()=>import("./embedded-wallet-BxgtT1uV.js"),__vite__mapDeps([8,9,10,11,3,4,1,2,5,6,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]))),t.email&&i.push(Ge(()=>import("./email-C8DRQjTT.js"),__vite__mapDeps([30,11,9,10,3,4,31,23,16,1,2,5,6,7,22,13,14,15,21,32,19,25,26,27,28,29]))),t.socials&&i.push(Ge(()=>import("./socials-Dx84-PrV.js"),__vite__mapDeps([33,9,10,13,11,3,4,34,14,15,1,2,5,6,7,35,22,18,21,16,36,12,37,38,25,26,27,28,29]))),t.swaps&&t.swaps.length>0&&i.push(Ge(()=>import("./swaps-CK9Sfcew.js"),__vite__mapDeps([39,9,10,11,3,4,21,16,22,13,40,1,2,5,6,7,41,38,42,12,43,19,14,15,25,26,27,28,29]))),e.send&&i.push(Ge(()=>import("./send-ByB5fOtm.js"),__vite__mapDeps([44,9,10,11,3,4,21,16,22,13,45,14,15,1,2,5,6,7,46,23,42,12,38,41,19,47,48,25,26,27,28,29]))),e.receive&&i.push(Ge(()=>import("./receive-t2TxUItI.js"),__vite__mapDeps([49,9,10,13,11,3,4,12,36,37,1,2,5,6,7,25,26,27,28,29]))),t.onramp&&t.onramp.length>0&&i.push(Ge(()=>import("./onramp--l5ZLxWE.js"),__vite__mapDeps([50,9,10,13,11,3,4,51,16,34,14,15,1,2,5,6,7,12,52,53,23,21,22,19,25,26,27,28,29]))),t.payWithExchange&&i.push(Ge(()=>import("./pay-with-exchange-CiXPJJ6-.js"),__vite__mapDeps([54,9,10,13,11,3,4,12,20,51,16,38,21,46,14,15,23,1,2,5,6,7,55,22,19,47,45,25,26,27,28,29]))),t.activity&&i.push(Ge(()=>import("./transactions-BLOC2qYE.js"),__vite__mapDeps([56,9,11,10,3,4,57,22,13,23,12,38,1,2,5,6,7,25,26,27,28,29]))),(e.pay||t.payments)&&i.push(Ge(()=>import("./index-CH0zI801.js"),__vite__mapDeps([58,59,9,10,13,11,3,4,21,16,20,12,51,60,22,45,1,2,5,6,7,38,43,25,26,27,28,29]))),t.emailCapture&&i.push(Ge(()=>import("./data-capture-DnvAEYWK.js"),__vite__mapDeps([61,9,10,11,3,4,31,23,16,1,2,5,6,7,0,25,26,27,28,29]))),await Promise.all([...i,Ge(()=>import("./index-okvlQSs2.js"),__vite__mapDeps([62,9,10,13,11,3,4,12,16,48,1,2,5,6,7,22,63,53,23,17,18,60,20,51,21,55,57,38,47,40,43,45,14,15,19,32,34,35,36,37,24,52,25,26,27,28,29])),Ge(()=>import("./w3m-modal-CCQuGDus.js"),__vite__mapDeps([64,9,10,13,11,3,4,1,2,5,6,7,59,21,16,20,12,51,60,22,45,38,43,17,18,40,63,53,23,41,25,26,27,28,29]))])}}const Ix="1.8.19";function xx(s){return new nd({...s,sdkVersion:_e.generateSdkVersion(s.adapters??[],"html",Ix)})}const hS=Object.freeze(Object.defineProperty({__proto__:null,AppKit:nd,CoreHelperUtil:_e,WcConstantsUtil:ki,createAppKit:xx},Symbol.toStringTag,{value:"Module"}));export{Yn as O,sS as a,tS as b,nS as c,oS as d,lS as e,rS as f,iS as g,hS as h,aS as i,cS as r,mx as v};
208
+ `,ki={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class wx extends dd{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new fd({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){const i=(this.provider?.session?.namespaces?.[e]?.accounts||[]).filter((r,n,o)=>o.indexOf(r)===n);return Promise.resolve({accounts:i.map(r=>_e.createAccount({caipAddress:r,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&be.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};const i=P.getAccountData();if(i?.balanceLoading&&e.chainId===P.state.activeCaipNetwork?.id)return{balance:i?.balance||"0.00",symbol:i?.balanceSymbol||""};const n=(await P.fetchTokenBalance()).find(o=>o.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&o.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:n?.quantity.numeric||"0.00",symbol:n?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return P.state.activeCaipNetwork?.chainNamespace===J.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Pd.encode(new TextEncoder().encode(i)),pubkey:r}},P.state.activeCaipNetwork?.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},P.state.activeCaipNetwork?.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:""})}emitFirstAvailableConnection(){}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){const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===J.CHAIN.EVM)try{await i.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:_a(t.id)}]})}catch(r){if(r.code===ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||r.code===ki.ERROR_INVALID_CHAIN_ID||r.code===ki.ERROR_CODE_DEFAULT||r?.data?.originalError?.code===ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await i.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:_a(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]})}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){return this.connectors.find(i=>i.type==="WALLET_CONNECT")?.provider}}const bx=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],yr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!s?.config)return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?be.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?be.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?be.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>be.DEFAULT_REMOTE_FEATURES.headless}},vx={localSettingsOverridden:new Set,getApiConfig(s,e){return e?.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=yr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=yr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return a?.config===null?this.processFallbackFeature(s,o):a?.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return yr[s].processApi(e)},processFallbackFeature(s,e){return yr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await xs.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?be.DEFAULT_REMOTE_FEATURES:be.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of bx){const a=this.processFeature(o,t,i,r,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),be.DEFAULT_REMOTE_FEATURES}if(r&&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.`;Le.open({debugMessage:Me.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class Ex{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{if(t){const r=P.getCaipNetworks(t)?.find(a=>a.id===i);if(r)return r;const n=P.getNetworkData(t)?.caipNetwork;return n||P.getRequestedCaipNetworks(t).filter(a=>a.chainNamespace===t)?.[0]}return P.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>P.getCaipNetworks(t),this.getActiveChainNamespace=()=>P.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{P.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>P.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>P.state.activeChain===t||!t?P.state.activeCaipAddress:P.state.chains.get(t)?.accountState?.caipAddress,this.setClientId=t=>{Cr.setClientId(t)},this.getProvider=t=>de.getProvider(t),this.getProviderType=t=>de.getProviderId(t),this.getPreferredAccountType=t=>Hn(t),this.setCaipAddress=(t,i,r=!1)=>{P.setAccountProp("caipAddress",t,i,r),P.setAccountProp("address",_e.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{P.setAccountProp("balance",t,r),P.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{P.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{P.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{P.setAccountProp("user",t,i)},this.resetAccount=t=>{P.resetAccount(t)},this.setCaipNetwork=t=>{P.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{P.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{P.setAccountProp("status",t,i),ce.isConnected()?ne.setConnectionStatus("connected"):ne.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>P.getAccountData(t)?.address,this.setConnectors=t=>{const i=[...ce.state.allConnectors,...t];ce.setConnectors(i)},this.setConnections=(t,i)=>{ne.setConnections(t,i),me.setConnections(t,i)},this.fetchIdentity=t=>Cr.fetchIdentity(t),this.getReownName=t=>pd.getNamesForAddress(t),this.getConnectors=()=>ce.getConnectors(),this.getConnectorImage=t=>gd.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?Ea.getConnectionsData(t).connections:(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?Ea.getConnectionsData(t).recentConnections:(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await me.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ne.deleteAddressFromConnection(t),me.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=de.getProviderId(i),n=t?{...t,type:r}:void 0;P.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!P.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{const n=P.getAccountData(r)?.addressLabels||{};P.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{const r=P.getAccountData(i)?.addressLabels||{};P.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{const i=t||P.state.activeChain;return P.getAccountData(i)?.address},this.resetNetwork=t=>{P.resetNetwork(t)},this.addConnector=t=>{ce.addConnector(t)},this.resetWcConnection=()=>{me.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{P.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{P.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{P.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{K.setEIP6963Enabled(t)},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,t){const i=e?.map(n=>n.namespace).filter(n=>!!n);if(i?.length)return[...new Set(i)];const r=t?.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),e.features?.headless&&!md.hasInjectedConnectors()&&xs.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),K.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await vx.fetchRemoteFeatures(e)),await xs.fetchUsage(),K.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Yn.setOnrampProviders(this.remoteFeatures.onramp),(K.state.remoteFeatures?.email||Array.isArray(K.state.remoteFeatures?.socials)&&K.state.remoteFeatures?.socials.length>0)&&await this.checkAllowedOrigins(),K.state.features?.reownAuthentication||K.state.remoteFeatures?.reownAuthentication){const{ReownAuthentication:t}=await Ge(async()=>{const{ReownAuthentication:r}=await import("./features-fx-atM_l.js");return{ReownAuthentication:r}},__vite__mapDeps([0,1,2,3,4,5,6,7])),i=K.state.siwx;i instanceof t||(i&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),K.setSIWX(new t))}}async openSend(e){const t=e.namespace||P.state.activeChain,i=this.getCaipAddress(t),r=this.getCaipNetwork(t)?.id;if(!i)throw new Error("openSend: caipAddress not found");if(r?.toString()!==e.chainId.toString()){const n=P.getCaipNetworkById(e.chainId,t);if(!n)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(n,{throwOnFailure:!0})}try{const n=rd.getTokenSymbolByAddress(e.assetAddress);n&&await xs.fetchTokenImages([n])}catch{}return await ls.open({view:"WalletSend",data:{send:e}}),new Promise((n,o)=>{const a=Ia.subscribeKey("hash",h=>{h&&(l(),n({hash:h}))}),c=ls.subscribe(h=>{h.open||(l(),o(new Error("Modal closed")))}),l=this.createCleanupHandler([a,c])})}toModalOptions(){function e(i){return i?.view==="Swap"}function t(i){return i?.view==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await xs.fetchAllowedOrigins();if(!_e.isClient())return;const t=window.location.origin;nn.isOriginAllowed(t,e,J.DEFAULT_ALLOWED_ANCESTORS)||Le.open(Me.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":Le.open(Me.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;Le.open({displayMessage:Me.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Me.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){const{...t}=e;delete t.adapters,delete t.universalProvider,Bt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(i=>i.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){yd.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&kt.setThemeMode(e.themeMode),e.themeVariables&&kt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");P.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&P.setActiveCaipNetwork(t)}initializeConnectionController(e){me.initialize(e.adapters??[]),me.setWcBasic(e.basic??!1)}initializeConnectorController(){ce.initialize(this.chainNamespaces)}initializeProjectSettings(e){K.setProjectId(e.projectId),K.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){K.setDebug(e.debug!==!1),K.setEnableWalletGuide(e.enableWalletGuide!==!1),K.setEnableWallets(e.enableWallets!==!1),K.setEIP6963Enabled(e.enableEIP6963!==!1),K.setEnableCoinbase(e.enableCoinbase!==!1),K.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),K.setEnableReconnect(e.enableReconnect!==!1),K.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),K.setCoinbasePreference(e.coinbasePreference),K.setEnableAuthLogger(e.enableAuthLogger!==!1),K.setCustomRpcUrls(e.customRpcUrls),K.setEnableEmbedded(e.enableEmbedded),K.setAllWallets(e.allWallets),K.setIncludeWalletIds(e.includeWalletIds),K.setExcludeWalletIds(e.excludeWalletIds),K.setFeaturedWalletIds(e.featuredWalletIds),K.setTokens(e.tokens),K.setTermsConditionsUrl(e.termsConditionsUrl),K.setPrivacyPolicyUrl(e.privacyPolicyUrl),K.setCustomWallets(e.customWallets),K.setFeatures(e.features),K.setAllowUnsupportedChain(e.allowUnsupportedChain),K.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),K.setPreferUniversalLinks(e.experimental_preferUniversalLinks),K.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),K.setMetadata(e.metadata),K.setDisableAppend(e.disableAppend),K.setEnableEmbedded(e.enableEmbedded),K.setSIWX(e.siwx),this.features=K.state.features??{},!e.projectId){Le.open(Me.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(e.adapters?.find(r=>r.namespace===J.CHAIN.EVM)&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");K.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return _e.isClient()?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=wi.getUnsupportedNetwork(`${t}:${e}`);P.setActiveCaipNetwork(i)}}getDefaultNetwork(){return wi.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return wi.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return wi.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>r.id===e.defaultNetwork?.id);return t?wi.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){try{this.setLoading(!0,e);let i={connections:[]};const r=this.getAdapter(e);return(P.state.chains.get(e)?.accountState?.caipAddress||!K.state.enableReconnect)&&r?.disconnect&&(i=await r.disconnect({id:t})),this.setLoading(!1,e),i}catch(i){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${i.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=P.state.activeChain,t=this.getAdapter(e),i=this.getCaipNetwork(e)?.id,r=me.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId(a?.clientId||null),ne.setConnectedNamespaces([...P.state.chains.keys()]),await this.syncWalletConnectAccount(),await wr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{const n=P.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o?.reconnect&&(await o?.reconnect({id:e,info:t,type:i,provider:r,chainId:this.getCaipNetwork()?.id}),ne.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||P.state.activeChain,o=ce.getConnectorId(n),a=t===J.CONNECTOR_ID.AUTH||o===J.CONNECTOR_ID.AUTH,c=t===J.CONNECTOR_ID.WALLET_CONNECT||o===J.CONNECTOR_ID.WALLET_CONNECT;try{const l=Array.from(P.state.chains.keys());let h=i?[i]:l;(c||a)&&(h=l);const u=h.map(async p=>{const g=ce.getConnectorId(p),y=t||g,N=await this.disconnectConnector(p,y);N&&(a&&ne.deleteConnectedSocialProvider(),N.connections.forEach($=>{ne.addDisconnectedConnectorId($.connectorId,p)})),r&&this.onDisconnectNamespace({chainNamespace:p,closeModal:!1})}),d=await Promise.allSettled(u);Ia.resetSend(),me.resetWcConnection(),wr.getSIWX()?.signOutOnDisconnect&&await wr.clearSessions(),ce.setFilterByNamespace(void 0),me.syncStorageConnections();const f=d.filter(p=>p.status==="rejected");if(f.length>0)throw new Error(f.map(p=>p.reason.message).join(", "));Bt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(l){throw new Error(`Failed to disconnect chains: ${l.message}`)}},checkInstalled:e=>e?e.some(t=>!!window.ethereum?.[String(t)]):!!window.ethereum,signMessage:async e=>{const t=P.state.activeChain,i=this.getAdapter(P.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");return(await i?.signMessage({message:e,address:r,provider:de.getProvider(t)}))?.signature||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(be.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=de.getProvider(t);return(await i?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}))?.hash||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===J.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=de.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");return(await i?.estimateGas({...e,provider:r,caipNetwork:n}))?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=P.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");return await this.syncIdentity({address:t,chainId:Number(this.getCaipNetwork()?.id),chainNamespace:e}),P.getAccountData()?.profileImage||!1},getEnsAddress:async e=>await nn.resolveReownName(e),writeContract:async e=>{const t=P.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=de.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");return(await i?.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}))?.hash},writeSolanaTransaction:async e=>{const t=P.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=de.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");return(await i?.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}))?.hash},parseUnits:(e,t)=>{const i=this.getAdapter(P.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return i?.parseUnits({value:e,decimals:t})??0n},formatUnits:(e,t)=>{const i=this.getAdapter(P.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return i?.formatUnits({value:e,decimals:t})??"0"},getCapabilities:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await t?.getCapabilities(e)},grantPermissions:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await t?.grantPermissions(e)},revokePermissions:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(P.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await t?.walletGetAssets(e)??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i?.id,e)}},me.setClient(this.connectionControllerClient)}async onConnectExternal(e){const t=P.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===Je.CONNECTOR_TYPE_AUTH&&J.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(u=>ce.getConnectorId(u)===J.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const l=this.getCaipNetworks().find(h=>h.chainNamespace===e.chain);l&&n&&this.setCaipNetwork(l)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:e.caipNetwork?.id||o?.id,rpcUrl:e.caipNetwork?.rpcUrls?.default?.http?.[0]||o?.rpcUrls?.default?.http?.[0]});if(c)return ne.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ne.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){const i=e.type===Je.CONNECTOR_TYPE_AUTH,r=Ar.getOtherAuthNamespaces(t?.connectedCaipNetwork?.chainNamespace),n=P.state.activeCaipNetwork,o=this.getAdapter(n?.chainNamespace);i&&(await Promise.all(r.map(async a=>{try{const c=de.getProvider(a),l=this.getCaipNetwork(a);await this.getAdapter(a)?.connect({...e,provider:c,socialUri:void 0,chainId:l?.id,rpcUrl:l?.rpcUrls?.default?.http?.[0]})&&(ne.addConnectedNamespace(a),ne.removeDisconnectedConnectorId(e.id,a),this.setStatus("connected",a),this.syncConnectedWalletInfo(a))}catch(c){Le.warn(Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(a,c instanceof Error?c.message:void 0),Me.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await o?.switchNetwork({caipNetwork:n}))}getApprovedCaipNetworksData(){if(de.getProviderId(P.state.activeChain)===Je.CONNECTOR_TYPE_WALLET_CONNECT){const t=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:this.universalProvider?.session?.peer?.metadata.name==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(t)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=de.getProviderId(t);if(e.chainNamespace===P.state.activeChain)await this.getAdapter(t)?.switchNetwork({caipNetwork:e});else if(this.setCaipNetwork(e),r===Je.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=ks.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{const r=e?.find(n=>n.namespace===i);return r?(r.construct({namespace:i,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:n})=>n===i)}),t[i]=r):t[i]=new wx({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){this.getAdapter(e)?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ne.getConnectionStatus();K.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ne.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id.toString()===n.toString()||l.caipNetworkId.toString()===n.toString()),a=P.state.activeChain===e,c=P.state.chains.get(e)?.accountState?.address;if(o){const l=a&&r?r:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(me.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=P.state.activeCaipNetwork;!r||!n?.id||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{this.handlePreviousConnectorConnection(o);const a=P.state.activeChain===e;o?.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o?.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=P.getNetworkData(e)?.caipNetwork?.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,n,e),ne.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){const t=e?.chain,i=e?.id,r=ce.getConnectorId(t),n=K.state.remoteFeatures?.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await me.disconnect({id:r,namespace:t})}catch(c){console.warn("Error disconnecting previous connector",c)}}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&await this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>me.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ne.deleteRecentWallet();const t=ne.getRecentWallet();Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:_e.isMobile()?"mobile":"qrcode",name:t?.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:t?.order}})}async syncNamespaceConnection(e){try{e===J.CHAIN.EVM&&_e.isSafeApp()&&ce.setConnectorId(J.CONNECTOR_ID.SAFE,e);const t=ce.getConnectorId(e);switch(this.setStatus("connecting",e),t){case J.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case J.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};P.resetAccount(t),P.resetNetwork(t),ne.removeConnectedNamespace(t);const r=Array.from(P.state.chains.keys());(t?[t]:r).forEach(o=>ne.addDisconnectedConnectorId(ce.getConnectorId(o)||"",o)),ce.removeConnectorId(t),de.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&ls.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t?.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=ce.getConnectorId(e),o=ce.getConnectors(e).find(a=>a.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const a=await t?.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]});a?(this.syncProvider({...a,chainNamespace:e}),await this.syncAccount({...a,chainNamespace:e}),this.setStatus("connected",e),Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:a.address,properties:{method:"browser",name:o.info?.name||o.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:o?.explorerWallet?.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){const e=Object.keys(this.universalProvider?.session?.namespaces||{}),t=this.chainNamespaces.map(async i=>{const r=this.getAdapter(i);if(!r)return;const n=this.universalProvider?.session?.namespaces?.[i]?.accounts||[],o=P.state.activeCaipNetwork?.id,a=n.find(l=>{const{chainId:h}=ks.parseCaipAddress(l);return h===o?.toString()})||n[0];if(a){const l=ks.validateCaipAddress(a),{chainId:h,address:u}=ks.parseCaipAddress(l);if(de.setProviderId(i,Je.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&P.state.activeCaipNetwork&&r.namespace!==J.CHAIN.EVM){const d=r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:P.state.activeCaipNetwork});de.setProvider(i,d)}else de.setProvider(i,this.universalProvider);ce.setConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,i),ne.addConnectedNamespace(i),await this.syncAccount({address:u,chainId:h,chainNamespace:i})}else e.includes(i)&&this.setStatus("disconnected",i);const c=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(i),P.setApprovedCaipNetworksData(i,{approvedCaipNetworkIds:c.approvedCaipNetworkIds,supportsAllNetworks:c.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){de.setProviderId(r,e),de.setProvider(r,t),ce.setConnectorId(i,r)}async syncAccount(e){const t=e.chainNamespace===P.state.activeChain,i=P.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ne.getActiveNetworkProps(),c=i?.id||a,l=P.state.activeCaipNetwork?.name===J.UNSUPPORTED_NETWORK_NAME,h=P.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let u=this.getCaipNetworks().find(g=>g.id.toString()===c.toString()),d=this.getCaipNetworks().find(g=>g.chainNamespace===o);if(!h&&!u&&!d){const g=this.getApprovedCaipNetworkIds()||[],y=g.find($=>ks.parseCaipNetworkId($)?.chainId===c.toString()),N=g.find($=>ks.parseCaipNetworkId($)?.chainNamespace===o);u=this.getCaipNetworks().find($=>$.caipNetworkId===y),d=this.getCaipNetworks().find($=>$.caipNetworkId===N||"deprecatedCaipNetworkId"in $&&$.deprecatedCaipNetworkId===N)}const f=u||d;f?.chainNamespace===P.state.activeChain?K.state.enableNetworkSwitch&&!K.state.allowUnsupportedChain&&P.state.activeCaipNetwork?.name===J.UNSUPPORTED_NETWORK_NAME?P.showUnsupportedChainUI():this.setCaipNetwork(f):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const p=this.getAddress(o);Ar.isLowerCaseMatch(r,p)||this.syncAccountInfo(r,f?.id,o),t?await this.syncBalance({address:r,chainId:f?.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i?.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||r?.split(":")[1];if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=ce.getConnectorId(e),i=de.getProviderId(e);if(i===Je.CONNECTOR_TYPE_ANNOUNCED||i===Je.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>{const a=o.id===t,c=o.info?.rdns===t,l=o.connectors?.some(h=>h.id===t||h.info?.rdns===t);return a||c||!!l});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(i===Je.CONNECTOR_TYPE_WALLET_CONNECT){const r=de.getProvider(e);r?.session&&this.setConnectedWalletInfo({...r.session.peer.metadata,name:r.session.peer.metadata.name,icon:r.session.peer.metadata.icons?.[0]},e)}else if(t&&(t===J.CONNECTOR_ID.COINBASE_SDK||t===J.CONNECTOR_ID.COINBASE)){const r=this.getConnectors().find(c=>c.id===t),n=r?.name||"Coinbase Wallet",o=r?.imageUrl||this.getConnectorImage(r),a=r?.info;this.setConnectedWalletInfo({...a,name:n,icon:o},e)}}async syncBalance(e){!Fd.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>i.id.toString()===e.chainId?.toString())||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=P.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){const e=ox.createLogger((r,...n)=>{r&&this.handleAlertError(r),console.error(...n)}),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};K.setManualWCControl(!!this.options?.manualWCControl),this.universalProvider=this.options.universalProvider??await wa.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(r){if(r instanceof Error&&r.message.includes("Missing or invalid. Record was recently deleted"))return;throw r}},K.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{nn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{me.setUri(t)},onConnect:t=>{const{address:i}=_e.getAccount(t[0]);for(const r of this.chainNamespaces)ne.removeDisconnectedConnectorId(J.CONNECTOR_ID.WALLET_CONNECT,r);me.finalizeWcConnection(i)},onDisconnect:()=>{P.state.noAdapters&&this.resetAccount(e),me.resetWcConnection()},onChainChanged:t=>{const i=P.state.activeChain,r=i&&ce.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(P.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}o?.id.toString()!==n?.id.toString()&&o?.chainNamespace===n?.chainNamespace&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=P.state.activeChain,r=i&&ce.state.activeConnectorIds[i]===J.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&(P.state.noAdapters||r)){const n=t?.[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){return!this.universalProviderInitPromise&&_e.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Bt.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}getDisabledCaipNetworks(){const e=P.getAllApprovedCaipNetworkIds(),t=P.getAllRequestedCaipNetworks();return _e.sortRequestedNetworks(e,t).filter(r=>P.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(Me.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Me.ALERT_ERRORS[o];a&&(Le.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:r})=>r===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e?.uri&&me.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?ls.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):ls.open(e)}async close(){await this.injectModalUi(),ls.close()}setLoading(e,t){ls.setLoading(e,t)}async disconnect(e){await me.disconnect({namespace:e})}getSIWX(){return K.state.siwx}getError(){return""}getChainId(){return P.state.activeCaipNetwork?.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){Le.open(Me.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await P.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return P.state.activeChain?de.state.providers[P.state.activeChain]:null}getWalletProviderType(){return de.getProviderId(P.state.activeChain)}subscribeProviders(e){return de.subscribeProviders(e)}getThemeMode(){return kt.state.themeMode}getThemeVariables(){return kt.state.themeVariables}setThemeMode(e){kt.setThemeMode(e),Do(kt.state.themeMode)}setTermsConditionsUrl(e){K.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){K.setPrivacyPolicyUrl(e)}setThemeVariables(e){kt.setThemeVariables(e),yx(kt.state.themeVariables)}subscribeTheme(e){return kt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?me.subscribe(e):(Le.open(J.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){return e?P.state.chains.get(e)?.accountState?.connectedWalletInfo:P.getAccountData()?.connectedWalletInfo}getAccount(e){const t=e||P.state.activeChain,i=ce.getAuthConnector(t),r=P.getAccountData(t),n=ne.getConnectedConnectorId(P.state.activeChain),o=me.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>{const{caipNetwork:l}=c;return l?c.accounts.map(({address:h,type:u,publicKey:d})=>_e.createAccount({caipAddress:`${l.caipNetworkId}:${h}`,type:u||"eoa",publicKey:d})):[]});if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:_e.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===J.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ne.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:Hn(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=P.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=P.subscribe(r);i.push(o)}const n=ce.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return P.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})})}subscribeWalletInfo(e,t){return t?P.subscribeChainProp("accountState",i=>e(i?.connectedWalletInfo),t):P.subscribeChainProp("accountState",i=>e(i?.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return P.subscribeChainProp("accountState",t=>e(t?.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return P.subscribeKey("activeCaipNetwork",e)}getState(){return _r.state}getRemoteFeatures(){return K.state.remoteFeatures}subscribeState(e){return _r.subscribe(e)}subscribeRemoteFeatures(e){return K.subscribeKey("remoteFeatures",e)}showErrorMessage(e){xa.showError(e)}showSuccessMessage(e){xa.showSuccess(e)}getEvent(){return{...Bt.state}}subscribeEvents(e){return Bt.subscribe(e)}replace(e){$s.replace(e)}redirect(e){$s.push(e)}popTransactionStack(e){$s.popTransactionStack(e)}isOpen(){return ls.state.open}isTransactionStackEmpty(){return $s.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){K.setFeatures(e)}updateRemoteFeatures(e){K.setRemoteFeatures(e)}updateOptions(e){const i={...K.state||{},...e};K.setOptions(i)}setConnectMethodsOrder(e){K.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){K.setWalletFeaturesOrder(e)}setCollapseWallets(e){K.setCollapseWallets(e)}setSocialsOrder(e){K.setSocialsOrder(e)}getConnectMethodsOrder(){return wd.getConnectOrderMethod(K.state.features,ce.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||P.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&P.removeNetwork(e,t)}}let Ll=!1;class nd extends Ex{async onAuthProviderConnected(e){const t=Ar.userChainIdToChainNamespace(e?.chainId);if(e.message&&e.signature&&e.siwxMessage&&await wr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===J.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=K.state.defaultAccountTypes[t],n=Hn(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=P.getAccountData(t);this.setUser({...u?.user||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{on.checkIfRequestExists(t)?on.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(Sa.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(Sa.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=on.checkIfRequestIsSafe(i),n=this.getAddress(),o=P.state.activeCaipNetwork;r||(n&&o?.id&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=P.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");ce.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=P.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=kt.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:bd(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){const i=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===P.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=P.getAccountData(t)?.user||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&this.connectionControllerClient?.connectExternal){await e.init(),await this.syncAuthConnectorTheme(e),await this.connectionControllerClient?.connectExternal({id:J.CONNECTOR_ID.AUTH,info:{name:J.CONNECTOR_ID.AUTH},type:Je.CONNECTOR_TYPE_AUTH,provider:e,chainId:P.getNetworkData(t)?.caipNetwork?.id,chain:t}),this.setStatus("connected",t);const h=ne.getConnectedSocialProvider();h?Bt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:h,reconnect:!0}}):Bt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:this.universalProvider?.session?.peer?.metadata?.name||"Unknown",reconnect:!0,view:$s.state.view,walletRank:void 0}})}else ce.getConnectorId(t)===J.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ne.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){try{if(!_e.isTelegram())return;const t=ne.getTelegramSocialProvider();if(!t||!_e.isClient())return;const r=new URL(window.location.href).searchParams.get("result_uri");if(!r)return;t&&P.setAccountProp("socialProvider",t,e),await this.authProvider?.init();const n=ce.getAuthConnector();t&&n&&(this.setLoading(!0,e),await me.connectExternal({id:n.id,type:n.type,socialUri:r},n.chain),ne.setConnectedSocialProvider(t),ne.removeTelegramSocialProvider(),Bt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:t}}))}catch(t){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",t)}try{const t=new URL(window.location.href);t.searchParams.delete("result_uri"),window.history.replaceState({},document.title,t.toString())}catch(t){console.error("tma social login failed",t)}}createAuthProvider(e){if(!J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=this.remoteFeatures?.email,r=Array.isArray(this.remoteFeatures?.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Ar.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&this.options?.projectId&&n&&(this.authProvider=vd.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:this.getCaipNetwork(a)?.caipNetworkId,abortController:Me.EmbeddedWalletAbortController,onTimeout:l=>{l==="iframe_load_failed"?Le.open(Me.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):l==="iframe_request_timeout"?Le.open(Me.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):l==="unverified_domain"&&Le.open(Me.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:l=>Ed(l),getCaipNetworks:l=>P.getCaipNetworks(l)}),_r.subscribeOpen(l=>{!l&&this.isTransactionStackEmpty()&&this.authProvider?.rejectRpcRequests()}));const c=e===P.state.activeChain&&K.state.enableReconnect;K.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){this.createAuthProvider(e),this.authProvider&&this.chainAdapters?.[e]?.setAuthProvider?.(this.authProvider)}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&xs.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){if(!e)return;const t=P.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&P.getAccountData(i)?.caipAddress)await this.getAdapter(i)?.switchNetwork({caipNetwork:e}),this.setCaipNetwork(e);else{const a=de.getProviderId(t)===Je.CONNECTOR_TYPE_AUTH,c=de.getProviderId(i),l=c===Je.CONNECTOR_TYPE_AUTH,h=J.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((a&&c===void 0||l)&&h)try{P.state.activeChain=e.chainNamespace,r?await this.getAdapter(i)?.switchNetwork({caipNetwork:e}):await this.connectionControllerClient?.connectExternal?.({id:J.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:Je.CONNECTOR_TYPE_AUTH,caipNetwork:e}),this.setCaipNetwork(e)}catch{await this.getAdapter(i)?.switchNetwork({caipNetwork:e})}else c===Je.CONNECTOR_TYPE_WALLET_CONNECT?(P.state.noAdapters||await this.getAdapter(i)?.switchNetwork({caipNetwork:e}),this.setCaipNetwork(e),this.syncWalletConnectAccount()):(this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i}))}}async initialize(e){await super.initialize(e),this.chainNamespaces?.forEach(t=>{this.createAuthProviderForAdapter(t)}),await this.injectModalUi(),_r.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){if(i!==J.CHAIN.EVM)return;const r=`${i}:${t}`;if(this.caipNetworks?.find(a=>a.caipNetworkId===r)?.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=ce.getConnectorId(i)===J.CONNECTOR_ID.AUTH;try{const{name:a,avatar:c}=await this.fetchIdentity({address:e});!a&&o?await this.syncReownName(e,i):(this.setProfileName(a,i),this.setProfileImage(c,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=de.getProviderId(e);if(t===Je.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ne.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!_e.isClient())return;const e={...be.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!Ll)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),_e.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!K.state.disableAppend&&!K.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}Ll=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!_e.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Ge(()=>import("./embedded-wallet-DZAeJhJN.js"),__vite__mapDeps([8,9,10,11,3,4,1,2,5,6,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]))),t.email&&i.push(Ge(()=>import("./email-CUatRSQC.js"),__vite__mapDeps([30,11,9,10,3,4,31,23,16,1,2,5,6,7,22,13,14,15,21,32,19,25,26,27,28,29]))),t.socials&&i.push(Ge(()=>import("./socials-CER945jA.js"),__vite__mapDeps([33,9,10,13,11,3,4,34,14,15,1,2,5,6,7,35,22,18,21,16,36,12,37,38,25,26,27,28,29]))),t.swaps&&t.swaps.length>0&&i.push(Ge(()=>import("./swaps-Dy4hNTFm.js"),__vite__mapDeps([39,9,10,11,3,4,21,16,22,13,40,1,2,5,6,7,41,38,42,12,43,19,14,15,25,26,27,28,29]))),e.send&&i.push(Ge(()=>import("./send-DsnDja5n.js"),__vite__mapDeps([44,9,10,11,3,4,21,16,22,13,45,14,15,1,2,5,6,7,46,23,42,12,38,41,19,47,48,25,26,27,28,29]))),e.receive&&i.push(Ge(()=>import("./receive-JnpfZY7d.js"),__vite__mapDeps([49,9,10,13,11,3,4,12,36,37,1,2,5,6,7,25,26,27,28,29]))),t.onramp&&t.onramp.length>0&&i.push(Ge(()=>import("./onramp-qvbxoSMm.js"),__vite__mapDeps([50,9,10,13,11,3,4,51,16,34,14,15,1,2,5,6,7,12,52,53,23,21,22,19,25,26,27,28,29]))),t.payWithExchange&&i.push(Ge(()=>import("./pay-with-exchange-1MlV9x6H.js"),__vite__mapDeps([54,9,10,13,11,3,4,12,20,51,16,38,21,46,14,15,23,1,2,5,6,7,55,22,19,47,45,25,26,27,28,29]))),t.activity&&i.push(Ge(()=>import("./transactions-CwEfhngY.js"),__vite__mapDeps([56,9,11,10,3,4,57,22,13,23,12,38,1,2,5,6,7,25,26,27,28,29]))),(e.pay||t.payments)&&i.push(Ge(()=>import("./index-C5oPclal.js"),__vite__mapDeps([58,59,9,10,13,11,3,4,21,16,20,12,51,60,22,45,1,2,5,6,7,38,43,25,26,27,28,29]))),t.emailCapture&&i.push(Ge(()=>import("./data-capture-C5UoNnMk.js"),__vite__mapDeps([61,9,10,11,3,4,31,23,16,1,2,5,6,7,0,25,26,27,28,29]))),await Promise.all([...i,Ge(()=>import("./index-Coj3uG35.js"),__vite__mapDeps([62,9,10,13,11,3,4,12,16,48,1,2,5,6,7,22,63,53,23,17,18,60,20,51,21,55,57,38,47,40,43,45,14,15,19,32,34,35,36,37,24,52,25,26,27,28,29])),Ge(()=>import("./w3m-modal-B6M729n4.js"),__vite__mapDeps([64,9,10,13,11,3,4,1,2,5,6,7,59,21,16,20,12,51,60,22,45,38,43,17,18,40,63,53,23,41,25,26,27,28,29]))])}}const Ix="1.8.19";function xx(s){return new nd({...s,sdkVersion:_e.generateSdkVersion(s.adapters??[],"html",Ix)})}const hS=Object.freeze(Object.defineProperty({__proto__:null,AppKit:nd,CoreHelperUtil:_e,WcConstantsUtil:ki,createAppKit:xx},Symbol.toStringTag,{value:"Module"}));export{Yn as O,sS as a,tS as b,nS as c,oS as d,lS as e,rS as f,iS as g,hS as h,aS as i,cS as r,mx as v};