@antseed/payments 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{add-DocZPFAh.js → add-DO48uBkb.js} +1 -1
- package/dist/web/assets/{all-wallets-BlmuWikl.js → all-wallets-BkWVVAS1.js} +1 -1
- package/dist/web/assets/{app-store-BOAtptal.js → app-store-C1GcxcuM.js} +1 -1
- package/dist/web/assets/{apple-BVuGLQFf.js → apple-DRlSkxCJ.js} +1 -1
- package/dist/web/assets/{arrow-bottom-BfI_b_jU.js → arrow-bottom-Dy6m-dGR.js} +1 -1
- package/dist/web/assets/{arrow-bottom-circle-DXAZqR32.js → arrow-bottom-circle-OaPyrZJI.js} +1 -1
- package/dist/web/assets/{arrow-left-D1QxsP5J.js → arrow-left-B-xL79ld.js} +1 -1
- package/dist/web/assets/{arrow-right-B2aeprYS.js → arrow-right-CDDOEehx.js} +1 -1
- package/dist/web/assets/{arrow-top-Dj0c55Fu.js → arrow-top-B2DPbEC0.js} +1 -1
- package/dist/web/assets/{bank-Ds7QEe7p.js → bank-Dp2d_jcI.js} +1 -1
- package/dist/web/assets/{basic-BMBwjKA8.js → basic-wb3lzxpj.js} +1 -1
- package/dist/web/assets/{browser-BdmnWXof.js → browser-DiavMjo3.js} +1 -1
- package/dist/web/assets/{card-C4Xu9wgL.js → card-CXol1E6y.js} +1 -1
- package/dist/web/assets/{ccip-B3uez93r.js → ccip-C830ozAe.js} +1 -1
- package/dist/web/assets/{checkmark-bold-u4pkEwJ7.js → checkmark-bold-DxsScgl-.js} +1 -1
- package/dist/web/assets/{checkmark-BTF_TSmM.js → checkmark-e7H-qhu3.js} +1 -1
- package/dist/web/assets/{chevron-bottom-DUco1ORe.js → chevron-bottom-CvZfXzBT.js} +1 -1
- package/dist/web/assets/{chevron-left-CiceTJIx.js → chevron-left-DFBaQyQK.js} +1 -1
- package/dist/web/assets/{chevron-right-8Kfq0LM-.js → chevron-right-Bf_SF_cp.js} +1 -1
- package/dist/web/assets/{chevron-top-CkE3raQU.js → chevron-top-B0n_Zh87.js} +1 -1
- package/dist/web/assets/{chrome-store-DgInc3Qf.js → chrome-store-BDZONbOt.js} +1 -1
- package/dist/web/assets/{clock-C0990J2j.js → clock-C_BVK706.js} +1 -1
- package/dist/web/assets/{close-CHgHmpCY.js → close-eHk8a8tJ.js} +1 -1
- package/dist/web/assets/{coinPlaceholder-CSA6iapt.js → coinPlaceholder-aL7BEX1k.js} +1 -1
- package/dist/web/assets/{compass-DpaKQ2he.js → compass-RZbEaXGl.js} +1 -1
- package/dist/web/assets/{copy-BaiECgly.js → copy-CHkGGl5J.js} +1 -1
- package/dist/web/assets/core-_kiBKHZY.js +908 -0
- package/dist/web/assets/{cursor-BZ6UxGan.js → cursor-DFJbazqp.js} +1 -1
- package/dist/web/assets/{cursor-transparent-Dcts1MI8.js → cursor-transparent-B67EeEQg.js} +1 -1
- package/dist/web/assets/{desktop-CfwszHBZ.js → desktop-BU69u1US.js} +1 -1
- package/dist/web/assets/{disconnect-DmImDVvy.js → disconnect-BbDef4m-.js} +1 -1
- package/dist/web/assets/{discord-OLpEWZAC.js → discord-oXIadhpF.js} +1 -1
- package/dist/web/assets/{etherscan-C07_6eky.js → etherscan-CoQpNlDL.js} +1 -1
- package/dist/web/assets/{exclamation-triangle-BiswlrqT.js → exclamation-triangle-CjfzUL4g.js} +1 -1
- package/dist/web/assets/{extension-UwLquuzI.js → extension-C5L64T6f.js} +1 -1
- package/dist/web/assets/{external-link-CSLm_-tJ.js → external-link-D_sy6vDx.js} +1 -1
- package/dist/web/assets/{facebook-BRCrfpVw.js → facebook-DjmrhmFq.js} +1 -1
- package/dist/web/assets/{farcaster-Bf9m2Otr.js → farcaster-DmMF77Xj.js} +1 -1
- package/dist/web/assets/{filters-DehzOxU1.js → filters-D2f0XPGO.js} +1 -1
- package/dist/web/assets/{github-hAkxsgoS.js → github-BDybahrF.js} +1 -1
- package/dist/web/assets/{google-B3N5JDat.js → google-CSB9Kfmf.js} +1 -1
- package/dist/web/assets/{help-circle-CNgVImeX.js → help-circle-DB23Ty7u.js} +1 -1
- package/dist/web/assets/{id-pw2EMpwA.js → id-D5gPzS6F.js} +1 -1
- package/dist/web/assets/{image-Cxyq8Cui.js → image-NZoxDgOK.js} +1 -1
- package/dist/web/assets/index-BdUIfw6p.css +1 -0
- package/dist/web/assets/{index-VjSCsmQ_.js → index-C21LFfGU.js} +1 -1
- package/dist/web/assets/{index-Bft26p4H.js → index-CkhAWBO6.js} +3 -3
- package/dist/web/assets/{index-j0nG5kdO.js → index-DtljJr-y.js} +1 -1
- package/dist/web/assets/{index-DdCqo2iD.js → index-Lr-e9hfO.js} +1 -1
- package/dist/web/assets/index-g2oIv4aL.js +1775 -0
- package/dist/web/assets/{index.es-CgpmFgU-.js → index.es-DNztKQ9p.js} +4 -4
- package/dist/web/assets/{info-CfJxZZH4.js → info-C4wx9Htm.js} +1 -1
- package/dist/web/assets/{info-circle-UGz8nwSA.js → info-circle-D1Cmx7mJ.js} +1 -1
- package/dist/web/assets/{lightbulb-1gMiuscj.js → lightbulb-CvsAEXZz.js} +1 -1
- package/dist/web/assets/{mail-jUjUUbN_.js → mail-C7pHszz9.js} +1 -1
- package/dist/web/assets/{metamask-sdk-CbS0jbL-.js → metamask-sdk-gqt9hhaE.js} +1 -1
- package/dist/web/assets/{mobile-Dt9xWNxt.js → mobile-D2ktYh20.js} +1 -1
- package/dist/web/assets/{more-sXoh0fak.js → more-BDcZRHGE.js} +1 -1
- package/dist/web/assets/{network-placeholder-Ci2QoxkE.js → network-placeholder-uAsFZ0N6.js} +1 -1
- package/dist/web/assets/{nftPlaceholder-B9NpVZeo.js → nftPlaceholder-CAmeFtDk.js} +1 -1
- package/dist/web/assets/{off-BTwuO7ia.js → off-CnsMLe4a.js} +1 -1
- package/dist/web/assets/{play-store-C6pls6Vy.js → play-store-BWBCekI3.js} +1 -1
- package/dist/web/assets/{plus-ClaLJgZu.js → plus-DcqOmNnO.js} +1 -1
- package/dist/web/assets/{qr-code-Kt3GafiB.js → qr-code-kWARpZ1V.js} +1 -1
- package/dist/web/assets/{recycle-horizontal-abN1vhMK.js → recycle-horizontal-CRjP5bVY.js} +1 -1
- package/dist/web/assets/{refresh-CVq5AhHc.js → refresh-BmgOAu1R.js} +1 -1
- package/dist/web/assets/{reown-logo-St5b0D6C.js → reown-logo-D_NG_fWN.js} +1 -1
- package/dist/web/assets/{search-Chk95Ojw.js → search-Dx7e5lJ3.js} +1 -1
- package/dist/web/assets/{secp256k1-vayZNtsf.js → secp256k1-DffysWcZ.js} +1 -1
- package/dist/web/assets/{secp256k1-BmewtLue.js → secp256k1-qFgvCj4z.js} +1 -1
- package/dist/web/assets/{send-Ck2m5AoO.js → send-Dq_-74KT.js} +1 -1
- package/dist/web/assets/{swapHorizontal-BPsXrF3L.js → swapHorizontal-Do1Xf2eE.js} +1 -1
- package/dist/web/assets/{swapHorizontalBold-Dmm0fWxo.js → swapHorizontalBold-DSAw1A-e.js} +1 -1
- package/dist/web/assets/{swapHorizontalMedium-C-h0SSuc.js → swapHorizontalMedium-NQgPkERU.js} +1 -1
- package/dist/web/assets/{swapHorizontalRoundedBold-DusMAoQQ.js → swapHorizontalRoundedBold-WIVym2ML.js} +1 -1
- package/dist/web/assets/{swapVertical-CoqVXTTE.js → swapVertical-iz1iMNzs.js} +1 -1
- package/dist/web/assets/{telegram-BHBphLJM.js → telegram-BdaGOXYA.js} +1 -1
- package/dist/web/assets/{three-dots-DVuU7rRQ.js → three-dots-CJe04iHO.js} +1 -1
- package/dist/web/assets/{twitch-D6KnDIGR.js → twitch-Dn95Orvn.js} +1 -1
- package/dist/web/assets/{twitterIcon-Du8R03S8.js → twitterIcon-dHRfC90o.js} +1 -1
- package/dist/web/assets/{verify-CKhkA-i9.js → verify-BQMMiIyf.js} +1 -1
- package/dist/web/assets/{verify-filled-CyZqNOkT.js → verify-filled-C9AnpVj0.js} +1 -1
- package/dist/web/assets/{w3m-modal-BYx8cjX-.js → w3m-modal-C2ckylSw.js} +1 -1
- package/dist/web/assets/{wallet-Das1gtZW.js → wallet-BEeQhJEj.js} +1 -1
- package/dist/web/assets/{wallet-placeholder-NXcPvC7U.js → wallet-placeholder-CiPjLH93.js} +1 -1
- package/dist/web/assets/{walletconnect-DTAM9xN9.js → walletconnect-ByWXqkux.js} +1 -1
- package/dist/web/assets/{warning-circle-B7irzO2l.js → warning-circle-B0jejq5j.js} +1 -1
- package/dist/web/assets/{x-zHzJxpDt.js → x-y1x93MqW.js} +1 -1
- package/dist/web/diem-logo.png +0 -0
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/assets/core-JRXsheka.js +0 -908
- package/dist/web/assets/index-XFberJbs.js +0 -1775
- package/dist/web/assets/index-vhd6ZTWQ.css +0 -1
|
@@ -0,0 +1,908 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secp256k1-DffysWcZ.js","assets/index-g2oIv4aL.js","assets/index-BdUIfw6p.css","assets/index.es-DNztKQ9p.js","assets/events-DQ172AOg.js","assets/basic-wb3lzxpj.js","assets/index-CkhAWBO6.js","assets/w3m-modal-C2ckylSw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as Gp,_ as _a,p as zc,q as xn,t as Hc}from"./index-g2oIv4aL.js";import{I as bi,h as it,i as q,j as $t,C as Jp,k as Et,l as Yp,m as Gi,s as Sa,n as Ph,o as gr,p as bn,A as Oh,E as ht,q as Zp,u as Xp,y as xt,v as er,x as vi,O as yc,z as qt,B as Qp,D as bc,F as vc,G as go,N as Ec,P as Wc,Q as ef,J as tf,K as sf,L as Vc,M as Gr,R as $h,S as fs,T as is,U as Th,V as Cs,W as Xt}from"./index.es-DNztKQ9p.js";var Kc={};const K={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof process<"u"&&typeof Kc<"u"?Kc.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},xh={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=K.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var rf=20,nf=1,ar=1e6,Gc=1e6,of=-7,af=21,cf=!1,vn="[big.js] ",mr=vn+"Invalid ",mo=mr+"decimal places",lf=mr+"rounding mode",kh=vn+"Division by zero",Ee={},os=void 0,uf=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Rh(){function t(e){var s=this;if(!(s instanceof t))return e===os?Rh():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(mr+"value");e=e===0&&1/e<0?"-0":String(e)}hf(s,e)}s.constructor=t}return t.prototype=Ee,t.DP=rf,t.RM=nf,t.NE=of,t.PE=af,t.strict=cf,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function hf(t,e){var s,r,i;if(!uf.test(e))throw Error(mr+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(s<0&&(s=r),s+=+e.slice(r+1),e=e.substring(0,r)):s<0&&(s=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=s-r-1,t.c=[],s=0;r<=i;)t.c[s++]=+e.charAt(r++)}return t}function wr(t,e,s,r){var i=t.c;if(s===os&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(lf);if(e<1)r=s===3&&(r||!!i[0])||e===0&&(s===1&&i[0]>=5||s===2&&(i[0]>5||i[0]===5&&(r||i[1]!==os))),i.length=1,r?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(r=s===1&&i[e]>=5||s===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==os||i[e-1]&1))||s===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function yr(t,e,s){var r=t.e,i=t.c.join(""),n=i.length;if(e)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>n)for(r-=n;r--;)i+="0";else r<n&&(i=i.slice(0,r)+"."+i.slice(r));else n>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&s?"-"+i:i}Ee.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ee.cmp=function(t){var e,s=this,r=s.c,i=(t=new s.constructor(t)).c,n=s.s,o=t.s,a=s.e,c=t.e;if(!r[0]||!i[0])return r[0]?n:i[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=c)return a>c^e?1:-1;for(o=(a=r.length)<(c=i.length)?a:c,n=-1;++n<o;)if(r[n]!=i[n])return r[n]>i[n]^e?1:-1;return a==c?0:a>c^e?1:-1};Ee.div=function(t){var e=this,s=e.constructor,r=e.c,i=(t=new s(t)).c,n=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>ar)throw Error(mo);if(!i[0])throw Error(kh);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),f=a=i.length,y=r.length,g=r.slice(0,a),p=g.length,m=t,w=m.c=[],C=0,P=o+(m.e=e.e-t.e)+1;for(m.s=n,n=P<0?0:P,d.unshift(0);p++<a;)g.push(0);do{for(l=0;l<10;l++){if(a!=(p=g.length))u=a>p?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=g[h]){u=i[h]>g[h]?1:-1;break}if(u<0){for(c=p==a?i:d;p;){if(g[--p]<c[p]){for(h=p;h&&!g[--h];)g[h]=9;--g[h],g[p]+=10}g[p]-=c[p]}for(;!g[0];)g.shift()}else break}w[C++]=u?l:++l,g[0]&&u?g[p]=r[f]||0:g=[r[f]]}while((f++<y||g[0]!==os)&&n--);return!w[0]&&C!=1&&(w.shift(),m.e--,P--),C>P&&wr(m,P,s.RM,g[0]!==os),m};Ee.eq=function(t){return this.cmp(t)===0};Ee.gt=function(t){return this.cmp(t)>0};Ee.gte=function(t){return this.cmp(t)>-1};Ee.lt=function(t){return this.cmp(t)<0};Ee.lte=function(t){return this.cmp(t)<1};Ee.minus=Ee.sub=function(t){var e,s,r,i,n=this,o=n.constructor,a=n.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,n.plus(t);var l=n.c.slice(),u=n.e,h=t.c,d=t.e;if(!l[0]||!h[0])return h[0]?t.s=-c:l[0]?t=new o(n):t.s=1,t;if(a=u-d){for((i=a<0)?(a=-a,r=l):(d=u,r=h),r.reverse(),c=a;c--;)r.push(0);r.reverse()}else for(s=((i=l.length<h.length)?l:h).length,a=c=0;c<s;c++)if(l[c]!=h[c]){i=l[c]<h[c];break}if(i&&(r=l,l=h,h=r,t.s=-t.s),(c=(s=h.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<h[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=h[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t};Ee.mod=function(t){var e,s=this,r=s.constructor,i=s.s,n=(t=new r(t)).s;if(!t.c[0])throw Error(kh);return s.s=t.s=1,e=t.cmp(s)==1,s.s=i,t.s=n,e?new r(s):(i=r.DP,n=r.RM,r.DP=r.RM=0,s=s.div(t),r.DP=i,r.RM=n,this.minus(s.times(t)))};Ee.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ee.plus=Ee.add=function(t){var e,s,r,i=this,n=i.constructor;if(t=new n(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new n(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,r=l):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-l.length<0&&(r=l,l=a,a=r),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};Ee.pow=function(t){var e=this,s=new e.constructor("1"),r=s,i=t<0;if(t!==~~t||t<-Gc||t>Gc)throw Error(mr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};Ee.prec=function(t,e){if(t!==~~t||t<1||t>ar)throw Error(mr+"precision");return wr(new this.constructor(this),t,e)};Ee.round=function(t,e){if(t===os)t=0;else if(t!==~~t||t<-ar||t>ar)throw Error(mo);return wr(new this.constructor(this),t+this.e+1,e)};Ee.sqrt=function(){var t,e,s,r=this,i=r.constructor,n=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(n<0)throw Error(vn+"No square root");n=Math.sqrt(+yr(r,!0,!0)),n===0||n===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):t=new i(n+""),o=t.e+(i.DP+=4);do s=t,t=a.times(s.plus(r.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return wr(t,(i.DP-=4)+t.e+1,i.RM)};Ee.times=Ee.mul=function(t){var e,s=this,r=s.constructor,i=s.c,n=(t=new r(t)).c,o=i.length,a=n.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!i[0]||!n[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=n,n=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+n[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};Ee.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>ar)throw Error(mo);for(s=wr(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return yr(s,!0,!!r)};Ee.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==os){if(t!==~~t||t<0||t>ar)throw Error(mo);for(s=wr(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return yr(s,!1,!!r)};Ee[Symbol.for("nodejs.util.inspect.custom")]=Ee.toJSON=Ee.toString=function(){var t=this,e=t.constructor;return yr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ee.toNumber=function(){var t=+yr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(vn+"Imprecise conversion");return t};Ee.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==os){if(t!==~~t||t<1||t>ar)throw Error(mr+"precision");for(s=wr(new r(s),t,e);s.c.length<t;)s.c.push(0)}return yr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};Ee.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(vn+"valueOf disallowed");return yr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Pi=Rh();const df={bigNumber(t){return t?new Pi(t):new Pi(0)},multiply(t,e){if(t===void 0||e===void 0)return new Pi(0);const s=new Pi(t),r=new Pi(e);return s.times(r)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},pf=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],ff=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],gf=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],mf={getERC20Abi:t=>K.USDT_CONTRACT_ADDRESSES.includes(t)?gf:pf,getSwapAbi:()=>ff},Is={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},re={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function Ro(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const se={setItem(t,e){ji()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(ji())return localStorage.getItem(t)||void 0},removeItem(t){ji()&&localStorage.removeItem(t)},clear(){ji()&&localStorage.clear()}};function ji(){return typeof window<"u"&&typeof localStorage<"u"}function ks(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const wf=Symbol(),Jc=Object.getPrototypeOf,Pa=new WeakMap,yf=t=>t&&(Pa.has(t)?Pa.get(t):Jc(t)===Object.prototype||Jc(t)===Array.prototype),bf=t=>yf(t)&&t[wf]||null,Yc=(t,e=!0)=>{Pa.set(t,e)},io={},Uo=t=>typeof t=="object"&&t!==null,Ts=new WeakMap,Fi=new WeakSet,vf=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>Uo(l)&&!Fi.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,u,h=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const f=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Yc(f,!0),i.set(l,[u,f]),Reflect.ownKeys(l).forEach(y=>{if(Object.getOwnPropertyDescriptor(f,y))return;const g=Reflect.get(l,y),{enumerable:p}=Reflect.getOwnPropertyDescriptor(l,y),m={value:g,enumerable:p,configurable:!0};if(Fi.has(g))Yc(g,!1);else if(g instanceof Promise)delete m.value,m.get=()=>h(g);else if(Ts.has(g)){const[w,C]=Ts.get(g);m.value=n(w,C(),h)}Object.defineProperty(f,y,m)}),Object.preventExtensions(f)},o=new WeakMap,a=[1,1],c=l=>{if(!Uo(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,f=(v,T=++a[0])=>{h!==T&&(h=T,d.forEach(_=>_(v,T)))};let y=a[1];const g=(v=++a[1])=>(y!==v&&!d.size&&(y=v,m.forEach(([T])=>{const _=T[1](v);_>h&&(h=_)})),h),p=v=>(T,_)=>{const k=[...T];k[1]=[v,...k[1]],f(k,_)},m=new Map,w=(v,T)=>{if((io?"production":void 0)!=="production"&&m.has(v))throw new Error("prop listener already exists");if(d.size){const _=T[3](p(v));m.set(v,[T,_])}else m.set(v,[T])},C=v=>{var T;const _=m.get(v);_&&(m.delete(v),(T=_[1])==null||T.call(_))},P=v=>(d.add(v),d.size===1&&m.forEach(([_,k],L)=>{if((io?"production":void 0)!=="production"&&k)throw new Error("remove already exists");const E=_[3](p(L));m.set(L,[_,E])}),()=>{d.delete(v),d.size===0&&m.forEach(([_,k],L)=>{k&&(k(),m.set(L,[_]))})}),R=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e(R,{deleteProperty(v,T){const _=Reflect.get(v,T);C(T);const k=Reflect.deleteProperty(v,T);return k&&f(["delete",[T],_]),k},set(v,T,_,k){const L=Reflect.has(v,T),E=Reflect.get(v,T,k);if(L&&(t(E,_)||o.has(_)&&t(E,o.get(_))))return!0;C(T),Uo(_)&&(_=bf(_)||_);let A=_;if(_ instanceof Promise)_.then(I=>{_.status="fulfilled",_.value=I,f(["resolve",[T],I])}).catch(I=>{_.status="rejected",_.reason=I,f(["reject",[T],I])});else{!Ts.has(_)&&s(_)&&(A=c(_));const I=!Fi.has(A)&&Ts.get(A);I&&w(T,I)}return Reflect.set(v,T,A,k),f(["set",[T],_,E]),!0}});o.set(l,S);const $=[R,g,n,P];return Ts.set(S,$),Reflect.ownKeys(l).forEach(v=>{const T=Object.getOwnPropertyDescriptor(l,v);"value"in T&&(S[v]=l[v],delete T.value,delete T.writable),Object.defineProperty(R,v,T)}),S})=>[c,Ts,Fi,t,e,s,r,i,n,o,a],[Ef]=vf();function xe(t={}){return Ef(t)}function nt(t,e,s){const r=Ts.get(t);(io?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let i;const n=[],o=r[3];let a=!1;const l=o(u=>{n.push(u),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function an(t,e){const s=Ts.get(t);(io?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function cr(t){return Fi.add(t),t}function ot(t,e,s,r){let i=t[e];return nt(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function Cf(t){const e=xe({data:Array.from([]),has(s){return this.data.some(r=>r[0]===s)},set(s,r){const i=this.data.find(n=>n[0]===s);return i?i[1]=r:this.data.push([s,r]),this},get(s){var r;return(r=this.data.find(i=>i[0]===s))==null?void 0:r[1]},delete(s){const r=this.data.findIndex(i=>i[0]===s);return r===-1?!1:(this.data.splice(r,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(s){this.data.forEach(r=>{s(r[1],r[0],this)})},keys(){return this.data.map(s=>s[0]).values()},values(){return this.data.map(s=>s[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const Uh=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],If="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Pe={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,ONE_SEC_MS:1e3,BALANCE_SUPPORTED_CHAINS:["eip155","solana"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal"}},W={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=W.getActiveNamespace(),e=W.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,r=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:r}},setWalletConnectDeepLink({name:t,href:e}){try{se.setItem(re.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=se.getItem(re.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{se.removeItem(re.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{se.setItem(re.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{se.setItem(re.ACTIVE_CAIP_NETWORK_ID,t),W.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return se.getItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{se.removeItem(re.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=Ro(t);se.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=W.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),se.setItem(re.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=se.getItem(re.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Ro(t);se.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return se.getItem(re.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Ro(t);return se.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{se.setItem(re.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return se.getItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{se.removeItem(re.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return se.getItem(re.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=se.getItem(re.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{se.setItem(re.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return se.getItem(re.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=se.getItem(re.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));se.setItem(re.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=W.getConnectedNamespaces();e.includes(t)||(e.push(t),W.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=W.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),W.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return se.getItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{se.setItem(re.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{se.removeItem(re.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=se.getItem(re.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=W.getBalanceCache();se.setItem(re.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=W.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;W.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=W.getBalanceCache();e[t.caipAddress]=t,se.setItem(re.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=se.getItem(re.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=W.getBalanceCache();se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=W.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),W.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=W.getNativeBalanceCache();e[t.caipAddress]=t,se.setItem(re.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=se.getItem(re.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=W.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;W.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=W.getEnsCache();e[t.address]=t,se.setItem(re.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=W.getEnsCache();se.setItem(re.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=se.getItem(re.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=W.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;W.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=W.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},se.setItem(re.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=W.getIdentityCache();se.setItem(re.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{se.removeItem(re.PORTFOLIO_CACHE),se.removeItem(re.NATIVE_BALANCE_CACHE),se.removeItem(re.ENS_CACHE),se.removeItem(re.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{se.setItem(re.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=se.getItem(re.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s={...W.getConnections(),[e]:t};se.setItem(re.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=se.getItem(re.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},te={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return te.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Pe.TEN_SEC_MS:!0},isAllowedRetry(t,e=Pe.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(te.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Pe.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(te.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t,i=s;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),i&&!(i!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!te.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const r=encodeURIComponent(e);return{redirect:`${s}wc?uri=${r}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?W.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,te.wait(2e3)])},formatBalance(t,e){let s="0.000";if(typeof t=="string"){const r=Number(t);if(r){const i=Math.floor(r*1e3)/1e3;i&&(s=i.toString())}}return`${s}${e?` ${e}`:""}`},formatBalance2(t,e){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return K.W3M_API_URL},getBlockchainApiUrl(){return K.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return K.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?Pe.ADAPTER_TYPES.UNIVERSAL:t.map(n=>n.adapterType).join(",");return`${e}-${i}-${s}`},createAccount(t,e,s,r,i){return{namespace:t,address:e,type:s,publicKey:r,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in K.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function Oi(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class En{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:r,...i}){const n=this.createUrl(i);return(await Oi(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await Oi(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Oi(n,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Oi(n,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await Oi(n,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:s}){const r=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([i,n])=>{n&&r.searchParams.append(i,n)}),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}const Af={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Pe.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(te.isTelegram()){if(te.isIos())return t.filter(e=>e!=="google");if(te.isMac())return t.filter(e=>e!=="x");if(te.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},Y=xe({features:Pe.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Pe.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),B={state:Y,subscribeKey(t,e){return ot(Y,t,e)},setOptions(t){Object.assign(Y,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...Y.remoteFeatures,...t};Y.remoteFeatures=e,(s=Y.remoteFeatures)!=null&&s.socials&&(Y.remoteFeatures.socials=Af.filterSocialsByPlatform(Y.remoteFeatures.socials))},setFeatures(t){if(!t)return;Y.features||(Y.features=Pe.DEFAULT_FEATURES);const e={...Y.features,...t};Y.features=e},setProjectId(t){Y.projectId=t},setCustomRpcUrls(t){Y.customRpcUrls=t},setAllWallets(t){Y.allWallets=t},setIncludeWalletIds(t){Y.includeWalletIds=t},setExcludeWalletIds(t){Y.excludeWalletIds=t},setFeaturedWalletIds(t){Y.featuredWalletIds=t},setTokens(t){Y.tokens=t},setTermsConditionsUrl(t){Y.termsConditionsUrl=t},setPrivacyPolicyUrl(t){Y.privacyPolicyUrl=t},setCustomWallets(t){Y.customWallets=t},setIsSiweEnabled(t){Y.isSiweEnabled=t},setIsUniversalProvider(t){Y.isUniversalProvider=t},setSdkVersion(t){Y.sdkVersion=t},setMetadata(t){Y.metadata=t},setDisableAppend(t){Y.disableAppend=t},setEIP6963Enabled(t){Y.enableEIP6963=t},setDebug(t){Y.debug=t},setEnableWalletConnect(t){Y.enableWalletConnect=t},setEnableWalletGuide(t){Y.enableWalletGuide=t},setEnableAuthLogger(t){Y.enableAuthLogger=t},setEnableWallets(t){Y.enableWallets=t},setPreferUniversalLinks(t){Y.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){Y.hasMultipleAddresses=t},setSIWX(t){Y.siwx=t},setConnectMethodsOrder(t){Y.features={...Y.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){Y.features={...Y.features,walletFeaturesOrder:t}},setSocialsOrder(t){Y.remoteFeatures={...Y.remoteFeatures,socials:t}},setCollapseWallets(t){Y.features={...Y.features,collapseWallets:t}},setEnableEmbedded(t){Y.enableEmbedded=t},setAllowUnsupportedChain(t){Y.allowUnsupportedChain=t},setManualWCControl(t){Y.manualWCControl=t},setEnableNetworkSwitch(t){Y.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(Y.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){Y.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return Y.universalProviderConfigOverride},getSnapshot(){return an(Y)}},Nf=Object.freeze({enabled:!0,events:[]}),_f=new En({baseUrl:te.getAnalyticsUrl(),clientId:null}),Sf=5,Pf=60*1e3,As=xe({...Nf}),Of={state:As,subscribeKey(t,e){return ot(As,t,e)},async sendError(t,e){if(!As.enabled)return;const s=Date.now();if(As.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<Pf}).length>=Sf)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};As.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=B.state;await _f.post({path:"/e",params:{projectId:n,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:te.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){As.enabled=!0},disable(){As.enabled=!1},clearEvents(){As.events=[]}};class ri extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,ri.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
3
|
+
`);if(o>-1){const a=n.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
4
|
+
${a}`,i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,ri):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Zc(t,e){const s=t instanceof ri?t:new ri(t instanceof Error?t.message:String(t),e,t);throw Of.sendError(s,s.category),s}function kt(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(r=>{const i=t[r];if(typeof i=="function"){let n=i;i.constructor.name==="AsyncFunction"?n=async(...o)=>{try{return await i(...o)}catch(a){return Zc(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return Zc(a,e)}},s[r]=n}else s[r]=i}),s}const ns={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},$f={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===ns.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${ns.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===ns.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${ns.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===K.CHAIN.SOLANA&&t===ns.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${ns.COINBASE.url}/dapp?cb_url=${r}`)}},Ct=xe({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Tf={state:Ct,subscribeNetworkImages(t){return nt(Ct.networkImages,()=>t(Ct.networkImages))},subscribeKey(t,e){return ot(Ct,t,e)},subscribe(t){return nt(Ct,()=>t(Ct))},setWalletImage(t,e){Ct.walletImages[t]=e},setNetworkImage(t,e){Ct.networkImages[t]=e},setChainImage(t,e){Ct.chainImages[t]=e},setConnectorImage(t,e){Ct.connectorImages={...Ct.connectorImages,[t]:e}},setTokenImage(t,e){Ct.tokenImages[t]=e},setCurrencyImage(t,e){Ct.currencyImages[t]=e}},Jt=kt(Tf),xf={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},Do=xe({networkImagePromises:{}}),Dh={async fetchWalletImage(t){if(t)return await J._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(Do.networkImagePromises[t]||(Do.networkImagePromises[t]=J._fetchNetworkImage(t)),await Do.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Jt.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return Jt.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,r;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((r=t==null?void 0:t.assets)!=null&&r.imageId)return Jt.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Jt.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Jt.state.connectorImages[t.imageId]},getChainImage(t){return Jt.state.networkImages[xf[t]]}},Ns=xe({message:"",variant:"info",open:!1}),kf={state:Ns,subscribeKey(t,e){return ot(Ns,t,e)},open(t,e){const{debug:s}=B.state,{shortMessage:r,longMessage:i}=t;s&&(Ns.message=r,Ns.variant=e,Ns.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){Ns.open=!1,Ns.message="",Ns.variant="info"}},Js=kt(kf),Rf=te.getAnalyticsUrl(),Uf=new En({baseUrl:Rf,clientId:null}),Df=["MODAL_CREATED"],ls=xe({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Ue={state:ls,subscribe(t){return nt(ls,()=>t(ls))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=B.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=V.state.address;if(Df.includes(t.data.event)||typeof window>"u")return;await Uf.post({path:"/e",params:Ue.getSdkProperties(),body:{eventId:te.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),ls.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===K.HTTP_STATUS_CODES.FORBIDDEN&&!ls.reportedErrors.FORBIDDEN&&(Js.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${ji()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),ls.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;ls.timestamp=Date.now(),ls.data=t,(e=B.state.features)!=null&&e.analytics&&Ue._sendAnalyticsEvent(ls)}},Lf=te.getApiUrl(),dt=new En({baseUrl:Lf,clientId:null}),Bf=40,Xc=4,Mf=20,ie=xe({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),J={state:ie,subscribeKey(t,e){return ot(ie,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=B.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return B.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${dt.baseUrl}/getWalletImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${dt.baseUrl}/public/getCurrencyImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${dt.baseUrl}/public/getTokenImage/${t}`,s=await dt.getBlob({path:e,params:J._getSdkProperties()});Jt.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return te.isMobile()?t==null?void 0:t.filter(s=>s.mobile_link||s.id===ns.COINBASE.id?!0:b.state.activeChain==="solana"&&(s.id===ns.SOLFLARE.id||s.id===ns.PHANTOM.id)):t},async fetchProjectConfig(){return(await dt.get({path:"/appkit/v1/config",params:J._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await dt.get({path:"/projects/v1/origins",params:J._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=b.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!Dh.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>J._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=H.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>J._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>J._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>J._fetchTokenImage(e)))},async fetchWallets(t){var n;const e=t.exclude??[];J._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(ns).map(o=>o.id));const r=await dt.get({path:"/getWallets",params:{...J._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(n=t.include)==null?void 0:n.join(","),exclude:e.join(",")}});return{data:J._filterWalletsByPlatform(r==null?void 0:r.data)||[],count:r==null?void 0:r.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=B.state;if(t!=null&&t.length){const e={...J._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Xc,include:t},{data:s}=await J.fetchWallets(e),r=[...s].sort((n,o)=>t.indexOf(n.id)-t.indexOf(o.id)),i=r.map(n=>n.image_id).filter(Boolean);await Promise.allSettled(i.map(n=>J._fetchWalletImage(n))),ie.featured=r,ie.allFeatured=r}},async fetchRecommendedWallets(){try{ie.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=B.state,r=[...e??[],...s??[]].filter(Boolean),i=b.getRequestedCaipNetworkIds().join(","),n={page:1,entries:Xc,include:t,exclude:r,chains:i},{data:o,count:a}=await J.fetchWallets(n),c=W.getRecentWallets(),l=o.map(h=>h.image_id).filter(Boolean),u=c.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(h=>J._fetchWalletImage(h))),ie.recommended=o,ie.allRecommended=o,ie.count=a??0}catch{}finally{ie.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=B.state,i=b.getRequestedCaipNetworkIds().join(","),n=[...ie.recommended.map(({id:u})=>u),...s??[],...r??[]].filter(Boolean),o={page:t,entries:Bf,include:e,exclude:n,chains:i},{data:a,count:c}=await J.fetchWallets(o),l=a.slice(0,Mf).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>J._fetchWalletImage(u))),ie.wallets=te.uniqueBy([...ie.wallets,...J._filterOutExtensions(a)],"id").filter(u=>{var h;return(h=u.chains)==null?void 0:h.some(d=>i.includes(d))}),ie.count=c>ie.count?c:ie.count,ie.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await J.fetchWallets(e);s&&s.forEach(r=>{ie.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=B.state,i=b.getRequestedCaipNetworkIds().join(",");ie.search=[];const n={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:r,chains:i},{data:o}=await J.fetchWallets(n);Ue.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>J._fetchWalletImage(c)),te.wait(300)]),ie.search=J._filterOutExtensions(o)},initPromise(t,e){const s=ie.promises[t];return s||(ie.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&J.initPromise("connectorImages",J.fetchConnectorImages),e&&J.initPromise("featuredWallets",J.fetchFeaturedWallets),s&&J.initPromise("recommendedWallets",J.fetchRecommendedWallets),r&&J.initPromise("networkImages",J.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=B.state.features)!=null&&t.analytics&&J.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await dt.get({path:"/getAnalyticsConfig",params:J._getSdkProperties()});B.setFeatures({analytics:t})}catch{B.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){ie.featured=ie.allFeatured,ie.recommended=ie.allRecommended;return}const e=b.getRequestedCaipNetworkIds().join(",");ie.featured=ie.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.recommended=ie.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.filteredWallets=ie.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})},clearFilterByNamespaces(){ie.filteredWallets=[]},setFilterByNamespace(t){if(!t){ie.featured=ie.allFeatured,ie.recommended=ie.allRecommended;return}const e=b.getRequestedCaipNetworkIds().join(",");ie.featured=ie.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.recommended=ie.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),ie.filteredWallets=ie.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})}},Ce=xe({view:"Connect",history:["Connect"],transactionStack:[]}),qf={state:Ce,subscribeKey(t,e){return ot(Ce,t,e)},pushTransactionStack(t){Ce.transactionStack.push(t)},popTransactionStack(t){const e=Ce.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:r,onCancel:i}=e;switch(t){case"success":s==null||s();break;case"error":r==null||r(),ne.goBack();break;case"cancel":i==null||i(),ne.goBack();break}},push(t,e){t!==Ce.view&&(Ce.view=t,Ce.history.push(t),Ce.data=e)},reset(t,e){Ce.view=t,Ce.history=[t],Ce.data=e},replace(t,e){Ce.history.at(-1)===t||(Ce.view=t,Ce.history[Ce.history.length-1]=t,Ce.data=e)},goBack(){var r;const t=b.state.activeCaipAddress,e=ne.state.view==="ConnectingFarcaster",s=!t&&e;if(Ce.history.length>1){Ce.history.pop();const[i]=Ce.history.slice(-1);i&&(t&&i==="Connect"?Ce.view="Account":Ce.view=i)}else Ge.close();(r=Ce.data)!=null&&r.wallet&&(Ce.data.wallet=void 0),setTimeout(()=>{var i,n,o;if(s){V.setFarcasterUrl(void 0,b.state.activeChain);const a=H.getAuthConnector();(i=a==null?void 0:a.provider)==null||i.reload();const c=an(B.state);(o=(n=a==null?void 0:a.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:c.metadata,sdkVersion:c.sdkVersion,projectId:c.projectId,sdkType:c.sdkType})}},100)},goBackToIndex(t){if(Ce.history.length>1){Ce.history=Ce.history.slice(0,t+1);const[e]=Ce.history.slice(-1);e&&(Ce.view=e)}},goBackOrCloseModal(){ne.state.history.length>1?ne.goBack():Ge.close()}},ne=kt(qf),us=xe({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),Oa={state:us,subscribe(t){return nt(us,()=>t(us))},setThemeMode(t){us.themeMode=t;try{const e=H.getAuthConnector();if(e){const s=Oa.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:ks(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){us.themeVariables={...us.themeVariables,...t};try{const e=H.getAuthConnector();if(e){const s=Oa.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:ks(us.themeVariables,us.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return an(us)}},Nt=kt(Oa),Lh={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},pe=xe({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Lh},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),jf={state:pe,subscribe(t){return nt(pe,()=>{t(pe)})},subscribeKey(t,e){return ot(pe,t,e)},initialize(t){t.forEach(e=>{const s=W.getConnectedConnectorId(e);s&&H.setConnectorId(s,e)})},setActiveConnector(t){t&&(pe.activeConnector=cr(t))},setConnectors(t){t.filter(i=>!pe.allConnectors.some(n=>n.id===i.id&&H.getConnectorName(n.name)===H.getConnectorName(i.name)&&n.chain===i.chain)).forEach(i=>{i.type!=="MULTI_CHAIN"&&pe.allConnectors.push(cr(i))});const s=H.getEnabledNamespaces(),r=H.getEnabledConnectors(s);pe.connectors=H.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(pe.filterByNamespaceMap).forEach(e=>{pe.filterByNamespaceMap[e]=!1}),t.forEach(e=>{pe.filterByNamespaceMap[e]=!0}),H.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){pe.filterByNamespaceMap[t]=e,H.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=H.getEnabledNamespaces(),e=H.getEnabledConnectors(t),s=H.areAllNamespacesEnabled();pe.connectors=H.mergeMultiChainConnectors(e),s?J.clearFilterByNamespaces():J.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(pe.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return pe.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(pe.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=H.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=(i==null?void 0:i.id)===K.CONNECTOR_ID.AUTH;r.length>1&&i?s.push({name:i.name,imageUrl:i.imageUrl,imageId:i.imageId,connectors:[...r],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(i==null?void 0:i.id)||""}):i&&s.push(i)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:r}=s,i=H.getConnectorName(r);if(!i)return;const n=e.get(i)||[];n.find(a=>a.chain===s.chain)||n.push(s),e.set(i,n)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(r=>r.chain===s.chain)||e.push(s)}),e},addConnector(t){var e,s,r;if(t.id===K.CONNECTOR_ID.AUTH){const i=t,n=an(B.state),o=Nt.getSnapshot().themeMode,a=Nt.getSnapshot().themeVariables;(s=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(r=i==null?void 0:i.provider)==null||r.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:ks(a,o)}),H.setConnectors([t])}else H.setConnectors([t])},getAuthConnector(t){var r;const e=t||b.state.activeChain,s=pe.connectors.find(i=>i.id===K.CONNECTOR_ID.AUTH);if(s)return(r=s==null?void 0:s.connectors)!=null&&r.length?s.connectors.find(n=>n.chain===e):s},getAnnouncedConnectorRdns(){return pe.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return pe.allConnectors.find(e=>e.id===t)},getConnector(t,e){return pe.allConnectors.filter(r=>r.chain===b.state.activeChain).find(r=>{var i;return r.explorerId===t||((i=r.info)==null?void 0:i.rdns)===e})},syncIfAuthConnector(t){var n,o;if(t.id!=="ID_AUTH")return;const e=t,s=an(B.state),r=Nt.getSnapshot().themeMode,i=Nt.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:ks(i,r)})},getConnectorsByNamespace(t){const e=pe.allConnectors.filter(s=>s.chain===t);return H.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=H.getConnector(t.id,t.rdns),s=b.state.activeChain;$f.handleMobileDeeplinkRedirect((e==null?void 0:e.explorerId)||t.id,s),e?ne.push("ConnectingExternal",{connector:e}):ne.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?H.getConnectorsByNamespace(t):H.mergeMultiChainConnectors(pe.allConnectors)},setFilterByNamespace(t){pe.filterByNamespace=t,pe.connectors=H.getConnectors(t),J.setFilterByNamespace(t)},setConnectorId(t,e){t&&(pe.activeConnectorIds={...pe.activeConnectorIds,[e]:t},W.setConnectedConnectorId(e,t))},removeConnectorId(t){pe.activeConnectorIds={...pe.activeConnectorIds,[t]:void 0},W.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return pe.activeConnectorIds[t]},isConnected(t){return t?!!pe.activeConnectorIds[t]:Object.values(pe.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){pe.activeConnectorIds={...Lh}}},H=kt(jf),Ji={ACCOUNT_TYPES:{SMART_ACCOUNT:"smartAccount"}},Gs=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Me=xe({...Gs}),Ff={state:Me,subscribeKey(t,e){return ot(Me,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=te.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){Me.message=Gs.message,Me.variant=Gs.variant,Me.svg=Gs.svg,Me.open=Gs.open,Me.autoClose=Gs.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=Gs.autoClose}){Me.open?(Me.open=!1,setTimeout(()=>{Me.message=t,Me.variant=s,Me.svg=e,Me.open=!0,Me.autoClose=r},150)):(Me.message=t,Me.variant=s,Me.svg=e,Me.open=!0,Me.autoClose=r)}},Yt=Ff,Oe=xe({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),zf={state:Oe,subscribe(t){return nt(Oe,()=>t(Oe))},setLastNetworkInView(t){Oe.lastNetworkInView=t},async fetchTransactions(t,e){var s,r;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Oe.loading=!0;try{const i=await Q.fetchTransactions({account:t,cursor:Oe.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId}),n=zi.filterSpamTransactions(i.data),o=zi.filterByConnectedChain(n),a=[...Oe.transactions,...o];Oe.loading=!1,e==="coinbase"?Oe.coinbaseTransactions=zi.groupTransactionsByYearAndMonth(Oe.coinbaseTransactions,i.data):(Oe.transactions=a,Oe.transactionsByYear=zi.groupTransactionsByYearAndMonth(Oe.transactionsByYear,o)),Oe.empty=a.length===0,Oe.next=i.next?i.next:void 0}catch{const n=b.state.activeChain;Ue.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:B.state.projectId,cursor:Oe.next,isSmartAccount:((r=V.state.preferredAccountTypes)==null?void 0:r[n])===Ji.ACCOUNT_TYPES.SMART_ACCOUNT}}),Yt.showError("Failed to fetch transactions"),Oe.loading=!1,Oe.empty=!0,Oe.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(r=>{const i=new Date(r.metadata.minedAt).getFullYear(),n=new Date(r.metadata.minedAt).getMonth(),o=s[i]??{},c=(o[n]??[]).filter(l=>l.id!==r.id);s[i]={...o,[n]:[...c,r].sort((l,u)=>new Date(u.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){Oe.next=void 0},resetTransactions(){Oe.transactions=[],Oe.transactionsByYear={},Oe.lastNetworkInView=void 0,Oe.loading=!1,Oe.empty=!1,Oe.next=void 0}},zi=kt(zf,"API_ERROR"),Ae=xe({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Hs;const Hf={state:Ae,subscribeKey(t,e){return ot(Ae,t,e)},_getClient(){return Ae._client},setClient(t){Ae._client=cr(t)},async connectWalletConnect(){var t,e,s,r;if(te.isTelegram()||te.isSafari()&&te.isIos()){if(Hs){await Hs,Hs=void 0;return}if(!te.isPairingExpired(Ae==null?void 0:Ae.wcPairingExpiry)){const i=Ae.wcUri;Ae.wcUri=i;return}Hs=(e=(t=ee._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),ee.state.status="connecting",await Hs,Hs=void 0,Ae.wcPairingExpiry=void 0,ee.state.status="connected"}else await((r=(s=ee._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:r.call(s))},async connectExternal(t,e,s=!0){var r,i;await((i=(r=ee._getClient())==null?void 0:r.connectExternal)==null?void 0:i.call(r,t)),s&&b.setActiveNamespace(e)},async reconnectExternal(t){var s,r;await((r=(s=ee._getClient())==null?void 0:s.reconnectExternal)==null?void 0:r.call(s,t));const e=t.chain||b.state.activeChain;e&&H.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var r;Ge.setLoading(!0,b.state.activeChain);const s=H.getAuthConnector();s&&(V.setPreferredAccountType(t,e),await s.provider.setPreferredAccount(t),W.setPreferredAccountTypes(V.state.preferredAccountTypes??{[e]:t}),await ee.reconnectExternal(s),Ge.setLoading(!1,b.state.activeChain),Ue.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=ee._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=ee._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=ee._getClient())==null?void 0:s.formatUnits(t,e)},async sendTransaction(t){var e;return(e=ee._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=ee._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=ee._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=ee._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=ee._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=ee._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=ee._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=ee._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=ee._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){Ae.wcUri=void 0,Ae.wcPairingExpiry=void 0,Ae.wcLinking=void 0,Ae.recentWallet=void 0,Ae.status="disconnected",zi.resetTransactions(),W.deleteWalletConnectDeepLink()},resetUri(){Ae.wcUri=void 0,Ae.wcPairingExpiry=void 0,Hs=void 0},finalizeWcConnection(){var s,r;const{wcLinking:t,recentWallet:e}=ee.state;t&&W.setWalletConnectDeepLink(t),e&&W.setAppKitRecent(e),Ue.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((r=(s=ne.state.data)==null?void 0:s.wallet)==null?void 0:r.name)||"Unknown"}})},setWcBasic(t){Ae.wcBasic=t},setUri(t){Ae.wcUri=t,Ae.wcPairingExpiry=te.getPairingExpiry()},setWcLinking(t){Ae.wcLinking=t},setWcError(t){Ae.wcError=t,Ae.buffering=!1},setRecentWallet(t){Ae.recentWallet=t},setBuffering(t){Ae.buffering=t},setStatus(t){Ae.status=t},async disconnect(t){var e;try{await((e=ee._getClient())==null?void 0:e.disconnect(t))}catch(s){throw new ri("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){Ae.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(H.state.activeConnectorIds[s]===t.connectorId){const n=b.state.activeCaipNetwork;if(n){const o=`${s}:${n.id}:${e}`;V.setCaipAddress(o,s)}else console.warn(`No current network found for namespace "${s}"`)}else{const n=H.getConnector(t.connectorId);n?ee.connectExternal(n,s):console.warn(`No connector found for namespace "${s}"`)}}},ee=kt(Hf),Cr=xe({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Us={state:Cr,subscribe(t){return nt(Cr,()=>t(Cr))},subscribeOpen(t){return ot(Cr,"open",t)},set(t){Object.assign(Cr,{...Cr,...t})}},Lo={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return Gp(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],r=parseInt(s,10);return isNaN(r)?"0x0":`0x${r.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}},Qc={async getMyTokensWithBalance(t){const e=V.state.address,s=b.state.activeCaipNetwork;if(!e||!s)return[];if(s.chainNamespace==="eip155"){const i=await this.getEIP155Balances(e,s);if(i)return this.filterLowQualityTokens(i)}const r=await Q.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(r.balances)},async getEIP155Balances(t,e){var s,r;try{const i=Lo.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await ee.getCapabilities(t);if(!((r=(s=n==null?void 0:n[i])==null?void 0:s.assetDiscovery)!=null&&r.supported))return null;const o=await ee.walletGetAssets({account:t,chainFilter:[i]});return Lo.isWalletGetAssetsResponse(o)?(o[i]||[]).map(c=>Lo.createBalance(c,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:b.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},ve=xe({tokenBalances:[],loading:!1}),Wf={state:ve,subscribe(t){return nt(ve,()=>t(ve))},subscribeKey(t,e){return ot(ve,t,e)},setToken(t){t&&(ve.token=cr(t))},setTokenAmount(t){ve.sendTokenAmount=t},setReceiverAddress(t){ve.receiverAddress=t},setReceiverProfileImageUrl(t){ve.receiverProfileImageUrl=t},setReceiverProfileName(t){ve.receiverProfileName=t},setNetworkBalanceInUsd(t){ve.networkBalanceInUSD=t},setLoading(t){ve.loading=t},async sendToken(){var t;try{switch(ye.setLoading(!0),(t=b.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await ye.sendEvmToken();return;case"solana":await ye.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}finally{ye.setLoading(!1)}},async sendEvmToken(){var s,r,i,n;const t=b.state.activeChain,e=(s=V.state.preferredAccountTypes)==null?void 0:s[t];if(!ye.state.sendTokenAmount||!ye.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!ye.state.token)throw new Error("A token is required");(r=ye.state.token)!=null&&r.address?(Ue.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ji.ACCOUNT_TYPES.SMART_ACCOUNT,token:ye.state.token.address,amount:ye.state.sendTokenAmount,network:((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),await ye.sendERC20Token({receiverAddress:ye.state.receiverAddress,tokenAddress:ye.state.token.address,sendTokenAmount:ye.state.sendTokenAmount,decimals:ye.state.token.quantity.decimals})):(Ue.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ji.ACCOUNT_TYPES.SMART_ACCOUNT,token:ye.state.token.symbol||"",amount:ye.state.sendTokenAmount,network:((n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}),await ye.sendNativeToken({receiverAddress:ye.state.receiverAddress,sendTokenAmount:ye.state.sendTokenAmount,decimals:ye.state.token.quantity.decimals}))},async fetchTokenBalance(t){var n,o;ve.loading=!0;const e=(n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=b.state.activeCaipAddress,i=r?te.getPlainAddress(r):void 0;if(ve.lastRetry&&!te.isAllowedRetry(ve.lastRetry,30*Pe.ONE_SEC_MS))return ve.loading=!1,[];try{if(i&&e&&s){const a=await Qc.getMyTokensWithBalance();return ve.tokenBalances=a,ve.lastRetry=void 0,a}}catch(a){ve.lastRetry=Date.now(),t==null||t(a),Yt.showError("Token Balance Unavailable")}finally{ve.loading=!1}return[]},fetchNetworkBalance(){if(ve.tokenBalances.length===0)return;const t=Qc.mapBalancesToSwapTokens(ve.tokenBalances);if(!t)return;const e=t.find(s=>s.address===b.getActiveNetworkTokenAddress());e&&(ve.networkBalanceInUSD=e?df.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var n,o,a,c;ne.pushTransactionStack({});const e=t.receiverAddress,s=V.state.address,r=ee.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));await ee.sendTransaction({chainNamespace:"eip155",to:e,address:s,data:"0x",value:r??BigInt(0)}),Ue.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:((n=V.state.preferredAccountTypes)==null?void 0:n.eip155)===Ji.ACCOUNT_TYPES.SMART_ACCOUNT,token:((o=ye.state.token)==null?void 0:o.symbol)||"",amount:t.sendTokenAmount,network:((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||""}}),(c=ee._getClient())==null||c.updateBalance("eip155"),ye.resetSend()},async sendERC20Token(t){ne.pushTransactionStack({onSuccess(){ne.replace("Account")}});const e=ee.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));if(V.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const s=te.getPlainAddress(t.tokenAddress);await ee.writeContract({fromAddress:V.state.address,tokenAddress:s,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:mf.getERC20Abi(s),chainNamespace:"eip155"}),ye.resetSend()}},async sendSolanaToken(){var t;if(!ye.state.sendTokenAmount||!ye.state.receiverAddress)throw new Error("An amount and receiver address are required");ne.pushTransactionStack({onSuccess(){ne.replace("Account")}}),await ee.sendTransaction({chainNamespace:"solana",to:ye.state.receiverAddress,value:ye.state.sendTokenAmount}),(t=ee._getClient())==null||t.updateBalance("solana"),ye.resetSend()},resetSend(){ve.token=void 0,ve.sendTokenAmount=void 0,ve.receiverAddress=void 0,ve.receiverProfileImageUrl=void 0,ve.receiverProfileName=void 0,ve.loading=!1,ve.tokenBalances=[]}},ye=kt(Wf),Bo={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},kn={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},z=xe({chains:Cf(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),Vf={state:z,subscribe(t){return nt(z,()=>{t(z)})},subscribeKey(t,e){return ot(z,t,e)},subscribeChainProp(t,e,s){let r;return nt(z.chains,()=>{var n;const i=s||z.activeChain;if(i){const o=(n=z.chains.get(i))==null?void 0:n[t];r!==o&&(r=o,e(o))}})},initialize(t,e,s){const{chainId:r,namespace:i}=W.getActiveNetworkProps(),n=e==null?void 0:e.find(u=>u.id.toString()===(r==null?void 0:r.toString())),a=t.find(u=>(u==null?void 0:u.namespace)===i)||(t==null?void 0:t[0]),c=t.map(u=>u.namespace).filter(u=>u!==void 0),l=B.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(u=>u.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(z.noAdapters=!0),z.noAdapters||(z.activeChain=a==null?void 0:a.namespace,z.activeCaipNetwork=n,b.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),z.activeChain&&Us.set({activeChain:a==null?void 0:a.namespace})),l.forEach(u=>{const h=e==null?void 0:e.filter(d=>d.chainNamespace===u);b.state.chains.set(u,{namespace:u,networkState:xe({...kn,caipNetwork:h==null?void 0:h[0]}),accountState:xe(Bo),caipNetworks:h??[],...s}),b.setRequestedCaipNetworks(h??[],u)})},removeAdapter(t){var e,s;if(z.activeChain===t){const r=Array.from(z.chains.entries()).find(([i])=>i!==t);if(r){const i=(s=(e=r[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];i&&b.setActiveCaipNetwork(i)}}z.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){z.chains.set(t.namespace,{namespace:t.namespace,networkState:{...kn,caipNetwork:r[0]},accountState:Bo,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),b.setRequestedCaipNetworks((r==null?void 0:r.filter(i=>i.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=z.chains.get(t.chainNamespace);if(e){const r=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(i=>i.id===t.id)||r.push(t),z.chains.set(t.chainNamespace,{...e,caipNetworks:r}),b.setRequestedCaipNetworks(r,t.chainNamespace),H.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var r,i,n;const s=z.chains.get(t);if(s){const o=((r=z.activeCaipNetwork)==null?void 0:r.id)===e,a=[...((i=s.caipNetworks)==null?void 0:i.filter(c=>c.id!==e))||[]];o&&((n=s==null?void 0:s.caipNetworks)!=null&&n[0])&&b.setActiveCaipNetwork(s.caipNetworks[0]),z.chains.set(t,{...s,caipNetworks:a}),b.setRequestedCaipNetworks(a||[],t),a.length===0&&H.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=z.chains.get(t);s&&(s.networkState={...s.networkState||kn,...e},z.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const r=z.chains.get(t);if(r){const i={...r.accountState||Bo,...e};z.chains.set(t,{...r,accountState:i}),(z.chains.size===1||z.activeChain===t)&&(e.caipAddress&&(z.activeCaipAddress=e.caipAddress),V.replaceState(i))}},setChainNetworkData(t,e){if(!t)return;const s=z.chains.get(t);if(s){const r={...s.networkState||kn,...e};z.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){b.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&H.removeConnectorId(s)},setActiveNamespace(t){var r,i;z.activeChain=t;const e=t?z.chains.get(t):void 0,s=(r=e==null?void 0:e.networkState)==null?void 0:r.caipNetwork;s!=null&&s.id&&t&&(z.activeCaipAddress=(i=e==null?void 0:e.accountState)==null?void 0:i.caipAddress,z.activeCaipNetwork=s,b.setChainNetworkData(t,{caipNetwork:s}),W.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),Us.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var r,i,n;if(!t)return;z.activeChain!==t.chainNamespace&&b.setIsSwitchingNamespace(!0);const e=z.chains.get(t.chainNamespace);z.activeChain=t.chainNamespace,z.activeCaipNetwork=t,b.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),(r=e==null?void 0:e.accountState)!=null&&r.address?z.activeCaipAddress=`${t.chainNamespace}:${t.id}:${(i=e==null?void 0:e.accountState)==null?void 0:i.address}`:z.activeCaipAddress=void 0,b.setAccountProp("caipAddress",z.activeCaipAddress,t.chainNamespace),e&&V.replaceState(e.accountState),ye.resetSend(),Us.set({activeChain:z.activeChain,selectedNetworkId:(n=z.activeCaipNetwork)==null?void 0:n.caipNetworkId}),W.setActiveCaipNetworkId(t.caipNetworkId),!b.checkIfSupportedNetwork(t.chainNamespace)&&B.state.enableNetworkSwitch&&!B.state.allowUnsupportedChain&&!ee.state.wcBasic&&b.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=z.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var i;if(!t)return;const e=t!==b.state.activeChain,s=(i=b.getNetworkData(t))==null?void 0:i.caipNetwork,r=b.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&r&&await b.switchActiveNetwork(r)},async switchActiveNetwork(t){var i;const e=b.state.chains.get(b.state.activeChain),s=!((i=e==null?void 0:e.caipNetworks)!=null&&i.some(n=>{var o;return n.id===((o=z.activeCaipNetwork)==null?void 0:o.id)})),r=b.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&Ge.close()}catch{ne.goBack()}Ue.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})}},getNetworkControllerClient(t){const e=t||z.activeChain,s=z.chains.get(e);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(t){const e=t||z.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=z.chains.get(e);if(!(s!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(t,e){var i;let s=z.activeChain;if(e&&(s=e),!s)return;const r=(i=z.chains.get(s))==null?void 0:i.accountState;if(r)return r[t]},getNetworkProp(t,e){var r;const s=(r=z.chains.get(e))==null?void 0:r.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=z.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:r=[]}=(e==null?void 0:e.networkState)||{};return te.sortRequestedNetworks(s,r)},getAllRequestedCaipNetworks(){const t=[];return z.chains.forEach(e=>{const s=b.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){b.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=b.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));H.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return z.chains.forEach(e=>{const s=b.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(){return z.activeCaipNetwork},getActiveCaipAddress(){return z.activeCaipAddress},getApprovedCaipNetworkIds(t){var r;const e=z.chains.get(t);return((r=e==null?void 0:e.networkState)==null?void 0:r.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(t){const e=b.getNetworkControllerClient(),s=await(e==null?void 0:e.getApprovedCaipNetworksData());b.setAdapterNetworkState(t,{approvedCaipNetworkIds:s==null?void 0:s.approvedCaipNetworkIds,supportsAllNetworks:s==null?void 0:s.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||z.activeCaipNetwork,r=b.getRequestedCaipNetworks(t);return r.length?r==null?void 0:r.some(i=>i.id===(s==null?void 0:s.id)):!0},checkIfSupportedChainId(t){if(!z.activeChain)return!0;const e=b.getRequestedCaipNetworks(z.activeChain);return e==null?void 0:e.some(s=>s.id===t)},setSmartAccountEnabledNetworks(t,e){b.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){var r;const t=xh.caipNetworkIdToNumber((r=z.activeCaipNetwork)==null?void 0:r.caipNetworkId),e=z.activeChain;if(!e||!t)return!1;const s=b.getNetworkProp("smartAccountEnabledNetworks",e);return!!(s!=null&&s.includes(Number(t)))},getActiveNetworkTokenAddress(){var r,i;const t=((r=z.activeCaipNetwork)==null?void 0:r.chainNamespace)||"eip155",e=((i=z.activeCaipNetwork)==null?void 0:i.id)||1,s=Pe.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){Ge.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=z.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Pe.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){b.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(t){const e=t;if(!e)throw new Error("Chain is required to set account prop");z.activeCaipAddress=void 0,b.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountTypes:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),H.removeConnectorId(e)},setIsSwitchingNamespace(t){z.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,r;const t=[];let e;if(z.chains.forEach(i=>{K.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===i.namespace)&&i.namespace&&t.push(i.namespace)}),t.length>0){const i=t[0];return e=i?(r=(s=z.chains.get(i))==null?void 0:s.caipNetworks)==null?void 0:r[0]:void 0,e}},getAccountData(t){var e;return t?(e=b.state.chains.get(t))==null?void 0:e.accountState:V.state},getNetworkData(t){var s;const e=t||z.activeChain;if(e)return(s=b.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var i,n,o;if(!t)return;const s=b.state.chains.get(t),r=(i=s==null?void 0:s.caipNetworks)==null?void 0:i.find(a=>a.id===e);return r||((n=s==null?void 0:s.networkState)==null?void 0:n.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=H.state.filterByNamespace;return(t?[z.chains.get(t)]:Array.from(z.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?b.getRequestedCaipNetworks(t):b.getAllRequestedCaipNetworks()}},b=kt(Vf),Kf={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},Bh=te.getBlockchainApiUrl(),pt=xe({clientId:null,api:new En({baseUrl:Bh,clientId:null}),supportedChains:{http:[],ws:[]}}),Q={state:pt,async get(t){const{st:e,sv:s}=Q.getSdkProperties(),r=B.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return pt.api.get({...t,params:i})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=B.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{pt.supportedChains.http.length||await Q.getSupportedNetworks()}catch{return!1}return pt.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await Q.get({path:"v1/supported-chains"});return pt.supportedChains=t,t}catch{return pt.supportedChains}},async fetchIdentity({address:t,caipNetworkId:e}){if(!await Q.isNetworkSupported(e))return{avatar:"",name:""};const r=W.getIdentityFromCacheForAddress(t);if(r)return r;const i=await Q.get({path:`/v1/identity/${t}`,params:{sender:b.state.activeCaipAddress?te.getPlainAddress(b.state.activeCaipAddress):void 0}});return W.updateIdentityCache({address:t,identity:i,timestamp:Date.now()}),i},async fetchTransactions({account:t,cursor:e,onramp:s,signal:r,cache:i,chainId:n}){var a;return await Q.isNetworkSupported((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?Q.get({path:`/v1/account/${t}/history`,params:{cursor:e,onramp:s,chainId:n},signal:r,cache:i}):{data:[],next:void 0}},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:r,gasPrice:i}){var o;return await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?Q.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:r,gasPrice:i}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?pt.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:B.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var r;return await Q.isNetworkSupported((r=b.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?Q.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var i;const{st:e,sv:s}=Q.getSdkProperties();if(!await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId))throw new Error("Network not supported for Gas Price");return Q.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:r,disableEstimate:i}){var o;if(!await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return pt.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Pe.CONVERT_SLIPPAGE_TOLERANCE},projectId:B.state.projectId,from:e,to:s,userAddress:r,disableEstimate:i}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:r,sv:i}=Q.getSdkProperties();if(!await Q.isNetworkSupported((o=b.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return Q.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:r,sv:i}})},async getBalance(t,e,s){var l;const{st:r,sv:i}=Q.getSdkProperties();if(!await Q.isNetworkSupported((l=b.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return Yt.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=W.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await Q.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:r,sv:i}});return W.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/reverse/${t}`,params:{sender:V.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:r}){var n;return await Q.isNetworkSupported((n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?pt.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:r},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:r,paymentAmount:i}){var a;return await Q.isNetworkSupported((a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await pt.api.post({path:"/v1/generators/onrampurl",params:{projectId:B.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:i}})).url:""},async getOnrampOptions(){var e;if(!await Q.isNetworkSupported((e=b.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await Q.get({path:"/v1/onramp/options"})}catch{return Kf}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){var i;try{return await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?await pt.api.post({path:"/v1/onramp/quote",params:{projectId:B.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}}):null}catch{return{coinbaseFee:{amount:s,currency:e.id},networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await Q.isNetworkSupported((s=b.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?Q.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var i;return await Q.isNetworkSupported((i=b.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?pt.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:B.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){pt.clientId=t,pt.api=new En({baseUrl:Bh,clientId:t})}},Rt=xe({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),Gf={state:Rt,replaceState(t){t&&Object.assign(Rt,cr(t))},subscribe(t){return b.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return b.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){b.setAccountProp("status",t,e)},getCaipAddress(t){return b.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?te.getPlainAddress(t):void 0;e===b.state.activeChain&&(b.state.activeCaipAddress=t),b.setAccountProp("caipAddress",t,e),b.setAccountProp("address",s,e)},setBalance(t,e,s){b.setAccountProp("balance",t,s),b.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){b.setAccountProp("profileName",t,e)},setProfileImage(t,e){b.setAccountProp("profileImage",t,e)},setUser(t,e){b.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){b.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){b.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){b.setAccountProp("currentTab",t,b.state.activeChain)},setTokenBalance(t,e){t&&b.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){b.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){b.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=b.getAccountProp("addressLabels",s)||new Map;r.set(t,e),b.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=b.getAccountProp("addressLabels",e)||new Map;s.delete(t),b.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){b.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){b.setAccountProp("preferredAccountTypes",{...Rt.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){Rt.preferredAccountTypes=t},setSocialProvider(t,e){t&&b.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){b.setAccountProp("socialWindow",t?cr(t):void 0,e)},setFarcasterUrl(t,e){b.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){var n,o;Rt.balanceLoading=!0;const e=(n=b.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=b.state.activeCaipAddress,i=r?te.getPlainAddress(r):void 0;if(Rt.lastRetry&&!te.isAllowedRetry(Rt.lastRetry,30*Pe.ONE_SEC_MS))return Rt.balanceLoading=!1,[];try{if(i&&e&&s){const c=(await Q.getBalance(i,e)).balances.filter(l=>l.quantity.decimals!=="0");return V.setTokenBalance(c,s),Rt.lastRetry=void 0,Rt.balanceLoading=!1,c}}catch(a){Rt.lastRetry=Date.now(),t==null||t(a),Yt.showError("Token Balance Unavailable")}finally{Rt.balanceLoading=!1}return[]},resetAccount(t){b.resetAccount(t)}},V=kt(Gf),Jf={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=b.state.activeCaipNetwork,r=ne.state.data;if(t.id===(s==null?void 0:s.id))return;const n=V.getCaipAddress(b.state.activeChain),o=t.chainNamespace!==b.state.activeChain,a=V.getCaipAddress(t.chainNamespace),l=H.getConnectorId(b.state.activeChain)===K.CONNECTOR_ID.AUTH,u=K.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(h=>h===t.chainNamespace);e||l&&u?ne.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?ne.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ne.push("SwitchNetwork",{...r,network:t})}},ft=xe({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Yf={state:ft,subscribe(t){return nt(ft,()=>t(ft))},subscribeKey(t,e){return ot(ft,t,e)},async open(t){var o,a;const e=V.state.status==="connected",s=t==null?void 0:t.namespace,r=b.state.activeChain,i=s&&s!==r,n=(o=b.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress;if(ee.state.wcBasic?J.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await J.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),H.setFilterByNamespace(t==null?void 0:t.namespace),Ge.setLoading(!0,s),s&&i){const c=((a=b.getNetworkData(s))==null?void 0:a.caipNetwork)||b.getRequestedCaipNetworks(s)[0];c&&Jf.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0})}else{const c=b.state.noAdapters;B.state.manualWCControl||c&&!n?te.isMobile()?ne.reset("AllWallets"):ne.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?ne.reset(t.view,t.data):n?ne.reset("Account"):ne.reset("Connect")}ft.open=!0,Us.set({open:!0}),Ue.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=B.state.enableEmbedded,e=!!b.state.activeCaipAddress;ft.open&&Ue.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),ft.open=!1,ne.reset("Connect"),Ge.clearLoading(),t?e?ne.replace("Account"):ne.push("Connect"):Us.set({open:!1}),ee.resetUri()},setLoading(t,e){e&&ft.loadingNamespaceMap.set(e,t),ft.loading=t,Us.set({loading:t})},clearLoading(){ft.loadingNamespaceMap.clear(),ft.loading=!1},shake(){ft.shake||(ft.shake=!0,setTimeout(()=>{ft.shake=!1},500))}},Ge=kt(Yf),Yi={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"}]},$a={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},Zf={providers:Uh,selectedProvider:null,error:null,purchaseCurrency:Yi,paymentCurrency:$a,purchaseCurrencies:[Yi],paymentCurrencies:[],quotesLoading:!1},de=xe(Zf),Xf={state:de,subscribe(t){return nt(de,()=>t(de))},subscribeKey(t,e){return ot(de,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=b.state.activeChain===K.CHAIN.SOLANA?"SOL":"USDC",s=V.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",If),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",B.state.projectId),de.selectedProvider={...t,url:r.toString()}}else de.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=Uh.filter(r=>e.includes(r.name));de.providers=s}else de.providers=[]},setPurchaseCurrency(t){de.purchaseCurrency=t},setPaymentCurrency(t){de.paymentCurrency=t},setPurchaseAmount(t){Ta.state.purchaseAmount=t},setPaymentAmount(t){Ta.state.paymentAmount=t},async getAvailableCurrencies(){const t=await Q.getOnrampOptions();de.purchaseCurrencies=t.purchaseCurrencies,de.paymentCurrencies=t.paymentCurrencies,de.paymentCurrency=t.paymentCurrencies[0]||$a,de.purchaseCurrency=t.purchaseCurrencies[0]||Yi,await J.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await J.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;de.quotesLoading=!0;try{const s=await Q.getOnrampQuote({purchaseCurrency:de.purchaseCurrency,paymentCurrency:de.paymentCurrency,amount:((t=de.paymentAmount)==null?void 0:t.toString())||"0",network:(e=de.purchaseCurrency)==null?void 0:e.symbol});return de.quotesLoading=!1,de.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return de.error=s.message,de.quotesLoading=!1,null}finally{de.quotesLoading=!1}},resetState(){de.selectedProvider=null,de.error=null,de.purchaseCurrency=Yi,de.paymentCurrency=$a,de.purchaseCurrencies=[Yi],de.paymentCurrencies=[],de.paymentAmount=void 0,de.purchaseAmount=void 0,de.quotesLoading=!1}},Ta=kt(Xf),el=2147483648,Qf={convertEVMChainIdToCoinType(t){if(t>=el)throw new Error("Invalid chainId");return(el|t)>>>0}},Ut=xe({suggestions:[],loading:!1}),eg={state:Ut,subscribe(t){return nt(Ut,()=>t(Ut))},subscribeKey(t,e){return ot(Ut,t,e)},async resolveName(t){var e,s;try{return await Q.lookupEnsName(t)}catch(r){const i=r;throw new Error(((s=(e=i==null?void 0:i.reasons)==null?void 0:e[0])==null?void 0:s.description)||"Error resolving name")}},async isNameRegistered(t){try{return await Q.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{Ut.loading=!0,Ut.suggestions=[];const e=await Q.getEnsNameSuggestions(t);return Ut.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],Ut.suggestions}catch(e){const s=Zi.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Ut.loading=!1}},async getNamesForAddress(t){try{if(!b.state.activeCaipNetwork)return[];const s=W.getEnsFromCacheForAddress(t);if(s)return s;const r=await Q.reverseLookupEnsName({address:t});return W.updateEnsCache({address:t,ens:r,timestamp:Date.now()}),r}catch(e){const s=Zi.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=b.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const s=V.state.address,r=H.getAuthConnector();if(!s||!r)throw new Error("Address or auth connector not found");Ut.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});ne.pushTransactionStack({onCancel(){ne.replace("RegisterAccountName")}});const n=await ee.signMessage(i);Ut.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=Qf.convertEVMChainIdToCoinType(Number(o));await Q.registerEnsName({coinType:a,address:s,signature:n,message:i}),V.setProfileName(t,e.chainNamespace),ne.replace("RegisterAccountNameSuccess")}catch(i){const n=Zi.parseEnsApiError(i,`Error registering name ${t}`);throw ne.replace("RegisterAccountName"),new Error(n)}finally{Ut.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){var r,i;const s=t;return((i=(r=s==null?void 0:s.reasons)==null?void 0:r[0])==null?void 0:i.description)||e}},Zi=kt(eg);var tg=Object.defineProperty,sg=(t,e,s)=>e in t?tg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,tl=(t,e,s)=>sg(t,typeof e!="symbol"?e+"":e,s);let rg=class extends bi{constructor(e){super(),this.opts=e,tl(this,"protocol","wc"),tl(this,"version",2)}};var ig=Object.defineProperty,ng=(t,e,s)=>e in t?ig(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,og=(t,e,s)=>ng(t,e+"",s);let ag=class extends bi{constructor(e,s){super(),this.core=e,this.logger=s,og(this,"records",new Map)}},cg=class{constructor(e,s){this.logger=e,this.core=s}},lg=class extends bi{constructor(e,s){super(),this.relayer=e,this.logger=s}},ug=class extends bi{constructor(e){super()}},hg=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},dg=class extends bi{constructor(e,s){super(),this.relayer=e,this.logger=s}},pg=class extends bi{constructor(e,s){super(),this.core=e,this.logger=s}},fg=class{constructor(e,s,r){this.core=e,this.logger=s,this.store=r}},gg=class{constructor(e,s){this.projectId=e,this.logger=s}},mg=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var wg=Object.defineProperty,yg=(t,e,s)=>e in t?wg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,sl=(t,e,s)=>yg(t,typeof e!="symbol"?e+"":e,s);let bg=class{constructor(e){this.opts=e,sl(this,"protocol","wc"),sl(this,"version",2)}},vg=class{constructor(e){this.client=e}};var Eg={};const Cg="ReactNative",Zt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Ig="js";function no(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function br(){return!$t.getDocument()&&!!$t.getNavigator()&&navigator.product===Cg}function Ag(){return br()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Ng(){return br()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Cn(){return!no()&&!!$t.getNavigator()&&!!$t.getDocument()}function wo(){return br()?Zt.reactNative:no()?Zt.node:Cn()?Zt.browser:Zt.unknown}function rl(){var t;try{return br()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function _g(t,e){const s=new URLSearchParams(t);for(const r of Object.keys(e).sort())if(e.hasOwnProperty(r)){const i=e[r];i!==void 0&&s.set(r,i)}return s.toString()}function Sg(){return Ph.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function Pg(){if(wo()===Zt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:r}=global.Platform;return[s,r].join("-")}const t=Yp();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Og(){var t;const e=wo();return e===Zt.browser?[e,((t=$t.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function Mh(t,e,s){const r=Pg(),i=Og();return[[t,e].join("-"),[Ig,s].join("-"),r,i].join("/")}function $g({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=Mh(t,e,r),h={auth:i,ua:u,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=_g(l[1]||"",h);return l[0]+"?"+d}function xa(t){return Object.fromEntries(t.entries())}function ka(t){return new Map(Object.entries(t))}function Tg(t=q.FIVE_MINUTES,e){const s=q.toMiliseconds(t||q.FIVE_MINUTES);let r,i,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&i&&(clearTimeout(n),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),r=a,i=c})}}function Rs(t,e,s){return new Promise(async(r,i)=>{const n=setTimeout(()=>i(new Error(s)),e);try{const o=await t;r(o)}catch(o){i(o)}clearTimeout(n)})}function qh(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function xg(t){return qh("topic",t)}function kg(t){return qh("id",t)}function Rg(t){const[e,s]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")r.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))r.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return r}function Xi(t,e){return q.fromMiliseconds(Date.now()+q.toMiliseconds(t))}function il(t){return Date.now()>=q.toMiliseconds(t)}function Mo(t,e){return`${t}${e?`:${e}`:""}`}function nl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function jh(){return typeof process<"u"&&Eg.IS_VITEST==="true"}function Fh(t){return Buffer.from(t,"base64").toString("utf-8")}function Ug(t){return new Promise(e=>setTimeout(e,t))}function cn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Dg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function In(t,...e){if(!Dg(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Cc(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");cn(t.outputLen),cn(t.blockLen)}function ii(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function zh(t,e){In(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Rn=BigInt(2**32-1),ol=BigInt(32);function Lg(t,e=!1){return e?{h:Number(t&Rn),l:Number(t>>ol&Rn)}:{h:Number(t>>ol&Rn)|0,l:Number(t&Rn)|0}}function Bg(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=Lg(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Mg=(t,e,s)=>t<<s|e>>>32-s,qg=(t,e,s)=>e<<s|t>>>32-s,jg=(t,e,s)=>e<<s-32|t>>>64-s,Fg=(t,e,s)=>t<<s-32|e>>>64-s,Ir=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function zg(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function qo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Qt(t,e){return t<<32-e|t>>>e}const al=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function cl(t){for(let e=0;e<t.length;e++)t[e]=Hg(t[e])}function Wg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ni(t){return typeof t=="string"&&(t=Wg(t)),In(t),t}function Vg(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];In(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let Ic=class{clone(){return this._cloneInto()}};function Hh(t){const e=r=>t().update(ni(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Ei(t=32){if(Ir&&typeof Ir.getRandomValues=="function")return Ir.getRandomValues(new Uint8Array(t));if(Ir&&typeof Ir.randomBytes=="function")return Ir.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Wh=[],Vh=[],Kh=[],Kg=BigInt(0),$i=BigInt(1),Gg=BigInt(2),Jg=BigInt(7),Yg=BigInt(256),Zg=BigInt(113);for(let t=0,e=$i,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Wh.push(2*(5*r+s)),Vh.push((t+1)*(t+2)/2%64);let i=Kg;for(let n=0;n<7;n++)e=(e<<$i^(e>>Jg)*Zg)%Yg,e&Gg&&(i^=$i<<($i<<BigInt(n))-$i);Kh.push(i)}const[Xg,Qg]=Bg(Kh,!0),ll=(t,e,s)=>s>32?jg(t,e,s):Mg(t,e,s),ul=(t,e,s)=>s>32?Fg(t,e,s):qg(t,e,s);function em(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=ll(l,u,1)^s[a],d=ul(l,u,1)^s[a+1];for(let f=0;f<50;f+=10)t[o+f]^=h,t[o+f+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Vh[o],c=ll(i,n,a),l=ul(i,n,a),u=Wh[o];i=t[u],n=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=Xg[r],t[1]^=Qg[r]}s.fill(0)}let tm=class Gh extends Ic{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,cn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=zg(this.state)}keccak(){al||cl(this.state32),em(this.state32,this.rounds),al||cl(this.state32),this.posOut=0,this.pos=0}update(e){ii(this);const{blockLen:s,state:r}=this;e=ni(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,(s&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ii(this,!1),In(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return cn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(zh(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new Gh(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const sm=(t,e,s)=>Hh(()=>new tm(e,t,s));sm(1,136,256/8);function jo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Jh(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pt(t,...e){if(!Jh(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function hl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function rm(t,e){Pt(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function dl(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ds=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),im=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),nm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!nm)throw new Error("Non little-endian hardware is not supported");function om(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ra(t){if(typeof t=="string")t=om(t);else if(Jh(t))t=Ua(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function am(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function cm(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}const lm=(t,e)=>{function s(r,...i){if(Pt(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?Pt(l):Pt(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&Pt(i[1]);const o=e(r,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");Pt(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Pt(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(Pt(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(s,t),s};function pl(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!um(e))throw new Error("invalid output, must be aligned");return e}function fl(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n);t.setUint32(e+4,o,r),t.setUint32(e+0,a,r)}function um(t){return t.byteOffset%4===0}function Ua(t){return Uint8Array.from(t)}function oi(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Yh=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),hm=Yh("expand 16-byte k"),dm=Yh("expand 32-byte k"),pm=Ds(hm),fm=Ds(dm);function fe(t,e){return t<<e|t>>>32-e}function Da(t){return t.byteOffset%4===0}const Un=64,gm=16,Zh=2**32-1,gl=new Uint32Array;function mm(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(Un),u=Ds(l),h=Da(i)&&Da(n),d=h?Ds(i):gl,f=h?Ds(n):gl;for(let y=0;y<c;o++){if(t(e,s,r,u,o,a),o>=Zh)throw new Error("arx: counter overflow");const g=Math.min(Un,c-y);if(h&&g===Un){const p=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let m=0,w;m<gm;m++)w=p+m,f[w]=d[w]^u[m];y+=Un;continue}for(let p=0,m;p<g;p++)m=y+p,n[m]=i[m]^l[p];y+=g}}function wm(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=am({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return jo(i),jo(o),dl(n),dl(s),(a,c,l,u,h=0)=>{Pt(a),Pt(c),Pt(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),Pt(u),jo(h),h<0||h>=Zh)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const f=[];let y=a.length,g,p;if(y===32)f.push(g=Ua(a)),p=fm;else if(y===16&&s)g=new Uint8Array(32),g.set(a),g.set(a,16),p=pm,f.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);Da(c)||f.push(c=Ua(c));const m=Ds(g);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,Ds(c.subarray(0,16)),m),c=c.subarray(16)}const w=16-i;if(w!==c.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const P=new Uint8Array(12);P.set(c,n?0:12-c.length),c=P,f.push(c)}const C=Ds(c);return mm(t,p,m,C,l,u,h,o),oi(...f),u}}const Xe=(t,e)=>t[e++]&255|(t[e++]&255)<<8;let ym=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Ra(e),Pt(e,32);const s=Xe(e,0),r=Xe(e,2),i=Xe(e,4),n=Xe(e,6),o=Xe(e,8),a=Xe(e,10),c=Xe(e,12),l=Xe(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Xe(e,16+2*u)}process(e,s,r=!1){const i=r?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],f=o[6],y=o[7],g=o[8],p=o[9],m=Xe(e,s+0),w=Xe(e,s+2),C=Xe(e,s+4),P=Xe(e,s+6),R=Xe(e,s+8),O=Xe(e,s+10),S=Xe(e,s+12),$=Xe(e,s+14);let v=n[0]+(m&8191),T=n[1]+((m>>>13|w<<3)&8191),_=n[2]+((w>>>10|C<<6)&8191),k=n[3]+((C>>>7|P<<9)&8191),L=n[4]+((P>>>4|R<<12)&8191),E=n[5]+(R>>>1&8191),A=n[6]+((R>>>14|O<<2)&8191),I=n[7]+((O>>>11|S<<5)&8191),x=n[8]+((S>>>8|$<<8)&8191),U=n[9]+($>>>5|i),N=0,M=N+v*a+T*(5*p)+_*(5*g)+k*(5*y)+L*(5*f);N=M>>>13,M&=8191,M+=E*(5*d)+A*(5*h)+I*(5*u)+x*(5*l)+U*(5*c),N+=M>>>13,M&=8191;let j=N+v*c+T*a+_*(5*p)+k*(5*g)+L*(5*y);N=j>>>13,j&=8191,j+=E*(5*f)+A*(5*d)+I*(5*h)+x*(5*u)+U*(5*l),N+=j>>>13,j&=8191;let F=N+v*l+T*c+_*a+k*(5*p)+L*(5*g);N=F>>>13,F&=8191,F+=E*(5*y)+A*(5*f)+I*(5*d)+x*(5*h)+U*(5*u),N+=F>>>13,F&=8191;let X=N+v*u+T*l+_*c+k*a+L*(5*p);N=X>>>13,X&=8191,X+=E*(5*g)+A*(5*y)+I*(5*f)+x*(5*d)+U*(5*h),N+=X>>>13,X&=8191;let G=N+v*h+T*u+_*l+k*c+L*a;N=G>>>13,G&=8191,G+=E*(5*p)+A*(5*g)+I*(5*y)+x*(5*f)+U*(5*d),N+=G>>>13,G&=8191;let oe=N+v*d+T*h+_*u+k*l+L*c;N=oe>>>13,oe&=8191,oe+=E*a+A*(5*p)+I*(5*g)+x*(5*y)+U*(5*f),N+=oe>>>13,oe&=8191;let le=N+v*f+T*d+_*h+k*u+L*l;N=le>>>13,le&=8191,le+=E*c+A*a+I*(5*p)+x*(5*g)+U*(5*y),N+=le>>>13,le&=8191;let Ie=N+v*y+T*f+_*d+k*h+L*u;N=Ie>>>13,Ie&=8191,Ie+=E*l+A*c+I*a+x*(5*p)+U*(5*g),N+=Ie>>>13,Ie&=8191;let ue=N+v*g+T*y+_*f+k*d+L*h;N=ue>>>13,ue&=8191,ue+=E*u+A*l+I*c+x*a+U*(5*p),N+=ue>>>13,ue&=8191;let he=N+v*p+T*g+_*y+k*f+L*d;N=he>>>13,he&=8191,he+=E*h+A*u+I*l+x*c+U*a,N+=he>>>13,he&=8191,N=(N<<2)+N|0,N=N+M|0,M=N&8191,N=N>>>13,j+=N,n[0]=M,n[1]=j,n[2]=F,n[3]=X,n[4]=G,n[5]=oe,n[6]=le,n[7]=Ie,n[8]=ue,n[9]=he}finalize(){const{h:e,pad:s}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let n=(i^1)-1;for(let a=0;a<10;a++)r[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|r[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;oi(r)}update(e){hl(this);const{buffer:s,blockLen:r}=this;e=Ra(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){oi(this.h,this.r,this.buffer,this.pad)}digestInto(e){hl(this),rm(e,this),this.finished=!0;const{buffer:s,h:r}=this;let{pos:i}=this;if(i){for(s[i++]=1;i<16;i++)s[i]=0;this.process(s,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}};function bm(t){const e=(r,i)=>t(i).update(Ra(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const vm=bm(t=>new ym(t));function Em(t,e,s,r,i,n=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],f=e[3],y=e[4],g=e[5],p=e[6],m=e[7],w=i,C=s[0],P=s[1],R=s[2],O=o,S=a,$=c,v=l,T=u,_=h,k=d,L=f,E=y,A=g,I=p,x=m,U=w,N=C,M=P,j=R;for(let X=0;X<n;X+=2)O=O+T|0,U=fe(U^O,16),E=E+U|0,T=fe(T^E,12),O=O+T|0,U=fe(U^O,8),E=E+U|0,T=fe(T^E,7),S=S+_|0,N=fe(N^S,16),A=A+N|0,_=fe(_^A,12),S=S+_|0,N=fe(N^S,8),A=A+N|0,_=fe(_^A,7),$=$+k|0,M=fe(M^$,16),I=I+M|0,k=fe(k^I,12),$=$+k|0,M=fe(M^$,8),I=I+M|0,k=fe(k^I,7),v=v+L|0,j=fe(j^v,16),x=x+j|0,L=fe(L^x,12),v=v+L|0,j=fe(j^v,8),x=x+j|0,L=fe(L^x,7),O=O+_|0,j=fe(j^O,16),I=I+j|0,_=fe(_^I,12),O=O+_|0,j=fe(j^O,8),I=I+j|0,_=fe(_^I,7),S=S+k|0,U=fe(U^S,16),x=x+U|0,k=fe(k^x,12),S=S+k|0,U=fe(U^S,8),x=x+U|0,k=fe(k^x,7),$=$+L|0,N=fe(N^$,16),E=E+N|0,L=fe(L^E,12),$=$+L|0,N=fe(N^$,8),E=E+N|0,L=fe(L^E,7),v=v+T|0,M=fe(M^v,16),A=A+M|0,T=fe(T^A,12),v=v+T|0,M=fe(M^v,8),A=A+M|0,T=fe(T^A,7);let F=0;r[F++]=o+O|0,r[F++]=a+S|0,r[F++]=c+$|0,r[F++]=l+v|0,r[F++]=u+T|0,r[F++]=h+_|0,r[F++]=d+k|0,r[F++]=f+L|0,r[F++]=y+E|0,r[F++]=g+A|0,r[F++]=p+I|0,r[F++]=m+x|0,r[F++]=w+U|0,r[F++]=C+N|0,r[F++]=P+M|0,r[F++]=R+j|0}const Cm=wm(Em,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Im=new Uint8Array(16),ml=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(Im.subarray(s))},Am=new Uint8Array(32);function wl(t,e,s,r,i){const n=t(e,s,Am),o=vm.create(n);i&&ml(o,i),ml(o,r);const a=new Uint8Array(16),c=im(a);fl(c,0,BigInt(i?i.length:0),!0),fl(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return oi(n,a),l}const Nm=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=pl(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=wl(t,e,s,a,r);return n.set(c,o),oi(c),n},decrypt(i,n){n=pl(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=wl(t,e,s,o,r);if(!cm(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),oi(c),n}}),Xh=lm({blockSize:64,nonceLength:12,tagLength:16},Nm(Cm));let Qh=class extends Ic{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,Cc(e);const r=ni(s);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return ii(this),this.iHash.update(e),this}digestInto(e){ii(this),In(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const yo=(t,e,s)=>new Qh(t,e).update(s).digest();yo.create=(t,e)=>new Qh(t,e);function _m(t,e,s){return Cc(t),s===void 0&&(s=new Uint8Array(t.outputLen)),yo(t,ni(s),ni(e))}const Fo=new Uint8Array([0]),yl=new Uint8Array;function Sm(t,e,s,r=32){if(Cc(t),cn(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);s===void 0&&(s=yl);const n=new Uint8Array(i*t.outputLen),o=yo.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)Fo[0]=l+1,a.update(l===0?yl:c).update(s).update(Fo).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Fo.fill(0),n.slice(0,r)}const Pm=(t,e,s,r,i)=>Sm(t,_m(t,e,s),r,i);function Om(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function $m(t,e,s){return t&e^~t&s}function Tm(t,e,s){return t&e^t&s^e&s}let xm=class extends Ic{constructor(e,s,r,i){super(),this.blockLen=e,this.outputLen=s,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=qo(this.buffer)}update(e){ii(this);const{view:s,buffer:r,blockLen:i}=this;e=ni(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(i-this.pos,n-o);if(a===i){const c=qo(e);for(;i<=n-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ii(this),zh(e,this),this.finished=!0;const{buffer:s,view:r,blockLen:i,isLE:n}=this;let{pos:o}=this;s[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let h=o;h<i;h++)s[h]=0;Om(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=qo(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],n)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=n,e.destroyed=o,i%s&&e.buffer.set(r),e}};const km=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ss=new Uint32Array(64);let Rm=class extends xm{constructor(){super(64,32,8,!1),this.A=_s[0]|0,this.B=_s[1]|0,this.C=_s[2]|0,this.D=_s[3]|0,this.E=_s[4]|0,this.F=_s[5]|0,this.G=_s[6]|0,this.H=_s[7]|0}get(){const{A:e,B:s,C:r,D:i,E:n,F:o,G:a,H:c}=this;return[e,s,r,i,n,o,a,c]}set(e,s,r,i,n,o,a,c){this.A=e|0,this.B=s|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let h=0;h<16;h++,s+=4)Ss[h]=e.getUint32(s,!1);for(let h=16;h<64;h++){const d=Ss[h-15],f=Ss[h-2],y=Qt(d,7)^Qt(d,18)^d>>>3,g=Qt(f,17)^Qt(f,19)^f>>>10;Ss[h]=g+Ss[h-7]+y+Ss[h-16]|0}let{A:r,B:i,C:n,D:o,E:a,F:c,G:l,H:u}=this;for(let h=0;h<64;h++){const d=Qt(a,6)^Qt(a,11)^Qt(a,25),f=u+d+$m(a,c,l)+km[h]+Ss[h]|0,y=(Qt(r,2)^Qt(r,13)^Qt(r,22))+Tm(r,i,n)|0;u=l,l=c,c=a,a=o+f|0,o=n,n=i,i=r,r=f+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,n,o,a,c,l,u)}roundClean(){Ss.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const An=Hh(()=>new Rm);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const bo=BigInt(0),vo=BigInt(1),Um=BigInt(2);function lr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Nn(t){if(!lr(t))throw new Error("Uint8Array expected")}function ai(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Dm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ci(t){Nn(t);let e="";for(let s=0;s<t.length;s++)e+=Dm[t[s]];return e}function Jr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Ac(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?bo:BigInt("0x"+t)}const hs={_0:48,_9:57,A:65,F:70,a:97,f:102};function bl(t){if(t>=hs._0&&t<=hs._9)return t-hs._0;if(t>=hs.A&&t<=hs.F)return t-(hs.A-10);if(t>=hs.a&&t<=hs.f)return t-(hs.a-10)}function li(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(s);for(let i=0,n=0;i<s;i++,n+=2){const o=bl(t.charCodeAt(n)),a=bl(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[i]=o*16+a}return r}function rr(t){return Ac(ci(t))}function ln(t){return Nn(t),Ac(ci(Uint8Array.from(t).reverse()))}function ui(t,e){return li(t.toString(16).padStart(e*2,"0"))}function Eo(t,e){return ui(t,e).reverse()}function Lm(t){return li(Jr(t))}function _t(t,e,s){let r;if(typeof e=="string")try{r=li(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(lr(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return r}function un(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Nn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}function Bm(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}function Mm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const zo=t=>typeof t=="bigint"&&bo<=t;function Co(t,e,s){return zo(t)&&zo(e)&&zo(s)&&e<=t&&t<s}function vs(t,e,s,r){if(!Co(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function ed(t){let e;for(e=0;t>bo;t>>=vo,e+=1);return e}function qm(t,e){return t>>BigInt(e)&vo}function jm(t,e,s){return t|(s?vo:bo)<<BigInt(e)}const Nc=t=>(Um<<BigInt(t-1))-vo,Ho=t=>new Uint8Array(t),vl=t=>Uint8Array.from(t);function td(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");let r=Ho(t),i=Ho(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=Ho())=>{i=a(vl([0]),u),r=a(),u.length!==0&&(i=a(vl([1]),u),r=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u<e;){r=a();const d=r.slice();h.push(d),u+=r.length}return un(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const Fm={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||lr(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ci(t,e,s={}){const r=(i,n,o)=>{const a=Fm[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+n+", got "+c)};for(const[i,n]of Object.entries(e))r(i,n,!1);for(const[i,n]of Object.entries(s))r(i,n,!0);return t}const zm=()=>{throw new Error("not implemented")};function La(t){const e=new WeakMap;return(s,...r)=>{const i=e.get(s);if(i!==void 0)return i;const n=t(s,...r);return e.set(s,n),n}}var Hm=Object.freeze({__proto__:null,isBytes:lr,abytes:Nn,abool:ai,bytesToHex:ci,numberToHexUnpadded:Jr,hexToNumber:Ac,hexToBytes:li,bytesToNumberBE:rr,bytesToNumberLE:ln,numberToBytesBE:ui,numberToBytesLE:Eo,numberToVarBytesBE:Lm,ensureBytes:_t,concatBytes:un,equalBytes:Bm,utf8ToBytes:Mm,inRange:Co,aInRange:vs,bitLen:ed,bitGet:qm,bitSet:jm,bitMask:Nc,createHmacDrbg:td,validateObject:Ci,notImplemented:zm,memoized:La});const Je=BigInt(0),De=BigInt(1),Ys=BigInt(2),Wm=BigInt(3),Ba=BigInt(4),El=BigInt(5),Cl=BigInt(8);function yt(t,e){const s=t%e;return s>=Je?s:e+s}function sd(t,e,s){if(e<Je)throw new Error("invalid exponent, negatives unsupported");if(s<=Je)throw new Error("invalid modulus");if(s===De)return Je;let r=De;for(;e>Je;)e&De&&(r=r*t%s),t=t*t%s,e>>=De;return r}function Kt(t,e,s){let r=t;for(;e-- >Je;)r*=r,r%=s;return r}function Ma(t,e){if(t===Je)throw new Error("invert: expected non-zero number");if(e<=Je)throw new Error("invert: expected positive modulus, got "+e);let s=yt(t,e),r=e,i=Je,n=De;for(;s!==Je;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==De)throw new Error("invert: does not exist");return yt(i,e)}function Vm(t){const e=(t-De)/Ys;let s,r,i;for(s=t-De,r=0;s%Ys===Je;s/=Ys,r++);for(i=Ys;i<t&&sd(i,e,t)!==t-De;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+De)/Ba;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const n=(s+De)/Ys;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,l=o.pow(o.mul(o.ONE,i),s),u=o.pow(a,n),h=o.pow(a,s);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let y=o.sqr(h);d<c&&!o.eql(y,o.ONE);d++)y=o.sqr(y);const f=o.pow(l,De<<BigInt(c-d-1));l=o.sqr(f),u=o.mul(u,f),h=o.mul(h,l),c=d}return u}}function Km(t){if(t%Ba===Wm){const e=(t+De)/Ba;return function(s,r){const i=s.pow(r,e);if(!s.eql(s.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%Cl===El){const e=(t-El)/Cl;return function(s,r){const i=s.mul(r,Ys),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Ys),n),c=s.mul(o,s.sub(a,s.ONE));if(!s.eql(s.sqr(c),r))throw new Error("Cannot find square root");return c}}return Vm(t)}const Gm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Jm(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=Gm.reduce((r,i)=>(r[i]="function",r),e);return Ci(t,s)}function Ym(t,e,s){if(s<Je)throw new Error("invalid exponent, negatives unsupported");if(s===Je)return t.ONE;if(s===De)return e;let r=t.ONE,i=e;for(;s>Je;)s&De&&(r=t.mul(r,i)),i=t.sqr(i),s>>=De;return r}function Zm(t,e){const s=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(s[a]=n,t.mul(n,o)),t.ONE),i=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(s[a]=t.mul(n,s[a]),t.mul(n,o)),i),s}function rd(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function id(t,e,s=!1,r={}){if(t<=Je)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=rd(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:n,MASK:Nc(i),ZERO:Je,ONE:De,create:c=>yt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Je<=c&&c<t},is0:c=>c===Je,isOdd:c=>(c&De)===De,neg:c=>yt(-c,t),eql:(c,l)=>c===l,sqr:c=>yt(c*c,t),add:(c,l)=>yt(c+l,t),sub:(c,l)=>yt(c-l,t),mul:(c,l)=>yt(c*l,t),pow:(c,l)=>Ym(a,c,l),div:(c,l)=>yt(c*Ma(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ma(c,t),sqrt:r.sqrt||(c=>(o||(o=Km(t)),o(a,c))),invertBatch:c=>Zm(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?Eo(c,n):ui(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?ln(c):rr(c)}});return Object.freeze(a)}function nd(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function od(t){const e=nd(t);return e+Math.ceil(e/2)}function Xm(t,e,s=!1){const r=t.length,i=nd(e),n=od(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?ln(t):rr(t),a=yt(o,e-De)+De;return s?Eo(a,i):ui(a,i)}const Il=BigInt(0),Dn=BigInt(1);function Wo(t,e){const s=e.negate();return t?s:e}function ad(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Vo(t,e){ad(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function Qm(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,r)=>{if(!(s instanceof e))throw new Error("invalid point at index "+r)})}function ew(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,r)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+r)})}const Ko=new WeakMap,cd=new WeakMap;function Go(t){return cd.get(t)||1}function tw(t,e){return{constTimeNegate:Wo,hasPrecomputes(s){return Go(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>Il;)r&Dn&&(i=i.add(n)),n=n.double(),r>>=Dn;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=Vo(r,e),o=[];let a=s,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<n;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,r,i){const{windows:n,windowSize:o}=Vo(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),u=2**s,h=BigInt(s);for(let d=0;d<n;d++){const f=d*o;let y=Number(i&l);i>>=h,y>o&&(y-=u,i+=Dn);const g=f,p=f+Math.abs(y)-1,m=d%2!==0,w=y<0;y===0?c=c.add(Wo(m,r[g])):a=a.add(Wo(w,r[p]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=Vo(s,e),c=BigInt(2**s-1),l=2**s,u=BigInt(s);for(let h=0;h<o;h++){const d=h*a;if(i===Il)break;let f=Number(i&c);if(i>>=u,f>a&&(f-=l,i+=Dn),f===0)continue;let y=r[d+Math.abs(f)-1];f<0&&(y=y.negate()),n=n.add(y)}return n},getPrecomputes(s,r,i){let n=Ko.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&Ko.set(r,i(n))),n},wNAFCached(s,r,i){const n=Go(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=Go(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){ad(r,e),cd.set(s,r),Ko.delete(s)}}}function sw(t,e,s,r){if(Qm(s,t),ew(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=ed(BigInt(s.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let f=0;f<r.length;f++){const y=r[f],g=Number(y>>BigInt(h)&BigInt(a));c[g]=c[g].add(s[f])}let d=i;for(let f=c.length-1,y=i;f>0;f--)y=y.add(c[f]),d=d.add(y);if(u=u.add(d),h!==0)for(let f=0;f<o;f++)u=u.double()}return u}function ld(t){return Jm(t.Fp),Ci(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rd(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Ar=BigInt(0),Jo=BigInt(1);function rw(t){return Ci(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function iw(t){const e=rw(t),{P:s}=e,r=w=>yt(w,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>sd(w,s-BigInt(2),s));function l(w,C,P){const R=r(w*(C-P));return C=r(C-R),P=r(P+R),[C,P]}const u=(e.a-BigInt(2))/BigInt(4);function h(w,C){vs("u",w,Ar,s),vs("scalar",C,Ar,s);const P=C,R=w;let O=Jo,S=Ar,$=w,v=Jo,T=Ar,_;for(let L=BigInt(i-1);L>=Ar;L--){const E=P>>L&Jo;T^=E,_=l(T,O,$),O=_[0],$=_[1],_=l(T,S,v),S=_[0],v=_[1],T=E;const A=O+S,I=r(A*A),x=O-S,U=r(x*x),N=I-U,M=$+v,j=$-v,F=r(j*A),X=r(M*x),G=F+X,oe=F-X;$=r(G*G),v=r(R*r(oe*oe)),O=r(I*U),S=r(N*(I+r(u*N)))}_=l(T,O,$),O=_[0],$=_[1],_=l(T,S,v),S=_[0],v=_[1];const k=c(S);return r(O*k)}function d(w){return Eo(r(w),n)}function f(w){const C=_t("u coordinate",w,n);return o===32&&(C[31]&=127),ln(C)}function y(w){const C=_t("scalar",w),P=C.length;if(P!==n&&P!==o){let R=""+n+" or "+o;throw new Error("invalid scalar, expected "+R+" bytes, got "+P)}return ln(a(C))}function g(w,C){const P=f(C),R=y(w),O=h(P,R);if(O===Ar)throw new Error("invalid private or public key received");return d(O)}const p=d(e.Gu);function m(w){return g(w,p)}return{scalarMult:g,scalarMultBase:m,getSharedSecret:(w,C)=>g(w,C),getPublicKey:w=>m(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:p}}const qa=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const nw=BigInt(1),Al=BigInt(2),ow=BigInt(3),aw=BigInt(5);BigInt(8);function cw(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=qa,o=t*t%n*t%n,a=Kt(o,Al,n)*o%n,c=Kt(a,nw,n)*t%n,l=Kt(c,aw,n)*c%n,u=Kt(l,e,n)*l%n,h=Kt(u,s,n)*u%n,d=Kt(h,r,n)*h%n,f=Kt(d,i,n)*d%n,y=Kt(f,i,n)*d%n,g=Kt(y,e,n)*l%n;return{pow_p_5_8:Kt(g,Al,n)*t%n,b2:o}}function lw(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const ja=iw({P:qa,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=qa,{pow_p_5_8:s,b2:r}=cw(t);return yt(Kt(s,ow,e)*r,e)},adjustScalarBytes:lw,randomBytes:Ei});function Nl(t){t.lowS!==void 0&&ai("lowS",t.lowS),t.prehash!==void 0&&ai("prehash",t.prehash)}function uw(t){const e=ld(t);Ci(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:s,Fp:r,a:i}=e;if(s){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof s!="object"||typeof s.beta!="bigint"||typeof s.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:hw,hexToBytes:dw}=Hm;let pw=class extends Error{constructor(e=""){super(e)}};const ms={Err:pw,_tlv:{encode:(t,e)=>{const{Err:s}=ms;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const r=e.length/2,i=Jr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Jr(i.length/2|128):"";return Jr(t)+n+i+e},decode(t,e){const{Err:s}=ms;let r=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new s("tlv.decode: wrong tlv");const i=e[r++],n=!!(i&128);let o=0;if(!n)o=i;else{const c=i&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(r+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=ms;if(t<ys)throw new e("integer: negative integers are not allowed");let s=Jr(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=ms;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return hw(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=ms,i=typeof t=="string"?dw(t):t;Nn(i);const{v:n,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=ms,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},ys=BigInt(0),ze=BigInt(1);BigInt(2);const _l=BigInt(3);BigInt(4);function fw(t){const e=uw(t),{Fp:s}=e,r=id(e.n,e.nBitLength),i=e.toBytes||((g,p,m)=>{const w=p.toAffine();return un(Uint8Array.from([4]),s.toBytes(w.x),s.toBytes(w.y))}),n=e.fromBytes||(g=>{const p=g.subarray(1),m=s.fromBytes(p.subarray(0,s.BYTES)),w=s.fromBytes(p.subarray(s.BYTES,2*s.BYTES));return{x:m,y:w}});function o(g){const{a:p,b:m}=e,w=s.sqr(g),C=s.mul(w,g);return s.add(s.add(C,s.mul(g,p)),m)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(g){return Co(g,ze,e.n)}function c(g){const{allowedPrivateKeyLengths:p,nByteLength:m,wrapPrivateKey:w,n:C}=e;if(p&&typeof g!="bigint"){if(lr(g)&&(g=ci(g)),typeof g!="string"||!p.includes(g.length))throw new Error("invalid private key");g=g.padStart(m*2,"0")}let P;try{P=typeof g=="bigint"?g:rr(_t("private key",g,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof g)}return w&&(P=yt(P,C)),vs("private key",P,ze,C),P}function l(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}const u=La((g,p)=>{const{px:m,py:w,pz:C}=g;if(s.eql(C,s.ONE))return{x:m,y:w};const P=g.is0();p==null&&(p=P?s.ONE:s.inv(C));const R=s.mul(m,p),O=s.mul(w,p),S=s.mul(C,p);if(P)return{x:s.ZERO,y:s.ZERO};if(!s.eql(S,s.ONE))throw new Error("invZ was invalid");return{x:R,y:O}}),h=La(g=>{if(g.is0()){if(e.allowInfinityPoint&&!s.is0(g.py))return;throw new Error("bad point: ZERO")}const{x:p,y:m}=g.toAffine();if(!s.isValid(p)||!s.isValid(m))throw new Error("bad point: x or y not FE");const w=s.sqr(m),C=o(p);if(!s.eql(w,C))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(p,m,w){if(this.px=p,this.py=m,this.pz=w,p==null||!s.isValid(p))throw new Error("x required");if(m==null||!s.isValid(m))throw new Error("y required");if(w==null||!s.isValid(w))throw new Error("z required");Object.freeze(this)}static fromAffine(p){const{x:m,y:w}=p||{};if(!p||!s.isValid(m)||!s.isValid(w))throw new Error("invalid affine point");if(p instanceof d)throw new Error("projective point not allowed");const C=P=>s.eql(P,s.ZERO);return C(m)&&C(w)?d.ZERO:new d(m,w,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const m=s.invertBatch(p.map(w=>w.pz));return p.map((w,C)=>w.toAffine(m[C])).map(d.fromAffine)}static fromHex(p){const m=d.fromAffine(n(_t("pointHex",p)));return m.assertValidity(),m}static fromPrivateKey(p){return d.BASE.multiply(c(p))}static msm(p,m){return sw(d,r,p,m)}_setWindowSize(p){y.setWindowSize(this,p)}assertValidity(){h(this)}hasEvenY(){const{y:p}=this.toAffine();if(s.isOdd)return!s.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){l(p);const{px:m,py:w,pz:C}=this,{px:P,py:R,pz:O}=p,S=s.eql(s.mul(m,O),s.mul(P,C)),$=s.eql(s.mul(w,O),s.mul(R,C));return S&&$}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:p,b:m}=e,w=s.mul(m,_l),{px:C,py:P,pz:R}=this;let O=s.ZERO,S=s.ZERO,$=s.ZERO,v=s.mul(C,C),T=s.mul(P,P),_=s.mul(R,R),k=s.mul(C,P);return k=s.add(k,k),$=s.mul(C,R),$=s.add($,$),O=s.mul(p,$),S=s.mul(w,_),S=s.add(O,S),O=s.sub(T,S),S=s.add(T,S),S=s.mul(O,S),O=s.mul(k,O),$=s.mul(w,$),_=s.mul(p,_),k=s.sub(v,_),k=s.mul(p,k),k=s.add(k,$),$=s.add(v,v),v=s.add($,v),v=s.add(v,_),v=s.mul(v,k),S=s.add(S,v),_=s.mul(P,R),_=s.add(_,_),v=s.mul(_,k),O=s.sub(O,v),$=s.mul(_,T),$=s.add($,$),$=s.add($,$),new d(O,S,$)}add(p){l(p);const{px:m,py:w,pz:C}=this,{px:P,py:R,pz:O}=p;let S=s.ZERO,$=s.ZERO,v=s.ZERO;const T=e.a,_=s.mul(e.b,_l);let k=s.mul(m,P),L=s.mul(w,R),E=s.mul(C,O),A=s.add(m,w),I=s.add(P,R);A=s.mul(A,I),I=s.add(k,L),A=s.sub(A,I),I=s.add(m,C);let x=s.add(P,O);return I=s.mul(I,x),x=s.add(k,E),I=s.sub(I,x),x=s.add(w,C),S=s.add(R,O),x=s.mul(x,S),S=s.add(L,E),x=s.sub(x,S),v=s.mul(T,I),S=s.mul(_,E),v=s.add(S,v),S=s.sub(L,v),v=s.add(L,v),$=s.mul(S,v),L=s.add(k,k),L=s.add(L,k),E=s.mul(T,E),I=s.mul(_,I),L=s.add(L,E),E=s.sub(k,E),E=s.mul(T,E),I=s.add(I,E),k=s.mul(L,I),$=s.add($,k),k=s.mul(x,I),S=s.mul(A,S),S=s.sub(S,k),k=s.mul(A,L),v=s.mul(x,v),v=s.add(v,k),new d(S,$,v)}subtract(p){return this.add(p.negate())}is0(){return this.equals(d.ZERO)}wNAF(p){return y.wNAFCached(this,p,d.normalizeZ)}multiplyUnsafe(p){const{endo:m,n:w}=e;vs("scalar",p,ys,w);const C=d.ZERO;if(p===ys)return C;if(this.is0()||p===ze)return this;if(!m||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,p,d.normalizeZ);let{k1neg:P,k1:R,k2neg:O,k2:S}=m.splitScalar(p),$=C,v=C,T=this;for(;R>ys||S>ys;)R&ze&&($=$.add(T)),S&ze&&(v=v.add(T)),T=T.double(),R>>=ze,S>>=ze;return P&&($=$.negate()),O&&(v=v.negate()),v=new d(s.mul(v.px,m.beta),v.py,v.pz),$.add(v)}multiply(p){const{endo:m,n:w}=e;vs("scalar",p,ze,w);let C,P;if(m){const{k1neg:R,k1:O,k2neg:S,k2:$}=m.splitScalar(p);let{p:v,f:T}=this.wNAF(O),{p:_,f:k}=this.wNAF($);v=y.constTimeNegate(R,v),_=y.constTimeNegate(S,_),_=new d(s.mul(_.px,m.beta),_.py,_.pz),C=v.add(_),P=T.add(k)}else{const{p:R,f:O}=this.wNAF(p);C=R,P=O}return d.normalizeZ([C,P])[0]}multiplyAndAddUnsafe(p,m,w){const C=d.BASE,P=(O,S)=>S===ys||S===ze||!O.equals(C)?O.multiplyUnsafe(S):O.multiply(S),R=P(this,m).add(P(p,w));return R.is0()?void 0:R}toAffine(p){return u(this,p)}isTorsionFree(){const{h:p,isTorsionFree:m}=e;if(p===ze)return!0;if(m)return m(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:m}=e;return p===ze?this:m?m(d,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return ai("isCompressed",p),this.assertValidity(),i(d,this,p)}toHex(p=!0){return ai("isCompressed",p),ci(this.toRawBytes(p))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const f=e.nBitLength,y=tw(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function gw(t){const e=ld(t);return Ci(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mw(t){const e=gw(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(E){return yt(E,r)}function a(E){return Ma(E,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=fw({...e,toBytes(E,A,I){const x=A.toAffine(),U=s.toBytes(x.x),N=un;return ai("isCompressed",I),I?N(Uint8Array.from([A.hasEvenY()?2:3]),U):N(Uint8Array.from([4]),U,s.toBytes(x.y))},fromBytes(E){const A=E.length,I=E[0],x=E.subarray(1);if(A===i&&(I===2||I===3)){const U=rr(x);if(!Co(U,ze,s.ORDER))throw new Error("Point is not on curve");const N=u(U);let M;try{M=s.sqrt(N)}catch(F){const X=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+X)}const j=(M&ze)===ze;return(I&1)===1!==j&&(M=s.neg(M)),{x:U,y:M}}else if(A===n&&I===4){const U=s.fromBytes(x.subarray(0,s.BYTES)),N=s.fromBytes(x.subarray(s.BYTES,2*s.BYTES));return{x:U,y:N}}else{const U=i,N=n;throw new Error("invalid Point, expected length of "+U+", or uncompressed "+N+", got "+A)}}}),d=E=>ci(ui(E,e.nByteLength));function f(E){const A=r>>ze;return E>A}function y(E){return f(E)?o(-E):E}const g=(E,A,I)=>rr(E.slice(A,I));class p{constructor(A,I,x){this.r=A,this.s=I,this.recovery=x,this.assertValidity()}static fromCompact(A){const I=e.nByteLength;return A=_t("compactSignature",A,I*2),new p(g(A,0,I),g(A,I,2*I))}static fromDER(A){const{r:I,s:x}=ms.toSig(_t("DER",A));return new p(I,x)}assertValidity(){vs("r",this.r,ze,r),vs("s",this.s,ze,r)}addRecoveryBit(A){return new p(this.r,this.s,A)}recoverPublicKey(A){const{r:I,s:x,recovery:U}=this,N=O(_t("msgHash",A));if(U==null||![0,1,2,3].includes(U))throw new Error("recovery id invalid");const M=U===2||U===3?I+e.n:I;if(M>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(U&1)===0?"02":"03",F=c.fromHex(j+d(M)),X=a(M),G=o(-N*X),oe=o(x*X),le=c.BASE.multiplyAndAddUnsafe(F,G,oe);if(!le)throw new Error("point at infinify");return le.assertValidity(),le}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return li(this.toDERHex())}toDERHex(){return ms.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return li(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const E=od(e.n);return Xm(e.randomBytes(E),e.n)},precompute(E=8,A=c.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}};function w(E,A=!0){return c.fromPrivateKey(E).toRawBytes(A)}function C(E){const A=lr(E),I=typeof E=="string",x=(A||I)&&E.length;return A?x===i||x===n:I?x===2*i||x===2*n:E instanceof c}function P(E,A,I=!0){if(C(E))throw new Error("first arg must be private key");if(!C(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(l(E)).toRawBytes(I)}const R=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");const A=rr(E),I=E.length*8-e.nBitLength;return I>0?A>>BigInt(I):A},O=e.bits2int_modN||function(E){return o(R(E))},S=Nc(e.nBitLength);function $(E){return vs("num < 2^"+e.nBitLength,E,ys,S),ui(E,e.nByteLength)}function v(E,A,I=T){if(["recovered","canonical"].some(ue=>ue in I))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:U}=e;let{lowS:N,prehash:M,extraEntropy:j}=I;N==null&&(N=!0),E=_t("msgHash",E),Nl(I),M&&(E=_t("prehashed msgHash",x(E)));const F=O(E),X=l(A),G=[$(X),$(F)];if(j!=null&&j!==!1){const ue=j===!0?U(s.BYTES):j;G.push(_t("extraEntropy",ue))}const oe=un(...G),le=F;function Ie(ue){const he=R(ue);if(!h(he))return;const Ft=a(he),at=c.BASE.multiply(he).toAffine(),qe=o(at.x);if(qe===ys)return;const Ze=o(Ft*o(le+qe*X));if(Ze===ys)return;let ct=(at.x===qe?0:2)|Number(at.y&ze),zs=Ze;return N&&f(Ze)&&(zs=y(Ze),ct^=1),new p(qe,zs,ct)}return{seed:oe,k2sig:Ie}}const T={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function k(E,A,I=T){const{seed:x,k2sig:U}=v(E,A,I),N=e;return td(N.hash.outputLen,N.nByteLength,N.hmac)(x,U)}c.BASE._setWindowSize(8);function L(E,A,I,x=_){var Ze;const U=E;A=_t("msgHash",A),I=_t("publicKey",I);const{lowS:N,prehash:M,format:j}=x;if(Nl(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const F=typeof U=="string"||lr(U),X=!F&&!j&&typeof U=="object"&&U!==null&&typeof U.r=="bigint"&&typeof U.s=="bigint";if(!F&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,oe;try{if(X&&(G=new p(U.r,U.s)),F){try{j!=="compact"&&(G=p.fromDER(U))}catch(ct){if(!(ct instanceof ms.Err))throw ct}!G&&j!=="der"&&(G=p.fromCompact(U))}oe=c.fromHex(I)}catch{return!1}if(!G||N&&G.hasHighS())return!1;M&&(A=e.hash(A));const{r:le,s:Ie}=G,ue=O(A),he=a(Ie),Ft=o(ue*he),at=o(le*he),qe=(Ze=c.BASE.multiplyAndAddUnsafe(oe,Ft,at))==null?void 0:Ze.toAffine();return qe?o(qe.x)===le:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:P,sign:k,verify:L,ProjectivePoint:c,Signature:p,utils:m}}function ww(t){return{hash:t,hmac:(e,...s)=>yo(t,e,Vg(...s)),randomBytes:Ei}}function yw(t,e){const s=r=>mw({...t,...ww(r)});return{...s(e),create:s}}const ud=id(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),bw=ud.create(BigInt("-3")),vw=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Ew=yw({a:bw,b:vw,Fp:ud,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},An),hd="base10",ut="base16",ir="base64pad",_c="base64url",_n="utf8",dd=0,Ii=1,Io=2,Cw=0,Sl=1,Qi=12,Sc=32;function Iw(){const t=ja.utils.randomPrivateKey(),e=ja.getPublicKey(t);return{privateKey:it(t,ut),publicKey:it(e,ut)}}function Fa(){const t=Ei(Sc);return it(t,ut)}function Aw(t,e){const s=ja.getSharedSecret(Et(t,ut),Et(e,ut)),r=Pm(An,s,void 0,void 0,Sc);return it(r,ut)}function Nw(t){const e=An(Et(t,ut));return it(e,ut)}function Yn(t){const e=An(Et(t,_n));return it(e,ut)}function pd(t){return Et(`${t}`,hd)}function ur(t){return Number(it(t,hd))}function fd(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function gd(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function _w(t){const e=pd(typeof t.type<"u"?t.type:dd);if(ur(e)===Ii&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?Et(t.senderPublicKey,ut):void 0,r=typeof t.iv<"u"?Et(t.iv,ut):Ei(Qi),i=Et(t.symKey,ut),n=Xh(i,r).encrypt(Et(t.message,_n)),o=md({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===_c?fd(o):o}function Sw(t){const e=Et(t.symKey,ut),{sealed:s,iv:r}=hn({encoded:t.encoded,encoding:t.encoding}),i=Xh(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return it(i,_n)}function Pw(t,e){const s=pd(Io),r=Ei(Qi),i=Et(t,_n),n=md({type:s,sealed:i,iv:r});return e===_c?fd(n):n}function Ow(t,e){const{sealed:s}=hn({encoded:t,encoding:e});return it(s,_n)}function md(t){if(ur(t.type)===Io)return it(Gi([t.type,t.sealed]),ir);if(ur(t.type)===Ii){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return it(Gi([t.type,t.senderPublicKey,t.iv,t.sealed]),ir)}return it(Gi([t.type,t.iv,t.sealed]),ir)}function hn(t){const e=(t.encoding||ir)===_c?gd(t.encoded):t.encoded,s=Et(e,ir),r=s.slice(Cw,Sl),i=Sl;if(ur(r)===Ii){const c=i+Sc,l=c+Qi,u=s.slice(i,c),h=s.slice(c,l),d=s.slice(l);return{type:r,sealed:d,iv:h,senderPublicKey:u}}if(ur(r)===Io){const c=s.slice(i),l=Ei(Qi);return{type:r,sealed:c,iv:l}}const n=i+Qi,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function $w(t,e){const s=hn({encoded:t,encoding:e==null?void 0:e.encoding});return wd({type:ur(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?it(s.senderPublicKey,ut):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function wd(t){const e=(t==null?void 0:t.type)||dd;if(e===Ii){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function Pl(t){return t.type===Ii&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Ol(t){return t.type===Io}function Tw(t){const e=Buffer.from(t.x,"base64"),s=Buffer.from(t.y,"base64");return Gi([new Uint8Array([4]),e,s])}function xw(t,e){const[s,r,i]=t.split("."),n=Buffer.from(gd(i),"base64");if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=`${s}.${r}`,l=An(c),u=Tw(e);if(!Ew.verify(Gi([o,a]),l,u))throw new Error("Invalid signature");return Sa(t).payload}const kw="irn";function oo(t){return(t==null?void 0:t.relay)||{protocol:kw}}function Hi(t){const e=Jp[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function Rw(t,e="-"){const s={},r="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(r)){const n=i.replace(r,""),o=t[i];s[n]=o}}),s}function $l(t){if(!t.includes("wc:")){const l=Fh(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),s=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),i=t.substring(e+1,s).split("@"),n=typeof s<"u"?t.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((l,u)=>{a[u]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:r,topic:Uw(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:Rw(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Uw(t){return t.startsWith("//")?t.substring(2):t}function Dw(t,e="-"){const s="relay",r={};return Object.keys(t).forEach(i=>{const n=i,o=s+e+n;t[n]&&(r[o]=t[n])}),r}function Tl(t){const e=new URLSearchParams,s=Dw(t.relay);Object.keys(s).sort().forEach(i=>{e.set(i,s[i])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const r=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${r}`}const Lw={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}},Bw={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function be(t,e){const{message:s,code:r}=Bw[t];return{message:e?`${s} ${e}`:s,code:r}}function Wi(t,e){const{message:s,code:r}=Lw[t];return{message:e?`${s} ${e}`:s,code:r}}function za(t){return typeof t>"u"}function yd(t,e){return typeof t=="string"&&!!t.trim().length}function Mw(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(yd(t,!1)){if(e(t))return!0;const s=Fh(t);return e(s)}}catch{}return!1}function qw(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function jw(t){return t==null?void 0:t.topic}function Yo(t){return typeof t<"u"&&typeof t!==null}function xl(){const t=wo();return new Promise(e=>{switch(t){case Zt.browser:e(Fw());break;case Zt.reactNative:e(zw());break;case Zt.node:e(Hw());break;default:e(!0)}})}function Fw(){return Cn()&&(navigator==null?void 0:navigator.onLine)}async function zw(){if(br()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function Hw(){return!0}function Ww(t){switch(wo()){case Zt.browser:Vw(t);break;case Zt.reactNative:Kw(t);break}}function Vw(t){!br()&&Cn()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function Kw(t){br()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}function Gw(){var t;return Cn()&&$t.getDocument()?((t=$t.getDocument())==null?void 0:t.visibilityState)==="visible":!0}var Jw={};const bd="wc",vd=2,Ha="core",cs=`${bd}@2:${Ha}:`,Yw={logger:"error"},Zw={database:":memory:"},Xw="crypto",kl="client_ed25519_seed",Qw=q.ONE_DAY,ey="keychain",ty="0.3",sy="messages",ry="0.3",Rl=q.SIX_HOURS,iy="publisher",Ed="irn",ny="error",Cd="wss://relay.walletconnect.org",oy="relayer",Ve={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},ay="_subscription",Dt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},cy=.1,Wa="2.21.0",Te={link_mode:"link_mode",relay:"relay"},Zn={inbound:"inbound",outbound:"outbound"},ly="0.3",uy="WALLETCONNECT_CLIENT_ID",Ul="WALLETCONNECT_LINK_MODE_APPS",At={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},hy="subscription",dy="0.3",py="pairing",fy="0.3",Ti={wc_pairingDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:q.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:q.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:q.ONE_DAY,prompt:!1,tag:0},res:{ttl:q.ONE_DAY,prompt:!1,tag:0}}},Zs={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},zt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},gy="history",my="0.3",wy="expirer",Mt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},yy="0.3",by="verify-api",vy="https://verify.walletconnect.com",Id="https://verify.walletconnect.org",en=Id,Ey=`${en}/v3`,Cy=[vy,Id],Iy="echo",Ay="https://echo.walletconnect.com",rs={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},gs={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ht={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Ws={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Vs={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},xi={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Ny=.1,_y="event-client",Sy=86400,Py="https://pulse.walletconnect.org/batch";function Oy(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),r=0;r<s.length;r++)s[r]=255;for(var i=0;i<t.length;i++){var n=t.charAt(i),o=n.charCodeAt(0);if(s[o]!==255)throw new TypeError(n+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var g=0,p=0,m=0,w=y.length;m!==w&&y[m]===0;)m++,g++;for(var C=(w-m)*u+1>>>0,P=new Uint8Array(C);m!==w;){for(var R=y[m],O=0,S=C-1;(R!==0||O<p)&&S!==-1;S--,O++)R+=256*P[S]>>>0,P[S]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");p=O,m++}for(var $=C-p;$!==C&&P[$]===0;)$++;for(var v=c.repeat(g);$<C;++$)v+=t.charAt(P[$]);return v}function d(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var g=0;if(y[g]!==" "){for(var p=0,m=0;y[g]===c;)p++,g++;for(var w=(y.length-g)*l+1>>>0,C=new Uint8Array(w);y[g];){var P=s[y.charCodeAt(g)];if(P===255)return;for(var R=0,O=w-1;(P!==0||R<m)&&O!==-1;O--,R++)P+=a*C[O]>>>0,C[O]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");m=R,g++}if(y[g]!==" "){for(var S=w-m;S!==w&&C[S]===0;)S++;for(var $=new Uint8Array(p+(w-S)),v=p;S!==w;)$[v++]=C[S++];return $}}}function f(y){var g=d(y);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var $y=Oy,Ty=$y;const Ad=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},xy=t=>new TextEncoder().encode(t),ky=t=>new TextDecoder().decode(t);let Ry=class{constructor(e,s,r){this.name=e,this.prefix=s,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Uy=class{constructor(e,s,r){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Nd(this,e)}},Dy=class{constructor(e){this.decoders=e}or(e){return Nd(this,e)}decode(e){const s=e[0],r=this.decoders[s];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Nd=(t,e)=>new Dy({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let Ly=class{constructor(e,s,r,i){this.name=e,this.prefix=s,this.baseEncode=r,this.baseDecode=i,this.encoder=new Ry(e,s,r),this.decoder=new Uy(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Ao=({name:t,prefix:e,encode:s,decode:r})=>new Ly(t,e,s,r),Sn=({prefix:t,name:e,alphabet:s})=>{const{encode:r,decode:i}=Ty(s,e);return Ao({prefix:t,name:e,encode:r,decode:n=>Ad(i(n))})},By=(t,e,s,r)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,l=0;for(let u=0;u<n;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<s|h,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},My=(t,e,s)=>{const r=e[e.length-1]==="=",i=(1<<s)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,n+=e[i&a>>o];if(o&&(n+=e[i&a<<s-o]),r)for(;n.length*s&7;)n+="=";return n},st=({name:t,prefix:e,bitsPerChar:s,alphabet:r})=>Ao({prefix:e,name:t,encode(i){return My(i,r,s)},decode(i){return By(i,r,s,t)}}),qy=Ao({prefix:"\0",name:"identity",encode:t=>ky(t),decode:t=>xy(t)});var jy=Object.freeze({__proto__:null,identity:qy});const Fy=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zy=Object.freeze({__proto__:null,base2:Fy});const Hy=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wy=Object.freeze({__proto__:null,base8:Hy});const Vy=Sn({prefix:"9",name:"base10",alphabet:"0123456789"});var Ky=Object.freeze({__proto__:null,base10:Vy});const Gy=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jy=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yy=Object.freeze({__proto__:null,base16:Gy,base16upper:Jy});const Zy=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xy=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qy=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),eb=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tb=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sb=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rb=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ib=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nb=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ob=Object.freeze({__proto__:null,base32:Zy,base32upper:Xy,base32pad:Qy,base32padupper:eb,base32hex:tb,base32hexupper:sb,base32hexpad:rb,base32hexpadupper:ib,base32z:nb});const ab=Sn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cb=Sn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var lb=Object.freeze({__proto__:null,base36:ab,base36upper:cb});const ub=Sn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hb=Sn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var db=Object.freeze({__proto__:null,base58btc:ub,base58flickr:hb});const pb=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fb=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gb=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mb=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var wb=Object.freeze({__proto__:null,base64:pb,base64pad:fb,base64url:gb,base64urlpad:mb});const _d=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),yb=_d.reduce((t,e,s)=>(t[s]=e,t),[]),bb=_d.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function vb(t){return t.reduce((e,s)=>(e+=yb[s],e),"")}function Eb(t){const e=[];for(const s of t){const r=bb[s.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(r)}return new Uint8Array(e)}const Cb=Ao({prefix:"🚀",name:"base256emoji",encode:vb,decode:Eb});var Ib=Object.freeze({__proto__:null,base256emoji:Cb}),Ab=Sd,Dl=128,Nb=-128,_b=Math.pow(2,31);function Sd(t,e,s){e=e||[],s=s||0;for(var r=s;t>=_b;)e[s++]=t&255|Dl,t/=128;for(;t&Nb;)e[s++]=t&255|Dl,t>>>=7;return e[s]=t|0,Sd.bytes=s-r+1,e}var Sb=Va,Pb=128,Ll=127;function Va(t,r){var s=0,r=r||0,i=0,n=r,o,a=t.length;do{if(n>=a)throw Va.bytes=0,new RangeError("Could not decode varint");o=t[n++],s+=i<28?(o&Ll)<<i:(o&Ll)*Math.pow(2,i),i+=7}while(o>=Pb);return Va.bytes=n-r,s}var Ob=Math.pow(2,7),$b=Math.pow(2,14),Tb=Math.pow(2,21),xb=Math.pow(2,28),kb=Math.pow(2,35),Rb=Math.pow(2,42),Ub=Math.pow(2,49),Db=Math.pow(2,56),Lb=Math.pow(2,63),Bb=function(t){return t<Ob?1:t<$b?2:t<Tb?3:t<xb?4:t<kb?5:t<Rb?6:t<Ub?7:t<Db?8:t<Lb?9:10},Mb={encode:Ab,decode:Sb,encodingLength:Bb},Pd=Mb;const Bl=(t,e,s=0)=>(Pd.encode(t,e,s),e),Ml=t=>Pd.encodingLength(t),Ka=(t,e)=>{const s=e.byteLength,r=Ml(t),i=r+Ml(s),n=new Uint8Array(i+s);return Bl(t,n,0),Bl(s,n,r),n.set(e,i),new qb(t,s,e,n)};let qb=class{constructor(e,s,r,i){this.code=e,this.size=s,this.digest=r,this.bytes=i}};const Od=({name:t,code:e,encode:s})=>new jb(t,e,s);class jb{constructor(e,s,r){this.name=e,this.code=s,this.encode=r}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?Ka(this.code,s):s.then(r=>Ka(this.code,r))}else throw Error("Unknown type, must be binary type")}}const $d=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Fb=Od({name:"sha2-256",code:18,encode:$d("SHA-256")}),zb=Od({name:"sha2-512",code:19,encode:$d("SHA-512")});var Hb=Object.freeze({__proto__:null,sha256:Fb,sha512:zb});const Td=0,Wb="identity",xd=Ad,Vb=t=>Ka(Td,xd(t)),Kb={code:Td,name:Wb,encode:xd,digest:Vb};var Gb=Object.freeze({__proto__:null,identity:Kb});new TextEncoder,new TextDecoder;const ql={...jy,...zy,...Wy,...Ky,...Yy,...ob,...lb,...db,...wb,...Ib};({...Hb,...Gb});function Jb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function kd(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const jl=kd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Zo=kd("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=Jb(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Yb={utf8:jl,"utf-8":jl,hex:ql.base16,latin1:Zo,ascii:Zo,binary:Zo,...ql};function Zb(t,e="utf8"){const s=Yb[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):s.decoder.decode(`${s.prefix}${t}`)}var Xb=Object.defineProperty,Qb=(t,e,s)=>e in t?Xb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,es=(t,e,s)=>Qb(t,typeof e!="symbol"?e+"":e,s);let e0=class{constructor(e,s){this.core=e,this.logger=s,es(this,"keychain",new Map),es(this,"name",ey),es(this,"version",ty),es(this,"initialized",!1),es(this,"storagePrefix",cs),es(this,"init",async()=>{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),es(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),es(this,"set",async(r,i)=>{this.isInitialized(),this.keychain.set(r,i),await this.persist()}),es(this,"get",r=>{this.isInitialized();const i=this.keychain.get(r);if(typeof i>"u"){const{message:n}=be("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}),es(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=ht(s,this.name)}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,xa(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ka(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var t0=Object.defineProperty,s0=(t,e,s)=>e in t?t0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Qe=(t,e,s)=>s0(t,typeof e!="symbol"?e+"":e,s);let r0=class{constructor(e,s,r){this.core=e,this.logger=s,Qe(this,"name",Xw),Qe(this,"keychain"),Qe(this,"randomSessionIdentifier",Fa()),Qe(this,"initialized",!1),Qe(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Qe(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Qe(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),n=Wc(i);return ef(n.publicKey)}),Qe(this,"generateKeyPair",()=>{this.isInitialized();const i=Iw();return this.setPrivateKey(i.publicKey,i.privateKey)}),Qe(this,"signJWT",async i=>{this.isInitialized();const n=await this.getClientSeed(),o=Wc(n),a=this.randomSessionIdentifier;return await tf(a,i,Qw,o)}),Qe(this,"generateSharedKey",(i,n,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=Aw(a,n);return this.setSymKey(c,o)}),Qe(this,"setSymKey",async(i,n)=>{this.isInitialized();const o=n||Nw(i);return await this.keychain.set(o,i),o}),Qe(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Qe(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Qe(this,"encode",async(i,n,o)=>{this.isInitialized();const a=wd(o),c=sf(n);if(Ol(a))return Pw(c,o==null?void 0:o.encoding);if(Pl(a)){const d=a.senderPublicKey,f=a.receiverPublicKey;i=await this.generateSharedKey(d,f)}const l=this.getSymKey(i),{type:u,senderPublicKey:h}=a;return _w({type:u,symKey:l,message:c,senderPublicKey:h,encoding:o==null?void 0:o.encoding})}),Qe(this,"decode",async(i,n,o)=>{this.isInitialized();const a=$w(n,o);if(Ol(a)){const c=Ow(n,o==null?void 0:o.encoding);return Vc(c)}if(Pl(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=Sw({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return Vc(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Qe(this,"getPayloadType",(i,n=ir)=>{const o=hn({encoded:i,encoding:n});return ur(o.type)}),Qe(this,"getPayloadSenderPublicKey",(i,n=ir)=>{const o=hn({encoded:i,encoding:n});return o.senderPublicKey?it(o.senderPublicKey,ut):void 0}),this.core=e,this.logger=ht(s,this.name),this.keychain=r||new e0(this.core,this.logger)}get context(){return xt(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(kl)}catch{e=Fa(),await this.keychain.set(kl,e)}return Zb(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var i0=Object.defineProperty,n0=Object.defineProperties,o0=Object.getOwnPropertyDescriptors,Fl=Object.getOwnPropertySymbols,a0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable,Ga=(t,e,s)=>e in t?i0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,l0=(t,e)=>{for(var s in e||(e={}))a0.call(e,s)&&Ga(t,s,e[s]);if(Fl)for(var s of Fl(e))c0.call(e,s)&&Ga(t,s,e[s]);return t},u0=(t,e)=>n0(t,o0(e)),It=(t,e,s)=>Ga(t,typeof e!="symbol"?e+"":e,s);let h0=class extends cg{constructor(e,s){super(e,s),this.logger=e,this.core=s,It(this,"messages",new Map),It(this,"messagesWithoutClientAck",new Map),It(this,"name",sy),It(this,"version",ry),It(this,"initialized",!1),It(this,"storagePrefix",cs),It(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const r=await this.getRelayerMessages();typeof r<"u"&&(this.messages=r);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}finally{this.initialized=!0}}}),It(this,"set",async(r,i,n)=>{this.isInitialized();const o=Yn(i);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(r,a),n===Zn.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,u0(l0({},c),{[o]:i}))}return await this.persist(),o}),It(this,"get",r=>{this.isInitialized();let i=this.messages.get(r);return typeof i>"u"&&(i={}),i}),It(this,"getWithoutAck",r=>{this.isInitialized();const i={};for(const n of r){const o=this.messagesWithoutClientAck.get(n)||{};i[n]=Object.values(o)}return i}),It(this,"has",(r,i)=>{this.isInitialized();const n=this.get(r),o=Yn(i);return typeof n[o]<"u"}),It(this,"ack",async(r,i)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=Yn(i);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),It(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=ht(e,this.name),this.core=s}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,xa(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,xa(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ka(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?ka(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var d0=Object.defineProperty,p0=Object.defineProperties,f0=Object.getOwnPropertyDescriptors,zl=Object.getOwnPropertySymbols,g0=Object.prototype.hasOwnProperty,m0=Object.prototype.propertyIsEnumerable,Ja=(t,e,s)=>e in t?d0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ln=(t,e)=>{for(var s in e||(e={}))g0.call(e,s)&&Ja(t,s,e[s]);if(zl)for(var s of zl(e))m0.call(e,s)&&Ja(t,s,e[s]);return t},Xo=(t,e)=>p0(t,f0(e)),Wt=(t,e,s)=>Ja(t,typeof e!="symbol"?e+"":e,s);class w0 extends lg{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Wt(this,"events",new gr.EventEmitter),Wt(this,"name",iy),Wt(this,"queue",new Map),Wt(this,"publishTimeout",q.toMiliseconds(q.ONE_MINUTE)),Wt(this,"initialPublishTimeout",q.toMiliseconds(q.ONE_SECOND*15)),Wt(this,"needsTransportRestart",!1),Wt(this,"publish",async(r,i,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:r,message:i,opts:n}});const a=(n==null?void 0:n.ttl)||Rl,c=oo(n),l=(n==null?void 0:n.prompt)||!1,u=(n==null?void 0:n.tag)||0,h=(n==null?void 0:n.id)||Gr().toString(),d={topic:r,message:i,opts:{ttl:a,relay:c,prompt:l,tag:u,id:h,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},f=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const y=new Promise(async g=>{const p=({id:w})=>{d.opts.id===w&&(this.removeRequestFromQueue(w),this.relayer.events.removeListener(Ve.publish,p),g(d))};this.relayer.events.on(Ve.publish,p);const m=Rs(new Promise((w,C)=>{this.rpcPublish({topic:r,message:i,ttl:a,prompt:l,tag:u,id:h,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(w).catch(P=>{this.logger.warn(P,P==null?void 0:P.message),C(P)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await m,this.events.removeListener(Ve.publish,p)}catch(w){this.queue.set(h,Xo(Ln({},d),{attempt:1})),this.logger.warn(w,w==null?void 0:w.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:r,message:i,opts:n}}),await Rs(y,this.publishTimeout,f)}catch(y){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(y),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw y}finally{this.queue.delete(h)}}),Wt(this,"on",(r,i)=>{this.events.on(r,i)}),Wt(this,"once",(r,i)=>{this.events.once(r,i)}),Wt(this,"off",(r,i)=>{this.events.off(r,i)}),Wt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.relayer=e,this.logger=ht(s,this.name),this.registerEventListeners()}get context(){return xt(this.logger)}async rpcPublish(e){var s,r,i,n;const{topic:o,message:a,ttl:c=Rl,prompt:l,tag:u,id:h,attestation:d,tvf:f}=e,y={method:Hi(oo().protocol).publish,params:Ln({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:d},f),id:h};za((s=y.params)==null?void 0:s.prompt)&&((r=y.params)==null||delete r.prompt),za((i=y.params)==null?void 0:i.tag)&&((n=y.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y});const g=await this.relayer.request(y);return this.relayer.events.emit(Ve.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{const r=e.attempt+1;this.queue.set(s,Xo(Ln({},e),{attempt:r}));const{topic:i,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(Xo(Ln({},e),{topic:i,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(vi.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ve.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ve.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var y0=Object.defineProperty,b0=(t,e,s)=>e in t?y0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Nr=(t,e,s)=>b0(t,typeof e!="symbol"?e+"":e,s);class v0{constructor(){Nr(this,"map",new Map),Nr(this,"set",(e,s)=>{const r=this.get(e);this.exists(e,s)||this.map.set(e,[...r,s])}),Nr(this,"get",e=>this.map.get(e)||[]),Nr(this,"exists",(e,s)=>this.get(e).includes(s)),Nr(this,"delete",(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,s))return;const i=r.filter(n=>n!==s);if(!i.length){this.map.delete(e);return}this.map.set(e,i)}),Nr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var E0=Object.defineProperty,C0=Object.defineProperties,I0=Object.getOwnPropertyDescriptors,Hl=Object.getOwnPropertySymbols,A0=Object.prototype.hasOwnProperty,N0=Object.prototype.propertyIsEnumerable,Ya=(t,e,s)=>e in t?E0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ki=(t,e)=>{for(var s in e||(e={}))A0.call(e,s)&&Ya(t,s,e[s]);if(Hl)for(var s of Hl(e))N0.call(e,s)&&Ya(t,s,e[s]);return t},Qo=(t,e)=>C0(t,I0(e)),Ne=(t,e,s)=>Ya(t,typeof e!="symbol"?e+"":e,s);let _0=class extends dg{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Ne(this,"subscriptions",new Map),Ne(this,"topicMap",new v0),Ne(this,"events",new gr.EventEmitter),Ne(this,"name",hy),Ne(this,"version",dy),Ne(this,"pending",new Map),Ne(this,"cached",[]),Ne(this,"initialized",!1),Ne(this,"storagePrefix",cs),Ne(this,"subscribeTimeout",q.toMiliseconds(q.ONE_MINUTE)),Ne(this,"initialSubscribeTimeout",q.toMiliseconds(q.ONE_SECOND*15)),Ne(this,"clientId"),Ne(this,"batchSubscribeTopicsLimit",500),Ne(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ne(this,"subscribe",async(r,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}});try{const n=oo(i),o={topic:r,relay:n,transportType:i==null?void 0:i.transportType};this.pending.set(r,o);const a=await this.rpcSubscribe(r,n,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),Ne(this,"unsubscribe",async(r,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(r,i.id,i):await this.unsubscribeByTopic(r,i)}),Ne(this,"isSubscribed",r=>new Promise(i=>{i(this.topicMap.topics.includes(r))})),Ne(this,"isKnownTopic",r=>new Promise(i=>{i(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),Ne(this,"on",(r,i)=>{this.events.on(r,i)}),Ne(this,"once",(r,i)=>{this.events.once(r,i)}),Ne(this,"off",(r,i)=>{this.events.off(r,i)}),Ne(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),Ne(this,"start",async()=>{await this.onConnect()}),Ne(this,"stop",async()=>{await this.onDisconnect()}),Ne(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Ne(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}),Ne(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(vi.pulse,async()=>{await this.checkPending()}),this.events.on(At.created,async r=>{const i=At.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(At.deleted,async r=>{const i=At.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}),this.relayer=e,this.logger=ht(s,this.name),this.clientId=""}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,s){let r=!1;try{r=this.getSubscription(e).topic===s}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const r=this.topicMap.get(e);await Promise.all(r.map(async i=>await this.unsubscribeById(e,i,s)))}async unsubscribeById(e,s,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}});try{const i=oo(r);await this.restartToComplete({topic:e,id:s,relay:i}),await this.rpcUnsubscribe(e,s,i);const n=Wi("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,s,r){var i;(!r||(r==null?void 0:r.transportType)===Te.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const n={method:Hi(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((r==null?void 0:r.transportType)===Te.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(u=>this.logger.warn(u))},q.toMiliseconds(q.ONE_SECOND)),a;const c=new Promise(async u=>{const h=d=>{d.topic===e&&(this.events.removeListener(At.created,h),u(d.id))};this.events.on(At.created,h);try{const d=await Rs(new Promise((f,y)=>{this.relayer.request(n).catch(g=>{this.logger.warn(g,g==null?void 0:g.message),y(g)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(At.created,h),u(d)}catch{}}),l=await Rs(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ve.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const s=e[0].relay,r={method:Hi(s.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await Rs(new Promise(i=>{this.relayer.request(r).catch(n=>this.logger.warn(n)).then(i)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ve.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,r={method:Hi(s.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let i;try{i=await await Rs(new Promise((n,o)=>{this.relayer.request(r).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ve.connection_stalled)}return i}rpcUnsubscribe(e,s,r){const i={method:Hi(r.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,s){this.setSubscription(e,Qo(ki({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,ki({},s)),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,r){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,ki({},s)),this.topicMap.set(s.topic,e),this.events.emit(At.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(At.deleted,Qo(ki({},r),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(At.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<s;r++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(At.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async s=>Qo(ki({},s),{id:await this.getSubscriptionId(s.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await Ug(q.toMiliseconds(q.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Yn(e+await this.getClientId())}};var S0=Object.defineProperty,Wl=Object.getOwnPropertySymbols,P0=Object.prototype.hasOwnProperty,O0=Object.prototype.propertyIsEnumerable,Za=(t,e,s)=>e in t?S0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Vl=(t,e)=>{for(var s in e||(e={}))P0.call(e,s)&&Za(t,s,e[s]);if(Wl)for(var s of Wl(e))O0.call(e,s)&&Za(t,s,e[s]);return t},ge=(t,e,s)=>Za(t,typeof e!="symbol"?e+"":e,s);let $0=class extends ug{constructor(e){super(e),ge(this,"protocol","wc"),ge(this,"version",2),ge(this,"core"),ge(this,"logger"),ge(this,"events",new gr.EventEmitter),ge(this,"provider"),ge(this,"messages"),ge(this,"subscriber"),ge(this,"publisher"),ge(this,"name",oy),ge(this,"transportExplicitlyClosed",!1),ge(this,"initialized",!1),ge(this,"connectionAttemptInProgress",!1),ge(this,"relayUrl"),ge(this,"projectId"),ge(this,"packageName"),ge(this,"bundleId"),ge(this,"hasExperiencedNetworkDisruption",!1),ge(this,"pingTimeout"),ge(this,"heartBeatTimeout",q.toMiliseconds(q.THIRTY_SECONDS+q.FIVE_SECONDS)),ge(this,"reconnectTimeout"),ge(this,"connectPromise"),ge(this,"reconnectInProgress",!1),ge(this,"requestsInFlight",[]),ge(this,"connectTimeout",q.toMiliseconds(q.ONE_SECOND*15)),ge(this,"request",async s=>{var r,i;this.logger.debug("Publishing Request Payload");const n=s.id||Gr().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:s.method,topic:(r=s.params)==null?void 0:r.topic},"relayer.request - publishing...");const o=`${n}:${((i=s.params)==null?void 0:i.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),ge(this,"resetPingTimeout",()=>{no()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,r,i,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=(s=this.provider)==null?void 0:s.connection)==null?void 0:r.socket)==null?void 0:i.terminate)==null||n.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),ge(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),ge(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Ve.connect)}),ge(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),ge(this,"onProviderErrorHandler",s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(Ve.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),ge(this,"registerProviderListeners",()=>{this.provider.on(Dt.payload,this.onPayloadHandler),this.provider.on(Dt.connect,this.onConnectHandler),this.provider.on(Dt.disconnect,this.onDisconnectHandler),this.provider.on(Dt.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?ht(e.logger,this.name):yc(bn({level:e.logger||ny})),this.messages=new h0(this.logger,e.core),this.subscriber=new _0(this,this.logger),this.publisher=new w0(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Cd,this.projectId=e.projectId,Ag()?this.packageName=rl():Ng()&&(this.bundleId=rl()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return xt(this.logger)}get connected(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===1||!1}get connecting(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,s,r){this.isInitialized(),await this.publisher.publish(e,s,r),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:Te.relay},Zn.outbound)}async subscribe(e,s){var r,i,n;this.isInitialized(),(!(s!=null&&s.transportType)||(s==null?void 0:s.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((r=s==null?void 0:s.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(i=s==null?void 0:s.internal)==null?void 0:i.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(At.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(At.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,Vl({internal:{throwOnFailedPublish:o}},s)).catch(d=>{o&&h(d)})||a,u()})]),a}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Rs(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(s,r)=>{await this.connect(e).then(s).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await xl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const s=e.sort((r,i)=>r.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const r of s)try{await this.onMessageEvent(r)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:r}=e;if(!s.sessionExists){const i=Xi(q.FIVE_MINUTES),n={topic:r,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(Ve.message,e),await this.recordMessageEvent(e,Zn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(r,i)=>{const n=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dt.disconnect,n),await Rs(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{i(o)}).finally(()=>{this.provider.off(Dt.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dt.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Dt.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){await this.subscriber.stop();const i=r;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${s}`);break}await new Promise(r=>setTimeout(r,q.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,r,i,n;if(no())try{(s=(e=this.provider)==null?void 0:e.connection)!=null&&s.socket&&((n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new qt(new Qp($g({sdkVersion:Wa,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,s){const{topic:r,message:i}=e;await this.messages.set(r,i,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:r}=e;if(!r||r.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const i=this.messages.has(s,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),bc(e)){if(!e.method.endsWith(ay))return;const s=e.params,{topic:r,message:i,publishedAt:n,attestation:o}=s.data,a={topic:r,message:i,publishedAt:n,transportType:Te.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Vl({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else vc(e)&&this.events.emit(Ve.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Zn.inbound),this.events.emit(Ve.message,e))}async acknowledgePayload(e){const s=go(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(Dt.payload,this.onPayloadHandler),this.provider.off(Dt.connect,this.onConnectHandler),this.provider.off(Dt.disconnect,this.onDisconnectHandler),this.provider.off(Dt.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await xl();Ww(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(r=>this.logger.error(r,r==null?void 0:r.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(vi.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&Gw())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s==null?void 0:s.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Ve.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},q.toMiliseconds(cy)))))}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}};function T0(){}function Kl(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function Gl(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Jl(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const x0="[object RegExp]",k0="[object String]",R0="[object Number]",U0="[object Boolean]",Yl="[object Arguments]",D0="[object Symbol]",L0="[object Date]",B0="[object Map]",M0="[object Set]",q0="[object Array]",j0="[object Function]",F0="[object ArrayBuffer]",ea="[object Object]",z0="[object Error]",H0="[object DataView]",W0="[object Uint8Array]",V0="[object Uint8ClampedArray]",K0="[object Uint16Array]",G0="[object Uint32Array]",J0="[object BigUint64Array]",Y0="[object Int8Array]",Z0="[object Int16Array]",X0="[object Int32Array]",Q0="[object BigInt64Array]",ev="[object Float32Array]",tv="[object Float64Array]";function sv(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function rv(t,e,s){return Vi(t,e,void 0,void 0,void 0,void 0,s)}function Vi(t,e,s,r,i,n,o){const a=o(t,e,s,r,i,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return tn(t,e,n,o)}return tn(t,e,n,o)}function tn(t,e,s,r){if(Object.is(t,e))return!0;let i=Jl(t),n=Jl(e);if(i===Yl&&(i=ea),n===Yl&&(n=ea),i!==n)return!1;switch(i){case k0:return t.toString()===e.toString();case R0:{const c=t.valueOf(),l=e.valueOf();return sv(c,l)}case U0:case L0:case D0:return Object.is(t.valueOf(),e.valueOf());case x0:return t.source===e.source&&t.flags===e.flags;case j0:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(i){case B0:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Vi(l,e.get(c),c,t,e,s,r))return!1;return!0}case M0:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let u=0;u<c.length;u++){const h=c[u],d=l.findIndex(f=>Vi(h,f,void 0,t,e,s,r));if(d===-1)return!1;l.splice(d,1)}return!0}case q0:case W0:case V0:case K0:case G0:case J0:case Y0:case Z0:case X0:case Q0:case ev:case tv:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Vi(t[c],e[c],c,t,e,s,r))return!1;return!0}case F0:return t.byteLength!==e.byteLength?!1:tn(new Uint8Array(t),new Uint8Array(e),s,r);case H0:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:tn(new Uint8Array(t),new Uint8Array(e),s,r);case z0:return t.name===e.name&&t.message===e.message;case ea:{if(!(tn(t.constructor,e.constructor,s,r)||Kl(t)&&Kl(e)))return!1;const c=[...Object.keys(t),...Gl(t)],l=[...Object.keys(e),...Gl(e)];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){const h=c[u],d=t[h];if(!Object.hasOwn(e,h))return!1;const f=e[h];if(!Vi(d,f,h,t,e,s,r))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function iv(t,e){return rv(t,e,T0)}var nv=Object.defineProperty,Zl=Object.getOwnPropertySymbols,ov=Object.prototype.hasOwnProperty,av=Object.prototype.propertyIsEnumerable,Xa=(t,e,s)=>e in t?nv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Xl=(t,e)=>{for(var s in e||(e={}))ov.call(e,s)&&Xa(t,s,e[s]);if(Zl)for(var s of Zl(e))av.call(e,s)&&Xa(t,s,e[s]);return t},gt=(t,e,s)=>Xa(t,typeof e!="symbol"?e+"":e,s);let vr=class extends hg{constructor(e,s,r,i=cs,n=void 0){super(e,s,r,i),this.core=e,this.logger=s,this.name=r,gt(this,"map",new Map),gt(this,"version",ly),gt(this,"cached",[]),gt(this,"initialized",!1),gt(this,"getKey"),gt(this,"storagePrefix",cs),gt(this,"recentlyDeleted",[]),gt(this,"recentlyDeletedLimit",200),gt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!za(o)?this.map.set(this.getKey(o),o):qw(o)?this.map.set(o.id,o):jw(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),gt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),gt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),gt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>iv(a[c],o[c]))):this.values)),gt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Xl(Xl({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),gt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=ht(s,this.name),this.storagePrefix=i,this.getKey=n}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:i}=be("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}return s}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var cv=Object.defineProperty,lv=(t,e,s)=>e in t?cv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ae=(t,e,s)=>lv(t,typeof e!="symbol"?e+"":e,s);let uv=class{constructor(e,s){this.core=e,this.logger=s,ae(this,"name",py),ae(this,"version",fy),ae(this,"events",new Ec),ae(this,"pairings"),ae(this,"initialized",!1),ae(this,"storagePrefix",cs),ae(this,"ignoredPayloadTypes",[Ii]),ae(this,"registeredMethods",[]),ae(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ae(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),ae(this,"create",async r=>{this.isInitialized();const i=Fa(),n=await this.core.crypto.setSymKey(i),o=Xi(q.FIVE_MINUTES),a={protocol:Ed},c={topic:n,expiry:o,relay:a,active:!1,methods:r==null?void 0:r.methods},l=Tl({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:a,expiryTimestamp:o,methods:r==null?void 0:r.methods});return this.events.emit(Zs.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r==null?void 0:r.transportType}),{topic:n,uri:l}}),ae(this,"pair",async r=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:r==null?void 0:r.uri,trace:[rs.pairing_started]}});this.isValidPair(r,i);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=$l(r.uri);i.props.properties.topic=n,i.addTrace(rs.pairing_uri_validation_success),i.addTrace(rs.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(n)){if(u=this.pairings.get(n),i.addTrace(rs.existing_pairing),u.active)throw i.setError(gs.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);i.addTrace(rs.pairing_not_expired)}const h=c||Xi(q.FIVE_MINUTES),d={topic:n,relay:a,expiry:h,active:!1,methods:l};this.core.expirer.set(n,h),await this.pairings.set(n,d),i.addTrace(rs.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(Zs.create,d),i.addTrace(rs.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),i.addTrace(rs.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(gs.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw i.setError(gs.subscribe_pairing_topic_failure),f}return i.addTrace(rs.subscribe_pairing_topic_success),d}),ae(this,"activate",async({topic:r})=>{this.isInitialized();const i=Xi(q.FIVE_MINUTES);this.core.expirer.set(r,i),await this.pairings.update(r,{active:!0,expiry:i})}),ae(this,"ping",async r=>{this.isInitialized(),await this.isValidPing(r),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=r;if(this.pairings.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Tg();this.events.once(Mo("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),ae(this,"updateExpiry",async({topic:r,expiry:i})=>{this.isInitialized(),await this.pairings.update(r,{expiry:i})}),ae(this,"updateMetadata",async({topic:r,metadata:i})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:i})}),ae(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ae(this,"disconnect",async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Wi("USER_DISCONNECTED")),await this.deletePairing(i))}),ae(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:i,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(i);return Tl({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),ae(this,"sendRequest",async(r,i,n)=>{const o=er(i,n),a=await this.core.crypto.encode(r,o),c=Ti[i].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),ae(this,"sendResult",async(r,i,n)=>{const o=go(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=Ti[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ae(this,"sendError",async(r,i,n)=>{const o=$h(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=Ti[c]?Ti[c].res:Ti.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ae(this,"deletePairing",async(r,i)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,Wi("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),i?Promise.resolve():this.core.expirer.del(r)])}),ae(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(i=>il(i.expiry));await Promise.all(r.map(i=>this.deletePairing(i.topic)))}),ae(this,"onRelayEventRequest",async r=>{const{topic:i,payload:n}=r;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,n);default:return await this.onUnknownRpcMethodRequest(i,n)}}),ae(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n}=r,o=(await this.core.history.get(i,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,n);default:return this.onUnknownRpcMethodResponse(o)}}),ae(this,"onPairingPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(Zs.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ae(this,"onPairingPingResponse",(r,i)=>{const{id:n}=i;setTimeout(()=>{fs(i)?this.events.emit(Mo("pairing_ping",n),{}):is(i)&&this.events.emit(Mo("pairing_ping",n),{error:i.error})},500)}),ae(this,"onPairingDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(Zs.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ae(this,"onUnknownRpcMethodRequest",async(r,i)=>{const{id:n,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Wi("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,r,a),this.logger.error(a)}catch(a){await this.sendError(n,r,a),this.logger.error(a)}}),ae(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(Wi("WC_METHOD_UNSUPPORTED",r))}),ae(this,"isValidPair",(r,i)=>{var n;if(!Yo(r)){const{message:a}=be("MISSING_OR_INVALID",`pair() params: ${r}`);throw i.setError(gs.malformed_pairing_uri),new Error(a)}if(!Mw(r.uri)){const{message:a}=be("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw i.setError(gs.malformed_pairing_uri),new Error(a)}const o=$l(r==null?void 0:r.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=be("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(gs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=be("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(gs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&q.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(gs.pairing_expired);const{message:a}=be("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ae(this,"isValidPing",async r=>{if(!Yo(r)){const{message:n}=be("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ae(this,"isValidDisconnect",async r=>{if(!Yo(r)){const{message:n}=be("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ae(this,"isValidPairingTopic",async r=>{if(!yd(r)){const{message:i}=be("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.pairings.keys.includes(r)){const{message:i}=be("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(il(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:i}=be("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}),this.core=e,this.logger=ht(s,this.name),this.pairings=new vr(this.core,this.logger,this.name,this.storagePrefix)}get context(){return xt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ve.message,async e=>{const{topic:s,message:r,transportType:i}=e;if(this.pairings.keys.includes(s)&&i!==Te.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(s,r);bc(n)?(this.core.history.set(s,n),await this.onRelayEventRequest({topic:s,payload:n})):vc(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:s,payload:n}),this.core.history.delete(s,n.id)),await this.core.relayer.messages.ack(s,r)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(Mt.expired,async e=>{const{topic:s}=Rg(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(Zs.expire,{topic:s}))})}};var hv=Object.defineProperty,dv=(t,e,s)=>e in t?hv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,et=(t,e,s)=>dv(t,typeof e!="symbol"?e+"":e,s);let pv=class extends ag{constructor(e,s){super(e,s),this.core=e,this.logger=s,et(this,"records",new Map),et(this,"events",new gr.EventEmitter),et(this,"name",gy),et(this,"version",my),et(this,"cached",[]),et(this,"initialized",!1),et(this,"storagePrefix",cs),et(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.records.set(r.id,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),et(this,"set",(r,i,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:r,request:i,chainId:n}),this.records.has(i.id))return;const o={id:i.id,topic:r,request:{method:i.method,params:i.params||null},chainId:n,expiry:Xi(q.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(zt.created,o)}),et(this,"resolve",async r=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:r}),!this.records.has(r.id))return;const i=await this.getRecord(r.id);typeof i.response>"u"&&(i.response=is(r)?{error:r.error}:{result:r.result},this.records.set(i.id,i),this.persist(),this.events.emit(zt.updated,i))}),et(this,"get",async(r,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:r,id:i}),await this.getRecord(i))),et(this,"delete",(r,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(n=>{if(n.topic===r){if(typeof i<"u"&&n.id!==i)return;this.records.delete(n.id),this.events.emit(zt.deleted,n)}}),this.persist()}),et(this,"exists",async(r,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===r:!1)),et(this,"on",(r,i)=>{this.events.on(r,i)}),et(this,"once",(r,i)=>{this.events.once(r,i)}),et(this,"off",(r,i)=>{this.events.off(r,i)}),et(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ht(s,this.name)}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(s=>{if(typeof s.response<"u")return;const r={topic:s.topic,request:er(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const s=this.records.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(zt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(zt.created,e=>{const s=zt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(zt.updated,e=>{const s=zt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(zt.deleted,e=>{const s=zt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(vi.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{q.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(zt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var fv=Object.defineProperty,gv=(t,e,s)=>e in t?fv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,rt=(t,e,s)=>gv(t,typeof e!="symbol"?e+"":e,s);let mv=class extends pg{constructor(e,s){super(e,s),this.core=e,this.logger=s,rt(this,"expirations",new Map),rt(this,"events",new gr.EventEmitter),rt(this,"name",wy),rt(this,"version",yy),rt(this,"cached",[]),rt(this,"initialized",!1),rt(this,"storagePrefix",cs),rt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.expirations.set(r.target,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),rt(this,"has",r=>{try{const i=this.formatTarget(r);return typeof this.getExpiration(i)<"u"}catch{return!1}}),rt(this,"set",(r,i)=>{this.isInitialized();const n=this.formatTarget(r),o={target:n,expiry:i};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Mt.created,{target:n,expiration:o})}),rt(this,"get",r=>{this.isInitialized();const i=this.formatTarget(r);return this.getExpiration(i)}),rt(this,"del",r=>{if(this.isInitialized(),this.has(r)){const i=this.formatTarget(r),n=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Mt.deleted,{target:i,expiration:n})}}),rt(this,"on",(r,i)=>{this.events.on(r,i)}),rt(this,"once",(r,i)=>{this.events.once(r,i)}),rt(this,"off",(r,i)=>{this.events.off(r,i)}),rt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ht(s,this.name)}get context(){return xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return xg(e);if(typeof e=="number")return kg(e);const{message:s}=be("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Mt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=be("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const s=this.expirations.get(e);if(!s){const{message:r}=be("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return s}checkExpiry(e,s){const{expiry:r}=s;q.toMiliseconds(r)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(Mt.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(vi.pulse,()=>this.checkExpirations()),this.events.on(Mt.created,e=>{const s=Mt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(Mt.expired,e=>{const s=Mt.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(Mt.deleted,e=>{const s=Mt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=be("NOT_INITIALIZED",this.name);throw new Error(e)}}};var wv=Object.defineProperty,yv=(t,e,s)=>e in t?wv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Be=(t,e,s)=>yv(t,typeof e!="symbol"?e+"":e,s);let bv=class extends fg{constructor(e,s,r){super(e,s,r),this.core=e,this.logger=s,this.store=r,Be(this,"name",by),Be(this,"abortController"),Be(this,"isDevEnv"),Be(this,"verifyUrlV3",Ey),Be(this,"storagePrefix",cs),Be(this,"version",vd),Be(this,"publicKey"),Be(this,"fetchPromise"),Be(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&q.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Be(this,"register",async i=>{if(!Cn()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const l=$t.getDocument(),u=this.startAbortTimer(q.ONE_SECOND*5),h=await new Promise((d,f)=>{const y=()=>{window.removeEventListener("message",p),l.body.removeChild(g),f("attestation aborted")};this.abortController.signal.addEventListener("abort",y);const g=l.createElement("iframe");g.src=c,g.style.display="none",g.addEventListener("error",y,{signal:this.abortController.signal});const p=m=>{if(m.data&&typeof m.data=="string")try{const w=JSON.parse(m.data);if(w.type==="verify_attestation"){if(Sa(w.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(g),this.abortController.signal.removeEventListener("abort",y),window.removeEventListener("message",p),d(w.attestation===null?"":w.attestation)}}catch(w){this.logger.warn(w)}};l.body.appendChild(g),window.addEventListener("message",p,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(l){this.logger.warn(l)}return""}),Be(this,"resolve",async i=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=i;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(Sa(n).payload.id!==a)return;const l=await this.isValidJwtAttestation(n);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),Be(this,"fetchAttestation",async(i,n)=>{this.logger.debug(`resolving attestation: ${i} from url: ${n}`);const o=this.startAbortTimer(q.ONE_SECOND*5),a=await fetch(`${n}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),Be(this,"getVerifyUrl",i=>{let n=i||en;return Cy.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${en}`),n=en),n}),Be(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(q.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await n.json()}catch(i){this.logger.warn(i)}}),Be(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),Be(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Be(this,"isValidJwtAttestation",async i=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(i,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),Be(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Be(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i}),Be(this,"validateAttestation",(i,n)=>{const o=xw(i,n.publicKey),a={hasExpired:q.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=ht(s,this.name),this.abortController=new AbortController,this.isDevEnv=jh(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return xt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),q.toMiliseconds(e))}};var vv=Object.defineProperty,Ev=(t,e,s)=>e in t?vv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ql=(t,e,s)=>Ev(t,typeof e!="symbol"?e+"":e,s);let Cv=class extends gg{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,Ql(this,"context",Iy),Ql(this,"registerDeviceToken",async r=>{const{clientId:i,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${Ay}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:n,always_raw:a})})}),this.logger=ht(s,this.context)}};var Iv=Object.defineProperty,eu=Object.getOwnPropertySymbols,Av=Object.prototype.hasOwnProperty,Nv=Object.prototype.propertyIsEnumerable,Qa=(t,e,s)=>e in t?Iv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ri=(t,e)=>{for(var s in e||(e={}))Av.call(e,s)&&Qa(t,s,e[s]);if(eu)for(var s of eu(e))Nv.call(e,s)&&Qa(t,s,e[s]);return t},je=(t,e,s)=>Qa(t,typeof e!="symbol"?e+"":e,s);class _v extends mg{constructor(e,s,r=!0){super(e,s,r),this.core=e,this.logger=s,je(this,"context",_y),je(this,"storagePrefix",cs),je(this,"storageVersion",Ny),je(this,"events",new Map),je(this,"shouldPersist",!1),je(this,"init",async()=>{if(!jh())try{const i={eventId:nl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Mh(this.core.relayer.protocol,this.core.relayer.version,Wa)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),je(this,"createEvent",i=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=nl(),u=this.core.projectId||"",h=Date.now(),d=Ri({eventId:l,timestamp:h,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d}),je(this,"getEvent",i=>{const{eventId:n,topic:o}=i;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Ri(Ri({},a),this.setMethods(a.eventId))}),je(this,"deleteEvent",i=>{const{eventId:n}=i;this.events.delete(n),this.shouldPersist=!0}),je(this,"setEventListeners",()=>{this.core.heartbeat.on(vi.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{q.fromMiliseconds(Date.now())-q.fromMiliseconds(i.timestamp)>Sy&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),je(this,"setMethods",i=>({addTrace:n=>this.addTrace(i,n),setError:n=>this.setError(i,n)})),je(this,"addTrace",(i,n)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(n),this.events.set(i,o),this.shouldPersist=!0)}),je(this,"setError",(i,n)=>{const o=this.events.get(i);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)}),je(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),je(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(n=>{this.events.set(n.eventId,Ri(Ri({},n),this.setMethods(n.eventId)))})}catch(i){this.logger.warn(i)}}),je(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[n,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const n of i)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),je(this,"sendEvent",async i=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${Py}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Wa}${n}`,{method:"POST",body:JSON.stringify(i)})}),je(this,"getAppDomain",()=>Sg().url),this.logger=ht(s,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Sv=Object.defineProperty,tu=Object.getOwnPropertySymbols,Pv=Object.prototype.hasOwnProperty,Ov=Object.prototype.propertyIsEnumerable,ec=(t,e,s)=>e in t?Sv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,su=(t,e)=>{for(var s in e||(e={}))Pv.call(e,s)&&ec(t,s,e[s]);if(tu)for(var s of tu(e))Ov.call(e,s)&&ec(t,s,e[s]);return t},$e=(t,e,s)=>ec(t,typeof e!="symbol"?e+"":e,s);let $v=class Rd extends rg{constructor(e){var s;super(e),$e(this,"protocol",bd),$e(this,"version",vd),$e(this,"name",Ha),$e(this,"relayUrl"),$e(this,"projectId"),$e(this,"customStoragePrefix"),$e(this,"events",new gr.EventEmitter),$e(this,"logger"),$e(this,"heartbeat"),$e(this,"relayer"),$e(this,"crypto"),$e(this,"storage"),$e(this,"history"),$e(this,"expirer"),$e(this,"pairing"),$e(this,"verify"),$e(this,"echoClient"),$e(this,"linkModeSupportedApps"),$e(this,"eventClient"),$e(this,"initialized",!1),$e(this,"logChunkController"),$e(this,"on",(a,c)=>this.events.on(a,c)),$e(this,"once",(a,c)=>this.events.once(a,c)),$e(this,"off",(a,c)=>this.events.off(a,c)),$e(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),$e(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:Te.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const r=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Cd,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=bn({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Yw.logger,name:Ha}),{logger:n,chunkLoggerController:o}=Oh({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(s=this.logChunkController)!=null&&s.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=ht(n,this.name),this.heartbeat=new Zp,this.crypto=new r0(this,this.logger,e==null?void 0:e.keychain),this.history=new pv(this,this.logger),this.expirer=new mv(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Xp(su(su({},Zw),e==null?void 0:e.storageOptions)),this.relayer=new $0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new uv(this,this.logger),this.verify=new bv(this,this.logger,this.storage),this.echoClient=new Cv(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new _v(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new Rd(e);await s.initialize();const r=await s.crypto.getClientId();return await s.storage.setItem(uy,r),s}get context(){return xt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Ul,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Ul)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,r=`${s}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[r]=e}catch(r){console.warn("Failed to set global WalletConnect core",r)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&Jw.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const Tv=$v;function dn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ru(t){return dn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Ud="2.23.2";let Ui={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${Ud}`};class hr extends Error{constructor(e,s={}){var a;const r=(()=>{var c;return s.cause instanceof hr?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),i=s.cause instanceof hr&&s.cause.docsPath||s.docsPath,n=(a=Ui.getDocsUrl)==null?void 0:a.call(Ui,{...s,docsPath:i}),o=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...r?[`Details: ${r}`]:[],...Ui.version?[`Version: ${Ui.version}`]:[]].join(`
|
|
5
|
+
`);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{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,"metaMessages",{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,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=Ud}walk(e){return Dd(this,e)}}function Dd(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Dd(t.cause,e):e?null:t}class Ld extends hr{constructor({size:e,targetSize:s,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function Ai(t,{dir:e,size:s=32}={}){return typeof t=="string"?xv(t,{dir:e,size:s}):kv(t,{dir:e,size:s})}function xv(t,{dir:e,size:s=32}={}){if(s===null)return t;const r=t.replace("0x","");if(r.length>s*2)throw new Ld({size:Math.ceil(r.length/2),targetSize:s,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function kv(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Ld({size:t.length,targetSize:s,type:"bytes"});const r=new Uint8Array(s);for(let i=0;i<s;i++){const n=e==="right";r[n?i:s-i-1]=t[n?i:t.length-i-1]}return r}class Rv extends hr{constructor({max:e,min:s,signed:r,size:i,value:n}){super(`Number "${n}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Uv extends hr{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Ni(t,{size:e}){if(ru(t)>e)throw new Uv({givenSize:ru(t),maxSize:e})}function tc(t,e={}){const{signed:s}=e;e.size&&Ni(t,{size:e.size});const r=BigInt(t);if(!s)return r;const i=(t.length-2)/2,n=(1n<<BigInt(i)*8n-1n)-1n;return r<=n?r:r-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function Dv(t,e={}){return Number(tc(t,e))}const Lv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function sc(t,e={}){return typeof t=="number"||typeof t=="bigint"?Md(t,e):typeof t=="string"?qv(t,e):typeof t=="boolean"?Bv(t,e):Bd(t,e)}function Bv(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(Ni(s,{size:e.size}),Ai(s,{size:e.size})):s}function Bd(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=Lv[t[i]];const r=`0x${s}`;return typeof e.size=="number"?(Ni(r,{size:e.size}),Ai(r,{dir:"right",size:e.size})):r}function Md(t,e={}){const{signed:s,size:r}=e,i=BigInt(t);let n;r?s?n=(1n<<BigInt(r)*8n-1n)-1n:n=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&s?-n-1n:0;if(n&&i>n||i<o){const c=typeof t=="bigint"?"n":"";throw new Rv({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:s,size:r,value:`${t}${c}`})}const a=`0x${(s&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?Ai(a,{size:r}):a}const Mv=new TextEncoder;function qv(t,e={}){const s=Mv.encode(t);return Bd(s,e)}const jv=new TextEncoder;function Fv(t,e={}){return typeof t=="number"||typeof t=="bigint"?Hv(t,e):typeof t=="boolean"?zv(t,e):dn(t)?qd(t,e):jd(t,e)}function zv(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(Ni(s,{size:e.size}),Ai(s,{size:e.size})):s}const ds={zero:48,nine:57,A:65,F:70,a:97,f:102};function iu(t){if(t>=ds.zero&&t<=ds.nine)return t-ds.zero;if(t>=ds.A&&t<=ds.F)return t-(ds.A-10);if(t>=ds.a&&t<=ds.f)return t-(ds.a-10)}function qd(t,e={}){let s=t;e.size&&(Ni(s,{size:e.size}),s=Ai(s,{dir:"right",size:e.size}));let r=s.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,n=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=iu(r.charCodeAt(a++)),l=iu(r.charCodeAt(a++));if(c===void 0||l===void 0)throw new hr(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);n[o]=c*16+l}return n}function Hv(t,e){const s=Md(t,e);return qd(s)}function jd(t,e={}){const s=jv.encode(t);return typeof e.size=="number"?(Ni(s,{size:e.size}),Ai(s,{dir:"right",size:e.size})):s}function ao(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Wv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function No(t,...e){if(!Wv(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function H_(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ao(t.outputLen),ao(t.blockLen)}function nu(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Vv(t,e){No(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Bn=BigInt(2**32-1),ou=BigInt(32);function Kv(t,e=!1){return e?{h:Number(t&Bn),l:Number(t>>ou&Bn)}:{h:Number(t>>ou&Bn)|0,l:Number(t&Bn)|0}}function Gv(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=Kv(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Jv=(t,e,s)=>t<<s|e>>>32-s,Yv=(t,e,s)=>e<<s|t>>>32-s,Zv=(t,e,s)=>e<<s-32|t>>>64-s,Xv=(t,e,s)=>t<<s-32|e>>>64-s,_r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Qv(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function W_(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function V_(t,e){return t<<32-e|t>>>e}const au=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function eE(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function cu(t){for(let e=0;e<t.length;e++)t[e]=eE(t[e])}function tE(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Fd(t){return typeof t=="string"&&(t=tE(t)),No(t),t}function K_(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];No(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}class sE{clone(){return this._cloneInto()}}function rE(t){const e=r=>t().update(Fd(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function G_(t=32){if(_r&&typeof _r.getRandomValues=="function")return _r.getRandomValues(new Uint8Array(t));if(_r&&typeof _r.randomBytes=="function")return _r.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const zd=[],Hd=[],Wd=[],iE=BigInt(0),Di=BigInt(1),nE=BigInt(2),oE=BigInt(7),aE=BigInt(256),cE=BigInt(113);for(let t=0,e=Di,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],zd.push(2*(5*r+s)),Hd.push((t+1)*(t+2)/2%64);let i=iE;for(let n=0;n<7;n++)e=(e<<Di^(e>>oE)*cE)%aE,e&nE&&(i^=Di<<(Di<<BigInt(n))-Di);Wd.push(i)}const[lE,uE]=Gv(Wd,!0),lu=(t,e,s)=>s>32?Zv(t,e,s):Jv(t,e,s),uu=(t,e,s)=>s>32?Xv(t,e,s):Yv(t,e,s);function hE(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=lu(l,u,1)^s[a],d=uu(l,u,1)^s[a+1];for(let f=0;f<50;f+=10)t[o+f]^=h,t[o+f+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Hd[o],c=lu(i,n,a),l=uu(i,n,a),u=zd[o];i=t[u],n=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=lE[r],t[1]^=uE[r]}s.fill(0)}class Pc extends sE{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ao(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Qv(this.state)}keccak(){au||cu(this.state32),hE(this.state32,this.rounds),au||cu(this.state32),this.posOut=0,this.pos=0}update(e){nu(this);const{blockLen:s,state:r}=this;e=Fd(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,(s&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){nu(this,!1),No(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ao(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Vv(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new Pc(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const dE=(t,e,s)=>rE(()=>new Pc(e,t,s)),pE=dE(1,136,256/8);function Vd(t,e){const s=e||"hex",r=pE(dn(t,{strict:!1})?Fv(t):t);return s==="bytes"?r:sc(r)}class fE extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ta=new fE(8192);function gE(t,e){if(ta.has(`${t}.${e}`))return ta.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),r=Vd(jd(s),"bytes"),i=s.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(r[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const n=`0x${i.join("")}`;return ta.set(`${t}.${e}`,n),n}function mE(t){const e=Vd(`0x${t.substring(4)}`).substring(26);return gE(`0x${e}`)}async function wE({hash:t,signature:e}){const s=dn(t)?t:sc(t),{secp256k1:r}=await _a(async()=>{const{secp256k1:o}=await import("./secp256k1-DffysWcZ.js");return{secp256k1:o}},__vite__mapDeps([0,1,2,3,4]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:h,yParity:d}=e,f=Number(d??h),y=hu(f);return new r.Signature(tc(l),tc(u)).addRecoveryBit(y)}const o=dn(e)?e:sc(e),a=Dv(`0x${o.slice(130)}`),c=hu(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(s.substring(2)).toHex(!1)}`}function hu(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function yE({hash:t,signature:e}){return mE(await wE({hash:t,signature:e}))}var bE={};const vE=":";function ei(t){const[e,s]=t.split(vE);return{namespace:e,reference:s}}function Kd(t,e){return t.includes(":")?[t]:e.chains||[]}var EE=Object.defineProperty,CE=Object.defineProperties,IE=Object.getOwnPropertyDescriptors,du=Object.getOwnPropertySymbols,AE=Object.prototype.hasOwnProperty,NE=Object.prototype.propertyIsEnumerable,pu=(t,e,s)=>e in t?EE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,fu=(t,e)=>{for(var s in e||(e={}))AE.call(e,s)&&pu(t,s,e[s]);if(du)for(var s of du(e))NE.call(e,s)&&pu(t,s,e[s]);return t},_E=(t,e)=>CE(t,IE(e));const SE="ReactNative",Yr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function Gd(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Jd(){return!$t.getDocument()&&!!$t.getNavigator()&&navigator.product===SE}function Yd(){return!Gd()&&!!$t.getNavigator()&&!!$t.getDocument()}function PE(){return Jd()?Yr.reactNative:Gd()?Yr.node:Yd()?Yr.browser:Yr.unknown}function OE(t){var e,s;const r=$E();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),_E(fu(fu({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),t||r}}function $E(){return Ph.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function tr(t,e){return t.filter(s=>e.includes(s)).length===t.length}function Sr(t=q.FIVE_MINUTES,e){const s=q.toMiliseconds(t||q.FIVE_MINUTES);let r,i,n,o;return{resolve:a=>{n&&r&&(clearTimeout(n),r(a),o=Promise.resolve(a))},reject:a=>{n&&i&&(clearTimeout(n),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),r=a,i=c})}}function TE(t){const[e,s]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")r.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))r.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return r}function mt(t,e){return q.fromMiliseconds(Date.now()+q.toMiliseconds(t))}function Pr(t){return Date.now()>=q.toMiliseconds(t)}function _e(t,e){return`${t}${e?`:${e}`:""}`}function as(t=[],e=[]){return[...new Set([...t,...e])]}async function xE({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i==null?void 0:i.href;if(typeof n!="string")return;const o=kE(n,t,e),a=PE();if(a===Yr.browser){if(!((r=$t.getDocument())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}RE(o)}else a===Yr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function kE(t,e,s){const r=`requestId=${e}&sessionTopic=${s}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${n}${ME(r,!0)}`}else i=`${i}/wc?${r}`;return i}function RE(t){let e="_self";BE()?e="_top":(LE()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function UE(t,e){let s="";try{if(Yd()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function gu(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function DE(){return typeof process<"u"&&bE.IS_VITEST==="true"}function LE(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function BE(){try{return window.self!==window.top}catch{return!1}}function ME(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function co(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function qE(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pn(t,...e){if(!qE(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function jE(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");co(t.outputLen),co(t.blockLen)}function hi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Zd(t,e){Pn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Mn=BigInt(2**32-1),mu=BigInt(32);function FE(t,e=!1){return e?{h:Number(t&Mn),l:Number(t>>mu&Mn)}:{h:Number(t>>mu&Mn)|0,l:Number(t&Mn)|0}}function zE(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=FE(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const HE=(t,e,s)=>t<<s|e>>>32-s,WE=(t,e,s)=>e<<s|t>>>32-s,VE=(t,e,s)=>e<<s-32|t>>>64-s,KE=(t,e,s)=>t<<s-32|e>>>64-s,Or=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function GE(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function sa(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ts(t,e){return t<<32-e|t>>>e}const wu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function JE(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function yu(t){for(let e=0;e<t.length;e++)t[e]=JE(t[e])}function YE(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function _o(t){return typeof t=="string"&&(t=YE(t)),Pn(t),t}function ZE(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Pn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let Oc=class{clone(){return this._cloneInto()}};function Xd(t){const e=r=>t().update(_o(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Qd(t=32){if(Or&&typeof Or.getRandomValues=="function")return Or.getRandomValues(new Uint8Array(t));if(Or&&typeof Or.randomBytes=="function")return Or.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ep=[],tp=[],sp=[],XE=BigInt(0),Li=BigInt(1),QE=BigInt(2),e1=BigInt(7),t1=BigInt(256),s1=BigInt(113);for(let t=0,e=Li,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],ep.push(2*(5*r+s)),tp.push((t+1)*(t+2)/2%64);let i=XE;for(let n=0;n<7;n++)e=(e<<Li^(e>>e1)*s1)%t1,e&QE&&(i^=Li<<(Li<<BigInt(n))-Li);sp.push(i)}const[r1,i1]=zE(sp,!0),bu=(t,e,s)=>s>32?VE(t,e,s):HE(t,e,s),vu=(t,e,s)=>s>32?KE(t,e,s):WE(t,e,s);function n1(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=bu(l,u,1)^s[a],d=vu(l,u,1)^s[a+1];for(let f=0;f<50;f+=10)t[o+f]^=h,t[o+f+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=tp[o],c=bu(i,n,a),l=vu(i,n,a),u=ep[o];i=t[u],n=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=r1[r],t[1]^=i1[r]}s.fill(0)}class $c extends Oc{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,co(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=GE(this.state)}keccak(){wu||yu(this.state32),n1(this.state32,this.rounds),wu||yu(this.state32),this.posOut=0,this.pos=0}update(e){hi(this);const{blockLen:s,state:r}=this;e=_o(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);for(let a=0;a<o;a++)r[this.pos++]^=e[n++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:r,blockLen:i}=this;e[r]^=s,(s&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){hi(this,!1),Pn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return co(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:s,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||(e=new $c(s,r,i,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const o1=(t,e,s)=>Xd(()=>new $c(e,t,s)),a1=o1(1,136,256/8),c1="https://rpc.walletconnect.org/v1";function rp(t){const e=`Ethereum Signed Message:
|
|
6
|
+
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(a1(s)).toString("hex")}async function l1(t,e,s,r,i,n){switch(s.t){case"eip191":return await u1(t,e,s.s);case"eip1271":return await h1(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function u1(t,e,s){return(await yE({hash:rp(e),signature:s})).toLowerCase()===t.toLowerCase()}async function h1(t,e,s,r,i,n){const o=ei(r);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=s.substring(2),h=rp(e).substring(2),d=a+h+c+l+u,f=await fetch(`${n||c1}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:d1(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:y}=await f.json();return y?y.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function d1(){return Date.now()+Math.floor(Math.random()*1e3)}function p1(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const r=s[0];if(r===0)throw new Error("No signatures found");const i=1+r*64;if(s.length<i)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return Th.encode(n)}var f1=Object.defineProperty,g1=Object.defineProperties,m1=Object.getOwnPropertyDescriptors,Eu=Object.getOwnPropertySymbols,w1=Object.prototype.hasOwnProperty,y1=Object.prototype.propertyIsEnumerable,Cu=(t,e,s)=>e in t?f1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,b1=(t,e)=>{for(var s in e||(e={}))w1.call(e,s)&&Cu(t,s,e[s]);if(Eu)for(var s of Eu(e))y1.call(e,s)&&Cu(t,s,e[s]);return t},v1=(t,e)=>g1(t,m1(e));const E1="did:pkh:",Tc=t=>t==null?void 0:t.split(":"),C1=t=>{const e=t&&Tc(t);if(e)return t.includes(E1)?e[3]:e[1]},rc=t=>{const e=t&&Tc(t);if(e)return e[2]+":"+e[3]},lo=t=>{const e=t&&Tc(t);if(e)return e.pop()};async function Iu(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=ip(i,i.iss),o=lo(i.iss);return await l1(o,n,r,rc(i.iss),s)}const ip=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=lo(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${C1(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,f=t.resources?`Resources:${t.resources.map(g=>`
|
|
7
|
+
- ${g}`).join("")}`:void 0,y=Xn(t.resources);if(y){const g=pn(y);i=T1(i,g)}return[s,r,"",i,"",n,o,a,c,l,u,h,d,f].filter(g=>g!=null).join(`
|
|
8
|
+
`)};function I1(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function A1(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function dr(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(s=>{const r=t.att[s];if(Array.isArray(r))throw new Error(`Resource must be an object: ${s}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${s}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${s}`);Object.keys(r).forEach(i=>{const n=r[i];if(!Array.isArray(n))throw new Error(`Ability limits ${i} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function N1(t,e,s,r={}){return s==null||s.sort((i,n)=>i.localeCompare(n)),{att:{[t]:_1(e,s,r)}}}function _1(t,e,s={}){e=e==null?void 0:e.sort((i,n)=>i.localeCompare(n));const r=e.map(i=>({[`${t}/${i}`]:[s]}));return Object.assign({},...r)}function np(t){return dr(t),`urn:recap:${I1(t).replace(/=/g,"")}`}function pn(t){const e=A1(t.replace("urn:recap:",""));return dr(e),e}function S1(t,e,s){const r=N1(t,e,s);return np(r)}function P1(t){return t&&t.includes("urn:recap:")}function O1(t,e){const s=pn(t),r=pn(e),i=$1(s,r);return np(i)}function $1(t,e){dr(t),dr(e);const s=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,n)=>i.localeCompare(n)),r={att:{}};return s.forEach(i=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;r.att[i]=v1(b1({},r.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),r}function T1(t="",e){dr(e);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(s))return t;const r=[];let i=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));c.sort((h,d)=>h.action.localeCompare(d.action));const l={};c.forEach(h=>{l[h.ability]||(l[h.ability]=[]),l[h.ability].push(h.action)});const u=Object.keys(l).map(h=>(i++,`(${i}) '${h}': '${l[h].join("', '")}' for '${a}'.`));r.push(u.join(", ").replace(".,","."))});const n=r.join(" "),o=`${s}${n}`;return`${t?t+" ":""}${o}`}function Au(t){var e;const s=pn(t);dr(s);const r=(e=s.att)==null?void 0:e.eip155;return r?Object.keys(r).map(i=>i.split("/")[1]):[]}function Nu(t){const e=pn(t);dr(e);const s=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(i=>{var n;(n=i==null?void 0:i[0])!=null&&n.chains&&s.push(i[0].chains)})}),[...new Set(s.flat())]}function Xn(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return P1(e)?e:void 0}function ra(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function op(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ot(t,...e){if(!op(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function _u(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function x1(t,e){Ot(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Su(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ls=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),k1=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),R1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!R1)throw new Error("Non little-endian hardware is not supported");function U1(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ic(t){if(typeof t=="string")t=U1(t);else if(op(t))t=nc(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function D1(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function L1(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}const B1=(t,e)=>{function s(r,...i){if(Ot(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?Ot(l):Ot(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&Ot(i[1]);const o=e(r,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");Ot(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Ot(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(Ot(l),n&&l.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(s,t),s};function Pu(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!M1(e))throw new Error("invalid output, must be aligned");return e}function Ou(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n);t.setUint32(e+4,o,r),t.setUint32(e+0,a,r)}function M1(t){return t.byteOffset%4===0}function nc(t){return Uint8Array.from(t)}function di(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const ap=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),q1=ap("expand 16-byte k"),j1=ap("expand 32-byte k"),F1=Ls(q1),z1=Ls(j1);function me(t,e){return t<<e|t>>>32-e}function oc(t){return t.byteOffset%4===0}const qn=64,H1=16,cp=2**32-1,$u=new Uint32Array;function W1(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(qn),u=Ls(l),h=oc(i)&&oc(n),d=h?Ls(i):$u,f=h?Ls(n):$u;for(let y=0;y<c;o++){if(t(e,s,r,u,o,a),o>=cp)throw new Error("arx: counter overflow");const g=Math.min(qn,c-y);if(h&&g===qn){const p=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let m=0,w;m<H1;m++)w=p+m,f[w]=d[w]^u[m];y+=qn;continue}for(let p=0,m;p<g;p++)m=y+p,n[m]=i[m]^l[p];y+=g}}function V1(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=D1({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return ra(i),ra(o),Su(n),Su(s),(a,c,l,u,h=0)=>{Ot(a),Ot(c),Ot(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),Ot(u),ra(h),h<0||h>=cp)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const f=[];let y=a.length,g,p;if(y===32)f.push(g=nc(a)),p=z1;else if(y===16&&s)g=new Uint8Array(32),g.set(a),g.set(a,16),p=F1,f.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);oc(c)||f.push(c=nc(c));const m=Ls(g);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,Ls(c.subarray(0,16)),m),c=c.subarray(16)}const w=16-i;if(w!==c.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const P=new Uint8Array(12);P.set(c,n?0:12-c.length),c=P,f.push(c)}const C=Ls(c);return W1(t,p,m,C,l,u,h,o),di(...f),u}}const tt=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class K1{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=ic(e),Ot(e,32);const s=tt(e,0),r=tt(e,2),i=tt(e,4),n=tt(e,6),o=tt(e,8),a=tt(e,10),c=tt(e,12),l=tt(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=tt(e,16+2*u)}process(e,s,r=!1){const i=r?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],f=o[6],y=o[7],g=o[8],p=o[9],m=tt(e,s+0),w=tt(e,s+2),C=tt(e,s+4),P=tt(e,s+6),R=tt(e,s+8),O=tt(e,s+10),S=tt(e,s+12),$=tt(e,s+14);let v=n[0]+(m&8191),T=n[1]+((m>>>13|w<<3)&8191),_=n[2]+((w>>>10|C<<6)&8191),k=n[3]+((C>>>7|P<<9)&8191),L=n[4]+((P>>>4|R<<12)&8191),E=n[5]+(R>>>1&8191),A=n[6]+((R>>>14|O<<2)&8191),I=n[7]+((O>>>11|S<<5)&8191),x=n[8]+((S>>>8|$<<8)&8191),U=n[9]+($>>>5|i),N=0,M=N+v*a+T*(5*p)+_*(5*g)+k*(5*y)+L*(5*f);N=M>>>13,M&=8191,M+=E*(5*d)+A*(5*h)+I*(5*u)+x*(5*l)+U*(5*c),N+=M>>>13,M&=8191;let j=N+v*c+T*a+_*(5*p)+k*(5*g)+L*(5*y);N=j>>>13,j&=8191,j+=E*(5*f)+A*(5*d)+I*(5*h)+x*(5*u)+U*(5*l),N+=j>>>13,j&=8191;let F=N+v*l+T*c+_*a+k*(5*p)+L*(5*g);N=F>>>13,F&=8191,F+=E*(5*y)+A*(5*f)+I*(5*d)+x*(5*h)+U*(5*u),N+=F>>>13,F&=8191;let X=N+v*u+T*l+_*c+k*a+L*(5*p);N=X>>>13,X&=8191,X+=E*(5*g)+A*(5*y)+I*(5*f)+x*(5*d)+U*(5*h),N+=X>>>13,X&=8191;let G=N+v*h+T*u+_*l+k*c+L*a;N=G>>>13,G&=8191,G+=E*(5*p)+A*(5*g)+I*(5*y)+x*(5*f)+U*(5*d),N+=G>>>13,G&=8191;let oe=N+v*d+T*h+_*u+k*l+L*c;N=oe>>>13,oe&=8191,oe+=E*a+A*(5*p)+I*(5*g)+x*(5*y)+U*(5*f),N+=oe>>>13,oe&=8191;let le=N+v*f+T*d+_*h+k*u+L*l;N=le>>>13,le&=8191,le+=E*c+A*a+I*(5*p)+x*(5*g)+U*(5*y),N+=le>>>13,le&=8191;let Ie=N+v*y+T*f+_*d+k*h+L*u;N=Ie>>>13,Ie&=8191,Ie+=E*l+A*c+I*a+x*(5*p)+U*(5*g),N+=Ie>>>13,Ie&=8191;let ue=N+v*g+T*y+_*f+k*d+L*h;N=ue>>>13,ue&=8191,ue+=E*u+A*l+I*c+x*a+U*(5*p),N+=ue>>>13,ue&=8191;let he=N+v*p+T*g+_*y+k*f+L*d;N=he>>>13,he&=8191,he+=E*h+A*u+I*l+x*c+U*a,N+=he>>>13,he&=8191,N=(N<<2)+N|0,N=N+M|0,M=N&8191,N=N>>>13,j+=N,n[0]=M,n[1]=j,n[2]=F,n[3]=X,n[4]=G,n[5]=oe,n[6]=le,n[7]=Ie,n[8]=ue,n[9]=he}finalize(){const{h:e,pad:s}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let n=(i^1)-1;for(let a=0;a<10;a++)r[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|r[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;di(r)}update(e){_u(this);const{buffer:s,blockLen:r}=this;e=ic(e);const i=e.length;for(let n=0;n<i;){const o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){di(this.h,this.r,this.buffer,this.pad)}digestInto(e){_u(this),x1(e,this),this.finished=!0;const{buffer:s,h:r}=this;let{pos:i}=this;if(i){for(s[i++]=1;i<16;i++)s[i]=0;this.process(s,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}}function G1(t){const e=(r,i)=>t(i).update(ic(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const J1=G1(t=>new K1(t));function Y1(t,e,s,r,i,n=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],f=e[3],y=e[4],g=e[5],p=e[6],m=e[7],w=i,C=s[0],P=s[1],R=s[2],O=o,S=a,$=c,v=l,T=u,_=h,k=d,L=f,E=y,A=g,I=p,x=m,U=w,N=C,M=P,j=R;for(let X=0;X<n;X+=2)O=O+T|0,U=me(U^O,16),E=E+U|0,T=me(T^E,12),O=O+T|0,U=me(U^O,8),E=E+U|0,T=me(T^E,7),S=S+_|0,N=me(N^S,16),A=A+N|0,_=me(_^A,12),S=S+_|0,N=me(N^S,8),A=A+N|0,_=me(_^A,7),$=$+k|0,M=me(M^$,16),I=I+M|0,k=me(k^I,12),$=$+k|0,M=me(M^$,8),I=I+M|0,k=me(k^I,7),v=v+L|0,j=me(j^v,16),x=x+j|0,L=me(L^x,12),v=v+L|0,j=me(j^v,8),x=x+j|0,L=me(L^x,7),O=O+_|0,j=me(j^O,16),I=I+j|0,_=me(_^I,12),O=O+_|0,j=me(j^O,8),I=I+j|0,_=me(_^I,7),S=S+k|0,U=me(U^S,16),x=x+U|0,k=me(k^x,12),S=S+k|0,U=me(U^S,8),x=x+U|0,k=me(k^x,7),$=$+L|0,N=me(N^$,16),E=E+N|0,L=me(L^E,12),$=$+L|0,N=me(N^$,8),E=E+N|0,L=me(L^E,7),v=v+T|0,M=me(M^v,16),A=A+M|0,T=me(T^A,12),v=v+T|0,M=me(M^v,8),A=A+M|0,T=me(T^A,7);let F=0;r[F++]=o+O|0,r[F++]=a+S|0,r[F++]=c+$|0,r[F++]=l+v|0,r[F++]=u+T|0,r[F++]=h+_|0,r[F++]=d+k|0,r[F++]=f+L|0,r[F++]=y+E|0,r[F++]=g+A|0,r[F++]=p+I|0,r[F++]=m+x|0,r[F++]=w+U|0,r[F++]=C+N|0,r[F++]=P+M|0,r[F++]=R+j|0}const Z1=V1(Y1,{counterRight:!1,counterLength:4,allowShortKeys:!1}),X1=new Uint8Array(16),Tu=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(X1.subarray(s))},Q1=new Uint8Array(32);function xu(t,e,s,r,i){const n=t(e,s,Q1),o=J1.create(n);i&&Tu(o,i),Tu(o,r);const a=new Uint8Array(16),c=k1(a);Ou(c,0,BigInt(i?i.length:0),!0),Ou(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return di(n,a),l}const eC=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=Pu(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=xu(t,e,s,a,r);return n.set(c,o),di(c),n},decrypt(i,n){n=Pu(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=xu(t,e,s,o,r);if(!L1(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),di(c),n}});B1({blockSize:64,nonceLength:12,tagLength:16},eC(Z1));class lp extends Oc{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,jE(e);const r=_o(s);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return hi(this),this.iHash.update(e),this}digestInto(e){hi(this),Pn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const up=(t,e,s)=>new lp(t,e).update(s).digest();up.create=(t,e)=>new lp(t,e);function tC(t,e,s,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,r);const i=BigInt(32),n=BigInt(4294967295),o=Number(s>>i&n),a=Number(s&n),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function sC(t,e,s){return t&e^~t&s}function rC(t,e,s){return t&e^t&s^e&s}let iC=class extends Oc{constructor(e,s,r,i){super(),this.blockLen=e,this.outputLen=s,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=sa(this.buffer)}update(e){hi(this);const{view:s,buffer:r,blockLen:i}=this;e=_o(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(i-this.pos,n-o);if(a===i){const c=sa(e);for(;i<=n-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){hi(this),Zd(e,this),this.finished=!0;const{buffer:s,view:r,blockLen:i,isLE:n}=this;let{pos:o}=this;s[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let h=o;h<i;h++)s[h]=0;tC(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=sa(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],n)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const r=e.slice(0,s);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=n,e.destroyed=o,i%s&&e.buffer.set(r),e}};const nC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ps=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Os=new Uint32Array(64);class oC extends iC{constructor(){super(64,32,8,!1),this.A=Ps[0]|0,this.B=Ps[1]|0,this.C=Ps[2]|0,this.D=Ps[3]|0,this.E=Ps[4]|0,this.F=Ps[5]|0,this.G=Ps[6]|0,this.H=Ps[7]|0}get(){const{A:e,B:s,C:r,D:i,E:n,F:o,G:a,H:c}=this;return[e,s,r,i,n,o,a,c]}set(e,s,r,i,n,o,a,c){this.A=e|0,this.B=s|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let h=0;h<16;h++,s+=4)Os[h]=e.getUint32(s,!1);for(let h=16;h<64;h++){const d=Os[h-15],f=Os[h-2],y=ts(d,7)^ts(d,18)^d>>>3,g=ts(f,17)^ts(f,19)^f>>>10;Os[h]=g+Os[h-7]+y+Os[h-16]|0}let{A:r,B:i,C:n,D:o,E:a,F:c,G:l,H:u}=this;for(let h=0;h<64;h++){const d=ts(a,6)^ts(a,11)^ts(a,25),f=u+d+sC(a,c,l)+nC[h]+Os[h]|0,y=(ts(r,2)^ts(r,13)^ts(r,22))+rC(r,i,n)|0;u=l,l=c,c=a,a=o+f|0,o=n,n=i,i=r,r=f+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,n,o,a,c,l,u)}roundClean(){Os.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const xc=Xd(()=>new oC);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const So=BigInt(0),Po=BigInt(1),aC=BigInt(2);function pr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function On(t){if(!pr(t))throw new Error("Uint8Array expected")}function pi(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const cC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fi(t){On(t);let e="";for(let s=0;s<t.length;s++)e+=cC[t[s]];return e}function Zr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function kc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?So:BigInt("0x"+t)}const ps={_0:48,_9:57,A:65,F:70,a:97,f:102};function ku(t){if(t>=ps._0&&t<=ps._9)return t-ps._0;if(t>=ps.A&&t<=ps.F)return t-(ps.A-10);if(t>=ps.a&&t<=ps.f)return t-(ps.a-10)}function gi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(s);for(let i=0,n=0;i<s;i++,n+=2){const o=ku(t.charCodeAt(n)),a=ku(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}r[i]=o*16+a}return r}function nr(t){return kc(fi(t))}function fn(t){return On(t),kc(fi(Uint8Array.from(t).reverse()))}function mi(t,e){return gi(t.toString(16).padStart(e*2,"0"))}function Oo(t,e){return mi(t,e).reverse()}function lC(t){return gi(Zr(t))}function St(t,e,s){let r;if(typeof e=="string")try{r=gi(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(pr(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return r}function gn(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];On(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}function uC(t,e){if(t.length!==e.length)return!1;let s=0;for(let r=0;r<t.length;r++)s|=t[r]^e[r];return s===0}function hC(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const ia=t=>typeof t=="bigint"&&So<=t;function $o(t,e,s){return ia(t)&&ia(e)&&ia(s)&&e<=t&&t<s}function Es(t,e,s,r){if(!$o(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function hp(t){let e;for(e=0;t>So;t>>=Po,e+=1);return e}function dC(t,e){return t>>BigInt(e)&Po}function pC(t,e,s){return t|(s?Po:So)<<BigInt(e)}const Rc=t=>(aC<<BigInt(t-1))-Po,na=t=>new Uint8Array(t),Ru=t=>Uint8Array.from(t);function dp(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");let r=na(t),i=na(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=na())=>{i=a(Ru([0]),u),r=a(),u.length!==0&&(i=a(Ru([1]),u),r=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u<e;){r=a();const d=r.slice();h.push(d),u+=r.length}return gn(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const fC={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||pr(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function _i(t,e,s={}){const r=(i,n,o)=>{const a=fC[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+n+", got "+c)};for(const[i,n]of Object.entries(e))r(i,n,!1);for(const[i,n]of Object.entries(s))r(i,n,!0);return t}const gC=()=>{throw new Error("not implemented")};function ac(t){const e=new WeakMap;return(s,...r)=>{const i=e.get(s);if(i!==void 0)return i;const n=t(s,...r);return e.set(s,n),n}}var mC=Object.freeze({__proto__:null,isBytes:pr,abytes:On,abool:pi,bytesToHex:fi,numberToHexUnpadded:Zr,hexToNumber:kc,hexToBytes:gi,bytesToNumberBE:nr,bytesToNumberLE:fn,numberToBytesBE:mi,numberToBytesLE:Oo,numberToVarBytesBE:lC,ensureBytes:St,concatBytes:gn,equalBytes:uC,utf8ToBytes:hC,inRange:$o,aInRange:Es,bitLen:hp,bitGet:dC,bitSet:pC,bitMask:Rc,createHmacDrbg:dp,validateObject:_i,notImplemented:gC,memoized:ac});const Ye=BigInt(0),Le=BigInt(1),Xs=BigInt(2),wC=BigInt(3),cc=BigInt(4),Uu=BigInt(5),Du=BigInt(8);function bt(t,e){const s=t%e;return s>=Ye?s:e+s}function pp(t,e,s){if(e<Ye)throw new Error("invalid exponent, negatives unsupported");if(s<=Ye)throw new Error("invalid modulus");if(s===Le)return Ye;let r=Le;for(;e>Ye;)e&Le&&(r=r*t%s),t=t*t%s,e>>=Le;return r}function Gt(t,e,s){let r=t;for(;e-- >Ye;)r*=r,r%=s;return r}function lc(t,e){if(t===Ye)throw new Error("invert: expected non-zero number");if(e<=Ye)throw new Error("invert: expected positive modulus, got "+e);let s=bt(t,e),r=e,i=Ye,n=Le;for(;s!==Ye;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==Le)throw new Error("invert: does not exist");return bt(i,e)}function yC(t){const e=(t-Le)/Xs;let s,r,i;for(s=t-Le,r=0;s%Xs===Ye;s/=Xs,r++);for(i=Xs;i<t&&pp(i,e,t)!==t-Le;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+Le)/cc;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const n=(s+Le)/Xs;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,l=o.pow(o.mul(o.ONE,i),s),u=o.pow(a,n),h=o.pow(a,s);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let y=o.sqr(h);d<c&&!o.eql(y,o.ONE);d++)y=o.sqr(y);const f=o.pow(l,Le<<BigInt(c-d-1));l=o.sqr(f),u=o.mul(u,f),h=o.mul(h,l),c=d}return u}}function bC(t){if(t%cc===wC){const e=(t+Le)/cc;return function(s,r){const i=s.pow(r,e);if(!s.eql(s.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%Du===Uu){const e=(t-Uu)/Du;return function(s,r){const i=s.mul(r,Xs),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Xs),n),c=s.mul(o,s.sub(a,s.ONE));if(!s.eql(s.sqr(c),r))throw new Error("Cannot find square root");return c}}return yC(t)}const vC=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function EC(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=vC.reduce((r,i)=>(r[i]="function",r),e);return _i(t,s)}function CC(t,e,s){if(s<Ye)throw new Error("invalid exponent, negatives unsupported");if(s===Ye)return t.ONE;if(s===Le)return e;let r=t.ONE,i=e;for(;s>Ye;)s&Le&&(r=t.mul(r,i)),i=t.sqr(i),s>>=Le;return r}function IC(t,e){const s=new Array(e.length),r=e.reduce((n,o,a)=>t.is0(o)?n:(s[a]=n,t.mul(n,o)),t.ONE),i=t.inv(r);return e.reduceRight((n,o,a)=>t.is0(o)?n:(s[a]=t.mul(n,s[a]),t.mul(n,o)),i),s}function fp(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function gp(t,e,s=!1,r={}){if(t<=Ye)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=fp(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:n,MASK:Rc(i),ZERO:Ye,ONE:Le,create:c=>bt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Ye<=c&&c<t},is0:c=>c===Ye,isOdd:c=>(c&Le)===Le,neg:c=>bt(-c,t),eql:(c,l)=>c===l,sqr:c=>bt(c*c,t),add:(c,l)=>bt(c+l,t),sub:(c,l)=>bt(c-l,t),mul:(c,l)=>bt(c*l,t),pow:(c,l)=>CC(a,c,l),div:(c,l)=>bt(c*lc(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>lc(c,t),sqrt:r.sqrt||(c=>(o||(o=bC(t)),o(a,c))),invertBatch:c=>IC(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?Oo(c,n):mi(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?fn(c):nr(c)}});return Object.freeze(a)}function mp(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function wp(t){const e=mp(t);return e+Math.ceil(e/2)}function AC(t,e,s=!1){const r=t.length,i=mp(e),n=wp(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?fn(t):nr(t),a=bt(o,e-Le)+Le;return s?Oo(a,i):mi(a,i)}const Lu=BigInt(0),jn=BigInt(1);function oa(t,e){const s=e.negate();return t?s:e}function yp(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function aa(t,e){yp(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function NC(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,r)=>{if(!(s instanceof e))throw new Error("invalid point at index "+r)})}function _C(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,r)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+r)})}const ca=new WeakMap,bp=new WeakMap;function la(t){return bp.get(t)||1}function SC(t,e){return{constTimeNegate:oa,hasPrecomputes(s){return la(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>Lu;)r&jn&&(i=i.add(n)),n=n.double(),r>>=jn;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=aa(r,e),o=[];let a=s,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<n;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,r,i){const{windows:n,windowSize:o}=aa(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),u=2**s,h=BigInt(s);for(let d=0;d<n;d++){const f=d*o;let y=Number(i&l);i>>=h,y>o&&(y-=u,i+=jn);const g=f,p=f+Math.abs(y)-1,m=d%2!==0,w=y<0;y===0?c=c.add(oa(m,r[g])):a=a.add(oa(w,r[p]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=aa(s,e),c=BigInt(2**s-1),l=2**s,u=BigInt(s);for(let h=0;h<o;h++){const d=h*a;if(i===Lu)break;let f=Number(i&c);if(i>>=u,f>a&&(f-=l,i+=jn),f===0)continue;let y=r[d+Math.abs(f)-1];f<0&&(y=y.negate()),n=n.add(y)}return n},getPrecomputes(s,r,i){let n=ca.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&ca.set(r,i(n))),n},wNAFCached(s,r,i){const n=la(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=la(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){yp(r,e),bp.set(s,r),ca.delete(s)}}}function PC(t,e,s,r){if(NC(s,t),_C(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=hp(BigInt(s.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let f=0;f<r.length;f++){const y=r[f],g=Number(y>>BigInt(h)&BigInt(a));c[g]=c[g].add(s[f])}let d=i;for(let f=c.length-1,y=i;f>0;f--)y=y.add(c[f]),d=d.add(y);if(u=u.add(d),h!==0)for(let f=0;f<o;f++)u=u.double()}return u}function vp(t){return EC(t.Fp),_i(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...fp(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const $r=BigInt(0),ua=BigInt(1);function OC(t){return _i(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function $C(t){const e=OC(t),{P:s}=e,r=w=>bt(w,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>pp(w,s-BigInt(2),s));function l(w,C,P){const R=r(w*(C-P));return C=r(C-R),P=r(P+R),[C,P]}const u=(e.a-BigInt(2))/BigInt(4);function h(w,C){Es("u",w,$r,s),Es("scalar",C,$r,s);const P=C,R=w;let O=ua,S=$r,$=w,v=ua,T=$r,_;for(let L=BigInt(i-1);L>=$r;L--){const E=P>>L&ua;T^=E,_=l(T,O,$),O=_[0],$=_[1],_=l(T,S,v),S=_[0],v=_[1],T=E;const A=O+S,I=r(A*A),x=O-S,U=r(x*x),N=I-U,M=$+v,j=$-v,F=r(j*A),X=r(M*x),G=F+X,oe=F-X;$=r(G*G),v=r(R*r(oe*oe)),O=r(I*U),S=r(N*(I+r(u*N)))}_=l(T,O,$),O=_[0],$=_[1],_=l(T,S,v),S=_[0],v=_[1];const k=c(S);return r(O*k)}function d(w){return Oo(r(w),n)}function f(w){const C=St("u coordinate",w,n);return o===32&&(C[31]&=127),fn(C)}function y(w){const C=St("scalar",w),P=C.length;if(P!==n&&P!==o){let R=""+n+" or "+o;throw new Error("invalid scalar, expected "+R+" bytes, got "+P)}return fn(a(C))}function g(w,C){const P=f(C),R=y(w),O=h(P,R);if(O===$r)throw new Error("invalid private or public key received");return d(O)}const p=d(e.Gu);function m(w){return g(w,p)}return{scalarMult:g,scalarMultBase:m,getSharedSecret:(w,C)=>g(w,C),getPublicKey:w=>m(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:p}}const uc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const TC=BigInt(1),Bu=BigInt(2),xC=BigInt(3),kC=BigInt(5);BigInt(8);function RC(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=uc,o=t*t%n*t%n,a=Gt(o,Bu,n)*o%n,c=Gt(a,TC,n)*t%n,l=Gt(c,kC,n)*c%n,u=Gt(l,e,n)*l%n,h=Gt(u,s,n)*u%n,d=Gt(h,r,n)*h%n,f=Gt(d,i,n)*d%n,y=Gt(f,i,n)*d%n,g=Gt(y,e,n)*l%n;return{pow_p_5_8:Gt(g,Bu,n)*t%n,b2:o}}function UC(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}$C({P:uc,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=uc,{pow_p_5_8:s,b2:r}=RC(t);return bt(Gt(s,xC,e)*r,e)},adjustScalarBytes:UC,randomBytes:Qd});function Mu(t){t.lowS!==void 0&&pi("lowS",t.lowS),t.prehash!==void 0&&pi("prehash",t.prehash)}function DC(t){const e=vp(t);_i(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:s,Fp:r,a:i}=e;if(s){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof s!="object"||typeof s.beta!="bigint"||typeof s.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:LC,hexToBytes:BC}=mC;class MC extends Error{constructor(e=""){super(e)}}const ws={Err:MC,_tlv:{encode:(t,e)=>{const{Err:s}=ws;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const r=e.length/2,i=Zr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Zr(i.length/2|128):"";return Zr(t)+n+i+e},decode(t,e){const{Err:s}=ws;let r=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new s("tlv.decode: wrong tlv");const i=e[r++],n=!!(i&128);let o=0;if(!n)o=i;else{const c=i&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(r+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=ws;if(t<bs)throw new e("integer: negative integers are not allowed");let s=Zr(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=ws;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return LC(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=ws,i=typeof t=="string"?BC(t):t;On(i);const{v:n,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=ws,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},bs=BigInt(0),He=BigInt(1);BigInt(2);const qu=BigInt(3);BigInt(4);function qC(t){const e=DC(t),{Fp:s}=e,r=gp(e.n,e.nBitLength),i=e.toBytes||((g,p,m)=>{const w=p.toAffine();return gn(Uint8Array.from([4]),s.toBytes(w.x),s.toBytes(w.y))}),n=e.fromBytes||(g=>{const p=g.subarray(1),m=s.fromBytes(p.subarray(0,s.BYTES)),w=s.fromBytes(p.subarray(s.BYTES,2*s.BYTES));return{x:m,y:w}});function o(g){const{a:p,b:m}=e,w=s.sqr(g),C=s.mul(w,g);return s.add(s.add(C,s.mul(g,p)),m)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(g){return $o(g,He,e.n)}function c(g){const{allowedPrivateKeyLengths:p,nByteLength:m,wrapPrivateKey:w,n:C}=e;if(p&&typeof g!="bigint"){if(pr(g)&&(g=fi(g)),typeof g!="string"||!p.includes(g.length))throw new Error("invalid private key");g=g.padStart(m*2,"0")}let P;try{P=typeof g=="bigint"?g:nr(St("private key",g,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof g)}return w&&(P=bt(P,C)),Es("private key",P,He,C),P}function l(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}const u=ac((g,p)=>{const{px:m,py:w,pz:C}=g;if(s.eql(C,s.ONE))return{x:m,y:w};const P=g.is0();p==null&&(p=P?s.ONE:s.inv(C));const R=s.mul(m,p),O=s.mul(w,p),S=s.mul(C,p);if(P)return{x:s.ZERO,y:s.ZERO};if(!s.eql(S,s.ONE))throw new Error("invZ was invalid");return{x:R,y:O}}),h=ac(g=>{if(g.is0()){if(e.allowInfinityPoint&&!s.is0(g.py))return;throw new Error("bad point: ZERO")}const{x:p,y:m}=g.toAffine();if(!s.isValid(p)||!s.isValid(m))throw new Error("bad point: x or y not FE");const w=s.sqr(m),C=o(p);if(!s.eql(w,C))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(p,m,w){if(this.px=p,this.py=m,this.pz=w,p==null||!s.isValid(p))throw new Error("x required");if(m==null||!s.isValid(m))throw new Error("y required");if(w==null||!s.isValid(w))throw new Error("z required");Object.freeze(this)}static fromAffine(p){const{x:m,y:w}=p||{};if(!p||!s.isValid(m)||!s.isValid(w))throw new Error("invalid affine point");if(p instanceof d)throw new Error("projective point not allowed");const C=P=>s.eql(P,s.ZERO);return C(m)&&C(w)?d.ZERO:new d(m,w,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const m=s.invertBatch(p.map(w=>w.pz));return p.map((w,C)=>w.toAffine(m[C])).map(d.fromAffine)}static fromHex(p){const m=d.fromAffine(n(St("pointHex",p)));return m.assertValidity(),m}static fromPrivateKey(p){return d.BASE.multiply(c(p))}static msm(p,m){return PC(d,r,p,m)}_setWindowSize(p){y.setWindowSize(this,p)}assertValidity(){h(this)}hasEvenY(){const{y:p}=this.toAffine();if(s.isOdd)return!s.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){l(p);const{px:m,py:w,pz:C}=this,{px:P,py:R,pz:O}=p,S=s.eql(s.mul(m,O),s.mul(P,C)),$=s.eql(s.mul(w,O),s.mul(R,C));return S&&$}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:p,b:m}=e,w=s.mul(m,qu),{px:C,py:P,pz:R}=this;let O=s.ZERO,S=s.ZERO,$=s.ZERO,v=s.mul(C,C),T=s.mul(P,P),_=s.mul(R,R),k=s.mul(C,P);return k=s.add(k,k),$=s.mul(C,R),$=s.add($,$),O=s.mul(p,$),S=s.mul(w,_),S=s.add(O,S),O=s.sub(T,S),S=s.add(T,S),S=s.mul(O,S),O=s.mul(k,O),$=s.mul(w,$),_=s.mul(p,_),k=s.sub(v,_),k=s.mul(p,k),k=s.add(k,$),$=s.add(v,v),v=s.add($,v),v=s.add(v,_),v=s.mul(v,k),S=s.add(S,v),_=s.mul(P,R),_=s.add(_,_),v=s.mul(_,k),O=s.sub(O,v),$=s.mul(_,T),$=s.add($,$),$=s.add($,$),new d(O,S,$)}add(p){l(p);const{px:m,py:w,pz:C}=this,{px:P,py:R,pz:O}=p;let S=s.ZERO,$=s.ZERO,v=s.ZERO;const T=e.a,_=s.mul(e.b,qu);let k=s.mul(m,P),L=s.mul(w,R),E=s.mul(C,O),A=s.add(m,w),I=s.add(P,R);A=s.mul(A,I),I=s.add(k,L),A=s.sub(A,I),I=s.add(m,C);let x=s.add(P,O);return I=s.mul(I,x),x=s.add(k,E),I=s.sub(I,x),x=s.add(w,C),S=s.add(R,O),x=s.mul(x,S),S=s.add(L,E),x=s.sub(x,S),v=s.mul(T,I),S=s.mul(_,E),v=s.add(S,v),S=s.sub(L,v),v=s.add(L,v),$=s.mul(S,v),L=s.add(k,k),L=s.add(L,k),E=s.mul(T,E),I=s.mul(_,I),L=s.add(L,E),E=s.sub(k,E),E=s.mul(T,E),I=s.add(I,E),k=s.mul(L,I),$=s.add($,k),k=s.mul(x,I),S=s.mul(A,S),S=s.sub(S,k),k=s.mul(A,L),v=s.mul(x,v),v=s.add(v,k),new d(S,$,v)}subtract(p){return this.add(p.negate())}is0(){return this.equals(d.ZERO)}wNAF(p){return y.wNAFCached(this,p,d.normalizeZ)}multiplyUnsafe(p){const{endo:m,n:w}=e;Es("scalar",p,bs,w);const C=d.ZERO;if(p===bs)return C;if(this.is0()||p===He)return this;if(!m||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,p,d.normalizeZ);let{k1neg:P,k1:R,k2neg:O,k2:S}=m.splitScalar(p),$=C,v=C,T=this;for(;R>bs||S>bs;)R&He&&($=$.add(T)),S&He&&(v=v.add(T)),T=T.double(),R>>=He,S>>=He;return P&&($=$.negate()),O&&(v=v.negate()),v=new d(s.mul(v.px,m.beta),v.py,v.pz),$.add(v)}multiply(p){const{endo:m,n:w}=e;Es("scalar",p,He,w);let C,P;if(m){const{k1neg:R,k1:O,k2neg:S,k2:$}=m.splitScalar(p);let{p:v,f:T}=this.wNAF(O),{p:_,f:k}=this.wNAF($);v=y.constTimeNegate(R,v),_=y.constTimeNegate(S,_),_=new d(s.mul(_.px,m.beta),_.py,_.pz),C=v.add(_),P=T.add(k)}else{const{p:R,f:O}=this.wNAF(p);C=R,P=O}return d.normalizeZ([C,P])[0]}multiplyAndAddUnsafe(p,m,w){const C=d.BASE,P=(O,S)=>S===bs||S===He||!O.equals(C)?O.multiplyUnsafe(S):O.multiply(S),R=P(this,m).add(P(p,w));return R.is0()?void 0:R}toAffine(p){return u(this,p)}isTorsionFree(){const{h:p,isTorsionFree:m}=e;if(p===He)return!0;if(m)return m(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:m}=e;return p===He?this:m?m(d,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return pi("isCompressed",p),this.assertValidity(),i(d,this,p)}toHex(p=!0){return pi("isCompressed",p),fi(this.toRawBytes(p))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const f=e.nBitLength,y=SC(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function jC(t){const e=vp(t);return _i(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function FC(t){const e=jC(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(E){return bt(E,r)}function a(E){return lc(E,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=qC({...e,toBytes(E,A,I){const x=A.toAffine(),U=s.toBytes(x.x),N=gn;return pi("isCompressed",I),I?N(Uint8Array.from([A.hasEvenY()?2:3]),U):N(Uint8Array.from([4]),U,s.toBytes(x.y))},fromBytes(E){const A=E.length,I=E[0],x=E.subarray(1);if(A===i&&(I===2||I===3)){const U=nr(x);if(!$o(U,He,s.ORDER))throw new Error("Point is not on curve");const N=u(U);let M;try{M=s.sqrt(N)}catch(F){const X=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+X)}const j=(M&He)===He;return(I&1)===1!==j&&(M=s.neg(M)),{x:U,y:M}}else if(A===n&&I===4){const U=s.fromBytes(x.subarray(0,s.BYTES)),N=s.fromBytes(x.subarray(s.BYTES,2*s.BYTES));return{x:U,y:N}}else{const U=i,N=n;throw new Error("invalid Point, expected length of "+U+", or uncompressed "+N+", got "+A)}}}),d=E=>fi(mi(E,e.nByteLength));function f(E){const A=r>>He;return E>A}function y(E){return f(E)?o(-E):E}const g=(E,A,I)=>nr(E.slice(A,I));class p{constructor(A,I,x){this.r=A,this.s=I,this.recovery=x,this.assertValidity()}static fromCompact(A){const I=e.nByteLength;return A=St("compactSignature",A,I*2),new p(g(A,0,I),g(A,I,2*I))}static fromDER(A){const{r:I,s:x}=ws.toSig(St("DER",A));return new p(I,x)}assertValidity(){Es("r",this.r,He,r),Es("s",this.s,He,r)}addRecoveryBit(A){return new p(this.r,this.s,A)}recoverPublicKey(A){const{r:I,s:x,recovery:U}=this,N=O(St("msgHash",A));if(U==null||![0,1,2,3].includes(U))throw new Error("recovery id invalid");const M=U===2||U===3?I+e.n:I;if(M>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(U&1)===0?"02":"03",F=c.fromHex(j+d(M)),X=a(M),G=o(-N*X),oe=o(x*X),le=c.BASE.multiplyAndAddUnsafe(F,G,oe);if(!le)throw new Error("point at infinify");return le.assertValidity(),le}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return gi(this.toDERHex())}toDERHex(){return ws.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return gi(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const E=wp(e.n);return AC(e.randomBytes(E),e.n)},precompute(E=8,A=c.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}};function w(E,A=!0){return c.fromPrivateKey(E).toRawBytes(A)}function C(E){const A=pr(E),I=typeof E=="string",x=(A||I)&&E.length;return A?x===i||x===n:I?x===2*i||x===2*n:E instanceof c}function P(E,A,I=!0){if(C(E))throw new Error("first arg must be private key");if(!C(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(l(E)).toRawBytes(I)}const R=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");const A=nr(E),I=E.length*8-e.nBitLength;return I>0?A>>BigInt(I):A},O=e.bits2int_modN||function(E){return o(R(E))},S=Rc(e.nBitLength);function $(E){return Es("num < 2^"+e.nBitLength,E,bs,S),mi(E,e.nByteLength)}function v(E,A,I=T){if(["recovered","canonical"].some(ue=>ue in I))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:U}=e;let{lowS:N,prehash:M,extraEntropy:j}=I;N==null&&(N=!0),E=St("msgHash",E),Mu(I),M&&(E=St("prehashed msgHash",x(E)));const F=O(E),X=l(A),G=[$(X),$(F)];if(j!=null&&j!==!1){const ue=j===!0?U(s.BYTES):j;G.push(St("extraEntropy",ue))}const oe=gn(...G),le=F;function Ie(ue){const he=R(ue);if(!h(he))return;const Ft=a(he),at=c.BASE.multiply(he).toAffine(),qe=o(at.x);if(qe===bs)return;const Ze=o(Ft*o(le+qe*X));if(Ze===bs)return;let ct=(at.x===qe?0:2)|Number(at.y&He),zs=Ze;return N&&f(Ze)&&(zs=y(Ze),ct^=1),new p(qe,zs,ct)}return{seed:oe,k2sig:Ie}}const T={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function k(E,A,I=T){const{seed:x,k2sig:U}=v(E,A,I),N=e;return dp(N.hash.outputLen,N.nByteLength,N.hmac)(x,U)}c.BASE._setWindowSize(8);function L(E,A,I,x=_){var Ze;const U=E;A=St("msgHash",A),I=St("publicKey",I);const{lowS:N,prehash:M,format:j}=x;if(Mu(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const F=typeof U=="string"||pr(U),X=!F&&!j&&typeof U=="object"&&U!==null&&typeof U.r=="bigint"&&typeof U.s=="bigint";if(!F&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,oe;try{if(X&&(G=new p(U.r,U.s)),F){try{j!=="compact"&&(G=p.fromDER(U))}catch(ct){if(!(ct instanceof ws.Err))throw ct}!G&&j!=="der"&&(G=p.fromCompact(U))}oe=c.fromHex(I)}catch{return!1}if(!G||N&&G.hasHighS())return!1;M&&(A=e.hash(A));const{r:le,s:Ie}=G,ue=O(A),he=a(Ie),Ft=o(ue*he),at=o(le*he),qe=(Ze=c.BASE.multiplyAndAddUnsafe(oe,Ft,at))==null?void 0:Ze.toAffine();return qe?o(qe.x)===le:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:P,sign:k,verify:L,ProjectivePoint:c,Signature:p,utils:m}}function zC(t){return{hash:t,hmac:(e,...s)=>up(t,e,ZE(...s)),randomBytes:Qd}}function HC(t,e){const s=r=>FC({...t,...zC(r)});return{...s(e),create:s}}const Ep=gp(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),WC=Ep.create(BigInt("-3")),VC=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");HC({a:WC,b:VC,Fp:Ep,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},xc);const hc="base16",Fn="base64pad",Bi="base64url",KC="utf8",ha=1,GC=2;function da(t){const e=xc(Et(t,hc));return it(e,hc)}function Tr(t){const e=xc(Et(t,KC));return it(e,hc)}function zn(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var JC=Object.defineProperty,YC=Object.defineProperties,ZC=Object.getOwnPropertyDescriptors,ju=Object.getOwnPropertySymbols,XC=Object.prototype.hasOwnProperty,QC=Object.prototype.propertyIsEnumerable,Fu=(t,e,s)=>e in t?JC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,eI=(t,e)=>{for(var s in e||(e={}))XC.call(e,s)&&Fu(t,s,e[s]);if(ju)for(var s of ju(e))QC.call(e,s)&&Fu(t,s,e[s]);return t},tI=(t,e)=>YC(t,ZC(e));function Si(t){const e=[];return t.forEach(s=>{const[r,i]=s.split(":");e.push(`${r}:${i}`)}),e}function sI(t){const e=[];return Object.values(t).forEach(s=>{e.push(...Si(s.accounts))}),e}function rI(t,e){const s=[];return Object.values(t).forEach(r=>{Si(r.accounts).includes(e)&&s.push(...r.methods)}),s}function iI(t,e){const s=[];return Object.values(t).forEach(r=>{Si(r.accounts).includes(e)&&s.push(...r.events)}),s}function To(t){return t.includes(":")}function Xr(t){return To(t)?t.split(":")[0]:t}function zu(t){var e,s,r;const i={};if(!Ms(t))return i;for(const[n,o]of Object.entries(t)){const a=To(n)?[n]:o.chains,c=o.methods||[],l=o.events||[],u=Xr(n);i[u]=tI(eI({},i[u]),{chains:as(a,(e=i[u])==null?void 0:e.chains),methods:as(c,(s=i[u])==null?void 0:s.methods),events:as(l,(r=i[u])==null?void 0:r.events)})}return i}function nI(t){const e={};return t==null||t.forEach(s=>{var r;const[i,n]=s.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[],methods:[]}),e[i].accounts.push(s),(r=e[i].chains)==null||r.push(`${i}:${n}`)}),e}function Hu(t,e){e=e.map(r=>r.replace("did:pkh:",""));const s=nI(e);for(const[r,i]of Object.entries(s))i.methods?i.methods=as(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return s}function oI(t,e){var s,r,i,n,o,a;const c=zu(t),l=zu(e),u={},h=Object.keys(c).concat(Object.keys(l));for(const d of h)u[d]={chains:as((s=c[d])==null?void 0:s.chains,(r=l[d])==null?void 0:r.chains),methods:as((i=c[d])==null?void 0:i.methods,(n=l[d])==null?void 0:n.methods),events:as((o=c[d])==null?void 0:o.events,(a=l[d])==null?void 0:a.events)};return u}const aI={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}},cI={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 Z(t,e){const{message:s,code:r}=cI[t];return{message:e?`${s} ${e}`:s,code:r}}function Re(t,e){const{message:s,code:r}=aI[t];return{message:e?`${s} ${e}`:s,code:r}}function Bs(t,e){return!!Array.isArray(t)}function Ms(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function vt(t){return typeof t>"u"}function We(t,e){return e&&vt(t)?!0:typeof t=="string"&&!!t.trim().length}function Uc(t,e){return e&&vt(t)?!0:typeof t=="number"&&!isNaN(t)}function lI(t,e){const{requiredNamespaces:s}=e,r=Object.keys(t.namespaces),i=Object.keys(s);let n=!0;return tr(i,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=Si(a),h=s[o];(!tr(Kd(o,h),u)||!tr(h.methods,c)||!tr(h.events,l))&&(n=!1)}),n):!1}function uo(t){return We(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function uI(t){if(We(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&uo(s)}}return!1}function hI(t,e){let s=null;return We(t==null?void 0:t.publicKey,!1)||(s=Z("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function Wu(t){let e=!0;return Bs(t)?t.length&&(e=t.every(s=>We(s,!1))):e=!1,e}function dI(t,e,s){let r=null;return Bs(e)&&e.length?e.forEach(i=>{r||uo(i)||(r=Re("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):uo(t)||(r=Re("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}function pI(t,e,s){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const o=dI(i,Kd(i,n),`${e} ${s}`);o&&(r=o)}),r}function fI(t,e){let s=null;return Bs(t)?t.forEach(r=>{s||uI(r)||(s=Re("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):s=Re("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function gI(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=fI(r==null?void 0:r.accounts,`${e} namespace`);i&&(s=i)}),s}function mI(t,e){let s=null;return Wu(t==null?void 0:t.methods)?Wu(t==null?void 0:t.events)||(s=Re("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=Re("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function Cp(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=mI(r,`${e}, namespace`);i&&(s=i)}),s}function wI(t,e,s){let r=null;if(t&&Ms(t)){const i=Cp(t,e);i&&(r=i);const n=pI(t,e,s);n&&(r=n)}else r=Z("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return r}function pa(t,e){let s=null;if(t&&Ms(t)){const r=Cp(t,e);r&&(s=r);const i=gI(t,e);i&&(s=i)}else s=Z("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function Ip(t){return We(t.protocol,!0)}function yI(t,e){let s=!1;return t?t&&Bs(t)&&t.length&&t.forEach(r=>{s=Ip(r)}):s=!0,s}function bI(t){return typeof t=="number"}function Vt(t){return typeof t<"u"&&typeof t!==null}function vI(t){return!(!t||typeof t!="object"||!t.code||!Uc(t.code,!1)||!t.message||!We(t.message,!1))}function EI(t){return!(vt(t)||!We(t.method,!1))}function CI(t){return!(vt(t)||vt(t.result)&&vt(t.error)||!Uc(t.id,!1)||!We(t.jsonrpc,!1))}function II(t){return!(vt(t)||!We(t.name,!1))}function Vu(t,e){return!(!uo(e)||!sI(t).includes(e))}function AI(t,e,s){return We(s,!1)?rI(t,e).includes(s):!1}function NI(t,e,s){return We(s,!1)?iI(t,e).includes(s):!1}function Ku(t,e,s){let r=null;const i=_I(t),n=SI(e),o=Object.keys(i),a=Object.keys(n),c=Gu(Object.keys(t)),l=Gu(Object.keys(e)),u=c.filter(h=>!l.includes(h));return u.length&&(r=Z("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.
|
|
9
|
+
Required: ${u.toString()}
|
|
10
|
+
Received: ${Object.keys(e).toString()}`)),tr(o,a)||(r=Z("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.
|
|
11
|
+
Required: ${o.toString()}
|
|
12
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||r)return;const d=Si(e[h].accounts);d.includes(h)||(r=Z("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
13
|
+
Required: ${h}
|
|
14
|
+
Approved: ${d.toString()}`))}),o.forEach(h=>{r||(tr(i[h].methods,n[h].methods)?tr(i[h].events,n[h].events)||(r=Z("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${h}`)):r=Z("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${h}`))}),r}function _I(t){const e={};return Object.keys(t).forEach(s=>{var r;s.includes(":")?e[s]=t[s]:(r=t[s].chains)==null||r.forEach(i=>{e[i]={methods:t[s].methods,events:t[s].events}})}),e}function Gu(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function SI(t){const e={};return Object.keys(t).forEach(s=>{if(s.includes(":"))e[s]=t[s];else{const r=Si(t[s].accounts);r==null||r.forEach(i=>{e[i]={accounts:t[s].accounts.filter(n=>n.includes(`${i}:`)),methods:t[s].methods,events:t[s].events}})}}),e}function PI(t,e){return Uc(t,!1)&&t<=e.max&&t>=e.min}const fa={};class Mi{static get(e){return fa[e]}static set(e,s){fa[e]=s}static delete(e){delete fa[e]}}const Ap="wc",Np=2,_p="client",Dc=`${Ap}@${Np}:${_p}:`,ga={name:_p,logger:"error"},Ju="WALLETCONNECT_DEEPLINK_CHOICE",OI="proposal",Yu="Proposal expired",$I="session",xr=q.SEVEN_DAYS,TI="engine",Fe={wc_sessionPropose:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1104},res:{ttl:q.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1106},res:{ttl:q.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:q.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1112},res:{ttl:q.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:q.ONE_DAY,prompt:!1,tag:1114},res:{ttl:q.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:q.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:q.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:q.FIVE_MINUTES,prompt:!1,tag:1119}}},ma={min:q.FIVE_MINUTES,max:q.SEVEN_DAYS},ss={idle:"IDLE",active:"ACTIVE"},Zu={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},xI="request",kI=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],RI="wc",UI="auth",DI="authKeys",LI="pairingTopics",BI="requests",xo=`${RI}@${1.5}:${UI}:`,Qn=`${xo}:PUB_KEY`;var MI=Object.defineProperty,qI=Object.defineProperties,jI=Object.getOwnPropertyDescriptors,Xu=Object.getOwnPropertySymbols,FI=Object.prototype.hasOwnProperty,zI=Object.prototype.propertyIsEnumerable,dc=(t,e,s)=>e in t?MI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Se=(t,e)=>{for(var s in e||(e={}))FI.call(e,s)&&dc(t,s,e[s]);if(Xu)for(var s of Xu(e))zI.call(e,s)&&dc(t,s,e[s]);return t},lt=(t,e)=>qI(t,jI(e)),D=(t,e,s)=>dc(t,typeof e!="symbol"?e+"":e,s);class HI extends vg{constructor(e){super(e),D(this,"name",TI),D(this,"events",new Ec),D(this,"initialized",!1),D(this,"requestQueue",{state:ss.idle,queue:[]}),D(this,"sessionRequestQueue",{state:ss.idle,queue:[]}),D(this,"requestQueueDelay",q.ONE_SECOND),D(this,"expectedPairingMethodMap",new Map),D(this,"recentlyDeletedMap",new Map),D(this,"recentlyDeletedLimit",200),D(this,"relayMessageCache",[]),D(this,"pendingSessions",new Map),D(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Fe)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay)))}),D(this,"connect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const r=lt(Se({},s),{requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}});await this.isValidConnect(r),r.optionalNamespaces=oI(r.requiredNamespaces,r.optionalNamespaces),r.requiredNamespaces={};const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l}=r;let u=i,h,d=!1;try{if(u){const O=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=O.active}}catch(O){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),O}if(!u||!d){const{topic:O,uri:S}=await this.client.core.pairing.create();u=O,h=S}if(!u){const{message:O}=Z("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(O)}const f=await this.client.core.crypto.generateKeyPair(),y=Fe.wc_sessionPropose.req.ttl||q.FIVE_MINUTES,g=mt(y),p=lt(Se(Se({requiredNamespaces:n,optionalNamespaces:o,relays:l??[{protocol:Ed}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:Cs()}),m=_e("session_connect",p.id),{reject:w,resolve:C,done:P}=Sr(y,Yu),R=({id:O})=>{O===p.id&&(this.client.events.off("proposal_expire",R),this.pendingSessions.delete(p.id),this.events.emit(m,{error:{message:Yu,code:0}}))};return this.client.events.on("proposal_expire",R),this.events.once(m,({error:O,session:S})=>{this.client.events.off("proposal_expire",R),O?w(O):S&&C(S)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:p,throwOnFailedPublish:!0,clientRpcId:p.id}),await this.setProposal(p.id,p),{uri:h,approval:P}}),D(this,"pair",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(s)}catch(r){throw this.client.logger.error("pair() failed"),r}}),D(this,"approve",async s=>{var r,i,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(r=s==null?void 0:s.id)==null?void 0:r.toString(),trace:[Ht.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(v){throw o.setError(Ws.no_internet_connection),v}try{await this.isValidProposalId(s==null?void 0:s.id)}catch(v){throw this.client.logger.error(`approve() -> proposal.get(${s==null?void 0:s.id}) failed`),o.setError(Ws.proposal_not_found),v}try{await this.isValidApprove(s)}catch(v){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ws.session_approve_namespace_validation_failure),v}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,scopedProperties:h,sessionConfig:d}=s,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:y,proposer:g,requiredNamespaces:p,optionalNamespaces:m}=f;let w=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:y});w||(w=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Ht.session_approve_started,properties:{topic:y,trace:[Ht.session_approve_started,Ht.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),P=g.publicKey,R=await this.client.core.crypto.generateSharedKey(C,P),O=Se(Se(Se({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:C,metadata:this.client.metadata},expiry:mt(xr)},u&&{sessionProperties:u}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),S=Te.relay;w.addTrace(Ht.subscribing_session_topic);try{await this.client.core.relayer.subscribe(R,{transportType:S})}catch(v){throw w.setError(Ws.subscribe_session_topic_failure),v}w.addTrace(Ht.subscribe_session_topic_success);const $=lt(Se({},O),{topic:R,requiredNamespaces:p,optionalNamespaces:m,pairingTopic:y,acknowledged:!1,self:O.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:C,transportType:Te.relay});await this.client.session.set(R,$),w.addTrace(Ht.store_session);try{w.addTrace(Ht.publishing_session_settle),await this.sendRequest({topic:R,method:"wc_sessionSettle",params:O,throwOnFailedPublish:!0}).catch(v=>{throw w==null||w.setError(Ws.session_settle_publish_failure),v}),w.addTrace(Ht.session_settle_publish_success),w.addTrace(Ht.publishing_session_approve),await this.sendResult({id:a,topic:y,result:{relay:{protocol:c??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(v=>{throw w==null||w.setError(Ws.session_approve_publish_failure),v}),w.addTrace(Ht.session_approve_publish_success)}catch(v){throw this.client.logger.error(v),this.client.session.delete(R,Re("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(R),v}return this.client.core.eventClient.deleteEvent({eventId:w.eventId}),await this.client.core.pairing.updateMetadata({topic:y,metadata:g.metadata}),await this.client.proposal.delete(a,Re("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:y}),await this.setExpiry(R,mt(xr)),{topic:R,acknowledged:()=>Promise.resolve(this.client.session.get(R))}}),D(this,"reject",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(s)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:r,reason:i}=s;let n;try{n=this.client.proposal.get(r).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),o}n&&(await this.sendError({id:r,topic:n,error:i,rpcOpts:Fe.wc_sessionPropose.reject}),await this.client.proposal.delete(r,Re("USER_DISCONNECTED")))}),D(this,"update",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(s)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:r,namespaces:i}=s,{done:n,resolve:o,reject:a}=Sr(),c=Cs(),l=Gr().toString(),u=this.client.session.get(r).namespaces;return this.events.once(_e("session_update",c),({error:h})=>{h?a(h):o()}),await this.client.session.update(r,{namespaces:i}),await this.sendRequest({topic:r,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(h=>{this.client.logger.error(h),this.client.session.update(r,{namespaces:u}),a(h)}),{acknowledged:n}}),D(this,"extend",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(s)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:r}=s,i=Cs(),{done:n,resolve:o,reject:a}=Sr();return this.events.once(_e("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(r,mt(xr)),this.sendRequest({topic:r,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),D(this,"request",async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(m){throw this.client.logger.error("request() -> isValidRequest() failed"),m}const{chainId:r,request:i,topic:n,expiry:o=Fe.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(n);(a==null?void 0:a.transportType)===Te.relay&&await this.confirmOnlineStateOrThrow();const c=Cs(),l=Gr().toString(),{done:u,resolve:h,reject:d}=Sr(o,"Request expired. Please try again.");this.events.once(_e("session_request",c),({error:m,result:w})=>{m?d(m):h(w)});const f="wc_sessionRequest",y=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(y)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:{request:lt(Se({},i),{expiryTimestamp:mt(o)}),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:y}).catch(m=>d(m)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),await u();const g={request:lt(Se({},i),{expiryTimestamp:mt(o)}),chainId:r},p=this.shouldSetTVF(f,g);return await Promise.all([new Promise(async m=>{await this.sendRequest(Se({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:g,expiry:o,throwOnFailedPublish:!0},p&&{tvf:this.getTVFParams(c,g)})).catch(w=>d(w)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),m()}),new Promise(async m=>{var w;if(!((w=a.sessionConfig)!=null&&w.disableDeepLink)){const C=await UE(this.client.core.storage,Ju);await xE({id:c,topic:n,wcDeepLink:C})}m()}),u()]).then(m=>m[2])}),D(this,"respond",async s=>{this.isInitialized(),await this.isValidRespond(s);const{topic:r,response:i}=s,{id:n}=i,o=this.client.session.get(r);o.transportType===Te.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);fs(i)?await this.sendResult({id:n,topic:r,result:i.result,throwOnFailedPublish:!0,appLink:a}):is(i)&&await this.sendError({id:n,topic:r,error:i.error,appLink:a}),this.cleanupAfterResponse(s)}),D(this,"ping",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(s)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:r}=s;if(this.client.session.keys.includes(r)){const i=Cs(),n=Gr().toString(),{done:o,resolve:a,reject:c}=Sr();this.events.once(_e("session_ping",i),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:r,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(r)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:r}))}),D(this,"emit",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:r,event:i,chainId:n}=s,o=Gr().toString(),a=Cs();await this.sendRequest({topic:r,method:"wc_sessionEvent",params:{event:i,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),D(this,"disconnect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(s);const{topic:r}=s;if(this.client.session.keys.includes(r))await this.sendRequest({topic:r,method:"wc_sessionDelete",params:Re("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:r,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(r))await this.client.core.pairing.disconnect({topic:r});else{const{message:i}=Z("MISMATCHED_TOPIC",`Session or pairing topic not found: ${r}`);throw new Error(i)}}),D(this,"find",s=>(this.isInitialized(),this.client.session.getAll().filter(r=>lI(r,s)))),D(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),D(this,"authenticate",async(s,r)=>{var i;this.isInitialized(),this.isValidAuthenticate(s);const n=r&&this.client.core.linkModeSupportedApps.includes(r)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=n?Te.link_mode:Te.relay;o===Te.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:h,type:d,exp:f,nbf:y,methods:g=[],expiry:p}=s,m=[...s.resources||[]],{topic:w,uri:C}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:w,uri:C}});const P=await this.client.core.crypto.generateKeyPair(),R=da(P);if(await Promise.all([this.client.auth.authKeys.set(Qn,{responseTopic:R,publicKey:P}),this.client.auth.pairingTopics.set(R,{topic:R,pairingTopic:w})]),await this.client.core.relayer.subscribe(R,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${w}`),g.length>0){const{namespace:N}=ei(a[0]);let M=S1(N,"request",g);Xn(m)&&(M=O1(M,m.pop())),m.push(M)}const O=p&&p>Fe.wc_sessionAuthenticate.req.ttl?p:Fe.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:d??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:h,iat:new Date().toISOString(),exp:f,nbf:y,resources:m},requester:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:mt(O)},$={eip155:{chains:a,methods:[...new Set(["personal_sign",...g])],events:["chainChanged","accountsChanged"]}},v={requiredNamespaces:{},optionalNamespaces:$,relays:[{protocol:"irn"}],pairingTopic:w,proposer:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:mt(Fe.wc_sessionPropose.req.ttl),id:Cs()},{done:T,resolve:_,reject:k}=Sr(O,"Request expired"),L=Cs(),E=_e("session_connect",v.id),A=_e("session_request",L),I=async({error:N,session:M})=>{this.events.off(A,x),N?k(N):M&&_({session:M})},x=async N=>{var M,j,F;if(await this.deletePendingAuthRequest(L,{message:"fulfilled",code:0}),N.error){const he=Re("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return N.error.code===he.code?void 0:(this.events.off(E,I),k(N.error.message))}await this.deleteProposal(v.id),this.events.off(E,I);const{cacaos:X,responder:G}=N.result,oe=[],le=[];for(const he of X){await Iu({cacao:he,projectId:this.client.core.projectId})||(this.client.logger.error(he,"Signature verification failed"),k(Re("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Ft}=he,at=Xn(Ft.resources),qe=[rc(Ft.iss)],Ze=lo(Ft.iss);if(at){const ct=Au(at),zs=Nu(at);oe.push(...ct),qe.push(...zs)}for(const ct of qe)le.push(`${ct}:${Ze}`)}const Ie=await this.client.core.crypto.generateSharedKey(P,G.publicKey);let ue;oe.length>0&&(ue={topic:Ie,acknowledged:!0,self:{publicKey:P,metadata:this.client.metadata},peer:G,controller:G.publicKey,expiry:mt(xr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:w,namespaces:Hu([...new Set(oe)],[...new Set(le)]),transportType:o},await this.client.core.relayer.subscribe(Ie,{transportType:o}),await this.client.session.set(Ie,ue),w&&await this.client.core.pairing.updateMetadata({topic:w,metadata:G.metadata}),ue=this.client.session.get(Ie)),(M=this.client.metadata.redirect)!=null&&M.linkMode&&(j=G.metadata.redirect)!=null&&j.linkMode&&(F=G.metadata.redirect)!=null&&F.universal&&r&&(this.client.core.addLinkModeSupportedApp(G.metadata.redirect.universal),this.client.session.update(Ie,{transportType:Te.link_mode})),_({auths:X,session:ue})};this.events.once(E,I),this.events.once(A,x);let U;try{if(n){const N=er("wc_sessionAuthenticate",S,L);this.client.core.history.set(w,N);const M=await this.client.core.crypto.encode("",N,{type:GC,encoding:Bi});U=zn(r,w,M)}else await Promise.all([this.sendRequest({topic:w,method:"wc_sessionAuthenticate",params:S,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:L}),this.sendRequest({topic:w,method:"wc_sessionPropose",params:v,expiry:Fe.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v.id})])}catch(N){throw this.events.off(E,I),this.events.off(A,x),N}return await this.setProposal(v.id,v),await this.setAuthRequest(L,{request:lt(Se({},S),{verifyContext:{}}),pairingTopic:w,transportType:o}),{uri:U??C,response:T}}),D(this,"approveSessionAuthenticate",async s=>{const{id:r,auths:i}=s,n=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:[Vs.authenticated_session_approve_started]}});try{this.isInitialized()}catch(p){throw n.setError(xi.no_internet_connection),p}const o=this.getPendingAuthRequest(r);if(!o)throw n.setError(xi.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${r}`);const a=o.transportType||Te.relay;a===Te.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=da(c),h={type:ha,receiverPublicKey:c,senderPublicKey:l},d=[],f=[];for(const p of i){if(!await Iu({cacao:p,projectId:this.client.core.projectId})){n.setError(xi.invalid_cacao);const R=Re("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:r,topic:u,error:R,encodeOpts:h}),new Error(R.message)}n.addTrace(Vs.cacaos_verified);const{p:m}=p,w=Xn(m.resources),C=[rc(m.iss)],P=lo(m.iss);if(w){const R=Au(w),O=Nu(w);d.push(...R),C.push(...O)}for(const R of C)f.push(`${R}:${P}`)}const y=await this.client.core.crypto.generateSharedKey(l,c);n.addTrace(Vs.create_authenticated_session_topic);let g;if((d==null?void 0:d.length)>0){g={topic:y,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:mt(xr),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Hu([...new Set(d)],[...new Set(f)]),transportType:a},n.addTrace(Vs.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(y,{transportType:a})}catch(p){throw n.setError(xi.subscribe_authenticated_session_topic_failure),p}n.addTrace(Vs.subscribe_authenticated_session_topic_success),await this.client.session.set(y,g),n.addTrace(Vs.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Vs.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:r,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(p){throw n.setError(xi.authenticated_session_approve_publish_failure),p}return await this.client.auth.requests.delete(r,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:g}}),D(this,"rejectSessionAuthenticate",async s=>{this.isInitialized();const{id:r,reason:i}=s,n=this.getPendingAuthRequest(r);if(!n)throw new Error(`Could not find pending auth request with id ${r}`);n.transportType===Te.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=da(o),l={type:ha,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:c,error:i,encodeOpts:l,rpcOpts:Fe.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(r,{message:"rejected",code:0}),await this.client.proposal.delete(r,Re("USER_DISCONNECTED"))}),D(this,"formatAuthMessage",s=>{this.isInitialized();const{request:r,iss:i}=s;return ip(r,i)}),D(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const s=this.relayMessageCache.shift();s&&await this.onRelayMessage(s)}catch(s){this.client.logger.error(s)}},50)}),D(this,"cleanupDuplicatePairings",async s=>{if(s.pairingTopic)try{const r=this.client.core.pairing.pairings.get(s.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===s.peer.metadata.url&&n.topic&&n.topic!==r.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(r){this.client.logger.error(r)}}),D(this,"deleteSession",async s=>{var r;const{topic:i,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=s,{self:c}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,Re("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),n||this.client.core.expirer.del(i),this.client.core.storage.removeItem(Ju).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,Re("USER_DISCONNECTED"))}),i===((r=this.sessionRequestQueue.queue[0])==null?void 0:r.topic)&&(this.sessionRequestQueue.state=ss.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})}),D(this,"deleteProposal",async(s,r)=>{if(r)try{const i=this.client.proposal.get(s),n=this.client.core.eventClient.getEvent({topic:i.pairingTopic});n==null||n.setError(Ws.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,Re("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")}),D(this,"deletePendingSessionRequest",async(s,r,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==s),i&&(this.sessionRequestQueue.state=ss.idle,this.client.events.emit("session_request_expire",{id:s}))}),D(this,"deletePendingAuthRequest",async(s,r,i=!1)=>{await Promise.all([this.client.auth.requests.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)])}),D(this,"setExpiry",async(s,r)=>{this.client.session.keys.includes(s)&&(this.client.core.expirer.set(s,r),await this.client.session.update(s,{expiry:r}))}),D(this,"setProposal",async(s,r)=>{this.client.core.expirer.set(s,mt(Fe.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,r)}),D(this,"setAuthRequest",async(s,r)=>{const{request:i,pairingTopic:n,transportType:o=Te.relay}=r;this.client.core.expirer.set(s,i.expiryTimestamp),await this.client.auth.requests.set(s,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:s,pairingTopic:n,verifyContext:i.verifyContext,transportType:o})}),D(this,"setPendingSessionRequest",async s=>{const{id:r,topic:i,params:n,verifyContext:o}=s,a=n.request.expiryTimestamp||mt(Fe.wc_sessionRequest.req.ttl);this.client.core.expirer.set(r,a),await this.client.pendingRequest.set(r,{id:r,topic:i,params:n,verifyContext:o})}),D(this,"sendRequest",async s=>{const{topic:r,method:i,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:h}=s,d=er(i,n,c);let f;const y=!!u;try{const m=y?Bi:Fn;f=await this.client.core.crypto.encode(r,d,{encoding:m})}catch(m){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),m}let g;if(kI.includes(i)){const m=Tr(JSON.stringify(d)),w=Tr(f);g=await this.client.core.verify.register({id:w,decryptedId:m})}const p=Fe[i].req;if(p.attestation=g,o&&(p.ttl=o),a&&(p.id=a),this.client.core.history.set(r,d),y){const m=zn(u,r,f);await global.Linking.openURL(m,this.client.name)}else{const m=Fe[i].req;o&&(m.ttl=o),a&&(m.id=a),m.tvf=lt(Se({},h),{correlationId:d.id}),l?(m.internal=lt(Se({},m.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,f,m)):this.client.core.relayer.publish(r,f,m).catch(w=>this.client.logger.error(w))}return d.id}),D(this,"sendResult",async s=>{const{id:r,topic:i,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=go(r,n);let u;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const y=h?Bi:Fn;u=await this.client.core.crypto.encode(i,l,lt(Se({},a||{}),{encoding:y}))}catch(y){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),y}let d,f;try{d=await this.client.core.history.get(i,r);const y=d.request;try{this.shouldSetTVF(y.method,y.params)&&(f=this.getTVFParams(r,y.params,n))}catch(g){this.client.logger.warn("sendResult() -> getTVFParams() failed",g)}}catch(y){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${r}) failed`),y}if(h){const y=zn(c,i,u);await global.Linking.openURL(y,this.client.name)}else{const y=d.request.method,g=Fe[y].res;g.tvf=lt(Se({},f),{correlationId:r}),o?(g.internal=lt(Se({},g.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,g)):this.client.core.relayer.publish(i,u,g).catch(p=>this.client.logger.error(p))}await this.client.core.history.resolve(l)}),D(this,"sendError",async s=>{const{id:r,topic:i,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=$h(r,n);let u;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=h?Bi:Fn;u=await this.client.core.crypto.encode(i,l,lt(Se({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),f}let d;try{d=await this.client.core.history.get(i,r)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${i}, ${r}) failed`),f}if(h){const f=zn(c,i,u);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,y=a||Fe[f].res;this.client.core.relayer.publish(i,u,y)}await this.client.core.history.resolve(l)}),D(this,"cleanup",async()=>{const s=[],r=[];this.client.session.getAll().forEach(i=>{let n=!1;Pr(i.expiry)&&(n=!0),this.client.core.crypto.keychain.has(i.topic)||(n=!0),n&&s.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Pr(i.expiryTimestamp)&&r.push(i.id)}),await Promise.all([...s.map(i=>this.deleteSession({topic:i})),...r.map(i=>this.deleteProposal(i))])}),D(this,"onProviderMessageEvent",async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)}),D(this,"onRelayEventRequest",async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()}),D(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===ss.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=ss.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(r){this.client.logger.warn(r)}}this.requestQueue.state=ss.idle}),D(this,"processRequest",async s=>{const{topic:r,payload:i,attestation:n,transportType:o,encryptedId:a}=s,c=i.method;if(!this.shouldIgnorePairingRequest({topic:r,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:r,payload:i,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(r,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(r,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(r,i);case"wc_sessionPing":return await this.onSessionPingRequest(r,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(r,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(r,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),D(this,"onRelayEventResponse",async s=>{const{topic:r,payload:i,transportType:n}=s,o=(await this.client.core.history.get(r,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(r,i,n);case"wc_sessionSettle":return this.onSessionSettleResponse(r,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(r,i);case"wc_sessionExtend":return this.onSessionExtendResponse(r,i);case"wc_sessionPing":return this.onSessionPingResponse(r,i);case"wc_sessionRequest":return this.onSessionRequestResponse(r,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(r,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),D(this,"onRelayEventUnknownPayload",s=>{const{topic:r}=s,{message:i}=Z("MISSING_OR_INVALID",`Decoded payload on topic ${r} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),D(this,"shouldIgnorePairingRequest",s=>{const{topic:r,requestMethod:i}=s,n=this.expectedPairingMethodMap.get(r);return!n||n.includes(i)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),D(this,"onSessionProposeRequest",async s=>{const{topic:r,payload:i,attestation:n,encryptedId:o}=s,{params:a,id:c}=i;try{const l=this.client.core.eventClient.getEvent({topic:r});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(gs.proposal_listener_not_found)),this.isValidConnect(Se({},i.params));const u=a.expiryTimestamp||mt(Fe.wc_sessionPropose.req.ttl),h=Se({id:c,pairingTopic:r,expiryTimestamp:u},a);await this.setProposal(c,h);const d=await this.getVerifyContext({attestationId:n,hash:Tr(JSON.stringify(i)),encryptedId:o,metadata:h.proposer.metadata});l==null||l.addTrace(rs.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:d})}catch(l){await this.sendError({id:c,topic:r,error:l,rpcOpts:Fe.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),D(this,"onSessionProposeResponse",async(s,r,i)=>{const{id:n}=r;if(fs(r)){const{result:o}=r;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(n,{sessionTopic:u,pairingTopic:s,proposalId:n,publicKey:c});const h=await this.client.core.relayer.subscribe(u,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:s})}else if(is(r)){await this.client.proposal.delete(n,Re("USER_DISCONNECTED"));const o=_e("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:r.error})}}),D(this,"onSessionSettleRequest",async(s,r)=>{const{id:i,params:n}=r;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,scopedProperties:h,sessionConfig:d}=r.params,f=[...this.pendingSessions.values()].find(p=>p.sessionTopic===s);if(!f)return this.client.logger.error(`Pending session not found for topic ${s}`);const y=this.client.proposal.get(f.proposalId),g=lt(Se(Se(Se({topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:y.requiredNamespaces,optionalNamespaces:y.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),{transportType:Te.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit(_e("session_connect",f.proposalId),{session:g}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:r.id,topic:s,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),D(this,"onSessionSettleResponse",async(s,r)=>{const{id:i}=r;fs(r)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(_e("session_approve",i),{})):is(r)&&(await this.client.session.delete(s,Re("USER_DISCONNECTED")),this.events.emit(_e("session_approve",i),{error:r.error}))}),D(this,"onSessionUpdateRequest",async(s,r)=>{const{params:i,id:n}=r;try{const o=`${s}_session_update`,a=Mi.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:s,error:Re("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Se({topic:s},i));try{Mi.set(o,n),await this.client.session.update(s,{namespaces:i.namespaces}),await this.sendResult({id:n,topic:s,result:!0,throwOnFailedPublish:!0})}catch(c){throw Mi.delete(o),c}this.client.events.emit("session_update",{id:n,topic:s,params:i})}catch(o){await this.sendError({id:n,topic:s,error:o}),this.client.logger.error(o)}}),D(this,"isRequestOutOfSync",(s,r)=>r.toString().slice(0,-3)<s.toString().slice(0,-3)),D(this,"onSessionUpdateResponse",(s,r)=>{const{id:i}=r,n=_e("session_update",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);fs(r)?this.events.emit(_e("session_update",i),{}):is(r)&&this.events.emit(_e("session_update",i),{error:r.error})}),D(this,"onSessionExtendRequest",async(s,r)=>{const{id:i}=r;try{this.isValidExtend({topic:s}),await this.setExpiry(s,mt(xr)),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),D(this,"onSessionExtendResponse",(s,r)=>{const{id:i}=r,n=_e("session_extend",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);fs(r)?this.events.emit(_e("session_extend",i),{}):is(r)&&this.events.emit(_e("session_extend",i),{error:r.error})}),D(this,"onSessionPingRequest",async(s,r)=>{const{id:i}=r;try{this.isValidPing({topic:s}),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),D(this,"onSessionPingResponse",(s,r)=>{const{id:i}=r,n=_e("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);fs(r)?this.events.emit(_e("session_ping",i),{}):is(r)&&this.events.emit(_e("session_ping",i),{error:r.error})},500)}),D(this,"onSessionDeleteRequest",async(s,r)=>{const{id:i}=r;try{this.isValidDisconnect({topic:s,reason:r.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(Ve.publish,async()=>{n(await this.deleteSession({topic:s,id:i}))})}),this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:s,error:Re("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),D(this,"onSessionRequest",async s=>{var r,i,n;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=s,{id:h,params:d}=a;try{await this.isValidRequest(Se({topic:o},d));const f=this.client.session.get(o),y=await this.getVerifyContext({attestationId:c,hash:Tr(JSON.stringify(er("wc_sessionRequest",d,h))),encryptedId:l,metadata:f.peer.metadata,transportType:u}),g={id:h,topic:o,params:d,verifyContext:y};await this.setPendingSessionRequest(g),u===Te.link_mode&&(r=f.peer.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp((i=f.peer.metadata.redirect)==null?void 0:i.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(f){await this.sendError({id:h,topic:o,error:f}),this.client.logger.error(f)}}),D(this,"onSessionRequestResponse",(s,r)=>{const{id:i}=r,n=_e("session_request",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);fs(r)?this.events.emit(_e("session_request",i),{result:r.result}):is(r)&&this.events.emit(_e("session_request",i),{error:r.error})}),D(this,"onSessionEventRequest",async(s,r)=>{const{id:i,params:n}=r;try{const o=`${s}_session_event_${n.event.name}`,a=Mi.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(Se({topic:s},n)),this.client.events.emit("session_event",{id:i,topic:s,params:n}),Mi.set(o,i)}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),D(this,"onSessionAuthenticateResponse",(s,r)=>{const{id:i}=r;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:r}),fs(r)?this.events.emit(_e("session_request",i),{result:r.result}):is(r)&&this.events.emit(_e("session_request",i),{error:r.error})}),D(this,"onSessionAuthenticateRequest",async s=>{var r;const{topic:i,payload:n,attestation:o,encryptedId:a,transportType:c}=s;try{const{requester:l,authPayload:u,expiryTimestamp:h}=n.params,d=await this.getVerifyContext({attestationId:o,hash:Tr(JSON.stringify(n)),encryptedId:a,metadata:l.metadata,transportType:c}),f={requester:l,pairingTopic:i,id:n.id,authPayload:u,verifyContext:d,expiryTimestamp:h};await this.setAuthRequest(n.id,{request:f,pairingTopic:i,transportType:c}),c===Te.link_mode&&(r=l.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:n.params,id:n.id,verifyContext:d})}catch(l){this.client.logger.error(l);const u=n.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:ha,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:n.id,topic:i,error:l,encodeOpts:f,rpcOpts:Fe.wc_sessionAuthenticate.autoReject,appLink:d})}}),D(this,"addSessionRequestToSessionRequestQueue",s=>{this.sessionRequestQueue.queue.push(s)}),D(this,"cleanupAfterResponse",s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=ss.idle,this.processSessionRequestQueue()},q.toMiliseconds(this.requestQueueDelay))}),D(this,"cleanupPendingSentRequestsForTopic",({topic:s,error:r})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(n=>n.topic===s&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=_e("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(_e("session_request",n.request.id),{error:r})})}),D(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===ss.active){this.client.logger.info("session request queue is already active.");return}const s=this.sessionRequestQueue.queue[0];if(!s){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=ss.active,this.emitSessionRequest(s)}catch(r){this.client.logger.error(r)}}),D(this,"emitSessionRequest",s=>{this.client.events.emit("session_request",s)}),D(this,"onPairingCreated",s=>{if(s.methods&&this.expectedPairingMethodMap.set(s.topic,s.methods),s.active)return;const r=this.client.proposal.getAll().find(i=>i.pairingTopic===s.topic);r&&this.onSessionProposeRequest({topic:s.topic,payload:er("wc_sessionPropose",lt(Se({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces,relays:r.relays,proposer:r.proposer,sessionProperties:r.sessionProperties,scopedProperties:r.scopedProperties}),r.id)})}),D(this,"isValidConnect",async s=>{if(!Vt(s)){const{message:l}=Z("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(s)}`);throw new Error(l)}const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:c}=s;if(vt(r)||await this.isValidPairingTopic(r),!yI(c)){const{message:l}=Z("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!vt(i)&&Ms(i)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(i,"requiredNamespaces")}if(!vt(n)&&Ms(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),vt(o)||this.validateSessionProps(o,"sessionProperties"),!vt(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(i||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(u=>l.includes(u)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),D(this,"validateNamespaces",(s,r)=>{const i=wI(s,"connect()",r);if(i)throw new Error(i.message)}),D(this,"isValidApprove",async s=>{if(!Vt(s))throw new Error(Z("MISSING_OR_INVALID",`approve() params: ${s}`).message);const{id:r,namespaces:i,relayProtocol:n,sessionProperties:o,scopedProperties:a}=s;this.checkRecentlyDeleted(r),await this.isValidProposalId(r);const c=this.client.proposal.get(r),l=pa(i,"approve()");if(l)throw new Error(l.message);const u=Ku(c.requiredNamespaces,i,"approve()");if(u)throw new Error(u.message);if(!We(n,!0)){const{message:h}=Z("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(h)}if(vt(o)||this.validateSessionProps(o,"sessionProperties"),!vt(a)){this.validateSessionProps(a,"scopedProperties");const h=new Set(Object.keys(i));if(!Object.keys(a).every(d=>h.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),D(this,"isValidReject",async s=>{if(!Vt(s)){const{message:n}=Z("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(n)}const{id:r,reason:i}=s;if(this.checkRecentlyDeleted(r),await this.isValidProposalId(r),!vI(i)){const{message:n}=Z("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(n)}}),D(this,"isValidSessionSettleRequest",s=>{if(!Vt(s)){const{message:l}=Z("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:r,controller:i,namespaces:n,expiry:o}=s;if(!Ip(r)){const{message:l}=Z("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=hI(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=pa(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Pr(o)){const{message:l}=Z("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),D(this,"isValidUpdate",async s=>{if(!Vt(s)){const{message:c}=Z("MISSING_OR_INVALID",`update() params: ${s}`);throw new Error(c)}const{topic:r,namespaces:i}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const n=this.client.session.get(r),o=pa(i,"update()");if(o)throw new Error(o.message);const a=Ku(n.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)}),D(this,"isValidExtend",async s=>{if(!Vt(s)){const{message:i}=Z("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(i)}const{topic:r}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r)}),D(this,"isValidRequest",async s=>{if(!Vt(s)){const{message:c}=Z("MISSING_OR_INVALID",`request() params: ${s}`);throw new Error(c)}const{topic:r,request:i,chainId:n,expiry:o}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const{namespaces:a}=this.client.session.get(r);if(!Vu(a,n)){const{message:c}=Z("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!EI(i)){const{message:c}=Z("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!AI(a,n,i.method)){const{message:c}=Z("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}if(o&&!PI(o,ma)){const{message:c}=Z("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${ma.min} and ${ma.max}`);throw new Error(c)}}),D(this,"isValidRespond",async s=>{var r;if(!Vt(s)){const{message:o}=Z("MISSING_OR_INVALID",`respond() params: ${s}`);throw new Error(o)}const{topic:i,response:n}=s;try{await this.isValidSessionTopic(i)}catch(o){throw(r=s==null?void 0:s.response)!=null&&r.id&&this.cleanupAfterResponse(s),o}if(!CI(n)){const{message:o}=Z("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),D(this,"isValidPing",async s=>{if(!Vt(s)){const{message:i}=Z("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),D(this,"isValidEmit",async s=>{if(!Vt(s)){const{message:a}=Z("MISSING_OR_INVALID",`emit() params: ${s}`);throw new Error(a)}const{topic:r,event:i,chainId:n}=s;await this.isValidSessionTopic(r);const{namespaces:o}=this.client.session.get(r);if(!Vu(o,n)){const{message:a}=Z("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!II(i)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!NI(o,n,i.name)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}}),D(this,"isValidDisconnect",async s=>{if(!Vt(s)){const{message:i}=Z("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),D(this,"isValidAuthenticate",s=>{const{chains:r,uri:i,domain:n,nonce:o}=s;if(!Array.isArray(r)||r.length===0)throw new Error("chains is required and must be a non-empty array");if(!We(i,!1))throw new Error("uri is required parameter");if(!We(n,!1))throw new Error("domain is required parameter");if(!We(o,!1))throw new Error("nonce is required parameter");if([...new Set(r.map(c=>ei(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ei(r[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),D(this,"getVerifyContext",async s=>{const{attestationId:r,hash:i,encryptedId:n,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||en,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Te.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:r,hash:i,encryptedId:n,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),D(this,"validateSessionProps",(s,r)=>{Object.values(s).forEach((i,n)=>{if(i==null){const{message:o}=Z("MISSING_OR_INVALID",`${r} must contain an existing value for each key. Received: ${i} for key ${Object.keys(s)[n]}`);throw new Error(o)}})}),D(this,"getPendingAuthRequest",s=>{const r=this.client.auth.requests.get(s);return typeof r=="object"?r:void 0}),D(this,"addToRecentlyDeleted",(s,r)=>{if(this.recentlyDeletedMap.set(s,r),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=n)break;this.recentlyDeletedMap.delete(o)}}}),D(this,"checkRecentlyDeleted",s=>{const r=this.recentlyDeletedMap.get(s);if(r){const{message:i}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${r}: ${s}`);throw new Error(i)}}),D(this,"isLinkModeEnabled",(s,r)=>{var i,n,o,a,c,l,u,h,d;return!s||r!==Te.link_mode?!1:((n=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=s==null?void 0:s.redirect)==null?void 0:u.universal)!==void 0&&((h=s==null?void 0:s.redirect)==null?void 0:h.universal)!==""&&((d=s==null?void 0:s.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),D(this,"getAppLinkIfEnabled",(s,r)=>{var i;return this.isLinkModeEnabled(s,r)?(i=s==null?void 0:s.redirect)==null?void 0:i.universal:void 0}),D(this,"handleLinkModeMessage",({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const r=gu(s,"topic")||"",i=decodeURIComponent(gu(s,"wc_ev")||""),n=this.client.session.keys.includes(r);n&&this.client.session.update(r,{transportType:Te.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:i,sessionExists:n})}),D(this,"registerLinkModeListeners",async()=>{var s;if(DE()||Jd()&&(s=this.client.metadata.redirect)!=null&&s.linkMode){const r=global==null?void 0:global.Linking;if(typeof r<"u"){r.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await r.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}),D(this,"shouldSetTVF",(s,r)=>{if(!r||s!=="wc_sessionRequest")return!1;const{request:i}=r;return Object.keys(Zu).includes(i.method)}),D(this,"getTVFParams",(s,r,i)=>{var n,o;try{const a=r.request.method,c=this.extractTxHashesFromResult(a,i);return lt(Se({correlationId:s,rpcMethods:[a],chainId:r.chainId},this.isValidContractData(r.request.params)&&{contractAddresses:[(o=(n=r.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),D(this,"isValidContractData",s=>{var r;if(!s)return!1;try{const i=(s==null?void 0:s.data)||((r=s==null?void 0:s[0])==null?void 0:r.data);if(!i.startsWith("0x"))return!1;const n=i.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),D(this,"extractTxHashesFromResult",(s,r)=>{try{const i=Zu[s];if(typeof r=="string")return[r];const n=r[i.key];if(Bs(n))return s==="solana_signAllTransactions"?n.map(o=>p1(o)):n;if(typeof n=="string")return[n]}catch(i){this.client.logger.warn("Error extracting tx hashes from result",i)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,s=this.client.core.relayer.messages.getWithoutAck(e);for(const[r,i]of Object.entries(s))for(const n of i)try{await this.onProviderMessageEvent({topic:r,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${r}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ve.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:s,message:r,attestation:i,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Qn)?this.client.auth.authKeys.get(Qn):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,r,{receiverPublicKey:o,encoding:n===Te.link_mode?Bi:Fn});bc(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:i,transportType:n,encryptedId:Tr(r)})):vc(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:s,payload:a,transportType:n}),this.client.core.history.delete(s,a.id)):await this.onRelayEventUnknownPayload({topic:s,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(s,r)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(Mt.expired,async e=>{const{topic:s,id:r}=TE(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,Z("EXPIRED"),!0);if(r&&this.client.auth.requests.keys.includes(r))return await this.deletePendingAuthRequest(r,Z("EXPIRED"),!0);s?this.client.session.keys.includes(s)&&(await this.deleteSession({topic:s,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:s})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))})}registerPairingEvents(){this.client.core.pairing.events.on(Zs.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Zs.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!We(e,!1)){const{message:s}=Z("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(s)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:s}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(Pr(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=Z("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!We(e,!1)){const{message:s}=Z("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(s)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:s}=Z("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(Pr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=Z("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=Z("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(s)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(We(e,!1)){const{message:s}=Z("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=Z("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!bI(e)){const{message:s}=Z("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=Z("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(Pr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=Z("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}}class WI extends vr{constructor(e,s){super(e,s,OI,Dc),this.core=e,this.logger=s}}let VI=class extends vr{constructor(e,s){super(e,s,$I,Dc),this.core=e,this.logger=s}};class KI extends vr{constructor(e,s){super(e,s,xI,Dc,r=>r.id),this.core=e,this.logger=s}}class GI extends vr{constructor(e,s){super(e,s,DI,xo,()=>Qn),this.core=e,this.logger=s}}class JI extends vr{constructor(e,s){super(e,s,LI,xo),this.core=e,this.logger=s}}class YI extends vr{constructor(e,s){super(e,s,BI,xo,r=>r.id),this.core=e,this.logger=s}}var ZI=Object.defineProperty,XI=(t,e,s)=>e in t?ZI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,wa=(t,e,s)=>XI(t,typeof e!="symbol"?e+"":e,s);class QI{constructor(e,s){this.core=e,this.logger=s,wa(this,"authKeys"),wa(this,"pairingTopics"),wa(this,"requests"),this.authKeys=new GI(this.core,this.logger),this.pairingTopics=new JI(this.core,this.logger),this.requests=new YI(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var eA=Object.defineProperty,tA=(t,e,s)=>e in t?eA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ce=(t,e,s)=>tA(t,typeof e!="symbol"?e+"":e,s);let sA=class Sp extends bg{constructor(e){super(e),ce(this,"protocol",Ap),ce(this,"version",Np),ce(this,"name",ga.name),ce(this,"metadata"),ce(this,"core"),ce(this,"logger"),ce(this,"events",new gr.EventEmitter),ce(this,"engine"),ce(this,"session"),ce(this,"proposal"),ce(this,"pendingRequest"),ce(this,"auth"),ce(this,"signConfig"),ce(this,"on",(r,i)=>this.events.on(r,i)),ce(this,"once",(r,i)=>this.events.once(r,i)),ce(this,"off",(r,i)=>this.events.off(r,i)),ce(this,"removeListener",(r,i)=>this.events.removeListener(r,i)),ce(this,"removeAllListeners",r=>this.events.removeAllListeners(r)),ce(this,"connect",async r=>{try{return await this.engine.connect(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"pair",async r=>{try{return await this.engine.pair(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"approve",async r=>{try{return await this.engine.approve(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"reject",async r=>{try{return await this.engine.reject(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"update",async r=>{try{return await this.engine.update(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"extend",async r=>{try{return await this.engine.extend(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"request",async r=>{try{return await this.engine.request(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"respond",async r=>{try{return await this.engine.respond(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"ping",async r=>{try{return await this.engine.ping(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"emit",async r=>{try{return await this.engine.emit(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"disconnect",async r=>{try{return await this.engine.disconnect(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"find",r=>{try{return this.engine.find(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(r){throw this.logger.error(r.message),r}}),ce(this,"authenticate",async(r,i)=>{try{return await this.engine.authenticate(r,i)}catch(n){throw this.logger.error(n.message),n}}),ce(this,"formatAuthMessage",r=>{try{return this.engine.formatAuthMessage(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"approveSessionAuthenticate",async r=>{try{return await this.engine.approveSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),ce(this,"rejectSessionAuthenticate",async r=>{try{return await this.engine.rejectSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),this.name=(e==null?void 0:e.name)||ga.name,this.metadata=OE(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const s=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:yc(bn({level:(e==null?void 0:e.logger)||ga.logger}));this.core=(e==null?void 0:e.core)||new Tv(e),this.logger=ht(s,this.name),this.session=new VI(this.core,this.logger),this.proposal=new WI(this.core,this.logger),this.pendingRequest=new KI(this.core,this.logger),this.engine=new HI(this),this.auth=new QI(this.core,this.logger)}static async init(e){const s=new Sp(e);return await s.initialize(),s}get context(){return xt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},q.toMiliseconds(q.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const Qu="error",rA="wss://relay.walletconnect.org",iA="wc",nA="universal_provider",Hn=`${iA}@2:${nA}:`,Pp="https://rpc.walletconnect.org/v1/",Wr="generic",oA=`${Pp}bundler`,jt={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function aA(){}function Lc(t){return t==null||typeof t!="object"&&typeof t!="function"}function Bc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function cA(t){if(Lc(t))return t;if(Array.isArray(t)||Bc(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const r=new s(t);return r.lastIndex=t.lastIndex,r}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const r=new s(t.message);return r.stack=t.stack,r.name=t.name,r.cause=t.cause,r}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const r=Object.create(e);return Object.assign(r,t)}return t}function eh(t){return typeof t=="object"&&t!==null}function Op(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function $p(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const lA="[object RegExp]",Tp="[object String]",xp="[object Number]",kp="[object Boolean]",Rp="[object Arguments]",uA="[object Symbol]",hA="[object Date]",dA="[object Map]",pA="[object Set]",fA="[object Array]",gA="[object ArrayBuffer]",mA="[object Object]",wA="[object DataView]",yA="[object Uint8Array]",bA="[object Uint8ClampedArray]",vA="[object Uint16Array]",EA="[object Uint32Array]",CA="[object Int8Array]",IA="[object Int16Array]",AA="[object Int32Array]",NA="[object Float32Array]",_A="[object Float64Array]";function SA(t,e){return Qr(t,void 0,t,new Map,e)}function Qr(t,e,s,r=new Map,i=void 0){const n=i==null?void 0:i(t,e,s,r);if(n!=null)return n;if(Lc(t))return t;if(r.has(t))return r.get(t);if(Array.isArray(t)){const o=new Array(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=Qr(t[a],a,s,r,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;r.set(t,o);for(const[a,c]of t)o.set(a,Qr(c,a,s,r,i));return o}if(t instanceof Set){const o=new Set;r.set(t,o);for(const a of t)o.add(Qr(a,void 0,s,r,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(Bc(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=Qr(t[a],a,s,r,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return r.set(t,o),Qs(o,t,s,r,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return r.set(t,o),Qs(o,t,s,r,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return r.set(t,o),Qs(o,t,s,r,i),o}if(t instanceof Error){const o=new t.constructor;return r.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Qs(o,t,s,r,i),o}if(typeof t=="object"&&PA(t)){const o=Object.create(Object.getPrototypeOf(t));return r.set(t,o),Qs(o,t,s,r,i),o}return t}function Qs(t,e,s=t,r,i){const n=[...Object.keys(e),...Op(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Qr(e[a],a,s,r,i))}}function PA(t){switch($p(t)){case Rp:case fA:case gA:case wA:case kp:case hA:case NA:case _A:case CA:case IA:case AA:case dA:case xp:case mA:case lA:case pA:case Tp:case uA:case yA:case bA:case vA:case EA:return!0;default:return!1}}function OA(t,e){return SA(t,(s,r,i,n)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case xp:case Tp:case kp:{const o=new t.constructor(t==null?void 0:t.valueOf());return Qs(o,t),o}case Rp:{const o={};return Qs(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function th(t){return OA(t)}function sh(t){return t!==null&&typeof t=="object"&&$p(t)==="[object Arguments]"}function $A(t){return Bc(t)}function TA(t){var s;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!((s=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&s.writable)?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function xA(t,...e){const s=e.slice(0,-1),r=e[e.length-1];let i=t;for(let n=0;n<s.length;n++){const o=s[n];i=pc(i,o,r,new Map)}return i}function pc(t,e,s,r){if(Lc(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(r.has(e))return cA(r.get(e));if(r.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const i=[...Object.keys(e),...Op(e)];for(let n=0;n<i.length;n++){const o=i[n];let a=e[o],c=t[o];if(sh(a)&&(a={...a}),sh(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=th(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],h=Reflect.ownKeys(c);for(let d=0;d<h.length;d++){const f=h[d];u[f]=c[f]}c=u}else c=[];const l=s(c,a,o,t,e,r);l!=null?t[o]=l:Array.isArray(a)||eh(c)&&eh(a)?t[o]=pc(c,a,s,r):c==null&&TA(a)?t[o]=pc({},a,s,r):c==null&&$A(a)?t[o]=th(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function kA(t,...e){return xA(t,...e,aA)}var RA=Object.defineProperty,UA=Object.defineProperties,DA=Object.getOwnPropertyDescriptors,rh=Object.getOwnPropertySymbols,LA=Object.prototype.hasOwnProperty,BA=Object.prototype.propertyIsEnumerable,ih=(t,e,s)=>e in t?RA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Wn=(t,e)=>{for(var s in e||(e={}))LA.call(e,s)&&ih(t,s,e[s]);if(rh)for(var s of rh(e))BA.call(e,s)&&ih(t,s,e[s]);return t},MA=(t,e)=>UA(t,DA(e));function Tt(t,e,s){var r;const i=ei(t);return((r=e.rpcMap)==null?void 0:r[i.reference])||`${Pp}?chainId=${i.namespace}:${i.reference}&projectId=${s}`}function Er(t){return t.includes(":")?t.split(":")[1]:t}function Up(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function qA(t,e){const s=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!s.length)return[];const r=[];return s.forEach(i=>{const n=e.namespaces[i].accounts;r.push(...n)}),r}function Vn(t={},e={}){const s=nh(t),r=nh(e);return kA(s,r)}function nh(t){var e,s,r,i,n;const o={};if(!Ms(t))return o;for(const[a,c]of Object.entries(t)){const l=To(a)?[a]:c.chains,u=c.methods||[],h=c.events||[],d=c.rpcMap||{},f=Xr(a);o[f]=MA(Wn(Wn({},o[f]),c),{chains:as(l,(e=o[f])==null?void 0:e.chains),methods:as(u,(s=o[f])==null?void 0:s.methods),events:as(h,(r=o[f])==null?void 0:r.events)}),(Ms(d)||Ms(((i=o[f])==null?void 0:i.rpcMap)||{}))&&(o[f].rpcMap=Wn(Wn({},d),(n=o[f])==null?void 0:n.rpcMap))}return o}function oh(t){return t.includes(":")?t.split(":")[2]:t}function ah(t){const e={};for(const[s,r]of Object.entries(t)){const i=r.methods||[],n=r.events||[],o=r.accounts||[],a=To(s)?[s]:r.chains?r.chains:Up(r.accounts);e[s]={chains:a,methods:i,events:n,accounts:o}}return e}function ya(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Dp={},we=t=>Dp[t],ba=(t,e)=>{Dp[t]=e};var jA=Object.defineProperty,FA=(t,e,s)=>e in t?jA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,kr=(t,e,s)=>FA(t,typeof e!="symbol"?e+"":e,s);class zA{constructor(e){kr(this,"name","polkadot"),kr(this,"client"),kr(this,"httpProviders"),kr(this,"events"),kr(this,"namespace"),kr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=Er(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var HA=Object.defineProperty,WA=Object.defineProperties,VA=Object.getOwnPropertyDescriptors,ch=Object.getOwnPropertySymbols,KA=Object.prototype.hasOwnProperty,GA=Object.prototype.propertyIsEnumerable,fc=(t,e,s)=>e in t?HA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,lh=(t,e)=>{for(var s in e||(e={}))KA.call(e,s)&&fc(t,s,e[s]);if(ch)for(var s of ch(e))GA.call(e,s)&&fc(t,s,e[s]);return t},uh=(t,e)=>WA(t,VA(e)),Rr=(t,e,s)=>fc(t,typeof e!="symbol"?e+"":e,s);class JA{constructor(e){Rr(this,"name","eip155"),Rr(this,"client"),Rr(this,"chainId"),Rr(this,"namespace"),Rr(this,"httpProviders"),Rr(this,"events"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s),this.chainId=parseInt(e),this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const r=s||Tt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=parseInt(Er(s));e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}async handleSwitchChain(e){var s,r;let i=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const n=parseInt(i,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(r=this.namespace.chains)==null?void 0:r[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var s,r,i,n,o;const a=(r=(s=e.request)==null?void 0:s.params)==null?void 0:r[0],c=((n=(i=e.request)==null?void 0:i.params)==null?void 0:n[1])||[],l=`${a}${c.join(",")}`;if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(e.topic),h=((o=u==null?void 0:u.sessionProperties)==null?void 0:o.capabilities)||{};if(h!=null&&h[l])return h==null?void 0:h[l];const d=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:uh(lh({},u.sessionProperties||{}),{capabilities:uh(lh({},h||{}),{[l]:d})})})}catch(f){console.warn("Failed to update session with capabilities",f)}return d}async getCallStatus(e){var s,r;const i=this.client.session.get(e.topic),n=(s=i.sessionProperties)==null?void 0:s.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(r=i.sessionProperties)==null?void 0:r.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var r;const i=new URL(e),n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(er("eth_getUserOperationReceipt",[(r=s.request.params)==null?void 0:r[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,s){return`${oA}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}}var YA=Object.defineProperty,ZA=(t,e,s)=>e in t?YA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ur=(t,e,s)=>ZA(t,typeof e!="symbol"?e+"":e,s);class XA{constructor(e){Ur(this,"name","solana"),Ur(this,"client"),Ur(this,"httpProviders"),Ur(this,"events"),Ur(this,"namespace"),Ur(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=Er(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var QA=Object.defineProperty,eN=(t,e,s)=>e in t?QA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Dr=(t,e,s)=>eN(t,typeof e!="symbol"?e+"":e,s);class tN{constructor(e){Dr(this,"name","cosmos"),Dr(this,"client"),Dr(this,"httpProviders"),Dr(this,"events"),Dr(this,"namespace"),Dr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=Er(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var sN=Object.defineProperty,rN=(t,e,s)=>e in t?sN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Lr=(t,e,s)=>rN(t,typeof e!="symbol"?e+"":e,s);class iN{constructor(e){Lr(this,"name","algorand"),Lr(this,"client"),Lr(this,"httpProviders"),Lr(this,"events"),Lr(this,"namespace"),Lr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(!this.httpProviders[e]){const r=s||Tt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new qt(new Xt(r,we("disableProviderPing")))}}var nN=Object.defineProperty,oN=(t,e,s)=>e in t?nN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Br=(t,e,s)=>oN(t,typeof e!="symbol"?e+"":e,s);class aN{constructor(e){Br(this,"name","cip34"),Br(this,"client"),Br(this,"httpProviders"),Br(this,"events"),Br(this,"namespace"),Br(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{const r=this.getCardanoRPCUrl(s),i=Er(s);e[i]=this.createHttpProvider(i,r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}getCardanoRPCUrl(e){const s=this.namespace.rpcMap;if(s)return s[e]}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var cN=Object.defineProperty,lN=(t,e,s)=>e in t?cN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Mr=(t,e,s)=>lN(t,typeof e!="symbol"?e+"":e,s);class uN{constructor(e){Mr(this,"name","elrond"),Mr(this,"client"),Mr(this,"httpProviders"),Mr(this,"events"),Mr(this,"namespace"),Mr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=Er(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var hN=Object.defineProperty,dN=(t,e,s)=>e in t?hN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,qr=(t,e,s)=>dN(t,typeof e!="symbol"?e+"":e,s);class pN{constructor(e){qr(this,"name","multiversx"),qr(this,"client"),qr(this,"httpProviders"),qr(this,"events"),qr(this,"namespace"),qr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=Er(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var fN=Object.defineProperty,gN=(t,e,s)=>e in t?fN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jr=(t,e,s)=>gN(t,typeof e!="symbol"?e+"":e,s);class mN{constructor(e){jr(this,"name","near"),jr(this,"client"),jr(this,"httpProviders"),jr(this,"events"),jr(this,"namespace"),jr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||Tt(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace);return typeof r>"u"?void 0:new qt(new Xt(r,we("disableProviderPing")))}}var wN=Object.defineProperty,yN=(t,e,s)=>e in t?wN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Fr=(t,e,s)=>yN(t,typeof e!="symbol"?e+"":e,s);class bN{constructor(e){Fr(this,"name","tezos"),Fr(this,"client"),Fr(this,"httpProviders"),Fr(this,"events"),Fr(this,"namespace"),Fr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||Tt(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{e[s]=this.createHttpProvider(s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace);return typeof r>"u"?void 0:new qt(new Xt(r))}}var vN=Object.defineProperty,EN=(t,e,s)=>e in t?vN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,zr=(t,e,s)=>EN(t,typeof e!="symbol"?e+"":e,s);class CN{constructor(e){zr(this,"name",Wr),zr(this,"client"),zr(this,"httpProviders"),zr(this,"events"),zr(this,"namespace"),zr(this,"chainId"),this.namespace=e.namespace,this.events=we("events"),this.client=we("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(jt.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const r={};return(s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(i=>{const n=ei(i);r[`${n.namespace}:${n.reference}`]=this.createHttpProvider(i)}),r}getHttpProvider(e){const s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||Tt(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new qt(new Xt(r,we("disableProviderPing")))}}var IN=Object.defineProperty,AN=Object.defineProperties,NN=Object.getOwnPropertyDescriptors,hh=Object.getOwnPropertySymbols,_N=Object.prototype.hasOwnProperty,SN=Object.prototype.propertyIsEnumerable,gc=(t,e,s)=>e in t?IN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Kn=(t,e)=>{for(var s in e||(e={}))_N.call(e,s)&&gc(t,s,e[s]);if(hh)for(var s of hh(e))SN.call(e,s)&&gc(t,s,e[s]);return t},va=(t,e)=>AN(t,NN(e)),Lt=(t,e,s)=>gc(t,typeof e!="symbol"?e+"":e,s);let PN=class Lp{constructor(e){Lt(this,"client"),Lt(this,"namespaces"),Lt(this,"optionalNamespaces"),Lt(this,"sessionProperties"),Lt(this,"scopedProperties"),Lt(this,"events",new Ec),Lt(this,"rpcProviders",{}),Lt(this,"session"),Lt(this,"providerOpts"),Lt(this,"logger"),Lt(this,"uri"),Lt(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:yc(bn({level:(e==null?void 0:e.logger)||Qu})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const s=new Lp(e);return await s.initialize(),s}async request(e,s,r){const[i,n]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Kn({},e),chainId:`${i}:${n}`,topic:this.session.topic,expiry:r})}sendAsync(e,s,r,i){const n=new Date().getTime();this.request(e,r,i).then(o=>s(null,go(n,o))).catch(o=>s(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Re("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:r,response:i}=await this.client.authenticate(e,s);r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();if(this.session=n.session,this.session){const o=ah(this.session.namespaces);this.namespaces=Vn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}removeListener(e,s){this.events.removeListener(e,s)}off(e,s){this.events.off(e,s)}get isWalletConnect(){return!0}async pair(e){const{uri:s,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const i=await r();this.session=i;const n=ah(i.namespaces);return this.namespaces=Vn(this.namespaces,n),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[r,i]=this.validateChain(e),n=this.getProvider(r);n.name===Wr?n.setDefaultChain(`${r}:${i}`,s):n.setDefaultChain(i,s)}catch(r){if(!/Please call connect/.test(r.message))throw r}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(Bs(s)){for(const r of s)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,s;if(this.client=this.providerOpts.client||await sA.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Qu,relayUrl:this.providerOpts.relayUrl||rA,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else{const r=this.client.session.getAll();this.session=r[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>Xr(s)))];ba("client",this.client),ba("events",this.events),ba("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const r=qA(s,this.session),i=Up(r),n=Vn(this.namespaces,this.optionalNamespaces),o=va(Kn({},n[s]),{accounts:r,chains:i});switch(s){case"eip155":this.rpcProviders[s]=new JA({namespace:o});break;case"algorand":this.rpcProviders[s]=new iN({namespace:o});break;case"solana":this.rpcProviders[s]=new XA({namespace:o});break;case"cosmos":this.rpcProviders[s]=new tN({namespace:o});break;case"polkadot":this.rpcProviders[s]=new zA({namespace:o});break;case"cip34":this.rpcProviders[s]=new aN({namespace:o});break;case"elrond":this.rpcProviders[s]=new uN({namespace:o});break;case"multiversx":this.rpcProviders[s]=new pN({namespace:o});break;case"near":this.rpcProviders[s]=new mN({namespace:o});break;case"tezos":this.rpcProviders[s]=new bN({namespace:o});break;default:this.rpcProviders[Wr]?this.rpcProviders[Wr].updateNamespace(o):this.rpcProviders[Wr]=new CN({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:r}=e;r===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var s;const{params:r,topic:i}=e;if(i!==((s=this.session)==null?void 0:s.topic))return;const{event:n}=r;if(n.name==="accountsChanged"){const o=n.data;o&&Bs(o)&&this.events.emit("accountsChanged",o.map(oh))}else if(n.name==="chainChanged"){const o=r.chainId,a=r.event.data,c=Xr(o),l=ya(o)!==ya(a)?`${c}:${ya(a)}`:o;this.onChainChanged(l)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:s})=>{var r,i;if(e!==((r=this.session)==null?void 0:r.topic))return;const{namespaces:n}=s,o=(i=this.client)==null?void 0:i.session.get(e);this.session=va(Kn({},o),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s})}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",va(Kn({},Re("USER_DISCONNECTED")),{data:e.topic})))}),this.on(jt.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Wr]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e])})}setNamespaces(e){const{namespaces:s={},optionalNamespaces:r={},sessionProperties:i,scopedProperties:n}=e;this.optionalNamespaces=Vn(s,r),this.sessionProperties=i,this.scopedProperties=n}validateChain(e){const[s,r]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,r];if(s&&!Object.keys(this.namespaces||{}).map(o=>Xr(o)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&r)return[s,r];const i=Xr(Object.keys(this.namespaces)[0]),n=this.rpcProviders[i].getDefaultChain();return[i,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,s=!1){if(!this.namespaces)return;const[r,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(r,i),this.events.emit("chainChanged",i);const n=this.getProvider(r).getDefaultChain();s||this.getProvider(r).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:n,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:s,newChainId:r}){var i,n;try{if(s===r)return;const o=(n=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:n.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${r}:`)).map(oh);if(!Bs(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,s){if(!this.namespaces)return;const r=this.namespaces[e]?e:`${e}:${s}`,i={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=s):this.namespaces[r]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,s){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.setItem(`${Hn}/${e}${i}`,s)}async getFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${Hn}/${e}${r}`)}async deleteFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${Hn}/${e}${r}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const r of s)r.startsWith(Hn)&&await this.client.core.storage.removeItem(r)}catch(s){this.logger.warn("Failed to cleanup storage",s)}}};const sn={getSIWX(){return B.state.siwx},async initializeIfEnabled(){var n;const t=B.state.siwx,e=b.getActiveCaipAddress();if(!(t&&e))return;const[s,r,i]=e.split(":");if(b.checkIfSupportedNetwork(s))try{if((await t.getSessions(`${s}:${r}`,i)).length)return;await Ge.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),Ue.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=ee._getClient())==null?void 0:n.disconnect().catch(console.error)),ne.reset("Connect"),Yt.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=B.state.siwx,e=te.getPlainAddress(b.getActiveCaipAddress()),s=b.getActiveCaipNetwork(),r=ee._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!s)throw new Error("No ActiveCaipNetwork or client found");if(!r)throw new Error("No ConnectionController client found");try{const i=await t.createMessage({chainId:s.caipNetworkId,accountAddress:e}),n=i.toString();H.getConnectorId(s.chainNamespace)===K.CONNECTOR_ID.AUTH&&ne.pushTransactionStack({});const a=await r.signMessage(n);await t.addSession({data:i,message:n,signature:a}),Ge.close(),Ue.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const n=this.getSIWXEventProperties();(!Ge.state.open||ne.state.view==="ApproveTransaction")&&await Ge.open({view:"SIWXSignMessage"}),n.isSmartAccount?Yt.showError("This application might not support Smart Accounts"):Yt.showError("Signature declined"),Ue.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){var t;try{const e=this.getSIWX();((t=e==null?void 0:e.getRequired)==null?void 0:t.call(e))?await ee.disconnect():Ge.close(),ne.reset("Connect"),Ue.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const t=B.state.siwx,e=te.getPlainAddress(b.getActiveCaipAddress()),s=b.getActiveCaipNetwork();return t&&e&&s?t.getSessions(s.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const s=ne.state.view==="ApproveTransaction",r=ne.state.view==="SIWXSignMessage";if(s||r)return((e=t.getRequired)==null?void 0:e.call(t))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:s}){var a,c,l;const r=sn.getSIWX(),i=new Set(e.map(u=>u.split(":")[0]));if(!r||i.size!==1||!i.has("eip155"))return!1;const n=await r.createMessage({chainId:((a=b.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await t.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:s,chains:[n.chainId,...e.filter(u=>u!==n.chainId)]});if(Yt.showLoading("Authenticating...",{autoClose:!1}),V.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(i)[0]),(l=o==null?void 0:o.auths)!=null&&l.length){const u=o.auths.map(h=>{const d=t.client.formatAuthMessage({request:h.p,iss:h.p.iss});return{data:{...h.p,accountAddress:h.p.iss.split(":").slice(-1).join(""),chainId:h.p.iss.split(":").slice(2,4).join(":"),uri:h.p.aud,version:h.p.version||n.version,expirationTime:h.p.exp,issuedAt:h.p.iat,notBefore:h.p.nbf},message:d,signature:h.s.s,cacao:h}});try{await r.setSessions(u),Ue.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:sn.getSIWXEventProperties()})}catch(h){throw console.error("SIWX:universalProviderAuth - failed to set sessions",h),Ue.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:sn.getSIWXEventProperties()}),await t.disconnect().catch(console.error),h}finally{Yt.hide()}}return!0},getSIWXEventProperties(){var e,s;const t=b.state.activeChain;return{network:((e=b.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((s=V.state.preferredAccountTypes)==null?void 0:s[t])===Ji.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};function Gn(t,e){return H.getConnectorId(t)===e}function ON(t){const e=Array.from(b.state.chains.keys());let s=[];return t?(s.push([t,b.state.chains.get(t)]),Gn(t,K.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(r=>{r!==t&&Gn(r,K.CONNECTOR_ID.WALLET_CONNECT)&&s.push([r,b.state.chains.get(r)])}):Gn(t,K.CONNECTOR_ID.AUTH)&&e.forEach(r=>{r!==t&&Gn(r,K.CONNECTOR_ID.AUTH)&&s.push([r,b.state.chains.get(r)])})):s=Array.from(b.state.chains.entries()),s}const $s={EIP155:"eip155",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED"},ho={NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[K.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[K.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[K.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[K.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[K.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[K.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[K.CONNECTOR_ID.INJECTED]:"Browser Wallet",[K.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[K.CONNECTOR_ID.COINBASE]:"Coinbase",[K.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[K.CONNECTOR_ID.LEDGER]:"Ledger",[K.CONNECTOR_ID.SAFE]:"Safe"}},Mc={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([s,r])=>{e[`${$s.EIP155}:${s}`]=r}),e},isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())}};new AbortController;const Hr={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${$N()?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},IFRAME_LOAD_FAILED:{shortMessage:"Network Error - Could not load embedded wallet",longMessage:()=>"There was an issue loading the embedded wallet. Please try again later."},IFRAME_REQUEST_TIMEOUT:{shortMessage:"Embedded Wallet Request Timed Out",longMessage:()=>"There was an issue doing the request to the embedded wallet. Please try again later."},UNVERIFIED_DOMAIN:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}};function $N(){return typeof window<"u"}const TN={createLogger(t,e="error"){const s=bn({level:e}),{logger:r}=Oh({opts:s});return r.error=(...i)=>{for(const n of i)if(n instanceof Error){t(n,...i);return}t(void 0,...i)},r}},xN="rpc.walletconnect.org";function dh(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()}const Ea=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],Vr={extendRpcUrlWithProjectId(t,e){let s=!1;try{s=new URL(t).host===xN}catch{s=!1}if(s){const r=new URL(t);return r.searchParams.has("projectId")||r.searchParams.set("projectId",e),r.toString()}return t},isCaipNetwork(t){return"chainNamespace"in t&&"caipNetworkId"in t},getChainNamespace(t){return this.isCaipNetwork(t)?t.chainNamespace:K.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${K.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,s){var i,n,o;const r=(o=(n=(i=t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null?void 0:o[0];return Ea.includes(e)?dh(e,s):r||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){var d,f,y,g,p;const i=this.getChainNamespace(t),n=this.getCaipNetworkId(t),o=(d=t.rpcUrls.default.http)==null?void 0:d[0],a=this.getDefaultRpcUrl(t,n,s),c=((g=(y=(f=t==null?void 0:t.rpcUrls)==null?void 0:f.chainDefault)==null?void 0:y.http)==null?void 0:g[0])||o,l=((p=r==null?void 0:r[n])==null?void 0:p.map(m=>m.url))||[],u=[...l,a],h=[...l];return c&&!h.includes(c)&&h.push(c),{...t,chainNamespace:i,caipNetworkId:n,assets:{imageId:ho.NetworkImageIds[t.id],imageUrl:e==null?void 0:e[t.id]},rpcUrls:{...t.rpcUrls,default:{http:u},chainDefault:{http:h}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){return t.map(i=>Vr.extendCaipNetwork(i,{customNetworkImageUrls:e,customRpcUrls:r,projectId:s}))},getViemTransport(t,e,s){var i,n,o;const r=[];return s==null||s.forEach(a=>{r.push(xn(a.url,a.config))}),Ea.includes(t.caipNetworkId)&&r.push(xn(dh(t.caipNetworkId,e),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),(o=(n=(i=t==null?void 0:t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null||o.forEach(a=>{r.push(xn(a))}),zc(r)},extendWagmiTransports(t,e,s){if(Ea.includes(t.caipNetworkId)){const r=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return zc([s,xn(r)])}return s},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:K.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){var c;const e=W.getActiveCaipNetworkId(),s=b.getAllRequestedCaipNetworks(),r=Array.from(((c=b.state.chains)==null?void 0:c.keys())||[]),i=e==null?void 0:e.split(":")[0],n=i?r.includes(i):!1,o=s==null?void 0:s.find(l=>l.caipNetworkId===e);return n&&!o&&e?this.getUnsupportedNetwork(e):o||t||(s==null?void 0:s[0])}},po={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},wt=xe({providers:{...po},providerIds:{...po}}),ke={state:wt,subscribeKey(t,e){return ot(wt,t,e)},subscribe(t){return nt(wt,()=>{t(wt)})},subscribeProviders(t){return nt(wt.providers,()=>t(wt.providers))},setProvider(t,e){e&&(wt.providers[t]=cr(e))},getProvider(t){return wt.providers[t]},setProviderId(t,e){e&&(wt.providerIds[t]=e)},getProviderId(t){if(t)return wt.providerIds[t]},reset(){wt.providers={...po},wt.providerIds={...po}},resetChain(t){wt.providers[t]=void 0,wt.providerIds[t]=void 0}},kN={VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}},mc={filterOutDuplicatesByRDNS(t){const e=B.state.enableEIP6963?H.state.connectors:[],s=W.getRecentWallets(),r=e.map(a=>{var c;return(c=a.info)==null?void 0:c.rdns}).filter(Boolean),i=s.map(a=>a.rdns).filter(Boolean),n=r.concat(i);if(n.includes("io.metamask.mobile")&&te.isMobile()){const a=n.indexOf("io.metamask.mobile");n[a]="io.metamask"}return t.filter(a=>!n.includes(String(a==null?void 0:a.rdns)))},filterOutDuplicatesByIds(t){const e=H.state.connectors.filter(a=>a.type==="ANNOUNCED"||a.type==="INJECTED"),s=W.getRecentWallets(),r=e.map(a=>a.explorerId),i=s.map(a=>a.id),n=r.concat(i);return t.filter(a=>!n.includes(a==null?void 0:a.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=H.state,{featuredWalletIds:s}=B.state,r=e.filter(o=>o.type==="ANNOUNCED").reduce((o,a)=>{var c;return(c=a.info)!=null&&c.rdns&&(o[a.info.rdns]=!0),o},{});return t.map(o=>({...o,installed:!!o.rdns&&!!r[o.rdns??""]})).sort((o,a)=>{const c=Number(a.installed)-Number(o.installed);if(c!==0)return c;if(s!=null&&s.length){const l=s.indexOf(o.id),u=s.indexOf(a.id);if(l!==-1&&u!==-1)return l-u;if(l!==-1)return-1;if(u!==-1)return 1}return 0})},getConnectOrderMethod(t,e){var c;const s=(t==null?void 0:t.connectMethodsOrder)||((c=B.state.features)==null?void 0:c.connectMethodsOrder),r=e||H.state.connectors;if(s)return s;const{injected:i,announced:n}=eo.getConnectorsByType(r,J.state.recommended,J.state.featured),o=i.filter(eo.showConnector),a=n.filter(eo.showConnector);return o.length||a.length?["wallet","email","social"]:kN.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(t){const e=!!t.rdns&&J.state.excludedWallets.some(r=>r.rdns===t.rdns),s=!!t.name&&J.state.excludedWallets.some(r=>Mc.isLowerCaseMatch(r.name,t.name));return e||s}},eo={getConnectorsByType(t,e,s){const{customWallets:r}=B.state,i=W.getRecentWallets(),n=mc.filterOutDuplicateWallets(e),o=mc.filterOutDuplicateWallets(s),a=t.filter(h=>h.type==="MULTI_CHAIN"),c=t.filter(h=>h.type==="ANNOUNCED"),l=t.filter(h=>h.type==="INJECTED"),u=t.filter(h=>h.type==="EXTERNAL");return{custom:r,recent:i,external:u,multiChain:a,announced:c,injected:l,recommended:n,featured:o}},showConnector(t){var i;const e=(i=t.info)==null?void 0:i.rdns,s=!!e&&J.state.excludedWallets.some(n=>!!n.rdns&&n.rdns===e),r=!!t.name&&J.state.excludedWallets.some(n=>Mc.isLowerCaseMatch(n.name,t.name));return!(t.type==="INJECTED"&&(t.name==="Browser Wallet"&&(!te.isMobile()||te.isMobile()&&!e&&!ee.checkInstalled())||s||r)||(t.type==="ANNOUNCED"||t.type==="EXTERNAL")&&(s||r))},getIsConnectedWithWC(){return Array.from(b.state.chains.values()).some(s=>H.getConnectorId(s.namespace)===K.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:s,recent:r,announced:i,injected:n,multiChain:o,external:a,overriddenConnectors:c=(l=>(l=B.state.features)==null?void 0:l.connectorTypeOrder)()??[]}){const u=eo.getIsConnectedWithWC(),f=[{type:"walletConnect",isEnabled:B.state.enableWalletConnect&&!u},{type:"recent",isEnabled:r.length>0},{type:"injected",isEnabled:[...n,...i,...o].length>0},{type:"featured",isEnabled:e.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:t.length>0}].filter(m=>m.isEnabled),y=new Set(f.map(m=>m.type)),g=c.filter(m=>y.has(m)).map(m=>({type:m,isEnabled:!0})),p=f.filter(({type:m})=>!g.some(({type:C})=>C===m));return Array.from(new Set([...g,...p].map(({type:m})=>m)))}};/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2019 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/const to=globalThis,qc=to.ShadowRoot&&(to.ShadyCSS===void 0||to.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jc=Symbol(),ph=new WeakMap;let Bp=class{constructor(e,s,r){if(this._$cssResult$=!0,r!==jc)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=s}get styleSheet(){let e=this.o;const s=this.t;if(qc&&e===void 0){const r=s!==void 0&&s.length===1;r&&(e=ph.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&ph.set(s,e))}return e}toString(){return this.cssText}};const Bt=t=>new Bp(typeof t=="string"?t:t+"",void 0,jc),ti=(t,...e)=>{const s=t.length===1?t[0]:e.reduce((r,i,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1],t[0]);return new Bp(s,t,jc)},RN=(t,e)=>{if(qc)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const r=document.createElement("style"),i=to.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=s.cssText,t.appendChild(r)}},fh=qc?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const r of e.cssRules)s+=r.cssText;return Bt(s)})(t):t;/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2017 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/const{is:UN,defineProperty:DN,getOwnPropertyDescriptor:LN,getOwnPropertyNames:BN,getOwnPropertySymbols:MN,getPrototypeOf:qN}=Object,qs=globalThis,gh=qs.trustedTypes,jN=gh?gh.emptyScript:"",Ca=qs.reactiveElementPolyfillSupport,rn=(t,e)=>t,wc={toAttribute(t,e){switch(e){case Boolean:t=t?jN:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=t!==null;break;case Number:s=t===null?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},Mp=(t,e)=>!UN(t,e),mh={attribute:!0,type:String,converter:wc,reflect:!1,useDefault:!1,hasChanged:Mp};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),qs.litPropertyMetadata??(qs.litPropertyMetadata=new WeakMap);let Kr=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,s=mh){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(e,s),!s.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,s);i!==void 0&&DN(this.prototype,e,i)}}static getPropertyDescriptor(e,s,r){const{get:i,set:n}=LN(this.prototype,e)??{get(){return this[s]},set(o){this[s]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??mh}static _$Ei(){if(this.hasOwnProperty(rn("elementProperties")))return;const e=qN(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(rn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(rn("properties"))){const s=this.properties,r=[...BN(s),...MN(s)];for(const i of r)this.createProperty(i,s[i])}const e=this[Symbol.metadata];if(e!==null){const s=litPropertyMetadata.get(e);if(s!==void 0)for(const[r,i]of s)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[s,r]of this.elementProperties){const i=this._$Eu(s,r);i!==void 0&&this._$Eh.set(i,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const s=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const i of r)s.unshift(fh(i))}else e!==void 0&&s.push(fh(e));return s}static _$Eu(e,s){const r=s.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(s=>this.enableUpdating=s),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(s=>s(this))}addController(e){var s;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)==null||s.call(e))}removeController(e){var s;(s=this._$EO)==null||s.delete(e)}_$E_(){const e=new Map,s=this.constructor.elementProperties;for(const r of s.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return RN(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostConnected)==null?void 0:r.call(s)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostDisconnected)==null?void 0:r.call(s)})}attributeChangedCallback(e,s,r){this._$AK(e,r)}_$ET(e,s){var n;const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const o=(((n=r.converter)==null?void 0:n.toAttribute)!==void 0?r.converter:wc).toAttribute(s,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,s){var n,o;const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const a=r.getPropertyOptions(i),c=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:wc;this._$Em=i;const l=c.fromAttribute(s,a.type);this[i]=l??((o=this._$Ej)==null?void 0:o.get(i))??l,this._$Em=null}}requestUpdate(e,s,r,i=!1,n){var o;if(e!==void 0){const a=this.constructor;if(i===!1&&(n=this[e]),r??(r=a.getPropertyOptions(e)),!((r.hasChanged??Mp)(n,s)||r.useDefault&&r.reflect&&n===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(a._$Eu(e,r))))return;this.C(e,s,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,s,{useDefault:r,reflect:i,wrapped:n},o){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??s??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(s=void 0),this._$AL.set(e,s)),i===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:a}=o,c=this[n];a!==!0||this._$AL.has(n)||c===void 0||this.C(n,void 0,o,c)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),(r=this._$EO)==null||r.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(s)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(s)}willUpdate(e){}_$AE(e){var s;(s=this._$EO)==null||s.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(s=>this._$ET(s,this[s]))),this._$EM()}updated(e){}firstUpdated(e){}};Kr.elementStyles=[],Kr.shadowRootOptions={mode:"open"},Kr[rn("elementProperties")]=new Map,Kr[rn("finalized")]=new Map,Ca==null||Ca({ReactiveElement:Kr}),(qs.reactiveElementVersions??(qs.reactiveElementVersions=[])).push("2.1.2");/**
|
|
23
|
+
* @license
|
|
24
|
+
* Copyright 2017 Google LLC
|
|
25
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
26
|
+
*/const nn=globalThis,wh=t=>t,fo=nn.trustedTypes,yh=fo?fo.createPolicy("lit-html",{createHTML:t=>t}):void 0,qp="$lit$",xs=`lit$${Math.random().toFixed(9).slice(2)}$`,jp="?"+xs,FN=`<${jp}>`,fr=document,mn=()=>fr.createComment(""),wn=t=>t===null||typeof t!="object"&&typeof t!="function",Fc=Array.isArray,zN=t=>Fc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Ia=`[
|
|
27
|
+
\f\r]`,qi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bh=/-->/g,vh=/>/g,Ks=RegExp(`>|${Ia}(?:([^\\s"'>=/]+)(${Ia}*=${Ia}*(?:[^
|
|
28
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Eh=/'/g,Ch=/"/g,Fp=/^(?:script|style|textarea|title)$/i,zp=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),eS=zp(1),tS=zp(2),wi=Symbol.for("lit-noChange"),Ke=Symbol.for("lit-nothing"),Ih=new WeakMap,sr=fr.createTreeWalker(fr,129);function Hp(t,e){if(!Fc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return yh!==void 0?yh.createHTML(e):e}const HN=(t,e)=>{const s=t.length-1,r=[];let i,n=e===2?"<svg>":e===3?"<math>":"",o=qi;for(let a=0;a<s;a++){const c=t[a];let l,u,h=-1,d=0;for(;d<c.length&&(o.lastIndex=d,u=o.exec(c),u!==null);)d=o.lastIndex,o===qi?u[1]==="!--"?o=bh:u[1]!==void 0?o=vh:u[2]!==void 0?(Fp.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Ks):u[3]!==void 0&&(o=Ks):o===Ks?u[0]===">"?(o=i??qi,h=-1):u[1]===void 0?h=-2:(h=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?Ks:u[3]==='"'?Ch:Eh):o===Ch||o===Eh?o=Ks:o===bh||o===vh?o=qi:(o=Ks,i=void 0);const f=o===Ks&&t[a+1].startsWith("/>")?" ":"";n+=o===qi?c+FN:h>=0?(r.push(l),c.slice(0,h)+qp+c.slice(h)+xs+f):c+xs+(h===-2?a:f)}return[Hp(t,n+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class yn{constructor({strings:e,_$litType$:s},r){let i;this.parts=[];let n=0,o=0;const a=e.length-1,c=this.parts,[l,u]=HN(e,s);if(this.el=yn.createElement(l,r),sr.currentNode=this.el.content,s===2||s===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=sr.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const h of i.getAttributeNames())if(h.endsWith(qp)){const d=u[o++],f=i.getAttribute(h).split(xs),y=/([.?@])?(.*)/.exec(d);c.push({type:1,index:n,name:y[2],strings:f,ctor:y[1]==="."?VN:y[1]==="?"?KN:y[1]==="@"?GN:ko}),i.removeAttribute(h)}else h.startsWith(xs)&&(c.push({type:6,index:n}),i.removeAttribute(h));if(Fp.test(i.tagName)){const h=i.textContent.split(xs),d=h.length-1;if(d>0){i.textContent=fo?fo.emptyScript:"";for(let f=0;f<d;f++)i.append(h[f],mn()),sr.nextNode(),c.push({type:2,index:++n});i.append(h[d],mn())}}}else if(i.nodeType===8)if(i.data===jp)c.push({type:2,index:n});else{let h=-1;for(;(h=i.data.indexOf(xs,h+1))!==-1;)c.push({type:7,index:n}),h+=xs.length-1}n++}}static createElement(e,s){const r=fr.createElement("template");return r.innerHTML=e,r}}function yi(t,e,s=t,r){var o,a;if(e===wi)return e;let i=r!==void 0?(o=s._$Co)==null?void 0:o[r]:s._$Cl;const n=wn(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),n===void 0?i=void 0:(i=new n(t),i._$AT(t,s,r)),r!==void 0?(s._$Co??(s._$Co=[]))[r]=i:s._$Cl=i),i!==void 0&&(e=yi(t,i._$AS(t,e.values),i,r)),e}class WN{constructor(e,s){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:s},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??fr).importNode(s,!0);sr.currentNode=i;let n=sr.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new $n(n,n.nextSibling,this,e):c.type===1?l=new c.ctor(n,c.name,c.strings,this,e):c.type===6&&(l=new JN(n,this,e)),this._$AV.push(l),c=r[++a]}o!==(c==null?void 0:c.index)&&(n=sr.nextNode(),o++)}return sr.currentNode=fr,i}p(e){let s=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,s),s+=r.strings.length-2):r._$AI(e[s])),s++}}class $n{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,s,r,i){this.type=2,this._$AH=Ke,this._$AN=void 0,this._$AA=e,this._$AB=s,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=yi(this,e,s),wn(e)?e===Ke||e==null||e===""?(this._$AH!==Ke&&this._$AR(),this._$AH=Ke):e!==this._$AH&&e!==wi&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zN(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Ke&&wn(this._$AH)?this._$AA.nextSibling.data=e:this.T(fr.createTextNode(e)),this._$AH=e}$(e){var n;const{values:s,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=yn.createElement(Hp(r.h,r.h[0]),this.options)),r);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(s);else{const o=new WN(i,this),a=o.u(this.options);o.p(s),this.T(a),this._$AH=o}}_$AC(e){let s=Ih.get(e.strings);return s===void 0&&Ih.set(e.strings,s=new yn(e)),s}k(e){Fc(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let r,i=0;for(const n of e)i===s.length?s.push(r=new $n(this.O(mn()),this.O(mn()),this,this.options)):r=s[i],r._$AI(n),i++;i<s.length&&(this._$AR(r&&r._$AB.nextSibling,i),s.length=i)}_$AR(e=this._$AA.nextSibling,s){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,s);e!==this._$AB;){const i=wh(e).nextSibling;wh(e).remove(),e=i}}setConnected(e){var s;this._$AM===void 0&&(this._$Cv=e,(s=this._$AP)==null||s.call(this,e))}}class ko{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,s,r,i,n){this.type=1,this._$AH=Ke,this._$AN=void 0,this.element=e,this.name=s,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Ke}_$AI(e,s=this,r,i){const n=this.strings;let o=!1;if(n===void 0)e=yi(this,e,s,0),o=!wn(e)||e!==this._$AH&&e!==wi,o&&(this._$AH=e);else{const a=e;let c,l;for(e=n[0],c=0;c<n.length-1;c++)l=yi(this,a[r+c],s,c),l===wi&&(l=this._$AH[c]),o||(o=!wn(l)||l!==this._$AH[c]),l===Ke?e=Ke:e!==Ke&&(e+=(l??"")+n[c+1]),this._$AH[c]=l}o&&!i&&this.j(e)}j(e){e===Ke?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class VN extends ko{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ke?void 0:e}}class KN extends ko{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ke)}}class GN extends ko{constructor(e,s,r,i,n){super(e,s,r,i,n),this.type=5}_$AI(e,s=this){if((e=yi(this,e,s,0)??Ke)===wi)return;const r=this._$AH,i=e===Ke&&r!==Ke||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,n=e!==Ke&&(r===Ke||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var s;typeof this._$AH=="function"?this._$AH.call(((s=this.options)==null?void 0:s.host)??this.element,e):this._$AH.handleEvent(e)}}class JN{constructor(e,s,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=s,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){yi(this,e)}}const Aa=nn.litHtmlPolyfillSupport;Aa==null||Aa(yn,$n),(nn.litHtmlVersions??(nn.litHtmlVersions=[])).push("3.3.2");const YN=(t,e,s)=>{const r=(s==null?void 0:s.renderBefore)??e;let i=r._$litPart$;if(i===void 0){const n=(s==null?void 0:s.renderBefore)??null;r._$litPart$=i=new $n(e.insertBefore(mn(),n),n,void 0,s??{})}return i._$AI(t),i};/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2017 Google LLC
|
|
31
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
32
|
+
*/const or=globalThis;class so extends Kr{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;const e=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=e.firstChild),e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=YN(s,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return wi}}var Sh;so._$litElement$=!0,so.finalized=!0,(Sh=or.litElementHydrateSupport)==null||Sh.call(or,{LitElement:so});const Na=or.litElementPolyfillSupport;Na==null||Na({LitElement:so});(or.litElementVersions??(or.litElementVersions=[])).push("4.2.2");let on,js,Fs;function sS(t,e){on=document.createElement("style"),js=document.createElement("style"),Fs=document.createElement("style"),on.textContent=si(t).core.cssText,js.textContent=si(t).dark.cssText,Fs.textContent=si(t).light.cssText,document.head.appendChild(on),document.head.appendChild(js),document.head.appendChild(Fs),Wp(e)}function Wp(t){js&&Fs&&(t==="light"?(js.removeAttribute("media"),Fs.media="enabled"):(Fs.removeAttribute("media"),js.media="enabled"))}function ZN(t){on&&js&&Fs&&(on.textContent=si(t).core.cssText,js.textContent=si(t).dark.cssText,Fs.textContent=si(t).light.cssText)}function si(t){return{core:ti`
|
|
33
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
34
|
+
@keyframes w3m-shake {
|
|
35
|
+
0% {
|
|
36
|
+
transform: scale(1) rotate(0deg);
|
|
37
|
+
}
|
|
38
|
+
20% {
|
|
39
|
+
transform: scale(1) rotate(-1deg);
|
|
40
|
+
}
|
|
41
|
+
40% {
|
|
42
|
+
transform: scale(1) rotate(1.5deg);
|
|
43
|
+
}
|
|
44
|
+
60% {
|
|
45
|
+
transform: scale(1) rotate(-1.5deg);
|
|
46
|
+
}
|
|
47
|
+
80% {
|
|
48
|
+
transform: scale(1) rotate(1deg);
|
|
49
|
+
}
|
|
50
|
+
100% {
|
|
51
|
+
transform: scale(1) rotate(0deg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
@keyframes w3m-iframe-fade-out {
|
|
55
|
+
0% {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
}
|
|
58
|
+
100% {
|
|
59
|
+
opacity: 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
@keyframes w3m-iframe-zoom-in {
|
|
63
|
+
0% {
|
|
64
|
+
transform: translateY(50px);
|
|
65
|
+
opacity: 0;
|
|
66
|
+
}
|
|
67
|
+
100% {
|
|
68
|
+
transform: translateY(0px);
|
|
69
|
+
opacity: 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
@keyframes w3m-iframe-zoom-in-mobile {
|
|
73
|
+
0% {
|
|
74
|
+
transform: scale(0.95);
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
100% {
|
|
78
|
+
transform: scale(1);
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
:root {
|
|
83
|
+
--w3m-modal-width: 360px;
|
|
84
|
+
--w3m-color-mix-strength: ${Bt(t!=null&&t["--w3m-color-mix-strength"]?`${t["--w3m-color-mix-strength"]}%`:"0%")};
|
|
85
|
+
--w3m-font-family: ${Bt((t==null?void 0:t["--w3m-font-family"])||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
86
|
+
--w3m-font-size-master: ${Bt((t==null?void 0:t["--w3m-font-size-master"])||"10px")};
|
|
87
|
+
--w3m-border-radius-master: ${Bt((t==null?void 0:t["--w3m-border-radius-master"])||"4px")};
|
|
88
|
+
--w3m-z-index: ${Bt((t==null?void 0:t["--w3m-z-index"])||999)};
|
|
89
|
+
|
|
90
|
+
--wui-font-family: var(--w3m-font-family);
|
|
91
|
+
|
|
92
|
+
--wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
|
|
93
|
+
--wui-font-size-micro: var(--w3m-font-size-master);
|
|
94
|
+
--wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
|
|
95
|
+
--wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
|
|
96
|
+
--wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
|
|
97
|
+
--wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
|
|
98
|
+
--wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
|
|
99
|
+
--wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
|
|
100
|
+
--wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
|
|
101
|
+
--wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
|
|
102
|
+
|
|
103
|
+
--wui-border-radius-5xs: var(--w3m-border-radius-master);
|
|
104
|
+
--wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
|
|
105
|
+
--wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
|
|
106
|
+
--wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
|
|
107
|
+
--wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
|
|
108
|
+
--wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
|
|
109
|
+
--wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
|
|
110
|
+
--wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
|
|
111
|
+
--wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
|
|
112
|
+
|
|
113
|
+
--wui-font-weight-light: 400;
|
|
114
|
+
--wui-font-weight-regular: 500;
|
|
115
|
+
--wui-font-weight-medium: 600;
|
|
116
|
+
--wui-font-weight-bold: 700;
|
|
117
|
+
|
|
118
|
+
--wui-letter-spacing-2xl: -1.6px;
|
|
119
|
+
--wui-letter-spacing-medium-title: -0.96px;
|
|
120
|
+
--wui-letter-spacing-title-6: -0.88px;
|
|
121
|
+
--wui-letter-spacing-large: -0.8px;
|
|
122
|
+
--wui-letter-spacing-medium: -0.72px;
|
|
123
|
+
--wui-letter-spacing-paragraph: -0.64px;
|
|
124
|
+
--wui-letter-spacing-small: -0.56px;
|
|
125
|
+
--wui-letter-spacing-tiny: -0.48px;
|
|
126
|
+
--wui-letter-spacing-micro: -0.2px;
|
|
127
|
+
--wui-letter-spacing-mini: -0.16px;
|
|
128
|
+
|
|
129
|
+
--wui-spacing-0: 0px;
|
|
130
|
+
--wui-spacing-4xs: 2px;
|
|
131
|
+
--wui-spacing-3xs: 4px;
|
|
132
|
+
--wui-spacing-xxs: 6px;
|
|
133
|
+
--wui-spacing-2xs: 7px;
|
|
134
|
+
--wui-spacing-xs: 8px;
|
|
135
|
+
--wui-spacing-1xs: 10px;
|
|
136
|
+
--wui-spacing-s: 12px;
|
|
137
|
+
--wui-spacing-m: 14px;
|
|
138
|
+
--wui-spacing-l: 16px;
|
|
139
|
+
--wui-spacing-2l: 18px;
|
|
140
|
+
--wui-spacing-xl: 20px;
|
|
141
|
+
--wui-spacing-xxl: 24px;
|
|
142
|
+
--wui-spacing-2xl: 32px;
|
|
143
|
+
--wui-spacing-3xl: 40px;
|
|
144
|
+
--wui-spacing-4xl: 90px;
|
|
145
|
+
--wui-spacing-5xl: 95px;
|
|
146
|
+
|
|
147
|
+
--wui-icon-box-size-xxs: 14px;
|
|
148
|
+
--wui-icon-box-size-xs: 20px;
|
|
149
|
+
--wui-icon-box-size-sm: 24px;
|
|
150
|
+
--wui-icon-box-size-md: 32px;
|
|
151
|
+
--wui-icon-box-size-mdl: 36px;
|
|
152
|
+
--wui-icon-box-size-lg: 40px;
|
|
153
|
+
--wui-icon-box-size-2lg: 48px;
|
|
154
|
+
--wui-icon-box-size-xl: 64px;
|
|
155
|
+
|
|
156
|
+
--wui-icon-size-inherit: inherit;
|
|
157
|
+
--wui-icon-size-xxs: 10px;
|
|
158
|
+
--wui-icon-size-xs: 12px;
|
|
159
|
+
--wui-icon-size-sm: 14px;
|
|
160
|
+
--wui-icon-size-md: 16px;
|
|
161
|
+
--wui-icon-size-mdl: 18px;
|
|
162
|
+
--wui-icon-size-lg: 20px;
|
|
163
|
+
--wui-icon-size-xl: 24px;
|
|
164
|
+
--wui-icon-size-xxl: 28px;
|
|
165
|
+
|
|
166
|
+
--wui-wallet-image-size-inherit: inherit;
|
|
167
|
+
--wui-wallet-image-size-sm: 40px;
|
|
168
|
+
--wui-wallet-image-size-md: 56px;
|
|
169
|
+
--wui-wallet-image-size-lg: 80px;
|
|
170
|
+
|
|
171
|
+
--wui-visual-size-size-inherit: inherit;
|
|
172
|
+
--wui-visual-size-sm: 40px;
|
|
173
|
+
--wui-visual-size-md: 55px;
|
|
174
|
+
--wui-visual-size-lg: 80px;
|
|
175
|
+
|
|
176
|
+
--wui-box-size-md: 100px;
|
|
177
|
+
--wui-box-size-lg: 120px;
|
|
178
|
+
|
|
179
|
+
--wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
|
|
180
|
+
--wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
|
|
181
|
+
|
|
182
|
+
--wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
|
|
183
|
+
--wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
|
|
184
|
+
--wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
|
|
185
|
+
|
|
186
|
+
--wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
|
|
187
|
+
|
|
188
|
+
--wui-duration-lg: 200ms;
|
|
189
|
+
--wui-duration-md: 125ms;
|
|
190
|
+
--wui-duration-sm: 75ms;
|
|
191
|
+
|
|
192
|
+
--wui-path-network-sm: path(
|
|
193
|
+
'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
--wui-path-network-md: path(
|
|
197
|
+
'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
--wui-path-network-lg: path(
|
|
201
|
+
'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
--wui-width-network-sm: 36px;
|
|
205
|
+
--wui-width-network-md: 48px;
|
|
206
|
+
--wui-width-network-lg: 86px;
|
|
207
|
+
|
|
208
|
+
--wui-height-network-sm: 40px;
|
|
209
|
+
--wui-height-network-md: 54px;
|
|
210
|
+
--wui-height-network-lg: 96px;
|
|
211
|
+
|
|
212
|
+
--wui-icon-size-network-xs: 12px;
|
|
213
|
+
--wui-icon-size-network-sm: 16px;
|
|
214
|
+
--wui-icon-size-network-md: 24px;
|
|
215
|
+
--wui-icon-size-network-lg: 42px;
|
|
216
|
+
|
|
217
|
+
--wui-color-inherit: inherit;
|
|
218
|
+
|
|
219
|
+
--wui-color-inverse-100: #fff;
|
|
220
|
+
--wui-color-inverse-000: #000;
|
|
221
|
+
|
|
222
|
+
--wui-cover: rgba(20, 20, 20, 0.8);
|
|
223
|
+
|
|
224
|
+
--wui-color-modal-bg: var(--wui-color-modal-bg-base);
|
|
225
|
+
|
|
226
|
+
--wui-color-accent-100: var(--wui-color-accent-base-100);
|
|
227
|
+
--wui-color-accent-090: var(--wui-color-accent-base-090);
|
|
228
|
+
--wui-color-accent-080: var(--wui-color-accent-base-080);
|
|
229
|
+
|
|
230
|
+
--wui-color-success-100: var(--wui-color-success-base-100);
|
|
231
|
+
--wui-color-success-125: var(--wui-color-success-base-125);
|
|
232
|
+
|
|
233
|
+
--wui-color-warning-100: var(--wui-color-warning-base-100);
|
|
234
|
+
|
|
235
|
+
--wui-color-error-100: var(--wui-color-error-base-100);
|
|
236
|
+
--wui-color-error-125: var(--wui-color-error-base-125);
|
|
237
|
+
|
|
238
|
+
--wui-color-blue-100: var(--wui-color-blue-base-100);
|
|
239
|
+
--wui-color-blue-90: var(--wui-color-blue-base-90);
|
|
240
|
+
|
|
241
|
+
--wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
|
|
242
|
+
--wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
|
|
243
|
+
--wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
|
|
244
|
+
--wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
|
|
245
|
+
|
|
246
|
+
--wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
|
|
247
|
+
|
|
248
|
+
--wui-avatar-border: var(--wui-avatar-border-base);
|
|
249
|
+
|
|
250
|
+
--wui-thumbnail-border: var(--wui-thumbnail-border-base);
|
|
251
|
+
|
|
252
|
+
--wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
|
|
253
|
+
|
|
254
|
+
--wui-box-shadow-blue: var(--wui-color-accent-glass-020);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@supports (background: color-mix(in srgb, white 50%, black)) {
|
|
258
|
+
:root {
|
|
259
|
+
--wui-color-modal-bg: color-mix(
|
|
260
|
+
in srgb,
|
|
261
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
262
|
+
var(--wui-color-modal-bg-base)
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
--wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
|
|
266
|
+
|
|
267
|
+
--wui-color-accent-100: color-mix(
|
|
268
|
+
in srgb,
|
|
269
|
+
var(--wui-color-accent-base-100) 100%,
|
|
270
|
+
transparent
|
|
271
|
+
);
|
|
272
|
+
--wui-color-accent-090: color-mix(
|
|
273
|
+
in srgb,
|
|
274
|
+
var(--wui-color-accent-base-100) 90%,
|
|
275
|
+
transparent
|
|
276
|
+
);
|
|
277
|
+
--wui-color-accent-080: color-mix(
|
|
278
|
+
in srgb,
|
|
279
|
+
var(--wui-color-accent-base-100) 80%,
|
|
280
|
+
transparent
|
|
281
|
+
);
|
|
282
|
+
--wui-color-accent-glass-090: color-mix(
|
|
283
|
+
in srgb,
|
|
284
|
+
var(--wui-color-accent-base-100) 90%,
|
|
285
|
+
transparent
|
|
286
|
+
);
|
|
287
|
+
--wui-color-accent-glass-080: color-mix(
|
|
288
|
+
in srgb,
|
|
289
|
+
var(--wui-color-accent-base-100) 80%,
|
|
290
|
+
transparent
|
|
291
|
+
);
|
|
292
|
+
--wui-color-accent-glass-020: color-mix(
|
|
293
|
+
in srgb,
|
|
294
|
+
var(--wui-color-accent-base-100) 20%,
|
|
295
|
+
transparent
|
|
296
|
+
);
|
|
297
|
+
--wui-color-accent-glass-015: color-mix(
|
|
298
|
+
in srgb,
|
|
299
|
+
var(--wui-color-accent-base-100) 15%,
|
|
300
|
+
transparent
|
|
301
|
+
);
|
|
302
|
+
--wui-color-accent-glass-010: color-mix(
|
|
303
|
+
in srgb,
|
|
304
|
+
var(--wui-color-accent-base-100) 10%,
|
|
305
|
+
transparent
|
|
306
|
+
);
|
|
307
|
+
--wui-color-accent-glass-005: color-mix(
|
|
308
|
+
in srgb,
|
|
309
|
+
var(--wui-color-accent-base-100) 5%,
|
|
310
|
+
transparent
|
|
311
|
+
);
|
|
312
|
+
--wui-color-accent-002: color-mix(
|
|
313
|
+
in srgb,
|
|
314
|
+
var(--wui-color-accent-base-100) 2%,
|
|
315
|
+
transparent
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
--wui-color-fg-100: color-mix(
|
|
319
|
+
in srgb,
|
|
320
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
321
|
+
var(--wui-color-fg-100)
|
|
322
|
+
);
|
|
323
|
+
--wui-color-fg-125: color-mix(
|
|
324
|
+
in srgb,
|
|
325
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
326
|
+
var(--wui-color-fg-125)
|
|
327
|
+
);
|
|
328
|
+
--wui-color-fg-150: color-mix(
|
|
329
|
+
in srgb,
|
|
330
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
331
|
+
var(--wui-color-fg-150)
|
|
332
|
+
);
|
|
333
|
+
--wui-color-fg-175: color-mix(
|
|
334
|
+
in srgb,
|
|
335
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
336
|
+
var(--wui-color-fg-175)
|
|
337
|
+
);
|
|
338
|
+
--wui-color-fg-200: color-mix(
|
|
339
|
+
in srgb,
|
|
340
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
341
|
+
var(--wui-color-fg-200)
|
|
342
|
+
);
|
|
343
|
+
--wui-color-fg-225: color-mix(
|
|
344
|
+
in srgb,
|
|
345
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
346
|
+
var(--wui-color-fg-225)
|
|
347
|
+
);
|
|
348
|
+
--wui-color-fg-250: color-mix(
|
|
349
|
+
in srgb,
|
|
350
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
351
|
+
var(--wui-color-fg-250)
|
|
352
|
+
);
|
|
353
|
+
--wui-color-fg-275: color-mix(
|
|
354
|
+
in srgb,
|
|
355
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
356
|
+
var(--wui-color-fg-275)
|
|
357
|
+
);
|
|
358
|
+
--wui-color-fg-300: color-mix(
|
|
359
|
+
in srgb,
|
|
360
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
361
|
+
var(--wui-color-fg-300)
|
|
362
|
+
);
|
|
363
|
+
--wui-color-fg-325: color-mix(
|
|
364
|
+
in srgb,
|
|
365
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
366
|
+
var(--wui-color-fg-325)
|
|
367
|
+
);
|
|
368
|
+
--wui-color-fg-350: color-mix(
|
|
369
|
+
in srgb,
|
|
370
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
371
|
+
var(--wui-color-fg-350)
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
--wui-color-bg-100: color-mix(
|
|
375
|
+
in srgb,
|
|
376
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
377
|
+
var(--wui-color-bg-100)
|
|
378
|
+
);
|
|
379
|
+
--wui-color-bg-125: color-mix(
|
|
380
|
+
in srgb,
|
|
381
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
382
|
+
var(--wui-color-bg-125)
|
|
383
|
+
);
|
|
384
|
+
--wui-color-bg-150: color-mix(
|
|
385
|
+
in srgb,
|
|
386
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
387
|
+
var(--wui-color-bg-150)
|
|
388
|
+
);
|
|
389
|
+
--wui-color-bg-175: color-mix(
|
|
390
|
+
in srgb,
|
|
391
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
392
|
+
var(--wui-color-bg-175)
|
|
393
|
+
);
|
|
394
|
+
--wui-color-bg-200: color-mix(
|
|
395
|
+
in srgb,
|
|
396
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
397
|
+
var(--wui-color-bg-200)
|
|
398
|
+
);
|
|
399
|
+
--wui-color-bg-225: color-mix(
|
|
400
|
+
in srgb,
|
|
401
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
402
|
+
var(--wui-color-bg-225)
|
|
403
|
+
);
|
|
404
|
+
--wui-color-bg-250: color-mix(
|
|
405
|
+
in srgb,
|
|
406
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
407
|
+
var(--wui-color-bg-250)
|
|
408
|
+
);
|
|
409
|
+
--wui-color-bg-275: color-mix(
|
|
410
|
+
in srgb,
|
|
411
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
412
|
+
var(--wui-color-bg-275)
|
|
413
|
+
);
|
|
414
|
+
--wui-color-bg-300: color-mix(
|
|
415
|
+
in srgb,
|
|
416
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
417
|
+
var(--wui-color-bg-300)
|
|
418
|
+
);
|
|
419
|
+
--wui-color-bg-325: color-mix(
|
|
420
|
+
in srgb,
|
|
421
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
422
|
+
var(--wui-color-bg-325)
|
|
423
|
+
);
|
|
424
|
+
--wui-color-bg-350: color-mix(
|
|
425
|
+
in srgb,
|
|
426
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
427
|
+
var(--wui-color-bg-350)
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
--wui-color-success-100: color-mix(
|
|
431
|
+
in srgb,
|
|
432
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
433
|
+
var(--wui-color-success-base-100)
|
|
434
|
+
);
|
|
435
|
+
--wui-color-success-125: color-mix(
|
|
436
|
+
in srgb,
|
|
437
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
438
|
+
var(--wui-color-success-base-125)
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
--wui-color-warning-100: color-mix(
|
|
442
|
+
in srgb,
|
|
443
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
444
|
+
var(--wui-color-warning-base-100)
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
--wui-color-error-100: color-mix(
|
|
448
|
+
in srgb,
|
|
449
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
450
|
+
var(--wui-color-error-base-100)
|
|
451
|
+
);
|
|
452
|
+
--wui-color-blue-100: color-mix(
|
|
453
|
+
in srgb,
|
|
454
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
455
|
+
var(--wui-color-blue-base-100)
|
|
456
|
+
);
|
|
457
|
+
--wui-color-blue-90: color-mix(
|
|
458
|
+
in srgb,
|
|
459
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
460
|
+
var(--wui-color-blue-base-90)
|
|
461
|
+
);
|
|
462
|
+
--wui-color-error-125: color-mix(
|
|
463
|
+
in srgb,
|
|
464
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
465
|
+
var(--wui-color-error-base-125)
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
--wui-icon-box-bg-error-100: color-mix(
|
|
469
|
+
in srgb,
|
|
470
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
471
|
+
var(--wui-icon-box-bg-error-base-100)
|
|
472
|
+
);
|
|
473
|
+
--wui-icon-box-bg-accent-100: color-mix(
|
|
474
|
+
in srgb,
|
|
475
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
476
|
+
var(--wui-icon-box-bg-blue-base-100)
|
|
477
|
+
);
|
|
478
|
+
--wui-icon-box-bg-success-100: color-mix(
|
|
479
|
+
in srgb,
|
|
480
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
481
|
+
var(--wui-icon-box-bg-success-base-100)
|
|
482
|
+
);
|
|
483
|
+
--wui-icon-box-bg-inverse-100: color-mix(
|
|
484
|
+
in srgb,
|
|
485
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
486
|
+
var(--wui-icon-box-bg-inverse-base-100)
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
--wui-all-wallets-bg-100: color-mix(
|
|
490
|
+
in srgb,
|
|
491
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
492
|
+
var(--wui-all-wallets-bg-100)
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
--wui-avatar-border: color-mix(
|
|
496
|
+
in srgb,
|
|
497
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
498
|
+
var(--wui-avatar-border-base)
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
--wui-thumbnail-border: color-mix(
|
|
502
|
+
in srgb,
|
|
503
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
504
|
+
var(--wui-thumbnail-border-base)
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
--wui-wallet-button-bg: color-mix(
|
|
508
|
+
in srgb,
|
|
509
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
510
|
+
var(--wui-wallet-button-bg-base)
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
`,light:ti`
|
|
515
|
+
:root {
|
|
516
|
+
--w3m-color-mix: ${Bt((t==null?void 0:t["--w3m-color-mix"])||"#fff")};
|
|
517
|
+
--w3m-accent: ${Bt(ks(t,"dark")["--w3m-accent"])};
|
|
518
|
+
--w3m-default: #fff;
|
|
519
|
+
|
|
520
|
+
--wui-color-modal-bg-base: ${Bt(ks(t,"dark")["--w3m-background"])};
|
|
521
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
522
|
+
|
|
523
|
+
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
524
|
+
--wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
|
|
525
|
+
--wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
|
|
526
|
+
--wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
|
|
527
|
+
|
|
528
|
+
--wui-color-fg-100: #e4e7e7;
|
|
529
|
+
--wui-color-fg-125: #d0d5d5;
|
|
530
|
+
--wui-color-fg-150: #a8b1b1;
|
|
531
|
+
--wui-color-fg-175: #a8b0b0;
|
|
532
|
+
--wui-color-fg-200: #949e9e;
|
|
533
|
+
--wui-color-fg-225: #868f8f;
|
|
534
|
+
--wui-color-fg-250: #788080;
|
|
535
|
+
--wui-color-fg-275: #788181;
|
|
536
|
+
--wui-color-fg-300: #6e7777;
|
|
537
|
+
--wui-color-fg-325: #9a9a9a;
|
|
538
|
+
--wui-color-fg-350: #363636;
|
|
539
|
+
|
|
540
|
+
--wui-color-bg-100: #141414;
|
|
541
|
+
--wui-color-bg-125: #191a1a;
|
|
542
|
+
--wui-color-bg-150: #1e1f1f;
|
|
543
|
+
--wui-color-bg-175: #222525;
|
|
544
|
+
--wui-color-bg-200: #272a2a;
|
|
545
|
+
--wui-color-bg-225: #2c3030;
|
|
546
|
+
--wui-color-bg-250: #313535;
|
|
547
|
+
--wui-color-bg-275: #363b3b;
|
|
548
|
+
--wui-color-bg-300: #3b4040;
|
|
549
|
+
--wui-color-bg-325: #252525;
|
|
550
|
+
--wui-color-bg-350: #ffffff;
|
|
551
|
+
|
|
552
|
+
--wui-color-success-base-100: #26d962;
|
|
553
|
+
--wui-color-success-base-125: #30a46b;
|
|
554
|
+
|
|
555
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
556
|
+
|
|
557
|
+
--wui-color-error-base-100: #f25a67;
|
|
558
|
+
--wui-color-error-base-125: #df4a34;
|
|
559
|
+
|
|
560
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
561
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
562
|
+
|
|
563
|
+
--wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
|
|
564
|
+
--wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
|
|
565
|
+
--wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
|
|
566
|
+
--wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
|
|
567
|
+
--wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
|
|
568
|
+
--wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
|
|
569
|
+
--wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
|
|
570
|
+
--wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
|
|
571
|
+
--wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
|
|
572
|
+
--wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
|
|
573
|
+
|
|
574
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
575
|
+
|
|
576
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
577
|
+
|
|
578
|
+
--wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
|
|
579
|
+
--wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
|
|
580
|
+
--wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
|
|
581
|
+
--wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
|
|
582
|
+
--wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
|
|
583
|
+
--wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
|
|
584
|
+
--wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
|
|
585
|
+
--wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
|
|
586
|
+
--wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
|
|
587
|
+
--wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
|
|
588
|
+
|
|
589
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
590
|
+
|
|
591
|
+
--wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
|
|
592
|
+
--wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
|
|
593
|
+
--wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
|
|
594
|
+
--wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
|
|
595
|
+
--wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
|
|
596
|
+
--wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
|
|
597
|
+
--wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
|
|
598
|
+
--wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
|
|
599
|
+
--wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
|
|
600
|
+
--wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
|
|
601
|
+
--wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
|
|
602
|
+
|
|
603
|
+
--wui-color-dark-glass-100: rgba(42, 42, 42, 1);
|
|
604
|
+
|
|
605
|
+
--wui-icon-box-bg-error-base-100: #3c2426;
|
|
606
|
+
--wui-icon-box-bg-blue-base-100: #20303f;
|
|
607
|
+
--wui-icon-box-bg-success-base-100: #1f3a28;
|
|
608
|
+
--wui-icon-box-bg-inverse-base-100: #243240;
|
|
609
|
+
|
|
610
|
+
--wui-all-wallets-bg-100: #222b35;
|
|
611
|
+
|
|
612
|
+
--wui-avatar-border-base: #252525;
|
|
613
|
+
|
|
614
|
+
--wui-thumbnail-border-base: #252525;
|
|
615
|
+
|
|
616
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
617
|
+
|
|
618
|
+
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
619
|
+
}
|
|
620
|
+
`,dark:ti`
|
|
621
|
+
:root {
|
|
622
|
+
--w3m-color-mix: ${Bt((t==null?void 0:t["--w3m-color-mix"])||"#000")};
|
|
623
|
+
--w3m-accent: ${Bt(ks(t,"light")["--w3m-accent"])};
|
|
624
|
+
--w3m-default: #000;
|
|
625
|
+
|
|
626
|
+
--wui-color-modal-bg-base: ${Bt(ks(t,"light")["--w3m-background"])};
|
|
627
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
628
|
+
|
|
629
|
+
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
630
|
+
--wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
|
|
631
|
+
--wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
|
|
632
|
+
|
|
633
|
+
--wui-color-fg-100: #141414;
|
|
634
|
+
--wui-color-fg-125: #2d3131;
|
|
635
|
+
--wui-color-fg-150: #474d4d;
|
|
636
|
+
--wui-color-fg-175: #636d6d;
|
|
637
|
+
--wui-color-fg-200: #798686;
|
|
638
|
+
--wui-color-fg-225: #828f8f;
|
|
639
|
+
--wui-color-fg-250: #8b9797;
|
|
640
|
+
--wui-color-fg-275: #95a0a0;
|
|
641
|
+
--wui-color-fg-300: #9ea9a9;
|
|
642
|
+
--wui-color-fg-325: #9a9a9a;
|
|
643
|
+
--wui-color-fg-350: #d0d0d0;
|
|
644
|
+
|
|
645
|
+
--wui-color-bg-100: #ffffff;
|
|
646
|
+
--wui-color-bg-125: #f5fafa;
|
|
647
|
+
--wui-color-bg-150: #f3f8f8;
|
|
648
|
+
--wui-color-bg-175: #eef4f4;
|
|
649
|
+
--wui-color-bg-200: #eaf1f1;
|
|
650
|
+
--wui-color-bg-225: #e5eded;
|
|
651
|
+
--wui-color-bg-250: #e1e9e9;
|
|
652
|
+
--wui-color-bg-275: #dce7e7;
|
|
653
|
+
--wui-color-bg-300: #d8e3e3;
|
|
654
|
+
--wui-color-bg-325: #f3f3f3;
|
|
655
|
+
--wui-color-bg-350: #202020;
|
|
656
|
+
|
|
657
|
+
--wui-color-success-base-100: #26b562;
|
|
658
|
+
--wui-color-success-base-125: #30a46b;
|
|
659
|
+
|
|
660
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
661
|
+
|
|
662
|
+
--wui-color-error-base-100: #f05142;
|
|
663
|
+
--wui-color-error-base-125: #df4a34;
|
|
664
|
+
|
|
665
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
666
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
667
|
+
|
|
668
|
+
--wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
|
|
669
|
+
--wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
|
|
670
|
+
--wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
|
|
671
|
+
--wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
|
|
672
|
+
--wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
|
|
673
|
+
--wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
|
|
674
|
+
--wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
|
|
675
|
+
--wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
|
|
676
|
+
--wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
|
|
677
|
+
--wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
|
|
678
|
+
|
|
679
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
680
|
+
|
|
681
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
682
|
+
|
|
683
|
+
--wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
|
|
684
|
+
--wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
|
|
685
|
+
--wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
|
|
686
|
+
--wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
|
|
687
|
+
--wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
|
|
688
|
+
--wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
|
|
689
|
+
--wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
|
|
690
|
+
--wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
|
|
691
|
+
--wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
|
|
692
|
+
--wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
|
|
693
|
+
|
|
694
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
695
|
+
|
|
696
|
+
--wui-icon-box-bg-error-base-100: #f4dfdd;
|
|
697
|
+
--wui-icon-box-bg-blue-base-100: #d9ecfb;
|
|
698
|
+
--wui-icon-box-bg-success-base-100: #daf0e4;
|
|
699
|
+
--wui-icon-box-bg-inverse-base-100: #dcecfc;
|
|
700
|
+
|
|
701
|
+
--wui-all-wallets-bg-100: #e8f1fa;
|
|
702
|
+
|
|
703
|
+
--wui-avatar-border-base: #f3f4f4;
|
|
704
|
+
|
|
705
|
+
--wui-thumbnail-border-base: #eaefef;
|
|
706
|
+
|
|
707
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
708
|
+
|
|
709
|
+
--wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
|
|
710
|
+
--wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
|
|
711
|
+
--wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
|
|
712
|
+
--wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
|
|
713
|
+
--wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
|
|
714
|
+
--wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
|
|
715
|
+
--wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
|
|
716
|
+
--wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
|
|
717
|
+
--wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
|
|
718
|
+
--wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
|
|
719
|
+
--wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
|
|
720
|
+
|
|
721
|
+
--wui-color-dark-glass-100: rgba(233, 233, 233, 1);
|
|
722
|
+
|
|
723
|
+
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
724
|
+
}
|
|
725
|
+
`}}const rS=ti`
|
|
726
|
+
*,
|
|
727
|
+
*::after,
|
|
728
|
+
*::before,
|
|
729
|
+
:host {
|
|
730
|
+
margin: 0;
|
|
731
|
+
padding: 0;
|
|
732
|
+
box-sizing: border-box;
|
|
733
|
+
font-style: normal;
|
|
734
|
+
text-rendering: optimizeSpeed;
|
|
735
|
+
-webkit-font-smoothing: antialiased;
|
|
736
|
+
-moz-osx-font-smoothing: grayscale;
|
|
737
|
+
-webkit-tap-highlight-color: transparent;
|
|
738
|
+
font-family: var(--wui-font-family);
|
|
739
|
+
backface-visibility: hidden;
|
|
740
|
+
}
|
|
741
|
+
`,iS=ti`
|
|
742
|
+
button,
|
|
743
|
+
a {
|
|
744
|
+
cursor: pointer;
|
|
745
|
+
display: flex;
|
|
746
|
+
justify-content: center;
|
|
747
|
+
align-items: center;
|
|
748
|
+
position: relative;
|
|
749
|
+
transition:
|
|
750
|
+
color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
751
|
+
background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
752
|
+
border var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
753
|
+
border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
754
|
+
box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
755
|
+
will-change: background-color, color, border, box-shadow, border-radius;
|
|
756
|
+
outline: none;
|
|
757
|
+
border: none;
|
|
758
|
+
column-gap: var(--wui-spacing-3xs);
|
|
759
|
+
background-color: transparent;
|
|
760
|
+
text-decoration: none;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
wui-flex {
|
|
764
|
+
transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
765
|
+
will-change: border-radius;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
button:disabled > wui-wallet-image,
|
|
769
|
+
button:disabled > wui-all-wallets-image,
|
|
770
|
+
button:disabled > wui-network-image,
|
|
771
|
+
button:disabled > wui-image,
|
|
772
|
+
button:disabled > wui-transaction-visual,
|
|
773
|
+
button:disabled > wui-logo {
|
|
774
|
+
filter: grayscale(1);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
@media (hover: hover) and (pointer: fine) {
|
|
778
|
+
button:hover:enabled {
|
|
779
|
+
background-color: var(--wui-color-gray-glass-005);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
button:active:enabled {
|
|
783
|
+
background-color: var(--wui-color-gray-glass-010);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
button:disabled > wui-icon-box {
|
|
788
|
+
opacity: 0.5;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
input {
|
|
792
|
+
border: none;
|
|
793
|
+
outline: none;
|
|
794
|
+
appearance: none;
|
|
795
|
+
}
|
|
796
|
+
`,nS=ti`
|
|
797
|
+
.wui-color-inherit {
|
|
798
|
+
color: var(--wui-color-inherit);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.wui-color-accent-100 {
|
|
802
|
+
color: var(--wui-color-accent-100);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.wui-color-error-100 {
|
|
806
|
+
color: var(--wui-color-error-100);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.wui-color-blue-100 {
|
|
810
|
+
color: var(--wui-color-blue-100);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.wui-color-blue-90 {
|
|
814
|
+
color: var(--wui-color-blue-90);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
.wui-color-error-125 {
|
|
818
|
+
color: var(--wui-color-error-125);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.wui-color-success-100 {
|
|
822
|
+
color: var(--wui-color-success-100);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.wui-color-success-125 {
|
|
826
|
+
color: var(--wui-color-success-125);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.wui-color-inverse-100 {
|
|
830
|
+
color: var(--wui-color-inverse-100);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.wui-color-inverse-000 {
|
|
834
|
+
color: var(--wui-color-inverse-000);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.wui-color-fg-100 {
|
|
838
|
+
color: var(--wui-color-fg-100);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
.wui-color-fg-200 {
|
|
842
|
+
color: var(--wui-color-fg-200);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.wui-color-fg-300 {
|
|
846
|
+
color: var(--wui-color-fg-300);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
.wui-color-fg-325 {
|
|
850
|
+
color: var(--wui-color-fg-325);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.wui-color-fg-350 {
|
|
854
|
+
color: var(--wui-color-fg-350);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.wui-bg-color-inherit {
|
|
858
|
+
background-color: var(--wui-color-inherit);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.wui-bg-color-blue-100 {
|
|
862
|
+
background-color: var(--wui-color-accent-100);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.wui-bg-color-error-100 {
|
|
866
|
+
background-color: var(--wui-color-error-100);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.wui-bg-color-error-125 {
|
|
870
|
+
background-color: var(--wui-color-error-125);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.wui-bg-color-success-100 {
|
|
874
|
+
background-color: var(--wui-color-success-100);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.wui-bg-color-success-125 {
|
|
878
|
+
background-color: var(--wui-color-success-100);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
.wui-bg-color-inverse-100 {
|
|
882
|
+
background-color: var(--wui-color-inverse-100);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
.wui-bg-color-inverse-000 {
|
|
886
|
+
background-color: var(--wui-color-inverse-000);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.wui-bg-color-fg-100 {
|
|
890
|
+
background-color: var(--wui-color-fg-100);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
.wui-bg-color-fg-200 {
|
|
894
|
+
background-color: var(--wui-color-fg-200);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
.wui-bg-color-fg-300 {
|
|
898
|
+
background-color: var(--wui-color-fg-300);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.wui-color-fg-325 {
|
|
902
|
+
background-color: var(--wui-color-fg-325);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.wui-color-fg-350 {
|
|
906
|
+
background-color: var(--wui-color-fg-350);
|
|
907
|
+
}
|
|
908
|
+
`,Ki={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"]};function Tn(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const Ah=Tn({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),Nh=Tn({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"});Tn({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});Tn({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Tn({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const XN={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},ro={getMethodsByChainNamespace(t){return XN[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const s={...t},r=new Set;if(e.methods&&Object.keys(e.methods).forEach(i=>r.add(i)),e.chains&&Object.keys(e.chains).forEach(i=>r.add(i)),e.events&&Object.keys(e.events).forEach(i=>r.add(i)),e.rpcMap&&Object.keys(e.rpcMap).forEach(i=>{const[n]=i.split(":");n&&r.add(n)}),r.forEach(i=>{s[i]||(s[i]=this.createDefaultNamespace(i))}),e.methods&&Object.entries(e.methods).forEach(([i,n])=>{s[i]&&(s[i].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([i,n])=>{s[i]&&(s[i].chains=n)}),e.events&&Object.entries(e.events).forEach(([i,n])=>{s[i]&&(s[i].events=n)}),e.rpcMap){const i=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,c]=n.split(":");!a||!c||!s[a]||(s[a].rpcMap||(s[a].rpcMap={}),i.has(a)||(s[a].rpcMap={},i.add(a)),s[a].rpcMap[c]=o)})}return s},createNamespaces(t,e){const s=t.reduce((r,i)=>{const{id:n,chainNamespace:o,rpcUrls:a}=i,c=a.default.http[0];r[o]||(r[o]=this.createDefaultNamespace(o));const l=`${o}:${n}`,u=r[o];switch(u.chains.push(l),l){case Ah.caipNetworkId:u.chains.push(Ah.deprecatedCaipNetworkId);break;case Nh.caipNetworkId:u.chains.push(Nh.deprecatedCaipNetworkId);break}return u!=null&&u.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await Zi.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class Vp{constructor({provider:e,namespace:s}){this.id=K.CONNECTOR_ID.WALLET_CONNECT,this.name=ho.ConnectorNamesMap[K.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=ho.ConnectorImageIds[K.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=b.getCaipNetworks.bind(b),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=s}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const s=this.getCaipNetworks(),r=B.state.universalProviderConfigOverride,i=ro.createNamespaces(s,r);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(s=>s.caipNetworkId);return sn.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:QN})}}const QN=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class e_{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>b.getCaipNetworks(s),e&&this.construct(e)}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.getCaipNetworks(this.namespace)}setAuthProvider(e){this.addConnector({id:K.CONNECTOR_ID.AUTH,type:"AUTH",name:K.CONNECTOR_NAMES.AUTH,provider:e,imageId:ho.ConnectorImageIds[K.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const s=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(r=>s.has(r.id)?!1:(s.add(r.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,s){V.setStatus(e,s)}on(e,s){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=V.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof Vp);if(!e)throw new Error("WalletConnectConnector not found");return e}}class t_ extends e_{setUniversalProvider(e){this.addConnector(new Vp({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,u)=>u.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Pe.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(V.state.balanceLoading&&e.chainId===((c=b.state.activeCaipNetwork)==null?void 0:c.id))return{balance:V.state.balance||"0.00",symbol:V.state.balanceSymbol||""};const i=(await V.fetchTokenBalance()).find(u=>{var h,d;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=b.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===K.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:Th.encode(new TextEncoder().encode(r)),pubkey:i}},(a=b.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=b.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===K.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:Hc(s.id)}]}))}catch(u){if(u.code===Ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===Ki.ERROR_INVALID_CHAIN_ID||u.code===Ki.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===Ki.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Hc(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const s_=["email","socials","swaps","onramp","activity","reownBranding"],Jn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Pe.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Pe.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},r_={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=Jn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=Jn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return Jn[t].processApi(e)},processFallbackFeature(t,e){return Jn[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let r=null,i=!1;try{r=await J.fetchProjectConfig(),i=r!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=i&&!e?Pe.DEFAULT_REMOTE_FEATURES:Pe.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of s_){const a=this.processFeature(o,s,r,i,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Pe.DEFAULT_REMOTE_FEATURES}if(i&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Js.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${o}`},"warning")}return n}};class i_{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=b.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(h=>h.id===r);if(c)return c;const l=(o=b.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=b.getRequestedCaipNetworks(s).filter(h=>h.chainNamespace===s))==null?void 0:a[0])}return b.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>b.getCaipNetworks(s),this.getActiveChainNamespace=()=>b.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{b.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>b.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>b.state.activeChain===s||!s?b.state.activeCaipAddress:b.getAccountProp("caipAddress",s),this.setClientId=s=>{Q.setClientId(s)},this.getProvider=s=>ke.getProvider(s),this.getProviderType=s=>ke.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=V.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{V.setCaipAddress(s,r),s&&B.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{V.setBalance(s,r,i)},this.setProfileName=(s,r)=>{V.setProfileName(s,r)},this.setProfileImage=(s,r)=>{V.setProfileImage(s,r)},this.setUser=(s,r)=>{V.setUser(s,r)},this.resetAccount=s=>{V.resetAccount(s)},this.setCaipNetwork=s=>{b.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{b.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{V.setAllAccounts(s,r),B.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{V.setStatus(s,r),H.isConnected()?W.setConnectionStatus("connected"):W.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>b.getAccountProp("address",s),this.setConnectors=s=>{const r=[...H.state.allConnectors,...s];H.setConnectors(r)},this.setConnections=(s,r)=>{ee.setConnections(s,r)},this.fetchIdentity=s=>Q.fetchIdentity(s),this.getReownName=s=>Zi.getNamesForAddress(s),this.getConnectors=()=>H.getConnectors(),this.getConnectorImage=s=>Dh.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=ke.getProviderId(r),n=s?{...s,type:i}:void 0;V.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!b.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{V.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{V.removeAddressLabel(s,r)},this.getAddress=s=>b.state.activeChain===s||!s?V.state.address:b.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>b.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{b.resetNetwork(s)},this.addConnector=s=>{H.addConnector(s)},this.resetWcConnection=()=>{ee.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{V.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{V.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{b.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{V.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{B.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await r_.fetchRemoteFeatures(e),B.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Ta.setOnrampProviders(this.remoteFeatures.onramp),((s=B.state.remoteFeatures)!=null&&s.email||Array.isArray((r=B.state.remoteFeatures)==null?void 0:r.socials)&&((i=B.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await J.fetchAllowedOrigins();if(e&&te.isClient()){const s=window.location.origin;ro.isOriginAllowed(s,e,Ki.DEFAULT_ALLOWED_ANCESTORS)||Js.open(Hr.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else Js.open(Hr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Ue.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Nt.setThemeMode(e.themeMode),e.themeVariables&&Nt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");b.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&b.setActiveCaipNetwork(s)}initializeConnectionController(e){ee.setWcBasic(e.basic??!1)}initializeConnectorController(){H.initialize(this.chainNamespaces)}initializeProjectSettings(e){B.setProjectId(e.projectId),B.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;B.setDebug(e.debug!==!1),B.setEnableWalletConnect(e.enableWalletConnect!==!1),B.setEnableWalletGuide(e.enableWalletGuide!==!1),B.setEnableWallets(e.enableWallets!==!1),B.setEIP6963Enabled(e.enableEIP6963!==!1),B.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),B.setEnableAuthLogger(e.enableAuthLogger!==!1),B.setCustomRpcUrls(e.customRpcUrls),B.setEnableEmbedded(e.enableEmbedded),B.setAllWallets(e.allWallets),B.setIncludeWalletIds(e.includeWalletIds),B.setExcludeWalletIds(e.excludeWalletIds),B.setFeaturedWalletIds(e.featuredWalletIds),B.setTokens(e.tokens),B.setTermsConditionsUrl(e.termsConditionsUrl),B.setPrivacyPolicyUrl(e.privacyPolicyUrl),B.setCustomWallets(e.customWallets),B.setFeatures(e.features),B.setAllowUnsupportedChain(e.allowUnsupportedChain),B.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),B.setPreferUniversalLinks(e.experimental_preferUniversalLinks),B.setDefaultAccountTypes(e.defaultAccountTypes);const s=W.getPreferredAccountTypes()||{},r={...B.state.defaultAccountTypes,...s};V.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),B.setMetadata(e.metadata),B.setDisableAppend(e.disableAppend),B.setEnableEmbedded(e.enableEmbedded),B.setSIWX(e.siwx),!e.projectId){Js.open(Hr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===K.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");B.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return te.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=Vr.getUnsupportedNetwork(`${s}:${e}`);b.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Vr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Vr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Vr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?Vr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=ke.getProvider(e),i=ke.getProviderId(e),{caipAddress:n}=b.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),W.removeConnectedNamespace(e),ke.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),H.removeConnectorId(e),b.resetAccount(e),b.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=b.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),W.setConnectedNamespaces([...b.state.chains.keys()]),this.chainNamespaces.forEach(o=>{H.setConnectorId($s.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var g,p,m,w,C,P;const c=b.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const R=this.getCaipNetworks().find(O=>O.chainNamespace===n);R&&this.setCaipNetwork(R)}if(!u)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),d=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((m=(p=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:p.http)==null?void 0:m[0])||((P=(C=(w=h==null?void 0:h.rpcUrls)==null?void 0:w.default)==null?void 0:C.http)==null?void 0:P[0])});if(!d)return;W.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const f=V.state.allAccounts,{accounts:y}=(f==null?void 0:f.length)>0?{accounts:[...f]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(y,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=b.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),W.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=ON(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));ye.resetSend(),ee.resetWcConnection(),await sn.clearSessions(),H.setFilterByNamespace(void 0);const i=r.filter(n=>n.status==="rejected");if(i.length>0)throw new Error(i.map(n=>n.reason.message).join(", "));W.deleteConnectedSocialProvider(),Ue.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(b.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:V.state.address,provider:ke.getProvider(b.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Pe.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(b.state.activeChain),i=ke.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===K.CHAIN.EVM){const s=this.getAdapter(b.state.activeChain),r=ke.getProvider(b.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:V.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:b.state.activeChain}),V.state.profileImage||!1},getEnsAddress:async e=>await ro.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(b.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=ke.getProvider(b.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(b.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(b.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(b.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!V.state.address||this.updateNativeBalance(V.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ee.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(ke.getProviderId(b.state.activeChain)===$s.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=ke.getProvider(s),n=ke.getProviderId(s);if(e.chainNamespace===b.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===$s.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(s);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const r=s.chains||[],i=s.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Is.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...r,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,r)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new t_({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=W.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(W.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=b.state.activeChain===e,c=b.getAccountProp("address",e);if(o){const l=a&&i?i:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),s.on("disconnect",this.disconnect.bind(this,e)),s.on("connections",i=>{this.setConnections(i,e)}),s.on("pendingTransactions",()=>{const i=V.state.address,n=b.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=b.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=b.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=b.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===K.CHAIN.EVM&&te.isSafeApp()&&H.setConnectorId(K.CONNECTOR_ID.SAFE,e);const s=H.getConnectorId(e);switch(this.setStatus("connecting",e),s){case K.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case K.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var a,c,l;const s=this.getAdapter(e),r=H.getConnectorId(e),i=this.getCaipNetwork(e),o=H.getConnectors(e).find(u=>u.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const u=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(u){const h=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([te.createAccount(e,u.address,"eoa")],e),this.syncProvider({...u,chainNamespace:e}),await this.syncAccount({...u,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,u,h;const r=this.getAdapter(s),i=((u=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:u.accounts)||[],n=(h=b.state.activeCaipNetwork)==null?void 0:h.id,o=i.find(d=>{const{chainId:f}=Is.parseCaipAddress(d);return f===(n==null?void 0:n.toString())})||i[0];if(o){const d=Is.validateCaipAddress(o),{chainId:f,address:y}=Is.parseCaipAddress(d);if(ke.setProviderId(s,$s.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&b.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==K.CHAIN.EVM){const g=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:b.state.activeCaipNetwork});ke.setProvider(s,g)}else ke.setProvider(s,this.universalProvider);H.setConnectorId(K.CONNECTOR_ID.WALLET_CONNECT,s),W.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:y,chainId:f,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await b.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=Is.parseCaipAddress(c);return l}).filter((c,l,u)=>u.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>te.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){ke.setProviderId(i,e),ke.setProvider(i,s),H.setConnectorId(r,i)}async syncAllAccounts(e){const s=H.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var h,d;const s=e.chainNamespace===b.state.activeChain,r=b.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=W.getActiveNetworkProps(),c=n||a,l=((h=b.state.activeCaipNetwork)==null?void 0:h.name)===K.UNSUPPORTED_NETWORK_NAME,u=b.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let f=this.getCaipNetworks().find(p=>p.id.toString()===c.toString()),y=this.getCaipNetworks().find(p=>p.chainNamespace===o);if(!u&&!f&&!y){const p=this.getApprovedCaipNetworkIds()||[],m=p.find(C=>{var P;return((P=Is.parseCaipNetworkId(C))==null?void 0:P.chainId)===c.toString()}),w=p.find(C=>{var P;return((P=Is.parseCaipNetworkId(C))==null?void 0:P.chainNamespace)===o});f=this.getCaipNetworks().find(C=>C.caipNetworkId===m),y=this.getCaipNetworks().find(C=>C.caipNetworkId===w||"deprecatedCaipNetworkId"in C&&C.deprecatedCaipNetworkId===w)}const g=f||y;(g==null?void 0:g.chainNamespace)===b.state.activeChain?B.state.enableNetworkSwitch&&!B.state.allowUnsupportedChain&&((d=b.state.activeCaipNetwork)==null?void 0:d.name)===K.UNSUPPORTED_NETWORK_NAME?b.showUnsupportedChainUI():this.setCaipNetwork(g):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),Mc.isLowerCaseMatch(i,V.state.address)||this.syncAccountInfo(i,g==null?void 0:g.id,o),s?await this.syncBalance({address:i,chainId:g==null?void 0:g.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=H.getConnectorId(e),r=ke.getProviderId(e);if(r===$s.CONNECTOR_TYPE_ANNOUNCED||r===$s.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===$s.CONNECTOR_TYPE_WALLET_CONNECT){const n=ke.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===K.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===K.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!xh.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=b.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,u,h,d;const e=TN.createLogger((f,...y)=>{f&&this.handleAlertError(f),console.error(...y)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};B.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await PN.init(s),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ee.setUri(e)}),this.universalProvider.on("connect",ee.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ee.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const s=this.getCaipNetworks().find(i=>i.id==e),r=this.getCaipNetwork();if(!s){this.setUnsupportedNetwork(e);return}(r==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(ro.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&te.isCaipAddress(r[0])&&this.syncAccount(Is.parseCaipAddress(r[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&te.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Ue.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const s=Object.entries(Hr.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=Hr.ALERT_ERRORS[o];a&&(Js.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&ee.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return Ge.open({...e,data:{swap:e.arguments}})}return Ge.open(e)}async close(){await this.injectModalUi(),Ge.close()}setLoading(e,s){Ge.setLoading(e,s)}async disconnect(e){await ee.disconnect(e)}getSIWX(){return B.state.siwx}getError(){return""}getChainId(){var e;return(e=b.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){Js.open(Hr.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await b.switchActiveNetwork(s)}getWalletProvider(){return b.state.activeChain?ke.state.providers[b.state.activeChain]:null}getWalletProviderType(){return ke.getProviderId(b.state.activeChain)}subscribeProviders(e){return ke.subscribeProviders(e)}getThemeMode(){return Nt.state.themeMode}getThemeVariables(){return Nt.state.themeVariables}setThemeMode(e){Nt.setThemeMode(e),Wp(Nt.state.themeMode)}setTermsConditionsUrl(e){B.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){B.setPrivacyPolicyUrl(e)}setThemeVariables(e){Nt.setThemeVariables(e),ZN(Nt.state.themeVariables)}subscribeTheme(e){return Nt.subscribe(e)}getWalletInfo(){return V.state.connectedWalletInfo}getAccount(e){var o;const s=H.getAuthConnector(e),r=b.getAccountData(e),i=b.state.activeChain,n=W.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:te.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:s&&n===K.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:W.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?b.subscribeChainProp("accountState",r,s):b.subscribe(r),H.subscribe(r)}subscribeNetwork(e){return b.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return V.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){V.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){b.subscribeKey("activeCaipNetwork",e)}getState(){return Us.state}subscribeState(e){return Us.subscribe(e)}showErrorMessage(e){Yt.showError(e)}showSuccessMessage(e){Yt.showSuccess(e)}getEvent(){return{...Ue.state}}subscribeEvents(e){return Ue.subscribe(e)}replace(e){ne.replace(e)}redirect(e){ne.push(e)}popTransactionStack(e){ne.popTransactionStack(e)}isOpen(){return Ge.state.open}isTransactionStackEmpty(){return ne.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){B.setFeatures(e)}updateRemoteFeatures(e){B.setRemoteFeatures(e)}updateOptions(e){const r={...B.state||{},...e};B.setOptions(r)}setConnectMethodsOrder(e){B.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){B.setWalletFeaturesOrder(e)}setCollapseWallets(e){B.setCollapseWallets(e)}setSocialsOrder(e){B.setSocialsOrder(e)}getConnectMethodsOrder(){return mc.getConnectOrderMethod(B.state.features,H.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const r=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(i=>i.id===r.id)||b.addNetwork(r)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(i=>i.id===s)&&b.removeNetwork(e,s)}}let _h=!1;class Kp extends i_{async open(e){H.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ee.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!_h&&te.isClient()){if(await _a(()=>import("./basic-wb3lzxpj.js"),__vite__mapDeps([5,6,1,2,3,4])),await _a(()=>import("./w3m-modal-C2ckylSw.js"),__vite__mapDeps([7,6,1,2,3,4])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!B.state.disableAppend&&!B.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}_h=!0}}}const n_="1.7.8";function o_(t){return new Kp({...t,basic:!0,sdkVersion:`html-core-${n_}`})}const oS=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Kp,createAppKit:o_},Symbol.toStringTag,{value:"Module"}));export{Js as A,Yt as B,b as C,J as D,Ue as E,sS as F,te as G,sE as H,K as I,Mp as J,wc as K,Ke as L,Ge as M,wi as N,B as O,eo as P,ee as Q,ne as R,sn as S,Nt as T,W as U,Pe as V,mc as W,oS as X,nu as a,Vv as b,W_ as c,rE as d,H_ as e,No as f,G_ as g,K_ as h,kt as i,nt as j,ti as k,rS as l,so as m,eS as n,iS as o,xe as p,nS as q,V_ as r,ot as s,Fd as t,Dh as u,Jt as v,tS as w,kN as x,H as y,V as z};
|