@dcl/landing-site 0.0.1-23617073172.commit-1b94d0b
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/JumpIn.svg +7 -0
- package/assets/AnimatedBackground-BzCdmJe0.js +79 -0
- package/assets/FooterLanding-CAnbewff.js +1 -0
- package/assets/RoobertPRO-Bold-BLoSpx-h.otf +0 -0
- package/assets/RoobertPRO-Bold-zQ2qeH97.ttf +0 -0
- package/assets/add-B0mw33H-.js +15 -0
- package/assets/all-wallets-BKHVM3IF.js +6 -0
- package/assets/app-store-CYXevwgU.js +17 -0
- package/assets/apple-Gd4xIQWy.js +18 -0
- package/assets/arrow-bottom-C7OkmDGe.js +8 -0
- package/assets/arrow-bottom-circle-Djk9mHtO.js +11 -0
- package/assets/arrow-left-DSS-zc-_.js +8 -0
- package/assets/arrow-right-DtUjd1ud.js +8 -0
- package/assets/arrow-top-CVSFupFw.js +8 -0
- package/assets/auto-track-Cahm-Wf4.js +1 -0
- package/assets/bank-uNxVYn_m.js +14 -0
- package/assets/basic-BRmrmnBW.js +2128 -0
- package/assets/brotli_wasm_bg-NfWIZley.wasm +0 -0
- package/assets/browser-DWAkL3dn.js +14 -0
- package/assets/card-Bp_2Mxaj.js +14 -0
- package/assets/checkmark-CHLyENIp.js +11 -0
- package/assets/checkmark-bold-BBUQnsxn.js +8 -0
- package/assets/chevron-bottom-DqNuv8rq.js +8 -0
- package/assets/chevron-left-CX2lEPlF.js +8 -0
- package/assets/chevron-right-B2_IRqRJ.js +8 -0
- package/assets/chevron-top-Dek9HHwn.js +8 -0
- package/assets/chrome-store-BXGFuMtX.js +61 -0
- package/assets/clock-BZs881t-.js +8 -0
- package/assets/close-BLQm0ppo.js +8 -0
- package/assets/coinPlaceholder-CHTPQw0s.js +8 -0
- package/assets/compass-zymgTugJ.js +8 -0
- package/assets/copy-CC3ClT6b.js +15 -0
- package/assets/core-BbKmbY3L.js +907 -0
- package/assets/create-submenu-DEFVbrc5.png +0 -0
- package/assets/cursor-B9b2acRY.js +3 -0
- package/assets/cursor-transparent-W7EqHDYV.js +12 -0
- package/assets/custom-welcome-background-BxlFQma9.webp +0 -0
- package/assets/desktop-Cjdg0-Vl.js +9 -0
- package/assets/disconnect-Bg6F594y.js +8 -0
- package/assets/discord-hrp0SVCw.js +17 -0
- package/assets/etherscan-BZWr5RaD.js +6 -0
- package/assets/exclamation-triangle-Beu3xgJK.js +4 -0
- package/assets/explore-submenu-KVl6Dc-h.png +0 -0
- package/assets/extension-BpNSOEp3.js +8 -0
- package/assets/external-link-DnPe_xUI.js +8 -0
- package/assets/facebook-BTiklAat.js +26 -0
- package/assets/farcaster-CwDPkeLP.js +12 -0
- package/assets/filters-DPMHc-EZ.js +8 -0
- package/assets/github-CsIjVMC3.js +18 -0
- package/assets/google-Dq9F1MP7.js +18 -0
- package/assets/governance-submenu-CXxLX9nT.png +0 -0
- package/assets/help-circle-BztJcfSv.js +12 -0
- package/assets/id-Bj8Qa65f.js +12 -0
- package/assets/image-DyjQ2xnU.js +4 -0
- package/assets/index-0yNEkc8s.js +1 -0
- package/assets/index-8I_N421M.js +2 -0
- package/assets/index-BLrxeEjH.js +601 -0
- package/assets/index-BNrN3W5h.js +1 -0
- package/assets/index-BR4K2jzd.js +1 -0
- package/assets/index-BrKSltIn.js +1 -0
- package/assets/index-C-tFO0qB.js +2 -0
- package/assets/index-CBYpkhnB.js +395 -0
- package/assets/index-CEsga2rN.js +1 -0
- package/assets/index-CKuqw-nv.js +1 -0
- package/assets/index-Ch0OF5I1.js +7 -0
- package/assets/index-D6ZMQedT.js +1 -0
- package/assets/index-D90HGkMV.js +5 -0
- package/assets/index-DlTEcUUv.js +1 -0
- package/assets/index-VU0JrGQ3.js +1 -0
- package/assets/index-q5EOHO-4.js +1 -0
- package/assets/index-srlQH2fM.js +1 -0
- package/assets/index.es-4KXFYWf6.js +38 -0
- package/assets/index.umd-CIiTi8qb.js +1 -0
- package/assets/info-circle-M0yLnFSM.js +12 -0
- package/assets/info-p3EiU3hQ.js +3 -0
- package/assets/inherits_browser-BlmhoU4v.js +1 -0
- package/assets/is-plan-event-enabled-DeNtQvA5.js +1 -0
- package/assets/learn-submenu-Xs1jOwfy.png +0 -0
- package/assets/lightbulb-CJC6tDE9.js +3 -0
- package/assets/logo-pattern-D4X-bvlg.webp +0 -0
- package/assets/mail-DSO2W3iY.js +8 -0
- package/assets/man-default1-BEO13leF.png +0 -0
- package/assets/marketplace-submenu-CjxTqNhj.png +0 -0
- package/assets/mobile-fR1glIQ4.js +9 -0
- package/assets/more-DlbbY_6F.js +11 -0
- package/assets/network-placeholder-B8KzPhQY.js +14 -0
- package/assets/nftPlaceholder-BhwV6AWB.js +8 -0
- package/assets/off-DvzvX-Zr.js +8 -0
- package/assets/play-store-D2xrZam7.js +32 -0
- package/assets/plus-BNWFugCs.js +13 -0
- package/assets/qr-code-BhcOp34-.js +6 -0
- package/assets/recycle-horizontal-R8jOnIoo.js +9 -0
- package/assets/refresh-BXmKUFff.js +8 -0
- package/assets/reown-logo-mM_wmpSd.js +12 -0
- package/assets/search-gm3-bH1R.js +8 -0
- package/assets/send-Btky8Jae.js +15 -0
- package/assets/swapHorizontal-Biy93Zfl.js +8 -0
- package/assets/swapHorizontalBold-DV7_ZVCc.js +8 -0
- package/assets/swapHorizontalMedium-Cjt4byad.js +16 -0
- package/assets/swapHorizontalRoundedBold-DPjEaS5s.js +8 -0
- package/assets/swapVertical-C40pQqwB.js +8 -0
- package/assets/swiper-react-BALcxKpm.js +1 -0
- package/assets/swiper-react-BPTn8INI.css +1 -0
- package/assets/telegram-BLyaResm.js +16 -0
- package/assets/three-dots-OxU7Emnn.js +5 -0
- package/assets/twitch-CTJYfvIb.js +18 -0
- package/assets/twitterIcon-CkrscVcH.js +6 -0
- package/assets/vendor-mui-40jyI-Tp.js +197 -0
- package/assets/vendor-react-DJXYd7Dm.js +40 -0
- package/assets/vendor-web3-CarjtzLo.js +74 -0
- package/assets/verify-Do4TVEUh.js +8 -0
- package/assets/verify-filled-Dn6k7QuV.js +8 -0
- package/assets/w3m-modal-CQYCTo4E.js +642 -0
- package/assets/wallet-C_-8vEun.js +8 -0
- package/assets/wallet-placeholder-BUaaPYTt.js +14 -0
- package/assets/walletconnect-DaUEigG8.js +30 -0
- package/assets/warning-circle-BGToh6Re.js +12 -0
- package/assets/x-DI0y4W5T.js +12 -0
- package/avatar_face.png +0 -0
- package/catch_the_vibe/alan.mp4 +0 -0
- package/catch_the_vibe/alan.png +0 -0
- package/catch_the_vibe/roustan.mp4 +0 -0
- package/catch_the_vibe/roustan.png +0 -0
- package/come_hang_out_background.png +0 -0
- package/index.html +31 -0
- package/jump_into_background.png +0 -0
- package/landing_hero.png +0 -0
- package/package.json +21 -0
- package/persona.png +0 -0
- package/video_landing.mp4 +0 -0
- package/weekly-rituals/career-mondays.webp +0 -0
- package/weekly-rituals/play-with-friends.webp +0 -0
- package/weekly-rituals/takeover-tuesdays.webp +0 -0
- package/weekly-rituals/trivia-thursdays.webp +0 -0
- package/weekly-rituals/watch-party.webp +0 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/basic-BRmrmnBW.js","assets/index-CBYpkhnB.js","assets/vendor-web3-CarjtzLo.js","assets/vendor-react-DJXYd7Dm.js","assets/vendor-mui-40jyI-Tp.js","assets/index-BLrxeEjH.js","assets/index.es-4KXFYWf6.js","assets/w3m-modal-CQYCTo4E.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as _s,E as Wh,B as Ye,l as Hh,n as _a,o as zh,q as Vh,t as Kh,v as Gh,F as Jh,h as Vi,G as Aa,H as Sa,_ as Pa}from"./vendor-web3-CarjtzLo.js";import{g as Q}from"./index-BLrxeEjH.js";import{g as Yh}from"./vendor-mui-40jyI-Tp.js";import{d as Ki,s as sa,a as bn,I as Kr,g as Xh,c as U,f as Rt,t as wt,b as Dr,e as Wl,C as Zh,h as Qh,i as ed,j as fi,k as Co,E as ct,y as At,l as xi,A as Hl,m as td,B as ra,o as Ut,n as sd,p as ia,q as na,r as Tn,u as Gr,v as zs,P as Oa,Q as rd,w as id,x as Sr,z as zl,D as as,F as Yt,G as ps,H as Ht}from"./index.es-4KXFYWf6.js";var Ta={};const j={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 _s<"u"&&typeof Ta<"u"?Ta.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},Vl={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?.filter(s=>s.chainNamespace===e)||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){if(!e)return;const s=t.find(i=>i.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return j.CHAIN_NAME_MAP?.[r]||void 0}};var nd=20,od=1,Js=1e6,ka=1e6,ad=-7,cd=21,ld=!1,Ri="[big.js] ",tr=Ri+"Invalid ",kn=tr+"decimal places",ud=tr+"rounding mode",Kl=Ri+"Division by zero",me={},Qt=void 0,hd=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Gl(){function t(e){var s=this;if(!(s instanceof t))return e===Qt?Gl():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(tr+"value");e=e===0&&1/e<0?"-0":String(e)}dd(s,e)}s.constructor=t}return t.prototype=me,t.DP=nd,t.RM=od,t.NE=ad,t.PE=cd,t.strict=ld,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function dd(t,e){var s,r,i;if(!hd.test(e))throw Error(tr+"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 sr(t,e,s,r){var i=t.c;if(s===Qt&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(ud);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]!==Qt))),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]!==Qt||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 rr(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}me.abs=function(){var t=new this.constructor(this);return t.s=1,t};me.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};me.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>Js)throw Error(kn);if(!i[0])throw Error(Kl);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,m=r.length,w=r.slice(0,a),g=w.length,y=t,v=y.c=[],E=0,N=o+(y.e=e.e-t.e)+1;for(y.s=n,n=N<0?0:N,d.unshift(0);g++<a;)w.push(0);do{for(l=0;l<10;l++){if(a!=(g=w.length))u=a>g?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=w[h]){u=i[h]>w[h]?1:-1;break}if(u<0){for(c=g==a?i:d;g;){if(w[--g]<c[g]){for(h=g;h&&!w[--h];)w[h]=9;--w[h],w[g]+=10}w[g]-=c[g]}for(;!w[0];)w.shift()}else break}v[E++]=u?l:++l,w[0]&&u?w[g]=r[f]||0:w=[r[f]]}while((f++<m||w[0]!==Qt)&&n--);return!v[0]&&E!=1&&(v.shift(),y.e--,N--),E>N&&sr(y,N,s.RM,w[0]!==Qt),y};me.eq=function(t){return this.cmp(t)===0};me.gt=function(t){return this.cmp(t)>0};me.gte=function(t){return this.cmp(t)>-1};me.lt=function(t){return this.cmp(t)<0};me.lte=function(t){return this.cmp(t)<1};me.minus=me.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};me.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(Kl);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)))};me.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};me.plus=me.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};me.pow=function(t){var e=this,s=new e.constructor("1"),r=s,i=t<0;if(t!==~~t||t<-ka||t>ka)throw Error(tr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};me.prec=function(t,e){if(t!==~~t||t<1||t>Js)throw Error(tr+"precision");return sr(new this.constructor(this),t,e)};me.round=function(t,e){if(t===Qt)t=0;else if(t!==~~t||t<-Js||t>Js)throw Error(kn);return sr(new this.constructor(this),t+this.e+1,e)};me.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(Ri+"No square root");n=Math.sqrt(+rr(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 sr(t,(i.DP-=4)+t.e+1,i.RM)};me.times=me.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};me.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==Qt){if(t!==~~t||t<0||t>Js)throw Error(kn);for(s=sr(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return rr(s,!0,!!r)};me.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==Qt){if(t!==~~t||t<0||t>Js)throw Error(kn);for(s=sr(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return rr(s,!1,!!r)};me[Symbol.for("nodejs.util.inspect.custom")]=me.toJSON=me.toString=function(){var t=this,e=t.constructor;return rr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};me.toNumber=function(){var t=+rr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Ri+"Imprecise conversion");return t};me.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==Qt){if(t!==~~t||t<1||t>Js)throw Error(tr+"precision");for(s=sr(new r(s),t,e);s.c.length<t;)s.c.push(0)}return rr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};me.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Ri+"valueOf disallowed");return rr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Qr=Gl();const pd={bigNumber(t){return t?new Qr(t):new Qr(0)},multiply(t,e){if(t===void 0||e===void 0)return new Qr(0);const s=new Qr(t),r=new Qr(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,""))}},fd=[{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"}]}],gd=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],md=[{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"}]}],wd={getERC20Abi:t=>j.USDT_CONTRACT_ADDRESSES.includes(t)?md:fd,getSwapAbi:()=>gd},fs={validateCaipAddress(t){if(t.split(":")?.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}}},te={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 Hn(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const Z={setItem(t,e){ci()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(ci())return localStorage.getItem(t)||void 0},removeItem(t){ci()&&localStorage.removeItem(t)},clear(){ci()&&localStorage.clear()}};function ci(){return typeof window<"u"&&typeof localStorage<"u"}function Is(t,e){return e==="light"?{"--w3m-accent":t?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":t?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const yd=Symbol(),$a=Object.getPrototypeOf,Io=new WeakMap,vd=t=>t&&(Io.has(t)?Io.get(t):$a(t)===Object.prototype||$a(t)===Array.prototype),bd=t=>vd(t)&&t[yd]||null,xa=(t,e=!0)=>{Io.set(t,e)};var En={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/landing-site/0.0.1-23617073172.commit-1b94d0b",VITE_REACT_APP_DCL_DEFAULT_ENV:"prod",BASE_URL:"https://cdn.decentraland.org/@dcl/landing-site/0.0.1-23617073172.commit-1b94d0b",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const zn=t=>typeof t=="object"&&t!==null,vs=new WeakMap,li=new WeakSet,Ed=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>zn(l)&&!li.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?.[0]===u)return d[1];const f=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return xa(f,!0),i.set(l,[u,f]),Reflect.ownKeys(l).forEach(m=>{if(Object.getOwnPropertyDescriptor(f,m))return;const w=Reflect.get(l,m),{enumerable:g}=Reflect.getOwnPropertyDescriptor(l,m),y={value:w,enumerable:g,configurable:!0};if(li.has(w))xa(w,!1);else if(w instanceof Promise)delete y.value,y.get=()=>h(w);else if(vs.has(w)){const[v,E]=vs.get(w);y.value=n(v,E(),h)}Object.defineProperty(f,m,y)}),Object.preventExtensions(f)},o=new WeakMap,a=[1,1],c=l=>{if(!zn(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,f=(b,x=++a[0])=>{h!==x&&(h=x,d.forEach(C=>C(b,x)))};let m=a[1];const w=(b=++a[1])=>(m!==b&&!d.size&&(m=b,y.forEach(([x])=>{const C=x[1](b);C>h&&(h=C)})),h),g=b=>(x,C)=>{const L=[...x];L[1]=[b,...L[1]],f(L,C)},y=new Map,v=(b,x)=>{if((En?"production":void 0)!=="production"&&y.has(b))throw new Error("prop listener already exists");if(d.size){const C=x[3](g(b));y.set(b,[x,C])}else y.set(b,[x])},E=b=>{var x;const C=y.get(b);C&&(y.delete(b),(x=C[1])==null||x.call(C))},N=b=>(d.add(b),d.size===1&&y.forEach(([C,L],z)=>{if((En?"production":void 0)!=="production"&&L)throw new Error("remove already exists");const I=C[3](g(z));y.set(z,[C,I])}),()=>{d.delete(b),d.size===0&&y.forEach(([C,L],z)=>{L&&(L(),y.set(z,[C]))})}),$=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e($,{deleteProperty(b,x){const C=Reflect.get(b,x);E(x);const L=Reflect.deleteProperty(b,x);return L&&f(["delete",[x],C]),L},set(b,x,C,L){const z=Reflect.has(b,x),I=Reflect.get(b,x,L);if(z&&(t(I,C)||o.has(C)&&t(I,o.get(C))))return!0;E(x),zn(C)&&(C=bd(C)||C);let T=C;if(C instanceof Promise)C.then(A=>{C.status="fulfilled",C.value=A,f(["resolve",[x],A])}).catch(A=>{C.status="rejected",C.reason=A,f(["reject",[x],A])});else{!vs.has(C)&&s(C)&&(T=c(C));const A=!li.has(T)&&vs.get(T);A&&v(x,A)}return Reflect.set(b,x,T,L),f(["set",[x],C,I]),!0}});o.set(l,S);const D=[$,w,n,N];return vs.set(S,D),Reflect.ownKeys(l).forEach(b=>{const x=Object.getOwnPropertyDescriptor(l,b);"value"in x&&(S[b]=l[b],delete x.value,delete x.writable),Object.defineProperty($,b,x)}),S})=>[c,vs,li,t,e,s,r,i,n,o,a],[Cd]=Ed();function Oe(t={}){return Cd(t)}function it(t,e,s){const r=vs.get(t);(En?"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 Ni(t,e){const s=vs.get(t);(En?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function Ys(t){return li.add(t),t}function nt(t,e,s,r){let i=t[e];return it(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function Id(t){const e=Oe({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}var Ra={};const Vn=(typeof _s<"u"&&typeof Ra<"u"?Ra.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",Jl=[{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"]}],Nd="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Ie={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:Vn,SECURE_SITE_DASHBOARD:`${Vn}/dashboard`,SECURE_SITE_FAVICON:`${Vn}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_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",WEB:"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_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},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{Z.setItem(te.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Z.getItem(te.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Z.removeItem(te.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Z.setItem(te.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Z.setItem(te.ACTIVE_CAIP_NETWORK_ID,t),W.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return Z.getItem(te.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Z.removeItem(te.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=Hn(t);Z.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(),Z.setItem(te.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Z.getItem(te.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Hn(t);Z.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Z.getItem(te.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Hn(t);return Z.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{Z.setItem(te.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Z.getItem(te.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Z.removeItem(te.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Z.getItem(te.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){return Z.getItem(te.ACTIVE_CAIP_NETWORK_ID)?.split(":")?.[1]},setConnectionStatus(t){try{Z.setItem(te.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Z.getItem(te.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Z.getItem(te.CONNECTED_NAMESPACES);return t?.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Z.setItem(te.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 Z.getItem(te.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Z.setItem(te.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Z.removeItem(te.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Z.getItem(te.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=W.getBalanceCache();Z.setItem(te.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,Z.setItem(te.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Z.getItem(te.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();Z.setItem(te.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,Z.setItem(te.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Z.getItem(te.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,Z.setItem(te.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=W.getEnsCache();Z.setItem(te.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=Z.getItem(te.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},Z.setItem(te.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=W.getIdentityCache();Z.setItem(te.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Z.removeItem(te.PORTFOLIO_CACHE),Z.removeItem(te.NATIVE_BALANCE_CACHE),Z.removeItem(te.ENS_CACHE),Z.removeItem(te.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Z.setItem(te.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Z.getItem(te.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};Z.setItem(te.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=Z.getItem(te.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},X={isMobile(){return this.isClient()?!!(typeof window?.matchMedia=="function"&&window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t?.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return X.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window?.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Ie.TEN_SEC_MS:!0},isAllowedRetry(t,e=Ie.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return window?.self!==window?.top}catch{return!1}},isSafeApp(){if(X.isClient()&&window.self!==window.top)try{const t=window?.location?.ancestorOrigins?.[0],e="https://app.safe.global";if(t){const s=new URL(t),r=new URL(e);return s.hostname===r.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ie.FOUR_MINUTES_MS},getNetworkId(t){return t?.split(":")[1]},getPlainAddress(t){return 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(X.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?.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(!X.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?.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window?.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){if(typeof window>"u")return!1;const t=window.matchMedia?.("(display-mode: standalone)")?.matches,e=window?.navigator?.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,X.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){let s;if(t==="0")s="0";else if(typeof t=="string"){const r=Number(t);r&&(s=r.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return j.W3M_API_URL},getBlockchainApiUrl(){return j.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return j.PULSE_API_URL},getUUID(){return 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){return typeof t=="string"?t:typeof t?.issues?.[0]?.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?Ie.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 j.CHAIN_NAME_MAP},isMac(){const t=window?.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(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 ei(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class Ui{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 ei(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await ei(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await ei(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 ei(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 ei(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 _d={getFeatureValue(t,e){const s=e?.[t];return s===void 0?Ie.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(X.isTelegram()){if(X.isIos())return t.filter(e=>e!=="google");if(X.isMac())return t.filter(e=>e!=="x");if(X.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},K=Oe({features:Ie.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ie.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),P={state:K,subscribeKey(t,e){return nt(K,t,e)},setOptions(t){Object.assign(K,t)},setRemoteFeatures(t){if(!t)return;const e={...K.remoteFeatures,...t};K.remoteFeatures=e,K.remoteFeatures?.socials&&(K.remoteFeatures.socials=_d.filterSocialsByPlatform(K.remoteFeatures.socials))},setFeatures(t){if(!t)return;K.features||(K.features=Ie.DEFAULT_FEATURES);const e={...K.features,...t};K.features=e},setProjectId(t){K.projectId=t},setCustomRpcUrls(t){K.customRpcUrls=t},setAllWallets(t){K.allWallets=t},setIncludeWalletIds(t){K.includeWalletIds=t},setExcludeWalletIds(t){K.excludeWalletIds=t},setFeaturedWalletIds(t){K.featuredWalletIds=t},setTokens(t){K.tokens=t},setTermsConditionsUrl(t){K.termsConditionsUrl=t},setPrivacyPolicyUrl(t){K.privacyPolicyUrl=t},setCustomWallets(t){K.customWallets=t},setIsSiweEnabled(t){K.isSiweEnabled=t},setIsUniversalProvider(t){K.isUniversalProvider=t},setSdkVersion(t){K.sdkVersion=t},setMetadata(t){K.metadata=t},setDisableAppend(t){K.disableAppend=t},setEIP6963Enabled(t){K.enableEIP6963=t},setDebug(t){K.debug=t},setEnableWalletConnect(t){K.enableWalletConnect=t},setEnableWalletGuide(t){K.enableWalletGuide=t},setEnableAuthLogger(t){K.enableAuthLogger=t},setEnableWallets(t){K.enableWallets=t},setPreferUniversalLinks(t){K.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){K.hasMultipleAddresses=t},setSIWX(t){K.siwx=t},setConnectMethodsOrder(t){K.features={...K.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){K.features={...K.features,walletFeaturesOrder:t}},setSocialsOrder(t){K.remoteFeatures={...K.remoteFeatures,socials:t}},setCollapseWallets(t){K.features={...K.features,collapseWallets:t}},setEnableEmbedded(t){K.enableEmbedded=t},setAllowUnsupportedChain(t){K.allowUnsupportedChain=t},setManualWCControl(t){K.manualWCControl=t},setEnableNetworkSwitch(t){K.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(K.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){K.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return K.universalProviderConfigOverride},getSnapshot(){return Ni(K)}},Ad=Object.freeze({enabled:!0,events:[]}),Sd=new Ui({baseUrl:X.getAnalyticsUrl(),clientId:null}),Pd=5,Od=60*1e3,gs=Oe({...Ad}),Td={state:gs,subscribeKey(t,e){return nt(gs,t,e)},async sendError(t,e){if(!gs.enabled)return;const s=Date.now();if(gs.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<Od}).length>=Pd)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};gs.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=P.state;await Sd.post({path:"/e",params:{projectId:n,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:X.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(){gs.enabled=!0},disable(){gs.enabled=!1},clearEvents(){gs.events=[]}};class Lr extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,Lr.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,Lr):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Ua(t,e){const s=t instanceof Lr?t:new Lr(t instanceof Error?t.message:String(t),e,t);throw Td.sendError(s,s.category),s}function St(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 Ua(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return Ua(a,e)}},s[r]=n}else s[r]=i}),s}const Xt={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},kd={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===Xt.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${Xt.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===Xt.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${Xt.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===j.CHAIN.SOLANA&&t===Xt.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${Xt.COINBASE.url}/dapp?cb_url=${r}`)}},yt=Oe({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),$d={state:yt,subscribeNetworkImages(t){return it(yt.networkImages,()=>t(yt.networkImages))},subscribeKey(t,e){return nt(yt,t,e)},subscribe(t){return it(yt,()=>t(yt))},setWalletImage(t,e){yt.walletImages[t]=e},setNetworkImage(t,e){yt.networkImages[t]=e},setChainImage(t,e){yt.chainImages[t]=e},setConnectorImage(t,e){yt.connectorImages={...yt.connectorImages,[t]:e}},setTokenImage(t,e){yt.tokenImages[t]=e},setCurrencyImage(t,e){yt.currencyImages[t]=e}},qt=St($d),xd={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},Kn=Oe({networkImagePromises:{}}),Yl={async fetchWalletImage(t){if(t)return await V._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(Kn.networkImagePromises[t]||(Kn.networkImagePromises[t]=V._fetchNetworkImage(t)),await Kn.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return qt.state.walletImages[t]},getWalletImage(t){if(t?.image_url)return t?.image_url;if(t?.image_id)return qt.state.walletImages[t.image_id]},getNetworkImage(t){if(t?.assets?.imageUrl)return t?.assets?.imageUrl;if(t?.assets?.imageId)return qt.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return qt.state.networkImages[t]},getConnectorImage(t){if(t?.imageUrl)return t.imageUrl;if(t?.imageId)return qt.state.connectorImages[t.imageId]},getChainImage(t){return qt.state.networkImages[xd[t]]}},ms=Oe({message:"",variant:"info",open:!1}),Rd={state:ms,subscribeKey(t,e){return nt(ms,t,e)},open(t,e){const{debug:s}=P.state,{shortMessage:r,longMessage:i}=t;s&&(ms.message=r,ms.variant=e,ms.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){ms.open=!1,ms.message="",ms.variant="info"}},qs=St(Rd),Ud=X.getAnalyticsUrl(),Dd=new Ui({baseUrl:Ud,clientId:null}),Ld=["MODAL_CREATED"],is=Oe({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),ke={state:is,subscribe(t){return it(is,()=>t(is))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=P.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=H.state.address;if(Ld.includes(t.data.event)||typeof window>"u")return;await Dd.post({path:"/e",params:ke.getSdkProperties(),body:{eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),is.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===j.HTTP_STATUS_CODES.FORBIDDEN&&!is.reportedErrors.FORBIDDEN&&(qs.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${ci()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),is.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){is.timestamp=Date.now(),is.data=t,P.state.features?.analytics&&ke._sendAnalyticsEvent(is)}},Md=X.getApiUrl(),lt=new Ui({baseUrl:Md,clientId:null}),Bd=40,Da=4,jd=20,se=Oe({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),V={state:se,subscribeKey(t,e){return nt(se,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=P.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return P.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${lt.baseUrl}/getWalletImage/${t}`,s=await lt.getBlob({path:e,params:V._getSdkProperties()});qt.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${lt.baseUrl}/public/getAssetImage/${t}`,s=await lt.getBlob({path:e,params:V._getSdkProperties()});qt.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${lt.baseUrl}/public/getAssetImage/${t}`,s=await lt.getBlob({path:e,params:V._getSdkProperties()});qt.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${lt.baseUrl}/public/getCurrencyImage/${t}`,s=await lt.getBlob({path:e,params:V._getSdkProperties()});qt.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${lt.baseUrl}/public/getTokenImage/${t}`,s=await lt.getBlob({path:e,params:V._getSdkProperties()});qt.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return X.isMobile()?t?.filter(s=>s.mobile_link||s.id===Xt.COINBASE.id?!0:p.state.activeChain==="solana"&&(s.id===Xt.SOLFLARE.id||s.id===Xt.PHANTOM.id)):t},async fetchProjectConfig(){return(await lt.get({path:"/appkit/v1/config",params:V._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await lt.get({path:"/projects/v1/origins",params:V._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const e=p.getAllRequestedCaipNetworks()?.map(({assets:s})=>s?.imageId).filter(Boolean).filter(s=>!Yl.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>V._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=q.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>V._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>V._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>V._fetchTokenImage(e)))},async fetchWallets(t){const e=t.exclude??[];V._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(Xt).map(n=>n.id));const r=await lt.get({path:"/getWallets",params:{...V._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:t.include?.join(","),exclude:e.join(",")}});return{data:V._filterWalletsByPlatform(r?.data)||[],count:r?.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=P.state;if(t?.length){const e={...V._getSdkProperties(),page:1,entries:t?.length??Da,include:t},{data:s}=await V.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=>V._fetchWalletImage(n))),se.featured=r,se.allFeatured=r}},async fetchRecommendedWallets(){try{se.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=P.state,r=[...e??[],...s??[]].filter(Boolean),i=p.getRequestedCaipNetworkIds().join(","),n={page:1,entries:Da,include:t,exclude:r,chains:i},{data:o,count:a}=await V.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=>V._fetchWalletImage(h))),se.recommended=o,se.allRecommended=o,se.count=a??0}catch{}finally{se.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=P.state,i=p.getRequestedCaipNetworkIds().join(","),n=[...se.recommended.map(({id:u})=>u),...s??[],...r??[]].filter(Boolean),o={page:t,entries:Bd,include:e,exclude:n,chains:i},{data:a,count:c}=await V.fetchWallets(o),l=a.slice(0,jd).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>V._fetchWalletImage(u))),se.wallets=X.uniqueBy([...se.wallets,...V._filterOutExtensions(a)],"id").filter(u=>u.chains?.some(h=>i.includes(h))),se.count=c>se.count?c:se.count,se.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await V.fetchWallets(e);s&&s.forEach(r=>{se.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=P.state,i=p.getRequestedCaipNetworkIds().join(",");se.search=[];const n={page:1,entries:100,search:t?.trim(),badge_type:e,include:s,exclude:r,chains:i},{data:o}=await V.fetchWallets(n);ke.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=>V._fetchWalletImage(c)),X.wait(300)]),se.search=V._filterOutExtensions(o)},initPromise(t,e){const s=se.promises[t];return s||(se.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&V.initPromise("connectorImages",V.fetchConnectorImages),e&&V.initPromise("featuredWallets",V.fetchFeaturedWallets),s&&V.initPromise("recommendedWallets",V.fetchRecommendedWallets),r&&V.initPromise("networkImages",V.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){P.state.features?.analytics&&V.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await lt.get({path:"/getAnalyticsConfig",params:V._getSdkProperties()});P.setFeatures({analytics:t})}catch{P.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!t?.length){se.featured=se.allFeatured,se.recommended=se.allRecommended;return}const e=p.getRequestedCaipNetworkIds().join(",");se.featured=se.allFeatured.filter(s=>s.chains?.some(r=>e.includes(r))),se.recommended=se.allRecommended.filter(s=>s.chains?.some(r=>e.includes(r))),se.filteredWallets=se.wallets.filter(s=>s.chains?.some(r=>e.includes(r)))},clearFilterByNamespaces(){se.filteredWallets=[]},setFilterByNamespace(t){if(!t){se.featured=se.allFeatured,se.recommended=se.allRecommended;return}const e=p.getRequestedCaipNetworkIds().join(",");se.featured=se.allFeatured.filter(s=>s.chains?.some(r=>e.includes(r))),se.recommended=se.allRecommended.filter(s=>s.chains?.some(r=>e.includes(r))),se.filteredWallets=se.wallets.filter(s=>s.chains?.some(r=>e.includes(r)))}},we=Oe({view:"Connect",history:["Connect"],transactionStack:[]}),qd={state:we,subscribeKey(t,e){return nt(we,t,e)},pushTransactionStack(t){we.transactionStack.push(t)},popTransactionStack(t){const e=we.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:r,onCancel:i}=e;switch(t){case"success":s?.();break;case"error":r?.(),ie.goBack();break;case"cancel":i?.(),ie.goBack();break}},push(t,e){t!==we.view&&(we.view=t,we.history.push(t),we.data=e)},reset(t,e){we.view=t,we.history=[t],we.data=e},replace(t,e){we.history.at(-1)===t||(we.view=t,we.history[we.history.length-1]=t,we.data=e)},goBack(){const t=p.state.activeCaipAddress,e=ie.state.view==="ConnectingFarcaster",s=!t&&e;if(we.history.length>1){we.history.pop();const[r]=we.history.slice(-1);r&&(t&&r==="Connect"?we.view="Account":we.view=r)}else Ge.close();we.data?.wallet&&(we.data.wallet=void 0),setTimeout(()=>{if(s){H.setFarcasterUrl(void 0,p.state.activeChain);const r=q.getAuthConnector();r?.provider?.reload();const i=Ni(P.state);r?.provider?.syncDappData?.({metadata:i.metadata,sdkVersion:i.sdkVersion,projectId:i.projectId,sdkType:i.sdkType})}},100)},goBackToIndex(t){if(we.history.length>1){we.history=we.history.slice(0,t+1);const[e]=we.history.slice(-1);e&&(we.view=e)}},goBackOrCloseModal(){ie.state.history.length>1?ie.goBack():Ge.close()}},ie=St(qd),ns=Oe({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),No={state:ns,subscribe(t){return it(ns,()=>t(ns))},setThemeMode(t){ns.themeMode=t;try{const e=q.getAuthConnector();if(e){const s=No.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:Is(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){ns.themeVariables={...ns.themeVariables,...t};try{const e=q.getAuthConnector();if(e){const s=No.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:Is(ns.themeVariables,ns.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Ni(ns)}},Et=St(No),Xl={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ce=Oe({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Xl},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),Fd={state:ce,subscribe(t){return it(ce,()=>{t(ce)})},subscribeKey(t,e){return nt(ce,t,e)},initialize(t){t.forEach(e=>{const s=W.getConnectedConnectorId(e);s&&q.setConnectorId(s,e)})},setActiveConnector(t){t&&(ce.activeConnector=Ys(t))},setConnectors(t){t.filter(i=>!ce.allConnectors.some(n=>n.id===i.id&&q.getConnectorName(n.name)===q.getConnectorName(i.name)&&n.chain===i.chain)).forEach(i=>{i.type!=="MULTI_CHAIN"&&ce.allConnectors.push(Ys(i))});const s=q.getEnabledNamespaces(),r=q.getEnabledConnectors(s);ce.connectors=q.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(ce.filterByNamespaceMap).forEach(e=>{ce.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ce.filterByNamespaceMap[e]=!0}),q.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ce.filterByNamespaceMap[t]=e,q.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=q.getEnabledNamespaces(),e=q.getEnabledConnectors(t),s=q.areAllNamespacesEnabled();ce.connectors=q.mergeMultiChainConnectors(e),s?V.clearFilterByNamespaces():V.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ce.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ce.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ce.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=q.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=i?.id===j.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?.id||""}):i&&s.push(i)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:r}=s,i=q.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){if(t.id===j.CONNECTOR_ID.AUTH){const e=t,s=Ni(P.state),r=Et.getSnapshot().themeMode,i=Et.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),e?.provider?.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:Is(i,r)}),q.setConnectors([t])}else q.setConnectors([t])},getAuthConnector(t){const e=t||p.state.activeChain,s=ce.connectors.find(r=>r.id===j.CONNECTOR_ID.AUTH);if(s)return s?.connectors?.length?s.connectors.find(i=>i.chain===e):s},getAnnouncedConnectorRdns(){return ce.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>t.info?.rdns)},getConnectorById(t){return ce.allConnectors.find(e=>e.id===t)},getConnector(t,e){return ce.allConnectors.filter(r=>r.chain===p.state.activeChain).find(r=>r.explorerId===t||r.info?.rdns===e)},syncIfAuthConnector(t){if(t.id!=="ID_AUTH")return;const e=t,s=Ni(P.state),r=Et.getSnapshot().themeMode,i=Et.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:Is(i,r)})},getConnectorsByNamespace(t){const e=ce.allConnectors.filter(s=>s.chain===t);return q.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=q.getConnector(t.id,t.rdns),s=p.state.activeChain;kd.handleMobileDeeplinkRedirect(e?.explorerId||t.id,s),e?ie.push("ConnectingExternal",{connector:e}):ie.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?q.getConnectorsByNamespace(t):q.mergeMultiChainConnectors(ce.allConnectors)},setFilterByNamespace(t){ce.filterByNamespace=t,ce.connectors=q.getConnectors(t),V.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ce.activeConnectorIds={...ce.activeConnectorIds,[e]:t},W.setConnectedConnectorId(e,t))},removeConnectorId(t){ce.activeConnectorIds={...ce.activeConnectorIds,[t]:void 0},W.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ce.activeConnectorIds[t]},isConnected(t){return t?!!ce.activeConnectorIds[t]:Object.values(ce.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ce.activeConnectorIds={...Xl}}},q=St(Fd),gi={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Bs=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Me=Oe({...Bs}),Wd={state:Me,subscribeKey(t,e){return nt(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=X.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){Me.message=Bs.message,Me.variant=Bs.variant,Me.svg=Bs.svg,Me.open=Bs.open,Me.autoClose=Bs.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=Bs.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)}},Ft=Wd,_e=Oe({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),Hd={state:_e,subscribe(t){return it(_e,()=>t(_e))},setLastNetworkInView(t){_e.lastNetworkInView=t},async fetchTransactions(t,e){if(!t)throw new Error("Transactions can't be fetched without an accountAddress");_e.loading=!0;try{const s=await J.fetchTransactions({account:t,cursor:_e.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:p.state.activeCaipNetwork?.caipNetworkId}),r=ui.filterSpamTransactions(s.data),i=ui.filterByConnectedChain(r),n=[..._e.transactions,...i];_e.loading=!1,e==="coinbase"?_e.coinbaseTransactions=ui.groupTransactionsByYearAndMonth(_e.coinbaseTransactions,s.data):(_e.transactions=n,_e.transactionsByYear=ui.groupTransactionsByYearAndMonth(_e.transactionsByYear,i)),_e.empty=n.length===0,_e.next=s.next?s.next:void 0}catch{const r=p.state.activeChain;ke.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:P.state.projectId,cursor:_e.next,isSmartAccount:H.state.preferredAccountTypes?.[r]===gi.ACCOUNT_TYPES.SMART_ACCOUNT}}),Ft.showError("Failed to fetch transactions"),_e.loading=!1,_e.empty=!0,_e.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=>r.nft_info?.flags.is_spam===!0))},filterByConnectedChain(t){const e=p.state.activeCaipNetwork?.caipNetworkId;return t.filter(r=>r.metadata.chain===e)},clearCursor(){_e.next=void 0},resetTransactions(){_e.transactions=[],_e.transactionsByYear={},_e.lastNetworkInView=void 0,_e.loading=!1,_e.empty=!1,_e.next=void 0}},ui=St(Hd,"API_ERROR"),Se=Oe({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Us;const zd={state:Se,subscribeKey(t,e){return nt(Se,t,e)},_getClient(){return Se._client},setClient(t){Se._client=Ys(t)},async connectWalletConnect(){if(X.isTelegram()||X.isSafari()&&X.isIos()){if(Us){await Us,Us=void 0;return}if(!X.isPairingExpired(Se?.wcPairingExpiry)){const t=Se.wcUri;Se.wcUri=t;return}Us=Y._getClient()?.connectWalletConnect?.().catch(()=>{}),Y.state.status="connecting",await Us,Us=void 0,Se.wcPairingExpiry=void 0,Y.state.status="connected"}else await Y._getClient()?.connectWalletConnect?.()},async connectExternal(t,e,s=!0){await Y._getClient()?.connectExternal?.(t),s&&p.setActiveNamespace(e)},async reconnectExternal(t){await Y._getClient()?.reconnectExternal?.(t);const e=t.chain||p.state.activeChain;e&&q.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){Ge.setLoading(!0,p.state.activeChain);const s=q.getAuthConnector();s&&(H.setPreferredAccountType(t,e),await s.provider.setPreferredAccount(t),W.setPreferredAccountTypes(H.state.preferredAccountTypes??{[e]:t}),await Y.reconnectExternal(s),Ge.setLoading(!1,p.state.activeChain),ke.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:p.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(t){return Y._getClient()?.signMessage(t)},parseUnits(t,e){return Y._getClient()?.parseUnits(t,e)},formatUnits(t,e){return Y._getClient()?.formatUnits(t,e)},async sendTransaction(t){return Y._getClient()?.sendTransaction(t)},async getCapabilities(t){return Y._getClient()?.getCapabilities(t)},async grantPermissions(t){return Y._getClient()?.grantPermissions(t)},async walletGetAssets(t){return Y._getClient()?.walletGetAssets(t)??{}},async estimateGas(t){return Y._getClient()?.estimateGas(t)},async writeContract(t){return Y._getClient()?.writeContract(t)},async getEnsAddress(t){return Y._getClient()?.getEnsAddress(t)},async getEnsAvatar(t){return Y._getClient()?.getEnsAvatar(t)},checkInstalled(t){return Y._getClient()?.checkInstalled?.(t)||!1},resetWcConnection(){Se.wcUri=void 0,Se.wcPairingExpiry=void 0,Se.wcLinking=void 0,Se.recentWallet=void 0,Se.status="disconnected",ui.resetTransactions(),W.deleteWalletConnectDeepLink()},resetUri(){Se.wcUri=void 0,Se.wcPairingExpiry=void 0,Us=void 0},finalizeWcConnection(){const{wcLinking:t,recentWallet:e}=Y.state;t&&W.setWalletConnectDeepLink(t),e&&W.setAppKitRecent(e),ke.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:ie.state.data?.wallet?.name||"Unknown"}})},setWcBasic(t){Se.wcBasic=t},setUri(t){Se.wcUri=t,Se.wcPairingExpiry=X.getPairingExpiry()},setWcLinking(t){Se.wcLinking=t},setWcError(t){Se.wcError=t,Se.buffering=!1},setRecentWallet(t){Se.recentWallet=t},setBuffering(t){Se.buffering=t},setStatus(t){Se.status=t},async disconnect(t){try{await Y._getClient()?.disconnect(t)}catch(e){throw new Lr("Failed to disconnect","INTERNAL_SDK_ERROR",e)}},setConnections(t,e){Se.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(q.state.activeConnectorIds[s]===t.connectorId){const n=p.state.activeCaipNetwork;if(n){const o=`${s}:${n.id}:${e}`;H.setCaipAddress(o,s)}else console.warn(`No current network found for namespace "${s}"`)}else{const n=q.getConnector(t.connectorId);n?Y.connectExternal(n,s):console.warn(`No connector found for namespace "${s}"`)}}},Y=St(zd),ar=Oe({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),As={state:ar,subscribe(t){return it(ar,()=>t(ar))},subscribeOpen(t){return nt(ar,"open",t)},set(t){Object.assign(ar,{...ar,...t})}},Gn={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 Wh(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"}},La={async getMyTokensWithBalance(t){const e=H.state.address,s=p.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 J.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(r.balances)},async getEIP155Balances(t,e){try{const s=Gn.getChainIdHexFromCAIP2ChainId(e.caipNetworkId);if(!(await Y.getCapabilities(t))?.[s]?.assetDiscovery?.supported)return null;const i=await Y.walletGetAssets({account:t,chainFilter:[s]});return Gn.isWalletGetAssetsResponse(i)?(i[s]||[]).map(o=>Gn.createBalance(o,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return t?.map(e=>({...e,address:e?.address?e.address:p.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]}},ge=Oe({tokenBalances:[],loading:!1}),Vd={state:ge,subscribe(t){return it(ge,()=>t(ge))},subscribeKey(t,e){return nt(ge,t,e)},setToken(t){t&&(ge.token=Ys(t))},setTokenAmount(t){ge.sendTokenAmount=t},setReceiverAddress(t){ge.receiverAddress=t},setReceiverProfileImageUrl(t){ge.receiverProfileImageUrl=t},setReceiverProfileName(t){ge.receiverProfileName=t},setNetworkBalanceInUsd(t){ge.networkBalanceInUSD=t},setLoading(t){ge.loading=t},async sendToken(){try{switch(de.setLoading(!0),p.state.activeCaipNetwork?.chainNamespace){case"eip155":await de.sendEvmToken();return;case"solana":await de.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}finally{de.setLoading(!1)}},async sendEvmToken(){const t=p.state.activeChain,e=H.state.preferredAccountTypes?.[t];if(!de.state.sendTokenAmount||!de.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!de.state.token)throw new Error("A token is required");de.state.token?.address?(ke.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===gi.ACCOUNT_TYPES.SMART_ACCOUNT,token:de.state.token.address,amount:de.state.sendTokenAmount,network:p.state.activeCaipNetwork?.caipNetworkId||""}}),await de.sendERC20Token({receiverAddress:de.state.receiverAddress,tokenAddress:de.state.token.address,sendTokenAmount:de.state.sendTokenAmount,decimals:de.state.token.quantity.decimals})):(ke.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===gi.ACCOUNT_TYPES.SMART_ACCOUNT,token:de.state.token.symbol||"",amount:de.state.sendTokenAmount,network:p.state.activeCaipNetwork?.caipNetworkId||""}}),await de.sendNativeToken({receiverAddress:de.state.receiverAddress,sendTokenAmount:de.state.sendTokenAmount,decimals:de.state.token.quantity.decimals}))},async fetchTokenBalance(t){ge.loading=!0;const e=p.state.activeCaipNetwork?.caipNetworkId,s=p.state.activeCaipNetwork?.chainNamespace,r=p.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(ge.lastRetry&&!X.isAllowedRetry(ge.lastRetry,30*Ie.ONE_SEC_MS))return ge.loading=!1,[];try{if(i&&e&&s){const n=await La.getMyTokensWithBalance();return ge.tokenBalances=n,ge.lastRetry=void 0,n}}catch(n){ge.lastRetry=Date.now(),t?.(n),Ft.showError("Token Balance Unavailable")}finally{ge.loading=!1}return[]},fetchNetworkBalance(){if(ge.tokenBalances.length===0)return;const t=La.mapBalancesToSwapTokens(ge.tokenBalances);if(!t)return;const e=t.find(s=>s.address===p.getActiveNetworkTokenAddress());e&&(ge.networkBalanceInUSD=e?pd.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){ie.pushTransactionStack({});const e=t.receiverAddress,s=H.state.address,r=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));await Y.sendTransaction({chainNamespace:"eip155",to:e,address:s,data:"0x",value:r??BigInt(0)}),ke.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:H.state.preferredAccountTypes?.eip155===gi.ACCOUNT_TYPES.SMART_ACCOUNT,token:de.state.token?.symbol||"",amount:t.sendTokenAmount,network:p.state.activeCaipNetwork?.caipNetworkId||""}}),Y._getClient()?.updateBalance("eip155"),de.resetSend()},async sendERC20Token(t){ie.pushTransactionStack({onSuccess(){ie.replace("Account")}});const e=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));if(H.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const s=X.getPlainAddress(t.tokenAddress);await Y.writeContract({fromAddress:H.state.address,tokenAddress:s,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:wd.getERC20Abi(s),chainNamespace:"eip155"}),de.resetSend()}},async sendSolanaToken(){if(!de.state.sendTokenAmount||!de.state.receiverAddress)throw new Error("An amount and receiver address are required");ie.pushTransactionStack({onSuccess(){ie.replace("Account")}}),await Y.sendTransaction({chainNamespace:"solana",to:de.state.receiverAddress,value:de.state.sendTokenAmount}),Y._getClient()?.updateBalance("solana"),de.resetSend()},resetSend(){ge.token=void 0,ge.sendTokenAmount=void 0,ge.receiverAddress=void 0,ge.receiverProfileImageUrl=void 0,ge.receiverProfileName=void 0,ge.loading=!1,ge.tokenBalances=[]}},de=St(Vd),Jn={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},Gi={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},M=Oe({chains:Id(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),Kd={state:M,subscribe(t){return it(M,()=>{t(M)})},subscribeKey(t,e){return nt(M,t,e)},subscribeChainProp(t,e,s){let r;return it(M.chains,()=>{const i=s||M.activeChain;if(i){const n=M.chains.get(i)?.[t];r!==n&&(r=n,e(n))}})},initialize(t,e,s){const{chainId:r,namespace:i}=W.getActiveNetworkProps(),n=e?.find(u=>u.id.toString()===r?.toString()),a=t.find(u=>u?.namespace===i)||t?.[0],c=t.map(u=>u.namespace).filter(u=>u!==void 0),l=P.state.enableEmbedded?new Set([...c]):new Set([...e?.map(u=>u.chainNamespace)??[]]);(t?.length===0||!a)&&(M.noAdapters=!0),M.noAdapters||(M.activeChain=a?.namespace,M.activeCaipNetwork=n,p.setChainNetworkData(a?.namespace,{caipNetwork:n}),M.activeChain&&As.set({activeChain:a?.namespace})),l.forEach(u=>{const h=e?.filter(d=>d.chainNamespace===u);p.state.chains.set(u,{namespace:u,networkState:Oe({...Gi,caipNetwork:h?.[0]}),accountState:Oe(Jn),caipNetworks:h??[],...s}),p.setRequestedCaipNetworks(h??[],u)})},removeAdapter(t){if(M.activeChain===t){const e=Array.from(M.chains.entries()).find(([s])=>s!==t);if(e){const s=e[1]?.caipNetworks?.[0];s&&p.setActiveCaipNetwork(s)}}M.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){M.chains.set(t.namespace,{namespace:t.namespace,networkState:{...Gi,caipNetwork:r[0]},accountState:Jn,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),p.setRequestedCaipNetworks(r?.filter(i=>i.chainNamespace===t.namespace)??[],t.namespace)},addNetwork(t){const e=M.chains.get(t.chainNamespace);if(e){const s=[...e.caipNetworks||[]];e.caipNetworks?.find(r=>r.id===t.id)||s.push(t),M.chains.set(t.chainNamespace,{...e,caipNetworks:s}),p.setRequestedCaipNetworks(s,t.chainNamespace),q.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){const s=M.chains.get(t);if(s){const r=M.activeCaipNetwork?.id===e,i=[...s.caipNetworks?.filter(n=>n.id!==e)||[]];r&&s?.caipNetworks?.[0]&&p.setActiveCaipNetwork(s.caipNetworks[0]),M.chains.set(t,{...s,caipNetworks:i}),p.setRequestedCaipNetworks(i||[],t),i.length===0&&q.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=M.chains.get(t);s&&(s.networkState={...s.networkState||Gi,...e},M.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const r=M.chains.get(t);if(r){const i={...r.accountState||Jn,...e};M.chains.set(t,{...r,accountState:i}),(M.chains.size===1||M.activeChain===t)&&(e.caipAddress&&(M.activeCaipAddress=e.caipAddress),H.replaceState(i))}},setChainNetworkData(t,e){if(!t)return;const s=M.chains.get(t);if(s){const r={...s.networkState||Gi,...e};M.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){p.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&q.removeConnectorId(s)},setActiveNamespace(t){M.activeChain=t;const e=t?M.chains.get(t):void 0,s=e?.networkState?.caipNetwork;s?.id&&t&&(M.activeCaipAddress=e?.accountState?.caipAddress,M.activeCaipNetwork=s,p.setChainNetworkData(t,{caipNetwork:s}),W.setActiveCaipNetworkId(s?.caipNetworkId),As.set({activeChain:t,selectedNetworkId:s?.caipNetworkId}))},setActiveCaipNetwork(t){if(!t)return;M.activeChain!==t.chainNamespace&&p.setIsSwitchingNamespace(!0);const e=M.chains.get(t.chainNamespace);M.activeChain=t.chainNamespace,M.activeCaipNetwork=t,p.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),e?.accountState?.address?M.activeCaipAddress=`${t.chainNamespace}:${t.id}:${e?.accountState?.address}`:M.activeCaipAddress=void 0,p.setAccountProp("caipAddress",M.activeCaipAddress,t.chainNamespace),e&&H.replaceState(e.accountState),de.resetSend(),As.set({activeChain:M.activeChain,selectedNetworkId:M.activeCaipNetwork?.caipNetworkId}),W.setActiveCaipNetworkId(t.caipNetworkId),!p.checkIfSupportedNetwork(t.chainNamespace)&&P.state.enableNetworkSwitch&&!P.state.allowUnsupportedChain&&!Y.state.wcBasic&&p.showUnsupportedChainUI()},addCaipNetwork(t){if(!t)return;const e=M.chains.get(t.chainNamespace);e&&e?.caipNetworks?.push(t)},async switchActiveNamespace(t){if(!t)return;const e=t!==p.state.activeChain,s=p.getNetworkData(t)?.caipNetwork,r=p.getCaipNetworkByNamespace(t,s?.id);e&&r&&await p.switchActiveNetwork(r)},async switchActiveNetwork(t){const s=!p.state.chains.get(p.state.activeChain)?.caipNetworks?.some(i=>i.id===M.activeCaipNetwork?.id),r=p.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&Ge.close()}catch{ie.goBack()}ke.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})}},getNetworkControllerClient(t){const e=t||M.activeChain,s=M.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||M.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=M.chains.get(e);if(!s?.connectionControllerClient)throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(t,e){let s=M.activeChain;if(e&&(s=e),!s)return;const r=M.chains.get(s)?.accountState;if(r)return r[t]},getNetworkProp(t,e){const s=M.chains.get(e)?.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=M.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:r=[]}=e?.networkState||{};return X.sortRequestedNetworks(s,r)},getAllRequestedCaipNetworks(){const t=[];return M.chains.forEach(e=>{const s=p.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){p.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=p.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));q.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return M.chains.forEach(e=>{const s=p.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(){return M.activeCaipNetwork},getActiveCaipAddress(){return M.activeCaipAddress},getApprovedCaipNetworkIds(t){return M.chains.get(t)?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(t){const s=await p.getNetworkControllerClient()?.getApprovedCaipNetworksData();p.setAdapterNetworkState(t,{approvedCaipNetworkIds:s?.approvedCaipNetworkIds,supportsAllNetworks:s?.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||M.activeCaipNetwork,r=p.getRequestedCaipNetworks(t);return r.length?r?.some(i=>i.id===s?.id):!0},checkIfSupportedChainId(t){return M.activeChain?p.getRequestedCaipNetworks(M.activeChain)?.some(s=>s.id===t):!0},setSmartAccountEnabledNetworks(t,e){p.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){const t=Vl.caipNetworkIdToNumber(M.activeCaipNetwork?.caipNetworkId),e=M.activeChain;return!e||!t?!1:!!p.getNetworkProp("smartAccountEnabledNetworks",e)?.includes(Number(t))},getActiveNetworkTokenAddress(){const t=M.activeCaipNetwork?.chainNamespace||"eip155",e=M.activeCaipNetwork?.id||1,s=Ie.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){Ge.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=M.activeCaipNetwork;return!!(t?.chainNamespace&&Ie.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){p.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");M.activeCaipAddress=void 0,p.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"}),q.removeConnectorId(e)},setIsSwitchingNamespace(t){M.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){const t=[];let e;if(M.chains.forEach(s=>{j.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(r=>r===s.namespace)&&s.namespace&&t.push(s.namespace)}),t.length>0){const s=t[0];return e=s?M.chains.get(s)?.caipNetworks?.[0]:void 0,e}},getAccountData(t){return t?p.state.chains.get(t)?.accountState:H.state},getNetworkData(t){const e=t||M.activeChain;if(e)return p.state.chains.get(e)?.networkState},getCaipNetworkByNamespace(t,e){if(!t)return;const s=p.state.chains.get(t),r=s?.caipNetworks?.find(i=>i.id===e);return r||s?.networkState?.caipNetwork||s?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const t=q.state.filterByNamespace;return(t?[M.chains.get(t)]:Array.from(M.chains.values())).flatMap(s=>s?.caipNetworks||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?p.getRequestedCaipNetworks(t):p.getAllRequestedCaipNetworks()}},p=St(Kd),Gd={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"}]}]},Zl=X.getBlockchainApiUrl(),ut=Oe({clientId:null,api:new Ui({baseUrl:Zl,clientId:null}),supportedChains:{http:[],ws:[]}}),J={state:ut,async get(t){const{st:e,sv:s}=J.getSdkProperties(),r=P.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return ut.api.get({...t,params:i})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=P.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{ut.supportedChains.http.length||await J.getSupportedNetworks()}catch{return!1}return ut.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await J.get({path:"v1/supported-chains"});return ut.supportedChains=t,t}catch{return ut.supportedChains}},async fetchIdentity({address:t,caipNetworkId:e}){if(!await J.isNetworkSupported(e))return{avatar:"",name:""};const r=W.getIdentityFromCacheForAddress(t);if(r)return r;const i=await J.get({path:`/v1/identity/${t}`,params:{sender:p.state.activeCaipAddress?X.getPlainAddress(p.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}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.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}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.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}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?ut.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:P.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){const{st:e,sv:s}=J.getSdkProperties();if(!await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return J.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}){if(!await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return ut.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ie.CONVERT_SLIPPAGE_TOLERANCE},projectId:P.state.projectId,from:e,to:s,userAddress:r,disableEstimate:i}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return J.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){const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId))return Ft.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=W.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await J.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){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:`/v1/profile/reverse/${t}`,params:{sender:H.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:r}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?ut.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}){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?(await ut.api.post({path:"/v1/generators/onrampurl",params:{projectId:P.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:i}})).url:""},async getOnrampOptions(){if(!await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await J.get({path:"/v1/onramp/options"})}catch{return Gd}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){try{return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?await ut.api.post({path:"/v1/onramp/quote",params:{projectId:P.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){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?J.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){return await J.isNetworkSupported(p.state.activeCaipNetwork?.caipNetworkId)?ut.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:P.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){ut.clientId=t,ut.api=new Ui({baseUrl:Zl,clientId:t})}},Pt=Oe({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),Jd={state:Pt,replaceState(t){t&&Object.assign(Pt,Ys(t))},subscribe(t){return p.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return p.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){p.setAccountProp("status",t,e)},getCaipAddress(t){return p.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?X.getPlainAddress(t):void 0;e===p.state.activeChain&&(p.state.activeCaipAddress=t),p.setAccountProp("caipAddress",t,e),p.setAccountProp("address",s,e)},setBalance(t,e,s){p.setAccountProp("balance",t,s),p.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){p.setAccountProp("profileName",t,e)},setProfileImage(t,e){p.setAccountProp("profileImage",t,e)},setUser(t,e){p.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){p.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){p.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){p.setAccountProp("currentTab",t,p.state.activeChain)},setTokenBalance(t,e){t&&p.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){p.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){p.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=p.getAccountProp("addressLabels",s)||new Map;r.set(t,e),p.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=p.getAccountProp("addressLabels",e)||new Map;s.delete(t),p.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){p.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){p.setAccountProp("preferredAccountTypes",{...Pt.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){Pt.preferredAccountTypes=t},setSocialProvider(t,e){t&&p.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){p.setAccountProp("socialWindow",t?Ys(t):void 0,e)},setFarcasterUrl(t,e){p.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){Pt.balanceLoading=!0;const e=p.state.activeCaipNetwork?.caipNetworkId,s=p.state.activeCaipNetwork?.chainNamespace,r=p.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(Pt.lastRetry&&!X.isAllowedRetry(Pt.lastRetry,30*Ie.ONE_SEC_MS))return Pt.balanceLoading=!1,[];try{if(i&&e&&s){const o=(await J.getBalance(i,e)).balances.filter(a=>a.quantity.decimals!=="0");return H.setTokenBalance(o,s),Pt.lastRetry=void 0,Pt.balanceLoading=!1,o}}catch(n){Pt.lastRetry=Date.now(),t?.(n),Ft.showError("Token Balance Unavailable")}finally{Pt.balanceLoading=!1}return[]},resetAccount(t){p.resetAccount(t)}},H=St(Jd),Yd={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=p.state.activeCaipNetwork,r=ie.state.data;if(t.id===s?.id)return;const n=H.getCaipAddress(p.state.activeChain),o=t.chainNamespace!==p.state.activeChain,a=H.getCaipAddress(t.chainNamespace),l=q.getConnectorId(p.state.activeChain)===j.CONNECTOR_ID.AUTH,u=j.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(h=>h===t.chainNamespace);e||l&&u?ie.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?ie.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ie.push("SwitchNetwork",{...r,network:t})}},ht=Oe({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Xd={state:ht,subscribe(t){return it(ht,()=>t(ht))},subscribeKey(t,e){return nt(ht,t,e)},async open(t){const e=H.state.status==="connected",s=t?.namespace,r=p.state.activeChain,i=s&&s!==r,n=p.getAccountData(t?.namespace)?.caipAddress;if(Y.state.wcBasic?V.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await V.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),q.setFilterByNamespace(t?.namespace),Ge.setLoading(!0,s),s&&i){const o=p.getNetworkData(s)?.caipNetwork||p.getRequestedCaipNetworks(s)[0];o&&Yd.onSwitchNetwork({network:o,ignoreSwitchConfirmation:!0})}else{const o=p.state.noAdapters;P.state.manualWCControl||o&&!n?X.isMobile()?ie.reset("AllWallets"):ie.reset("ConnectingWalletConnectBasic"):t?.view?ie.reset(t.view,t.data):n?ie.reset("Account"):ie.reset("Connect")}ht.open=!0,As.set({open:!0}),ke.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=P.state.enableEmbedded,e=!!p.state.activeCaipAddress;ht.open&&ke.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),ht.open=!1,ie.reset("Connect"),Ge.clearLoading(),t?e?ie.replace("Account"):ie.push("Connect"):As.set({open:!1}),Y.resetUri()},setLoading(t,e){e&&ht.loadingNamespaceMap.set(e,t),ht.loading=t,As.set({loading:t})},clearLoading(){ht.loadingNamespaceMap.clear(),ht.loading=!1},shake(){ht.shake||(ht.shake=!0,setTimeout(()=>{ht.shake=!1},500))}},Ge=St(Xd),mi={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"}]},_o={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},Zd={providers:Jl,selectedProvider:null,error:null,purchaseCurrency:mi,paymentCurrency:_o,purchaseCurrencies:[mi],paymentCurrencies:[],quotesLoading:!1},ae=Oe(Zd),Qd={state:ae,subscribe(t){return it(ae,()=>t(ae))},subscribeKey(t,e){return nt(ae,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=p.state.activeChain===j.CHAIN.SOLANA?"SOL":"USDC",s=H.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",Nd),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",P.state.projectId),ae.selectedProvider={...t,url:r.toString()}}else ae.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=Jl.filter(r=>e.includes(r.name));ae.providers=s}else ae.providers=[]},setPurchaseCurrency(t){ae.purchaseCurrency=t},setPaymentCurrency(t){ae.paymentCurrency=t},setPurchaseAmount(t){Ao.state.purchaseAmount=t},setPaymentAmount(t){Ao.state.paymentAmount=t},async getAvailableCurrencies(){const t=await J.getOnrampOptions();ae.purchaseCurrencies=t.purchaseCurrencies,ae.paymentCurrencies=t.paymentCurrencies,ae.paymentCurrency=t.paymentCurrencies[0]||_o,ae.purchaseCurrency=t.purchaseCurrencies[0]||mi,await V.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await V.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){ae.quotesLoading=!0;try{const t=await J.getOnrampQuote({purchaseCurrency:ae.purchaseCurrency,paymentCurrency:ae.paymentCurrency,amount:ae.paymentAmount?.toString()||"0",network:ae.purchaseCurrency?.symbol});return ae.quotesLoading=!1,ae.purchaseAmount=Number(t?.purchaseAmount.amount),t}catch(t){return ae.error=t.message,ae.quotesLoading=!1,null}finally{ae.quotesLoading=!1}},resetState(){ae.selectedProvider=null,ae.error=null,ae.purchaseCurrency=mi,ae.paymentCurrency=_o,ae.purchaseCurrencies=[mi],ae.paymentCurrencies=[],ae.paymentAmount=void 0,ae.purchaseAmount=void 0,ae.quotesLoading=!1}},Ao=St(Qd),Ma=2147483648,ep={convertEVMChainIdToCoinType(t){if(t>=Ma)throw new Error("Invalid chainId");return(Ma|t)>>>0}},Ot=Oe({suggestions:[],loading:!1}),tp={state:Ot,subscribe(t){return it(Ot,()=>t(Ot))},subscribeKey(t,e){return nt(Ot,t,e)},async resolveName(t){try{return await J.lookupEnsName(t)}catch(e){const s=e;throw new Error(s?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(t){try{return await J.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{Ot.loading=!0,Ot.suggestions=[];const e=await J.getEnsNameSuggestions(t);return Ot.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],Ot.suggestions}catch(e){const s=wi.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Ot.loading=!1}},async getNamesForAddress(t){try{if(!p.state.activeCaipNetwork)return[];const s=W.getEnsFromCacheForAddress(t);if(s)return s;const r=await J.reverseLookupEnsName({address:t});return W.updateEnsCache({address:t,ens:r,timestamp:Date.now()}),r}catch(e){const s=wi.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=p.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const s=H.state.address,r=q.getAuthConnector();if(!s||!r)throw new Error("Address or auth connector not found");Ot.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});ie.pushTransactionStack({onCancel(){ie.replace("RegisterAccountName")}});const n=await Y.signMessage(i);Ot.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=ep.convertEVMChainIdToCoinType(Number(o));await J.registerEnsName({coinType:a,address:s,signature:n,message:i}),H.setProfileName(t,e.chainNamespace),ie.replace("RegisterAccountNameSuccess")}catch(i){const n=wi.parseEnsApiError(i,`Error registering name ${t}`);throw ie.replace("RegisterAccountName"),new Error(n)}finally{Ot.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){return t?.reasons?.[0]?.description||e}},wi=St(tp);var Ql={exports:{}},kr=typeof Reflect=="object"?Reflect:null,Ba=kr&&typeof kr.apply=="function"?kr.apply:function(e,s,r){return Function.prototype.apply.call(e,s,r)},cn;kr&&typeof kr.ownKeys=="function"?cn=kr.ownKeys:Object.getOwnPropertySymbols?cn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:cn=function(e){return Object.getOwnPropertyNames(e)};function sp(t){console&&console.warn&&console.warn(t)}var eu=Number.isNaN||function(e){return e!==e};function ve(){ve.init.call(this)}Ql.exports=ve;Ql.exports.once=op;ve.EventEmitter=ve;ve.prototype._events=void 0;ve.prototype._eventsCount=0;ve.prototype._maxListeners=void 0;var ja=10;function $n(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ve,"defaultMaxListeners",{enumerable:!0,get:function(){return ja},set:function(t){if(typeof t!="number"||t<0||eu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ja=t}});ve.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ve.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||eu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function tu(t){return t._maxListeners===void 0?ve.defaultMaxListeners:t._maxListeners}ve.prototype.getMaxListeners=function(){return tu(this)};ve.prototype.emit=function(e){for(var s=[],r=1;r<arguments.length;r++)s.push(arguments[r]);var i=e==="error",n=this._events;if(n!==void 0)i=i&&n.error===void 0;else if(!i)return!1;if(i){var o;if(s.length>0&&(o=s[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(c===void 0)return!1;if(typeof c=="function")Ba(c,this,s);else for(var l=c.length,u=ou(c,l),r=0;r<l;++r)Ba(u[r],this,s);return!0};function su(t,e,s,r){var i,n,o;if($n(s),n=t._events,n===void 0?(n=t._events=Object.create(null),t._eventsCount=0):(n.newListener!==void 0&&(t.emit("newListener",e,s.listener?s.listener:s),n=t._events),o=n[e]),o===void 0)o=n[e]=s,++t._eventsCount;else if(typeof o=="function"?o=n[e]=r?[s,o]:[o,s]:r?o.unshift(s):o.push(s),i=tu(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,sp(a)}return t}ve.prototype.addListener=function(e,s){return su(this,e,s,!1)};ve.prototype.on=ve.prototype.addListener;ve.prototype.prependListener=function(e,s){return su(this,e,s,!0)};function rp(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ru(t,e,s){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},i=rp.bind(r);return i.listener=s,r.wrapFn=i,i}ve.prototype.once=function(e,s){return $n(s),this.on(e,ru(this,e,s)),this};ve.prototype.prependOnceListener=function(e,s){return $n(s),this.prependListener(e,ru(this,e,s)),this};ve.prototype.removeListener=function(e,s){var r,i,n,o,a;if($n(s),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===s||r.listener===s)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||s));else if(typeof r!="function"){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===s||r[o].listener===s){a=r[o].listener,n=o;break}if(n<0)return this;n===0?r.shift():ip(r,n),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||s)}return this};ve.prototype.off=ve.prototype.removeListener;ve.prototype.removeAllListeners=function(e){var s,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var n=Object.keys(r),o;for(i=0;i<n.length;++i)o=n[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(s=r[e],typeof s=="function")this.removeListener(e,s);else if(s!==void 0)for(i=s.length-1;i>=0;i--)this.removeListener(e,s[i]);return this};function iu(t,e,s){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?s?[i.listener||i]:[i]:s?np(i):ou(i,i.length)}ve.prototype.listeners=function(e){return iu(this,e,!0)};ve.prototype.rawListeners=function(e){return iu(this,e,!1)};ve.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):nu.call(t,e)};ve.prototype.listenerCount=nu;function nu(t){var e=this._events;if(e!==void 0){var s=e[t];if(typeof s=="function")return 1;if(s!==void 0)return s.length}return 0}ve.prototype.eventNames=function(){return this._eventsCount>0?cn(this._events):[]};function ou(t,e){for(var s=new Array(e),r=0;r<e;++r)s[r]=t[r];return s}function ip(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function np(t){for(var e=new Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}function op(t,e){return new Promise(function(s,r){function i(o){t.removeListener(e,n),r(o)}function n(){typeof t.removeListener=="function"&&t.removeListener("error",i),s([].slice.call(arguments))}au(t,e,n,{once:!0}),e!=="error"&&ap(t,i,{once:!0})})}function ap(t,e,s){typeof t.on=="function"&&au(t,"error",e,s)}function au(t,e,s,r){if(typeof t.on=="function")r.once?t.once(e,s):t.on(e,s);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(n){r.once&&t.removeEventListener(e,i),s(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const yi={getSIWX(){return P.state.siwx},async initializeIfEnabled(){const t=P.state.siwx,e=p.getActiveCaipAddress();if(!(t&&e))return;const[s,r,i]=e.split(":");if(p.checkIfSupportedNetwork(s))try{if((await t.getSessions(`${s}:${r}`,i)).length)return;await Ge.open({view:"SIWXSignMessage"})}catch(n){console.error("SIWXUtil:initializeIfEnabled",n),ke.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await Y._getClient()?.disconnect().catch(console.error),ie.reset("Connect"),Ft.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=P.state.siwx,e=X.getPlainAddress(p.getActiveCaipAddress()),s=p.getActiveCaipNetwork(),r=Y._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();q.getConnectorId(s.chainNamespace)===j.CONNECTOR_ID.AUTH&&ie.pushTransactionStack({});const a=await r.signMessage(n);await t.addSession({data:i,message:n,signature:a}),Ge.close(),ke.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const n=this.getSIWXEventProperties();(!Ge.state.open||ie.state.view==="ApproveTransaction")&&await Ge.open({view:"SIWXSignMessage"}),n.isSmartAccount?Ft.showError("This application might not support Smart Accounts"):Ft.showError("Signature declined"),ke.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){try{this.getSIWX()?.getRequired?.()?await Y.disconnect():Ge.close(),ie.reset("Connect"),ke.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(t){console.error("SIWXUtil:cancelSignMessage",t)}},async getSessions(){const t=P.state.siwx,e=X.getPlainAddress(p.getActiveCaipAddress()),s=p.getActiveCaipNetwork();return t&&e&&s?t.getSessions(s.caipNetworkId,e):[]},async isSIWXCloseDisabled(){const t=this.getSIWX();if(t){const e=ie.state.view==="ApproveTransaction",s=ie.state.view==="SIWXSignMessage";if(e||s)return t.getRequired?.()&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:s}){const r=yi.getSIWX(),i=new Set(e.map(a=>a.split(":")[0]));if(!r||i.size!==1||!i.has("eip155"))return!1;const n=await r.createMessage({chainId:p.getActiveCaipNetwork()?.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(a=>a!==n.chainId)]});if(Ft.showLoading("Authenticating...",{autoClose:!1}),H.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:o.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(i)[0]),o?.auths?.length){const a=o.auths.map(c=>{const l=t.client.formatAuthMessage({request:c.p,iss:c.p.iss});return{data:{...c.p,accountAddress:c.p.iss.split(":").slice(-1).join(""),chainId:c.p.iss.split(":").slice(2,4).join(":"),uri:c.p.aud,version:c.p.version||n.version,expirationTime:c.p.exp,issuedAt:c.p.iat,notBefore:c.p.nbf},message:l,signature:c.s.s,cacao:c}});try{await r.setSessions(a),ke.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:yi.getSIWXEventProperties()})}catch(c){throw console.error("SIWX:universalProviderAuth - failed to set sessions",c),ke.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:yi.getSIWXEventProperties()}),await t.disconnect().catch(console.error),c}finally{Ft.hide()}}return!0},getSIWXEventProperties(){const t=p.state.activeChain;return{network:p.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:H.state.preferredAccountTypes?.[t]===gi.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};var oa={exports:{}},$r=typeof Reflect=="object"?Reflect:null,qa=$r&&typeof $r.apply=="function"?$r.apply:function(e,s,r){return Function.prototype.apply.call(e,s,r)},ln;$r&&typeof $r.ownKeys=="function"?ln=$r.ownKeys:Object.getOwnPropertySymbols?ln=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ln=function(e){return Object.getOwnPropertyNames(e)};function cp(t){console&&console.warn&&console.warn(t)}var cu=Number.isNaN||function(e){return e!==e};function be(){be.init.call(this)}oa.exports=be;oa.exports.once=dp;be.EventEmitter=be;be.prototype._events=void 0;be.prototype._eventsCount=0;be.prototype._maxListeners=void 0;var Fa=10;function xn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(be,"defaultMaxListeners",{enumerable:!0,get:function(){return Fa},set:function(t){if(typeof t!="number"||t<0||cu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Fa=t}});be.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};be.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||cu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function lu(t){return t._maxListeners===void 0?be.defaultMaxListeners:t._maxListeners}be.prototype.getMaxListeners=function(){return lu(this)};be.prototype.emit=function(e){for(var s=[],r=1;r<arguments.length;r++)s.push(arguments[r]);var i=e==="error",n=this._events;if(n!==void 0)i=i&&n.error===void 0;else if(!i)return!1;if(i){var o;if(s.length>0&&(o=s[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(c===void 0)return!1;if(typeof c=="function")qa(c,this,s);else for(var l=c.length,u=fu(c,l),r=0;r<l;++r)qa(u[r],this,s);return!0};function uu(t,e,s,r){var i,n,o;if(xn(s),n=t._events,n===void 0?(n=t._events=Object.create(null),t._eventsCount=0):(n.newListener!==void 0&&(t.emit("newListener",e,s.listener?s.listener:s),n=t._events),o=n[e]),o===void 0)o=n[e]=s,++t._eventsCount;else if(typeof o=="function"?o=n[e]=r?[s,o]:[o,s]:r?o.unshift(s):o.push(s),i=lu(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,cp(a)}return t}be.prototype.addListener=function(e,s){return uu(this,e,s,!1)};be.prototype.on=be.prototype.addListener;be.prototype.prependListener=function(e,s){return uu(this,e,s,!0)};function lp(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function hu(t,e,s){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},i=lp.bind(r);return i.listener=s,r.wrapFn=i,i}be.prototype.once=function(e,s){return xn(s),this.on(e,hu(this,e,s)),this};be.prototype.prependOnceListener=function(e,s){return xn(s),this.prependListener(e,hu(this,e,s)),this};be.prototype.removeListener=function(e,s){var r,i,n,o,a;if(xn(s),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===s||r.listener===s)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||s));else if(typeof r!="function"){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===s||r[o].listener===s){a=r[o].listener,n=o;break}if(n<0)return this;n===0?r.shift():up(r,n),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||s)}return this};be.prototype.off=be.prototype.removeListener;be.prototype.removeAllListeners=function(e){var s,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var n=Object.keys(r),o;for(i=0;i<n.length;++i)o=n[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(s=r[e],typeof s=="function")this.removeListener(e,s);else if(s!==void 0)for(i=s.length-1;i>=0;i--)this.removeListener(e,s[i]);return this};function du(t,e,s){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?s?[i.listener||i]:[i]:s?hp(i):fu(i,i.length)}be.prototype.listeners=function(e){return du(this,e,!0)};be.prototype.rawListeners=function(e){return du(this,e,!1)};be.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):pu.call(t,e)};be.prototype.listenerCount=pu;function pu(t){var e=this._events;if(e!==void 0){var s=e[t];if(typeof s=="function")return 1;if(s!==void 0)return s.length}return 0}be.prototype.eventNames=function(){return this._eventsCount>0?ln(this._events):[]};function fu(t,e){for(var s=new Array(e),r=0;r<e;++r)s[r]=t[r];return s}function up(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function hp(t){for(var e=new Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}function dp(t,e){return new Promise(function(s,r){function i(o){t.removeListener(e,n),r(o)}function n(){typeof t.removeListener=="function"&&t.removeListener("error",i),s([].slice.call(arguments))}gu(t,e,n,{once:!0}),e!=="error"&&pp(t,i,{once:!0})})}function pp(t,e,s){typeof t.on=="function"&&gu(t,"error",e,s)}function gu(t,e,s,r){if(typeof t.on=="function")r.once?t.once(e,s):t.on(e,s);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(n){r.once&&t.removeEventListener(e,i),s(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var $s=oa.exports;const aa=Yh($s);function fp(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function He(t,...e){try{return fp(t(...e))}catch(s){return Promise.reject(s)}}function gp(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function mp(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function un(t){if(gp(t))return String(t);if(mp(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return un(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const So="base64:";function wp(t){return typeof t=="string"?t:So+bp(t)}function yp(t){return typeof t!="string"||!t.startsWith(So)?t:vp(t.slice(So.length))}function vp(t){return globalThis.Buffer?Ye.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function bp(t){return globalThis.Buffer?Ye.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function ft(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function Ep(...t){return ft(t.join(":"))}function Ji(t){return t=ft(t),t?t+":":""}function Cp(t,e){if(e===void 0)return!0;let s=0,r=t.indexOf(":");for(;r>-1;)s++,r=t.indexOf(":",r+1);return s<=e}function Ip(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const Np="memory",_p=()=>{const t=new Map;return{name:Np,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,s){t.set(e,s)},setItemRaw(e,s){t.set(e,s)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function Ap(t={}){const e={mounts:{"":t.driver||_p()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},s=l=>{for(const u of e.mountpoints)if(l.startsWith(u))return{base:u,relativeKey:l.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:l,driver:e.mounts[""]}},r=(l,u)=>e.mountpoints.filter(h=>h.startsWith(l)||u&&l.startsWith(h)).map(h=>({relativeBase:l.length>h.length?l.slice(h.length):void 0,mountpoint:h,driver:e.mounts[h]})),i=(l,u)=>{if(e.watching){u=ft(u);for(const h of e.watchListeners)h(l,u)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Wa(e.mounts[l],i,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,u,h)=>{const d=new Map,f=m=>{let w=d.get(m.base);return w||(w={driver:m.driver,base:m.base,items:[]},d.set(m.base,w)),w};for(const m of l){const w=typeof m=="string",g=ft(w?m:m.key),y=w?void 0:m.value,v=w||!m.options?u:{...u,...m.options},E=s(g);f(E).items.push({key:g,value:y,relativeKey:E.relativeKey,options:v})}return Promise.all([...d.values()].map(m=>h(m))).then(m=>m.flat())},c={hasItem(l,u={}){l=ft(l);const{relativeKey:h,driver:d}=s(l);return He(d.hasItem,h,u)},getItem(l,u={}){l=ft(l);const{relativeKey:h,driver:d}=s(l);return He(d.getItem,h,u).then(f=>Ki(f))},getItems(l,u={}){return a(l,u,h=>h.driver.getItems?He(h.driver.getItems,h.items.map(d=>({key:d.relativeKey,options:d.options})),u).then(d=>d.map(f=>({key:Ep(h.base,f.key),value:Ki(f.value)}))):Promise.all(h.items.map(d=>He(h.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:Ki(f)})))))},getItemRaw(l,u={}){l=ft(l);const{relativeKey:h,driver:d}=s(l);return d.getItemRaw?He(d.getItemRaw,h,u):He(d.getItem,h,u).then(f=>yp(f))},async setItem(l,u,h={}){if(u===void 0)return c.removeItem(l);l=ft(l);const{relativeKey:d,driver:f}=s(l);f.setItem&&(await He(f.setItem,d,un(u),h),f.watch||i("update",l))},async setItems(l,u){await a(l,u,async h=>{if(h.driver.setItems)return He(h.driver.setItems,h.items.map(d=>({key:d.relativeKey,value:un(d.value),options:d.options})),u);h.driver.setItem&&await Promise.all(h.items.map(d=>He(h.driver.setItem,d.relativeKey,un(d.value),d.options)))})},async setItemRaw(l,u,h={}){if(u===void 0)return c.removeItem(l,h);l=ft(l);const{relativeKey:d,driver:f}=s(l);if(f.setItemRaw)await He(f.setItemRaw,d,u,h);else if(f.setItem)await He(f.setItem,d,wp(u),h);else return;f.watch||i("update",l)},async removeItem(l,u={}){typeof u=="boolean"&&(u={removeMeta:u}),l=ft(l);const{relativeKey:h,driver:d}=s(l);d.removeItem&&(await He(d.removeItem,h,u),(u.removeMeta||u.removeMata)&&await He(d.removeItem,h+"$",u),d.watch||i("remove",l))},async getMeta(l,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),l=ft(l);const{relativeKey:h,driver:d}=s(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await He(d.getMeta,h,u)),!u.nativeOnly){const m=await He(d.getItem,h+"$",u).then(w=>Ki(w));m&&typeof m=="object"&&(typeof m.atime=="string"&&(m.atime=new Date(m.atime)),typeof m.mtime=="string"&&(m.mtime=new Date(m.mtime)),Object.assign(f,m))}return f},setMeta(l,u,h={}){return this.setItem(l+"$",u,h)},removeMeta(l,u={}){return this.removeItem(l+"$",u)},async getKeys(l,u={}){l=Ji(l);const h=r(l,!0);let d=[];const f=[];let m=!0;for(const g of h){g.driver.flags?.maxDepth||(m=!1);const y=await He(g.driver.getKeys,g.relativeBase,u);for(const v of y){const E=g.mountpoint+ft(v);d.some(N=>E.startsWith(N))||f.push(E)}d=[g.mountpoint,...d.filter(v=>!v.startsWith(g.mountpoint))]}const w=u.maxDepth!==void 0&&!m;return f.filter(g=>(!w||Cp(g,u.maxDepth))&&Ip(g,l))},async clear(l,u={}){l=Ji(l),await Promise.all(r(l,!1).map(async h=>{if(h.driver.clear)return He(h.driver.clear,h.relativeBase,u);if(h.driver.removeItem){const d=await h.driver.getKeys(h.relativeBase||"",u);return Promise.all(d.map(f=>h.driver.removeItem(f,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Ha(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,u){if(l=Ji(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((h,d)=>d.length-h.length)),e.mounts[l]=u,e.watching&&Promise.resolve(Wa(u,i,l)).then(h=>{e.unwatch[l]=h}).catch(console.error),c},async unmount(l,u=!0){l=Ji(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l]?.(),delete e.unwatch[l]),u&&await Ha(e.mounts[l]),e.mountpoints=e.mountpoints.filter(h=>h!==l),delete e.mounts[l])},getMount(l=""){l=ft(l)+":";const u=s(l);return{driver:u.driver,base:u.base}},getMounts(l="",u={}){return l=ft(l),r(l,u.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,u={})=>c.getKeys(l,u),get:(l,u={})=>c.getItem(l,u),set:(l,u,h={})=>c.setItem(l,u,h),has:(l,u={})=>c.hasItem(l,u),del:(l,u={})=>c.removeItem(l,u),remove:(l,u={})=>c.removeItem(l,u)};return c}function Wa(t,e,s){return t.watch?t.watch((r,i)=>e(r,s+i)):()=>{}}async function Ha(t){typeof t.dispose=="function"&&await He(t.dispose)}const Sp="idb-keyval";var Pp=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=i=>e+i;let r;return t.dbName&&t.storeName&&(r=Hh(t.dbName,t.storeName)),{name:Sp,options:t,async hasItem(i){return!(typeof await _a(s(i),r)>"u")},async getItem(i){return await _a(s(i),r)??null},setItem(i,n){return zh(s(i),n,r)},removeItem(i){return Vh(s(i),r)},getKeys(){return Kh(r)},clear(){return Gh(r)}}};const Op="WALLET_CONNECT_V2_INDEXED_DB",Tp="keyvaluestorage";let kp=class{constructor(){this.indexedDb=Ap({driver:Pp({dbName:Op,storeName:Tp})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const s=await this.indexedDb.getItem(e);if(s!==null)return s}async setItem(e,s){await this.indexedDb.setItem(e,sa(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Q<"u"?Q:typeof self<"u"?self:{},hn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(s){return this.hasOwnProperty(s)?String(this[s]):null},t.prototype.setItem=function(s,r){this[s]=String(r)},t.prototype.removeItem=function(s){delete this[s]},t.prototype.clear=function(){const s=this;Object.keys(s).forEach(function(r){s[r]=void 0,delete s[r]})},t.prototype.key=function(s){return s=s||0,Object.keys(this)[s]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Yn<"u"&&Yn.localStorage?hn.exports=Yn.localStorage:typeof window<"u"&&window.localStorage?hn.exports=window.localStorage:hn.exports=new e})();function $p(t){var e;return[t[0],bn((e=t[1])!=null?e:"")]}let xp=class{constructor(){this.localStorage=hn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map($p)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return bn(s)}async setItem(e,s){this.localStorage.setItem(e,sa(s))}async removeItem(e){this.localStorage.removeItem(e)}};const Rp="wc_storage_version",za=1,Up=async(t,e,s)=>{const r=Rp,i=await e.getItem(r);if(i&&i>=za){s(e);return}const n=await t.getKeys();if(!n.length){s(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(r,za),s(e),Dp(t,o)},Dp=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let Lp=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new xp;this.storage=e;try{const s=new kp;Up(e,s,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,s){return await this.initialize(),this.storage.setItem(e,s)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const s=setInterval(()=>{this.initialized&&(clearInterval(s),e())},20)})}};var Mp=Object.defineProperty,Bp=(t,e,s)=>e in t?Mp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Va=(t,e,s)=>Bp(t,typeof e!="symbol"?e+"":e,s);let jp=class extends Kr{constructor(e){super(),this.opts=e,Va(this,"protocol","wc"),Va(this,"version",2)}};var qp=Object.defineProperty,Fp=(t,e,s)=>e in t?qp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Wp=(t,e,s)=>Fp(t,e+"",s);let Hp=class extends Kr{constructor(e,s){super(),this.core=e,this.logger=s,Wp(this,"records",new Map)}},zp=class{constructor(e,s){this.logger=e,this.core=s}},Vp=class extends Kr{constructor(e,s){super(),this.relayer=e,this.logger=s}},Kp=class extends Kr{constructor(e){super()}},Gp=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},Jp=class extends Kr{constructor(e,s){super(),this.relayer=e,this.logger=s}},Yp=class extends Kr{constructor(e,s){super(),this.core=e,this.logger=s}},Xp=class{constructor(e,s,r){this.core=e,this.logger=s,this.store=r}},Zp=class{constructor(e,s){this.projectId=e,this.logger=s}},Qp=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var ef=Object.defineProperty,tf=(t,e,s)=>e in t?ef(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ka=(t,e,s)=>tf(t,typeof e!="symbol"?e+"":e,s);let sf=class{constructor(e){this.opts=e,Ka(this,"protocol","wc"),Ka(this,"version",2)}},rf=class{constructor(e){this.client=e}};function nf(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<t.length;l++){const u=t.charAt(l),h=u.charCodeAt(0);if(e[h]!==255)throw new TypeError(u+" is ambiguous");e[h]=l}const s=t.length,r=t.charAt(0),i=Math.log(s)/Math.log(256),n=Math.log(256)/Math.log(s);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let u=0,h=0,d=0;const f=l.length;for(;d!==f&&l[d]===0;)d++,u++;const m=(f-d)*n+1>>>0,w=new Uint8Array(m);for(;d!==f;){let v=l[d],E=0;for(let N=m-1;(v!==0||E<h)&&N!==-1;N--,E++)v+=256*w[N]>>>0,w[N]=v%s>>>0,v=v/s>>>0;if(v!==0)throw new Error("Non-zero carry");h=E,d++}let g=m-h;for(;g!==m&&w[g]===0;)g++;let y=r.repeat(u);for(;g<m;++g)y+=t.charAt(w[g]);return y}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let u=0,h=0,d=0;for(;l[u]===r;)h++,u++;const f=(l.length-u)*i+1>>>0,m=new Uint8Array(f);for(;u<l.length;){const v=l.charCodeAt(u);if(v>255)return;let E=e[v];if(E===255)return;let N=0;for(let $=f-1;(E!==0||N<d)&&$!==-1;$--,N++)E+=s*m[$]>>>0,m[$]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");d=N,u++}let w=f-d;for(;w!==f&&m[w]===0;)w++;const g=new Uint8Array(h+(f-w));let y=h;for(;w!==f;)g[y++]=m[w++];return g}function c(l){const u=a(l);if(u)return u;throw new Error("Non-base"+s+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var of="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const mu=nf(of);var af={};const cf=":";function xr(t){const[e,s]=t.split(cf);return{namespace:e,reference:s}}function wu(t,e){return t.includes(":")?[t]:e.chains||[]}var lf=Object.defineProperty,uf=Object.defineProperties,hf=Object.getOwnPropertyDescriptors,Ga=Object.getOwnPropertySymbols,df=Object.prototype.hasOwnProperty,pf=Object.prototype.propertyIsEnumerable,Ja=(t,e,s)=>e in t?lf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ya=(t,e)=>{for(var s in e||(e={}))df.call(e,s)&&Ja(t,s,e[s]);if(Ga)for(var s of Ga(e))pf.call(e,s)&&Ja(t,s,e[s]);return t},ff=(t,e)=>uf(t,hf(e));const gf="ReactNative",Nt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},mf="js";function Cn(){return typeof _s<"u"&&typeof _s.versions<"u"&&typeof _s.versions.node<"u"}function xs(){return!Dr()&&!!Wl()&&navigator.product===gf}function wf(){return xs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="android"}function yf(){return xs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="ios"}function Jr(){return!Cn()&&!!Wl()&&!!Dr()}function Di(){return xs()?Nt.reactNative:Cn()?Nt.node:Jr()?Nt.browser:Nt.unknown}function Xa(){var t;try{return xs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Application)<"u"?(t=Q.Application)==null?void 0:t.applicationId:void 0}catch{return}}function vf(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 bf(t){var e,s;const r=yu();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?.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),ff(Ya(Ya({},r),t),{url:t?.url||r.url,name:t?.name||r.name,description:t?.description||r.description,icons:(s=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 yu(){return Xh()||{name:"",description:"",url:"",icons:[""]}}function Ef(){if(Di()===Nt.reactNative&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"){const{OS:s,Version:r}=Q.Platform;return[s,r].join("-")}const t=Qh();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 Cf(){var t;const e=Di();return e===Nt.browser?[e,((t=ed())==null?void 0:t.host)||"unknown"].join(":"):e}function vu(t,e,s){const r=Ef(),i=Cf();return[[t,e].join("-"),[mf,s].join("-"),r,i].join("/")}function If({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=vu(t,e,r),h={auth:i,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=vf(l[1]||"",h);return l[0]+"?"+d}function Vs(t,e){return t.filter(s=>e.includes(s)).length===t.length}function Po(t){return Object.fromEntries(t.entries())}function Oo(t){return new Map(Object.entries(t))}function js(t=U.FIVE_MINUTES,e){const s=U.toMiliseconds(t||U.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 Ns(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 bu(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 Nf(t){return bu("topic",t)}function _f(t){return bu("id",t)}function Eu(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 Be(t,e){return U.fromMiliseconds(Date.now()+U.toMiliseconds(t))}function bs(t){return Date.now()>=U.toMiliseconds(t)}function fe(t,e){return`${t}${e?`:${e}`:""}`}function es(t=[],e=[]){return[...new Set([...t,...e])]}async function Af({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i?.href;if(typeof n!="string")return;const o=Sf(n,t,e),a=Di();if(a===Nt.browser){if(!((r=Dr())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Pf(o)}else a===Nt.reactNative&&typeof(Q==null?void 0:Q.Linking)<"u"&&await Q.Linking.openURL(o)}catch(i){console.error(i)}}function Sf(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}${$f(r,!0)}`}else i=`${i}/wc?${r}`;return i}function Pf(t){let e="_self";kf()?e="_top":(Tf()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Of(t,e){let s="";try{if(Jr()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function Za(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Qa(){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 ca(){return typeof _s<"u"&&af.IS_VITEST==="true"}function Tf(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function kf(){try{return window.self!==window.top}catch{return!1}}function $f(t,e=!1){const s=Ye.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function Cu(t){return Ye.from(t,"base64").toString("utf-8")}function xf(t){return new Promise(e=>setTimeout(e,t))}function _i(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Rf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Li(t,...e){if(!Rf(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 la(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_i(t.outputLen),_i(t.blockLen)}function Mr(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 Iu(t,e){Li(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const Yi=BigInt(2**32-1),ec=BigInt(32);function Uf(t,e=!1){return e?{h:Number(t&Yi),l:Number(t>>ec&Yi)}:{h:Number(t>>ec&Yi)|0,l:Number(t&Yi)|0}}function Df(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}=Uf(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Lf=(t,e,s)=>t<<s|e>>>32-s,Mf=(t,e,s)=>e<<s|t>>>32-s,Bf=(t,e,s)=>e<<s-32|t>>>64-s,jf=(t,e,s)=>t<<s-32|e>>>64-s,cr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function qf(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Xn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Vt(t,e){return t<<32-e|t>>>e}const tc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ff(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function sc(t){for(let e=0;e<t.length;e++)t[e]=Ff(t[e])}function Wf(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Br(t){return typeof t=="string"&&(t=Wf(t)),Li(t),t}function Hf(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Li(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 ua=class{clone(){return this._cloneInto()}};function Nu(t){const e=r=>t().update(Br(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Yr(t=32){if(cr&&typeof cr.getRandomValues=="function")return cr.getRandomValues(new Uint8Array(t));if(cr&&typeof cr.randomBytes=="function")return cr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const _u=[],Au=[],Su=[],zf=BigInt(0),ti=BigInt(1),Vf=BigInt(2),Kf=BigInt(7),Gf=BigInt(256),Jf=BigInt(113);for(let t=0,e=ti,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],_u.push(2*(5*r+s)),Au.push((t+1)*(t+2)/2%64);let i=zf;for(let n=0;n<7;n++)e=(e<<ti^(e>>Kf)*Jf)%Gf,e&Vf&&(i^=ti<<(ti<<BigInt(n))-ti);Su.push(i)}const[Yf,Xf]=Df(Su,!0),rc=(t,e,s)=>s>32?Bf(t,e,s):Lf(t,e,s),ic=(t,e,s)=>s>32?jf(t,e,s):Mf(t,e,s);function Zf(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=rc(l,u,1)^s[a],d=ic(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=Au[o],c=rc(i,n,a),l=ic(i,n,a),u=_u[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]^=Yf[r],t[1]^=Xf[r]}s.fill(0)}let Qf=class Pu extends ua{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,_i(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qf(this.state)}keccak(){tc||sc(this.state32),Zf(this.state32,this.rounds),tc||sc(this.state32),this.posOut=0,this.pos=0}update(e){Mr(this);const{blockLen:s,state:r}=this;e=Br(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&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Mr(this,!1),Li(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 _i(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Iu(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 Pu(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 eg=(t,e,s)=>Nu(()=>new Qf(e,t,s)),tg=eg(1,136,256/8),sg="https://rpc.walletconnect.org/v1";function Ou(t){const e=`Ethereum Signed Message:
|
|
5
|
+
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Ye.from(tg(s)).toString("hex")}async function rg(t,e,s,r,i,n){switch(s.t){case"eip191":return await ig(t,e,s.s);case"eip1271":return await ng(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function ig(t,e,s){return(await Jh({hash:Ou(e),signature:s})).toLowerCase()===t.toLowerCase()}async function ng(t,e,s,r,i,n){const o=xr(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=Ou(e).substring(2),d=a+h+c+l+u,f=await fetch(`${n||sg}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:og(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:m}=await f.json();return m?m.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function og(){return Date.now()+Math.floor(Math.random()*1e3)}function ag(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=Ye.from(t,"base64").slice(1,65);return mu.encode(n)}var cg=Object.defineProperty,lg=Object.defineProperties,ug=Object.getOwnPropertyDescriptors,nc=Object.getOwnPropertySymbols,hg=Object.prototype.hasOwnProperty,dg=Object.prototype.propertyIsEnumerable,oc=(t,e,s)=>e in t?cg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,pg=(t,e)=>{for(var s in e||(e={}))hg.call(e,s)&&oc(t,s,e[s]);if(nc)for(var s of nc(e))dg.call(e,s)&&oc(t,s,e[s]);return t},fg=(t,e)=>lg(t,ug(e));const gg="did:pkh:",ha=t=>t?.split(":"),mg=t=>{const e=t&&ha(t);if(e)return t.includes(gg)?e[3]:e[1]},To=t=>{const e=t&&ha(t);if(e)return e[2]+":"+e[3]},In=t=>{const e=t&&ha(t);if(e)return e.pop()};async function ac(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=Tu(i,i.iss),o=In(i.iss);return await rg(o,n,r,To(i.iss),s)}const Tu=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=In(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: ${mg(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(w=>`
|
|
6
|
+
- ${w}`).join("")}`:void 0,m=dn(t.resources);if(m){const w=Ai(m);i=_g(i,w)}return[s,r,"",i,"",n,o,a,c,l,u,h,d,f].filter(w=>w!=null).join(`
|
|
7
|
+
`)};function wg(t){return Ye.from(JSON.stringify(t)).toString("base64")}function yg(t){return JSON.parse(Ye.from(t,"base64").toString("utf-8"))}function Xs(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 vg(t,e,s,r={}){return s?.sort((i,n)=>i.localeCompare(n)),{att:{[t]:bg(e,s,r)}}}function bg(t,e,s={}){e=e?.sort((i,n)=>i.localeCompare(n));const r=e.map(i=>({[`${t}/${i}`]:[s]}));return Object.assign({},...r)}function ku(t){return Xs(t),`urn:recap:${wg(t).replace(/=/g,"")}`}function Ai(t){const e=yg(t.replace("urn:recap:",""));return Xs(e),e}function Eg(t,e,s){const r=vg(t,e,s);return ku(r)}function Cg(t){return t&&t.includes("urn:recap:")}function Ig(t,e){const s=Ai(t),r=Ai(e),i=Ng(s,r);return ku(i)}function Ng(t,e){Xs(t),Xs(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]=fg(pg({},r.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),r}function _g(t="",e){Xs(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 cc(t){var e;const s=Ai(t);Xs(s);const r=(e=s.att)==null?void 0:e.eip155;return r?Object.keys(r).map(i=>i.split("/")[1]):[]}function lc(t){const e=Ai(t);Xs(e);const s=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(i=>{var n;(n=i?.[0])!=null&&n.chains&&s.push(i[0].chains)})}),[...new Set(s.flat())]}function dn(t){if(!t)return;const e=t?.[t.length-1];return Cg(e)?e:void 0}function Zn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function $u(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function It(t,...e){if(!$u(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 uc(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 Ag(t,e){It(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function hc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ss=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Sg=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Pg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Pg)throw new Error("Non little-endian hardware is not supported");function Og(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ko(t){if(typeof t=="string")t=Og(t);else if($u(t))t=$o(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Tg(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function kg(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 $g=(t,e)=>{function s(r,...i){if(It(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?It(l):It(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&It(i[1]);const o=e(r,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");It(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,It(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(It(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 dc(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&&!xg(e))throw new Error("invalid output, must be aligned");return e}function pc(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 xg(t){return t.byteOffset%4===0}function $o(t){return Uint8Array.from(t)}function jr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const xu=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Rg=xu("expand 16-byte k"),Ug=xu("expand 32-byte k"),Dg=Ss(Rg),Lg=Ss(Ug);function le(t,e){return t<<e|t>>>32-e}function xo(t){return t.byteOffset%4===0}const Xi=64,Mg=16,Ru=2**32-1,fc=new Uint32Array;function Bg(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(Xi),u=Ss(l),h=xo(i)&&xo(n),d=h?Ss(i):fc,f=h?Ss(n):fc;for(let m=0;m<c;o++){if(t(e,s,r,u,o,a),o>=Ru)throw new Error("arx: counter overflow");const w=Math.min(Xi,c-m);if(h&&w===Xi){const g=m/4;if(m%4!==0)throw new Error("arx: invalid block position");for(let y=0,v;y<Mg;y++)v=g+y,f[v]=d[v]^u[y];m+=Xi;continue}for(let g=0,y;g<w;g++)y=m+g,n[y]=i[y]^l[g];m+=w}}function jg(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=Tg({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Zn(i),Zn(o),hc(n),hc(s),(a,c,l,u,h=0)=>{It(a),It(c),It(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),It(u),Zn(h),h<0||h>=Ru)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 m=a.length,w,g;if(m===32)f.push(w=$o(a)),g=Lg;else if(m===16&&s)w=new Uint8Array(32),w.set(a),w.set(a,16),g=Dg,f.push(w);else throw new Error(`arx: invalid 32-byte key, got length=${m}`);xo(c)||f.push(c=$o(c));const y=Ss(w);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(g,y,Ss(c.subarray(0,16)),y),c=c.subarray(16)}const v=16-i;if(v!==c.length)throw new Error(`arx: nonce must be ${v} or 16 bytes`);if(v!==12){const N=new Uint8Array(12);N.set(c,n?0:12-c.length),c=N,f.push(c)}const E=Ss(c);return Bg(t,g,y,E,l,u,h,o),jr(...f),u}}const Xe=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class qg{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=ko(e),It(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],m=o[7],w=o[8],g=o[9],y=Xe(e,s+0),v=Xe(e,s+2),E=Xe(e,s+4),N=Xe(e,s+6),$=Xe(e,s+8),O=Xe(e,s+10),S=Xe(e,s+12),D=Xe(e,s+14);let b=n[0]+(y&8191),x=n[1]+((y>>>13|v<<3)&8191),C=n[2]+((v>>>10|E<<6)&8191),L=n[3]+((E>>>7|N<<9)&8191),z=n[4]+((N>>>4|$<<12)&8191),I=n[5]+($>>>1&8191),T=n[6]+(($>>>14|O<<2)&8191),A=n[7]+((O>>>11|S<<5)&8191),B=n[8]+((S>>>8|D<<8)&8191),F=n[9]+(D>>>5|i),k=0,G=k+b*a+x*(5*g)+C*(5*w)+L*(5*m)+z*(5*f);k=G>>>13,G&=8191,G+=I*(5*d)+T*(5*h)+A*(5*u)+B*(5*l)+F*(5*c),k+=G>>>13,G&=8191;let ee=k+b*c+x*a+C*(5*g)+L*(5*w)+z*(5*m);k=ee>>>13,ee&=8191,ee+=I*(5*f)+T*(5*d)+A*(5*h)+B*(5*u)+F*(5*l),k+=ee>>>13,ee&=8191;let re=k+b*l+x*c+C*a+L*(5*g)+z*(5*w);k=re>>>13,re&=8191,re+=I*(5*m)+T*(5*f)+A*(5*d)+B*(5*h)+F*(5*u),k+=re>>>13,re&=8191;let Ne=k+b*u+x*l+C*c+L*a+z*(5*g);k=Ne>>>13,Ne&=8191,Ne+=I*(5*w)+T*(5*m)+A*(5*f)+B*(5*d)+F*(5*h),k+=Ne>>>13,Ne&=8191;let pe=k+b*h+x*u+C*l+L*c+z*a;k=pe>>>13,pe&=8191,pe+=I*(5*g)+T*(5*w)+A*(5*m)+B*(5*f)+F*(5*d),k+=pe>>>13,pe&=8191;let xe=k+b*d+x*h+C*u+L*l+z*c;k=xe>>>13,xe&=8191,xe+=I*a+T*(5*g)+A*(5*w)+B*(5*m)+F*(5*f),k+=xe>>>13,xe&=8191;let qe=k+b*f+x*d+C*h+L*u+z*l;k=qe>>>13,qe&=8191,qe+=I*c+T*a+A*(5*g)+B*(5*w)+F*(5*m),k+=qe>>>13,qe&=8191;let tt=k+b*m+x*f+C*d+L*h+z*u;k=tt>>>13,tt&=8191,tt+=I*l+T*c+A*a+B*(5*g)+F*(5*w),k+=tt>>>13,tt&=8191;let De=k+b*w+x*m+C*f+L*d+z*h;k=De>>>13,De&=8191,De+=I*u+T*l+A*c+B*a+F*(5*g),k+=De>>>13,De&=8191;let Le=k+b*g+x*w+C*m+L*f+z*d;k=Le>>>13,Le&=8191,Le+=I*h+T*u+A*l+B*c+F*a,k+=Le>>>13,Le&=8191,k=(k<<2)+k|0,k=k+G|0,G=k&8191,k=k>>>13,ee+=k,n[0]=G,n[1]=ee,n[2]=re,n[3]=Ne,n[4]=pe,n[5]=xe,n[6]=qe,n[7]=tt,n[8]=De,n[9]=Le}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;jr(r)}update(e){uc(this);const{buffer:s,blockLen:r}=this;e=ko(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(){jr(this.h,this.r,this.buffer,this.pad)}digestInto(e){uc(this),Ag(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 Fg(t){const e=(r,i)=>t(i).update(ko(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const Wg=Fg(t=>new qg(t));function Hg(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],m=e[4],w=e[5],g=e[6],y=e[7],v=i,E=s[0],N=s[1],$=s[2],O=o,S=a,D=c,b=l,x=u,C=h,L=d,z=f,I=m,T=w,A=g,B=y,F=v,k=E,G=N,ee=$;for(let Ne=0;Ne<n;Ne+=2)O=O+x|0,F=le(F^O,16),I=I+F|0,x=le(x^I,12),O=O+x|0,F=le(F^O,8),I=I+F|0,x=le(x^I,7),S=S+C|0,k=le(k^S,16),T=T+k|0,C=le(C^T,12),S=S+C|0,k=le(k^S,8),T=T+k|0,C=le(C^T,7),D=D+L|0,G=le(G^D,16),A=A+G|0,L=le(L^A,12),D=D+L|0,G=le(G^D,8),A=A+G|0,L=le(L^A,7),b=b+z|0,ee=le(ee^b,16),B=B+ee|0,z=le(z^B,12),b=b+z|0,ee=le(ee^b,8),B=B+ee|0,z=le(z^B,7),O=O+C|0,ee=le(ee^O,16),A=A+ee|0,C=le(C^A,12),O=O+C|0,ee=le(ee^O,8),A=A+ee|0,C=le(C^A,7),S=S+L|0,F=le(F^S,16),B=B+F|0,L=le(L^B,12),S=S+L|0,F=le(F^S,8),B=B+F|0,L=le(L^B,7),D=D+z|0,k=le(k^D,16),I=I+k|0,z=le(z^I,12),D=D+z|0,k=le(k^D,8),I=I+k|0,z=le(z^I,7),b=b+x|0,G=le(G^b,16),T=T+G|0,x=le(x^T,12),b=b+x|0,G=le(G^b,8),T=T+G|0,x=le(x^T,7);let re=0;r[re++]=o+O|0,r[re++]=a+S|0,r[re++]=c+D|0,r[re++]=l+b|0,r[re++]=u+x|0,r[re++]=h+C|0,r[re++]=d+L|0,r[re++]=f+z|0,r[re++]=m+I|0,r[re++]=w+T|0,r[re++]=g+A|0,r[re++]=y+B|0,r[re++]=v+F|0,r[re++]=E+k|0,r[re++]=N+G|0,r[re++]=$+ee|0}const zg=jg(Hg,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Vg=new Uint8Array(16),gc=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(Vg.subarray(s))},Kg=new Uint8Array(32);function mc(t,e,s,r,i){const n=t(e,s,Kg),o=Wg.create(n);i&&gc(o,i),gc(o,r);const a=new Uint8Array(16),c=Sg(a);pc(c,0,BigInt(i?i.length:0),!0),pc(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return jr(n,a),l}const Gg=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=dc(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=mc(t,e,s,a,r);return n.set(c,o),jr(c),n},decrypt(i,n){n=dc(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=mc(t,e,s,o,r);if(!kg(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),jr(c),n}}),Uu=$g({blockSize:64,nonceLength:12,tagLength:16},Gg(zg));let Du=class extends ua{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,la(e);const r=Br(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 Mr(this),this.iHash.update(e),this}digestInto(e){Mr(this),Li(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 Rn=(t,e,s)=>new Du(t,e).update(s).digest();Rn.create=(t,e)=>new Du(t,e);function Jg(t,e,s){return la(t),s===void 0&&(s=new Uint8Array(t.outputLen)),Rn(t,Br(s),Br(e))}const Qn=new Uint8Array([0]),wc=new Uint8Array;function Yg(t,e,s,r=32){if(la(t),_i(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);s===void 0&&(s=wc);const n=new Uint8Array(i*t.outputLen),o=Rn.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)Qn[0]=l+1,a.update(l===0?wc:c).update(s).update(Qn).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Qn.fill(0),n.slice(0,r)}const Xg=(t,e,s,r,i)=>Yg(t,Jg(t,e,s),r,i);function Zg(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 Qg(t,e,s){return t&e^~t&s}function em(t,e,s){return t&e^t&s^e&s}let tm=class extends ua{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=Xn(this.buffer)}update(e){Mr(this);const{view:s,buffer:r,blockLen:i}=this;e=Br(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=Xn(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){Mr(this),Iu(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;Zg(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=Xn(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 sm=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]),ws=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ys=new Uint32Array(64);class rm extends tm{constructor(){super(64,32,8,!1),this.A=ws[0]|0,this.B=ws[1]|0,this.C=ws[2]|0,this.D=ws[3]|0,this.E=ws[4]|0,this.F=ws[5]|0,this.G=ws[6]|0,this.H=ws[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)ys[h]=e.getUint32(s,!1);for(let h=16;h<64;h++){const d=ys[h-15],f=ys[h-2],m=Vt(d,7)^Vt(d,18)^d>>>3,w=Vt(f,17)^Vt(f,19)^f>>>10;ys[h]=w+ys[h-7]+m+ys[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=Vt(a,6)^Vt(a,11)^Vt(a,25),f=u+d+Qg(a,c,l)+sm[h]+ys[h]|0,m=(Vt(r,2)^Vt(r,13)^Vt(r,22))+em(r,i,n)|0;u=l,l=c,c=a,a=o+f|0,o=n,n=i,i=r,r=f+m|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(){ys.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Mi=Nu(()=>new rm);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Un=BigInt(0),Dn=BigInt(1),im=BigInt(2);function Zs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Bi(t){if(!Zs(t))throw new Error("Uint8Array expected")}function qr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const nm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Fr(t){Bi(t);let e="";for(let s=0;s<t.length;s++)e+=nm[t[s]];return e}function Pr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function da(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Un:BigInt("0x"+t)}const os={_0:48,_9:57,A:65,F:70,a:97,f:102};function yc(t){if(t>=os._0&&t<=os._9)return t-os._0;if(t>=os.A&&t<=os.F)return t-(os.A-10);if(t>=os.a&&t<=os.f)return t-(os.a-10)}function Wr(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=yc(t.charCodeAt(n)),a=yc(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 Gs(t){return da(Fr(t))}function Si(t){return Bi(t),da(Fr(Uint8Array.from(t).reverse()))}function Hr(t,e){return Wr(t.toString(16).padStart(e*2,"0"))}function Ln(t,e){return Hr(t,e).reverse()}function om(t){return Wr(Pr(t))}function Ct(t,e,s){let r;if(typeof e=="string")try{r=Wr(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(Zs(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 Pi(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Bi(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 am(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 cm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const eo=t=>typeof t=="bigint"&&Un<=t;function Mn(t,e,s){return eo(t)&&eo(e)&&eo(s)&&e<=t&&t<s}function hs(t,e,s,r){if(!Mn(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function Lu(t){let e;for(e=0;t>Un;t>>=Dn,e+=1);return e}function lm(t,e){return t>>BigInt(e)&Dn}function um(t,e,s){return t|(s?Dn:Un)<<BigInt(e)}const pa=t=>(im<<BigInt(t-1))-Dn,to=t=>new Uint8Array(t),vc=t=>Uint8Array.from(t);function Mu(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=to(t),i=to(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=to())=>{i=a(vc([0]),u),r=a(),u.length!==0&&(i=a(vc([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 Pi(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const hm={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"||Zs(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 Xr(t,e,s={}){const r=(i,n,o)=>{const a=hm[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 dm=()=>{throw new Error("not implemented")};function Ro(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 pm=Object.freeze({__proto__:null,isBytes:Zs,abytes:Bi,abool:qr,bytesToHex:Fr,numberToHexUnpadded:Pr,hexToNumber:da,hexToBytes:Wr,bytesToNumberBE:Gs,bytesToNumberLE:Si,numberToBytesBE:Hr,numberToBytesLE:Ln,numberToVarBytesBE:om,ensureBytes:Ct,concatBytes:Pi,equalBytes:am,utf8ToBytes:cm,inRange:Mn,aInRange:hs,bitLen:Lu,bitGet:lm,bitSet:um,bitMask:pa,createHmacDrbg:Mu,validateObject:Xr,notImplemented:dm,memoized:Ro});const Je=BigInt(0),$e=BigInt(1),Fs=BigInt(2),fm=BigInt(3),Uo=BigInt(4),bc=BigInt(5),Ec=BigInt(8);function mt(t,e){const s=t%e;return s>=Je?s:e+s}function Bu(t,e,s){if(e<Je)throw new Error("invalid exponent, negatives unsupported");if(s<=Je)throw new Error("invalid modulus");if(s===$e)return Je;let r=$e;for(;e>Je;)e&$e&&(r=r*t%s),t=t*t%s,e>>=$e;return r}function jt(t,e,s){let r=t;for(;e-- >Je;)r*=r,r%=s;return r}function Do(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=mt(t,e),r=e,i=Je,n=$e;for(;s!==Je;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==$e)throw new Error("invert: does not exist");return mt(i,e)}function gm(t){const e=(t-$e)/Fs;let s,r,i;for(s=t-$e,r=0;s%Fs===Je;s/=Fs,r++);for(i=Fs;i<t&&Bu(i,e,t)!==t-$e;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+$e)/Uo;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+$e)/Fs;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 m=o.sqr(h);d<c&&!o.eql(m,o.ONE);d++)m=o.sqr(m);const f=o.pow(l,$e<<BigInt(c-d-1));l=o.sqr(f),u=o.mul(u,f),h=o.mul(h,l),c=d}return u}}function mm(t){if(t%Uo===fm){const e=(t+$e)/Uo;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%Ec===bc){const e=(t-bc)/Ec;return function(s,r){const i=s.mul(r,Fs),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Fs),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 gm(t)}const wm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ym(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=wm.reduce((r,i)=>(r[i]="function",r),e);return Xr(t,s)}function vm(t,e,s){if(s<Je)throw new Error("invalid exponent, negatives unsupported");if(s===Je)return t.ONE;if(s===$e)return e;let r=t.ONE,i=e;for(;s>Je;)s&$e&&(r=t.mul(r,i)),i=t.sqr(i),s>>=$e;return r}function bm(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 ju(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function qu(t,e,s=!1,r={}){if(t<=Je)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=ju(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:pa(i),ZERO:Je,ONE:$e,create:c=>mt(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&$e)===$e,neg:c=>mt(-c,t),eql:(c,l)=>c===l,sqr:c=>mt(c*c,t),add:(c,l)=>mt(c+l,t),sub:(c,l)=>mt(c-l,t),mul:(c,l)=>mt(c*l,t),pow:(c,l)=>vm(a,c,l),div:(c,l)=>mt(c*Do(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Do(c,t),sqrt:r.sqrt||(c=>(o||(o=mm(t)),o(a,c))),invertBatch:c=>bm(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?Ln(c,n):Hr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?Si(c):Gs(c)}});return Object.freeze(a)}function Fu(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 Wu(t){const e=Fu(t);return e+Math.ceil(e/2)}function Em(t,e,s=!1){const r=t.length,i=Fu(e),n=Wu(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?Si(t):Gs(t),a=mt(o,e-$e)+$e;return s?Ln(a,i):Hr(a,i)}const Cc=BigInt(0),Zi=BigInt(1);function so(t,e){const s=e.negate();return t?s:e}function Hu(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function ro(t,e){Hu(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function Cm(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 Im(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 io=new WeakMap,zu=new WeakMap;function no(t){return zu.get(t)||1}function Nm(t,e){return{constTimeNegate:so,hasPrecomputes(s){return no(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>Cc;)r&Zi&&(i=i.add(n)),n=n.double(),r>>=Zi;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=ro(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}=ro(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 m=Number(i&l);i>>=h,m>o&&(m-=u,i+=Zi);const w=f,g=f+Math.abs(m)-1,y=d%2!==0,v=m<0;m===0?c=c.add(so(y,r[w])):a=a.add(so(v,r[g]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=ro(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===Cc)break;let f=Number(i&c);if(i>>=u,f>a&&(f-=l,i+=Zi),f===0)continue;let m=r[d+Math.abs(f)-1];f<0&&(m=m.negate()),n=n.add(m)}return n},getPrecomputes(s,r,i){let n=io.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&io.set(r,i(n))),n},wNAFCached(s,r,i){const n=no(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=no(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){Hu(r,e),zu.set(s,r),io.delete(s)}}}function _m(t,e,s,r){if(Cm(s,t),Im(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=Lu(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 m=r[f],w=Number(m>>BigInt(h)&BigInt(a));c[w]=c[w].add(s[f])}let d=i;for(let f=c.length-1,m=i;f>0;f--)m=m.add(c[f]),d=d.add(m);if(u=u.add(d),h!==0)for(let f=0;f<o;f++)u=u.double()}return u}function Vu(t){return ym(t.Fp),Xr(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ju(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const lr=BigInt(0),oo=BigInt(1);function Am(t){return Xr(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Sm(t){const e=Am(t),{P:s}=e,r=v=>mt(v,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(v=>v),c=e.powPminus2||(v=>Bu(v,s-BigInt(2),s));function l(v,E,N){const $=r(v*(E-N));return E=r(E-$),N=r(N+$),[E,N]}const u=(e.a-BigInt(2))/BigInt(4);function h(v,E){hs("u",v,lr,s),hs("scalar",E,lr,s);const N=E,$=v;let O=oo,S=lr,D=v,b=oo,x=lr,C;for(let z=BigInt(i-1);z>=lr;z--){const I=N>>z&oo;x^=I,C=l(x,O,D),O=C[0],D=C[1],C=l(x,S,b),S=C[0],b=C[1],x=I;const T=O+S,A=r(T*T),B=O-S,F=r(B*B),k=A-F,G=D+b,ee=D-b,re=r(ee*T),Ne=r(G*B),pe=re+Ne,xe=re-Ne;D=r(pe*pe),b=r($*r(xe*xe)),O=r(A*F),S=r(k*(A+r(u*k)))}C=l(x,O,D),O=C[0],D=C[1],C=l(x,S,b),S=C[0],b=C[1];const L=c(S);return r(O*L)}function d(v){return Ln(r(v),n)}function f(v){const E=Ct("u coordinate",v,n);return o===32&&(E[31]&=127),Si(E)}function m(v){const E=Ct("scalar",v),N=E.length;if(N!==n&&N!==o){let $=""+n+" or "+o;throw new Error("invalid scalar, expected "+$+" bytes, got "+N)}return Si(a(E))}function w(v,E){const N=f(E),$=m(v),O=h(N,$);if(O===lr)throw new Error("invalid private or public key received");return d(O)}const g=d(e.Gu);function y(v){return w(v,g)}return{scalarMult:w,scalarMultBase:y,getSharedSecret:(v,E)=>w(v,E),getPublicKey:v=>y(v),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:g}}const Lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Pm=BigInt(1),Ic=BigInt(2),Om=BigInt(3),Tm=BigInt(5);BigInt(8);function km(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=Lo,o=t*t%n*t%n,a=jt(o,Ic,n)*o%n,c=jt(a,Pm,n)*t%n,l=jt(c,Tm,n)*c%n,u=jt(l,e,n)*l%n,h=jt(u,s,n)*u%n,d=jt(h,r,n)*h%n,f=jt(d,i,n)*d%n,m=jt(f,i,n)*d%n,w=jt(m,e,n)*l%n;return{pow_p_5_8:jt(w,Ic,n)*t%n,b2:o}}function $m(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Mo=Sm({P:Lo,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Lo,{pow_p_5_8:s,b2:r}=km(t);return mt(jt(s,Om,e)*r,e)},adjustScalarBytes:$m,randomBytes:Yr});function Nc(t){t.lowS!==void 0&&qr("lowS",t.lowS),t.prehash!==void 0&&qr("prehash",t.prehash)}function xm(t){const e=Vu(t);Xr(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:Rm,hexToBytes:Um}=pm;class Dm extends Error{constructor(e=""){super(e)}}const ls={Err:Dm,_tlv:{encode:(t,e)=>{const{Err:s}=ls;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=Pr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Pr(i.length/2|128):"";return Pr(t)+n+i+e},decode(t,e){const{Err:s}=ls;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}=ls;if(t<us)throw new e("integer: negative integers are not allowed");let s=Pr(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}=ls;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 Rm(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=ls,i=typeof t=="string"?Um(t):t;Bi(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}=ls,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},us=BigInt(0),ze=BigInt(1);BigInt(2);const _c=BigInt(3);BigInt(4);function Lm(t){const e=xm(t),{Fp:s}=e,r=qu(e.n,e.nBitLength),i=e.toBytes||((w,g,y)=>{const v=g.toAffine();return Pi(Uint8Array.from([4]),s.toBytes(v.x),s.toBytes(v.y))}),n=e.fromBytes||(w=>{const g=w.subarray(1),y=s.fromBytes(g.subarray(0,s.BYTES)),v=s.fromBytes(g.subarray(s.BYTES,2*s.BYTES));return{x:y,y:v}});function o(w){const{a:g,b:y}=e,v=s.sqr(w),E=s.mul(v,w);return s.add(s.add(E,s.mul(w,g)),y)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return Mn(w,ze,e.n)}function c(w){const{allowedPrivateKeyLengths:g,nByteLength:y,wrapPrivateKey:v,n:E}=e;if(g&&typeof w!="bigint"){if(Zs(w)&&(w=Fr(w)),typeof w!="string"||!g.includes(w.length))throw new Error("invalid private key");w=w.padStart(y*2,"0")}let N;try{N=typeof w=="bigint"?w:Gs(Ct("private key",w,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof w)}return v&&(N=mt(N,E)),hs("private key",N,ze,E),N}function l(w){if(!(w instanceof d))throw new Error("ProjectivePoint expected")}const u=Ro((w,g)=>{const{px:y,py:v,pz:E}=w;if(s.eql(E,s.ONE))return{x:y,y:v};const N=w.is0();g==null&&(g=N?s.ONE:s.inv(E));const $=s.mul(y,g),O=s.mul(v,g),S=s.mul(E,g);if(N)return{x:s.ZERO,y:s.ZERO};if(!s.eql(S,s.ONE))throw new Error("invZ was invalid");return{x:$,y:O}}),h=Ro(w=>{if(w.is0()){if(e.allowInfinityPoint&&!s.is0(w.py))return;throw new Error("bad point: ZERO")}const{x:g,y}=w.toAffine();if(!s.isValid(g)||!s.isValid(y))throw new Error("bad point: x or y not FE");const v=s.sqr(y),E=o(g);if(!s.eql(v,E))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(g,y,v){if(this.px=g,this.py=y,this.pz=v,g==null||!s.isValid(g))throw new Error("x required");if(y==null||!s.isValid(y))throw new Error("y required");if(v==null||!s.isValid(v))throw new Error("z required");Object.freeze(this)}static fromAffine(g){const{x:y,y:v}=g||{};if(!g||!s.isValid(y)||!s.isValid(v))throw new Error("invalid affine point");if(g instanceof d)throw new Error("projective point not allowed");const E=N=>s.eql(N,s.ZERO);return E(y)&&E(v)?d.ZERO:new d(y,v,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const y=s.invertBatch(g.map(v=>v.pz));return g.map((v,E)=>v.toAffine(y[E])).map(d.fromAffine)}static fromHex(g){const y=d.fromAffine(n(Ct("pointHex",g)));return y.assertValidity(),y}static fromPrivateKey(g){return d.BASE.multiply(c(g))}static msm(g,y){return _m(d,r,g,y)}_setWindowSize(g){m.setWindowSize(this,g)}assertValidity(){h(this)}hasEvenY(){const{y:g}=this.toAffine();if(s.isOdd)return!s.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){l(g);const{px:y,py:v,pz:E}=this,{px:N,py:$,pz:O}=g,S=s.eql(s.mul(y,O),s.mul(N,E)),D=s.eql(s.mul(v,O),s.mul($,E));return S&&D}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:g,b:y}=e,v=s.mul(y,_c),{px:E,py:N,pz:$}=this;let O=s.ZERO,S=s.ZERO,D=s.ZERO,b=s.mul(E,E),x=s.mul(N,N),C=s.mul($,$),L=s.mul(E,N);return L=s.add(L,L),D=s.mul(E,$),D=s.add(D,D),O=s.mul(g,D),S=s.mul(v,C),S=s.add(O,S),O=s.sub(x,S),S=s.add(x,S),S=s.mul(O,S),O=s.mul(L,O),D=s.mul(v,D),C=s.mul(g,C),L=s.sub(b,C),L=s.mul(g,L),L=s.add(L,D),D=s.add(b,b),b=s.add(D,b),b=s.add(b,C),b=s.mul(b,L),S=s.add(S,b),C=s.mul(N,$),C=s.add(C,C),b=s.mul(C,L),O=s.sub(O,b),D=s.mul(C,x),D=s.add(D,D),D=s.add(D,D),new d(O,S,D)}add(g){l(g);const{px:y,py:v,pz:E}=this,{px:N,py:$,pz:O}=g;let S=s.ZERO,D=s.ZERO,b=s.ZERO;const x=e.a,C=s.mul(e.b,_c);let L=s.mul(y,N),z=s.mul(v,$),I=s.mul(E,O),T=s.add(y,v),A=s.add(N,$);T=s.mul(T,A),A=s.add(L,z),T=s.sub(T,A),A=s.add(y,E);let B=s.add(N,O);return A=s.mul(A,B),B=s.add(L,I),A=s.sub(A,B),B=s.add(v,E),S=s.add($,O),B=s.mul(B,S),S=s.add(z,I),B=s.sub(B,S),b=s.mul(x,A),S=s.mul(C,I),b=s.add(S,b),S=s.sub(z,b),b=s.add(z,b),D=s.mul(S,b),z=s.add(L,L),z=s.add(z,L),I=s.mul(x,I),A=s.mul(C,A),z=s.add(z,I),I=s.sub(L,I),I=s.mul(x,I),A=s.add(A,I),L=s.mul(z,A),D=s.add(D,L),L=s.mul(B,A),S=s.mul(T,S),S=s.sub(S,L),L=s.mul(T,z),b=s.mul(B,b),b=s.add(b,L),new d(S,D,b)}subtract(g){return this.add(g.negate())}is0(){return this.equals(d.ZERO)}wNAF(g){return m.wNAFCached(this,g,d.normalizeZ)}multiplyUnsafe(g){const{endo:y,n:v}=e;hs("scalar",g,us,v);const E=d.ZERO;if(g===us)return E;if(this.is0()||g===ze)return this;if(!y||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,g,d.normalizeZ);let{k1neg:N,k1:$,k2neg:O,k2:S}=y.splitScalar(g),D=E,b=E,x=this;for(;$>us||S>us;)$&ze&&(D=D.add(x)),S&ze&&(b=b.add(x)),x=x.double(),$>>=ze,S>>=ze;return N&&(D=D.negate()),O&&(b=b.negate()),b=new d(s.mul(b.px,y.beta),b.py,b.pz),D.add(b)}multiply(g){const{endo:y,n:v}=e;hs("scalar",g,ze,v);let E,N;if(y){const{k1neg:$,k1:O,k2neg:S,k2:D}=y.splitScalar(g);let{p:b,f:x}=this.wNAF(O),{p:C,f:L}=this.wNAF(D);b=m.constTimeNegate($,b),C=m.constTimeNegate(S,C),C=new d(s.mul(C.px,y.beta),C.py,C.pz),E=b.add(C),N=x.add(L)}else{const{p:$,f:O}=this.wNAF(g);E=$,N=O}return d.normalizeZ([E,N])[0]}multiplyAndAddUnsafe(g,y,v){const E=d.BASE,N=(O,S)=>S===us||S===ze||!O.equals(E)?O.multiplyUnsafe(S):O.multiply(S),$=N(this,y).add(N(g,v));return $.is0()?void 0:$}toAffine(g){return u(this,g)}isTorsionFree(){const{h:g,isTorsionFree:y}=e;if(g===ze)return!0;if(y)return y(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:y}=e;return g===ze?this:y?y(d,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return qr("isCompressed",g),this.assertValidity(),i(d,this,g)}toHex(g=!0){return qr("isCompressed",g),Fr(this.toRawBytes(g))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const f=e.nBitLength,m=Nm(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Mm(t){const e=Vu(t);return Xr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Bm(t){const e=Mm(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(I){return mt(I,r)}function a(I){return Do(I,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=Lm({...e,toBytes(I,T,A){const B=T.toAffine(),F=s.toBytes(B.x),k=Pi;return qr("isCompressed",A),A?k(Uint8Array.from([T.hasEvenY()?2:3]),F):k(Uint8Array.from([4]),F,s.toBytes(B.y))},fromBytes(I){const T=I.length,A=I[0],B=I.subarray(1);if(T===i&&(A===2||A===3)){const F=Gs(B);if(!Mn(F,ze,s.ORDER))throw new Error("Point is not on curve");const k=u(F);let G;try{G=s.sqrt(k)}catch(re){const Ne=re instanceof Error?": "+re.message:"";throw new Error("Point is not on curve"+Ne)}const ee=(G&ze)===ze;return(A&1)===1!==ee&&(G=s.neg(G)),{x:F,y:G}}else if(T===n&&A===4){const F=s.fromBytes(B.subarray(0,s.BYTES)),k=s.fromBytes(B.subarray(s.BYTES,2*s.BYTES));return{x:F,y:k}}else{const F=i,k=n;throw new Error("invalid Point, expected length of "+F+", or uncompressed "+k+", got "+T)}}}),d=I=>Fr(Hr(I,e.nByteLength));function f(I){const T=r>>ze;return I>T}function m(I){return f(I)?o(-I):I}const w=(I,T,A)=>Gs(I.slice(T,A));class g{constructor(T,A,B){this.r=T,this.s=A,this.recovery=B,this.assertValidity()}static fromCompact(T){const A=e.nByteLength;return T=Ct("compactSignature",T,A*2),new g(w(T,0,A),w(T,A,2*A))}static fromDER(T){const{r:A,s:B}=ls.toSig(Ct("DER",T));return new g(A,B)}assertValidity(){hs("r",this.r,ze,r),hs("s",this.s,ze,r)}addRecoveryBit(T){return new g(this.r,this.s,T)}recoverPublicKey(T){const{r:A,s:B,recovery:F}=this,k=O(Ct("msgHash",T));if(F==null||![0,1,2,3].includes(F))throw new Error("recovery id invalid");const G=F===2||F===3?A+e.n:A;if(G>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const ee=F&1?"03":"02",re=c.fromHex(ee+d(G)),Ne=a(G),pe=o(-k*Ne),xe=o(B*Ne),qe=c.BASE.multiplyAndAddUnsafe(re,pe,xe);if(!qe)throw new Error("point at infinify");return qe.assertValidity(),qe}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Wr(this.toDERHex())}toDERHex(){return ls.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const y={isValidPrivateKey(I){try{return l(I),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const I=Wu(e.n);return Em(e.randomBytes(I),e.n)},precompute(I=8,T=c.BASE){return T._setWindowSize(I),T.multiply(BigInt(3)),T}};function v(I,T=!0){return c.fromPrivateKey(I).toRawBytes(T)}function E(I){const T=Zs(I),A=typeof I=="string",B=(T||A)&&I.length;return T?B===i||B===n:A?B===2*i||B===2*n:I instanceof c}function N(I,T,A=!0){if(E(I))throw new Error("first arg must be private key");if(!E(T))throw new Error("second arg must be public key");return c.fromHex(T).multiply(l(I)).toRawBytes(A)}const $=e.bits2int||function(I){if(I.length>8192)throw new Error("input is too large");const T=Gs(I),A=I.length*8-e.nBitLength;return A>0?T>>BigInt(A):T},O=e.bits2int_modN||function(I){return o($(I))},S=pa(e.nBitLength);function D(I){return hs("num < 2^"+e.nBitLength,I,us,S),Hr(I,e.nByteLength)}function b(I,T,A=x){if(["recovered","canonical"].some(De=>De in A))throw new Error("sign() legacy options not supported");const{hash:B,randomBytes:F}=e;let{lowS:k,prehash:G,extraEntropy:ee}=A;k==null&&(k=!0),I=Ct("msgHash",I),Nc(A),G&&(I=Ct("prehashed msgHash",B(I)));const re=O(I),Ne=l(T),pe=[D(Ne),D(re)];if(ee!=null&&ee!==!1){const De=ee===!0?F(s.BYTES):ee;pe.push(Ct("extraEntropy",De))}const xe=Pi(...pe),qe=re;function tt(De){const Le=$(De);if(!h(Le))return;const Rs=a(Le),ss=c.BASE.multiply(Le).toAffine(),zt=o(ss.x);if(zt===us)return;const rs=o(Rs*o(qe+zt*Ne));if(rs===us)return;let or=(ss.x===zt?0:2)|Number(ss.y&ze),zi=rs;return k&&f(rs)&&(zi=m(rs),or^=1),new g(zt,zi,or)}return{seed:xe,k2sig:tt}}const x={lowS:e.lowS,prehash:!1},C={lowS:e.lowS,prehash:!1};function L(I,T,A=x){const{seed:B,k2sig:F}=b(I,T,A),k=e;return Mu(k.hash.outputLen,k.nByteLength,k.hmac)(B,F)}c.BASE._setWindowSize(8);function z(I,T,A,B=C){const F=I;T=Ct("msgHash",T),A=Ct("publicKey",A);const{lowS:k,prehash:G,format:ee}=B;if(Nc(B),"strict"in B)throw new Error("options.strict was renamed to lowS");if(ee!==void 0&&ee!=="compact"&&ee!=="der")throw new Error("format must be compact or der");const re=typeof F=="string"||Zs(F),Ne=!re&&!ee&&typeof F=="object"&&F!==null&&typeof F.r=="bigint"&&typeof F.s=="bigint";if(!re&&!Ne)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let pe,xe;try{if(Ne&&(pe=new g(F.r,F.s)),re){try{ee!=="compact"&&(pe=g.fromDER(F))}catch(rs){if(!(rs instanceof ls.Err))throw rs}!pe&&ee!=="der"&&(pe=g.fromCompact(F))}xe=c.fromHex(A)}catch{return!1}if(!pe||k&&pe.hasHighS())return!1;G&&(T=e.hash(T));const{r:qe,s:tt}=pe,De=O(T),Le=a(tt),Rs=o(De*Le),ss=o(qe*Le),zt=c.BASE.multiplyAndAddUnsafe(xe,Rs,ss)?.toAffine();return zt?o(zt.x)===qe:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:N,sign:L,verify:z,ProjectivePoint:c,Signature:g,utils:y}}function jm(t){return{hash:t,hmac:(e,...s)=>Rn(t,e,Hf(...s)),randomBytes:Yr}}function qm(t,e){const s=r=>Bm({...t,...jm(r)});return{...s(e),create:s}}const Ku=qu(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Fm=Ku.create(BigInt("-3")),Wm=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Hm=qm({a:Fm,b:Wm,Fp:Ku,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Mi),Gu="base10",at="base16",Wt="base64pad",Es="base64url",ji="utf8",Ju=0,ds=1,qi=2,zm=0,Ac=1,vi=12,fa=32;function Vm(){const t=Mo.utils.randomPrivateKey(),e=Mo.getPublicKey(t);return{privateKey:wt(t,at),publicKey:wt(e,at)}}function Bo(){const t=Yr(fa);return wt(t,at)}function Km(t,e){const s=Mo.getSharedSecret(Rt(t,at),Rt(e,at)),r=Xg(Mi,s,void 0,void 0,fa);return wt(r,at)}function pn(t){const e=Mi(Rt(t,at));return wt(e,at)}function Zt(t){const e=Mi(Rt(t,ji));return wt(e,at)}function Yu(t){return Rt(`${t}`,Gu)}function Qs(t){return Number(wt(t,Gu))}function Xu(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Zu(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function Gm(t){const e=Yu(typeof t.type<"u"?t.type:Ju);if(Qs(e)===ds&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?Rt(t.senderPublicKey,at):void 0,r=typeof t.iv<"u"?Rt(t.iv,at):Yr(vi),i=Rt(t.symKey,at),n=Uu(i,r).encrypt(Rt(t.message,ji)),o=Qu({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===Es?Xu(o):o}function Jm(t){const e=Rt(t.symKey,at),{sealed:s,iv:r}=Oi({encoded:t.encoded,encoding:t.encoding}),i=Uu(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return wt(i,ji)}function Ym(t,e){const s=Yu(qi),r=Yr(vi),i=Rt(t,ji),n=Qu({type:s,sealed:i,iv:r});return e===Es?Xu(n):n}function Xm(t,e){const{sealed:s}=Oi({encoded:t,encoding:e});return wt(s,ji)}function Qu(t){if(Qs(t.type)===qi)return wt(fi([t.type,t.sealed]),Wt);if(Qs(t.type)===ds){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return wt(fi([t.type,t.senderPublicKey,t.iv,t.sealed]),Wt)}return wt(fi([t.type,t.iv,t.sealed]),Wt)}function Oi(t){const e=(t.encoding||Wt)===Es?Zu(t.encoded):t.encoded,s=Rt(e,Wt),r=s.slice(zm,Ac),i=Ac;if(Qs(r)===ds){const c=i+fa,l=c+vi,u=s.slice(i,c),h=s.slice(c,l),d=s.slice(l);return{type:r,sealed:d,iv:h,senderPublicKey:u}}if(Qs(r)===qi){const c=s.slice(i),l=Yr(vi);return{type:r,sealed:c,iv:l}}const n=i+vi,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function Zm(t,e){const s=Oi({encoded:t,encoding:e?.encoding});return eh({type:Qs(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?wt(s.senderPublicKey,at):void 0,receiverPublicKey:e?.receiverPublicKey})}function eh(t){const e=t?.type||Ju;if(e===ds){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Sc(t){return t.type===ds&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Pc(t){return t.type===qi}function Qm(t){const e=Ye.from(t.x,"base64"),s=Ye.from(t.y,"base64");return fi([new Uint8Array([4]),e,s])}function ew(t,e){const[s,r,i]=t.split("."),n=Ye.from(Zu(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=Mi(c),u=Qm(e);if(!Hm.verify(fi([o,a]),l,u))throw new Error("Invalid signature");return Co(t).payload}const tw="irn";function Nn(t){return t?.relay||{protocol:tw}}function hi(t){const e=Zh[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function sw(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 Oc(t){if(!t.includes("wc:")){const l=Cu(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:rw(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:sw(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function rw(t){return t.startsWith("//")?t.substring(2):t}function iw(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 Tc(t){const e=new URLSearchParams,s=iw(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}`}function Qi(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var nw=Object.defineProperty,ow=Object.defineProperties,aw=Object.getOwnPropertyDescriptors,kc=Object.getOwnPropertySymbols,cw=Object.prototype.hasOwnProperty,lw=Object.prototype.propertyIsEnumerable,$c=(t,e,s)=>e in t?nw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,uw=(t,e)=>{for(var s in e||(e={}))cw.call(e,s)&&$c(t,s,e[s]);if(kc)for(var s of kc(e))lw.call(e,s)&&$c(t,s,e[s]);return t},hw=(t,e)=>ow(t,aw(e));function Zr(t){const e=[];return t.forEach(s=>{const[r,i]=s.split(":");e.push(`${r}:${i}`)}),e}function dw(t){const e=[];return Object.values(t).forEach(s=>{e.push(...Zr(s.accounts))}),e}function pw(t,e){const s=[];return Object.values(t).forEach(r=>{Zr(r.accounts).includes(e)&&s.push(...r.methods)}),s}function fw(t,e){const s=[];return Object.values(t).forEach(r=>{Zr(r.accounts).includes(e)&&s.push(...r.events)}),s}function Bn(t){return t.includes(":")}function Or(t){return Bn(t)?t.split(":")[0]:t}function xc(t){var e,s,r;const i={};if(!Os(t))return i;for(const[n,o]of Object.entries(t)){const a=Bn(n)?[n]:o.chains,c=o.methods||[],l=o.events||[],u=Or(n);i[u]=hw(uw({},i[u]),{chains:es(a,(e=i[u])==null?void 0:e.chains),methods:es(c,(s=i[u])==null?void 0:s.methods),events:es(l,(r=i[u])==null?void 0:r.events)})}return i}function gw(t){const e={};return 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 Rc(t,e){e=e.map(r=>r.replace("did:pkh:",""));const s=gw(e);for(const[r,i]of Object.entries(s))i.methods?i.methods=es(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return s}function mw(t,e){var s,r,i,n,o,a;const c=xc(t),l=xc(e),u={},h=Object.keys(c).concat(Object.keys(l));for(const d of h)u[d]={chains:es((s=c[d])==null?void 0:s.chains,(r=l[d])==null?void 0:r.chains),methods:es((i=c[d])==null?void 0:i.methods,(n=l[d])==null?void 0:n.methods),events:es((o=c[d])==null?void 0:o.events,(a=l[d])==null?void 0:a.events)};return u}const ww={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}},yw={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 R(t,e){const{message:s,code:r}=yw[t];return{message:e?`${s} ${e}`:s,code:r}}function ye(t,e){const{message:s,code:r}=ww[t];return{message:e?`${s} ${e}`:s,code:r}}function Ps(t,e){return!!Array.isArray(t)}function Os(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function rt(t){return typeof t>"u"}function Ue(t,e){return e&&rt(t)?!0:typeof t=="string"&&!!t.trim().length}function ga(t,e){return typeof t=="number"&&!isNaN(t)}function vw(t,e){const{requiredNamespaces:s}=e,r=Object.keys(t.namespaces),i=Object.keys(s);let n=!0;return Vs(i,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=Zr(a),h=s[o];(!Vs(wu(o,h),u)||!Vs(h.methods,c)||!Vs(h.events,l))&&(n=!1)}),n):!1}function _n(t){return Ue(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function bw(t){if(Ue(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&_n(s)}}return!1}function Ew(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(Ue(t,!1)){if(e(t))return!0;const s=Cu(t);return e(s)}}catch{}return!1}function Cw(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Iw(t){return t?.topic}function Nw(t,e){let s=null;return Ue(t?.publicKey,!1)||(s=R("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function Uc(t){let e=!0;return Ps(t)?t.length&&(e=t.every(s=>Ue(s,!1))):e=!1,e}function _w(t,e,s){let r=null;return Ps(e)&&e.length?e.forEach(i=>{r||_n(i)||(r=ye("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):_n(t)||(r=ye("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 Aw(t,e,s){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const o=_w(i,wu(i,n),`${e} ${s}`);o&&(r=o)}),r}function Sw(t,e){let s=null;return Ps(t)?t.forEach(r=>{s||bw(r)||(s=ye("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):s=ye("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function Pw(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=Sw(r?.accounts,`${e} namespace`);i&&(s=i)}),s}function Ow(t,e){let s=null;return Uc(t?.methods)?Uc(t?.events)||(s=ye("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=ye("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function th(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=Ow(r,`${e}, namespace`);i&&(s=i)}),s}function Tw(t,e,s){let r=null;if(t&&Os(t)){const i=th(t,e);i&&(r=i);const n=Aw(t,e,s);n&&(r=n)}else r=R("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return r}function ao(t,e){let s=null;if(t&&Os(t)){const r=th(t,e);r&&(s=r);const i=Pw(t,e);i&&(s=i)}else s=R("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function sh(t){return Ue(t.protocol,!0)}function kw(t,e){let s=!1;return t?t&&Ps(t)&&t.length&&t.forEach(r=>{s=sh(r)}):s=!0,s}function $w(t){return typeof t=="number"}function gt(t){return typeof t<"u"&&typeof t!==null}function xw(t){return!(!t||typeof t!="object"||!t.code||!ga(t.code)||!t.message||!Ue(t.message,!1))}function Rw(t){return!(rt(t)||!Ue(t.method,!1))}function Uw(t){return!(rt(t)||rt(t.result)&&rt(t.error)||!ga(t.id)||!Ue(t.jsonrpc,!1))}function Dw(t){return!(rt(t)||!Ue(t.name,!1))}function Dc(t,e){return!(!_n(e)||!dw(t).includes(e))}function Lw(t,e,s){return Ue(s,!1)?pw(t,e).includes(s):!1}function Mw(t,e,s){return Ue(s,!1)?fw(t,e).includes(s):!1}function Lc(t,e,s){let r=null;const i=Bw(t),n=jw(e),o=Object.keys(i),a=Object.keys(n),c=Mc(Object.keys(t)),l=Mc(Object.keys(e)),u=c.filter(h=>!l.includes(h));return u.length&&(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.
|
|
8
|
+
Required: ${u.toString()}
|
|
9
|
+
Received: ${Object.keys(e).toString()}`)),Vs(o,a)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.
|
|
10
|
+
Required: ${o.toString()}
|
|
11
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||r)return;const d=Zr(e[h].accounts);d.includes(h)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
12
|
+
Required: ${h}
|
|
13
|
+
Approved: ${d.toString()}`))}),o.forEach(h=>{r||(Vs(i[h].methods,n[h].methods)?Vs(i[h].events,n[h].events)||(r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${h}`)):r=R("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${h}`))}),r}function Bw(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 Mc(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function jw(t){const e={};return Object.keys(t).forEach(s=>{s.includes(":")?e[s]=t[s]:Zr(t[s].accounts)?.forEach(i=>{e[i]={accounts:t[s].accounts.filter(n=>n.includes(`${i}:`)),methods:t[s].methods,events:t[s].events}})}),e}function qw(t,e){return ga(t)&&t<=e.max&&t>=e.min}function Bc(){const t=Di();return new Promise(e=>{switch(t){case Nt.browser:e(Fw());break;case Nt.reactNative:e(Ww());break;case Nt.node:e(Hw());break;default:e(!0)}})}function Fw(){return Jr()&&navigator?.onLine}async function Ww(){return xs()&&typeof Q<"u"&&Q!=null&&Q.NetInfo?(await(Q==null?void 0:Q.NetInfo.fetch()))?.isConnected:!0}function Hw(){return!0}function zw(t){switch(Di()){case Nt.browser:Vw(t);break;case Nt.reactNative:Kw(t);break}}function Vw(t){!xs()&&Jr()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function Kw(t){xs()&&typeof Q<"u"&&Q!=null&&Q.NetInfo&&Q?.NetInfo.addEventListener(e=>t(e?.isConnected))}function Gw(){var t;return Jr()&&Dr()?((t=Dr())==null?void 0:t.visibilityState)==="visible":!0}const co={};class si{static get(e){return co[e]}static set(e,s){co[e]=s}static delete(e){delete co[e]}}var Jw={};const rh="wc",ih=2,An="core",ts=`${rh}@2:${An}:`,Yw={name:An,logger:"error"},Xw={database:":memory:"},Zw="crypto",jc="client_ed25519_seed",Qw=U.ONE_DAY,ey="keychain",ty="0.3",sy="messages",ry="0.3",qc=U.SIX_HOURS,iy="publisher",nh="irn",ny="error",oh="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",Tt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},cy=.1,jo="2.21.0",Pe={link_mode:"link_mode",relay:"relay"},fn={inbound:"inbound",outbound:"outbound"},ly="0.3",uy="WALLETCONNECT_CLIENT_ID",Fc="WALLETCONNECT_LINK_MODE_APPS",bt={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",ri={wc_pairingDelete:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:U.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:U.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:U.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:U.ONE_DAY,prompt:!1,tag:0},res:{ttl:U.ONE_DAY,prompt:!1,tag:0}}},Ws={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Lt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},gy="history",my="0.3",wy="expirer",xt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},yy="0.3",vy="verify-api",by="https://verify.walletconnect.com",ah="https://verify.walletconnect.org",bi=ah,Ey=`${bi}/v3`,Cy=[by,ah],Iy="echo",Ny="https://echo.walletconnect.com",Jt={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"},cs={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"},Mt={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"},Ds={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"},Ls={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",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",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ii={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",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"},_y=.1,Ay="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(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var w=0,g=0,y=0,v=m.length;y!==v&&m[y]===0;)y++,w++;for(var E=(v-y)*u+1>>>0,N=new Uint8Array(E);y!==v;){for(var $=m[y],O=0,S=E-1;($!==0||O<g)&&S!==-1;S--,O++)$+=256*N[S]>>>0,N[S]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");g=O,y++}for(var D=E-g;D!==E&&N[D]===0;)D++;for(var b=c.repeat(w);D<E;++D)b+=t.charAt(N[D]);return b}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var w=0;if(m[w]!==" "){for(var g=0,y=0;m[w]===c;)g++,w++;for(var v=(m.length-w)*l+1>>>0,E=new Uint8Array(v);m[w];){var N=s[m.charCodeAt(w)];if(N===255)return;for(var $=0,O=v-1;(N!==0||$<y)&&O!==-1;O--,$++)N+=a*E[O]>>>0,E[O]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");y=$,w++}if(m[w]!==" "){for(var S=v-y;S!==v&&E[S]===0;)S++;for(var D=new Uint8Array(g+(v-S)),b=g;S!==v;)D[b++]=E[S++];return D}}}function f(m){var w=d(m);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:f}}var Ty=Oy,ky=Ty;const ch=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")},$y=t=>new TextEncoder().encode(t),xy=t=>new TextDecoder().decode(t);class Ry{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")}}class Uy{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 lh(this,e)}}class Dy{constructor(e){this.decoders=e}or(e){return lh(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 lh=(t,e)=>new Dy({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Ly{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 jn=({name:t,prefix:e,encode:s,decode:r})=>new Ly(t,e,s,r),Fi=({prefix:t,name:e,alphabet:s})=>{const{encode:r,decode:i}=ky(s,e);return jn({prefix:t,name:e,encode:r,decode:n=>ch(i(n))})},My=(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},By=(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},et=({name:t,prefix:e,bitsPerChar:s,alphabet:r})=>jn({prefix:e,name:t,encode(i){return By(i,r,s)},decode(i){return My(i,r,s,t)}}),jy=jn({prefix:"\0",name:"identity",encode:t=>xy(t),decode:t=>$y(t)});var qy=Object.freeze({__proto__:null,identity:jy});const Fy=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Wy=Object.freeze({__proto__:null,base2:Fy});const Hy=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zy=Object.freeze({__proto__:null,base8:Hy});const Vy=Fi({prefix:"9",name:"base10",alphabet:"0123456789"});var Ky=Object.freeze({__proto__:null,base10:Vy});const Gy=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jy=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yy=Object.freeze({__proto__:null,base16:Gy,base16upper:Jy});const Xy=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zy=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qy=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ev=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tv=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sv=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rv=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iv=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nv=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ov=Object.freeze({__proto__:null,base32:Xy,base32upper:Zy,base32pad:Qy,base32padupper:ev,base32hex:tv,base32hexupper:sv,base32hexpad:rv,base32hexpadupper:iv,base32z:nv});const av=Fi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cv=Fi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var lv=Object.freeze({__proto__:null,base36:av,base36upper:cv});const uv=Fi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hv=Fi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dv=Object.freeze({__proto__:null,base58btc:uv,base58flickr:hv});const pv=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fv=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gv=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mv=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var wv=Object.freeze({__proto__:null,base64:pv,base64pad:fv,base64url:gv,base64urlpad:mv});const uh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),yv=uh.reduce((t,e,s)=>(t[s]=e,t),[]),vv=uh.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function bv(t){return t.reduce((e,s)=>(e+=yv[s],e),"")}function Ev(t){const e=[];for(const s of t){const r=vv[s.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(r)}return new Uint8Array(e)}const Cv=jn({prefix:"🚀",name:"base256emoji",encode:bv,decode:Ev});var Iv=Object.freeze({__proto__:null,base256emoji:Cv}),Nv=hh,Wc=128,_v=127,Av=~_v,Sv=Math.pow(2,31);function hh(t,e,s){e=e||[],s=s||0;for(var r=s;t>=Sv;)e[s++]=t&255|Wc,t/=128;for(;t&Av;)e[s++]=t&255|Wc,t>>>=7;return e[s]=t|0,hh.bytes=s-r+1,e}var Pv=qo,Ov=128,Hc=127;function qo(t,r){var s=0,r=r||0,i=0,n=r,o,a=t.length;do{if(n>=a)throw qo.bytes=0,new RangeError("Could not decode varint");o=t[n++],s+=i<28?(o&Hc)<<i:(o&Hc)*Math.pow(2,i),i+=7}while(o>=Ov);return qo.bytes=n-r,s}var Tv=Math.pow(2,7),kv=Math.pow(2,14),$v=Math.pow(2,21),xv=Math.pow(2,28),Rv=Math.pow(2,35),Uv=Math.pow(2,42),Dv=Math.pow(2,49),Lv=Math.pow(2,56),Mv=Math.pow(2,63),Bv=function(t){return t<Tv?1:t<kv?2:t<$v?3:t<xv?4:t<Rv?5:t<Uv?6:t<Dv?7:t<Lv?8:t<Mv?9:10},jv={encode:Nv,decode:Pv,encodingLength:Bv},dh=jv;const zc=(t,e,s=0)=>(dh.encode(t,e,s),e),Vc=t=>dh.encodingLength(t),Fo=(t,e)=>{const s=e.byteLength,r=Vc(t),i=r+Vc(s),n=new Uint8Array(i+s);return zc(t,n,0),zc(s,n,r),n.set(e,i),new qv(t,s,e,n)};class qv{constructor(e,s,r,i){this.code=e,this.size=s,this.digest=r,this.bytes=i}}const ph=({name:t,code:e,encode:s})=>new Fv(t,e,s);class Fv{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?Fo(this.code,s):s.then(r=>Fo(this.code,r))}else throw Error("Unknown type, must be binary type")}}const fh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Wv=ph({name:"sha2-256",code:18,encode:fh("SHA-256")}),Hv=ph({name:"sha2-512",code:19,encode:fh("SHA-512")});var zv=Object.freeze({__proto__:null,sha256:Wv,sha512:Hv});const gh=0,Vv="identity",mh=ch,Kv=t=>Fo(gh,mh(t)),Gv={code:gh,name:Vv,encode:mh,digest:Kv};var Jv=Object.freeze({__proto__:null,identity:Gv});new TextEncoder,new TextDecoder;const Kc={...qy,...Wy,...zy,...Ky,...Yy,...ov,...lv,...dv,...wv,...Iv};({...zv,...Jv});function Yv(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function wh(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const Gc=wh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),lo=wh("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=Yv(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Xv={utf8:Gc,"utf-8":Gc,hex:Kc.base16,latin1:lo,ascii:lo,binary:lo,...Kc};function Zv(t,e="utf8"){const s=Xv[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 Qv=Object.defineProperty,eb=(t,e,s)=>e in t?Qv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Kt=(t,e,s)=>eb(t,typeof e!="symbol"?e+"":e,s);class tb{constructor(e,s){this.core=e,this.logger=s,Kt(this,"keychain",new Map),Kt(this,"name",ey),Kt(this,"version",ty),Kt(this,"initialized",!1),Kt(this,"storagePrefix",ts),Kt(this,"init",async()=>{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),Kt(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),Kt(this,"set",async(r,i)=>{this.isInitialized(),this.keychain.set(r,i),await this.persist()}),Kt(this,"get",r=>{this.isInitialized();const i=this.keychain.get(r);if(typeof i>"u"){const{message:n}=R("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}),Kt(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=ct(s,this.name)}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Po(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var sb=Object.defineProperty,rb=(t,e,s)=>e in t?sb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ze=(t,e,s)=>rb(t,typeof e!="symbol"?e+"":e,s);class ib{constructor(e,s,r){this.core=e,this.logger=s,Ze(this,"name",Zw),Ze(this,"keychain"),Ze(this,"randomSessionIdentifier",Bo()),Ze(this,"initialized",!1),Ze(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ze(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Ze(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),n=Oa(i);return rd(n.publicKey)}),Ze(this,"generateKeyPair",()=>{this.isInitialized();const i=Vm();return this.setPrivateKey(i.publicKey,i.privateKey)}),Ze(this,"signJWT",async i=>{this.isInitialized();const n=await this.getClientSeed(),o=Oa(n),a=this.randomSessionIdentifier;return await id(a,i,Qw,o)}),Ze(this,"generateSharedKey",(i,n,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=Km(a,n);return this.setSymKey(c,o)}),Ze(this,"setSymKey",async(i,n)=>{this.isInitialized();const o=n||pn(i);return await this.keychain.set(o,i),o}),Ze(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Ze(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Ze(this,"encode",async(i,n,o)=>{this.isInitialized();const a=eh(o),c=sa(n);if(Pc(a))return Ym(c,o?.encoding);if(Sc(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 Gm({type:u,symKey:l,message:c,senderPublicKey:h,encoding:o?.encoding})}),Ze(this,"decode",async(i,n,o)=>{this.isInitialized();const a=Zm(n,o);if(Pc(a)){const c=Xm(n,o?.encoding);return bn(c)}if(Sc(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=Jm({symKey:c,encoded:n,encoding:o?.encoding});return bn(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Ze(this,"getPayloadType",(i,n=Wt)=>{const o=Oi({encoded:i,encoding:n});return Qs(o.type)}),Ze(this,"getPayloadSenderPublicKey",(i,n=Wt)=>{const o=Oi({encoded:i,encoding:n});return o.senderPublicKey?wt(o.senderPublicKey,at):void 0}),this.core=e,this.logger=ct(s,this.name),this.keychain=r||new tb(this.core,this.logger)}get context(){return At(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(jc)}catch{e=Bo(),await this.keychain.set(jc,e)}return Zv(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var nb=Object.defineProperty,ob=Object.defineProperties,ab=Object.getOwnPropertyDescriptors,Jc=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,lb=Object.prototype.propertyIsEnumerable,Wo=(t,e,s)=>e in t?nb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ub=(t,e)=>{for(var s in e||(e={}))cb.call(e,s)&&Wo(t,s,e[s]);if(Jc)for(var s of Jc(e))lb.call(e,s)&&Wo(t,s,e[s]);return t},hb=(t,e)=>ob(t,ab(e)),vt=(t,e,s)=>Wo(t,typeof e!="symbol"?e+"":e,s);class db extends zp{constructor(e,s){super(e,s),this.logger=e,this.core=s,vt(this,"messages",new Map),vt(this,"messagesWithoutClientAck",new Map),vt(this,"name",sy),vt(this,"version",ry),vt(this,"initialized",!1),vt(this,"storagePrefix",ts),vt(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}}}),vt(this,"set",async(r,i,n)=>{this.isInitialized();const o=Zt(i);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(r,a),n===fn.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,hb(ub({},c),{[o]:i}))}return await this.persist(),o}),vt(this,"get",r=>{this.isInitialized();let i=this.messages.get(r);return typeof i>"u"&&(i={}),i}),vt(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}),vt(this,"has",(r,i)=>{this.isInitialized();const n=this.get(r),o=Zt(i);return typeof n[o]<"u"}),vt(this,"ack",async(r,i)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=Zt(i);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),vt(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=ct(e,this.name),this.core=s}get context(){return At(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,Po(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,Po(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var pb=Object.defineProperty,fb=Object.defineProperties,gb=Object.getOwnPropertyDescriptors,Yc=Object.getOwnPropertySymbols,mb=Object.prototype.hasOwnProperty,wb=Object.prototype.propertyIsEnumerable,Ho=(t,e,s)=>e in t?pb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,en=(t,e)=>{for(var s in e||(e={}))mb.call(e,s)&&Ho(t,s,e[s]);if(Yc)for(var s of Yc(e))wb.call(e,s)&&Ho(t,s,e[s]);return t},uo=(t,e)=>fb(t,gb(e)),Bt=(t,e,s)=>Ho(t,typeof e!="symbol"?e+"":e,s);class yb extends Vp{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Bt(this,"events",new $s.EventEmitter),Bt(this,"name",iy),Bt(this,"queue",new Map),Bt(this,"publishTimeout",U.toMiliseconds(U.ONE_MINUTE)),Bt(this,"initialPublishTimeout",U.toMiliseconds(U.ONE_SECOND*15)),Bt(this,"needsTransportRestart",!1),Bt(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?.ttl||qc,c=Nn(n),l=n?.prompt||!1,u=n?.tag||0,h=n?.id||Sr().toString(),d={topic:r,message:i,opts:{ttl:a,relay:c,prompt:l,tag:u,id:h,attestation:n?.attestation,tvf:n?.tvf}},f=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const m=new Promise(async w=>{const g=({id:v})=>{d.opts.id===v&&(this.removeRequestFromQueue(v),this.relayer.events.removeListener(Ve.publish,g),w(d))};this.relayer.events.on(Ve.publish,g);const y=Ns(new Promise((v,E)=>{this.rpcPublish({topic:r,message:i,ttl:a,prompt:l,tag:u,id:h,attestation:n?.attestation,tvf:n?.tvf}).then(v).catch(N=>{this.logger.warn(N,N?.message),E(N)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await y,this.events.removeListener(Ve.publish,g)}catch(v){this.queue.set(h,uo(en({},d),{attempt:1})),this.logger.warn(v,v?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:r,message:i,opts:n}}),await Ns(m,this.publishTimeout,f)}catch(m){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(m),(o=n?.internal)!=null&&o.throwOnFailedPublish)throw m}finally{this.queue.delete(h)}}),Bt(this,"on",(r,i)=>{this.events.on(r,i)}),Bt(this,"once",(r,i)=>{this.events.once(r,i)}),Bt(this,"off",(r,i)=>{this.events.off(r,i)}),Bt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.relayer=e,this.logger=ct(s,this.name),this.registerEventListeners()}get context(){return At(this.logger)}async rpcPublish(e){var s,r,i,n;const{topic:o,message:a,ttl:c=qc,prompt:l,tag:u,id:h,attestation:d,tvf:f}=e,m={method:hi(Nn().protocol).publish,params:en({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:d},f),id:h};rt((s=m.params)==null?void 0:s.prompt)&&((r=m.params)==null||delete r.prompt),rt((i=m.params)==null?void 0:i.tag)&&((n=m.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:m});const w=await this.relayer.request(m);return this.relayer.events.emit(Ve.publish,e),this.logger.debug("Successfully Published Payload"),w}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{const r=e.attempt+1;this.queue.set(s,uo(en({},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(uo(en({},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(Gr.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 vb=Object.defineProperty,bb=(t,e,s)=>e in t?vb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ur=(t,e,s)=>bb(t,typeof e!="symbol"?e+"":e,s);class Eb{constructor(){ur(this,"map",new Map),ur(this,"set",(e,s)=>{const r=this.get(e);this.exists(e,s)||this.map.set(e,[...r,s])}),ur(this,"get",e=>this.map.get(e)||[]),ur(this,"exists",(e,s)=>this.get(e).includes(s)),ur(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)}),ur(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Cb=Object.defineProperty,Ib=Object.defineProperties,Nb=Object.getOwnPropertyDescriptors,Xc=Object.getOwnPropertySymbols,_b=Object.prototype.hasOwnProperty,Ab=Object.prototype.propertyIsEnumerable,zo=(t,e,s)=>e in t?Cb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ni=(t,e)=>{for(var s in e||(e={}))_b.call(e,s)&&zo(t,s,e[s]);if(Xc)for(var s of Xc(e))Ab.call(e,s)&&zo(t,s,e[s]);return t},ho=(t,e)=>Ib(t,Nb(e)),Ee=(t,e,s)=>zo(t,typeof e!="symbol"?e+"":e,s);class Sb extends Jp{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Ee(this,"subscriptions",new Map),Ee(this,"topicMap",new Eb),Ee(this,"events",new $s.EventEmitter),Ee(this,"name",hy),Ee(this,"version",dy),Ee(this,"pending",new Map),Ee(this,"cached",[]),Ee(this,"initialized",!1),Ee(this,"storagePrefix",ts),Ee(this,"subscribeTimeout",U.toMiliseconds(U.ONE_MINUTE)),Ee(this,"initialSubscribeTimeout",U.toMiliseconds(U.ONE_SECOND*15)),Ee(this,"clientId"),Ee(this,"batchSubscribeTopicsLimit",500),Ee(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ee(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=Nn(i),o={topic:r,relay:n,transportType: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}}),Ee(this,"unsubscribe",async(r,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(r,i.id,i):await this.unsubscribeByTopic(r,i)}),Ee(this,"isSubscribed",r=>new Promise(i=>{i(this.topicMap.topics.includes(r))})),Ee(this,"isKnownTopic",r=>new Promise(i=>{i(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),Ee(this,"on",(r,i)=>{this.events.on(r,i)}),Ee(this,"once",(r,i)=>{this.events.once(r,i)}),Ee(this,"off",(r,i)=>{this.events.off(r,i)}),Ee(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),Ee(this,"start",async()=>{await this.onConnect()}),Ee(this,"stop",async()=>{await this.onDisconnect()}),Ee(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Ee(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)}),Ee(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(Gr.pulse,async()=>{await this.checkPending()}),this.events.on(bt.created,async r=>{const i=bt.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(bt.deleted,async r=>{const i=bt.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}),this.relayer=e,this.logger=ct(s,this.name),this.clientId=""}get context(){return At(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=Nn(r);await this.restartToComplete({topic:e,id:s,relay:i}),await this.rpcUnsubscribe(e,s,i);const n=ye("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?.transportType===Pe.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?.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(r?.transportType===Pe.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(u=>this.logger.warn(u))},U.toMiliseconds(U.ONE_SECOND)),a;const c=new Promise(async u=>{const h=d=>{d.topic===e&&(this.events.removeListener(bt.created,h),u(d.id))};this.events.on(bt.created,h);try{const d=await Ns(new Promise((f,m)=>{this.relayer.request(n).catch(w=>{this.logger.warn(w,w?.message),m(w)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(bt.created,h),u(d)}catch{}}),l=await Ns(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 Ns(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 Ns(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,ho(ni({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,ni({},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,ni({},s)),this.topicMap.set(s.topic,e),this.events.emit(bt.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}=R("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(bt.deleted,ho(ni({},r),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(bt.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(bt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:s}=R("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=>ho(ni({},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 xf(U.toMiliseconds(U.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}=R("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 Zt(e+await this.getClientId())}}var Pb=Object.defineProperty,Zc=Object.getOwnPropertySymbols,Ob=Object.prototype.hasOwnProperty,Tb=Object.prototype.propertyIsEnumerable,Vo=(t,e,s)=>e in t?Pb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Qc=(t,e)=>{for(var s in e||(e={}))Ob.call(e,s)&&Vo(t,s,e[s]);if(Zc)for(var s of Zc(e))Tb.call(e,s)&&Vo(t,s,e[s]);return t},ue=(t,e,s)=>Vo(t,typeof e!="symbol"?e+"":e,s);class kb extends Kp{constructor(e){super(e),ue(this,"protocol","wc"),ue(this,"version",2),ue(this,"core"),ue(this,"logger"),ue(this,"events",new $s.EventEmitter),ue(this,"provider"),ue(this,"messages"),ue(this,"subscriber"),ue(this,"publisher"),ue(this,"name",oy),ue(this,"transportExplicitlyClosed",!1),ue(this,"initialized",!1),ue(this,"connectionAttemptInProgress",!1),ue(this,"relayUrl"),ue(this,"projectId"),ue(this,"packageName"),ue(this,"bundleId"),ue(this,"hasExperiencedNetworkDisruption",!1),ue(this,"pingTimeout"),ue(this,"heartBeatTimeout",U.toMiliseconds(U.THIRTY_SECONDS+U.FIVE_SECONDS)),ue(this,"reconnectTimeout"),ue(this,"connectPromise"),ue(this,"reconnectInProgress",!1),ue(this,"requestsInFlight",[]),ue(this,"connectTimeout",U.toMiliseconds(U.ONE_SECOND*15)),ue(this,"request",async s=>{var r,i;this.logger.debug("Publishing Request Payload");const n=s.id||Sr().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}}),ue(this,"resetPingTimeout",()=>{Cn()&&(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?.message)}},this.heartBeatTimeout))}),ue(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),ue(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Ve.connect)}),ue(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),ue(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()}),ue(this,"registerProviderListeners",()=>{this.provider.on(Tt.payload,this.onPayloadHandler),this.provider.on(Tt.connect,this.onConnectHandler),this.provider.on(Tt.disconnect,this.onDisconnectHandler),this.provider.on(Tt.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?ct(e.logger,this.name):ra(xi({level:e.logger||ny})),this.messages=new db(this.logger,e.core),this.subscriber=new Sb(this,this.logger),this.publisher=new yb(this,this.logger),this.relayUrl=e?.relayUrl||oh,this.projectId=e.projectId,wf()?this.packageName=Xa():yf()&&(this.bundleId=Xa()),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?.message)}}get context(){return At(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:Pe.relay},fn.outbound)}async subscribe(e,s){var r,i,n;this.isInitialized(),(!(s!=null&&s.transportType)||s?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((r=s?.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(i=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(bt.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(bt.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,Qc({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 Ns(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 Bc())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(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?.message)}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:r}=e;if(!s.sessionExists){const i=Be(U.FIVE_MINUTES),n={topic:r,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(Ve.message,e),await this.recordMessageEvent(e,fn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(r,i)=>{const n=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Tt.disconnect,n),await Ns(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(Tt.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(Tt.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Tt.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,U.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,r,i,n;if(Cn())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?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ut(new sd(If({sdkVersion:jo,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}),ia(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:Pe.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Qc({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else na(e)&&this.events.emit(Ve.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,fn.inbound),this.events.emit(Ve.message,e))}async acknowledgePayload(e){const s=Tn(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(Tt.payload,this.onPayloadHandler),this.provider.off(Tt.connect,this.onConnectHandler),this.provider.off(Tt.disconnect,this.onDisconnectHandler),this.provider.off(Tt.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Bc();zw(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(r=>this.logger.error(r,r?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(Gr.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&Gw())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,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?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},U.toMiliseconds(cy)))))}isInitialized(){if(!this.initialized){const{message:e}=R("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 $b(){}function el(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 tl(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function sl(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const xb="[object RegExp]",Rb="[object String]",Ub="[object Number]",Db="[object Boolean]",rl="[object Arguments]",Lb="[object Symbol]",Mb="[object Date]",Bb="[object Map]",jb="[object Set]",qb="[object Array]",Fb="[object Function]",Wb="[object ArrayBuffer]",po="[object Object]",Hb="[object Error]",zb="[object DataView]",Vb="[object Uint8Array]",Kb="[object Uint8ClampedArray]",Gb="[object Uint16Array]",Jb="[object Uint32Array]",Yb="[object BigUint64Array]",Xb="[object Int8Array]",Zb="[object Int16Array]",Qb="[object Int32Array]",e0="[object BigInt64Array]",t0="[object Float32Array]",s0="[object Float64Array]";function r0(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function i0(t,e,s){return di(t,e,void 0,void 0,void 0,void 0,s)}function di(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 Ei(t,e,n,o)}return Ei(t,e,n,o)}function Ei(t,e,s,r){if(Object.is(t,e))return!0;let i=sl(t),n=sl(e);if(i===rl&&(i=po),n===rl&&(n=po),i!==n)return!1;switch(i){case Rb:return t.toString()===e.toString();case Ub:{const c=t.valueOf(),l=e.valueOf();return r0(c,l)}case Db:case Mb:case Lb:return Object.is(t.valueOf(),e.valueOf());case xb:return t.source===e.source&&t.flags===e.flags;case Fb: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 Bb:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!di(l,e.get(c),c,t,e,s,r))return!1;return!0}case jb:{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=>di(h,f,void 0,t,e,s,r));if(d===-1)return!1;l.splice(d,1)}return!0}case qb:case Vb:case Kb:case Gb:case Jb:case Yb:case Xb:case Zb:case Qb:case e0:case t0:case s0:{if(typeof Ye<"u"&&Ye.isBuffer(t)!==Ye.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!di(t[c],e[c],c,t,e,s,r))return!1;return!0}case Wb:return t.byteLength!==e.byteLength?!1:Ei(new Uint8Array(t),new Uint8Array(e),s,r);case zb:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Ei(new Uint8Array(t),new Uint8Array(e),s,r);case Hb:return t.name===e.name&&t.message===e.message;case po:{if(!(Ei(t.constructor,e.constructor,s,r)||el(t)&&el(e)))return!1;const c=[...Object.keys(t),...tl(t)],l=[...Object.keys(e),...tl(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(!di(d,f,h,t,e,s,r))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function n0(t,e){return i0(t,e,$b)}var o0=Object.defineProperty,il=Object.getOwnPropertySymbols,a0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable,Ko=(t,e,s)=>e in t?o0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,nl=(t,e)=>{for(var s in e||(e={}))a0.call(e,s)&&Ko(t,s,e[s]);if(il)for(var s of il(e))c0.call(e,s)&&Ko(t,s,e[s]);return t},dt=(t,e,s)=>Ko(t,typeof e!="symbol"?e+"":e,s);class ir extends Gp{constructor(e,s,r,i=ts,n=void 0){super(e,s,r,i),this.core=e,this.logger=s,this.name=r,dt(this,"map",new Map),dt(this,"version",ly),dt(this,"cached",[]),dt(this,"initialized",!1),dt(this,"getKey"),dt(this,"storagePrefix",ts),dt(this,"recentlyDeleted",[]),dt(this,"recentlyDeletedLimit",200),dt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!rt(o)?this.map.set(this.getKey(o),o):Cw(o)?this.map.set(o.id,o):Iw(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),dt(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())}),dt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),dt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>n0(a[c],o[c]))):this.values)),dt(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=nl(nl({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),dt(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=ct(s,this.name),this.storagePrefix=i,this.getKey=n}get context(){return At(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}=R("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:r}=R("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}=R("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}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var l0=Object.defineProperty,u0=(t,e,s)=>e in t?l0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e,s)=>u0(t,typeof e!="symbol"?e+"":e,s);class h0{constructor(e,s){this.core=e,this.logger=s,ne(this,"name",py),ne(this,"version",fy),ne(this,"events",new aa),ne(this,"pairings"),ne(this,"initialized",!1),ne(this,"storagePrefix",ts),ne(this,"ignoredPayloadTypes",[ds]),ne(this,"registeredMethods",[]),ne(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ne(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),ne(this,"create",async r=>{this.isInitialized();const i=Bo(),n=await this.core.crypto.setSymKey(i),o=Be(U.FIVE_MINUTES),a={protocol:nh},c={topic:n,expiry:o,relay:a,active:!1,methods:r?.methods},l=Tc({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:a,expiryTimestamp:o,methods:r?.methods});return this.events.emit(Ws.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r?.transportType}),{topic:n,uri:l}}),ne(this,"pair",async r=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:r?.uri,trace:[Jt.pairing_started]}});this.isValidPair(r,i);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Oc(r.uri);i.props.properties.topic=n,i.addTrace(Jt.pairing_uri_validation_success),i.addTrace(Jt.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(n)){if(u=this.pairings.get(n),i.addTrace(Jt.existing_pairing),u.active)throw i.setError(cs.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);i.addTrace(Jt.pairing_not_expired)}const h=c||Be(U.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(Jt.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(Ws.create,d),i.addTrace(Jt.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),i.addTrace(Jt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(cs.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw i.setError(cs.subscribe_pairing_topic_failure),f}return i.addTrace(Jt.subscribe_pairing_topic_success),d}),ne(this,"activate",async({topic:r})=>{this.isInitialized();const i=Be(U.FIVE_MINUTES);this.core.expirer.set(r,i),await this.pairings.update(r,{active:!0,expiry:i})}),ne(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}=js();this.events.once(fe("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),ne(this,"updateExpiry",async({topic:r,expiry:i})=>{this.isInitialized(),await this.pairings.update(r,{expiry:i})}),ne(this,"updateMetadata",async({topic:r,metadata:i})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:i})}),ne(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ne(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",ye("USER_DISCONNECTED")),await this.deletePairing(i))}),ne(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:i,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(i);return Tc({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),ne(this,"sendRequest",async(r,i,n)=>{const o=zs(i,n),a=await this.core.crypto.encode(r,o),c=ri[i].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),ne(this,"sendResult",async(r,i,n)=>{const o=Tn(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=ri[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ne(this,"sendError",async(r,i,n)=>{const o=zl(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=ri[c]?ri[c].res:ri.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ne(this,"deletePairing",async(r,i)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,ye("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),i?Promise.resolve():this.core.expirer.del(r)])}),ne(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(i=>bs(i.expiry));await Promise.all(r.map(i=>this.deletePairing(i.topic)))}),ne(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)}}),ne(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)}}),ne(this,"onPairingPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(Ws.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ne(this,"onPairingPingResponse",(r,i)=>{const{id:n}=i;setTimeout(()=>{as(i)?this.events.emit(fe("pairing_ping",n),{}):Yt(i)&&this.events.emit(fe("pairing_ping",n),{error:i.error})},500)}),ne(this,"onPairingDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(Ws.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ne(this,"onUnknownRpcMethodRequest",async(r,i)=>{const{id:n,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=ye("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)}}),ne(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(ye("WC_METHOD_UNSUPPORTED",r))}),ne(this,"isValidPair",(r,i)=>{var n;if(!gt(r)){const{message:a}=R("MISSING_OR_INVALID",`pair() params: ${r}`);throw i.setError(cs.malformed_pairing_uri),new Error(a)}if(!Ew(r.uri)){const{message:a}=R("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw i.setError(cs.malformed_pairing_uri),new Error(a)}const o=Oc(r?.uri);if(!((n=o?.relay)!=null&&n.protocol)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(cs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(cs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&U.toMiliseconds(o?.expiryTimestamp)<Date.now()){i.setError(cs.pairing_expired);const{message:a}=R("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ne(this,"isValidPing",async r=>{if(!gt(r)){const{message:n}=R("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ne(this,"isValidDisconnect",async r=>{if(!gt(r)){const{message:n}=R("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ne(this,"isValidPairingTopic",async r=>{if(!Ue(r,!1)){const{message:i}=R("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.pairings.keys.includes(r)){const{message:i}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(bs(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:i}=R("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}),this.core=e,this.logger=ct(s,this.name),this.pairings=new ir(this.core,this.logger,this.name,this.storagePrefix)}get context(){return At(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=R("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!==Pe.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(s,r);ia(n)?(this.core.history.set(s,n),await this.onRelayEventRequest({topic:s,payload:n})):na(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(xt.expired,async e=>{const{topic:s}=Eu(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(Ws.expire,{topic:s}))})}}var d0=Object.defineProperty,p0=(t,e,s)=>e in t?d0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Qe=(t,e,s)=>p0(t,typeof e!="symbol"?e+"":e,s);class f0 extends Hp{constructor(e,s){super(e,s),this.core=e,this.logger=s,Qe(this,"records",new Map),Qe(this,"events",new $s.EventEmitter),Qe(this,"name",gy),Qe(this,"version",my),Qe(this,"cached",[]),Qe(this,"initialized",!1),Qe(this,"storagePrefix",ts),Qe(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)}),Qe(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:Be(U.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Lt.created,o)}),Qe(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=Yt(r)?{error:r.error}:{result:r.result},this.records.set(i.id,i),this.persist(),this.events.emit(Lt.updated,i))}),Qe(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))),Qe(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(Lt.deleted,n)}}),this.persist()}),Qe(this,"exists",async(r,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===r:!1)),Qe(this,"on",(r,i)=>{this.events.on(r,i)}),Qe(this,"once",(r,i)=>{this.events.once(r,i)}),Qe(this,"off",(r,i)=>{this.events.off(r,i)}),Qe(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ct(s,this.name)}get context(){return At(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:zs(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}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Lt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=R("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(Lt.created,e=>{const s=Lt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Lt.updated,e=>{const s=Lt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Lt.deleted,e=>{const s=Lt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(Gr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{U.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(Lt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var g0=Object.defineProperty,m0=(t,e,s)=>e in t?g0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,st=(t,e,s)=>m0(t,typeof e!="symbol"?e+"":e,s);class w0 extends Yp{constructor(e,s){super(e,s),this.core=e,this.logger=s,st(this,"expirations",new Map),st(this,"events",new $s.EventEmitter),st(this,"name",wy),st(this,"version",yy),st(this,"cached",[]),st(this,"initialized",!1),st(this,"storagePrefix",ts),st(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)}),st(this,"has",r=>{try{const i=this.formatTarget(r);return typeof this.getExpiration(i)<"u"}catch{return!1}}),st(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(xt.created,{target:n,expiration:o})}),st(this,"get",r=>{this.isInitialized();const i=this.formatTarget(r);return this.getExpiration(i)}),st(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(xt.deleted,{target:i,expiration:n})}}),st(this,"on",(r,i)=>{this.events.on(r,i)}),st(this,"once",(r,i)=>{this.events.once(r,i)}),st(this,"off",(r,i)=>{this.events.off(r,i)}),st(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=ct(s,this.name)}get context(){return At(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 Nf(e);if(typeof e=="number")return _f(e);const{message:s}=R("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(xt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=R("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}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return s}checkExpiry(e,s){const{expiry:r}=s;U.toMiliseconds(r)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(xt.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(Gr.pulse,()=>this.checkExpirations()),this.events.on(xt.created,e=>{const s=xt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(xt.expired,e=>{const s=xt.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(xt.deleted,e=>{const s=xt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var y0=Object.defineProperty,v0=(t,e,s)=>e in t?y0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Re=(t,e,s)=>v0(t,typeof e!="symbol"?e+"":e,s);class b0 extends Xp{constructor(e,s,r){super(e,s,r),this.core=e,this.logger=s,this.store=r,Re(this,"name",vy),Re(this,"abortController"),Re(this,"isDevEnv"),Re(this,"verifyUrlV3",Ey),Re(this,"storagePrefix",ts),Re(this,"version",ih),Re(this,"publicKey"),Re(this,"fetchPromise"),Re(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&U.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Re(this,"register",async i=>{if(!Jr()||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=Dr(),u=this.startAbortTimer(U.ONE_SECOND*5),h=await new Promise((d,f)=>{const m=()=>{window.removeEventListener("message",g),l.body.removeChild(w),f("attestation aborted")};this.abortController.signal.addEventListener("abort",m);const w=l.createElement("iframe");w.src=c,w.style.display="none",w.addEventListener("error",m,{signal:this.abortController.signal});const g=y=>{if(y.data&&typeof y.data=="string")try{const v=JSON.parse(y.data);if(v.type==="verify_attestation"){if(Co(v.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(w),this.abortController.signal.removeEventListener("abort",m),window.removeEventListener("message",g),d(v.attestation===null?"":v.attestation)}}catch(v){this.logger.warn(v)}};l.body.appendChild(w),window.addEventListener("message",g,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(l){this.logger.warn(l)}return""}),Re(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(Co(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?.verifyUrl);return this.fetchAttestation(o,c)}),Re(this,"fetchAttestation",async(i,n)=>{this.logger.debug(`resolving attestation: ${i} from url: ${n}`);const o=this.startAbortTimer(U.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}),Re(this,"getVerifyUrl",i=>{let n=i||bi;return Cy.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${bi}`),n=bi),n}),Re(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(U.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)}}),Re(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),Re(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Re(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")}}),Re(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Re(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}),Re(this,"validateAttestation",(i,n)=>{const o=ew(i,n.publicKey),a={hasExpired:U.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=ct(s,this.name),this.abortController=new AbortController,this.isDevEnv=ca(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return At(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),U.toMiliseconds(e))}}var E0=Object.defineProperty,C0=(t,e,s)=>e in t?E0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ol=(t,e,s)=>C0(t,typeof e!="symbol"?e+"":e,s);class I0 extends Zp{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,ol(this,"context",Iy),ol(this,"registerDeviceToken",async r=>{const{clientId:i,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${Ny}/${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=ct(s,this.context)}}var N0=Object.defineProperty,al=Object.getOwnPropertySymbols,_0=Object.prototype.hasOwnProperty,A0=Object.prototype.propertyIsEnumerable,Go=(t,e,s)=>e in t?N0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,oi=(t,e)=>{for(var s in e||(e={}))_0.call(e,s)&&Go(t,s,e[s]);if(al)for(var s of al(e))A0.call(e,s)&&Go(t,s,e[s]);return t},Fe=(t,e,s)=>Go(t,typeof e!="symbol"?e+"":e,s);class S0 extends Qp{constructor(e,s,r=!0){super(e,s,r),this.core=e,this.logger=s,Fe(this,"context",Ay),Fe(this,"storagePrefix",ts),Fe(this,"storageVersion",_y),Fe(this,"events",new Map),Fe(this,"shouldPersist",!1),Fe(this,"init",async()=>{if(!ca())try{const i={eventId:Qa(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:vu(this.core.relayer.protocol,this.core.relayer.version,jo)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),Fe(this,"createEvent",i=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=Qa(),u=this.core.projectId||"",h=Date.now(),d=oi({eventId:l,timestamp:h,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d}),Fe(this,"getEvent",i=>{const{eventId:n,topic:o}=i;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return oi(oi({},a),this.setMethods(a.eventId))}),Fe(this,"deleteEvent",i=>{const{eventId:n}=i;this.events.delete(n),this.shouldPersist=!0}),Fe(this,"setEventListeners",()=>{this.core.heartbeat.on(Gr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{U.fromMiliseconds(Date.now())-U.fromMiliseconds(i.timestamp)>Sy&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),Fe(this,"setMethods",i=>({addTrace:n=>this.addTrace(i,n),setError:n=>this.setError(i,n)})),Fe(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)}),Fe(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)}),Fe(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Fe(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(n=>{this.events.set(n.eventId,oi(oi({},n),this.setMethods(n.eventId)))})}catch(i){this.logger.warn(i)}}),Fe(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)}}),Fe(this,"sendEvent",async i=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${Py}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${jo}${n}`,{method:"POST",body:JSON.stringify(i)})}),Fe(this,"getAppDomain",()=>yu().url),this.logger=ct(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 P0=Object.defineProperty,cl=Object.getOwnPropertySymbols,O0=Object.prototype.hasOwnProperty,T0=Object.prototype.propertyIsEnumerable,Jo=(t,e,s)=>e in t?P0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ll=(t,e)=>{for(var s in e||(e={}))O0.call(e,s)&&Jo(t,s,e[s]);if(cl)for(var s of cl(e))T0.call(e,s)&&Jo(t,s,e[s]);return t},Ae=(t,e,s)=>Jo(t,typeof e!="symbol"?e+"":e,s);let k0=class yh extends jp{constructor(e){var s;super(e),Ae(this,"protocol",rh),Ae(this,"version",ih),Ae(this,"name",An),Ae(this,"relayUrl"),Ae(this,"projectId"),Ae(this,"customStoragePrefix"),Ae(this,"events",new $s.EventEmitter),Ae(this,"logger"),Ae(this,"heartbeat"),Ae(this,"relayer"),Ae(this,"crypto"),Ae(this,"storage"),Ae(this,"history"),Ae(this,"expirer"),Ae(this,"pairing"),Ae(this,"verify"),Ae(this,"echoClient"),Ae(this,"linkModeSupportedApps"),Ae(this,"eventClient"),Ae(this,"initialized",!1),Ae(this,"logChunkController"),Ae(this,"on",(a,c)=>this.events.on(a,c)),Ae(this,"once",(a,c)=>this.events.once(a,c)),Ae(this,"off",(a,c)=>this.events.off(a,c)),Ae(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Ae(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:Pe.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const r=this.getGlobalCore(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?.projectId,this.relayUrl=e?.relayUrl||oh,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=xi({level:typeof e?.logger=="string"&&e.logger?e.logger:Yw.logger,name:An}),{logger:n,chunkLoggerController:o}=Hl({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride: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=ct(n,this.name),this.heartbeat=new td,this.crypto=new ib(this,this.logger,e?.keychain),this.history=new f0(this,this.logger),this.expirer=new w0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Lp(ll(ll({},Xw),e?.storageOptions)),this.relayer=new kb({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new h0(this,this.logger),this.verify=new b0(this,this.logger,this.storage),this.echoClient=new I0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new S0(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new yh(e);await s.initialize();const r=await s.crypto.getClientId();return await s.storage.setItem(uy,r),s}get context(){return At(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(Fc,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(Fc)||[],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 _s<"u"&&Jw.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const $0=k0,vh="wc",bh=2,Eh="client",ma=`${vh}@${bh}:${Eh}:`,fo={name:Eh,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},ul="WALLETCONNECT_DEEPLINK_CHOICE",x0="proposal",hl="Proposal expired",R0="session",hr=U.SEVEN_DAYS,U0="engine",We={wc_sessionPropose:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1104},res:{ttl:U.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1106},res:{ttl:U.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:U.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1112},res:{ttl:U.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:U.ONE_DAY,prompt:!1,tag:1114},res:{ttl:U.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:U.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:U.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:U.FIVE_MINUTES,prompt:!1,tag:1119}}},go={min:U.FIVE_MINUTES,max:U.SEVEN_DAYS},Gt={idle:"IDLE",active:"ACTIVE"},dl={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},D0="request",L0=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],M0="wc",B0="auth",j0="authKeys",q0="pairingTopics",F0="requests",qn=`${M0}@${1.5}:${B0}:`,gn=`${qn}:PUB_KEY`;var W0=Object.defineProperty,H0=Object.defineProperties,z0=Object.getOwnPropertyDescriptors,pl=Object.getOwnPropertySymbols,V0=Object.prototype.hasOwnProperty,K0=Object.prototype.propertyIsEnumerable,Yo=(t,e,s)=>e in t?W0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ce=(t,e)=>{for(var s in e||(e={}))V0.call(e,s)&&Yo(t,s,e[s]);if(pl)for(var s of pl(e))K0.call(e,s)&&Yo(t,s,e[s]);return t},ot=(t,e)=>H0(t,z0(e)),_=(t,e,s)=>Yo(t,typeof e!="symbol"?e+"":e,s);class G0 extends rf{constructor(e){super(e),_(this,"name",U0),_(this,"events",new aa),_(this,"initialized",!1),_(this,"requestQueue",{state:Gt.idle,queue:[]}),_(this,"sessionRequestQueue",{state:Gt.idle,queue:[]}),_(this,"requestQueueDelay",U.ONE_SECOND),_(this,"expectedPairingMethodMap",new Map),_(this,"recentlyDeletedMap",new Map),_(this,"recentlyDeletedLimit",200),_(this,"relayMessageCache",[]),_(this,"pendingSessions",new Map),_(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(We)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},U.toMiliseconds(this.requestQueueDelay)))}),_(this,"connect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const r=ot(Ce({},s),{requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}});await this.isValidConnect(r),r.optionalNamespaces=mw(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}=R("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(O)}const f=await this.client.core.crypto.generateKeyPair(),m=We.wc_sessionPropose.req.ttl||U.FIVE_MINUTES,w=Be(m),g=ot(Ce(Ce({requiredNamespaces:n,optionalNamespaces:o,relays:l??[{protocol:nh}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:w,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:ps()}),y=fe("session_connect",g.id),{reject:v,resolve:E,done:N}=js(m,hl),$=({id:O})=>{O===g.id&&(this.client.events.off("proposal_expire",$),this.pendingSessions.delete(g.id),this.events.emit(y,{error:{message:hl,code:0}}))};return this.client.events.on("proposal_expire",$),this.events.once(y,({error:O,session:S})=>{this.client.events.off("proposal_expire",$),O?v(O):S&&E(S)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0,clientRpcId:g.id}),await this.setProposal(g.id,g),{uri:h,approval:N}}),_(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}}),_(this,"approve",async s=>{var r,i,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(r=s?.id)==null?void 0:r.toString(),trace:[Mt.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(b){throw o.setError(Ds.no_internet_connection),b}try{await this.isValidProposalId(s?.id)}catch(b){throw this.client.logger.error(`approve() -> proposal.get(${s?.id}) failed`),o.setError(Ds.proposal_not_found),b}try{await this.isValidApprove(s)}catch(b){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ds.session_approve_namespace_validation_failure),b}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:m,proposer:w,requiredNamespaces:g,optionalNamespaces:y}=f;let v=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:m});v||(v=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Mt.session_approve_started,properties:{topic:m,trace:[Mt.session_approve_started,Mt.session_namespaces_validation_success]}}));const E=await this.client.core.crypto.generateKeyPair(),N=w.publicKey,$=await this.client.core.crypto.generateSharedKey(E,N),O=Ce(Ce(Ce({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:E,metadata:this.client.metadata},expiry:Be(hr)},u&&{sessionProperties:u}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),S=Pe.relay;v.addTrace(Mt.subscribing_session_topic);try{await this.client.core.relayer.subscribe($,{transportType:S})}catch(b){throw v.setError(Ds.subscribe_session_topic_failure),b}v.addTrace(Mt.subscribe_session_topic_success);const D=ot(Ce({},O),{topic:$,requiredNamespaces:g,optionalNamespaces:y,pairingTopic:m,acknowledged:!1,self:O.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:E,transportType:Pe.relay});await this.client.session.set($,D),v.addTrace(Mt.store_session);try{v.addTrace(Mt.publishing_session_settle),await this.sendRequest({topic:$,method:"wc_sessionSettle",params:O,throwOnFailedPublish:!0}).catch(b=>{throw v?.setError(Ds.session_settle_publish_failure),b}),v.addTrace(Mt.session_settle_publish_success),v.addTrace(Mt.publishing_session_approve),await this.sendResult({id:a,topic:m,result:{relay:{protocol:c??"irn"},responderPublicKey:E},throwOnFailedPublish:!0}).catch(b=>{throw v?.setError(Ds.session_approve_publish_failure),b}),v.addTrace(Mt.session_approve_publish_success)}catch(b){throw this.client.logger.error(b),this.client.session.delete($,ye("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe($),b}return this.client.core.eventClient.deleteEvent({eventId:v.eventId}),await this.client.core.pairing.updateMetadata({topic:m,metadata:w.metadata}),await this.client.proposal.delete(a,ye("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:m}),await this.setExpiry($,Be(hr)),{topic:$,acknowledged:()=>Promise.resolve(this.client.session.get($))}}),_(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:We.wc_sessionPropose.reject}),await this.client.proposal.delete(r,ye("USER_DISCONNECTED")))}),_(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}=js(),c=ps(),l=Sr().toString(),u=this.client.session.get(r).namespaces;return this.events.once(fe("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}}),_(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=ps(),{done:n,resolve:o,reject:a}=js();return this.events.once(fe("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(r,Be(hr)),this.sendRequest({topic:r,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),_(this,"request",async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(y){throw this.client.logger.error("request() -> isValidRequest() failed"),y}const{chainId:r,request:i,topic:n,expiry:o=We.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(n);a?.transportType===Pe.relay&&await this.confirmOnlineStateOrThrow();const c=ps(),l=Sr().toString(),{done:u,resolve:h,reject:d}=js(o,"Request expired. Please try again.");this.events.once(fe("session_request",c),({error:y,result:v})=>{y?d(y):h(v)});const f="wc_sessionRequest",m=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:{request:ot(Ce({},i),{expiryTimestamp:Be(o)}),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:m}).catch(y=>d(y)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),await u();const w={request:ot(Ce({},i),{expiryTimestamp:Be(o)}),chainId:r},g=this.shouldSetTVF(f,w);return await Promise.all([new Promise(async y=>{await this.sendRequest(Ce({clientRpcId:c,relayRpcId:l,topic:n,method:f,params:w,expiry:o,throwOnFailedPublish:!0},g&&{tvf:this.getTVFParams(c,w)})).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),y()}),new Promise(async y=>{var v;if(!((v=a.sessionConfig)!=null&&v.disableDeepLink)){const E=await Of(this.client.core.storage,ul);await Af({id:c,topic:n,wcDeepLink:E})}y()}),u()]).then(y=>y[2])}),_(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===Pe.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);as(i)?await this.sendResult({id:n,topic:r,result:i.result,throwOnFailedPublish:!0,appLink:a}):Yt(i)&&await this.sendError({id:n,topic:r,error:i.error,appLink:a}),this.cleanupAfterResponse(s)}),_(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=ps(),n=Sr().toString(),{done:o,resolve:a,reject:c}=js();this.events.once(fe("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}))}),_(this,"emit",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:r,event:i,chainId:n}=s,o=Sr().toString(),a=ps();await this.sendRequest({topic:r,method:"wc_sessionEvent",params:{event:i,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),_(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:ye("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}=R("MISMATCHED_TOPIC",`Session or pairing topic not found: ${r}`);throw new Error(i)}}),_(this,"find",s=>(this.isInitialized(),this.client.session.getAll().filter(r=>vw(r,s)))),_(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),_(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?Pe.link_mode:Pe.relay;o===Pe.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:h,type:d,exp:f,nbf:m,methods:w=[],expiry:g}=s,y=[...s.resources||[]],{topic:v,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:E}});const N=await this.client.core.crypto.generateKeyPair(),$=pn(N);if(await Promise.all([this.client.auth.authKeys.set(gn,{responseTopic:$,publicKey:N}),this.client.auth.pairingTopics.set($,{topic:$,pairingTopic:v})]),await this.client.core.relayer.subscribe($,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${v}`),w.length>0){const{namespace:k}=xr(a[0]);let G=Eg(k,"request",w);dn(y)&&(G=Ig(G,y.pop())),y.push(G)}const O=g&&g>We.wc_sessionAuthenticate.req.ttl?g:We.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:m,resources:y},requester:{publicKey:N,metadata:this.client.metadata},expiryTimestamp:Be(O)},D={eip155:{chains:a,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},b={requiredNamespaces:{},optionalNamespaces:D,relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:N,metadata:this.client.metadata},expiryTimestamp:Be(We.wc_sessionPropose.req.ttl),id:ps()},{done:x,resolve:C,reject:L}=js(O,"Request expired"),z=ps(),I=fe("session_connect",b.id),T=fe("session_request",z),A=async({error:k,session:G})=>{this.events.off(T,B),k?L(k):G&&C({session:G})},B=async k=>{var G,ee,re;if(await this.deletePendingAuthRequest(z,{message:"fulfilled",code:0}),k.error){const Le=ye("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return k.error.code===Le.code?void 0:(this.events.off(I,A),L(k.error.message))}await this.deleteProposal(b.id),this.events.off(I,A);const{cacaos:Ne,responder:pe}=k.result,xe=[],qe=[];for(const Le of Ne){await ac({cacao:Le,projectId:this.client.core.projectId})||(this.client.logger.error(Le,"Signature verification failed"),L(ye("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Rs}=Le,ss=dn(Rs.resources),zt=[To(Rs.iss)],rs=In(Rs.iss);if(ss){const or=cc(ss),zi=lc(ss);xe.push(...or),zt.push(...zi)}for(const or of zt)qe.push(`${or}:${rs}`)}const tt=await this.client.core.crypto.generateSharedKey(N,pe.publicKey);let De;xe.length>0&&(De={topic:tt,acknowledged:!0,self:{publicKey:N,metadata:this.client.metadata},peer:pe,controller:pe.publicKey,expiry:Be(hr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:Rc([...new Set(xe)],[...new Set(qe)]),transportType:o},await this.client.core.relayer.subscribe(tt,{transportType:o}),await this.client.session.set(tt,De),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:pe.metadata}),De=this.client.session.get(tt)),(G=this.client.metadata.redirect)!=null&&G.linkMode&&(ee=pe.metadata.redirect)!=null&&ee.linkMode&&(re=pe.metadata.redirect)!=null&&re.universal&&r&&(this.client.core.addLinkModeSupportedApp(pe.metadata.redirect.universal),this.client.session.update(tt,{transportType:Pe.link_mode})),C({auths:Ne,session:De})};this.events.once(I,A),this.events.once(T,B);let F;try{if(n){const k=zs("wc_sessionAuthenticate",S,z);this.client.core.history.set(v,k);const G=await this.client.core.crypto.encode("",k,{type:qi,encoding:Es});F=Qi(r,v,G)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:S,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:z}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:b,expiry:We.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b.id})])}catch(k){throw this.events.off(I,A),this.events.off(T,B),k}return await this.setProposal(b.id,b),await this.setAuthRequest(z,{request:ot(Ce({},S),{verifyContext:{}}),pairingTopic:v,transportType:o}),{uri:F??E,response:x}}),_(this,"approveSessionAuthenticate",async s=>{const{id:r,auths:i}=s,n=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:[Ls.authenticated_session_approve_started]}});try{this.isInitialized()}catch(g){throw n.setError(ii.no_internet_connection),g}const o=this.getPendingAuthRequest(r);if(!o)throw n.setError(ii.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${r}`);const a=o.transportType||Pe.relay;a===Pe.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=pn(c),h={type:ds,receiverPublicKey:c,senderPublicKey:l},d=[],f=[];for(const g of i){if(!await ac({cacao:g,projectId:this.client.core.projectId})){n.setError(ii.invalid_cacao);const $=ye("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:r,topic:u,error:$,encodeOpts:h}),new Error($.message)}n.addTrace(Ls.cacaos_verified);const{p:y}=g,v=dn(y.resources),E=[To(y.iss)],N=In(y.iss);if(v){const $=cc(v),O=lc(v);d.push(...$),E.push(...O)}for(const $ of E)f.push(`${$}:${N}`)}const m=await this.client.core.crypto.generateSharedKey(l,c);n.addTrace(Ls.create_authenticated_session_topic);let w;if(d?.length>0){w={topic:m,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:Be(hr),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Rc([...new Set(d)],[...new Set(f)]),transportType:a},n.addTrace(Ls.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(m,{transportType:a})}catch(g){throw n.setError(ii.subscribe_authenticated_session_topic_failure),g}n.addTrace(Ls.subscribe_authenticated_session_topic_success),await this.client.session.set(m,w),n.addTrace(Ls.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Ls.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(g){throw n.setError(ii.authenticated_session_approve_publish_failure),g}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:w}}),_(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===Pe.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=pn(o),l={type:ds,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:c,error:i,encodeOpts:l,rpcOpts:We.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,ye("USER_DISCONNECTED"))}),_(this,"formatAuthMessage",s=>{this.isInitialized();const{request:r,iss:i}=s;return Tu(r,i)}),_(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)}),_(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)}}),_(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,ye("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(ul).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,ye("USER_DISCONNECTED"))}),i===((r=this.sessionRequestQueue.queue[0])==null?void 0:r.topic)&&(this.sessionRequestQueue.state=Gt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})}),_(this,"deleteProposal",async(s,r)=>{if(r)try{const i=this.client.proposal.get(s);this.client.core.eventClient.getEvent({topic:i.pairingTopic})?.setError(Ds.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,ye("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")}),_(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=Gt.idle,this.client.events.emit("session_request_expire",{id:s}))}),_(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)])}),_(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}))}),_(this,"setProposal",async(s,r)=>{this.client.core.expirer.set(s,Be(We.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,r)}),_(this,"setAuthRequest",async(s,r)=>{const{request:i,pairingTopic:n,transportType:o=Pe.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})}),_(this,"setPendingSessionRequest",async s=>{const{id:r,topic:i,params:n,verifyContext:o}=s,a=n.request.expiryTimestamp||Be(We.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})}),_(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=zs(i,n,c);let f;const m=!!u;try{const y=m?Es:Wt;f=await this.client.core.crypto.encode(r,d,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),y}let w;if(L0.includes(i)){const y=Zt(JSON.stringify(d)),v=Zt(f);w=await this.client.core.verify.register({id:v,decryptedId:y})}const g=We[i].req;if(g.attestation=w,o&&(g.ttl=o),a&&(g.id=a),this.client.core.history.set(r,d),m){const y=Qi(u,r,f);await Q.Linking.openURL(y,this.client.name)}else{const y=We[i].req;o&&(y.ttl=o),a&&(y.id=a),y.tvf=ot(Ce({},h),{correlationId:d.id}),l?(y.internal=ot(Ce({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,f,y)):this.client.core.relayer.publish(r,f,y).catch(v=>this.client.logger.error(v))}return d.id}),_(this,"sendResult",async s=>{const{id:r,topic:i,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=Tn(r,n);let u;const h=c&&typeof(Q==null?void 0:Q.Linking)<"u";try{const m=h?Es:Wt;u=await this.client.core.crypto.encode(i,l,ot(Ce({},a||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),m}let d,f;try{d=await this.client.core.history.get(i,r);const m=d.request;try{this.shouldSetTVF(m.method,m.params)&&(f=this.getTVFParams(r,m.params,n))}catch(w){this.client.logger.warn("sendResult() -> getTVFParams() failed",w)}}catch(m){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${r}) failed`),m}if(h){const m=Qi(c,i,u);await Q.Linking.openURL(m,this.client.name)}else{const m=d.request.method,w=We[m].res;w.tvf=ot(Ce({},f),{correlationId:r}),o?(w.internal=ot(Ce({},w.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,w)):this.client.core.relayer.publish(i,u,w).catch(g=>this.client.logger.error(g))}await this.client.core.history.resolve(l)}),_(this,"sendError",async s=>{const{id:r,topic:i,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=zl(r,n);let u;const h=c&&typeof(Q==null?void 0:Q.Linking)<"u";try{const f=h?Es:Wt;u=await this.client.core.crypto.encode(i,l,ot(Ce({},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=Qi(c,i,u);await Q.Linking.openURL(f,this.client.name)}else{const f=d.request.method,m=a||We[f].res;this.client.core.relayer.publish(i,u,m)}await this.client.core.history.resolve(l)}),_(this,"cleanup",async()=>{const s=[],r=[];this.client.session.getAll().forEach(i=>{let n=!1;bs(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=>{bs(i.expiryTimestamp)&&r.push(i.id)}),await Promise.all([...s.map(i=>this.deleteSession({topic:i})),...r.map(i=>this.deleteProposal(i))])}),_(this,"onProviderMessageEvent",async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)}),_(this,"onRelayEventRequest",async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()}),_(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Gt.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=Gt.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(r){this.client.logger.warn(r)}}this.requestQueue.state=Gt.idle}),_(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}`)}}),_(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}`)}}),_(this,"onRelayEventUnknownPayload",s=>{const{topic:r}=s,{message:i}=R("MISSING_OR_INVALID",`Decoded payload on topic ${r} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),_(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)}),_(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?.setError(cs.proposal_listener_not_found)),this.isValidConnect(Ce({},i.params));const u=a.expiryTimestamp||Be(We.wc_sessionPropose.req.ttl),h=Ce({id:c,pairingTopic:r,expiryTimestamp:u},a);await this.setProposal(c,h);const d=await this.getVerifyContext({attestationId:n,hash:Zt(JSON.stringify(i)),encryptedId:o,metadata:h.proposer.metadata});l?.addTrace(Jt.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:We.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),_(this,"onSessionProposeResponse",async(s,r,i)=>{const{id:n}=r;if(as(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(Yt(r)){await this.client.proposal.delete(n,ye("USER_DISCONNECTED"));const o=fe("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})}}),_(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(g=>g.sessionTopic===s);if(!f)return this.client.logger.error(`Pending session not found for topic ${s}`);const m=this.client.proposal.get(f.proposalId),w=ot(Ce(Ce(Ce({topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:m.requiredNamespaces,optionalNamespaces:m.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:Pe.relay});await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:w.peer.metadata}),this.client.events.emit("session_connect",{session:w}),this.events.emit(fe("session_connect",f.proposalId),{session:w}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(w),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)}}),_(this,"onSessionSettleResponse",async(s,r)=>{const{id:i}=r;as(r)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(fe("session_approve",i),{})):Yt(r)&&(await this.client.session.delete(s,ye("USER_DISCONNECTED")),this.events.emit(fe("session_approve",i),{error:r.error}))}),_(this,"onSessionUpdateRequest",async(s,r)=>{const{params:i,id:n}=r;try{const o=`${s}_session_update`,a=si.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:ye("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ce({topic:s},i));try{si.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 si.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)}}),_(this,"isRequestOutOfSync",(s,r)=>r.toString().slice(0,-3)<s.toString().slice(0,-3)),_(this,"onSessionUpdateResponse",(s,r)=>{const{id:i}=r,n=fe("session_update",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);as(r)?this.events.emit(fe("session_update",i),{}):Yt(r)&&this.events.emit(fe("session_update",i),{error:r.error})}),_(this,"onSessionExtendRequest",async(s,r)=>{const{id:i}=r;try{this.isValidExtend({topic:s}),await this.setExpiry(s,Be(hr)),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)}}),_(this,"onSessionExtendResponse",(s,r)=>{const{id:i}=r,n=fe("session_extend",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);as(r)?this.events.emit(fe("session_extend",i),{}):Yt(r)&&this.events.emit(fe("session_extend",i),{error:r.error})}),_(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)}}),_(this,"onSessionPingResponse",(s,r)=>{const{id:i}=r,n=fe("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);as(r)?this.events.emit(fe("session_ping",i),{}):Yt(r)&&this.events.emit(fe("session_ping",i),{error:r.error})},500)}),_(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:ye("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),_(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(Ce({topic:o},d));const f=this.client.session.get(o),m=await this.getVerifyContext({attestationId:c,hash:Zt(JSON.stringify(zs("wc_sessionRequest",d,h))),encryptedId:l,metadata:f.peer.metadata,transportType:u}),w={id:h,topic:o,params:d,verifyContext:m};await this.setPendingSessionRequest(w),u===Pe.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(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue())}catch(f){await this.sendError({id:h,topic:o,error:f}),this.client.logger.error(f)}}),_(this,"onSessionRequestResponse",(s,r)=>{const{id:i}=r,n=fe("session_request",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);as(r)?this.events.emit(fe("session_request",i),{result:r.result}):Yt(r)&&this.events.emit(fe("session_request",i),{error:r.error})}),_(this,"onSessionEventRequest",async(s,r)=>{const{id:i,params:n}=r;try{const o=`${s}_session_event_${n.event.name}`,a=si.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(Ce({topic:s},n)),this.client.events.emit("session_event",{id:i,topic:s,params:n}),si.set(o,i)}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),_(this,"onSessionAuthenticateResponse",(s,r)=>{const{id:i}=r;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:r}),as(r)?this.events.emit(fe("session_request",i),{result:r.result}):Yt(r)&&this.events.emit(fe("session_request",i),{error:r.error})}),_(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:Zt(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===Pe.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:ds,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:n.id,topic:i,error:l,encodeOpts:f,rpcOpts:We.wc_sessionAuthenticate.autoReject,appLink:d})}}),_(this,"addSessionRequestToSessionRequestQueue",s=>{this.sessionRequestQueue.queue.push(s)}),_(this,"cleanupAfterResponse",s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Gt.idle,this.processSessionRequestQueue()},U.toMiliseconds(this.requestQueueDelay))}),_(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=fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(fe("session_request",n.request.id),{error:r})})}),_(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Gt.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=Gt.active,this.emitSessionRequest(s)}catch(r){this.client.logger.error(r)}}),_(this,"emitSessionRequest",s=>{this.client.events.emit("session_request",s)}),_(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:zs("wc_sessionPropose",ot(Ce({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces,relays:r.relays,proposer:r.proposer,sessionProperties:r.sessionProperties,scopedProperties:r.scopedProperties}),r.id)})}),_(this,"isValidConnect",async s=>{if(!gt(s)){const{message:l}=R("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(rt(r)||await this.isValidPairingTopic(r),!kw(c)){const{message:l}=R("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!rt(i)&&Os(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(!rt(n)&&Os(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),rt(o)||this.validateSessionProps(o,"sessionProperties"),!rt(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)}`)}}),_(this,"validateNamespaces",(s,r)=>{const i=Tw(s,"connect()",r);if(i)throw new Error(i.message)}),_(this,"isValidApprove",async s=>{if(!gt(s))throw new Error(R("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=ao(i,"approve()");if(l)throw new Error(l.message);const u=Lc(c.requiredNamespaces,i,"approve()");if(u)throw new Error(u.message);if(!Ue(n,!0)){const{message:h}=R("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(h)}if(rt(o)||this.validateSessionProps(o,"sessionProperties"),!rt(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(", ")}`)}}),_(this,"isValidReject",async s=>{if(!gt(s)){const{message:n}=R("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(n)}const{id:r,reason:i}=s;if(this.checkRecentlyDeleted(r),await this.isValidProposalId(r),!xw(i)){const{message:n}=R("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(n)}}),_(this,"isValidSessionSettleRequest",s=>{if(!gt(s)){const{message:l}=R("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:r,controller:i,namespaces:n,expiry:o}=s;if(!sh(r)){const{message:l}=R("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=Nw(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=ao(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(bs(o)){const{message:l}=R("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),_(this,"isValidUpdate",async s=>{if(!gt(s)){const{message:c}=R("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=ao(i,"update()");if(o)throw new Error(o.message);const a=Lc(n.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)}),_(this,"isValidExtend",async s=>{if(!gt(s)){const{message:i}=R("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(i)}const{topic:r}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r)}),_(this,"isValidRequest",async s=>{if(!gt(s)){const{message:c}=R("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(!Dc(a,n)){const{message:c}=R("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!Rw(i)){const{message:c}=R("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!Lw(a,n,i.method)){const{message:c}=R("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}if(o&&!qw(o,go)){const{message:c}=R("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${go.min} and ${go.max}`);throw new Error(c)}}),_(this,"isValidRespond",async s=>{var r;if(!gt(s)){const{message:o}=R("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?.response)!=null&&r.id&&this.cleanupAfterResponse(s),o}if(!Uw(n)){const{message:o}=R("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),_(this,"isValidPing",async s=>{if(!gt(s)){const{message:i}=R("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),_(this,"isValidEmit",async s=>{if(!gt(s)){const{message:a}=R("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(!Dc(o,n)){const{message:a}=R("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!Dw(i)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!Mw(o,n,i.name)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}}),_(this,"isValidDisconnect",async s=>{if(!gt(s)){const{message:i}=R("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),_(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(!Ue(i,!1))throw new Error("uri is required parameter");if(!Ue(n,!1))throw new Error("domain is required parameter");if(!Ue(o,!1))throw new Error("nonce is required parameter");if([...new Set(r.map(c=>xr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=xr(r[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),_(this,"getVerifyContext",async s=>{const{attestationId:r,hash:i,encryptedId:n,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||bi,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Pe.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}),_(this,"validateSessionProps",(s,r)=>{Object.values(s).forEach((i,n)=>{if(i==null){const{message:o}=R("MISSING_OR_INVALID",`${r} must contain an existing value for each key. Received: ${i} for key ${Object.keys(s)[n]}`);throw new Error(o)}})}),_(this,"getPendingAuthRequest",s=>{const r=this.client.auth.requests.get(s);return typeof r=="object"?r:void 0}),_(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)}}}),_(this,"checkRecentlyDeleted",s=>{const r=this.recentlyDeletedMap.get(s);if(r){const{message:i}=R("MISSING_OR_INVALID",`Record was recently deleted - ${r}: ${s}`);throw new Error(i)}}),_(this,"isLinkModeEnabled",(s,r)=>{var i,n,o,a,c,l,u,h,d;return!s||r!==Pe.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?.redirect)==null?void 0:u.universal)!==void 0&&((h=s?.redirect)==null?void 0:h.universal)!==""&&((d=s?.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(Q==null?void 0:Q.Linking)<"u"}),_(this,"getAppLinkIfEnabled",(s,r)=>{var i;return this.isLinkModeEnabled(s,r)?(i=s?.redirect)==null?void 0:i.universal:void 0}),_(this,"handleLinkModeMessage",({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const r=Za(s,"topic")||"",i=decodeURIComponent(Za(s,"wc_ev")||""),n=this.client.session.keys.includes(r);n&&this.client.session.update(r,{transportType:Pe.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:i,sessionExists:n})}),_(this,"registerLinkModeListeners",async()=>{var s;if(ca()||xs()&&(s=this.client.metadata.redirect)!=null&&s.linkMode){const r=Q==null?void 0:Q.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)}}}),_(this,"shouldSetTVF",(s,r)=>{if(!r||s!=="wc_sessionRequest")return!1;const{request:i}=r;return Object.keys(dl).includes(i.method)}),_(this,"getTVFParams",(s,r,i)=>{var n,o;try{const a=r.request.method,c=this.extractTxHashesFromResult(a,i);return ot(Ce({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{}}),_(this,"isValidContractData",s=>{var r;if(!s)return!1;try{const i=s?.data||((r=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}),_(this,"extractTxHashesFromResult",(s,r)=>{try{const i=dl[s];if(typeof r=="string")return[r];const n=r[i.key];if(Ps(n))return s==="solana_signAllTransactions"?n.map(o=>ag(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}=R("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(gn)?this.client.auth.authKeys.get(gn):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,r,{receiverPublicKey:o,encoding:n===Pe.link_mode?Es:Wt});ia(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:i,transportType:n,encryptedId:Zt(r)})):na(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(xt.expired,async e=>{const{topic:s,id:r}=Eu(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,R("EXPIRED"),!0);if(r&&this.client.auth.requests.keys.includes(r))return await this.deletePendingAuthRequest(r,R("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(Ws.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Ws.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ue(e,!1)){const{message:s}=R("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}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(bs(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=R("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!Ue(e,!1)){const{message:s}=R("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}=R("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(bs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=R("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=R("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(Ue(e,!1)){const{message:s}=R("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=R("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!$w(e)){const{message:s}=R("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=R("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(bs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=R("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}}class J0 extends ir{constructor(e,s){super(e,s,x0,ma),this.core=e,this.logger=s}}let Y0=class extends ir{constructor(e,s){super(e,s,R0,ma),this.core=e,this.logger=s}};class X0 extends ir{constructor(e,s){super(e,s,D0,ma,r=>r.id),this.core=e,this.logger=s}}class Z0 extends ir{constructor(e,s){super(e,s,j0,qn,()=>gn),this.core=e,this.logger=s}}class Q0 extends ir{constructor(e,s){super(e,s,q0,qn),this.core=e,this.logger=s}}class eE extends ir{constructor(e,s){super(e,s,F0,qn,r=>r.id),this.core=e,this.logger=s}}var tE=Object.defineProperty,sE=(t,e,s)=>e in t?tE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,mo=(t,e,s)=>sE(t,typeof e!="symbol"?e+"":e,s);class rE{constructor(e,s){this.core=e,this.logger=s,mo(this,"authKeys"),mo(this,"pairingTopics"),mo(this,"requests"),this.authKeys=new Z0(this.core,this.logger),this.pairingTopics=new Q0(this.core,this.logger),this.requests=new eE(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var iE=Object.defineProperty,nE=(t,e,s)=>e in t?iE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,oe=(t,e,s)=>nE(t,typeof e!="symbol"?e+"":e,s);let oE=class Ch extends sf{constructor(e){super(e),oe(this,"protocol",vh),oe(this,"version",bh),oe(this,"name",fo.name),oe(this,"metadata"),oe(this,"core"),oe(this,"logger"),oe(this,"events",new $s.EventEmitter),oe(this,"engine"),oe(this,"session"),oe(this,"proposal"),oe(this,"pendingRequest"),oe(this,"auth"),oe(this,"signConfig"),oe(this,"on",(r,i)=>this.events.on(r,i)),oe(this,"once",(r,i)=>this.events.once(r,i)),oe(this,"off",(r,i)=>this.events.off(r,i)),oe(this,"removeListener",(r,i)=>this.events.removeListener(r,i)),oe(this,"removeAllListeners",r=>this.events.removeAllListeners(r)),oe(this,"connect",async r=>{try{return await this.engine.connect(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"pair",async r=>{try{return await this.engine.pair(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"approve",async r=>{try{return await this.engine.approve(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"reject",async r=>{try{return await this.engine.reject(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"update",async r=>{try{return await this.engine.update(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"extend",async r=>{try{return await this.engine.extend(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"request",async r=>{try{return await this.engine.request(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"respond",async r=>{try{return await this.engine.respond(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"ping",async r=>{try{return await this.engine.ping(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"emit",async r=>{try{return await this.engine.emit(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"disconnect",async r=>{try{return await this.engine.disconnect(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"find",r=>{try{return this.engine.find(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(r){throw this.logger.error(r.message),r}}),oe(this,"authenticate",async(r,i)=>{try{return await this.engine.authenticate(r,i)}catch(n){throw this.logger.error(n.message),n}}),oe(this,"formatAuthMessage",r=>{try{return this.engine.formatAuthMessage(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"approveSessionAuthenticate",async r=>{try{return await this.engine.approveSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"rejectSessionAuthenticate",async r=>{try{return await this.engine.rejectSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),this.name=e?.name||fo.name,this.metadata=bf(e?.metadata),this.signConfig=e?.signConfig;const s=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ra(xi({level:e?.logger||fo.logger}));this.core=e?.core||new $0(e),this.logger=ct(s,this.name),this.session=new Y0(this.core,this.logger),this.proposal=new J0(this.core,this.logger),this.pendingRequest=new X0(this.core,this.logger),this.engine=new G0(this),this.auth=new rE(this.core,this.logger)}static async init(e){const s=new Ch(e);return await s.initialize(),s}get context(){return At(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()},U.toMiliseconds(U.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const fl="error",aE="wss://relay.walletconnect.org",cE="wc",lE="universal_provider",tn=`${cE}@2:${lE}:`,Ih="https://rpc.walletconnect.org/v1/",Nr="generic",uE=`${Ih}bundler`,Dt={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function hE(){}function wa(t){return t==null||typeof t!="object"&&typeof t!="function"}function ya(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function dE(t){if(wa(t))return t;if(Array.isArray(t)||ya(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 gl(t){return typeof t=="object"&&t!==null}function Nh(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function _h(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const pE="[object RegExp]",Ah="[object String]",Sh="[object Number]",Ph="[object Boolean]",Oh="[object Arguments]",fE="[object Symbol]",gE="[object Date]",mE="[object Map]",wE="[object Set]",yE="[object Array]",vE="[object ArrayBuffer]",bE="[object Object]",EE="[object DataView]",CE="[object Uint8Array]",IE="[object Uint8ClampedArray]",NE="[object Uint16Array]",_E="[object Uint32Array]",AE="[object Int8Array]",SE="[object Int16Array]",PE="[object Int32Array]",OE="[object Float32Array]",TE="[object Float64Array]";function kE(t,e){return Tr(t,void 0,t,new Map,e)}function Tr(t,e,s,r=new Map,i=void 0){const n=i?.(t,e,s,r);if(n!=null)return n;if(wa(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]=Tr(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,Tr(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(Tr(a,void 0,s,r,i));return o}if(typeof Ye<"u"&&Ye.isBuffer(t))return t.subarray();if(ya(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=Tr(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),Hs(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),Hs(o,t,s,r,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return r.set(t,o),Hs(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,Hs(o,t,s,r,i),o}if(typeof t=="object"&&$E(t)){const o=Object.create(Object.getPrototypeOf(t));return r.set(t,o),Hs(o,t,s,r,i),o}return t}function Hs(t,e,s=t,r,i){const n=[...Object.keys(e),...Nh(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Tr(e[a],a,s,r,i))}}function $E(t){switch(_h(t)){case Oh:case yE:case vE:case EE:case Ph:case gE:case OE:case TE:case AE:case SE:case PE:case mE:case Sh:case bE:case pE:case wE:case Ah:case fE:case CE:case IE:case NE:case _E:return!0;default:return!1}}function xE(t,e){return kE(t,(s,r,i,n)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case Sh:case Ah:case Ph:{const o=new t.constructor(t?.valueOf());return Hs(o,t),o}case Oh:{const o={};return Hs(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function ml(t){return xE(t)}function wl(t){return t!==null&&typeof t=="object"&&_h(t)==="[object Arguments]"}function RE(t){return ya(t)}function UE(t){if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const s=t[Symbol.toStringTag];return s==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?!1:t.toString()===`[object ${s}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function DE(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=Xo(i,o,r,new Map)}return i}function Xo(t,e,s,r){if(wa(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(r.has(e))return dE(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),...Nh(e)];for(let n=0;n<i.length;n++){const o=i[n];let a=e[o],c=t[o];if(wl(a)&&(a={...a}),wl(c)&&(c={...c}),typeof Ye<"u"&&Ye.isBuffer(a)&&(a=ml(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)||gl(c)&&gl(a)?t[o]=Xo(c,a,s,r):c==null&&UE(a)?t[o]=Xo({},a,s,r):c==null&&RE(a)?t[o]=ml(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function LE(t,...e){return DE(t,...e,hE)}var ME=Object.defineProperty,BE=Object.defineProperties,jE=Object.getOwnPropertyDescriptors,yl=Object.getOwnPropertySymbols,qE=Object.prototype.hasOwnProperty,FE=Object.prototype.propertyIsEnumerable,vl=(t,e,s)=>e in t?ME(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,sn=(t,e)=>{for(var s in e||(e={}))qE.call(e,s)&&vl(t,s,e[s]);if(yl)for(var s of yl(e))FE.call(e,s)&&vl(t,s,e[s]);return t},WE=(t,e)=>BE(t,jE(e));function _t(t,e,s){var r;const i=xr(t);return((r=e.rpcMap)==null?void 0:r[i.reference])||`${Ih}?chainId=${i.namespace}:${i.reference}&projectId=${s}`}function nr(t){return t.includes(":")?t.split(":")[1]:t}function Th(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function HE(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 rn(t={},e={}){const s=bl(t),r=bl(e);return LE(s,r)}function bl(t){var e,s,r,i,n;const o={};if(!Os(t))return o;for(const[a,c]of Object.entries(t)){const l=Bn(a)?[a]:c.chains,u=c.methods||[],h=c.events||[],d=c.rpcMap||{},f=Or(a);o[f]=WE(sn(sn({},o[f]),c),{chains:es(l,(e=o[f])==null?void 0:e.chains),methods:es(u,(s=o[f])==null?void 0:s.methods),events:es(h,(r=o[f])==null?void 0:r.events)}),(Os(d)||Os(((i=o[f])==null?void 0:i.rpcMap)||{}))&&(o[f].rpcMap=sn(sn({},d),(n=o[f])==null?void 0:n.rpcMap))}return o}function El(t){return t.includes(":")?t.split(":")[2]:t}function Cl(t){const e={};for(const[s,r]of Object.entries(t)){const i=r.methods||[],n=r.events||[],o=r.accounts||[],a=Bn(s)?[s]:r.chains?r.chains:Th(r.accounts);e[s]={chains:a,methods:i,events:n,accounts:o}}return e}function wo(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 kh={},he=t=>kh[t],yo=(t,e)=>{kh[t]=e};var zE=Object.defineProperty,VE=(t,e,s)=>e in t?zE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,dr=(t,e,s)=>VE(t,typeof e!="symbol"?e+"":e,s);class KE{constructor(e){dr(this,"name","polkadot"),dr(this,"client"),dr(this,"httpProviders"),dr(this,"events"),dr(this,"namespace"),dr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var GE=Object.defineProperty,JE=Object.defineProperties,YE=Object.getOwnPropertyDescriptors,Il=Object.getOwnPropertySymbols,XE=Object.prototype.hasOwnProperty,ZE=Object.prototype.propertyIsEnumerable,Zo=(t,e,s)=>e in t?GE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Nl=(t,e)=>{for(var s in e||(e={}))XE.call(e,s)&&Zo(t,s,e[s]);if(Il)for(var s of Il(e))ZE.call(e,s)&&Zo(t,s,e[s]);return t},_l=(t,e)=>JE(t,YE(e)),pr=(t,e,s)=>Zo(t,typeof e!="symbol"?e+"":e,s);class QE{constructor(e){pr(this,"name","eip155"),pr(this,"client"),pr(this,"chainId"),pr(this,"namespace"),pr(this,"httpProviders"),pr(this,"events"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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||_t(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("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(nr(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?.sessionProperties)==null?void 0:o.capabilities)||{};if(h!=null&&h[l])return h?.[l];const d=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:_l(Nl({},u.sessionProperties||{}),{capabilities:_l(Nl({},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(zs("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`${uE}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}}var eC=Object.defineProperty,tC=(t,e,s)=>e in t?eC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,fr=(t,e,s)=>tC(t,typeof e!="symbol"?e+"":e,s);class sC{constructor(e){fr(this,"name","solana"),fr(this,"client"),fr(this,"httpProviders"),fr(this,"events"),fr(this,"namespace"),fr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var rC=Object.defineProperty,iC=(t,e,s)=>e in t?rC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,gr=(t,e,s)=>iC(t,typeof e!="symbol"?e+"":e,s);class nC{constructor(e){gr(this,"name","cosmos"),gr(this,"client"),gr(this,"httpProviders"),gr(this,"events"),gr(this,"namespace"),gr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var oC=Object.defineProperty,aC=(t,e,s)=>e in t?oC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,mr=(t,e,s)=>aC(t,typeof e!="symbol"?e+"":e,s);class cC{constructor(e){mr(this,"name","algorand"),mr(this,"client"),mr(this,"httpProviders"),mr(this,"events"),mr(this,"namespace"),mr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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||_t(`${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(Dt.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||_t(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ut(new Ht(r,he("disableProviderPing")))}}var lC=Object.defineProperty,uC=(t,e,s)=>e in t?lC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,wr=(t,e,s)=>uC(t,typeof e!="symbol"?e+"":e,s);class hC{constructor(e){wr(this,"name","cip34"),wr(this,"client"),wr(this,"httpProviders"),wr(this,"events"),wr(this,"namespace"),wr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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 Ut(new Ht(r,he("disableProviderPing")))}}var dC=Object.defineProperty,pC=(t,e,s)=>e in t?dC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,yr=(t,e,s)=>pC(t,typeof e!="symbol"?e+"":e,s);class fC{constructor(e){yr(this,"name","elrond"),yr(this,"client"),yr(this,"httpProviders"),yr(this,"events"),yr(this,"namespace"),yr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var gC=Object.defineProperty,mC=(t,e,s)=>e in t?gC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vr=(t,e,s)=>mC(t,typeof e!="symbol"?e+"":e,s);class wC{constructor(e){vr(this,"name","multiversx"),vr(this,"client"),vr(this,"httpProviders"),vr(this,"events"),vr(this,"namespace"),vr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=nr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var yC=Object.defineProperty,vC=(t,e,s)=>e in t?yC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,br=(t,e,s)=>vC(t,typeof e!="symbol"?e+"":e,s);class bC{constructor(e){br(this,"name","near"),br(this,"client"),br(this,"httpProviders"),br(this,"events"),br(this,"namespace"),br(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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||_t(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Dt.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||_t(e,this.namespace);return typeof r>"u"?void 0:new Ut(new Ht(r,he("disableProviderPing")))}}var EC=Object.defineProperty,CC=(t,e,s)=>e in t?EC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Er=(t,e,s)=>CC(t,typeof e!="symbol"?e+"":e,s);class IC{constructor(e){Er(this,"name","tezos"),Er(this,"client"),Er(this,"httpProviders"),Er(this,"events"),Er(this,"namespace"),Er(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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||_t(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Dt.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||_t(e,this.namespace);return typeof r>"u"?void 0:new Ut(new Ht(r))}}var NC=Object.defineProperty,_C=(t,e,s)=>e in t?NC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Cr=(t,e,s)=>_C(t,typeof e!="symbol"?e+"":e,s);class AC{constructor(e){Cr(this,"name",Nr),Cr(this,"client"),Cr(this,"httpProviders"),Cr(this,"events"),Cr(this,"namespace"),Cr(this,"chainId"),this.namespace=e.namespace,this.events=he("events"),this.client=he("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(Dt.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=xr(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||_t(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ut(new Ht(r,he("disableProviderPing")))}}var SC=Object.defineProperty,PC=Object.defineProperties,OC=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,TC=Object.prototype.hasOwnProperty,kC=Object.prototype.propertyIsEnumerable,Qo=(t,e,s)=>e in t?SC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,nn=(t,e)=>{for(var s in e||(e={}))TC.call(e,s)&&Qo(t,s,e[s]);if(Al)for(var s of Al(e))kC.call(e,s)&&Qo(t,s,e[s]);return t},vo=(t,e)=>PC(t,OC(e)),kt=(t,e,s)=>Qo(t,typeof e!="symbol"?e+"":e,s);let $C=class $h{constructor(e){kt(this,"client"),kt(this,"namespaces"),kt(this,"optionalNamespaces"),kt(this,"sessionProperties"),kt(this,"scopedProperties"),kt(this,"events",new aa),kt(this,"rpcProviders",{}),kt(this,"session"),kt(this,"providerOpts"),kt(this,"logger"),kt(this,"uri"),kt(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ra(xi({level:e?.logger||fl})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const s=new $h(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:nn({},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,Tn(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:ye("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=Cl(this.session.namespaces);this.namespaces=rn(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=Cl(i.namespaces);return this.namespaces=rn(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===Nr?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(Ps(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 oE.init({core:this.providerOpts.core,logger:this.providerOpts.logger||fl,relayUrl:this.providerOpts.relayUrl||aE,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=>Or(s)))];yo("client",this.client),yo("events",this.events),yo("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const r=HE(s,this.session),i=Th(r),n=rn(this.namespaces,this.optionalNamespaces),o=vo(nn({},n[s]),{accounts:r,chains:i});switch(s){case"eip155":this.rpcProviders[s]=new QE({namespace:o});break;case"algorand":this.rpcProviders[s]=new cC({namespace:o});break;case"solana":this.rpcProviders[s]=new sC({namespace:o});break;case"cosmos":this.rpcProviders[s]=new nC({namespace:o});break;case"polkadot":this.rpcProviders[s]=new KE({namespace:o});break;case"cip34":this.rpcProviders[s]=new hC({namespace:o});break;case"elrond":this.rpcProviders[s]=new fC({namespace:o});break;case"multiversx":this.rpcProviders[s]=new wC({namespace:o});break;case"near":this.rpcProviders[s]=new bC({namespace:o});break;case"tezos":this.rpcProviders[s]=new IC({namespace:o});break;default:this.rpcProviders[Nr]?this.rpcProviders[Nr].updateNamespace(o):this.rpcProviders[Nr]=new AC({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&&Ps(o)&&this.events.emit("accountsChanged",o.map(El))}else if(n.name==="chainChanged"){const o=r.chainId,a=r.event.data,c=Or(o),l=wo(o)!==wo(a)?`${c}:${wo(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=vo(nn({},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",vo(nn({},ye("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Dt.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Nr]}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=rn(s,r),this.sessionProperties=i,this.scopedProperties=n}validateChain(e){const[s,r]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,r];if(s&&!Object.keys(this.namespaces||{}).map(o=>Or(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=Or(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(El);if(!Ps(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(`${tn}/${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(`${tn}/${e}${r}`)}async deleteFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${tn}/${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(tn)&&await this.client.core.storage.removeItem(r)}catch(s){this.logger.warn("Failed to cleanup storage",s)}}};function on(t,e){return q.getConnectorId(t)===e}function xC(t){const e=Array.from(p.state.chains.keys());let s=[];return t?(s.push([t,p.state.chains.get(t)]),on(t,j.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(r=>{r!==t&&on(r,j.CONNECTOR_ID.WALLET_CONNECT)&&s.push([r,p.state.chains.get(r)])}):on(t,j.CONNECTOR_ID.AUTH)&&e.forEach(r=>{r!==t&&on(r,j.CONNECTOR_ID.AUTH)&&s.push([r,p.state.chains.get(r)])})):s=Array.from(p.state.chains.entries()),s}const je={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"},Sn={ConnectorExplorerIds:{[j.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[j.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[j.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[j.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[j.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[je.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[je.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[je.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[je.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[je.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[je.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[je.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[je.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[je.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[je.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[je.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},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:{[j.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[j.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[j.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[j.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[j.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[j.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[j.CONNECTOR_ID.INJECTED]:"Browser Wallet",[j.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[j.CONNECTOR_ID.COINBASE]:"Coinbase",[j.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[j.CONNECTOR_ID.LEDGER]:"Ledger",[j.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[j.CONNECTOR_ID.INJECTED]:"INJECTED",[j.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[j.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[j.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]},va={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([s,r])=>{e[`${je.EIP155}:${s}`]=r}),e},isLowerCaseMatch(t,e){return t?.toLowerCase()===e?.toLowerCase()}},RC=new AbortController,Ir={EmbeddedWalletAbortController:RC,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 ${UC()?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 UC(){return typeof window<"u"}const DC={createLogger(t,e="error"){const s=xi({level:e}),{logger:r}=Hl({opts:s});return r.error=(...i)=>{for(const n of i)if(n instanceof Error){t(n,...i);return}t(void 0,...i)},r}},LC="rpc.walletconnect.org";function Sl(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 bo=["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"],_r={extendRpcUrlWithProjectId(t,e){let s=!1;try{s=new URL(t).host===LC}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:j.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${j.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,s){const r=t.rpcUrls?.default?.http?.[0];return bo.includes(e)?Sl(e,s):r||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){const i=this.getChainNamespace(t),n=this.getCaipNetworkId(t),o=t.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(t,n,s),c=t?.rpcUrls?.chainDefault?.http?.[0]||o,l=r?.[n]?.map(d=>d.url)||[],u=[...l,a],h=[...l];return c&&!h.includes(c)&&h.push(c),{...t,chainNamespace:i,caipNetworkId:n,assets:{imageId:Sn.NetworkImageIds[t.id],imageUrl:e?.[t.id]},rpcUrls:{...t.rpcUrls,default:{http:u},chainDefault:{http:h}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){return t.map(i=>_r.extendCaipNetwork(i,{customNetworkImageUrls:e,customRpcUrls:r,projectId:s}))},getViemTransport(t,e,s){const r=[];return s?.forEach(i=>{r.push(Vi(i.url,i.config))}),bo.includes(t.caipNetworkId)&&r.push(Vi(Sl(t.caipNetworkId,e),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),t?.rpcUrls?.default?.http?.forEach(i=>{r.push(Vi(i))}),Aa(r)},extendWagmiTransports(t,e,s){if(bo.includes(t.caipNetworkId)){const r=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return Aa([s,Vi(r)])}return s},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:j.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){const e=W.getActiveCaipNetworkId(),s=p.getAllRequestedCaipNetworks(),r=Array.from(p.state.chains?.keys()||[]),i=e?.split(":")[0],n=i?r.includes(i):!1,o=s?.find(c=>c.caipNetworkId===e);return n&&!o&&e?this.getUnsupportedNetwork(e):o||t||s?.[0]}},Pn={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},pt=Oe({providers:{...Pn},providerIds:{...Pn}}),Te={state:pt,subscribeKey(t,e){return nt(pt,t,e)},subscribe(t){return it(pt,()=>{t(pt)})},subscribeProviders(t){return it(pt.providers,()=>t(pt.providers))},setProvider(t,e){e&&(pt.providers[t]=Ys(e))},getProvider(t){return pt.providers[t]},setProviderId(t,e){e&&(pt.providerIds[t]=e)},getProviderId(t){if(t)return pt.providerIds[t]},reset(){pt.providers={...Pn},pt.providerIds={...Pn}},resetChain(t){pt.providers[t]=void 0,pt.providerIds[t]=void 0}};var Pl={};const MC={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(typeof _s<"u"&&typeof Pl<"u"?Pl.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}},ea={filterOutDuplicatesByRDNS(t){const e=P.state.enableEIP6963?q.state.connectors:[],s=W.getRecentWallets(),r=e.map(a=>a.info?.rdns).filter(Boolean),i=s.map(a=>a.rdns).filter(Boolean),n=r.concat(i);if(n.includes("io.metamask.mobile")&&X.isMobile()){const a=n.indexOf("io.metamask.mobile");n[a]="io.metamask"}return t.filter(a=>!n.includes(String(a?.rdns)))},filterOutDuplicatesByIds(t){const e=q.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?.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=q.state,{featuredWalletIds:s}=P.state,r=e.filter(o=>o.type==="ANNOUNCED").reduce((o,a)=>(a.info?.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?.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){const s=t?.connectMethodsOrder||P.state.features?.connectMethodsOrder,r=e||q.state.connectors;if(s)return s;const{injected:i,announced:n}=mn.getConnectorsByType(r,V.state.recommended,V.state.featured),o=i.filter(mn.showConnector),a=n.filter(mn.showConnector);return o.length||a.length?["wallet","email","social"]:MC.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(t){const e=!!t.rdns&&V.state.excludedWallets.some(r=>r.rdns===t.rdns),s=!!t.name&&V.state.excludedWallets.some(r=>va.isLowerCaseMatch(r.name,t.name));return e||s}},mn={getConnectorsByType(t,e,s){const{customWallets:r}=P.state,i=W.getRecentWallets(),n=ea.filterOutDuplicateWallets(e),o=ea.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){const e=t.info?.rdns,s=!!e&&V.state.excludedWallets.some(i=>!!i.rdns&&i.rdns===e),r=!!t.name&&V.state.excludedWallets.some(i=>va.isLowerCaseMatch(i.name,t.name));return!(t.type==="INJECTED"&&(t.name==="Browser Wallet"&&(!X.isMobile()||X.isMobile()&&!e&&!Y.checkInstalled())||s||r)||(t.type==="ANNOUNCED"||t.type==="EXTERNAL")&&(s||r))},getIsConnectedWithWC(){return Array.from(p.state.chains.values()).some(s=>q.getConnectorId(s.namespace)===j.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:s,recent:r,announced:i,injected:n,multiChain:o,external:a,overriddenConnectors:c=P.state.features?.connectorTypeOrder??[]}){const l=mn.getIsConnectedWithWC(),d=[{type:"walletConnect",isEnabled:P.state.enableWalletConnect&&!l},{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(g=>g.isEnabled),f=new Set(d.map(g=>g.type)),m=c.filter(g=>f.has(g)).map(g=>({type:g,isEnabled:!0})),w=d.filter(({type:g})=>!m.some(({type:v})=>v===g));return Array.from(new Set([...m,...w].map(({type:g})=>g)))}};/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2019 Google LLC
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
*/const wn=globalThis,ba=wn.ShadowRoot&&(wn.ShadyCSS===void 0||wn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ea=Symbol(),Ol=new WeakMap;let xh=class{constructor(e,s,r){if(this._$cssResult$=!0,r!==Ea)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(ba&&e===void 0){const r=s!==void 0&&s.length===1;r&&(e=Ol.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Ol.set(s,e))}return e}toString(){return this.cssText}};const $t=t=>new xh(typeof t=="string"?t:t+"",void 0,Ea),Rr=(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 xh(s,t,Ea)},BC=(t,e)=>{if(ba)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const r=document.createElement("style"),i=wn.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=s.cssText,t.appendChild(r)}},Tl=ba?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const r of e.cssRules)s+=r.cssText;return $t(s)})(t):t;/**
|
|
18
|
+
* @license
|
|
19
|
+
* Copyright 2017 Google LLC
|
|
20
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
+
*/const{is:jC,defineProperty:qC,getOwnPropertyDescriptor:FC,getOwnPropertyNames:WC,getOwnPropertySymbols:HC,getPrototypeOf:zC}=Object,Fn=globalThis,kl=Fn.trustedTypes,VC=kl?kl.emptyScript:"",KC=Fn.reactiveElementPolyfillSupport,Ci=(t,e)=>t,ta={toAttribute(t,e){switch(e){case Boolean:t=t?VC: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}},Rh=(t,e)=>!jC(t,e),$l={attribute:!0,type:String,converter:ta,reflect:!1,useDefault:!1,hasChanged:Rh};Symbol.metadata??=Symbol("metadata"),Fn.litPropertyMetadata??=new WeakMap;let Ar=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,s=$l){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&&qC(this.prototype,e,i)}}static getPropertyDescriptor(e,s,r){const{get:i,set:n}=FC(this.prototype,e)??{get(){return this[s]},set(o){this[s]=o}};return{get:i,set(o){const a=i?.call(this);n?.call(this,o),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??$l}static _$Ei(){if(this.hasOwnProperty(Ci("elementProperties")))return;const e=zC(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ci("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ci("properties"))){const s=this.properties,r=[...WC(s),...HC(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(Tl(i))}else e!==void 0&&s.push(Tl(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(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.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 BC(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,s,r){this._$AK(e,r)}_$ET(e,s){const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const n=(r.converter?.toAttribute!==void 0?r.converter:ta).toAttribute(s,r.type);this._$Em=e,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(e,s){const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const n=r.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:ta;this._$Em=i;const a=o.fromAttribute(s,n.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(e,s,r,i=!1,n){if(e!==void 0){const o=this.constructor;if(i===!1&&(n=this[e]),r??=o.getPropertyOptions(e),!((r.hasChanged??Rh)(n,s)||r.useDefault&&r.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(o._$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??=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??=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(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[i,n]of r){const{wrapped:o}=n,a=this[i];o!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,n,a)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(s)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(s)}willUpdate(e){}_$AE(e){this._$EO?.forEach(s=>s.hostUpdated?.()),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.forEach(s=>this._$ET(s,this[s])),this._$EM()}updated(e){}firstUpdated(e){}};Ar.elementStyles=[],Ar.shadowRootOptions={mode:"open"},Ar[Ci("elementProperties")]=new Map,Ar[Ci("finalized")]=new Map,KC?.({ReactiveElement:Ar}),(Fn.reactiveElementVersions??=[]).push("2.1.2");/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const Ca=globalThis,xl=t=>t,On=Ca.trustedTypes,Rl=On?On.createPolicy("lit-html",{createHTML:t=>t}):void 0,Uh="$lit$",Cs=`lit$${Math.random().toFixed(9).slice(2)}$`,Dh="?"+Cs,GC=`<${Dh}>`,er=document,Ti=()=>er.createComment(""),ki=t=>t===null||typeof t!="object"&&typeof t!="function",Ia=Array.isArray,JC=t=>Ia(t)||typeof t?.[Symbol.iterator]=="function",Eo=`[
|
|
26
|
+
\f\r]`,ai=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ul=/-->/g,Dl=/>/g,Ms=RegExp(`>|${Eo}(?:([^\\s"'>=/]+)(${Eo}*=${Eo}*(?:[^
|
|
27
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ll=/'/g,Ml=/"/g,Lh=/^(?:script|style|textarea|title)$/i,Mh=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),q1=Mh(1),F1=Mh(2),zr=Symbol.for("lit-noChange"),Ke=Symbol.for("lit-nothing"),Bl=new WeakMap,Ks=er.createTreeWalker(er,129);function Bh(t,e){if(!Ia(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Rl!==void 0?Rl.createHTML(e):e}const YC=(t,e)=>{const s=t.length-1,r=[];let i,n=e===2?"<svg>":e===3?"<math>":"",o=ai;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===ai?u[1]==="!--"?o=Ul:u[1]!==void 0?o=Dl:u[2]!==void 0?(Lh.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Ms):u[3]!==void 0&&(o=Ms):o===Ms?u[0]===">"?(o=i??ai,h=-1):u[1]===void 0?h=-2:(h=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?Ms:u[3]==='"'?Ml:Ll):o===Ml||o===Ll?o=Ms:o===Ul||o===Dl?o=ai:(o=Ms,i=void 0);const f=o===Ms&&t[a+1].startsWith("/>")?" ":"";n+=o===ai?c+GC:h>=0?(r.push(l),c.slice(0,h)+Uh+c.slice(h)+Cs+f):c+Cs+(h===-2?a:f)}return[Bh(t,n+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class $i{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]=YC(e,s);if(this.el=$i.createElement(l,r),Ks.currentNode=this.el.content,s===2||s===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=Ks.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const h of i.getAttributeNames())if(h.endsWith(Uh)){const d=u[o++],f=i.getAttribute(h).split(Cs),m=/([.?@])?(.*)/.exec(d);c.push({type:1,index:n,name:m[2],strings:f,ctor:m[1]==="."?ZC:m[1]==="?"?QC:m[1]==="@"?e1:Wn}),i.removeAttribute(h)}else h.startsWith(Cs)&&(c.push({type:6,index:n}),i.removeAttribute(h));if(Lh.test(i.tagName)){const h=i.textContent.split(Cs),d=h.length-1;if(d>0){i.textContent=On?On.emptyScript:"";for(let f=0;f<d;f++)i.append(h[f],Ti()),Ks.nextNode(),c.push({type:2,index:++n});i.append(h[d],Ti())}}}else if(i.nodeType===8)if(i.data===Dh)c.push({type:2,index:n});else{let h=-1;for(;(h=i.data.indexOf(Cs,h+1))!==-1;)c.push({type:7,index:n}),h+=Cs.length-1}n++}}static createElement(e,s){const r=er.createElement("template");return r.innerHTML=e,r}}function Vr(t,e,s=t,r){if(e===zr)return e;let i=r!==void 0?s._$Co?.[r]:s._$Cl;const n=ki(e)?void 0:e._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(t),i._$AT(t,s,r)),r!==void 0?(s._$Co??=[])[r]=i:s._$Cl=i),i!==void 0&&(e=Vr(t,i._$AS(t,e.values),i,r)),e}class XC{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?.creationScope??er).importNode(s,!0);Ks.currentNode=i;let n=Ks.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new Wi(n,n.nextSibling,this,e):c.type===1?l=new c.ctor(n,c.name,c.strings,this,e):c.type===6&&(l=new t1(n,this,e)),this._$AV.push(l),c=r[++a]}o!==c?.index&&(n=Ks.nextNode(),o++)}return Ks.currentNode=er,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 Wi{get _$AU(){return this._$AM?._$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?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&e?.nodeType===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=Vr(this,e,s),ki(e)?e===Ke||e==null||e===""?(this._$AH!==Ke&&this._$AR(),this._$AH=Ke):e!==this._$AH&&e!==zr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):JC(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&&ki(this._$AH)?this._$AA.nextSibling.data=e:this.T(er.createTextNode(e)),this._$AH=e}$(e){const{values:s,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=$i.createElement(Bh(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(s);else{const n=new XC(i,this),o=n.u(this.options);n.p(s),this.T(o),this._$AH=n}}_$AC(e){let s=Bl.get(e.strings);return s===void 0&&Bl.set(e.strings,s=new $i(e)),s}k(e){Ia(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 Wi(this.O(Ti()),this.O(Ti()),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){for(this._$AP?.(!1,!0,s);e!==this._$AB;){const r=xl(e).nextSibling;xl(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class Wn{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=Vr(this,e,s,0),o=!ki(e)||e!==this._$AH&&e!==zr,o&&(this._$AH=e);else{const a=e;let c,l;for(e=n[0],c=0;c<n.length-1;c++)l=Vr(this,a[r+c],s,c),l===zr&&(l=this._$AH[c]),o||=!ki(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 ZC extends Wn{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ke?void 0:e}}class QC extends Wn{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ke)}}class e1 extends Wn{constructor(e,s,r,i,n){super(e,s,r,i,n),this.type=5}_$AI(e,s=this){if((e=Vr(this,e,s,0)??Ke)===zr)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){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class t1{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){Vr(this,e)}}const s1=Ca.litHtmlPolyfillSupport;s1?.($i,Wi),(Ca.litHtmlVersions??=[]).push("3.3.2");const r1=(t,e,s)=>{const r=s?.renderBefore??e;let i=r._$litPart$;if(i===void 0){const n=s?.renderBefore??null;r._$litPart$=i=new Wi(e.insertBefore(Ti(),n),n,void 0,s??{})}return i._$AI(t),i};/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2017 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/const Na=globalThis;class yn extends Ar{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=r1(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return zr}}yn._$litElement$=!0,yn.finalized=!0,Na.litElementHydrateSupport?.({LitElement:yn});const i1=Na.litElementPolyfillSupport;i1?.({LitElement:yn});(Na.litElementVersions??=[]).push("4.2.2");let Ii,Ts,ks;function W1(t,e){Ii=document.createElement("style"),Ts=document.createElement("style"),ks=document.createElement("style"),Ii.textContent=Ur(t).core.cssText,Ts.textContent=Ur(t).dark.cssText,ks.textContent=Ur(t).light.cssText,document.head.appendChild(Ii),document.head.appendChild(Ts),document.head.appendChild(ks),jh(e)}function jh(t){Ts&&ks&&(t==="light"?(Ts.removeAttribute("media"),ks.media="enabled"):(ks.removeAttribute("media"),Ts.media="enabled"))}function n1(t){Ii&&Ts&&ks&&(Ii.textContent=Ur(t).core.cssText,Ts.textContent=Ur(t).dark.cssText,ks.textContent=Ur(t).light.cssText)}function Ur(t){return{core:Rr`
|
|
32
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
33
|
+
@keyframes w3m-shake {
|
|
34
|
+
0% {
|
|
35
|
+
transform: scale(1) rotate(0deg);
|
|
36
|
+
}
|
|
37
|
+
20% {
|
|
38
|
+
transform: scale(1) rotate(-1deg);
|
|
39
|
+
}
|
|
40
|
+
40% {
|
|
41
|
+
transform: scale(1) rotate(1.5deg);
|
|
42
|
+
}
|
|
43
|
+
60% {
|
|
44
|
+
transform: scale(1) rotate(-1.5deg);
|
|
45
|
+
}
|
|
46
|
+
80% {
|
|
47
|
+
transform: scale(1) rotate(1deg);
|
|
48
|
+
}
|
|
49
|
+
100% {
|
|
50
|
+
transform: scale(1) rotate(0deg);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
@keyframes w3m-iframe-fade-out {
|
|
54
|
+
0% {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
100% {
|
|
58
|
+
opacity: 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
@keyframes w3m-iframe-zoom-in {
|
|
62
|
+
0% {
|
|
63
|
+
transform: translateY(50px);
|
|
64
|
+
opacity: 0;
|
|
65
|
+
}
|
|
66
|
+
100% {
|
|
67
|
+
transform: translateY(0px);
|
|
68
|
+
opacity: 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
@keyframes w3m-iframe-zoom-in-mobile {
|
|
72
|
+
0% {
|
|
73
|
+
transform: scale(0.95);
|
|
74
|
+
opacity: 0;
|
|
75
|
+
}
|
|
76
|
+
100% {
|
|
77
|
+
transform: scale(1);
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
:root {
|
|
82
|
+
--w3m-modal-width: 360px;
|
|
83
|
+
--w3m-color-mix-strength: ${$t(t?.["--w3m-color-mix-strength"]?`${t["--w3m-color-mix-strength"]}%`:"0%")};
|
|
84
|
+
--w3m-font-family: ${$t(t?.["--w3m-font-family"]||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
85
|
+
--w3m-font-size-master: ${$t(t?.["--w3m-font-size-master"]||"10px")};
|
|
86
|
+
--w3m-border-radius-master: ${$t(t?.["--w3m-border-radius-master"]||"4px")};
|
|
87
|
+
--w3m-z-index: ${$t(t?.["--w3m-z-index"]||999)};
|
|
88
|
+
|
|
89
|
+
--wui-font-family: var(--w3m-font-family);
|
|
90
|
+
|
|
91
|
+
--wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
|
|
92
|
+
--wui-font-size-micro: var(--w3m-font-size-master);
|
|
93
|
+
--wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
|
|
94
|
+
--wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
|
|
95
|
+
--wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
|
|
96
|
+
--wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
|
|
97
|
+
--wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
|
|
98
|
+
--wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
|
|
99
|
+
--wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
|
|
100
|
+
--wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
|
|
101
|
+
|
|
102
|
+
--wui-border-radius-5xs: var(--w3m-border-radius-master);
|
|
103
|
+
--wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
|
|
104
|
+
--wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
|
|
105
|
+
--wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
|
|
106
|
+
--wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
|
|
107
|
+
--wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
|
|
108
|
+
--wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
|
|
109
|
+
--wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
|
|
110
|
+
--wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
|
|
111
|
+
|
|
112
|
+
--wui-font-weight-light: 400;
|
|
113
|
+
--wui-font-weight-regular: 500;
|
|
114
|
+
--wui-font-weight-medium: 600;
|
|
115
|
+
--wui-font-weight-bold: 700;
|
|
116
|
+
|
|
117
|
+
--wui-letter-spacing-2xl: -1.6px;
|
|
118
|
+
--wui-letter-spacing-medium-title: -0.96px;
|
|
119
|
+
--wui-letter-spacing-title-6: -0.88px;
|
|
120
|
+
--wui-letter-spacing-large: -0.8px;
|
|
121
|
+
--wui-letter-spacing-medium: -0.72px;
|
|
122
|
+
--wui-letter-spacing-paragraph: -0.64px;
|
|
123
|
+
--wui-letter-spacing-small: -0.56px;
|
|
124
|
+
--wui-letter-spacing-tiny: -0.48px;
|
|
125
|
+
--wui-letter-spacing-micro: -0.2px;
|
|
126
|
+
--wui-letter-spacing-mini: -0.16px;
|
|
127
|
+
|
|
128
|
+
--wui-spacing-0: 0px;
|
|
129
|
+
--wui-spacing-4xs: 2px;
|
|
130
|
+
--wui-spacing-3xs: 4px;
|
|
131
|
+
--wui-spacing-xxs: 6px;
|
|
132
|
+
--wui-spacing-2xs: 7px;
|
|
133
|
+
--wui-spacing-xs: 8px;
|
|
134
|
+
--wui-spacing-1xs: 10px;
|
|
135
|
+
--wui-spacing-s: 12px;
|
|
136
|
+
--wui-spacing-m: 14px;
|
|
137
|
+
--wui-spacing-l: 16px;
|
|
138
|
+
--wui-spacing-2l: 18px;
|
|
139
|
+
--wui-spacing-xl: 20px;
|
|
140
|
+
--wui-spacing-xxl: 24px;
|
|
141
|
+
--wui-spacing-2xl: 32px;
|
|
142
|
+
--wui-spacing-3xl: 40px;
|
|
143
|
+
--wui-spacing-4xl: 90px;
|
|
144
|
+
--wui-spacing-5xl: 95px;
|
|
145
|
+
|
|
146
|
+
--wui-icon-box-size-xxs: 14px;
|
|
147
|
+
--wui-icon-box-size-xs: 20px;
|
|
148
|
+
--wui-icon-box-size-sm: 24px;
|
|
149
|
+
--wui-icon-box-size-md: 32px;
|
|
150
|
+
--wui-icon-box-size-mdl: 36px;
|
|
151
|
+
--wui-icon-box-size-lg: 40px;
|
|
152
|
+
--wui-icon-box-size-2lg: 48px;
|
|
153
|
+
--wui-icon-box-size-xl: 64px;
|
|
154
|
+
|
|
155
|
+
--wui-icon-size-inherit: inherit;
|
|
156
|
+
--wui-icon-size-xxs: 10px;
|
|
157
|
+
--wui-icon-size-xs: 12px;
|
|
158
|
+
--wui-icon-size-sm: 14px;
|
|
159
|
+
--wui-icon-size-md: 16px;
|
|
160
|
+
--wui-icon-size-mdl: 18px;
|
|
161
|
+
--wui-icon-size-lg: 20px;
|
|
162
|
+
--wui-icon-size-xl: 24px;
|
|
163
|
+
--wui-icon-size-xxl: 28px;
|
|
164
|
+
|
|
165
|
+
--wui-wallet-image-size-inherit: inherit;
|
|
166
|
+
--wui-wallet-image-size-sm: 40px;
|
|
167
|
+
--wui-wallet-image-size-md: 56px;
|
|
168
|
+
--wui-wallet-image-size-lg: 80px;
|
|
169
|
+
|
|
170
|
+
--wui-visual-size-size-inherit: inherit;
|
|
171
|
+
--wui-visual-size-sm: 40px;
|
|
172
|
+
--wui-visual-size-md: 55px;
|
|
173
|
+
--wui-visual-size-lg: 80px;
|
|
174
|
+
|
|
175
|
+
--wui-box-size-md: 100px;
|
|
176
|
+
--wui-box-size-lg: 120px;
|
|
177
|
+
|
|
178
|
+
--wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
|
|
179
|
+
--wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
|
|
180
|
+
|
|
181
|
+
--wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
|
|
182
|
+
--wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
|
|
183
|
+
--wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
|
|
184
|
+
|
|
185
|
+
--wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
|
|
186
|
+
|
|
187
|
+
--wui-duration-lg: 200ms;
|
|
188
|
+
--wui-duration-md: 125ms;
|
|
189
|
+
--wui-duration-sm: 75ms;
|
|
190
|
+
|
|
191
|
+
--wui-path-network-sm: path(
|
|
192
|
+
'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'
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
--wui-path-network-md: path(
|
|
196
|
+
'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'
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
--wui-path-network-lg: path(
|
|
200
|
+
'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'
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
--wui-width-network-sm: 36px;
|
|
204
|
+
--wui-width-network-md: 48px;
|
|
205
|
+
--wui-width-network-lg: 86px;
|
|
206
|
+
|
|
207
|
+
--wui-height-network-sm: 40px;
|
|
208
|
+
--wui-height-network-md: 54px;
|
|
209
|
+
--wui-height-network-lg: 96px;
|
|
210
|
+
|
|
211
|
+
--wui-icon-size-network-xs: 12px;
|
|
212
|
+
--wui-icon-size-network-sm: 16px;
|
|
213
|
+
--wui-icon-size-network-md: 24px;
|
|
214
|
+
--wui-icon-size-network-lg: 42px;
|
|
215
|
+
|
|
216
|
+
--wui-color-inherit: inherit;
|
|
217
|
+
|
|
218
|
+
--wui-color-inverse-100: #fff;
|
|
219
|
+
--wui-color-inverse-000: #000;
|
|
220
|
+
|
|
221
|
+
--wui-cover: rgba(20, 20, 20, 0.8);
|
|
222
|
+
|
|
223
|
+
--wui-color-modal-bg: var(--wui-color-modal-bg-base);
|
|
224
|
+
|
|
225
|
+
--wui-color-accent-100: var(--wui-color-accent-base-100);
|
|
226
|
+
--wui-color-accent-090: var(--wui-color-accent-base-090);
|
|
227
|
+
--wui-color-accent-080: var(--wui-color-accent-base-080);
|
|
228
|
+
|
|
229
|
+
--wui-color-success-100: var(--wui-color-success-base-100);
|
|
230
|
+
--wui-color-success-125: var(--wui-color-success-base-125);
|
|
231
|
+
|
|
232
|
+
--wui-color-warning-100: var(--wui-color-warning-base-100);
|
|
233
|
+
|
|
234
|
+
--wui-color-error-100: var(--wui-color-error-base-100);
|
|
235
|
+
--wui-color-error-125: var(--wui-color-error-base-125);
|
|
236
|
+
|
|
237
|
+
--wui-color-blue-100: var(--wui-color-blue-base-100);
|
|
238
|
+
--wui-color-blue-90: var(--wui-color-blue-base-90);
|
|
239
|
+
|
|
240
|
+
--wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
|
|
241
|
+
--wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
|
|
242
|
+
--wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
|
|
243
|
+
--wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
|
|
244
|
+
|
|
245
|
+
--wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
|
|
246
|
+
|
|
247
|
+
--wui-avatar-border: var(--wui-avatar-border-base);
|
|
248
|
+
|
|
249
|
+
--wui-thumbnail-border: var(--wui-thumbnail-border-base);
|
|
250
|
+
|
|
251
|
+
--wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
|
|
252
|
+
|
|
253
|
+
--wui-box-shadow-blue: var(--wui-color-accent-glass-020);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@supports (background: color-mix(in srgb, white 50%, black)) {
|
|
257
|
+
:root {
|
|
258
|
+
--wui-color-modal-bg: color-mix(
|
|
259
|
+
in srgb,
|
|
260
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
261
|
+
var(--wui-color-modal-bg-base)
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
--wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
|
|
265
|
+
|
|
266
|
+
--wui-color-accent-100: color-mix(
|
|
267
|
+
in srgb,
|
|
268
|
+
var(--wui-color-accent-base-100) 100%,
|
|
269
|
+
transparent
|
|
270
|
+
);
|
|
271
|
+
--wui-color-accent-090: color-mix(
|
|
272
|
+
in srgb,
|
|
273
|
+
var(--wui-color-accent-base-100) 90%,
|
|
274
|
+
transparent
|
|
275
|
+
);
|
|
276
|
+
--wui-color-accent-080: color-mix(
|
|
277
|
+
in srgb,
|
|
278
|
+
var(--wui-color-accent-base-100) 80%,
|
|
279
|
+
transparent
|
|
280
|
+
);
|
|
281
|
+
--wui-color-accent-glass-090: color-mix(
|
|
282
|
+
in srgb,
|
|
283
|
+
var(--wui-color-accent-base-100) 90%,
|
|
284
|
+
transparent
|
|
285
|
+
);
|
|
286
|
+
--wui-color-accent-glass-080: color-mix(
|
|
287
|
+
in srgb,
|
|
288
|
+
var(--wui-color-accent-base-100) 80%,
|
|
289
|
+
transparent
|
|
290
|
+
);
|
|
291
|
+
--wui-color-accent-glass-020: color-mix(
|
|
292
|
+
in srgb,
|
|
293
|
+
var(--wui-color-accent-base-100) 20%,
|
|
294
|
+
transparent
|
|
295
|
+
);
|
|
296
|
+
--wui-color-accent-glass-015: color-mix(
|
|
297
|
+
in srgb,
|
|
298
|
+
var(--wui-color-accent-base-100) 15%,
|
|
299
|
+
transparent
|
|
300
|
+
);
|
|
301
|
+
--wui-color-accent-glass-010: color-mix(
|
|
302
|
+
in srgb,
|
|
303
|
+
var(--wui-color-accent-base-100) 10%,
|
|
304
|
+
transparent
|
|
305
|
+
);
|
|
306
|
+
--wui-color-accent-glass-005: color-mix(
|
|
307
|
+
in srgb,
|
|
308
|
+
var(--wui-color-accent-base-100) 5%,
|
|
309
|
+
transparent
|
|
310
|
+
);
|
|
311
|
+
--wui-color-accent-002: color-mix(
|
|
312
|
+
in srgb,
|
|
313
|
+
var(--wui-color-accent-base-100) 2%,
|
|
314
|
+
transparent
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
--wui-color-fg-100: color-mix(
|
|
318
|
+
in srgb,
|
|
319
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
320
|
+
var(--wui-color-fg-100)
|
|
321
|
+
);
|
|
322
|
+
--wui-color-fg-125: color-mix(
|
|
323
|
+
in srgb,
|
|
324
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
325
|
+
var(--wui-color-fg-125)
|
|
326
|
+
);
|
|
327
|
+
--wui-color-fg-150: color-mix(
|
|
328
|
+
in srgb,
|
|
329
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
330
|
+
var(--wui-color-fg-150)
|
|
331
|
+
);
|
|
332
|
+
--wui-color-fg-175: color-mix(
|
|
333
|
+
in srgb,
|
|
334
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
335
|
+
var(--wui-color-fg-175)
|
|
336
|
+
);
|
|
337
|
+
--wui-color-fg-200: color-mix(
|
|
338
|
+
in srgb,
|
|
339
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
340
|
+
var(--wui-color-fg-200)
|
|
341
|
+
);
|
|
342
|
+
--wui-color-fg-225: color-mix(
|
|
343
|
+
in srgb,
|
|
344
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
345
|
+
var(--wui-color-fg-225)
|
|
346
|
+
);
|
|
347
|
+
--wui-color-fg-250: color-mix(
|
|
348
|
+
in srgb,
|
|
349
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
350
|
+
var(--wui-color-fg-250)
|
|
351
|
+
);
|
|
352
|
+
--wui-color-fg-275: color-mix(
|
|
353
|
+
in srgb,
|
|
354
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
355
|
+
var(--wui-color-fg-275)
|
|
356
|
+
);
|
|
357
|
+
--wui-color-fg-300: color-mix(
|
|
358
|
+
in srgb,
|
|
359
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
360
|
+
var(--wui-color-fg-300)
|
|
361
|
+
);
|
|
362
|
+
--wui-color-fg-325: color-mix(
|
|
363
|
+
in srgb,
|
|
364
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
365
|
+
var(--wui-color-fg-325)
|
|
366
|
+
);
|
|
367
|
+
--wui-color-fg-350: color-mix(
|
|
368
|
+
in srgb,
|
|
369
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
370
|
+
var(--wui-color-fg-350)
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
--wui-color-bg-100: color-mix(
|
|
374
|
+
in srgb,
|
|
375
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
376
|
+
var(--wui-color-bg-100)
|
|
377
|
+
);
|
|
378
|
+
--wui-color-bg-125: color-mix(
|
|
379
|
+
in srgb,
|
|
380
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
381
|
+
var(--wui-color-bg-125)
|
|
382
|
+
);
|
|
383
|
+
--wui-color-bg-150: color-mix(
|
|
384
|
+
in srgb,
|
|
385
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
386
|
+
var(--wui-color-bg-150)
|
|
387
|
+
);
|
|
388
|
+
--wui-color-bg-175: color-mix(
|
|
389
|
+
in srgb,
|
|
390
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
391
|
+
var(--wui-color-bg-175)
|
|
392
|
+
);
|
|
393
|
+
--wui-color-bg-200: color-mix(
|
|
394
|
+
in srgb,
|
|
395
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
396
|
+
var(--wui-color-bg-200)
|
|
397
|
+
);
|
|
398
|
+
--wui-color-bg-225: color-mix(
|
|
399
|
+
in srgb,
|
|
400
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
401
|
+
var(--wui-color-bg-225)
|
|
402
|
+
);
|
|
403
|
+
--wui-color-bg-250: color-mix(
|
|
404
|
+
in srgb,
|
|
405
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
406
|
+
var(--wui-color-bg-250)
|
|
407
|
+
);
|
|
408
|
+
--wui-color-bg-275: color-mix(
|
|
409
|
+
in srgb,
|
|
410
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
411
|
+
var(--wui-color-bg-275)
|
|
412
|
+
);
|
|
413
|
+
--wui-color-bg-300: color-mix(
|
|
414
|
+
in srgb,
|
|
415
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
416
|
+
var(--wui-color-bg-300)
|
|
417
|
+
);
|
|
418
|
+
--wui-color-bg-325: color-mix(
|
|
419
|
+
in srgb,
|
|
420
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
421
|
+
var(--wui-color-bg-325)
|
|
422
|
+
);
|
|
423
|
+
--wui-color-bg-350: color-mix(
|
|
424
|
+
in srgb,
|
|
425
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
426
|
+
var(--wui-color-bg-350)
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
--wui-color-success-100: color-mix(
|
|
430
|
+
in srgb,
|
|
431
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
432
|
+
var(--wui-color-success-base-100)
|
|
433
|
+
);
|
|
434
|
+
--wui-color-success-125: color-mix(
|
|
435
|
+
in srgb,
|
|
436
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
437
|
+
var(--wui-color-success-base-125)
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
--wui-color-warning-100: color-mix(
|
|
441
|
+
in srgb,
|
|
442
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
443
|
+
var(--wui-color-warning-base-100)
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
--wui-color-error-100: color-mix(
|
|
447
|
+
in srgb,
|
|
448
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
449
|
+
var(--wui-color-error-base-100)
|
|
450
|
+
);
|
|
451
|
+
--wui-color-blue-100: color-mix(
|
|
452
|
+
in srgb,
|
|
453
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
454
|
+
var(--wui-color-blue-base-100)
|
|
455
|
+
);
|
|
456
|
+
--wui-color-blue-90: color-mix(
|
|
457
|
+
in srgb,
|
|
458
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
459
|
+
var(--wui-color-blue-base-90)
|
|
460
|
+
);
|
|
461
|
+
--wui-color-error-125: color-mix(
|
|
462
|
+
in srgb,
|
|
463
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
464
|
+
var(--wui-color-error-base-125)
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
--wui-icon-box-bg-error-100: color-mix(
|
|
468
|
+
in srgb,
|
|
469
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
470
|
+
var(--wui-icon-box-bg-error-base-100)
|
|
471
|
+
);
|
|
472
|
+
--wui-icon-box-bg-accent-100: color-mix(
|
|
473
|
+
in srgb,
|
|
474
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
475
|
+
var(--wui-icon-box-bg-blue-base-100)
|
|
476
|
+
);
|
|
477
|
+
--wui-icon-box-bg-success-100: color-mix(
|
|
478
|
+
in srgb,
|
|
479
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
480
|
+
var(--wui-icon-box-bg-success-base-100)
|
|
481
|
+
);
|
|
482
|
+
--wui-icon-box-bg-inverse-100: color-mix(
|
|
483
|
+
in srgb,
|
|
484
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
485
|
+
var(--wui-icon-box-bg-inverse-base-100)
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
--wui-all-wallets-bg-100: color-mix(
|
|
489
|
+
in srgb,
|
|
490
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
491
|
+
var(--wui-all-wallets-bg-100)
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
--wui-avatar-border: color-mix(
|
|
495
|
+
in srgb,
|
|
496
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
497
|
+
var(--wui-avatar-border-base)
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
--wui-thumbnail-border: color-mix(
|
|
501
|
+
in srgb,
|
|
502
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
503
|
+
var(--wui-thumbnail-border-base)
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
--wui-wallet-button-bg: color-mix(
|
|
507
|
+
in srgb,
|
|
508
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
509
|
+
var(--wui-wallet-button-bg-base)
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
`,light:Rr`
|
|
514
|
+
:root {
|
|
515
|
+
--w3m-color-mix: ${$t(t?.["--w3m-color-mix"]||"#fff")};
|
|
516
|
+
--w3m-accent: ${$t(Is(t,"dark")["--w3m-accent"])};
|
|
517
|
+
--w3m-default: #fff;
|
|
518
|
+
|
|
519
|
+
--wui-color-modal-bg-base: ${$t(Is(t,"dark")["--w3m-background"])};
|
|
520
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
521
|
+
|
|
522
|
+
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
523
|
+
--wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
|
|
524
|
+
--wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
|
|
525
|
+
--wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
|
|
526
|
+
|
|
527
|
+
--wui-color-fg-100: #e4e7e7;
|
|
528
|
+
--wui-color-fg-125: #d0d5d5;
|
|
529
|
+
--wui-color-fg-150: #a8b1b1;
|
|
530
|
+
--wui-color-fg-175: #a8b0b0;
|
|
531
|
+
--wui-color-fg-200: #949e9e;
|
|
532
|
+
--wui-color-fg-225: #868f8f;
|
|
533
|
+
--wui-color-fg-250: #788080;
|
|
534
|
+
--wui-color-fg-275: #788181;
|
|
535
|
+
--wui-color-fg-300: #6e7777;
|
|
536
|
+
--wui-color-fg-325: #9a9a9a;
|
|
537
|
+
--wui-color-fg-350: #363636;
|
|
538
|
+
|
|
539
|
+
--wui-color-bg-100: #141414;
|
|
540
|
+
--wui-color-bg-125: #191a1a;
|
|
541
|
+
--wui-color-bg-150: #1e1f1f;
|
|
542
|
+
--wui-color-bg-175: #222525;
|
|
543
|
+
--wui-color-bg-200: #272a2a;
|
|
544
|
+
--wui-color-bg-225: #2c3030;
|
|
545
|
+
--wui-color-bg-250: #313535;
|
|
546
|
+
--wui-color-bg-275: #363b3b;
|
|
547
|
+
--wui-color-bg-300: #3b4040;
|
|
548
|
+
--wui-color-bg-325: #252525;
|
|
549
|
+
--wui-color-bg-350: #ffffff;
|
|
550
|
+
|
|
551
|
+
--wui-color-success-base-100: #26d962;
|
|
552
|
+
--wui-color-success-base-125: #30a46b;
|
|
553
|
+
|
|
554
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
555
|
+
|
|
556
|
+
--wui-color-error-base-100: #f25a67;
|
|
557
|
+
--wui-color-error-base-125: #df4a34;
|
|
558
|
+
|
|
559
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
560
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
561
|
+
|
|
562
|
+
--wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
|
|
563
|
+
--wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
|
|
564
|
+
--wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
|
|
565
|
+
--wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
|
|
566
|
+
--wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
|
|
567
|
+
--wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
|
|
568
|
+
--wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
|
|
569
|
+
--wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
|
|
570
|
+
--wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
|
|
571
|
+
--wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
|
|
572
|
+
|
|
573
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
574
|
+
|
|
575
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
576
|
+
|
|
577
|
+
--wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
|
|
578
|
+
--wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
|
|
579
|
+
--wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
|
|
580
|
+
--wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
|
|
581
|
+
--wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
|
|
582
|
+
--wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
|
|
583
|
+
--wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
|
|
584
|
+
--wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
|
|
585
|
+
--wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
|
|
586
|
+
--wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
|
|
587
|
+
|
|
588
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
589
|
+
|
|
590
|
+
--wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
|
|
591
|
+
--wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
|
|
592
|
+
--wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
|
|
593
|
+
--wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
|
|
594
|
+
--wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
|
|
595
|
+
--wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
|
|
596
|
+
--wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
|
|
597
|
+
--wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
|
|
598
|
+
--wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
|
|
599
|
+
--wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
|
|
600
|
+
--wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
|
|
601
|
+
|
|
602
|
+
--wui-color-dark-glass-100: rgba(42, 42, 42, 1);
|
|
603
|
+
|
|
604
|
+
--wui-icon-box-bg-error-base-100: #3c2426;
|
|
605
|
+
--wui-icon-box-bg-blue-base-100: #20303f;
|
|
606
|
+
--wui-icon-box-bg-success-base-100: #1f3a28;
|
|
607
|
+
--wui-icon-box-bg-inverse-base-100: #243240;
|
|
608
|
+
|
|
609
|
+
--wui-all-wallets-bg-100: #222b35;
|
|
610
|
+
|
|
611
|
+
--wui-avatar-border-base: #252525;
|
|
612
|
+
|
|
613
|
+
--wui-thumbnail-border-base: #252525;
|
|
614
|
+
|
|
615
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
616
|
+
|
|
617
|
+
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
618
|
+
}
|
|
619
|
+
`,dark:Rr`
|
|
620
|
+
:root {
|
|
621
|
+
--w3m-color-mix: ${$t(t?.["--w3m-color-mix"]||"#000")};
|
|
622
|
+
--w3m-accent: ${$t(Is(t,"light")["--w3m-accent"])};
|
|
623
|
+
--w3m-default: #000;
|
|
624
|
+
|
|
625
|
+
--wui-color-modal-bg-base: ${$t(Is(t,"light")["--w3m-background"])};
|
|
626
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
627
|
+
|
|
628
|
+
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
629
|
+
--wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
|
|
630
|
+
--wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
|
|
631
|
+
|
|
632
|
+
--wui-color-fg-100: #141414;
|
|
633
|
+
--wui-color-fg-125: #2d3131;
|
|
634
|
+
--wui-color-fg-150: #474d4d;
|
|
635
|
+
--wui-color-fg-175: #636d6d;
|
|
636
|
+
--wui-color-fg-200: #798686;
|
|
637
|
+
--wui-color-fg-225: #828f8f;
|
|
638
|
+
--wui-color-fg-250: #8b9797;
|
|
639
|
+
--wui-color-fg-275: #95a0a0;
|
|
640
|
+
--wui-color-fg-300: #9ea9a9;
|
|
641
|
+
--wui-color-fg-325: #9a9a9a;
|
|
642
|
+
--wui-color-fg-350: #d0d0d0;
|
|
643
|
+
|
|
644
|
+
--wui-color-bg-100: #ffffff;
|
|
645
|
+
--wui-color-bg-125: #f5fafa;
|
|
646
|
+
--wui-color-bg-150: #f3f8f8;
|
|
647
|
+
--wui-color-bg-175: #eef4f4;
|
|
648
|
+
--wui-color-bg-200: #eaf1f1;
|
|
649
|
+
--wui-color-bg-225: #e5eded;
|
|
650
|
+
--wui-color-bg-250: #e1e9e9;
|
|
651
|
+
--wui-color-bg-275: #dce7e7;
|
|
652
|
+
--wui-color-bg-300: #d8e3e3;
|
|
653
|
+
--wui-color-bg-325: #f3f3f3;
|
|
654
|
+
--wui-color-bg-350: #202020;
|
|
655
|
+
|
|
656
|
+
--wui-color-success-base-100: #26b562;
|
|
657
|
+
--wui-color-success-base-125: #30a46b;
|
|
658
|
+
|
|
659
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
660
|
+
|
|
661
|
+
--wui-color-error-base-100: #f05142;
|
|
662
|
+
--wui-color-error-base-125: #df4a34;
|
|
663
|
+
|
|
664
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
665
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
666
|
+
|
|
667
|
+
--wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
|
|
668
|
+
--wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
|
|
669
|
+
--wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
|
|
670
|
+
--wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
|
|
671
|
+
--wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
|
|
672
|
+
--wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
|
|
673
|
+
--wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
|
|
674
|
+
--wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
|
|
675
|
+
--wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
|
|
676
|
+
--wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
|
|
677
|
+
|
|
678
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
679
|
+
|
|
680
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
681
|
+
|
|
682
|
+
--wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
|
|
683
|
+
--wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
|
|
684
|
+
--wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
|
|
685
|
+
--wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
|
|
686
|
+
--wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
|
|
687
|
+
--wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
|
|
688
|
+
--wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
|
|
689
|
+
--wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
|
|
690
|
+
--wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
|
|
691
|
+
--wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
|
|
692
|
+
|
|
693
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
694
|
+
|
|
695
|
+
--wui-icon-box-bg-error-base-100: #f4dfdd;
|
|
696
|
+
--wui-icon-box-bg-blue-base-100: #d9ecfb;
|
|
697
|
+
--wui-icon-box-bg-success-base-100: #daf0e4;
|
|
698
|
+
--wui-icon-box-bg-inverse-base-100: #dcecfc;
|
|
699
|
+
|
|
700
|
+
--wui-all-wallets-bg-100: #e8f1fa;
|
|
701
|
+
|
|
702
|
+
--wui-avatar-border-base: #f3f4f4;
|
|
703
|
+
|
|
704
|
+
--wui-thumbnail-border-base: #eaefef;
|
|
705
|
+
|
|
706
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
707
|
+
|
|
708
|
+
--wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
|
|
709
|
+
--wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
|
|
710
|
+
--wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
|
|
711
|
+
--wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
|
|
712
|
+
--wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
|
|
713
|
+
--wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
|
|
714
|
+
--wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
|
|
715
|
+
--wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
|
|
716
|
+
--wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
|
|
717
|
+
--wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
|
|
718
|
+
--wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
|
|
719
|
+
|
|
720
|
+
--wui-color-dark-glass-100: rgba(233, 233, 233, 1);
|
|
721
|
+
|
|
722
|
+
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
723
|
+
}
|
|
724
|
+
`}}const H1=Rr`
|
|
725
|
+
*,
|
|
726
|
+
*::after,
|
|
727
|
+
*::before,
|
|
728
|
+
:host {
|
|
729
|
+
margin: 0;
|
|
730
|
+
padding: 0;
|
|
731
|
+
box-sizing: border-box;
|
|
732
|
+
font-style: normal;
|
|
733
|
+
text-rendering: optimizeSpeed;
|
|
734
|
+
-webkit-font-smoothing: antialiased;
|
|
735
|
+
-moz-osx-font-smoothing: grayscale;
|
|
736
|
+
-webkit-tap-highlight-color: transparent;
|
|
737
|
+
font-family: var(--wui-font-family);
|
|
738
|
+
backface-visibility: hidden;
|
|
739
|
+
}
|
|
740
|
+
`,z1=Rr`
|
|
741
|
+
button,
|
|
742
|
+
a {
|
|
743
|
+
cursor: pointer;
|
|
744
|
+
display: flex;
|
|
745
|
+
justify-content: center;
|
|
746
|
+
align-items: center;
|
|
747
|
+
position: relative;
|
|
748
|
+
transition:
|
|
749
|
+
color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
750
|
+
background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
751
|
+
border var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
752
|
+
border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
753
|
+
box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
754
|
+
will-change: background-color, color, border, box-shadow, border-radius;
|
|
755
|
+
outline: none;
|
|
756
|
+
border: none;
|
|
757
|
+
column-gap: var(--wui-spacing-3xs);
|
|
758
|
+
background-color: transparent;
|
|
759
|
+
text-decoration: none;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
wui-flex {
|
|
763
|
+
transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
764
|
+
will-change: border-radius;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
button:disabled > wui-wallet-image,
|
|
768
|
+
button:disabled > wui-all-wallets-image,
|
|
769
|
+
button:disabled > wui-network-image,
|
|
770
|
+
button:disabled > wui-image,
|
|
771
|
+
button:disabled > wui-transaction-visual,
|
|
772
|
+
button:disabled > wui-logo {
|
|
773
|
+
filter: grayscale(1);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
@media (hover: hover) and (pointer: fine) {
|
|
777
|
+
button:hover:enabled {
|
|
778
|
+
background-color: var(--wui-color-gray-glass-005);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
button:active:enabled {
|
|
782
|
+
background-color: var(--wui-color-gray-glass-010);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
button:disabled > wui-icon-box {
|
|
787
|
+
opacity: 0.5;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
input {
|
|
791
|
+
border: none;
|
|
792
|
+
outline: none;
|
|
793
|
+
appearance: none;
|
|
794
|
+
}
|
|
795
|
+
`,V1=Rr`
|
|
796
|
+
.wui-color-inherit {
|
|
797
|
+
color: var(--wui-color-inherit);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.wui-color-accent-100 {
|
|
801
|
+
color: var(--wui-color-accent-100);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.wui-color-error-100 {
|
|
805
|
+
color: var(--wui-color-error-100);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
.wui-color-blue-100 {
|
|
809
|
+
color: var(--wui-color-blue-100);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
.wui-color-blue-90 {
|
|
813
|
+
color: var(--wui-color-blue-90);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
.wui-color-error-125 {
|
|
817
|
+
color: var(--wui-color-error-125);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.wui-color-success-100 {
|
|
821
|
+
color: var(--wui-color-success-100);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
.wui-color-success-125 {
|
|
825
|
+
color: var(--wui-color-success-125);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
.wui-color-inverse-100 {
|
|
829
|
+
color: var(--wui-color-inverse-100);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.wui-color-inverse-000 {
|
|
833
|
+
color: var(--wui-color-inverse-000);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.wui-color-fg-100 {
|
|
837
|
+
color: var(--wui-color-fg-100);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.wui-color-fg-200 {
|
|
841
|
+
color: var(--wui-color-fg-200);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
.wui-color-fg-300 {
|
|
845
|
+
color: var(--wui-color-fg-300);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
.wui-color-fg-325 {
|
|
849
|
+
color: var(--wui-color-fg-325);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
.wui-color-fg-350 {
|
|
853
|
+
color: var(--wui-color-fg-350);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
.wui-bg-color-inherit {
|
|
857
|
+
background-color: var(--wui-color-inherit);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
.wui-bg-color-blue-100 {
|
|
861
|
+
background-color: var(--wui-color-accent-100);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
.wui-bg-color-error-100 {
|
|
865
|
+
background-color: var(--wui-color-error-100);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.wui-bg-color-error-125 {
|
|
869
|
+
background-color: var(--wui-color-error-125);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
.wui-bg-color-success-100 {
|
|
873
|
+
background-color: var(--wui-color-success-100);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.wui-bg-color-success-125 {
|
|
877
|
+
background-color: var(--wui-color-success-100);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.wui-bg-color-inverse-100 {
|
|
881
|
+
background-color: var(--wui-color-inverse-100);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.wui-bg-color-inverse-000 {
|
|
885
|
+
background-color: var(--wui-color-inverse-000);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
.wui-bg-color-fg-100 {
|
|
889
|
+
background-color: var(--wui-color-fg-100);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.wui-bg-color-fg-200 {
|
|
893
|
+
background-color: var(--wui-color-fg-200);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.wui-bg-color-fg-300 {
|
|
897
|
+
background-color: var(--wui-color-fg-300);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
.wui-color-fg-325 {
|
|
901
|
+
background-color: var(--wui-color-fg-325);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
.wui-color-fg-350 {
|
|
905
|
+
background-color: var(--wui-color-fg-350);
|
|
906
|
+
}
|
|
907
|
+
`,pi={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 Hi(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const jl=Hi({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"}),ql=Hi({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"});Hi({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"});Hi({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Hi({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 o1={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"]},vn={getMethodsByChainNamespace(t){return o1[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 jl.caipNetworkId:u.chains.push(jl.deprecatedCaipNetworkId);break;case ql.caipNetworkId:u.chains.push(ql.deprecatedCaipNetworkId);break}return u?.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{const e=await wi.resolveName(t);return(Object.values(e?.addresses)||[])[0]?.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 qh{constructor({provider:e,namespace:s}){this.id=j.CONNECTOR_ID.WALLET_CONNECT,this.name=Sn.ConnectorNamesMap[j.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=Sn.ConnectorImageIds[j.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=p.getCaipNetworks.bind(p),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=P.state.universalProviderConfigOverride,i=vn.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 yi.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:a1})}}const a1=["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 c1{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>p.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:j.CONNECTOR_ID.AUTH,type:"AUTH",name:j.CONNECTOR_NAMES.AUTH,provider:e,imageId:Sn.ConnectorImageIds[j.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){H.setStatus(e,s)}on(e,s){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.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){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 n=i,o=H.state.preferredAccountTypes?.[s.chainNamespace];await n.switchNetwork(s.caipNetworkId);const a=await n.getUser({chainId:s.caipNetworkId,preferredAccountType:o});this.emit("switchNetwork",a)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof qh);if(!e)throw new Error("WalletConnectConnector not found");return e}}class l1 extends c1{setUniversalProvider(e){this.addConnector(new qh({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}){const r=this.provider?.session?.namespaces?.[e]?.accounts?.map(i=>{const[,,n]=i.split(":");return n}).filter((i,n,o)=>o.indexOf(i)===n)||[];return Promise.resolve({accounts:r.map(i=>X.createAccount(e,i,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&Ie.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(H.state.balanceLoading&&e.chainId===p.state.activeCaipNetwork?.id)return{balance:H.state.balance||"0.00",symbol:H.state.balanceSymbol||""};const i=(await H.fetchTokenBalance()).find(n=>n.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&n.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:i?.quantity.numeric||"0.00",symbol:i?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return p.state.activeCaipNetwork?.chainNamespace===j.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:mu.encode(new TextEncoder().encode(r)),pubkey:i}},p.state.activeCaipNetwork?.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},p.state.activeCaipNetwork?.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===j.CHAIN.EVM)try{await r.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:Sa(s.id)}]})}catch(i){if(i.code===pi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||i.code===pi.ERROR_INVALID_CHAIN_ID||i.code===pi.ERROR_CODE_DEFAULT||i?.data?.originalError?.code===pi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await r.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:Sa(s.id),rpcUrls:[s?.rpcUrls.chainDefault?.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[s.blockExplorers?.default.url]}]})}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){return this.connectors.find(r=>r.type==="WALLET_CONNECT")?.provider}}const u1=["email","socials","swaps","onramp","activity","reownBranding"],an={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ie.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!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?Ie.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Ie.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ie.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Ie.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ie.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Ie.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?Ie.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?Ie.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},h1={localSettingsOverridden:new Set,getApiConfig(t,e){return e?.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=an[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=an[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return a?.config===null?this.processFallbackFeature(t,o):a?.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return an[t].processApi(e)},processFallbackFeature(t,e){return an[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 V.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?Ie.DEFAULT_REMOTE_FEATURES:Ie.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of u1){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),Ie.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.`;qs.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${o}`},"warning")}return n}};class d1{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{if(s){const i=p.getNetworkData(s)?.requestedCaipNetworks?.find(a=>a.id===r);if(i)return i;const n=p.getNetworkData(s)?.caipNetwork;return n||p.getRequestedCaipNetworks(s).filter(a=>a.chainNamespace===s)?.[0]}return p.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>p.getCaipNetworks(s),this.getActiveChainNamespace=()=>p.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{p.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>p.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>p.state.activeChain===s||!s?p.state.activeCaipAddress:p.getAccountProp("caipAddress",s),this.setClientId=s=>{J.setClientId(s)},this.getProvider=s=>Te.getProvider(s),this.getProviderType=s=>Te.getProviderId(s),this.getPreferredAccountType=s=>H.state.preferredAccountTypes?.[s],this.setCaipAddress=(s,r)=>{H.setCaipAddress(s,r),s&&P.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{H.setBalance(s,r,i)},this.setProfileName=(s,r)=>{H.setProfileName(s,r)},this.setProfileImage=(s,r)=>{H.setProfileImage(s,r)},this.setUser=(s,r)=>{H.setUser(s,r)},this.resetAccount=s=>{H.resetAccount(s)},this.setCaipNetwork=s=>{p.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{p.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{H.setAllAccounts(s,r),P.setHasMultipleAddresses(s?.length>1)},this.setStatus=(s,r)=>{H.setStatus(s,r),q.isConnected()?W.setConnectionStatus("connected"):W.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>p.getAccountProp("address",s),this.setConnectors=s=>{const r=[...q.state.allConnectors,...s];q.setConnectors(r)},this.setConnections=(s,r)=>{Y.setConnections(s,r)},this.fetchIdentity=s=>J.fetchIdentity(s),this.getReownName=s=>wi.getNamesForAddress(s),this.getConnectors=()=>q.getConnectors(),this.getConnectorImage=s=>Yl.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=Te.getProviderId(r),n=s?{...s,type:i}:void 0;H.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!p.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{H.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{H.removeAddressLabel(s,r)},this.getAddress=s=>p.state.activeChain===s||!s?H.state.address:p.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>p.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{p.resetNetwork(s)},this.addConnector=s=>{q.addConnector(s)},this.resetWcConnection=()=>{Y.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{H.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{H.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{p.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{H.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{P.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?.map(n=>n.namespace).filter(n=>!!n);if(r?.length)return[...new Set(r)];const i=s?.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await h1.fetchRemoteFeatures(e),P.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Ao.setOnrampProviders(this.remoteFeatures.onramp),(P.state.remoteFeatures?.email||Array.isArray(P.state.remoteFeatures?.socials)&&P.state.remoteFeatures?.socials.length>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await V.fetchAllowedOrigins();if(e&&X.isClient()){const s=window.location.origin;vn.isOriginAllowed(s,e,pi.DEFAULT_ALLOWED_ANCESTORS)||qs.open(Ir.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else qs.open(Ir.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){const{...s}=e;delete s.adapters,delete s.universalProvider,ke.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(r=>r.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Et.setThemeMode(e.themeMode),e.themeVariables&&Et.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");p.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&p.setActiveCaipNetwork(s)}initializeConnectionController(e){Y.setWcBasic(e.basic??!1)}initializeConnectorController(){q.initialize(this.chainNamespaces)}initializeProjectSettings(e){P.setProjectId(e.projectId),P.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){P.setDebug(e.debug!==!1),P.setEnableWalletConnect(e.enableWalletConnect!==!1),P.setEnableWalletGuide(e.enableWalletGuide!==!1),P.setEnableWallets(e.enableWallets!==!1),P.setEIP6963Enabled(e.enableEIP6963!==!1),P.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),P.setEnableAuthLogger(e.enableAuthLogger!==!1),P.setCustomRpcUrls(e.customRpcUrls),P.setEnableEmbedded(e.enableEmbedded),P.setAllWallets(e.allWallets),P.setIncludeWalletIds(e.includeWalletIds),P.setExcludeWalletIds(e.excludeWalletIds),P.setFeaturedWalletIds(e.featuredWalletIds),P.setTokens(e.tokens),P.setTermsConditionsUrl(e.termsConditionsUrl),P.setPrivacyPolicyUrl(e.privacyPolicyUrl),P.setCustomWallets(e.customWallets),P.setFeatures(e.features),P.setAllowUnsupportedChain(e.allowUnsupportedChain),P.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),P.setPreferUniversalLinks(e.experimental_preferUniversalLinks),P.setDefaultAccountTypes(e.defaultAccountTypes);const s=W.getPreferredAccountTypes()||{},r={...P.state.defaultAccountTypes,...s};H.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),P.setMetadata(e.metadata),P.setDisableAppend(e.disableAppend),P.setEnableEmbedded(e.enableEmbedded),P.setSIWX(e.siwx),!e.projectId){qs.open(Ir.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(e.adapters?.find(o=>o.namespace===j.CHAIN.EVM)&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");P.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return X.isClient()?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=_r.getUnsupportedNetwork(`${s}:${e}`);p.setActiveCaipNetwork(r)}}getDefaultNetwork(){return _r.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return _r.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return _r.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>i.id===e.defaultNetwork?.id);return s?_r.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=Te.getProvider(e),i=Te.getProviderId(e),{caipAddress:n}=p.getAccountData(e)||{};this.setLoading(!0,e),n&&s?.disconnect&&await s.disconnect({provider:r,providerType:i}),W.removeConnectedNamespace(e),Te.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),q.removeConnectorId(e),p.resetAccount(e),p.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()=>{const e=p.state.activeChain,s=this.getAdapter(e),r=this.getCaipNetwork(e)?.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId(i?.clientId||null),W.setConnectedNamespaces([...p.state.chains.keys()]),this.chainNamespaces.forEach(n=>{q.setConnectorId(je.CONNECTOR_TYPE_WALLET_CONNECT,n)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{const c=p.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const w=this.getCaipNetworks().find(g=>g.chainNamespace===n);w&&this.setCaipNetwork(w)}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?.id||h?.id,rpcUrl:o?.rpcUrls?.default?.http?.[0]||h?.rpcUrls?.default?.http?.[0]});if(!d)return;W.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const f=H.state.allAccounts,{accounts:m}=f?.length>0?{accounts:[...f]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(m,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{const n=p.state.activeChain,o=this.getAdapter(n);o?.reconnect&&(await o?.reconnect({id:e,info:s,type:r,provider:i,chainId:this.getCaipNetwork()?.id}),W.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=xC(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));de.resetSend(),Y.resetWcConnection(),await yi.clearSessions(),q.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(),ke.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=>!!window.ethereum?.[String(s)]):!!window.ethereum,signMessage:async e=>(await this.getAdapter(p.state.activeChain)?.signMessage({message:e,address:H.state.address,provider:Te.getProvider(p.state.activeChain)}))?.signature||"",sendTransaction:async e=>{const s=e.chainNamespace;if(Ie.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(p.state.activeChain),i=Te.getProvider(s);return(await r?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}))?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===j.CHAIN.EVM){const s=this.getAdapter(p.state.activeChain),r=Te.getProvider(p.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");return(await s?.estimateGas({...e,provider:r,caipNetwork:i}))?.gas||0n}return 0n},getEnsAvatar:async()=>(await this.syncIdentity({address:H.state.address,chainId:Number(this.getCaipNetwork()?.id),chainNamespace:p.state.activeChain}),H.state.profileImage||!1),getEnsAddress:async e=>await vn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(p.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=Te.getProvider(p.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");return(await s?.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}))?.hash},parseUnits:(e,s)=>this.getAdapter(p.state.activeChain)?.parseUnits({value:e,decimals:s})??0n,formatUnits:(e,s)=>this.getAdapter(p.state.activeChain)?.formatUnits({value:e,decimals:s})??"0",getCapabilities:async e=>await this.getAdapter(p.state.activeChain)?.getCapabilities(e),grantPermissions:async e=>await this.getAdapter(p.state.activeChain)?.grantPermissions(e),revokePermissions:async e=>{const s=this.getAdapter(p.state.activeChain);return s?.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>await this.getAdapter(p.state.activeChain)?.walletGetAssets(e)??{},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!H.state.address||this.updateNativeBalance(H.state.address,s?.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},Y.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(Te.getProviderId(p.state.activeChain)===je.CONNECTOR_TYPE_WALLET_CONNECT){const s=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:this.universalProvider?.session?.peer?.metadata.name==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(s)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=Te.getProvider(s),n=Te.getProviderId(s);if(e.chainNamespace===p.state.activeChain)await this.getAdapter(s)?.switchNetwork({caipNetwork:e,provider:i,providerType:n});else if(this.setCaipNetwork(e),n===je.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}=fs.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...r,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,r)=>{const i=e?.find(n=>n.namespace===r);return i?(i.construct({namespace:r,projectId:this.options?.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new l1({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),await this.chainAdapters?.[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){this.getAdapter(e)?.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=p.state.activeChain===e,c=p.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=H.state.address,n=p.state.activeCaipNetwork;!i||!n?.id||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{const o=p.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&p.state.activeCaipNetwork?.id?this.syncAccount({address:i,chainId:p.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===j.CHAIN.EVM&&X.isSafeApp()&&q.setConnectorId(j.CONNECTOR_ID.SAFE,e);const s=q.getConnectorId(e);switch(this.setStatus("connecting",e),s){case j.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case j.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){const s=this.getAdapter(e),r=q.getConnectorId(e),i=this.getCaipNetwork(e),o=q.getConnectors(e).find(a=>a.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const a=await s?.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]});if(a){const c=await s?.getAccounts({namespace:e,id:o.id});c&&c.accounts.length>0?this.setAllAccounts(c.accounts,e):this.setAllAccounts([X.createAccount(e,a.address,"eoa")],e),this.syncProvider({...a,chainNamespace:e}),await this.syncAccount({...a,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=>{const r=this.getAdapter(s),i=this.universalProvider?.session?.namespaces?.[s]?.accounts||[],n=p.state.activeCaipNetwork?.id,o=i.find(a=>{const{chainId:c}=fs.parseCaipAddress(a);return c===n?.toString()})||i[0];if(o){const a=fs.validateCaipAddress(o),{chainId:c,address:l}=fs.parseCaipAddress(a);if(Te.setProviderId(s,je.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&p.state.activeCaipNetwork&&r?.namespace!==j.CHAIN.EVM){const u=r?.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:p.state.activeCaipNetwork});Te.setProvider(s,u)}else Te.setProvider(s,this.universalProvider);q.setConnectorId(j.CONNECTOR_ID.WALLET_CONNECT,s),W.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:l,chainId:c,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await p.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){const s=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map(r=>{const{address:i}=fs.parseCaipAddress(r);return i}).filter((r,i,n)=>n.indexOf(r)===i);s&&this.setAllAccounts(s.map(r=>X.createAccount(e,r,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){Te.setProviderId(i,e),Te.setProvider(i,s),q.setConnectorId(r,i)}async syncAllAccounts(e){const s=q.getConnectorId(e);if(!s)return;const i=await this.getAdapter(e)?.getAccounts({namespace:e,id:s});i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){const s=e.chainNamespace===p.state.activeChain,r=p.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=W.getActiveNetworkProps(),c=n||a,l=p.state.activeCaipNetwork?.name===j.UNSUPPORTED_NETWORK_NAME,u=p.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let h=this.getCaipNetworks().find(m=>m.id.toString()===c.toString()),d=this.getCaipNetworks().find(m=>m.chainNamespace===o);if(!u&&!h&&!d){const m=this.getApprovedCaipNetworkIds()||[],w=m.find(y=>fs.parseCaipNetworkId(y)?.chainId===c.toString()),g=m.find(y=>fs.parseCaipNetworkId(y)?.chainNamespace===o);h=this.getCaipNetworks().find(y=>y.caipNetworkId===w),d=this.getCaipNetworks().find(y=>y.caipNetworkId===g||"deprecatedCaipNetworkId"in y&&y.deprecatedCaipNetworkId===g)}const f=h||d;f?.chainNamespace===p.state.activeChain?P.state.enableNetworkSwitch&&!P.state.allowUnsupportedChain&&p.state.activeCaipNetwork?.name===j.UNSUPPORTED_NETWORK_NAME?p.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),va.isLowerCaseMatch(i,H.state.address)||this.syncAccountInfo(i,f?.id,o),s?await this.syncBalance({address:i,chainId:f?.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r?.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||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){const s=q.getConnectorId(e),r=Te.getProviderId(e);if(r===je.CONNECTOR_TYPE_ANNOUNCED||r===je.CONNECTOR_TYPE_INJECTED){if(s){const i=this.getConnectors().find(n=>n.id===s);if(i){const{info:n,name:o,imageUrl:a}=i,c=a||this.getConnectorImage(i);this.setConnectedWalletInfo({name:o,icon:c,...n},e)}}}else if(r===je.CONNECTOR_TYPE_WALLET_CONNECT){const i=Te.getProvider(e);i?.session&&this.setConnectedWalletInfo({...i.session.peer.metadata,name:i.session.peer.metadata.name,icon:i.session.peer.metadata.icons?.[0]},e)}else if(s&&s===j.CONNECTOR_ID.COINBASE){const i=this.getConnectors().find(n=>n.id===j.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(i)},e)}}async syncBalance(e){!Vl.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>r.id.toString()===e.chainId?.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=p.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(){const e=DC.createLogger((r,...i)=>{r&&this.handleAlertError(r),console.error(...i)}),s={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};P.setManualWCControl(!!this.options?.manualWCControl),this.universalProvider=this.options.universalProvider??await $C.init(s),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{Y.setUri(e)}),this.universalProvider.on("connect",Y.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),Y.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?.id!==s?.id&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(vn.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&X.isCaipAddress(r[0])&&this.syncAccount(fs.parseCaipAddress(r[0]))}}))}createUniversalProvider(){return!this.universalProviderInitPromise&&X.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){ke.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(Ir.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=Ir.ALERT_ERRORS[o];a&&(qs.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:this.options?.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?.uri&&Y.setUri(e.uri),e?.arguments)switch(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 Y.disconnect(e)}getSIWX(){return P.state.siwx}getError(){return""}getChainId(){return p.state.activeCaipNetwork?.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){qs.open(Ir.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await p.switchActiveNetwork(s)}getWalletProvider(){return p.state.activeChain?Te.state.providers[p.state.activeChain]:null}getWalletProviderType(){return Te.getProviderId(p.state.activeChain)}subscribeProviders(e){return Te.subscribeProviders(e)}getThemeMode(){return Et.state.themeMode}getThemeVariables(){return Et.state.themeVariables}setThemeMode(e){Et.setThemeMode(e),jh(Et.state.themeMode)}setTermsConditionsUrl(e){P.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){P.setPrivacyPolicyUrl(e)}setThemeVariables(e){Et.setThemeVariables(e),n1(Et.state.themeVariables)}subscribeTheme(e){return Et.subscribe(e)}getWalletInfo(){return H.state.connectedWalletInfo}getAccount(e){const s=q.getAuthConnector(e),r=p.getAccountData(e),i=p.state.activeChain,n=W.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:X.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:s&&n===j.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:W.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:r.preferredAccountTypes?.[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?p.subscribeChainProp("accountState",r,s):p.subscribe(r),q.subscribe(r)}subscribeNetwork(e){return p.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s?.id,caipNetworkId:s?.caipNetworkId})})}subscribeWalletInfo(e){return H.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){H.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){p.subscribeKey("activeCaipNetwork",e)}getState(){return As.state}subscribeState(e){return As.subscribe(e)}showErrorMessage(e){Ft.showError(e)}showSuccessMessage(e){Ft.showSuccess(e)}getEvent(){return{...ke.state}}subscribeEvents(e){return ke.subscribe(e)}replace(e){ie.replace(e)}redirect(e){ie.push(e)}popTransactionStack(e){ie.popTransactionStack(e)}isOpen(){return Ge.state.open}isTransactionStackEmpty(){return ie.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){P.setFeatures(e)}updateRemoteFeatures(e){P.setRemoteFeatures(e)}updateOptions(e){const r={...P.state||{},...e};P.setOptions(r)}setConnectMethodsOrder(e){P.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){P.setWalletFeaturesOrder(e)}setCollapseWallets(e){P.setCollapseWallets(e)}setSocialsOrder(e){P.setSocialsOrder(e)}getConnectMethodsOrder(){return ea.getConnectOrderMethod(P.state.features,q.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)||p.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)&&p.removeNetwork(e,s)}}let Fl=!1;class Fh extends d1{async open(e){q.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&Y.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!Fl&&X.isClient()){if(await Pa(()=>import("./basic-BRmrmnBW.js"),__vite__mapDeps([0,1,2,3,4,5,6])),await Pa(()=>import("./w3m-modal-CQYCTo4E.js"),__vite__mapDeps([7,1,2,3,4,5,6])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!P.state.disableAppend&&!P.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}Fl=!0}}}const p1="1.7.8";function f1(t){return new Fh({...t,basic:!0,sdkVersion:`html-core-${p1}`})}const K1=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Fh,createAppKit:f1},Symbol.toStringTag,{value:"Module"}));export{V as A,ta as B,q as C,Rh as D,ke as E,zr as F,K1 as G,Ge as M,P as O,ie as R,W as S,Et as T,ea as W,yn as a,q1 as b,X as c,mn as d,z1 as e,Yl as f,Y as g,j as h,Rr as i,p as j,qt as k,Ft as l,Ie as m,Ke as n,V1 as o,Oe as p,St as q,H1 as r,it as s,nt as t,yi as u,qs as v,F1 as w,MC as x,H as y,W1 as z};
|