@dcl/blog-site 0.1.2-22200898455.commit-be7c830 → 0.1.2
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/assets/{add-CONdz2L0.js → add-CyVnKjs7.js} +1 -1
- package/assets/{all-wallets-BqzhB1kH.js → all-wallets-CG777VR6.js} +1 -1
- package/assets/{app-store-CG7fZeTB.js → app-store-CyKybWLW.js} +1 -1
- package/assets/{apple-qYUKb-fL.js → apple-BLNXiKyR.js} +1 -1
- package/assets/{arrow-bottom-circle-wze6Ib1X.js → arrow-bottom-circle-u-wMwhnf.js} +1 -1
- package/assets/{arrow-bottom-SgoHwiLt.js → arrow-bottom-qde4rzT6.js} +1 -1
- package/assets/{arrow-left-Bc9t_8h8.js → arrow-left-DfxhJBdw.js} +1 -1
- package/assets/{arrow-right-DQoklnFO.js → arrow-right-Cb7w__hM.js} +1 -1
- package/assets/{arrow-top-CtzlGQJY.js → arrow-top-BeK_c3eg.js} +1 -1
- package/assets/auto-track-BdKMoPcs.js +1 -0
- package/assets/{bank-DNHWU_Jg.js → bank-HqtNO_bB.js} +1 -1
- package/assets/{basic-PxGakulR.js → basic-BNAPw1FU.js} +1 -1
- package/assets/{browser-BNy_mm43.js → browser-DIokFqEe.js} +1 -1
- package/assets/{card-g11mKc-V.js → card-DjOl3skX.js} +1 -1
- package/assets/{ccip-CdVPatLX.js → ccip-DqBdUu6i.js} +1 -1
- package/assets/{checkmark-DhBzwQ6t.js → checkmark-CWKlssVu.js} +1 -1
- package/assets/{checkmark-bold-svBeKBAh.js → checkmark-bold-Cj3u8wQw.js} +1 -1
- package/assets/{chevron-bottom-DAKGIwRE.js → chevron-bottom-D9yVYRKT.js} +1 -1
- package/assets/{chevron-left-pJoxer2X.js → chevron-left-DqBwyuOT.js} +1 -1
- package/assets/{chevron-right-BZQxa3gA.js → chevron-right-CKqSAH_x.js} +1 -1
- package/assets/{chevron-top-B1p3XmfH.js → chevron-top-DFQOHzSJ.js} +1 -1
- package/assets/{chrome-store-eRhpzwit.js → chrome-store-wJopyOxA.js} +1 -1
- package/assets/{clock-BAS4ouqS.js → clock-9KCU5m2q.js} +1 -1
- package/assets/{close-BAQozjiM.js → close-CAlya4Yr.js} +1 -1
- package/assets/{coinPlaceholder-BXdMDAlW.js → coinPlaceholder-D-_nqm5Y.js} +1 -1
- package/assets/{compass-DEaXwX19.js → compass-Cc9q07ac.js} +1 -1
- package/assets/{copy-D5b4R0M8.js → copy-D0kVMzUr.js} +1 -1
- package/assets/{core-Chr5umbM.js → core-o6E0YR6k.js} +4 -4
- package/assets/{cursor-CToeUN6u.js → cursor-8Q7GmcGD.js} +1 -1
- package/assets/{cursor-transparent-akq7d1Vw.js → cursor-transparent-CURyD4kY.js} +1 -1
- package/assets/{desktop-DGBZdcEp.js → desktop-DogYiFjA.js} +1 -1
- package/assets/{disconnect-CmKUkObt.js → disconnect-CfgkM-B7.js} +1 -1
- package/assets/{discord-AGPJXkYv.js → discord-CqpA_3K8.js} +1 -1
- package/assets/{etherscan-BCzO-bJK.js → etherscan-BnynTX8C.js} +1 -1
- package/assets/{exclamation-triangle-Dsv91uqg.js → exclamation-triangle-DNM8zLTG.js} +1 -1
- package/assets/{extension-DptuMijD.js → extension-BWNgZYd9.js} +1 -1
- package/assets/{external-link-BtrWPfav.js → external-link-Dz6LJ8_-.js} +1 -1
- package/assets/{facebook-BM1mR9Hc.js → facebook-B4NhgA3g.js} +1 -1
- package/assets/{farcaster-BnAwNR4c.js → farcaster-x-xnP4zp.js} +1 -1
- package/assets/{filters-DnAaDMtu.js → filters-BCP3KZSL.js} +1 -1
- package/assets/{github-BiifJsd8.js → github-Bv7KrAHw.js} +1 -1
- package/assets/{google-CsZwT3WU.js → google-CRoKw5G5.js} +1 -1
- package/assets/{help-circle-B8Z8NC0j.js → help-circle-JerI1UQH.js} +1 -1
- package/assets/{id-DBfaQRNy.js → id-DNx9O1ig.js} +1 -1
- package/assets/{image-BaZrELj9.js → image-B5lk579u.js} +1 -1
- package/assets/index-B4WTLPXJ.js +1 -0
- package/assets/{index-3zjttLF9.js → index-BSNxc2aY.js} +3 -3
- package/assets/index-C2CVTEjl.js +1 -0
- package/assets/index-C6-wFTel.js +1 -0
- package/assets/{index-fyJdZPtk.js → index-CTkJr32f.js} +1 -1
- package/assets/index-CXSCOxLa.js +1 -0
- package/assets/index-D1_e83sD.js +2 -0
- package/assets/index-D6ZMQedT.js +1 -0
- package/assets/index-FMsmThma.js +2 -0
- package/assets/{index-nDqVr4pH.js → index-I3pSy4Zy.js} +6 -6
- package/assets/{index-ch5fmFOv.js → index-m9AvnFPE.js} +124 -124
- package/assets/{index.es-Cl1t_1D0.js → index.es-ZeQVkZNG.js} +4 -4
- package/assets/index.umd-Du5YokXV.js +1 -0
- package/assets/{info-Bbb90kQC.js → info-DJJNUdKr.js} +1 -1
- package/assets/{info-circle-DC62YK7p.js → info-circle-D3lYH_jg.js} +1 -1
- package/assets/inherits_browser-BlmhoU4v.js +1 -0
- package/assets/is-plan-event-enabled-DS1Agtkw.js +1 -0
- package/assets/{lightbulb-D3KvOoms.js → lightbulb-lHrmWgEw.js} +1 -1
- package/assets/localBatchGatewayRequest-D3hqEo4H.js +1 -0
- package/assets/{mail-CgVPzJWi.js → mail-Dv_rw0qa.js} +1 -1
- package/assets/{mobile-DkODDOLr.js → mobile-CGf02IdD.js} +1 -1
- package/assets/{more-Vzh2YixA.js → more-DbI559Pm.js} +1 -1
- package/assets/{network-placeholder-CxREg9uT.js → network-placeholder-B53tzK5r.js} +1 -1
- package/assets/{nftPlaceholder-D6oHDmUM.js → nftPlaceholder-GEOyPEQA.js} +1 -1
- package/assets/{off-D7hAfKPw.js → off-C_yJUsh4.js} +1 -1
- package/assets/{play-store-ymeOX5eL.js → play-store-BJLp1IWs.js} +1 -1
- package/assets/{plus-BSW9Aosf.js → plus-D6nAtT6O.js} +1 -1
- package/assets/{qr-code-Cl8NBuwd.js → qr-code-lrgu_byx.js} +1 -1
- package/assets/{recycle-horizontal-DCp7d4ol.js → recycle-horizontal-CNYe9bbF.js} +1 -1
- package/assets/{refresh-CgZM0T20.js → refresh-ChVzXve8.js} +1 -1
- package/assets/{reown-logo-C4l2_-Rn.js → reown-logo-BvBUEEeQ.js} +1 -1
- package/assets/{search-BFwbgBO3.js → search-DQr5xz8G.js} +1 -1
- package/assets/{secp256k1-ceIhvGka.js → secp256k1-B5bjmlpC.js} +1 -1
- package/assets/{secp256k1-DoSvwiWn.js → secp256k1-DL-MVpVU.js} +1 -1
- package/assets/{send-Bw5bc-ux.js → send-BRFJj9vU.js} +1 -1
- package/assets/{swapHorizontal-DjoIz7Pz.js → swapHorizontal-4OcpYjBP.js} +1 -1
- package/assets/{swapHorizontalBold-7d-pvfYM.js → swapHorizontalBold-BIfY-n1S.js} +1 -1
- package/assets/{swapHorizontalMedium-BS3q74Ag.js → swapHorizontalMedium-D-xOF1-1.js} +1 -1
- package/assets/{swapHorizontalRoundedBold-7x4y8KAj.js → swapHorizontalRoundedBold-CWefS__1.js} +1 -1
- package/assets/{swapVertical-C-I-lOO2.js → swapVertical-10MLOLxY.js} +1 -1
- package/assets/{telegram-NT_2PwmR.js → telegram-CpUsTmvb.js} +1 -1
- package/assets/{three-dots-B9XoXaah.js → three-dots-BbzO9tlr.js} +1 -1
- package/assets/{twitch-DwklO_-v.js → twitch-DElwGcJp.js} +1 -1
- package/assets/{twitterIcon-D01VF8Iy.js → twitterIcon-CGBR8jTt.js} +1 -1
- package/assets/{verify-filled-BxWo9YFB.js → verify-filled-DkOi1MVN.js} +1 -1
- package/assets/{verify-D15WpctO.js → verify-nSw_mp2u.js} +1 -1
- package/assets/{w3m-modal-CGtztDSc.js → w3m-modal-o69qIUHV.js} +1 -1
- package/assets/{wallet-JyXNRnFs.js → wallet-CU5Un-2k.js} +1 -1
- package/assets/{wallet-placeholder-CSmHe_ZB.js → wallet-placeholder-IZIR9OIq.js} +1 -1
- package/assets/{walletconnect-B5GjgoQW.js → walletconnect-BqPmquZK.js} +1 -1
- package/assets/{warning-circle-BmgJOTmJ.js → warning-circle-BbDzrW_O.js} +1 -1
- package/assets/{x-D1Sk_2KN.js → x-Bc8cF9wJ.js} +1 -1
- package/index.html +3 -3
- package/package.json +3 -3
- package/assets/localBatchGatewayRequest-o8j0FHDn.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__fileDeps=["assets/secp256k1-
|
|
2
|
-
import{bU as Nd,bV as Sd,bW as Pd,bX as Od,bo as Td,bY as xd,a as kd,_ as Do,bD as en,af as qa}from"./index-ch5fmFOv.js";import{d as tn,s as ba,a as On,I as Jr,g as $d,c as D,f as kt,t as gt,b as Mr,e as fu,C as Rd,h as Ud,i as Dd,j as vi,k as Lo,E as ot,y as _t,l as qi,A as gu,m as Ld,O as va,o as $t,n as Md,p as Ea,q as Ca,r as jn,u as Yr,v as zs,P as Fa,Q as Bd,w as jd,x as Or,z as mu,B as as,D as Gt,F as ps,G as Ft}from"./index.es-Cl1t_1D0.js";import{c as qd,g as Wa,s as Fd,d as Wd,k as Hd,a as zd}from"./index-nibyPLVP.js";function Ha(t,e={}){const{key:s="fallback",name:r="Fallback",rank:i=!1,shouldThrow:n=Kd,retryCount:o,retryDelay:a}=e;return({chain:c,pollingInterval:l=4e3,timeout:u,...h})=>{let d=t,p=()=>{};const w=Nd({key:s,name:r,async request({method:f,params:m}){let y;const b=async(v=0)=>{const C=d[v]({...h,chain:c,retryCount:0,timeout:u});try{const I=await C.request({method:f,params:m});return p({method:f,params:m,response:I,transport:C,status:"success"}),I}catch(I){if(p({error:I,method:f,params:m,transport:C,status:"error"}),n(I)||v===d.length-1||(y??(y=d.slice(v+1).some(_=>{const{include:S,exclude:U}=_({chain:c}).config.methods||{};return S?S.includes(f):U?!U.includes(f):!0})),!y))throw I;return b(v+1)}};return b()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>p=f,transports:d.map(f=>f({chain:c,retryCount:0}))});if(i){const f=typeof i=="object"?i:{};Vd({chain:c,interval:f.interval??l,onTransports:m=>d=m,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:d,weights:f.weights})}return w}}function Kd(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Sd.code||t.code===Pd.code||Od.nodeMessage.test(t.message)||t.code===5e3))}function Vd({chain:t,interval:e=4e3,onTransports:s,ping:r,sampleCount:i=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],h=async()=>{const d=await Promise.all(o.map(async f=>{const m=f({chain:t,retryCount:0,timeout:n}),y=Date.now();let b,v;try{await(r?r({transport:m}):m.request({method:"net_listening"})),v=1}catch{v=0}finally{b=Date.now()}return{latency:b-y,success:v}}));u.push(d),u.length>i&&u.shift();const p=Math.max(...u.map(f=>Math.max(...f.map(({latency:m})=>m)))),w=o.map((f,m)=>{const y=u.map(_=>_[m].latency),v=1-y.reduce((_,S)=>_+S,0)/y.length/p,C=u.map(_=>_[m].success),I=C.reduce((_,S)=>_+S,0)/C.length;return I===0?[0,m]:[l*v+c*I,m]}).sort((f,m)=>m[0]-f[0]);s(w.map(([,f])=>o[f])),await Td(e),h()};h()}var za={};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 process<"u"&&typeof za<"u"?za.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},wu={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=j.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var Gd=20,Jd=1,Ys=1e6,Ka=1e6,Yd=-7,Xd=21,Zd=!1,Fi="[big.js] ",rr=Fi+"Invalid ",qn=rr+"decimal places",Qd=rr+"rounding mode",yu=Fi+"Division by zero",ge={},Xt=void 0,ep=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function bu(){function t(e){var s=this;if(!(s instanceof t))return e===Xt?bu():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(rr+"value");e=e===0&&1/e<0?"-0":String(e)}tp(s,e)}s.constructor=t}return t.prototype=ge,t.DP=Gd,t.RM=Jd,t.NE=Yd,t.PE=Xd,t.strict=Zd,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function tp(t,e){var s,r,i;if(!ep.test(e))throw Error(rr+"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 ir(t,e,s,r){var i=t.c;if(s===Xt&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(Qd);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]!==Xt))),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]!==Xt||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 nr(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}ge.abs=function(){var t=new this.constructor(this);return t.s=1,t};ge.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};ge.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>Ys)throw Error(qn);if(!i[0])throw Error(yu);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),p=a=i.length,w=r.length,f=r.slice(0,a),m=f.length,y=t,b=y.c=[],v=0,C=o+(y.e=e.e-t.e)+1;for(y.s=n,n=C<0?0:C,d.unshift(0);m++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(m=f.length))u=a>m?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=f[h]){u=i[h]>f[h]?1:-1;break}if(u<0){for(c=m==a?i:d;m;){if(f[--m]<c[m]){for(h=m;h&&!f[--h];)f[h]=9;--f[h],f[m]+=10}f[m]-=c[m]}for(;!f[0];)f.shift()}else break}b[v++]=u?l:++l,f[0]&&u?f[m]=r[p]||0:f=[r[p]]}while((p++<w||f[0]!==Xt)&&n--);return!b[0]&&v!=1&&(b.shift(),y.e--,C--),v>C&&ir(y,C,s.RM,f[0]!==Xt),y};ge.eq=function(t){return this.cmp(t)===0};ge.gt=function(t){return this.cmp(t)>0};ge.gte=function(t){return this.cmp(t)>-1};ge.lt=function(t){return this.cmp(t)<0};ge.lte=function(t){return this.cmp(t)<1};ge.minus=ge.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};ge.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(yu);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)))};ge.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};ge.plus=ge.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};ge.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(rr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};ge.prec=function(t,e){if(t!==~~t||t<1||t>Ys)throw Error(rr+"precision");return ir(new this.constructor(this),t,e)};ge.round=function(t,e){if(t===Xt)t=0;else if(t!==~~t||t<-Ys||t>Ys)throw Error(qn);return ir(new this.constructor(this),t+this.e+1,e)};ge.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(Fi+"No square root");n=Math.sqrt(+nr(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 ir(t,(i.DP-=4)+t.e+1,i.RM)};ge.times=ge.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};ge.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==Xt){if(t!==~~t||t<0||t>Ys)throw Error(qn);for(s=ir(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return nr(s,!0,!!r)};ge.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==Xt){if(t!==~~t||t<0||t>Ys)throw Error(qn);for(s=ir(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return nr(s,!1,!!r)};ge[Symbol.for("nodejs.util.inspect.custom")]=ge.toJSON=ge.toString=function(){var t=this,e=t.constructor;return nr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};ge.toNumber=function(){var t=+nr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Fi+"Imprecise conversion");return t};ge.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==Xt){if(t!==~~t||t<1||t>Ys)throw Error(rr+"precision");for(s=ir(new r(s),t,e);s.c.length<t;)s.c.push(0)}return nr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};ge.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Fi+"valueOf disallowed");return nr(t,t.e<=e.NE||t.e>=e.PE,!0)};var ri=bu();const sp={bigNumber(t){return t?new ri(t):new ri(0)},multiply(t,e){if(t===void 0||e===void 0)return new ri(0);const s=new ri(t),r=new ri(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,""))}},rp=[{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"}]}],ip=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],np=[{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"}]}],op={getERC20Abi:t=>j.USDT_CONTRACT_ADDRESSES.includes(t)?np:rp,getSwapAbi:()=>ip},fs={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},ee={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 eo(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const Z={setItem(t,e){fi()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(fi())return localStorage.getItem(t)||void 0},removeItem(t){fi()&&localStorage.removeItem(t)},clear(){fi()&&localStorage.clear()}};function fi(){return typeof window<"u"&&typeof localStorage<"u"}function Is(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const ap=Symbol(),Va=Object.getPrototypeOf,Mo=new WeakMap,cp=t=>t&&(Mo.has(t)?Mo.get(t):Va(t)===Object.prototype||Va(t)===Array.prototype),lp=t=>cp(t)&&t[ap]||null,Ga=(t,e=!0)=>{Mo.set(t,e)};var Tn={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830",VITE_REACT_APP_DCL_DEFAULT_ENV:"dev",VITE_SEGMENT_PRD_API_KEY:"",VITE_SEGMENT_DEV_API_KEY:"",BASE_URL:"https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const to=t=>typeof t=="object"&&t!==null,bs=new WeakMap,gi=new WeakSet,up=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>to(l)&&!gi.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,u,h=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const p=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Ga(p,!0),i.set(l,[u,p]),Reflect.ownKeys(l).forEach(w=>{if(Object.getOwnPropertyDescriptor(p,w))return;const f=Reflect.get(l,w),{enumerable:m}=Reflect.getOwnPropertyDescriptor(l,w),y={value:f,enumerable:m,configurable:!0};if(gi.has(f))Ga(f,!1);else if(f instanceof Promise)delete y.value,y.get=()=>h(f);else if(bs.has(f)){const[b,v]=bs.get(f);y.value=n(b,v(),h)}Object.defineProperty(p,w,y)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],c=l=>{if(!to(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,p=(E,$=++a[0])=>{h!==$&&(h=$,d.forEach(A=>A(E,$)))};let w=a[1];const f=(E=++a[1])=>(w!==E&&!d.size&&(w=E,y.forEach(([$])=>{const A=$[1](E);A>h&&(h=A)})),h),m=E=>($,A)=>{const L=[...$];L[1]=[E,...L[1]],p(L,A)},y=new Map,b=(E,$)=>{if((Tn?"production":void 0)!=="production"&&y.has(E))throw new Error("prop listener already exists");if(d.size){const A=$[3](m(E));y.set(E,[$,A])}else y.set(E,[$])},v=E=>{var $;const A=y.get(E);A&&(y.delete(E),($=A[1])==null||$.call(A))},C=E=>(d.add(E),d.size===1&&y.forEach(([A,L],z)=>{if((Tn?"production":void 0)!=="production"&&L)throw new Error("remove already exists");const N=A[3](m(z));y.set(z,[A,N])}),()=>{d.delete(E),d.size===0&&y.forEach(([A,L],z)=>{L&&(L(),y.set(z,[A]))})}),I=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e(I,{deleteProperty(E,$){const A=Reflect.get(E,$);v($);const L=Reflect.deleteProperty(E,$);return L&&p(["delete",[$],A]),L},set(E,$,A,L){const z=Reflect.has(E,$),N=Reflect.get(E,$,L);if(z&&(t(N,A)||o.has(A)&&t(N,o.get(A))))return!0;v($),to(A)&&(A=lp(A)||A);let x=A;if(A instanceof Promise)A.then(O=>{A.status="fulfilled",A.value=O,p(["resolve",[$],O])}).catch(O=>{A.status="rejected",A.reason=O,p(["reject",[$],O])});else{!bs.has(A)&&s(A)&&(x=c(A));const O=!gi.has(x)&&bs.get(x);O&&b($,O)}return Reflect.set(E,$,x,L),p(["set",[$],A,N]),!0}});o.set(l,S);const U=[I,f,n,C];return bs.set(S,U),Reflect.ownKeys(l).forEach(E=>{const $=Object.getOwnPropertyDescriptor(l,E);"value"in $&&(S[E]=l[E],delete $.value,delete $.writable),Object.defineProperty(I,E,$)}),S})=>[c,bs,gi,t,e,s,r,i,n,o,a],[hp]=up();function Pe(t={}){return hp(t)}function st(t,e,s){const r=bs.get(t);(Tn?"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 xi(t,e){const s=bs.get(t);(Tn?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function Xs(t){return gi.add(t),t}function rt(t,e,s,r){let i=t[e];return st(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function dp(t){const e=Pe({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 Ja={};const so=(typeof process<"u"&&typeof Ja<"u"?Ja.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",vu=[{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"]}],pp="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:so,SECURE_SITE_DASHBOARD:`${so}/dashboard`,SECURE_SITE_FAVICON:`${so}/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(ee.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Z.getItem(ee.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Z.removeItem(ee.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Z.setItem(ee.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Z.setItem(ee.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(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Z.removeItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=eo(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(ee.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Z.getItem(ee.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=eo(t);Z.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Z.getItem(ee.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=eo(t);return Z.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{Z.setItem(ee.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Z.getItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Z.removeItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Z.getItem(ee.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=Z.getItem(ee.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{Z.setItem(ee.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Z.getItem(ee.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Z.getItem(ee.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Z.setItem(ee.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(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Z.setItem(ee.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Z.removeItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Z.getItem(ee.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(ee.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(ee.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Z.getItem(ee.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(ee.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(ee.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Z.getItem(ee.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(ee.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=W.getEnsCache();Z.setItem(ee.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(ee.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(ee.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=W.getIdentityCache();Z.setItem(ee.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Z.removeItem(ee.PORTFOLIO_CACHE),Z.removeItem(ee.NATIVE_BALANCE_CACHE),Z.removeItem(ee.ENS_CACHE),Z.removeItem(ee.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Z.setItem(ee.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Z.getItem(ee.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(ee.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=Z.getItem(ee.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},X={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return X.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=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==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(X.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ie.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(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!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!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==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,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){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return j.W3M_API_URL},getBlockchainApiUrl(){return j.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return j.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?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==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function ii(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class Wi{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 ii(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await ii(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await ii(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 ii(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 ii(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 fp={getFeatureValue(t,e){const s=e==null?void 0: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}},V=Pe({features:Ie.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ie.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),T={state:V,subscribeKey(t,e){return rt(V,t,e)},setOptions(t){Object.assign(V,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...V.remoteFeatures,...t};V.remoteFeatures=e,(s=V.remoteFeatures)!=null&&s.socials&&(V.remoteFeatures.socials=fp.filterSocialsByPlatform(V.remoteFeatures.socials))},setFeatures(t){if(!t)return;V.features||(V.features=Ie.DEFAULT_FEATURES);const e={...V.features,...t};V.features=e},setProjectId(t){V.projectId=t},setCustomRpcUrls(t){V.customRpcUrls=t},setAllWallets(t){V.allWallets=t},setIncludeWalletIds(t){V.includeWalletIds=t},setExcludeWalletIds(t){V.excludeWalletIds=t},setFeaturedWalletIds(t){V.featuredWalletIds=t},setTokens(t){V.tokens=t},setTermsConditionsUrl(t){V.termsConditionsUrl=t},setPrivacyPolicyUrl(t){V.privacyPolicyUrl=t},setCustomWallets(t){V.customWallets=t},setIsSiweEnabled(t){V.isSiweEnabled=t},setIsUniversalProvider(t){V.isUniversalProvider=t},setSdkVersion(t){V.sdkVersion=t},setMetadata(t){V.metadata=t},setDisableAppend(t){V.disableAppend=t},setEIP6963Enabled(t){V.enableEIP6963=t},setDebug(t){V.debug=t},setEnableWalletConnect(t){V.enableWalletConnect=t},setEnableWalletGuide(t){V.enableWalletGuide=t},setEnableAuthLogger(t){V.enableAuthLogger=t},setEnableWallets(t){V.enableWallets=t},setPreferUniversalLinks(t){V.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){V.hasMultipleAddresses=t},setSIWX(t){V.siwx=t},setConnectMethodsOrder(t){V.features={...V.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){V.features={...V.features,walletFeaturesOrder:t}},setSocialsOrder(t){V.remoteFeatures={...V.remoteFeatures,socials:t}},setCollapseWallets(t){V.features={...V.features,collapseWallets:t}},setEnableEmbedded(t){V.enableEmbedded=t},setAllowUnsupportedChain(t){V.allowUnsupportedChain=t},setManualWCControl(t){V.manualWCControl=t},setEnableNetworkSwitch(t){V.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(V.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){V.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return V.universalProviderConfigOverride},getSnapshot(){return xi(V)}},gp=Object.freeze({enabled:!0,events:[]}),mp=new Wi({baseUrl:X.getAnalyticsUrl(),clientId:null}),wp=5,yp=60*1e3,gs=Pe({...gp}),bp={state:gs,subscribeKey(t,e){return rt(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<yp}).length>=wp)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}=T.state;await mp.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 Br extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,Br.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
1
|
+
const __vite__fileDeps=["assets/secp256k1-DL-MVpVU.js","assets/index-m9AvnFPE.js","assets/index.es-ZeQVkZNG.js","assets/index-nibyPLVP.js","assets/basic-BNAPw1FU.js","assets/index-BSNxc2aY.js","assets/w3m-modal-o69qIUHV.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
+
import{b_ as Nd,b$ as Sd,c0 as Pd,c1 as Od,bu as Td,c2 as xd,i as kd,g as Do,bJ as en,al as qa}from"./index-m9AvnFPE.js";import{d as tn,s as ba,a as On,I as Jr,g as $d,c as D,f as kt,t as gt,b as Mr,e as fu,C as Rd,h as Ud,i as Dd,j as vi,k as Lo,E as ot,y as _t,l as qi,A as gu,m as Ld,O as va,o as $t,n as Md,p as Ea,q as Ca,r as jn,u as Yr,v as zs,P as Fa,Q as Bd,w as jd,x as Or,z as mu,B as as,D as Gt,F as ps,G as Ft}from"./index.es-ZeQVkZNG.js";import{c as qd,g as Wa,s as Fd,d as Wd,k as Hd,a as zd}from"./index-nibyPLVP.js";function Ha(t,e={}){const{key:s="fallback",name:r="Fallback",rank:i=!1,shouldThrow:n=Kd,retryCount:o,retryDelay:a}=e;return({chain:c,pollingInterval:l=4e3,timeout:u,...h})=>{let d=t,p=()=>{};const w=Nd({key:s,name:r,async request({method:f,params:m}){let y;const b=async(v=0)=>{const C=d[v]({...h,chain:c,retryCount:0,timeout:u});try{const I=await C.request({method:f,params:m});return p({method:f,params:m,response:I,transport:C,status:"success"}),I}catch(I){if(p({error:I,method:f,params:m,transport:C,status:"error"}),n(I)||v===d.length-1||(y??(y=d.slice(v+1).some(_=>{const{include:S,exclude:U}=_({chain:c}).config.methods||{};return S?S.includes(f):U?!U.includes(f):!0})),!y))throw I;return b(v+1)}};return b()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>p=f,transports:d.map(f=>f({chain:c,retryCount:0}))});if(i){const f=typeof i=="object"?i:{};Vd({chain:c,interval:f.interval??l,onTransports:m=>d=m,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:d,weights:f.weights})}return w}}function Kd(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Sd.code||t.code===Pd.code||Od.nodeMessage.test(t.message)||t.code===5e3))}function Vd({chain:t,interval:e=4e3,onTransports:s,ping:r,sampleCount:i=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],h=async()=>{const d=await Promise.all(o.map(async f=>{const m=f({chain:t,retryCount:0,timeout:n}),y=Date.now();let b,v;try{await(r?r({transport:m}):m.request({method:"net_listening"})),v=1}catch{v=0}finally{b=Date.now()}return{latency:b-y,success:v}}));u.push(d),u.length>i&&u.shift();const p=Math.max(...u.map(f=>Math.max(...f.map(({latency:m})=>m)))),w=o.map((f,m)=>{const y=u.map(_=>_[m].latency),v=1-y.reduce((_,S)=>_+S,0)/y.length/p,C=u.map(_=>_[m].success),I=C.reduce((_,S)=>_+S,0)/C.length;return I===0?[0,m]:[l*v+c*I,m]}).sort((f,m)=>m[0]-f[0]);s(w.map(([,f])=>o[f])),await Td(e),h()};h()}var za={};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 process<"u"&&typeof za<"u"?za.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},wu={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(s=>s.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){var i;if(!e)return;const s=t.find(n=>n.caipNetworkId===e);if(s)return s.name;const[r]=e.split(":");return((i=j.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}};var Gd=20,Jd=1,Ys=1e6,Ka=1e6,Yd=-7,Xd=21,Zd=!1,Fi="[big.js] ",rr=Fi+"Invalid ",qn=rr+"decimal places",Qd=rr+"rounding mode",yu=Fi+"Division by zero",ge={},Xt=void 0,ep=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function bu(){function t(e){var s=this;if(!(s instanceof t))return e===Xt?bu():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(rr+"value");e=e===0&&1/e<0?"-0":String(e)}tp(s,e)}s.constructor=t}return t.prototype=ge,t.DP=Gd,t.RM=Jd,t.NE=Yd,t.PE=Xd,t.strict=Zd,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function tp(t,e){var s,r,i;if(!ep.test(e))throw Error(rr+"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 ir(t,e,s,r){var i=t.c;if(s===Xt&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(Qd);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]!==Xt))),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]!==Xt||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 nr(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}ge.abs=function(){var t=new this.constructor(this);return t.s=1,t};ge.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};ge.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>Ys)throw Error(qn);if(!i[0])throw Error(yu);if(!r[0])return t.s=n,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),p=a=i.length,w=r.length,f=r.slice(0,a),m=f.length,y=t,b=y.c=[],v=0,C=o+(y.e=e.e-t.e)+1;for(y.s=n,n=C<0?0:C,d.unshift(0);m++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(m=f.length))u=a>m?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=f[h]){u=i[h]>f[h]?1:-1;break}if(u<0){for(c=m==a?i:d;m;){if(f[--m]<c[m]){for(h=m;h&&!f[--h];)f[h]=9;--f[h],f[m]+=10}f[m]-=c[m]}for(;!f[0];)f.shift()}else break}b[v++]=u?l:++l,f[0]&&u?f[m]=r[p]||0:f=[r[p]]}while((p++<w||f[0]!==Xt)&&n--);return!b[0]&&v!=1&&(b.shift(),y.e--,C--),v>C&&ir(y,C,s.RM,f[0]!==Xt),y};ge.eq=function(t){return this.cmp(t)===0};ge.gt=function(t){return this.cmp(t)>0};ge.gte=function(t){return this.cmp(t)>-1};ge.lt=function(t){return this.cmp(t)<0};ge.lte=function(t){return this.cmp(t)<1};ge.minus=ge.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};ge.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(yu);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)))};ge.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};ge.plus=ge.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};ge.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(rr+"exponent");for(i&&(t=-t);t&1&&(r=r.times(e)),t>>=1,!!t;)e=e.times(e);return i?s.div(r):r};ge.prec=function(t,e){if(t!==~~t||t<1||t>Ys)throw Error(rr+"precision");return ir(new this.constructor(this),t,e)};ge.round=function(t,e){if(t===Xt)t=0;else if(t!==~~t||t<-Ys||t>Ys)throw Error(qn);return ir(new this.constructor(this),t+this.e+1,e)};ge.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(Fi+"No square root");n=Math.sqrt(+nr(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 ir(t,(i.DP-=4)+t.e+1,i.RM)};ge.times=ge.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};ge.toExponential=function(t,e){var s=this,r=s.c[0];if(t!==Xt){if(t!==~~t||t<0||t>Ys)throw Error(qn);for(s=ir(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return nr(s,!0,!!r)};ge.toFixed=function(t,e){var s=this,r=s.c[0];if(t!==Xt){if(t!==~~t||t<0||t>Ys)throw Error(qn);for(s=ir(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return nr(s,!1,!!r)};ge[Symbol.for("nodejs.util.inspect.custom")]=ge.toJSON=ge.toString=function(){var t=this,e=t.constructor;return nr(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};ge.toNumber=function(){var t=+nr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Fi+"Imprecise conversion");return t};ge.toPrecision=function(t,e){var s=this,r=s.constructor,i=s.c[0];if(t!==Xt){if(t!==~~t||t<1||t>Ys)throw Error(rr+"precision");for(s=ir(new r(s),t,e);s.c.length<t;)s.c.push(0)}return nr(s,t<=s.e||s.e<=r.NE||s.e>=r.PE,!!i)};ge.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Fi+"valueOf disallowed");return nr(t,t.e<=e.NE||t.e>=e.PE,!0)};var ri=bu();const sp={bigNumber(t){return t?new ri(t):new ri(0)},multiply(t,e){if(t===void 0||e===void 0)return new ri(0);const s=new ri(t),r=new ri(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,""))}},rp=[{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"}]}],ip=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],np=[{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"}]}],op={getERC20Abi:t=>j.USDT_CONTRACT_ADDRESSES.includes(t)?np:rp,getSwapAbi:()=>ip},fs={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,r,i]=e;if(!s||!r||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:r,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,r]=e;if(!s||!r)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:r}}},ee={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 eo(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const Z={setItem(t,e){fi()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(fi())return localStorage.getItem(t)||void 0},removeItem(t){fi()&&localStorage.removeItem(t)},clear(){fi()&&localStorage.clear()}};function fi(){return typeof window<"u"&&typeof localStorage<"u"}function Is(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const ap=Symbol(),Va=Object.getPrototypeOf,Mo=new WeakMap,cp=t=>t&&(Mo.has(t)?Mo.get(t):Va(t)===Object.prototype||Va(t)===Array.prototype),lp=t=>cp(t)&&t[ap]||null,Ga=(t,e=!0)=>{Mo.set(t,e)};var Tn={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/blog-site/0.1.2",VITE_REACT_APP_DCL_DEFAULT_ENV:"dev",VITE_SEGMENT_PRD_API_KEY:"",VITE_SEGMENT_DEV_API_KEY:"",BASE_URL:"https://cdn.decentraland.org/@dcl/blog-site/0.1.2",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const to=t=>typeof t=="object"&&t!==null,bs=new WeakMap,gi=new WeakSet,up=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>to(l)&&!gi.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),r=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,n=(l,u,h=r)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const p=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Ga(p,!0),i.set(l,[u,p]),Reflect.ownKeys(l).forEach(w=>{if(Object.getOwnPropertyDescriptor(p,w))return;const f=Reflect.get(l,w),{enumerable:m}=Reflect.getOwnPropertyDescriptor(l,w),y={value:f,enumerable:m,configurable:!0};if(gi.has(f))Ga(f,!1);else if(f instanceof Promise)delete y.value,y.get=()=>h(f);else if(bs.has(f)){const[b,v]=bs.get(f);y.value=n(b,v(),h)}Object.defineProperty(p,w,y)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],c=l=>{if(!to(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,p=(E,$=++a[0])=>{h!==$&&(h=$,d.forEach(A=>A(E,$)))};let w=a[1];const f=(E=++a[1])=>(w!==E&&!d.size&&(w=E,y.forEach(([$])=>{const A=$[1](E);A>h&&(h=A)})),h),m=E=>($,A)=>{const L=[...$];L[1]=[E,...L[1]],p(L,A)},y=new Map,b=(E,$)=>{if((Tn?"production":void 0)!=="production"&&y.has(E))throw new Error("prop listener already exists");if(d.size){const A=$[3](m(E));y.set(E,[$,A])}else y.set(E,[$])},v=E=>{var $;const A=y.get(E);A&&(y.delete(E),($=A[1])==null||$.call(A))},C=E=>(d.add(E),d.size===1&&y.forEach(([A,L],z)=>{if((Tn?"production":void 0)!=="production"&&L)throw new Error("remove already exists");const N=A[3](m(z));y.set(z,[A,N])}),()=>{d.delete(E),d.size===0&&y.forEach(([A,L],z)=>{L&&(L(),y.set(z,[A]))})}),I=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e(I,{deleteProperty(E,$){const A=Reflect.get(E,$);v($);const L=Reflect.deleteProperty(E,$);return L&&p(["delete",[$],A]),L},set(E,$,A,L){const z=Reflect.has(E,$),N=Reflect.get(E,$,L);if(z&&(t(N,A)||o.has(A)&&t(N,o.get(A))))return!0;v($),to(A)&&(A=lp(A)||A);let x=A;if(A instanceof Promise)A.then(O=>{A.status="fulfilled",A.value=O,p(["resolve",[$],O])}).catch(O=>{A.status="rejected",A.reason=O,p(["reject",[$],O])});else{!bs.has(A)&&s(A)&&(x=c(A));const O=!gi.has(x)&&bs.get(x);O&&b($,O)}return Reflect.set(E,$,x,L),p(["set",[$],A,N]),!0}});o.set(l,S);const U=[I,f,n,C];return bs.set(S,U),Reflect.ownKeys(l).forEach(E=>{const $=Object.getOwnPropertyDescriptor(l,E);"value"in $&&(S[E]=l[E],delete $.value,delete $.writable),Object.defineProperty(I,E,$)}),S})=>[c,bs,gi,t,e,s,r,i,n,o,a],[hp]=up();function Pe(t={}){return hp(t)}function st(t,e,s){const r=bs.get(t);(Tn?"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 xi(t,e){const s=bs.get(t);(Tn?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,i,n]=s;return n(r,i(),e)}function Xs(t){return gi.add(t),t}function rt(t,e,s,r){let i=t[e];return st(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)})}function dp(t){const e=Pe({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 Ja={};const so=(typeof process<"u"&&typeof Ja<"u"?Ja.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",vu=[{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"]}],pp="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:so,SECURE_SITE_DASHBOARD:`${so}/dashboard`,SECURE_SITE_FAVICON:`${so}/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(ee.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Z.getItem(ee.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Z.removeItem(ee.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Z.setItem(ee.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Z.setItem(ee.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(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Z.removeItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=eo(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(ee.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Z.getItem(ee.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=eo(t);Z.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Z.getItem(ee.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=eo(t);return Z.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{Z.setItem(ee.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Z.getItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Z.removeItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Z.getItem(ee.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=Z.getItem(ee.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{Z.setItem(ee.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Z.getItem(ee.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Z.getItem(ee.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Z.setItem(ee.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(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Z.setItem(ee.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Z.removeItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Z.getItem(ee.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(ee.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(ee.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Z.getItem(ee.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(ee.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(ee.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Z.getItem(ee.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(ee.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=W.getEnsCache();Z.setItem(ee.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(ee.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(ee.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=W.getIdentityCache();Z.setItem(ee.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Z.removeItem(ee.PORTFOLIO_CACHE),Z.removeItem(ee.NATIVE_BALANCE_CACHE),Z.removeItem(ee.ENS_CACHE),Z.removeItem(ee.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Z.setItem(ee.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Z.getItem(ee.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(ee.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=Z.getItem(ee.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},X={isMobile(){var t;return this.isClient()?!!(typeof(window==null?void 0:window.matchMedia)=="function"&&((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return X.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=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==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(X.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],r="https://app.safe.global";if(s){const i=new URL(s),n=new URL(r);return i.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ie.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...r)=>{function i(){t(...r)}s&&clearTimeout(s),s=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(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!=null&&i.endsWith("/"))&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:r}},formatUniversalUrl(t,e){if(!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==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,r,i;if(typeof window>"u")return!1;const t=(r=(s=window.matchMedia)==null?void 0:s.call(window,"(display-mode: standalone)"))==null?void 0:r.matches,e=(i=window==null?void 0:window.navigator)==null?void 0:i.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,r)=>{const i=new Image;i.onload=s,i.onerror=r,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,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){var r;let s;if(t==="0")s="0";else if(typeof t=="string"){const i=Number(t);i&&(s=(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:r[0])}return{value:s??"0",rest:s==="0"?"000":"",symbol:e}},getApiUrl(){return j.W3M_API_URL},getBlockchainApiUrl(){return j.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return j.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((r,i)=>{s[r]=i}),e.sort((r,i)=>{const n=s[r.id],o=s[i.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,r]=e.split(".");return{dollars:s,pennies:r}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(r=>{const i=r[e];return s.has(i)?!1:(s.add(i),!0)})},generateSdkVersion(t,e,s){const i=t.length===0?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==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function ii(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class Wi{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 ii(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await ii(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await ii(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 ii(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 ii(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 fp={getFeatureValue(t,e){const s=e==null?void 0: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}},V=Pe({features:Ie.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ie.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),T={state:V,subscribeKey(t,e){return rt(V,t,e)},setOptions(t){Object.assign(V,t)},setRemoteFeatures(t){var s;if(!t)return;const e={...V.remoteFeatures,...t};V.remoteFeatures=e,(s=V.remoteFeatures)!=null&&s.socials&&(V.remoteFeatures.socials=fp.filterSocialsByPlatform(V.remoteFeatures.socials))},setFeatures(t){if(!t)return;V.features||(V.features=Ie.DEFAULT_FEATURES);const e={...V.features,...t};V.features=e},setProjectId(t){V.projectId=t},setCustomRpcUrls(t){V.customRpcUrls=t},setAllWallets(t){V.allWallets=t},setIncludeWalletIds(t){V.includeWalletIds=t},setExcludeWalletIds(t){V.excludeWalletIds=t},setFeaturedWalletIds(t){V.featuredWalletIds=t},setTokens(t){V.tokens=t},setTermsConditionsUrl(t){V.termsConditionsUrl=t},setPrivacyPolicyUrl(t){V.privacyPolicyUrl=t},setCustomWallets(t){V.customWallets=t},setIsSiweEnabled(t){V.isSiweEnabled=t},setIsUniversalProvider(t){V.isUniversalProvider=t},setSdkVersion(t){V.sdkVersion=t},setMetadata(t){V.metadata=t},setDisableAppend(t){V.disableAppend=t},setEIP6963Enabled(t){V.enableEIP6963=t},setDebug(t){V.debug=t},setEnableWalletConnect(t){V.enableWalletConnect=t},setEnableWalletGuide(t){V.enableWalletGuide=t},setEnableAuthLogger(t){V.enableAuthLogger=t},setEnableWallets(t){V.enableWallets=t},setPreferUniversalLinks(t){V.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){V.hasMultipleAddresses=t},setSIWX(t){V.siwx=t},setConnectMethodsOrder(t){V.features={...V.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){V.features={...V.features,walletFeaturesOrder:t}},setSocialsOrder(t){V.remoteFeatures={...V.remoteFeatures,socials:t}},setCollapseWallets(t){V.features={...V.features,collapseWallets:t}},setEnableEmbedded(t){V.enableEmbedded=t},setAllowUnsupportedChain(t){V.allowUnsupportedChain=t},setManualWCControl(t){V.manualWCControl=t},setEnableNetworkSwitch(t){V.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(V.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){V.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return V.universalProviderConfigOverride},getSnapshot(){return xi(V)}},gp=Object.freeze({enabled:!0,events:[]}),mp=new Wi({baseUrl:X.getAnalyticsUrl(),clientId:null}),wp=5,yp=60*1e3,gs=Pe({...gp}),bp={state:gs,subscribeKey(t,e){return rt(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<yp}).length>=wp)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}=T.state;await mp.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 Br extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,Br.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
3
3
|
`);if(o>-1){const a=n.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
4
4
|
${a}`,i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,Br):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Ya(t,e){const s=t instanceof Br?t:new Br(t instanceof Error?t.message:String(t),e,t);throw bp.sendError(s,s.category),s}function At(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 Ya(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return Ya(a,e)}},s[r]=n}else s[r]=i}),s}const Jt={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},vp={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===Jt.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${Jt.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===Jt.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${Jt.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===j.CHAIN.SOLANA&&t===Jt.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${Jt.COINBASE.url}/dapp?cb_url=${r}`)}},mt=Pe({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Ep={state:mt,subscribeNetworkImages(t){return st(mt.networkImages,()=>t(mt.networkImages))},subscribeKey(t,e){return rt(mt,t,e)},subscribe(t){return st(mt,()=>t(mt))},setWalletImage(t,e){mt.walletImages[t]=e},setNetworkImage(t,e){mt.networkImages[t]=e},setChainImage(t,e){mt.chainImages[t]=e},setConnectorImage(t,e){mt.connectorImages={...mt.connectorImages,[t]:e}},setTokenImage(t,e){mt.tokenImages[t]=e},setCurrencyImage(t,e){mt.currencyImages[t]=e}},Bt=At(Ep),Cp={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},ro=Pe({networkImagePromises:{}}),Eu={async fetchWalletImage(t){if(t)return await K._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(ro.networkImagePromises[t]||(ro.networkImagePromises[t]=K._fetchNetworkImage(t)),await ro.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Bt.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return Bt.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,r;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((r=t==null?void 0:t.assets)!=null&&r.imageId)return Bt.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Bt.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Bt.state.connectorImages[t.imageId]},getChainImage(t){return Bt.state.networkImages[Cp[t]]}},ms=Pe({message:"",variant:"info",open:!1}),Ip={state:ms,subscribeKey(t,e){return rt(ms,t,e)},open(t,e){const{debug:s}=T.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=At(Ip),_p=X.getAnalyticsUrl(),Ap=new Wi({baseUrl:_p,clientId:null}),Np=["MODAL_CREATED"],rs=Pe({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Te={state:rs,subscribe(t){return st(rs,()=>t(rs))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=T.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=H.state.address;if(Np.includes(t.data.event)||typeof window>"u")return;await Ap.post({path:"/e",params:Te.getSdkProperties(),body:{eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),rs.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===j.HTTP_STATUS_CODES.FORBIDDEN&&!rs.reportedErrors.FORBIDDEN&&(qs.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${fi()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),rs.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;rs.timestamp=Date.now(),rs.data=t,(e=T.state.features)!=null&&e.analytics&&Te._sendAnalyticsEvent(rs)}},Sp=X.getApiUrl(),at=new Wi({baseUrl:Sp,clientId:null}),Pp=40,Xa=4,Op=20,te=Pe({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),K={state:te,subscribeKey(t,e){return rt(te,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=T.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return T.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${at.baseUrl}/getWalletImage/${t}`,s=await at.getBlob({path:e,params:K._getSdkProperties()});Bt.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${at.baseUrl}/public/getAssetImage/${t}`,s=await at.getBlob({path:e,params:K._getSdkProperties()});Bt.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${at.baseUrl}/public/getAssetImage/${t}`,s=await at.getBlob({path:e,params:K._getSdkProperties()});Bt.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${at.baseUrl}/public/getCurrencyImage/${t}`,s=await at.getBlob({path:e,params:K._getSdkProperties()});Bt.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${at.baseUrl}/public/getTokenImage/${t}`,s=await at.getBlob({path:e,params:K._getSdkProperties()});Bt.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return X.isMobile()?t==null?void 0:t.filter(s=>s.mobile_link||s.id===Jt.COINBASE.id?!0:g.state.activeChain==="solana"&&(s.id===Jt.SOLFLARE.id||s.id===Jt.PHANTOM.id)):t},async fetchProjectConfig(){return(await at.get({path:"/appkit/v1/config",params:K._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await at.get({path:"/projects/v1/origins",params:K._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=g.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!Eu.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>K._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=q.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>K._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>K._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>K._fetchTokenImage(e)))},async fetchWallets(t){var n;const e=t.exclude??[];K._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(Jt).map(o=>o.id));const r=await at.get({path:"/getWallets",params:{...K._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(n=t.include)==null?void 0:n.join(","),exclude:e.join(",")}});return{data:K._filterWalletsByPlatform(r==null?void 0:r.data)||[],count:r==null?void 0:r.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=T.state;if(t!=null&&t.length){const e={...K._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Xa,include:t},{data:s}=await K.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=>K._fetchWalletImage(n))),te.featured=r,te.allFeatured=r}},async fetchRecommendedWallets(){try{te.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=T.state,r=[...e??[],...s??[]].filter(Boolean),i=g.getRequestedCaipNetworkIds().join(","),n={page:1,entries:Xa,include:t,exclude:r,chains:i},{data:o,count:a}=await K.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=>K._fetchWalletImage(h))),te.recommended=o,te.allRecommended=o,te.count=a??0}catch{}finally{te.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=T.state,i=g.getRequestedCaipNetworkIds().join(","),n=[...te.recommended.map(({id:u})=>u),...s??[],...r??[]].filter(Boolean),o={page:t,entries:Pp,include:e,exclude:n,chains:i},{data:a,count:c}=await K.fetchWallets(o),l=a.slice(0,Op).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>K._fetchWalletImage(u))),te.wallets=X.uniqueBy([...te.wallets,...K._filterOutExtensions(a)],"id").filter(u=>{var h;return(h=u.chains)==null?void 0:h.some(d=>i.includes(d))}),te.count=c>te.count?c:te.count,te.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await K.fetchWallets(e);s&&s.forEach(r=>{te.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=T.state,i=g.getRequestedCaipNetworkIds().join(",");te.search=[];const n={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:r,chains:i},{data:o}=await K.fetchWallets(n);Te.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=>K._fetchWalletImage(c)),X.wait(300)]),te.search=K._filterOutExtensions(o)},initPromise(t,e){const s=te.promises[t];return s||(te.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&K.initPromise("connectorImages",K.fetchConnectorImages),e&&K.initPromise("featuredWallets",K.fetchFeaturedWallets),s&&K.initPromise("recommendedWallets",K.fetchRecommendedWallets),r&&K.initPromise("networkImages",K.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=T.state.features)!=null&&t.analytics&&K.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await at.get({path:"/getAnalyticsConfig",params:K._getSdkProperties()});T.setFeatures({analytics:t})}catch{T.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){te.featured=te.allFeatured,te.recommended=te.allRecommended;return}const e=g.getRequestedCaipNetworkIds().join(",");te.featured=te.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.recommended=te.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.filteredWallets=te.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})},clearFilterByNamespaces(){te.filteredWallets=[]},setFilterByNamespace(t){if(!t){te.featured=te.allFeatured,te.recommended=te.allRecommended;return}const e=g.getRequestedCaipNetworkIds().join(",");te.featured=te.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.recommended=te.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),te.filteredWallets=te.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})}},me=Pe({view:"Connect",history:["Connect"],transactionStack:[]}),Tp={state:me,subscribeKey(t,e){return rt(me,t,e)},pushTransactionStack(t){me.transactionStack.push(t)},popTransactionStack(t){const e=me.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:r,onCancel:i}=e;switch(t){case"success":s==null||s();break;case"error":r==null||r(),re.goBack();break;case"cancel":i==null||i(),re.goBack();break}},push(t,e){t!==me.view&&(me.view=t,me.history.push(t),me.data=e)},reset(t,e){me.view=t,me.history=[t],me.data=e},replace(t,e){me.history.at(-1)===t||(me.view=t,me.history[me.history.length-1]=t,me.data=e)},goBack(){var r;const t=g.state.activeCaipAddress,e=re.state.view==="ConnectingFarcaster",s=!t&&e;if(me.history.length>1){me.history.pop();const[i]=me.history.slice(-1);i&&(t&&i==="Connect"?me.view="Account":me.view=i)}else Ve.close();(r=me.data)!=null&&r.wallet&&(me.data.wallet=void 0),setTimeout(()=>{var i,n,o;if(s){H.setFarcasterUrl(void 0,g.state.activeChain);const a=q.getAuthConnector();(i=a==null?void 0:a.provider)==null||i.reload();const c=xi(T.state);(o=(n=a==null?void 0:a.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:c.metadata,sdkVersion:c.sdkVersion,projectId:c.projectId,sdkType:c.sdkType})}},100)},goBackToIndex(t){if(me.history.length>1){me.history=me.history.slice(0,t+1);const[e]=me.history.slice(-1);e&&(me.view=e)}},goBackOrCloseModal(){re.state.history.length>1?re.goBack():Ve.close()}},re=At(Tp),is=Pe({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),Bo={state:is,subscribe(t){return st(is,()=>t(is))},setThemeMode(t){is.themeMode=t;try{const e=q.getAuthConnector();if(e){const s=Bo.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){is.themeVariables={...is.themeVariables,...t};try{const e=q.getAuthConnector();if(e){const s=Bo.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:Is(is.themeVariables,is.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return xi(is)}},bt=At(Bo),Cu={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ae=Pe({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Cu},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),xp={state:ae,subscribe(t){return st(ae,()=>{t(ae)})},subscribeKey(t,e){return rt(ae,t,e)},initialize(t){t.forEach(e=>{const s=W.getConnectedConnectorId(e);s&&q.setConnectorId(s,e)})},setActiveConnector(t){t&&(ae.activeConnector=Xs(t))},setConnectors(t){t.filter(i=>!ae.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"&&ae.allConnectors.push(Xs(i))});const s=q.getEnabledNamespaces(),r=q.getEnabledConnectors(s);ae.connectors=q.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(ae.filterByNamespaceMap).forEach(e=>{ae.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ae.filterByNamespaceMap[e]=!0}),q.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ae.filterByNamespaceMap[t]=e,q.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=q.getEnabledNamespaces(),e=q.getEnabledConnectors(t),s=q.areAllNamespacesEnabled();ae.connectors=q.mergeMultiChainConnectors(e),s?K.clearFilterByNamespaces():K.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ae.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ae.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ae.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=q.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=(i==null?void 0: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==null?void 0:i.id)||""}):i&&s.push(i)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:r}=s,i=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){var e,s,r;if(t.id===j.CONNECTOR_ID.AUTH){const i=t,n=xi(T.state),o=bt.getSnapshot().themeMode,a=bt.getSnapshot().themeVariables;(s=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(r=i==null?void 0:i.provider)==null||r.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:Is(a,o)}),q.setConnectors([t])}else q.setConnectors([t])},getAuthConnector(t){var r;const e=t||g.state.activeChain,s=ae.connectors.find(i=>i.id===j.CONNECTOR_ID.AUTH);if(s)return(r=s==null?void 0:s.connectors)!=null&&r.length?s.connectors.find(n=>n.chain===e):s},getAnnouncedConnectorRdns(){return ae.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return ae.allConnectors.find(e=>e.id===t)},getConnector(t,e){return ae.allConnectors.filter(r=>r.chain===g.state.activeChain).find(r=>{var i;return r.explorerId===t||((i=r.info)==null?void 0:i.rdns)===e})},syncIfAuthConnector(t){var n,o;if(t.id!=="ID_AUTH")return;const e=t,s=xi(T.state),r=bt.getSnapshot().themeMode,i=bt.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:r,themeVariables:i,w3mThemeVariables:Is(i,r)})},getConnectorsByNamespace(t){const e=ae.allConnectors.filter(s=>s.chain===t);return q.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=q.getConnector(t.id,t.rdns),s=g.state.activeChain;vp.handleMobileDeeplinkRedirect((e==null?void 0:e.explorerId)||t.id,s),e?re.push("ConnectingExternal",{connector:e}):re.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?q.getConnectorsByNamespace(t):q.mergeMultiChainConnectors(ae.allConnectors)},setFilterByNamespace(t){ae.filterByNamespace=t,ae.connectors=q.getConnectors(t),K.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ae.activeConnectorIds={...ae.activeConnectorIds,[e]:t},W.setConnectedConnectorId(e,t))},removeConnectorId(t){ae.activeConnectorIds={...ae.activeConnectorIds,[t]:void 0},W.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ae.activeConnectorIds[t]},isConnected(t){return t?!!ae.activeConnectorIds[t]:Object.values(ae.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ae.activeConnectorIds={...Cu}}},q=At(xp),Ei={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}),Le=Pe({...Bs}),kp={state:Le,subscribeKey(t,e){return rt(Le,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(){Le.message=Bs.message,Le.variant=Bs.variant,Le.svg=Bs.svg,Le.open=Bs.open,Le.autoClose=Bs.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=Bs.autoClose}){Le.open?(Le.open=!1,setTimeout(()=>{Le.message=t,Le.variant=s,Le.svg=e,Le.open=!0,Le.autoClose=r},150)):(Le.message=t,Le.variant=s,Le.svg=e,Le.open=!0,Le.autoClose=r)}},jt=kp,Ae=Pe({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),$p={state:Ae,subscribe(t){return st(Ae,()=>t(Ae))},setLastNetworkInView(t){Ae.lastNetworkInView=t},async fetchTransactions(t,e){var s,r;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Ae.loading=!0;try{const i=await J.fetchTransactions({account:t,cursor:Ae.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId}),n=mi.filterSpamTransactions(i.data),o=mi.filterByConnectedChain(n),a=[...Ae.transactions,...o];Ae.loading=!1,e==="coinbase"?Ae.coinbaseTransactions=mi.groupTransactionsByYearAndMonth(Ae.coinbaseTransactions,i.data):(Ae.transactions=a,Ae.transactionsByYear=mi.groupTransactionsByYearAndMonth(Ae.transactionsByYear,o)),Ae.empty=a.length===0,Ae.next=i.next?i.next:void 0}catch{const n=g.state.activeChain;Te.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:T.state.projectId,cursor:Ae.next,isSmartAccount:((r=H.state.preferredAccountTypes)==null?void 0:r[n])===Ei.ACCOUNT_TYPES.SMART_ACCOUNT}}),jt.showError("Failed to fetch transactions"),Ae.loading=!1,Ae.empty=!0,Ae.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(r=>{const i=new Date(r.metadata.minedAt).getFullYear(),n=new Date(r.metadata.minedAt).getMonth(),o=s[i]??{},c=(o[n]??[]).filter(l=>l.id!==r.id);s[i]={...o,[n]:[...c,r].sort((l,u)=>new Date(u.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=g.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){Ae.next=void 0},resetTransactions(){Ae.transactions=[],Ae.transactionsByYear={},Ae.lastNetworkInView=void 0,Ae.loading=!1,Ae.empty=!1,Ae.next=void 0}},mi=At($p,"API_ERROR"),ve=Pe({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Us;const Rp={state:ve,subscribeKey(t,e){return rt(ve,t,e)},_getClient(){return ve._client},setClient(t){ve._client=Xs(t)},async connectWalletConnect(){var t,e,s,r;if(X.isTelegram()||X.isSafari()&&X.isIos()){if(Us){await Us,Us=void 0;return}if(!X.isPairingExpired(ve==null?void 0:ve.wcPairingExpiry)){const i=ve.wcUri;ve.wcUri=i;return}Us=(e=(t=Y._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),Y.state.status="connecting",await Us,Us=void 0,ve.wcPairingExpiry=void 0,Y.state.status="connected"}else await((r=(s=Y._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:r.call(s))},async connectExternal(t,e,s=!0){var r,i;await((i=(r=Y._getClient())==null?void 0:r.connectExternal)==null?void 0:i.call(r,t)),s&&g.setActiveNamespace(e)},async reconnectExternal(t){var s,r;await((r=(s=Y._getClient())==null?void 0:s.reconnectExternal)==null?void 0:r.call(s,t));const e=t.chain||g.state.activeChain;e&&q.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var r;Ve.setLoading(!0,g.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),Ve.setLoading(!1,g.state.activeChain),Te.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((r=g.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=Y._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=Y._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=Y._getClient())==null?void 0:s.formatUnits(t,e)},async sendTransaction(t){var e;return(e=Y._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=Y._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=Y._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=Y._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=Y._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=Y._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=Y._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=Y._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=Y._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){ve.wcUri=void 0,ve.wcPairingExpiry=void 0,ve.wcLinking=void 0,ve.recentWallet=void 0,ve.status="disconnected",mi.resetTransactions(),W.deleteWalletConnectDeepLink()},resetUri(){ve.wcUri=void 0,ve.wcPairingExpiry=void 0,Us=void 0},finalizeWcConnection(){var s,r;const{wcLinking:t,recentWallet:e}=Y.state;t&&W.setWalletConnectDeepLink(t),e&&W.setAppKitRecent(e),Te.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((r=(s=re.state.data)==null?void 0:s.wallet)==null?void 0:r.name)||"Unknown"}})},setWcBasic(t){ve.wcBasic=t},setUri(t){ve.wcUri=t,ve.wcPairingExpiry=X.getPairingExpiry()},setWcLinking(t){ve.wcLinking=t},setWcError(t){ve.wcError=t,ve.buffering=!1},setRecentWallet(t){ve.recentWallet=t},setBuffering(t){ve.buffering=t},setStatus(t){ve.status=t},async disconnect(t){var e;try{await((e=Y._getClient())==null?void 0:e.disconnect(t))}catch(s){throw new Br("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){ve.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(q.state.activeConnectorIds[s]===t.connectorId){const n=g.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=At(Rp),cr=Pe({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),As={state:cr,subscribe(t){return st(cr,()=>t(cr))},subscribeOpen(t){return rt(cr,"open",t)},set(t){Object.assign(cr,{...cr,...t})}},io={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 xd(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"}},Za={async getMyTokensWithBalance(t){const e=H.state.address,s=g.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){var s,r;try{const i=io.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await Y.getCapabilities(t);if(!((r=(s=n==null?void 0:n[i])==null?void 0:s.assetDiscovery)!=null&&r.supported))return null;const o=await Y.walletGetAssets({account:t,chainFilter:[i]});return io.isWalletGetAssetsResponse(o)?(o[i]||[]).map(c=>io.createBalance(c,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:g.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},fe=Pe({tokenBalances:[],loading:!1}),Up={state:fe,subscribe(t){return st(fe,()=>t(fe))},subscribeKey(t,e){return rt(fe,t,e)},setToken(t){t&&(fe.token=Xs(t))},setTokenAmount(t){fe.sendTokenAmount=t},setReceiverAddress(t){fe.receiverAddress=t},setReceiverProfileImageUrl(t){fe.receiverProfileImageUrl=t},setReceiverProfileName(t){fe.receiverProfileName=t},setNetworkBalanceInUsd(t){fe.networkBalanceInUSD=t},setLoading(t){fe.loading=t},async sendToken(){var t;try{switch(he.setLoading(!0),(t=g.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await he.sendEvmToken();return;case"solana":await he.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}finally{he.setLoading(!1)}},async sendEvmToken(){var s,r,i,n;const t=g.state.activeChain,e=(s=H.state.preferredAccountTypes)==null?void 0:s[t];if(!he.state.sendTokenAmount||!he.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!he.state.token)throw new Error("A token is required");(r=he.state.token)!=null&&r.address?(Te.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ei.ACCOUNT_TYPES.SMART_ACCOUNT,token:he.state.token.address,amount:he.state.sendTokenAmount,network:((i=g.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),await he.sendERC20Token({receiverAddress:he.state.receiverAddress,tokenAddress:he.state.token.address,sendTokenAmount:he.state.sendTokenAmount,decimals:he.state.token.quantity.decimals})):(Te.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ei.ACCOUNT_TYPES.SMART_ACCOUNT,token:he.state.token.symbol||"",amount:he.state.sendTokenAmount,network:((n=g.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}),await he.sendNativeToken({receiverAddress:he.state.receiverAddress,sendTokenAmount:he.state.sendTokenAmount,decimals:he.state.token.quantity.decimals}))},async fetchTokenBalance(t){var n,o;fe.loading=!0;const e=(n=g.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=g.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=g.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(fe.lastRetry&&!X.isAllowedRetry(fe.lastRetry,30*Ie.ONE_SEC_MS))return fe.loading=!1,[];try{if(i&&e&&s){const a=await Za.getMyTokensWithBalance();return fe.tokenBalances=a,fe.lastRetry=void 0,a}}catch(a){fe.lastRetry=Date.now(),t==null||t(a),jt.showError("Token Balance Unavailable")}finally{fe.loading=!1}return[]},fetchNetworkBalance(){if(fe.tokenBalances.length===0)return;const t=Za.mapBalancesToSwapTokens(fe.tokenBalances);if(!t)return;const e=t.find(s=>s.address===g.getActiveNetworkTokenAddress());e&&(fe.networkBalanceInUSD=e?sp.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var n,o,a,c;re.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)}),Te.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:((n=H.state.preferredAccountTypes)==null?void 0:n.eip155)===Ei.ACCOUNT_TYPES.SMART_ACCOUNT,token:((o=he.state.token)==null?void 0:o.symbol)||"",amount:t.sendTokenAmount,network:((a=g.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||""}}),(c=Y._getClient())==null||c.updateBalance("eip155"),he.resetSend()},async sendERC20Token(t){re.pushTransactionStack({onSuccess(){re.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:op.getERC20Abi(s),chainNamespace:"eip155"}),he.resetSend()}},async sendSolanaToken(){var t;if(!he.state.sendTokenAmount||!he.state.receiverAddress)throw new Error("An amount and receiver address are required");re.pushTransactionStack({onSuccess(){re.replace("Account")}}),await Y.sendTransaction({chainNamespace:"solana",to:he.state.receiverAddress,value:he.state.sendTokenAmount}),(t=Y._getClient())==null||t.updateBalance("solana"),he.resetSend()},resetSend(){fe.token=void 0,fe.sendTokenAmount=void 0,fe.receiverAddress=void 0,fe.receiverProfileImageUrl=void 0,fe.receiverProfileName=void 0,fe.loading=!1,fe.tokenBalances=[]}},he=At(Up),no={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},sn={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},M=Pe({chains:dp(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),Dp={state:M,subscribe(t){return st(M,()=>{t(M)})},subscribeKey(t,e){return rt(M,t,e)},subscribeChainProp(t,e,s){let r;return st(M.chains,()=>{var n;const i=s||M.activeChain;if(i){const o=(n=M.chains.get(i))==null?void 0:n[t];r!==o&&(r=o,e(o))}})},initialize(t,e,s){const{chainId:r,namespace:i}=W.getActiveNetworkProps(),n=e==null?void 0:e.find(u=>u.id.toString()===(r==null?void 0:r.toString())),a=t.find(u=>(u==null?void 0:u.namespace)===i)||(t==null?void 0:t[0]),c=t.map(u=>u.namespace).filter(u=>u!==void 0),l=T.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(u=>u.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(M.noAdapters=!0),M.noAdapters||(M.activeChain=a==null?void 0:a.namespace,M.activeCaipNetwork=n,g.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),M.activeChain&&As.set({activeChain:a==null?void 0:a.namespace})),l.forEach(u=>{const h=e==null?void 0:e.filter(d=>d.chainNamespace===u);g.state.chains.set(u,{namespace:u,networkState:Pe({...sn,caipNetwork:h==null?void 0:h[0]}),accountState:Pe(no),caipNetworks:h??[],...s}),g.setRequestedCaipNetworks(h??[],u)})},removeAdapter(t){var e,s;if(M.activeChain===t){const r=Array.from(M.chains.entries()).find(([i])=>i!==t);if(r){const i=(s=(e=r[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];i&&g.setActiveCaipNetwork(i)}}M.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){M.chains.set(t.namespace,{namespace:t.namespace,networkState:{...sn,caipNetwork:r[0]},accountState:no,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),g.setRequestedCaipNetworks((r==null?void 0:r.filter(i=>i.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=M.chains.get(t.chainNamespace);if(e){const r=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(i=>i.id===t.id)||r.push(t),M.chains.set(t.chainNamespace,{...e,caipNetworks:r}),g.setRequestedCaipNetworks(r,t.chainNamespace),q.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var r,i,n;const s=M.chains.get(t);if(s){const o=((r=M.activeCaipNetwork)==null?void 0:r.id)===e,a=[...((i=s.caipNetworks)==null?void 0:i.filter(c=>c.id!==e))||[]];o&&((n=s==null?void 0:s.caipNetworks)!=null&&n[0])&&g.setActiveCaipNetwork(s.caipNetworks[0]),M.chains.set(t,{...s,caipNetworks:a}),g.setRequestedCaipNetworks(a||[],t),a.length===0&&q.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=M.chains.get(t);s&&(s.networkState={...s.networkState||sn,...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||no,...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||sn,...e};M.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){g.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&q.removeConnectorId(s)},setActiveNamespace(t){var r,i;M.activeChain=t;const e=t?M.chains.get(t):void 0,s=(r=e==null?void 0:e.networkState)==null?void 0:r.caipNetwork;s!=null&&s.id&&t&&(M.activeCaipAddress=(i=e==null?void 0:e.accountState)==null?void 0:i.caipAddress,M.activeCaipNetwork=s,g.setChainNetworkData(t,{caipNetwork:s}),W.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),As.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var r,i,n;if(!t)return;M.activeChain!==t.chainNamespace&&g.setIsSwitchingNamespace(!0);const e=M.chains.get(t.chainNamespace);M.activeChain=t.chainNamespace,M.activeCaipNetwork=t,g.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),(r=e==null?void 0:e.accountState)!=null&&r.address?M.activeCaipAddress=`${t.chainNamespace}:${t.id}:${(i=e==null?void 0:e.accountState)==null?void 0:i.address}`:M.activeCaipAddress=void 0,g.setAccountProp("caipAddress",M.activeCaipAddress,t.chainNamespace),e&&H.replaceState(e.accountState),he.resetSend(),As.set({activeChain:M.activeChain,selectedNetworkId:(n=M.activeCaipNetwork)==null?void 0:n.caipNetworkId}),W.setActiveCaipNetworkId(t.caipNetworkId),!g.checkIfSupportedNetwork(t.chainNamespace)&&T.state.enableNetworkSwitch&&!T.state.allowUnsupportedChain&&!Y.state.wcBasic&&g.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=M.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var i;if(!t)return;const e=t!==g.state.activeChain,s=(i=g.getNetworkData(t))==null?void 0:i.caipNetwork,r=g.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&r&&await g.switchActiveNetwork(r)},async switchActiveNetwork(t){var i;const e=g.state.chains.get(g.state.activeChain),s=!((i=e==null?void 0:e.caipNetworks)!=null&&i.some(n=>{var o;return n.id===((o=M.activeCaipNetwork)==null?void 0:o.id)})),r=g.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&Ve.close()}catch{re.goBack()}Te.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!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(t,e){var i;let s=M.activeChain;if(e&&(s=e),!s)return;const r=(i=M.chains.get(s))==null?void 0:i.accountState;if(r)return r[t]},getNetworkProp(t,e){var r;const s=(r=M.chains.get(e))==null?void 0:r.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=M.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:r=[]}=(e==null?void 0:e.networkState)||{};return X.sortRequestedNetworks(s,r)},getAllRequestedCaipNetworks(){const t=[];return M.chains.forEach(e=>{const s=g.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){g.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=g.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));q.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return M.chains.forEach(e=>{const s=g.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(){return M.activeCaipNetwork},getActiveCaipAddress(){return M.activeCaipAddress},getApprovedCaipNetworkIds(t){var r;const e=M.chains.get(t);return((r=e==null?void 0:e.networkState)==null?void 0:r.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(t){const e=g.getNetworkControllerClient(),s=await(e==null?void 0:e.getApprovedCaipNetworksData());g.setAdapterNetworkState(t,{approvedCaipNetworkIds:s==null?void 0:s.approvedCaipNetworkIds,supportsAllNetworks:s==null?void 0:s.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||M.activeCaipNetwork,r=g.getRequestedCaipNetworks(t);return r.length?r==null?void 0:r.some(i=>i.id===(s==null?void 0:s.id)):!0},checkIfSupportedChainId(t){if(!M.activeChain)return!0;const e=g.getRequestedCaipNetworks(M.activeChain);return e==null?void 0:e.some(s=>s.id===t)},setSmartAccountEnabledNetworks(t,e){g.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){var r;const t=wu.caipNetworkIdToNumber((r=M.activeCaipNetwork)==null?void 0:r.caipNetworkId),e=M.activeChain;if(!e||!t)return!1;const s=g.getNetworkProp("smartAccountEnabledNetworks",e);return!!(s!=null&&s.includes(Number(t)))},getActiveNetworkTokenAddress(){var r,i;const t=((r=M.activeCaipNetwork)==null?void 0:r.chainNamespace)||"eip155",e=((i=M.activeCaipNetwork)==null?void 0:i.id)||1,s=Ie.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){Ve.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=M.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Ie.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){g.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,g.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(){var s,r;const t=[];let e;if(M.chains.forEach(i=>{j.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===i.namespace)&&i.namespace&&t.push(i.namespace)}),t.length>0){const i=t[0];return e=i?(r=(s=M.chains.get(i))==null?void 0:s.caipNetworks)==null?void 0:r[0]:void 0,e}},getAccountData(t){var e;return t?(e=g.state.chains.get(t))==null?void 0:e.accountState:H.state},getNetworkData(t){var s;const e=t||M.activeChain;if(e)return(s=g.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var i,n,o;if(!t)return;const s=g.state.chains.get(t),r=(i=s==null?void 0:s.caipNetworks)==null?void 0:i.find(a=>a.id===e);return r||((n=s==null?void 0:s.networkState)==null?void 0:n.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=q.state.filterByNamespace;return(t?[M.chains.get(t)]:Array.from(M.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?g.getRequestedCaipNetworks(t):g.getAllRequestedCaipNetworks()}},g=At(Dp),Lp={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"}]}]},Iu=X.getBlockchainApiUrl(),ct=Pe({clientId:null,api:new Wi({baseUrl:Iu,clientId:null}),supportedChains:{http:[],ws:[]}}),J={state:ct,async get(t){const{st:e,sv:s}=J.getSdkProperties(),r=T.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return ct.api.get({...t,params:i})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=T.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{ct.supportedChains.http.length||await J.getSupportedNetworks()}catch{return!1}return ct.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await J.get({path:"v1/supported-chains"});return ct.supportedChains=t,t}catch{return ct.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:g.state.activeCaipAddress?X.getPlainAddress(g.state.activeCaipAddress):void 0}});return W.updateIdentityCache({address:t,identity:i,timestamp:Date.now()}),i},async fetchTransactions({account:t,cursor:e,onramp:s,signal:r,cache:i,chainId:n}){var a;return await J.isNetworkSupported((a=g.state.activeCaipNetwork)==null?void 0:a.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}){var o;return await J.isNetworkSupported((o=g.state.activeCaipNetwork)==null?void 0:o.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}){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?ct.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:T.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var r;return await J.isNetworkSupported((r=g.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?J.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var i;const{st:e,sv:s}=J.getSdkProperties();if(!await J.isNetworkSupported((i=g.state.activeCaipNetwork)==null?void 0:i.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}){var o;if(!await J.isNetworkSupported((o=g.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return ct.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ie.CONVERT_SLIPPAGE_TOLERANCE},projectId:T.state.projectId,from:e,to:s,userAddress:r,disableEstimate:i}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported((o=g.state.activeCaipNetwork)==null?void 0:o.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){var l;const{st:r,sv:i}=J.getSdkProperties();if(!await J.isNetworkSupported((l=g.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return jt.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){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/reverse/${t}`,params:{sender:H.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:r}){var n;return await J.isNetworkSupported((n=g.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?ct.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:r},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:r,paymentAmount:i}){var a;return await J.isNetworkSupported((a=g.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await ct.api.post({path:"/v1/generators/onrampurl",params:{projectId:T.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:i}})).url:""},async getOnrampOptions(){var e;if(!await J.isNetworkSupported((e=g.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await J.get({path:"/v1/onramp/options"})}catch{return Lp}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){var i;try{return await J.isNetworkSupported((i=g.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?await ct.api.post({path:"/v1/onramp/quote",params:{projectId:T.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}}):null}catch{return{coinbaseFee:{amount:s,currency:e.id},networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await J.isNetworkSupported((s=g.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var i;return await J.isNetworkSupported((i=g.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?ct.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:T.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){ct.clientId=t,ct.api=new Wi({baseUrl:Iu,clientId:t})}},Nt=Pe({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),Mp={state:Nt,replaceState(t){t&&Object.assign(Nt,Xs(t))},subscribe(t){return g.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return g.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){g.setAccountProp("status",t,e)},getCaipAddress(t){return g.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?X.getPlainAddress(t):void 0;e===g.state.activeChain&&(g.state.activeCaipAddress=t),g.setAccountProp("caipAddress",t,e),g.setAccountProp("address",s,e)},setBalance(t,e,s){g.setAccountProp("balance",t,s),g.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){g.setAccountProp("profileName",t,e)},setProfileImage(t,e){g.setAccountProp("profileImage",t,e)},setUser(t,e){g.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){g.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){g.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){g.setAccountProp("currentTab",t,g.state.activeChain)},setTokenBalance(t,e){t&&g.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){g.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){g.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=g.getAccountProp("addressLabels",s)||new Map;r.set(t,e),g.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=g.getAccountProp("addressLabels",e)||new Map;s.delete(t),g.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){g.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){g.setAccountProp("preferredAccountTypes",{...Nt.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){Nt.preferredAccountTypes=t},setSocialProvider(t,e){t&&g.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){g.setAccountProp("socialWindow",t?Xs(t):void 0,e)},setFarcasterUrl(t,e){g.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){var n,o;Nt.balanceLoading=!0;const e=(n=g.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=g.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=g.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(Nt.lastRetry&&!X.isAllowedRetry(Nt.lastRetry,30*Ie.ONE_SEC_MS))return Nt.balanceLoading=!1,[];try{if(i&&e&&s){const c=(await J.getBalance(i,e)).balances.filter(l=>l.quantity.decimals!=="0");return H.setTokenBalance(c,s),Nt.lastRetry=void 0,Nt.balanceLoading=!1,c}}catch(a){Nt.lastRetry=Date.now(),t==null||t(a),jt.showError("Token Balance Unavailable")}finally{Nt.balanceLoading=!1}return[]},resetAccount(t){g.resetAccount(t)}},H=At(Mp),Bp={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=g.state.activeCaipNetwork,r=re.state.data;if(t.id===(s==null?void 0:s.id))return;const n=H.getCaipAddress(g.state.activeChain),o=t.chainNamespace!==g.state.activeChain,a=H.getCaipAddress(t.chainNamespace),l=q.getConnectorId(g.state.activeChain)===j.CONNECTOR_ID.AUTH,u=j.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(h=>h===t.chainNamespace);e||l&&u?re.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?re.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):re.push("SwitchNetwork",{...r,network:t})}},lt=Pe({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),jp={state:lt,subscribe(t){return st(lt,()=>t(lt))},subscribeKey(t,e){return rt(lt,t,e)},async open(t){var o,a;const e=H.state.status==="connected",s=t==null?void 0:t.namespace,r=g.state.activeChain,i=s&&s!==r,n=(o=g.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress;if(Y.state.wcBasic?K.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await K.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),q.setFilterByNamespace(t==null?void 0:t.namespace),Ve.setLoading(!0,s),s&&i){const c=((a=g.getNetworkData(s))==null?void 0:a.caipNetwork)||g.getRequestedCaipNetworks(s)[0];c&&Bp.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0})}else{const c=g.state.noAdapters;T.state.manualWCControl||c&&!n?X.isMobile()?re.reset("AllWallets"):re.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?re.reset(t.view,t.data):n?re.reset("Account"):re.reset("Connect")}lt.open=!0,As.set({open:!0}),Te.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=T.state.enableEmbedded,e=!!g.state.activeCaipAddress;lt.open&&Te.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),lt.open=!1,re.reset("Connect"),Ve.clearLoading(),t?e?re.replace("Account"):re.push("Connect"):As.set({open:!1}),Y.resetUri()},setLoading(t,e){e&<.loadingNamespaceMap.set(e,t),lt.loading=t,As.set({loading:t})},clearLoading(){lt.loadingNamespaceMap.clear(),lt.loading=!1},shake(){lt.shake||(lt.shake=!0,setTimeout(()=>{lt.shake=!1},500))}},Ve=At(jp),Ci={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"}]},jo={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},qp={providers:vu,selectedProvider:null,error:null,purchaseCurrency:Ci,paymentCurrency:jo,purchaseCurrencies:[Ci],paymentCurrencies:[],quotesLoading:!1},oe=Pe(qp),Fp={state:oe,subscribe(t){return st(oe,()=>t(oe))},subscribeKey(t,e){return rt(oe,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=g.state.activeChain===j.CHAIN.SOLANA?"SOL":"USDC",s=H.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",pp),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",T.state.projectId),oe.selectedProvider={...t,url:r.toString()}}else oe.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=vu.filter(r=>e.includes(r.name));oe.providers=s}else oe.providers=[]},setPurchaseCurrency(t){oe.purchaseCurrency=t},setPaymentCurrency(t){oe.paymentCurrency=t},setPurchaseAmount(t){qo.state.purchaseAmount=t},setPaymentAmount(t){qo.state.paymentAmount=t},async getAvailableCurrencies(){const t=await J.getOnrampOptions();oe.purchaseCurrencies=t.purchaseCurrencies,oe.paymentCurrencies=t.paymentCurrencies,oe.paymentCurrency=t.paymentCurrencies[0]||jo,oe.purchaseCurrency=t.purchaseCurrencies[0]||Ci,await K.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await K.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;oe.quotesLoading=!0;try{const s=await J.getOnrampQuote({purchaseCurrency:oe.purchaseCurrency,paymentCurrency:oe.paymentCurrency,amount:((t=oe.paymentAmount)==null?void 0:t.toString())||"0",network:(e=oe.purchaseCurrency)==null?void 0:e.symbol});return oe.quotesLoading=!1,oe.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return oe.error=s.message,oe.quotesLoading=!1,null}finally{oe.quotesLoading=!1}},resetState(){oe.selectedProvider=null,oe.error=null,oe.purchaseCurrency=Ci,oe.paymentCurrency=jo,oe.purchaseCurrencies=[Ci],oe.paymentCurrencies=[],oe.paymentAmount=void 0,oe.purchaseAmount=void 0,oe.quotesLoading=!1}},qo=At(Fp),Qa=2147483648,Wp={convertEVMChainIdToCoinType(t){if(t>=Qa)throw new Error("Invalid chainId");return(Qa|t)>>>0}},St=Pe({suggestions:[],loading:!1}),Hp={state:St,subscribe(t){return st(St,()=>t(St))},subscribeKey(t,e){return rt(St,t,e)},async resolveName(t){var e,s;try{return await J.lookupEnsName(t)}catch(r){const i=r;throw new Error(((s=(e=i==null?void 0:i.reasons)==null?void 0:e[0])==null?void 0:s.description)||"Error resolving name")}},async isNameRegistered(t){try{return await J.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{St.loading=!0,St.suggestions=[];const e=await J.getEnsNameSuggestions(t);return St.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],St.suggestions}catch(e){const s=Ii.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{St.loading=!1}},async getNamesForAddress(t){try{if(!g.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=Ii.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=g.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");St.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});re.pushTransactionStack({onCancel(){re.replace("RegisterAccountName")}});const n=await Y.signMessage(i);St.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=Wp.convertEVMChainIdToCoinType(Number(o));await J.registerEnsName({coinType:a,address:s,signature:n,message:i}),H.setProfileName(t,e.chainNamespace),re.replace("RegisterAccountNameSuccess")}catch(i){const n=Ii.parseEnsApiError(i,`Error registering name ${t}`);throw re.replace("RegisterAccountName"),new Error(n)}finally{St.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){var r,i;const s=t;return((i=(r=s==null?void 0:s.reasons)==null?void 0:r[0])==null?void 0:i.description)||e}},Ii=At(Hp);var _u={exports:{}},$r=typeof Reflect=="object"?Reflect:null,ec=$r&&typeof $r.apply=="function"?$r.apply:function(e,s,r){return Function.prototype.apply.call(e,s,r)},wn;$r&&typeof $r.ownKeys=="function"?wn=$r.ownKeys:Object.getOwnPropertySymbols?wn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:wn=function(e){return Object.getOwnPropertyNames(e)};function zp(t){console&&console.warn&&console.warn(t)}var Au=Number.isNaN||function(e){return e!==e};function ye(){ye.init.call(this)}_u.exports=ye;_u.exports.once=Jp;ye.EventEmitter=ye;ye.prototype._events=void 0;ye.prototype._eventsCount=0;ye.prototype._maxListeners=void 0;var tc=10;function Fn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ye,"defaultMaxListeners",{enumerable:!0,get:function(){return tc},set:function(t){if(typeof t!="number"||t<0||Au(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");tc=t}});ye.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};ye.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Au(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 Nu(t){return t._maxListeners===void 0?ye.defaultMaxListeners:t._maxListeners}ye.prototype.getMaxListeners=function(){return Nu(this)};ye.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")ec(c,this,s);else for(var l=c.length,u=xu(c,l),r=0;r<l;++r)ec(u[r],this,s);return!0};function Su(t,e,s,r){var i,n,o;if(Fn(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=Nu(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,zp(a)}return t}ye.prototype.addListener=function(e,s){return Su(this,e,s,!1)};ye.prototype.on=ye.prototype.addListener;ye.prototype.prependListener=function(e,s){return Su(this,e,s,!0)};function Kp(){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 Pu(t,e,s){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},i=Kp.bind(r);return i.listener=s,r.wrapFn=i,i}ye.prototype.once=function(e,s){return Fn(s),this.on(e,Pu(this,e,s)),this};ye.prototype.prependOnceListener=function(e,s){return Fn(s),this.prependListener(e,Pu(this,e,s)),this};ye.prototype.removeListener=function(e,s){var r,i,n,o,a;if(Fn(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():Vp(r,n),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||s)}return this};ye.prototype.off=ye.prototype.removeListener;ye.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 Ou(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?Gp(i):xu(i,i.length)}ye.prototype.listeners=function(e){return Ou(this,e,!0)};ye.prototype.rawListeners=function(e){return Ou(this,e,!1)};ye.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Tu.call(t,e)};ye.prototype.listenerCount=Tu;function Tu(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}ye.prototype.eventNames=function(){return this._eventsCount>0?wn(this._events):[]};function xu(t,e){for(var s=new Array(e),r=0;r<e;++r)s[r]=t[r];return s}function Vp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Gp(t){for(var e=new Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}function Jp(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))}ku(t,e,n,{once:!0}),e!=="error"&&Yp(t,i,{once:!0})})}function Yp(t,e,s){typeof t.on=="function"&&ku(t,"error",e,s)}function ku(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 _i={getSIWX(){return T.state.siwx},async initializeIfEnabled(){var n;const t=T.state.siwx,e=g.getActiveCaipAddress();if(!(t&&e))return;const[s,r,i]=e.split(":");if(g.checkIfSupportedNetwork(s))try{if((await t.getSessions(`${s}:${r}`,i)).length)return;await Ve.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),Te.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=Y._getClient())==null?void 0:n.disconnect().catch(console.error)),re.reset("Connect"),jt.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=T.state.siwx,e=X.getPlainAddress(g.getActiveCaipAddress()),s=g.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&&re.pushTransactionStack({});const a=await r.signMessage(n);await t.addSession({data:i,message:n,signature:a}),Ve.close(),Te.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const n=this.getSIWXEventProperties();(!Ve.state.open||re.state.view==="ApproveTransaction")&&await Ve.open({view:"SIWXSignMessage"}),n.isSmartAccount?jt.showError("This application might not support Smart Accounts"):jt.showError("Signature declined"),Te.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){var t;try{const e=this.getSIWX();((t=e==null?void 0:e.getRequired)==null?void 0:t.call(e))?await Y.disconnect():Ve.close(),re.reset("Connect"),Te.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const t=T.state.siwx,e=X.getPlainAddress(g.getActiveCaipAddress()),s=g.getActiveCaipNetwork();return t&&e&&s?t.getSessions(s.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const s=re.state.view==="ApproveTransaction",r=re.state.view==="SIWXSignMessage";if(s||r)return((e=t.getRequired)==null?void 0:e.call(t))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:s}){var a,c,l;const r=_i.getSIWX(),i=new Set(e.map(u=>u.split(":")[0]));if(!r||i.size!==1||!i.has("eip155"))return!1;const n=await r.createMessage({chainId:((a=g.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await t.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:s,chains:[n.chainId,...e.filter(u=>u!==n.chainId)]});if(jt.showLoading("Authenticating...",{autoClose:!1}),H.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(i)[0]),(l=o==null?void 0:o.auths)!=null&&l.length){const u=o.auths.map(h=>{const d=t.client.formatAuthMessage({request:h.p,iss:h.p.iss});return{data:{...h.p,accountAddress:h.p.iss.split(":").slice(-1).join(""),chainId:h.p.iss.split(":").slice(2,4).join(":"),uri:h.p.aud,version:h.p.version||n.version,expirationTime:h.p.exp,issuedAt:h.p.iat,notBefore:h.p.nbf},message:d,signature:h.s.s,cacao:h}});try{await r.setSessions(u),Te.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:_i.getSIWXEventProperties()})}catch(h){throw console.error("SIWX:universalProviderAuth - failed to set sessions",h),Te.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:_i.getSIWXEventProperties()}),await t.disconnect().catch(console.error),h}finally{jt.hide()}}return!0},getSIWXEventProperties(){var e,s;const t=g.state.activeChain;return{network:((e=g.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((s=H.state.preferredAccountTypes)==null?void 0:s[t])===Ei.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};var Ia={exports:{}},Rr=typeof Reflect=="object"?Reflect:null,sc=Rr&&typeof Rr.apply=="function"?Rr.apply:function(e,s,r){return Function.prototype.apply.call(e,s,r)},yn;Rr&&typeof Rr.ownKeys=="function"?yn=Rr.ownKeys:Object.getOwnPropertySymbols?yn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:yn=function(e){return Object.getOwnPropertyNames(e)};function Xp(t){console&&console.warn&&console.warn(t)}var $u=Number.isNaN||function(e){return e!==e};function be(){be.init.call(this)}Ia.exports=be;Ia.exports.once=tf;be.EventEmitter=be;be.prototype._events=void 0;be.prototype._eventsCount=0;be.prototype._maxListeners=void 0;var rc=10;function Wn(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 rc},set:function(t){if(typeof t!="number"||t<0||$u(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");rc=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||$u(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 Ru(t){return t._maxListeners===void 0?be.defaultMaxListeners:t._maxListeners}be.prototype.getMaxListeners=function(){return Ru(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")sc(c,this,s);else for(var l=c.length,u=Bu(c,l),r=0;r<l;++r)sc(u[r],this,s);return!0};function Uu(t,e,s,r){var i,n,o;if(Wn(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=Ru(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,Xp(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 Zp(){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 Du(t,e,s){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},i=Zp.bind(r);return i.listener=s,r.wrapFn=i,i}be.prototype.once=function(e,s){return Wn(s),this.on(e,Du(this,e,s)),this};be.prototype.prependOnceListener=function(e,s){return Wn(s),this.prependListener(e,Du(this,e,s)),this};be.prototype.removeListener=function(e,s){var r,i,n,o,a;if(Wn(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():Qp(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 Lu(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?ef(i):Bu(i,i.length)}be.prototype.listeners=function(e){return Lu(this,e,!0)};be.prototype.rawListeners=function(e){return Lu(this,e,!1)};be.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Mu.call(t,e)};be.prototype.listenerCount=Mu;function Mu(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?yn(this._events):[]};function Bu(t,e){for(var s=new Array(e),r=0;r<e;++r)s[r]=t[r];return s}function Qp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ef(t){for(var e=new Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}function tf(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))}ju(t,e,n,{once:!0}),e!=="error"&&sf(t,i,{once:!0})})}function sf(t,e,s){typeof t.on=="function"&&ju(t,"error",e,s)}function ju(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 ks=Ia.exports;const _a=kd(ks);function rf(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function We(t,...e){try{return rf(t(...e))}catch(s){return Promise.reject(s)}}function nf(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function of(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function bn(t){if(nf(t))return String(t);if(of(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return bn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Fo="base64:";function af(t){return typeof t=="string"?t:Fo+uf(t)}function cf(t){return typeof t!="string"||!t.startsWith(Fo)?t:lf(t.slice(Fo.length))}function lf(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function uf(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function dt(t){var e;return t&&((e=t.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function hf(...t){return dt(t.join(":"))}function rn(t){return t=dt(t),t?t+":":""}function df(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 pf(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const ff="memory",gf=()=>{const t=new Map;return{name:ff,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 mf(t={}){const e={mounts:{"":t.driver||gf()},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=dt(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 ic(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,p=w=>{let f=d.get(w.base);return f||(f={driver:w.driver,base:w.base,items:[]},d.set(w.base,f)),f};for(const w of l){const f=typeof w=="string",m=dt(f?w:w.key),y=f?void 0:w.value,b=f||!w.options?u:{...u,...w.options},v=s(m);p(v).items.push({key:m,value:y,relativeKey:v.relativeKey,options:b})}return Promise.all([...d.values()].map(w=>h(w))).then(w=>w.flat())},c={hasItem(l,u={}){l=dt(l);const{relativeKey:h,driver:d}=s(l);return We(d.hasItem,h,u)},getItem(l,u={}){l=dt(l);const{relativeKey:h,driver:d}=s(l);return We(d.getItem,h,u).then(p=>tn(p))},getItems(l,u={}){return a(l,u,h=>h.driver.getItems?We(h.driver.getItems,h.items.map(d=>({key:d.relativeKey,options:d.options})),u).then(d=>d.map(p=>({key:hf(h.base,p.key),value:tn(p.value)}))):Promise.all(h.items.map(d=>We(h.driver.getItem,d.relativeKey,d.options).then(p=>({key:d.key,value:tn(p)})))))},getItemRaw(l,u={}){l=dt(l);const{relativeKey:h,driver:d}=s(l);return d.getItemRaw?We(d.getItemRaw,h,u):We(d.getItem,h,u).then(p=>cf(p))},async setItem(l,u,h={}){if(u===void 0)return c.removeItem(l);l=dt(l);const{relativeKey:d,driver:p}=s(l);p.setItem&&(await We(p.setItem,d,bn(u),h),p.watch||i("update",l))},async setItems(l,u){await a(l,u,async h=>{if(h.driver.setItems)return We(h.driver.setItems,h.items.map(d=>({key:d.relativeKey,value:bn(d.value),options:d.options})),u);h.driver.setItem&&await Promise.all(h.items.map(d=>We(h.driver.setItem,d.relativeKey,bn(d.value),d.options)))})},async setItemRaw(l,u,h={}){if(u===void 0)return c.removeItem(l,h);l=dt(l);const{relativeKey:d,driver:p}=s(l);if(p.setItemRaw)await We(p.setItemRaw,d,u,h);else if(p.setItem)await We(p.setItem,d,af(u),h);else return;p.watch||i("update",l)},async removeItem(l,u={}){typeof u=="boolean"&&(u={removeMeta:u}),l=dt(l);const{relativeKey:h,driver:d}=s(l);d.removeItem&&(await We(d.removeItem,h,u),(u.removeMeta||u.removeMata)&&await We(d.removeItem,h+"$",u),d.watch||i("remove",l))},async getMeta(l,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),l=dt(l);const{relativeKey:h,driver:d}=s(l),p=Object.create(null);if(d.getMeta&&Object.assign(p,await We(d.getMeta,h,u)),!u.nativeOnly){const w=await We(d.getItem,h+"$",u).then(f=>tn(f));w&&typeof w=="object"&&(typeof w.atime=="string"&&(w.atime=new Date(w.atime)),typeof w.mtime=="string"&&(w.mtime=new Date(w.mtime)),Object.assign(p,w))}return p},setMeta(l,u,h={}){return this.setItem(l+"$",u,h)},removeMeta(l,u={}){return this.removeItem(l+"$",u)},async getKeys(l,u={}){var m;l=rn(l);const h=r(l,!0);let d=[];const p=[];let w=!0;for(const y of h){(m=y.driver.flags)!=null&&m.maxDepth||(w=!1);const b=await We(y.driver.getKeys,y.relativeBase,u);for(const v of b){const C=y.mountpoint+dt(v);d.some(I=>C.startsWith(I))||p.push(C)}d=[y.mountpoint,...d.filter(v=>!v.startsWith(y.mountpoint))]}const f=u.maxDepth!==void 0&&!w;return p.filter(y=>(!f||df(y,u.maxDepth))&&pf(y,l))},async clear(l,u={}){l=rn(l),await Promise.all(r(l,!1).map(async h=>{if(h.driver.clear)return We(h.driver.clear,h.relativeBase,u);if(h.driver.removeItem){const d=await h.driver.getKeys(h.relativeBase||"",u);return Promise.all(d.map(p=>h.driver.removeItem(p,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>nc(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=rn(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(ic(u,i,l)).then(h=>{e.unwatch[l]=h}).catch(console.error),c},async unmount(l,u=!0){var h,d;l=rn(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((d=(h=e.unwatch)[l])==null||d.call(h),delete e.unwatch[l]),u&&await nc(e.mounts[l]),e.mountpoints=e.mountpoints.filter(p=>p!==l),delete e.mounts[l])},getMount(l=""){l=dt(l)+":";const u=s(l);return{driver:u.driver,base:u.base}},getMounts(l="",u={}){return l=dt(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 ic(t,e,s){return t.watch?t.watch((r,i)=>e(r,s+i)):()=>{}}async function nc(t){typeof t.dispose=="function"&&await We(t.dispose)}const wf="idb-keyval";var yf=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=i=>e+i;let r;return t.dbName&&t.storeName&&(r=qd(t.dbName,t.storeName)),{name:wf,options:t,async hasItem(i){return!(typeof await Wa(s(i),r)>"u")},async getItem(i){return await Wa(s(i),r)??null},setItem(i,n){return Fd(s(i),n,r)},removeItem(i){return Wd(s(i),r)},getKeys(){return Hd(r)},clear(){return zd(r)}}};const bf="WALLET_CONNECT_V2_INDEXED_DB",vf="keyvaluestorage";let Ef=class{constructor(){this.indexedDb=mf({driver:yf({dbName:bf,storeName:vf})})}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,ba(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var oo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},vn={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 oo<"u"&&oo.localStorage?vn.exports=oo.localStorage:typeof window<"u"&&window.localStorage?vn.exports=window.localStorage:vn.exports=new e})();function Cf(t){var e;return[t[0],On((e=t[1])!=null?e:"")]}let If=class{constructor(){this.localStorage=vn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Cf)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return On(s)}async setItem(e,s){this.localStorage.setItem(e,ba(s))}async removeItem(e){this.localStorage.removeItem(e)}};const _f="wc_storage_version",oc=1,Af=async(t,e,s)=>{const r=_f,i=await e.getItem(r);if(i&&i>=oc){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,oc),s(e),Nf(t,o)},Nf=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let Sf=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new If;this.storage=e;try{const s=new Ef;Af(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 Pf=Object.defineProperty,Of=(t,e,s)=>e in t?Pf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ac=(t,e,s)=>Of(t,typeof e!="symbol"?e+"":e,s);let Tf=class extends Jr{constructor(e){super(),this.opts=e,ac(this,"protocol","wc"),ac(this,"version",2)}};var xf=Object.defineProperty,kf=(t,e,s)=>e in t?xf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,$f=(t,e,s)=>kf(t,e+"",s);let Rf=class extends Jr{constructor(e,s){super(),this.core=e,this.logger=s,$f(this,"records",new Map)}},Uf=class{constructor(e,s){this.logger=e,this.core=s}},Df=class extends Jr{constructor(e,s){super(),this.relayer=e,this.logger=s}},Lf=class extends Jr{constructor(e){super()}},Mf=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},Bf=class extends Jr{constructor(e,s){super(),this.relayer=e,this.logger=s}},jf=class extends Jr{constructor(e,s){super(),this.core=e,this.logger=s}},qf=class{constructor(e,s,r){this.core=e,this.logger=s,this.store=r}},Ff=class{constructor(e,s){this.projectId=e,this.logger=s}},Wf=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var Hf=Object.defineProperty,zf=(t,e,s)=>e in t?Hf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,cc=(t,e,s)=>zf(t,typeof e!="symbol"?e+"":e,s);let Kf=class{constructor(e){this.opts=e,cc(this,"protocol","wc"),cc(this,"version",2)}},Vf=class{constructor(e){this.client=e}};function ki(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function lc(t){return ki(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const qu="2.23.2";let ni={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${qu}`};class Zs extends Error{constructor(e,s={}){var a;const r=(()=>{var c;return s.cause instanceof Zs?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),i=s.cause instanceof Zs&&s.cause.docsPath||s.docsPath,n=(a=ni.getDocsUrl)==null?void 0:a.call(ni,{...s,docsPath:i}),o=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...r?[`Details: ${r}`]:[],...ni.version?[`Version: ${ni.version}`]:[]].join(`
|
|
5
|
-
`);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=qu}walk(e){return Fu(this,e)}}function Fu(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Fu(t.cause,e):e?null:t}class Wu extends Zs{constructor({size:e,targetSize:s,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function Xr(t,{dir:e,size:s=32}={}){return typeof t=="string"?Gf(t,{dir:e,size:s}):Jf(t,{dir:e,size:s})}function Gf(t,{dir:e,size:s=32}={}){if(s===null)return t;const r=t.replace("0x","");if(r.length>s*2)throw new Wu({size:Math.ceil(r.length/2),targetSize:s,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Jf(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Wu({size:t.length,targetSize:s,type:"bytes"});const r=new Uint8Array(s);for(let i=0;i<s;i++){const n=e==="right";r[n?i:s-i-1]=t[n?i:t.length-i-1]}return r}class Yf extends Zs{constructor({max:e,min:s,signed:r,size:i,value:n}){super(`Number "${n}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Xf extends Zs{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Zr(t,{size:e}){if(lc(t)>e)throw new Xf({givenSize:lc(t),maxSize:e})}function Wo(t,e={}){const{signed:s}=e;e.size&&Zr(t,{size:e.size});const r=BigInt(t);if(!s)return r;const i=(t.length-2)/2,n=(1n<<BigInt(i)*8n-1n)-1n;return r<=n?r:r-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function Zf(t,e={}){return Number(Wo(t,e))}const Qf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ho(t,e={}){return typeof t=="number"||typeof t=="bigint"?zu(t,e):typeof t=="string"?sg(t,e):typeof t=="boolean"?eg(t,e):Hu(t,e)}function eg(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{size:e.size})):s}function Hu(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=Qf[t[i]];const r=`0x${s}`;return typeof e.size=="number"?(Zr(r,{size:e.size}),Xr(r,{dir:"right",size:e.size})):r}function zu(t,e={}){const{signed:s,size:r}=e,i=BigInt(t);let n;r?s?n=(1n<<BigInt(r)*8n-1n)-1n:n=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&s?-n-1n:0;if(n&&i>n||i<o){const c=typeof t=="bigint"?"n":"";throw new Yf({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:s,size:r,value:`${t}${c}`})}const a=`0x${(s&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?Xr(a,{size:r}):a}const tg=new TextEncoder;function sg(t,e={}){const s=tg.encode(t);return Hu(s,e)}const rg=new TextEncoder;function ig(t,e={}){return typeof t=="number"||typeof t=="bigint"?og(t,e):typeof t=="boolean"?ng(t,e):ki(t)?Ku(t,e):Vu(t,e)}function ng(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{size:e.size})):s}const ns={zero:48,nine:57,A:65,F:70,a:97,f:102};function uc(t){if(t>=ns.zero&&t<=ns.nine)return t-ns.zero;if(t>=ns.A&&t<=ns.F)return t-(ns.A-10);if(t>=ns.a&&t<=ns.f)return t-(ns.a-10)}function Ku(t,e={}){let s=t;e.size&&(Zr(s,{size:e.size}),s=Xr(s,{dir:"right",size:e.size}));let r=s.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,n=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=uc(r.charCodeAt(a++)),l=uc(r.charCodeAt(a++));if(c===void 0||l===void 0)throw new Zs(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);n[o]=c*16+l}return n}function og(t,e){const s=zu(t,e);return Ku(s)}function Vu(t,e={}){const s=rg.encode(t);return typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{dir:"right",size:e.size})):s}function xn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ag(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hn(t,...e){if(!ag(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 a_(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xn(t.outputLen),xn(t.blockLen)}function hc(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 cg(t,e){Hn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const nn=BigInt(2**32-1),dc=BigInt(32);function lg(t,e=!1){return e?{h:Number(t&nn),l:Number(t>>dc&nn)}:{h:Number(t>>dc&nn)|0,l:Number(t&nn)|0}}function ug(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=lg(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const hg=(t,e,s)=>t<<s|e>>>32-s,dg=(t,e,s)=>e<<s|t>>>32-s,pg=(t,e,s)=>e<<s-32|t>>>64-s,fg=(t,e,s)=>t<<s-32|e>>>64-s,lr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gg(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function c_(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function l_(t,e){return t<<32-e|t>>>e}const pc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function mg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function fc(t){for(let e=0;e<t.length;e++)t[e]=mg(t[e])}function wg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Gu(t){return typeof t=="string"&&(t=wg(t)),Hn(t),t}function u_(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Hn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}class yg{clone(){return this._cloneInto()}}function bg(t){const e=r=>t().update(Gu(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function h_(t=32){if(lr&&typeof lr.getRandomValues=="function")return lr.getRandomValues(new Uint8Array(t));if(lr&&typeof lr.randomBytes=="function")return lr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Ju=[],Yu=[],Xu=[],vg=BigInt(0),oi=BigInt(1),Eg=BigInt(2),Cg=BigInt(7),Ig=BigInt(256),_g=BigInt(113);for(let t=0,e=oi,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Ju.push(2*(5*r+s)),Yu.push((t+1)*(t+2)/2%64);let i=vg;for(let n=0;n<7;n++)e=(e<<oi^(e>>Cg)*_g)%Ig,e&Eg&&(i^=oi<<(oi<<BigInt(n))-oi);Xu.push(i)}const[Ag,Ng]=ug(Xu,!0),gc=(t,e,s)=>s>32?pg(t,e,s):hg(t,e,s),mc=(t,e,s)=>s>32?fg(t,e,s):dg(t,e,s);function Sg(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=gc(l,u,1)^s[a],d=mc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Yu[o],c=gc(i,n,a),l=mc(i,n,a),u=Ju[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]^=Ag[r],t[1]^=Ng[r]}s.fill(0)}class Aa extends yg{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,xn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gg(this.state)}keccak(){pc||fc(this.state32),Sg(this.state32,this.rounds),pc||fc(this.state32),this.posOut=0,this.pos=0}update(e){hc(this);const{blockLen:s,state:r}=this;e=Gu(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){hc(this,!1),Hn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return xn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(cg(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 Aa(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 Pg=(t,e,s)=>bg(()=>new Aa(e,t,s)),Og=Pg(1,136,256/8);function Zu(t,e){const s=e||"hex",r=Og(ki(t,{strict:!1})?ig(t):t);return s==="bytes"?r:Ho(r)}class Tg extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ao=new Tg(8192);function xg(t,e){if(ao.has(`${t}.${e}`))return ao.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),r=Zu(Vu(s),"bytes"),i=s.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(r[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const n=`0x${i.join("")}`;return ao.set(`${t}.${e}`,n),n}function kg(t){const e=Zu(`0x${t.substring(4)}`).substring(26);return xg(`0x${e}`)}async function $g({hash:t,signature:e}){const s=ki(t)?t:Ho(t),{secp256k1:r}=await Do(async()=>{const{secp256k1:o}=await import("./secp256k1-DoSvwiWn.js");return{secp256k1:o}},__vite__mapDeps([0,1,2,3]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:h,yParity:d}=e,p=Number(d??h),w=wc(p);return new r.Signature(Wo(l),Wo(u)).addRecoveryBit(w)}const o=ki(e)?e:Ho(e),a=Zf(`0x${o.slice(130)}`),c=wc(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(s.substring(2)).toHex(!1)}`}function wc(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Rg({hash:t,signature:e}){return kg(await $g({hash:t,signature:e}))}function Ug(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 p=l.length;for(;d!==p&&l[d]===0;)d++,u++;const w=(p-d)*n+1>>>0,f=new Uint8Array(w);for(;d!==p;){let b=l[d],v=0;for(let C=w-1;(b!==0||v<h)&&C!==-1;C--,v++)b+=256*f[C]>>>0,f[C]=b%s>>>0,b=b/s>>>0;if(b!==0)throw new Error("Non-zero carry");h=v,d++}let m=w-h;for(;m!==w&&f[m]===0;)m++;let y=r.repeat(u);for(;m<w;++m)y+=t.charAt(f[m]);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 p=(l.length-u)*i+1>>>0,w=new Uint8Array(p);for(;u<l.length;){const b=l.charCodeAt(u);if(b>255)return;let v=e[b];if(v===255)return;let C=0;for(let I=p-1;(v!==0||C<d)&&I!==-1;I--,C++)v+=s*w[I]>>>0,w[I]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=C,u++}let f=p-d;for(;f!==p&&w[f]===0;)f++;const m=new Uint8Array(h+(p-f));let y=h;for(;f!==p;)m[y++]=w[f++];return m}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 Dg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Qu=Ug(Dg);var Lg={};const Mg=":";function Ur(t){const[e,s]=t.split(Mg);return{namespace:e,reference:s}}function eh(t,e){return t.includes(":")?[t]:e.chains||[]}var Bg=Object.defineProperty,jg=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,yc=Object.getOwnPropertySymbols,Fg=Object.prototype.hasOwnProperty,Wg=Object.prototype.propertyIsEnumerable,bc=(t,e,s)=>e in t?Bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vc=(t,e)=>{for(var s in e||(e={}))Fg.call(e,s)&&bc(t,s,e[s]);if(yc)for(var s of yc(e))Wg.call(e,s)&&bc(t,s,e[s]);return t},Hg=(t,e)=>jg(t,qg(e));const zg="ReactNative",Ct={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Kg="js";function kn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function $s(){return!Mr()&&!!fu()&&navigator.product===zg}function Vg(){return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Gg(){return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Qr(){return!kn()&&!!fu()&&!!Mr()}function Hi(){return $s()?Ct.reactNative:kn()?Ct.node:Qr()?Ct.browser:Ct.unknown}function Ec(){var t;try{return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Jg(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 Yg(t){var e,s;const r=th();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),Hg(vc(vc({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),t||r}}function th(){return $d()||{name:"",description:"",url:"",icons:[""]}}function Xg(){if(Hi()===Ct.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:r}=global.Platform;return[s,r].join("-")}const t=Ud();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 Zg(){var t;const e=Hi();return e===Ct.browser?[e,((t=Dd())==null?void 0:t.host)||"unknown"].join(":"):e}function sh(t,e,s){const r=Xg(),i=Zg();return[[t,e].join("-"),[Kg,s].join("-"),r,i].join("/")}function Qg({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=sh(t,e,r),h={auth:i,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=Jg(l[1]||"",h);return l[0]+"?"+d}function Ks(t,e){return t.filter(s=>e.includes(s)).length===t.length}function zo(t){return Object.fromEntries(t.entries())}function Ko(t){return new Map(Object.entries(t))}function js(t=D.FIVE_MINUTES,e){const s=D.toMiliseconds(t||D.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 _s(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 rh(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 em(t){return rh("topic",t)}function tm(t){return rh("id",t)}function ih(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 Me(t,e){return D.fromMiliseconds(Date.now()+D.toMiliseconds(t))}function vs(t){return Date.now()>=D.toMiliseconds(t)}function pe(t,e){return`${t}${e?`:${e}`:""}`}function Zt(t=[],e=[]){return[...new Set([...t,...e])]}async function sm({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i==null?void 0:i.href;if(typeof n!="string")return;const o=rm(n,t,e),a=Hi();if(a===Ct.browser){if(!((r=Mr())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}im(o)}else a===Ct.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function rm(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}${cm(r,!0)}`}else i=`${i}/wc?${r}`;return i}function im(t){let e="_self";am()?e="_top":(om()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function nm(t,e){let s="";try{if(Qr()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function Cc(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Ic(){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 Na(){return typeof process<"u"&&Lg.IS_VITEST==="true"}function om(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function am(){try{return window.self!==window.top}catch{return!1}}function cm(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function nh(t){return Buffer.from(t,"base64").toString("utf-8")}function lm(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 um(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zi(t,...e){if(!um(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 Sa(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 jr(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 oh(t,e){zi(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const on=BigInt(2**32-1),_c=BigInt(32);function hm(t,e=!1){return e?{h:Number(t&on),l:Number(t>>_c&on)}:{h:Number(t>>_c&on)|0,l:Number(t&on)|0}}function dm(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}=hm(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const pm=(t,e,s)=>t<<s|e>>>32-s,fm=(t,e,s)=>e<<s|t>>>32-s,gm=(t,e,s)=>e<<s-32|t>>>64-s,mm=(t,e,s)=>t<<s-32|e>>>64-s,ur=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function co(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ht(t,e){return t<<32-e|t>>>e}const Ac=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ym(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Nc(t){for(let e=0;e<t.length;e++)t[e]=ym(t[e])}function bm(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function qr(t){return typeof t=="string"&&(t=bm(t)),zi(t),t}function vm(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];zi(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 Pa=class{clone(){return this._cloneInto()}};function ah(t){const e=r=>t().update(qr(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function ei(t=32){if(ur&&typeof ur.getRandomValues=="function")return ur.getRandomValues(new Uint8Array(t));if(ur&&typeof ur.randomBytes=="function")return ur.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ch=[],lh=[],uh=[],Em=BigInt(0),ai=BigInt(1),Cm=BigInt(2),Im=BigInt(7),_m=BigInt(256),Am=BigInt(113);for(let t=0,e=ai,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],ch.push(2*(5*r+s)),lh.push((t+1)*(t+2)/2%64);let i=Em;for(let n=0;n<7;n++)e=(e<<ai^(e>>Im)*Am)%_m,e&Cm&&(i^=ai<<(ai<<BigInt(n))-ai);uh.push(i)}const[Nm,Sm]=dm(uh,!0),Sc=(t,e,s)=>s>32?gm(t,e,s):pm(t,e,s),Pc=(t,e,s)=>s>32?mm(t,e,s):fm(t,e,s);function Pm(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=Sc(l,u,1)^s[a],d=Pc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=lh[o],c=Sc(i,n,a),l=Pc(i,n,a),u=ch[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]^=Nm[r],t[1]^=Sm[r]}s.fill(0)}let Om=class hh extends Pa{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=wm(this.state)}keccak(){Ac||Nc(this.state32),Pm(this.state32,this.rounds),Ac||Nc(this.state32),this.posOut=0,this.pos=0}update(e){jr(this);const{blockLen:s,state:r}=this;e=qr(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){jr(this,!1),zi(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(oh(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 hh(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 Tm=(t,e,s)=>ah(()=>new Om(e,t,s)),xm=Tm(1,136,256/8),km="https://rpc.walletconnect.org/v1";function dh(t){const e=`Ethereum Signed Message:
|
|
5
|
+
`);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=qu}walk(e){return Fu(this,e)}}function Fu(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Fu(t.cause,e):e?null:t}class Wu extends Zs{constructor({size:e,targetSize:s,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function Xr(t,{dir:e,size:s=32}={}){return typeof t=="string"?Gf(t,{dir:e,size:s}):Jf(t,{dir:e,size:s})}function Gf(t,{dir:e,size:s=32}={}){if(s===null)return t;const r=t.replace("0x","");if(r.length>s*2)throw new Wu({size:Math.ceil(r.length/2),targetSize:s,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Jf(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Wu({size:t.length,targetSize:s,type:"bytes"});const r=new Uint8Array(s);for(let i=0;i<s;i++){const n=e==="right";r[n?i:s-i-1]=t[n?i:t.length-i-1]}return r}class Yf extends Zs{constructor({max:e,min:s,signed:r,size:i,value:n}){super(`Number "${n}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Xf extends Zs{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Zr(t,{size:e}){if(lc(t)>e)throw new Xf({givenSize:lc(t),maxSize:e})}function Wo(t,e={}){const{signed:s}=e;e.size&&Zr(t,{size:e.size});const r=BigInt(t);if(!s)return r;const i=(t.length-2)/2,n=(1n<<BigInt(i)*8n-1n)-1n;return r<=n?r:r-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function Zf(t,e={}){return Number(Wo(t,e))}const Qf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ho(t,e={}){return typeof t=="number"||typeof t=="bigint"?zu(t,e):typeof t=="string"?sg(t,e):typeof t=="boolean"?eg(t,e):Hu(t,e)}function eg(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{size:e.size})):s}function Hu(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=Qf[t[i]];const r=`0x${s}`;return typeof e.size=="number"?(Zr(r,{size:e.size}),Xr(r,{dir:"right",size:e.size})):r}function zu(t,e={}){const{signed:s,size:r}=e,i=BigInt(t);let n;r?s?n=(1n<<BigInt(r)*8n-1n)-1n:n=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&s?-n-1n:0;if(n&&i>n||i<o){const c=typeof t=="bigint"?"n":"";throw new Yf({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:s,size:r,value:`${t}${c}`})}const a=`0x${(s&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?Xr(a,{size:r}):a}const tg=new TextEncoder;function sg(t,e={}){const s=tg.encode(t);return Hu(s,e)}const rg=new TextEncoder;function ig(t,e={}){return typeof t=="number"||typeof t=="bigint"?og(t,e):typeof t=="boolean"?ng(t,e):ki(t)?Ku(t,e):Vu(t,e)}function ng(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{size:e.size})):s}const ns={zero:48,nine:57,A:65,F:70,a:97,f:102};function uc(t){if(t>=ns.zero&&t<=ns.nine)return t-ns.zero;if(t>=ns.A&&t<=ns.F)return t-(ns.A-10);if(t>=ns.a&&t<=ns.f)return t-(ns.a-10)}function Ku(t,e={}){let s=t;e.size&&(Zr(s,{size:e.size}),s=Xr(s,{dir:"right",size:e.size}));let r=s.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,n=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=uc(r.charCodeAt(a++)),l=uc(r.charCodeAt(a++));if(c===void 0||l===void 0)throw new Zs(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);n[o]=c*16+l}return n}function og(t,e){const s=zu(t,e);return Ku(s)}function Vu(t,e={}){const s=rg.encode(t);return typeof e.size=="number"?(Zr(s,{size:e.size}),Xr(s,{dir:"right",size:e.size})):s}function xn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ag(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hn(t,...e){if(!ag(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 a_(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xn(t.outputLen),xn(t.blockLen)}function hc(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 cg(t,e){Hn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const nn=BigInt(2**32-1),dc=BigInt(32);function lg(t,e=!1){return e?{h:Number(t&nn),l:Number(t>>dc&nn)}:{h:Number(t>>dc&nn)|0,l:Number(t&nn)|0}}function ug(t,e=!1){let s=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:n,l:o}=lg(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const hg=(t,e,s)=>t<<s|e>>>32-s,dg=(t,e,s)=>e<<s|t>>>32-s,pg=(t,e,s)=>e<<s-32|t>>>64-s,fg=(t,e,s)=>t<<s-32|e>>>64-s,lr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gg(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function c_(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function l_(t,e){return t<<32-e|t>>>e}const pc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function mg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function fc(t){for(let e=0;e<t.length;e++)t[e]=mg(t[e])}function wg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Gu(t){return typeof t=="string"&&(t=wg(t)),Hn(t),t}function u_(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Hn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}class yg{clone(){return this._cloneInto()}}function bg(t){const e=r=>t().update(Gu(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function h_(t=32){if(lr&&typeof lr.getRandomValues=="function")return lr.getRandomValues(new Uint8Array(t));if(lr&&typeof lr.randomBytes=="function")return lr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Ju=[],Yu=[],Xu=[],vg=BigInt(0),oi=BigInt(1),Eg=BigInt(2),Cg=BigInt(7),Ig=BigInt(256),_g=BigInt(113);for(let t=0,e=oi,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Ju.push(2*(5*r+s)),Yu.push((t+1)*(t+2)/2%64);let i=vg;for(let n=0;n<7;n++)e=(e<<oi^(e>>Cg)*_g)%Ig,e&Eg&&(i^=oi<<(oi<<BigInt(n))-oi);Xu.push(i)}const[Ag,Ng]=ug(Xu,!0),gc=(t,e,s)=>s>32?pg(t,e,s):hg(t,e,s),mc=(t,e,s)=>s>32?fg(t,e,s):dg(t,e,s);function Sg(t,e=24){const s=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],h=gc(l,u,1)^s[a],d=mc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Yu[o],c=gc(i,n,a),l=mc(i,n,a),u=Ju[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]^=Ag[r],t[1]^=Ng[r]}s.fill(0)}class Aa extends yg{constructor(e,s,r,i=!1,n=24){if(super(),this.blockLen=e,this.suffix=s,this.outputLen=r,this.enableXOF=i,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,xn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gg(this.state)}keccak(){pc||fc(this.state32),Sg(this.state32,this.rounds),pc||fc(this.state32),this.posOut=0,this.pos=0}update(e){hc(this);const{blockLen:s,state:r}=this;e=Gu(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){hc(this,!1),Hn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return xn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(cg(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 Aa(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 Pg=(t,e,s)=>bg(()=>new Aa(e,t,s)),Og=Pg(1,136,256/8);function Zu(t,e){const s=e||"hex",r=Og(ki(t,{strict:!1})?ig(t):t);return s==="bytes"?r:Ho(r)}class Tg extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ao=new Tg(8192);function xg(t,e){if(ao.has(`${t}.${e}`))return ao.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),r=Zu(Vu(s),"bytes"),i=s.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(r[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const n=`0x${i.join("")}`;return ao.set(`${t}.${e}`,n),n}function kg(t){const e=Zu(`0x${t.substring(4)}`).substring(26);return xg(`0x${e}`)}async function $g({hash:t,signature:e}){const s=ki(t)?t:Ho(t),{secp256k1:r}=await Do(async()=>{const{secp256k1:o}=await import("./secp256k1-DL-MVpVU.js");return{secp256k1:o}},__vite__mapDeps([0,1,2,3]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:h,yParity:d}=e,p=Number(d??h),w=wc(p);return new r.Signature(Wo(l),Wo(u)).addRecoveryBit(w)}const o=ki(e)?e:Ho(e),a=Zf(`0x${o.slice(130)}`),c=wc(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(s.substring(2)).toHex(!1)}`}function wc(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Rg({hash:t,signature:e}){return kg(await $g({hash:t,signature:e}))}function Ug(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 p=l.length;for(;d!==p&&l[d]===0;)d++,u++;const w=(p-d)*n+1>>>0,f=new Uint8Array(w);for(;d!==p;){let b=l[d],v=0;for(let C=w-1;(b!==0||v<h)&&C!==-1;C--,v++)b+=256*f[C]>>>0,f[C]=b%s>>>0,b=b/s>>>0;if(b!==0)throw new Error("Non-zero carry");h=v,d++}let m=w-h;for(;m!==w&&f[m]===0;)m++;let y=r.repeat(u);for(;m<w;++m)y+=t.charAt(f[m]);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 p=(l.length-u)*i+1>>>0,w=new Uint8Array(p);for(;u<l.length;){const b=l.charCodeAt(u);if(b>255)return;let v=e[b];if(v===255)return;let C=0;for(let I=p-1;(v!==0||C<d)&&I!==-1;I--,C++)v+=s*w[I]>>>0,w[I]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=C,u++}let f=p-d;for(;f!==p&&w[f]===0;)f++;const m=new Uint8Array(h+(p-f));let y=h;for(;f!==p;)m[y++]=w[f++];return m}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 Dg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Qu=Ug(Dg);var Lg={};const Mg=":";function Ur(t){const[e,s]=t.split(Mg);return{namespace:e,reference:s}}function eh(t,e){return t.includes(":")?[t]:e.chains||[]}var Bg=Object.defineProperty,jg=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,yc=Object.getOwnPropertySymbols,Fg=Object.prototype.hasOwnProperty,Wg=Object.prototype.propertyIsEnumerable,bc=(t,e,s)=>e in t?Bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vc=(t,e)=>{for(var s in e||(e={}))Fg.call(e,s)&&bc(t,s,e[s]);if(yc)for(var s of yc(e))Wg.call(e,s)&&bc(t,s,e[s]);return t},Hg=(t,e)=>jg(t,qg(e));const zg="ReactNative",Ct={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Kg="js";function kn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function $s(){return!Mr()&&!!fu()&&navigator.product===zg}function Vg(){return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Gg(){return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Qr(){return!kn()&&!!fu()&&!!Mr()}function Hi(){return $s()?Ct.reactNative:kn()?Ct.node:Qr()?Ct.browser:Ct.unknown}function Ec(){var t;try{return $s()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Jg(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 Yg(t){var e,s;const r=th();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),Hg(vc(vc({},r),t),{url:(t==null?void 0:t.url)||r.url,name:(t==null?void 0:t.name)||r.name,description:(t==null?void 0:t.description)||r.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:r.icons})}catch(i){return console.warn("Error populating app metadata",i),t||r}}function th(){return $d()||{name:"",description:"",url:"",icons:[""]}}function Xg(){if(Hi()===Ct.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:r}=global.Platform;return[s,r].join("-")}const t=Ud();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 Zg(){var t;const e=Hi();return e===Ct.browser?[e,((t=Dd())==null?void 0:t.host)||"unknown"].join(":"):e}function sh(t,e,s){const r=Xg(),i=Zg();return[[t,e].join("-"),[Kg,s].join("-"),r,i].join("/")}function Qg({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=sh(t,e,r),h={auth:i,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=Jg(l[1]||"",h);return l[0]+"?"+d}function Ks(t,e){return t.filter(s=>e.includes(s)).length===t.length}function zo(t){return Object.fromEntries(t.entries())}function Ko(t){return new Map(Object.entries(t))}function js(t=D.FIVE_MINUTES,e){const s=D.toMiliseconds(t||D.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 _s(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 rh(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 em(t){return rh("topic",t)}function tm(t){return rh("id",t)}function ih(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 Me(t,e){return D.fromMiliseconds(Date.now()+D.toMiliseconds(t))}function vs(t){return Date.now()>=D.toMiliseconds(t)}function pe(t,e){return`${t}${e?`:${e}`:""}`}function Zt(t=[],e=[]){return[...new Set([...t,...e])]}async function sm({id:t,topic:e,wcDeepLink:s}){var r;try{if(!s)return;const i=typeof s=="string"?JSON.parse(s):s,n=i==null?void 0:i.href;if(typeof n!="string")return;const o=rm(n,t,e),a=Hi();if(a===Ct.browser){if(!((r=Mr())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}im(o)}else a===Ct.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function rm(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}${cm(r,!0)}`}else i=`${i}/wc?${r}`;return i}function im(t){let e="_self";am()?e="_top":(om()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function nm(t,e){let s="";try{if(Qr()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function Cc(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Ic(){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 Na(){return typeof process<"u"&&Lg.IS_VITEST==="true"}function om(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function am(){try{return window.self!==window.top}catch{return!1}}function cm(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function nh(t){return Buffer.from(t,"base64").toString("utf-8")}function lm(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 um(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zi(t,...e){if(!um(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 Sa(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 jr(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 oh(t,e){zi(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const on=BigInt(2**32-1),_c=BigInt(32);function hm(t,e=!1){return e?{h:Number(t&on),l:Number(t>>_c&on)}:{h:Number(t>>_c&on)|0,l:Number(t&on)|0}}function dm(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}=hm(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const pm=(t,e,s)=>t<<s|e>>>32-s,fm=(t,e,s)=>e<<s|t>>>32-s,gm=(t,e,s)=>e<<s-32|t>>>64-s,mm=(t,e,s)=>t<<s-32|e>>>64-s,ur=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function co(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ht(t,e){return t<<32-e|t>>>e}const Ac=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ym(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Nc(t){for(let e=0;e<t.length;e++)t[e]=ym(t[e])}function bm(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function qr(t){return typeof t=="string"&&(t=bm(t)),zi(t),t}function vm(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];zi(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 Pa=class{clone(){return this._cloneInto()}};function ah(t){const e=r=>t().update(qr(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function ei(t=32){if(ur&&typeof ur.getRandomValues=="function")return ur.getRandomValues(new Uint8Array(t));if(ur&&typeof ur.randomBytes=="function")return ur.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ch=[],lh=[],uh=[],Em=BigInt(0),ai=BigInt(1),Cm=BigInt(2),Im=BigInt(7),_m=BigInt(256),Am=BigInt(113);for(let t=0,e=ai,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],ch.push(2*(5*r+s)),lh.push((t+1)*(t+2)/2%64);let i=Em;for(let n=0;n<7;n++)e=(e<<ai^(e>>Im)*Am)%_m,e&Cm&&(i^=ai<<(ai<<BigInt(n))-ai);uh.push(i)}const[Nm,Sm]=dm(uh,!0),Sc=(t,e,s)=>s>32?gm(t,e,s):pm(t,e,s),Pc=(t,e,s)=>s>32?mm(t,e,s):fm(t,e,s);function Pm(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=Sc(l,u,1)^s[a],d=Pc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=lh[o],c=Sc(i,n,a),l=Pc(i,n,a),u=ch[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]^=Nm[r],t[1]^=Sm[r]}s.fill(0)}let Om=class hh extends Pa{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=wm(this.state)}keccak(){Ac||Nc(this.state32),Pm(this.state32,this.rounds),Ac||Nc(this.state32),this.posOut=0,this.pos=0}update(e){jr(this);const{blockLen:s,state:r}=this;e=qr(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){jr(this,!1),zi(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(oh(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 hh(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 Tm=(t,e,s)=>ah(()=>new Om(e,t,s)),xm=Tm(1,136,256/8),km="https://rpc.walletconnect.org/v1";function dh(t){const e=`Ethereum Signed Message:
|
|
6
6
|
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(xm(s)).toString("hex")}async function $m(t,e,s,r,i,n){switch(s.t){case"eip191":return await Rm(t,e,s.s);case"eip1271":return await Um(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function Rm(t,e,s){return(await Rg({hash:dh(e),signature:s})).toLowerCase()===t.toLowerCase()}async function Um(t,e,s,r,i,n){const o=Ur(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=dh(e).substring(2),d=a+h+c+l+u,p=await fetch(`${n||km}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:Dm(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:w}=await p.json();return w?w.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Dm(){return Date.now()+Math.floor(Math.random()*1e3)}function Lm(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const r=s[0];if(r===0)throw new Error("No signatures found");const i=1+r*64;if(s.length<i)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return Qu.encode(n)}var Mm=Object.defineProperty,Bm=Object.defineProperties,jm=Object.getOwnPropertyDescriptors,Oc=Object.getOwnPropertySymbols,qm=Object.prototype.hasOwnProperty,Fm=Object.prototype.propertyIsEnumerable,Tc=(t,e,s)=>e in t?Mm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Wm=(t,e)=>{for(var s in e||(e={}))qm.call(e,s)&&Tc(t,s,e[s]);if(Oc)for(var s of Oc(e))Fm.call(e,s)&&Tc(t,s,e[s]);return t},Hm=(t,e)=>Bm(t,jm(e));const zm="did:pkh:",Oa=t=>t==null?void 0:t.split(":"),Km=t=>{const e=t&&Oa(t);if(e)return t.includes(zm)?e[3]:e[1]},Vo=t=>{const e=t&&Oa(t);if(e)return e[2]+":"+e[3]},$n=t=>{const e=t&&Oa(t);if(e)return e.pop()};async function xc(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=ph(i,i.iss),o=$n(i.iss);return await $m(o,n,r,Vo(i.iss),s)}const ph=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=$n(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: ${Km(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,p=t.resources?`Resources:${t.resources.map(f=>`
|
|
7
7
|
- ${f}`).join("")}`:void 0,w=En(t.resources);if(w){const f=Ri(w);i=tw(i,f)}return[s,r,"",i,"",n,o,a,c,l,u,h,d,p].filter(f=>f!=null).join(`
|
|
8
8
|
`)};function Vm(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Gm(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Qs(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 Jm(t,e,s,r={}){return s==null||s.sort((i,n)=>i.localeCompare(n)),{att:{[t]:Ym(e,s,r)}}}function Ym(t,e,s={}){e=e==null?void 0:e.sort((i,n)=>i.localeCompare(n));const r=e.map(i=>({[`${t}/${i}`]:[s]}));return Object.assign({},...r)}function fh(t){return Qs(t),`urn:recap:${Vm(t).replace(/=/g,"")}`}function Ri(t){const e=Gm(t.replace("urn:recap:",""));return Qs(e),e}function Xm(t,e,s){const r=Jm(t,e,s);return fh(r)}function Zm(t){return t&&t.includes("urn:recap:")}function Qm(t,e){const s=Ri(t),r=Ri(e),i=ew(s,r);return fh(i)}function ew(t,e){Qs(t),Qs(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]=Hm(Wm({},r.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),r}function tw(t="",e){Qs(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 kc(t){var e;const s=Ri(t);Qs(s);const r=(e=s.att)==null?void 0:e.eip155;return r?Object.keys(r).map(i=>i.split("/")[1]):[]}function $c(t){const e=Ri(t);Qs(e);const s=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(i=>{var n;(n=i==null?void 0:i[0])!=null&&n.chains&&s.push(i[0].chains)})}),[...new Set(s.flat())]}function En(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return Zm(e)?e:void 0}function lo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function gh(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Et(t,...e){if(!gh(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 Rc(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 sw(t,e){Et(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Uc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ns=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),rw=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),iw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!iw)throw new Error("Non little-endian hardware is not supported");function nw(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Go(t){if(typeof t=="string")t=nw(t);else if(gh(t))t=Jo(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function ow(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function aw(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 cw=(t,e)=>{function s(r,...i){if(Et(r),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?Et(l):Et(l,t.nonceLength)}const n=t.tagLength;n&&i[1]!==void 0&&Et(i[1]);const o=e(r,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");Et(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Et(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(Et(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&&!lw(e))throw new Error("invalid output, must be aligned");return e}function Lc(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 lw(t){return t.byteOffset%4===0}function Jo(t){return Uint8Array.from(t)}function Fr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const mh=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),uw=mh("expand 16-byte k"),hw=mh("expand 32-byte k"),dw=Ns(uw),pw=Ns(hw);function ce(t,e){return t<<e|t>>>32-e}function Yo(t){return t.byteOffset%4===0}const an=64,fw=16,wh=2**32-1,Mc=new Uint32Array;function gw(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(an),u=Ns(l),h=Yo(i)&&Yo(n),d=h?Ns(i):Mc,p=h?Ns(n):Mc;for(let w=0;w<c;o++){if(t(e,s,r,u,o,a),o>=wh)throw new Error("arx: counter overflow");const f=Math.min(an,c-w);if(h&&f===an){const m=w/4;if(w%4!==0)throw new Error("arx: invalid block position");for(let y=0,b;y<fw;y++)b=m+y,p[b]=d[b]^u[y];w+=an;continue}for(let m=0,y;m<f;m++)y=w+m,n[y]=i[y]^l[m];w+=f}}function mw(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=ow({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return lo(i),lo(o),Uc(n),Uc(s),(a,c,l,u,h=0)=>{Et(a),Et(c),Et(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),Et(u),lo(h),h<0||h>=wh)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const p=[];let w=a.length,f,m;if(w===32)p.push(f=Jo(a)),m=pw;else if(w===16&&s)f=new Uint8Array(32),f.set(a),f.set(a,16),m=dw,p.push(f);else throw new Error(`arx: invalid 32-byte key, got length=${w}`);Yo(c)||p.push(c=Jo(c));const y=Ns(f);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(m,y,Ns(c.subarray(0,16)),y),c=c.subarray(16)}const b=16-i;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const C=new Uint8Array(12);C.set(c,n?0:12-c.length),c=C,p.push(c)}const v=Ns(c);return gw(t,m,y,v,l,u,h,o),Fr(...p),u}}const Je=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class ww{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=Go(e),Et(e,32);const s=Je(e,0),r=Je(e,2),i=Je(e,4),n=Je(e,6),o=Je(e,8),a=Je(e,10),c=Je(e,12),l=Je(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]=Je(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],p=o[6],w=o[7],f=o[8],m=o[9],y=Je(e,s+0),b=Je(e,s+2),v=Je(e,s+4),C=Je(e,s+6),I=Je(e,s+8),_=Je(e,s+10),S=Je(e,s+12),U=Je(e,s+14);let E=n[0]+(y&8191),$=n[1]+((y>>>13|b<<3)&8191),A=n[2]+((b>>>10|v<<6)&8191),L=n[3]+((v>>>7|C<<9)&8191),z=n[4]+((C>>>4|I<<12)&8191),N=n[5]+(I>>>1&8191),x=n[6]+((I>>>14|_<<2)&8191),O=n[7]+((_>>>11|S<<5)&8191),B=n[8]+((S>>>8|U<<8)&8191),F=n[9]+(U>>>5|i),k=0,G=k+E*a+$*(5*m)+A*(5*f)+L*(5*w)+z*(5*p);k=G>>>13,G&=8191,G+=N*(5*d)+x*(5*h)+O*(5*u)+B*(5*l)+F*(5*c),k+=G>>>13,G&=8191;let Q=k+E*c+$*a+A*(5*m)+L*(5*f)+z*(5*w);k=Q>>>13,Q&=8191,Q+=N*(5*p)+x*(5*d)+O*(5*h)+B*(5*u)+F*(5*l),k+=Q>>>13,Q&=8191;let se=k+E*l+$*c+A*a+L*(5*m)+z*(5*f);k=se>>>13,se&=8191,se+=N*(5*w)+x*(5*p)+O*(5*d)+B*(5*h)+F*(5*u),k+=se>>>13,se&=8191;let _e=k+E*u+$*l+A*c+L*a+z*(5*m);k=_e>>>13,_e&=8191,_e+=N*(5*f)+x*(5*w)+O*(5*p)+B*(5*d)+F*(5*h),k+=_e>>>13,_e&=8191;let de=k+E*h+$*u+A*l+L*c+z*a;k=de>>>13,de&=8191,de+=N*(5*m)+x*(5*f)+O*(5*w)+B*(5*p)+F*(5*d),k+=de>>>13,de&=8191;let ke=k+E*d+$*h+A*u+L*l+z*c;k=ke>>>13,ke&=8191,ke+=N*a+x*(5*m)+O*(5*f)+B*(5*w)+F*(5*p),k+=ke>>>13,ke&=8191;let je=k+E*p+$*d+A*h+L*u+z*l;k=je>>>13,je&=8191,je+=N*c+x*a+O*(5*m)+B*(5*f)+F*(5*w),k+=je>>>13,je&=8191;let Qe=k+E*w+$*p+A*d+L*h+z*u;k=Qe>>>13,Qe&=8191,Qe+=N*l+x*c+O*a+B*(5*m)+F*(5*f),k+=Qe>>>13,Qe&=8191;let Ue=k+E*f+$*w+A*p+L*d+z*h;k=Ue>>>13,Ue&=8191,Ue+=N*u+x*l+O*c+B*a+F*(5*m),k+=Ue>>>13,Ue&=8191;let De=k+E*m+$*f+A*w+L*p+z*d;k=De>>>13,De&=8191,De+=N*h+x*u+O*l+B*c+F*a,k+=De>>>13,De&=8191,k=(k<<2)+k|0,k=k+G|0,G=k&8191,k=k>>>13,Q+=k,n[0]=G,n[1]=Q,n[2]=se,n[3]=_e,n[4]=de,n[5]=ke,n[6]=je,n[7]=Qe,n[8]=Ue,n[9]=De}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;Fr(r)}update(e){Rc(this);const{buffer:s,blockLen:r}=this;e=Go(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(){Fr(this.h,this.r,this.buffer,this.pad)}digestInto(e){Rc(this),sw(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 yw(t){const e=(r,i)=>t(i).update(Go(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const bw=yw(t=>new ww(t));function vw(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],p=e[3],w=e[4],f=e[5],m=e[6],y=e[7],b=i,v=s[0],C=s[1],I=s[2],_=o,S=a,U=c,E=l,$=u,A=h,L=d,z=p,N=w,x=f,O=m,B=y,F=b,k=v,G=C,Q=I;for(let _e=0;_e<n;_e+=2)_=_+$|0,F=ce(F^_,16),N=N+F|0,$=ce($^N,12),_=_+$|0,F=ce(F^_,8),N=N+F|0,$=ce($^N,7),S=S+A|0,k=ce(k^S,16),x=x+k|0,A=ce(A^x,12),S=S+A|0,k=ce(k^S,8),x=x+k|0,A=ce(A^x,7),U=U+L|0,G=ce(G^U,16),O=O+G|0,L=ce(L^O,12),U=U+L|0,G=ce(G^U,8),O=O+G|0,L=ce(L^O,7),E=E+z|0,Q=ce(Q^E,16),B=B+Q|0,z=ce(z^B,12),E=E+z|0,Q=ce(Q^E,8),B=B+Q|0,z=ce(z^B,7),_=_+A|0,Q=ce(Q^_,16),O=O+Q|0,A=ce(A^O,12),_=_+A|0,Q=ce(Q^_,8),O=O+Q|0,A=ce(A^O,7),S=S+L|0,F=ce(F^S,16),B=B+F|0,L=ce(L^B,12),S=S+L|0,F=ce(F^S,8),B=B+F|0,L=ce(L^B,7),U=U+z|0,k=ce(k^U,16),N=N+k|0,z=ce(z^N,12),U=U+z|0,k=ce(k^U,8),N=N+k|0,z=ce(z^N,7),E=E+$|0,G=ce(G^E,16),x=x+G|0,$=ce($^x,12),E=E+$|0,G=ce(G^E,8),x=x+G|0,$=ce($^x,7);let se=0;r[se++]=o+_|0,r[se++]=a+S|0,r[se++]=c+U|0,r[se++]=l+E|0,r[se++]=u+$|0,r[se++]=h+A|0,r[se++]=d+L|0,r[se++]=p+z|0,r[se++]=w+N|0,r[se++]=f+x|0,r[se++]=m+O|0,r[se++]=y+B|0,r[se++]=b+F|0,r[se++]=v+k|0,r[se++]=C+G|0,r[se++]=I+Q|0}const Ew=mw(vw,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Cw=new Uint8Array(16),Bc=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(Cw.subarray(s))},Iw=new Uint8Array(32);function jc(t,e,s,r,i){const n=t(e,s,Iw),o=bw.create(n);i&&Bc(o,i),Bc(o,r);const a=new Uint8Array(16),c=rw(a);Lc(c,0,BigInt(i?i.length:0),!0),Lc(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return Fr(n,a),l}const _w=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=jc(t,e,s,a,r);return n.set(c,o),Fr(c),n},decrypt(i,n){n=Dc(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=jc(t,e,s,o,r);if(!aw(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),Fr(c),n}}),yh=cw({blockSize:64,nonceLength:12,tagLength:16},_w(Ew));let bh=class extends Pa{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,Sa(e);const r=qr(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 jr(this),this.iHash.update(e),this}digestInto(e){jr(this),zi(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 zn=(t,e,s)=>new bh(t,e).update(s).digest();zn.create=(t,e)=>new bh(t,e);function Aw(t,e,s){return Sa(t),s===void 0&&(s=new Uint8Array(t.outputLen)),zn(t,qr(s),qr(e))}const uo=new Uint8Array([0]),qc=new Uint8Array;function Nw(t,e,s,r=32){if(Sa(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=qc);const n=new Uint8Array(i*t.outputLen),o=zn.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)uo[0]=l+1,a.update(l===0?qc:c).update(s).update(uo).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),uo.fill(0),n.slice(0,r)}const Sw=(t,e,s,r,i)=>Nw(t,Aw(t,e,s),r,i);function Pw(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 Ow(t,e,s){return t&e^~t&s}function Tw(t,e,s){return t&e^t&s^e&s}let xw=class extends Pa{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=co(this.buffer)}update(e){jr(this);const{view:s,buffer:r,blockLen:i}=this;e=qr(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=co(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){jr(this),oh(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;Pw(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=co(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 kw=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 $w extends xw{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],p=ys[h-2],w=Ht(d,7)^Ht(d,18)^d>>>3,f=Ht(p,17)^Ht(p,19)^p>>>10;ys[h]=f+ys[h-7]+w+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=Ht(a,6)^Ht(a,11)^Ht(a,25),p=u+d+Ow(a,c,l)+kw[h]+ys[h]|0,w=(Ht(r,2)^Ht(r,13)^Ht(r,22))+Tw(r,i,n)|0;u=l,l=c,c=a,a=o+p|0,o=n,n=i,i=r,r=p+w|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 Ki=ah(()=>new $w);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kn=BigInt(0),Vn=BigInt(1),Rw=BigInt(2);function er(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Vi(t){if(!er(t))throw new Error("Uint8Array expected")}function Wr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Uw=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Hr(t){Vi(t);let e="";for(let s=0;s<t.length;s++)e+=Uw[t[s]];return e}function Tr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Ta(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Kn:BigInt("0x"+t)}const os={_0:48,_9:57,A:65,F:70,a:97,f:102};function Fc(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 zr(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=Fc(t.charCodeAt(n)),a=Fc(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 Ta(Hr(t))}function Ui(t){return Vi(t),Ta(Hr(Uint8Array.from(t).reverse()))}function Kr(t,e){return zr(t.toString(16).padStart(e*2,"0"))}function Gn(t,e){return Kr(t,e).reverse()}function Dw(t){return zr(Tr(t))}function vt(t,e,s){let r;if(typeof e=="string")try{r=zr(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(er(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 Di(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Vi(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 Lw(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 Mw(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const ho=t=>typeof t=="bigint"&&Kn<=t;function Jn(t,e,s){return ho(t)&&ho(e)&&ho(s)&&e<=t&&t<s}function hs(t,e,s,r){if(!Jn(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function vh(t){let e;for(e=0;t>Kn;t>>=Vn,e+=1);return e}function Bw(t,e){return t>>BigInt(e)&Vn}function jw(t,e,s){return t|(s?Vn:Kn)<<BigInt(e)}const xa=t=>(Rw<<BigInt(t-1))-Vn,po=t=>new Uint8Array(t),Wc=t=>Uint8Array.from(t);function Eh(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=po(t),i=po(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=po())=>{i=a(Wc([0]),u),r=a(),u.length!==0&&(i=a(Wc([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 Di(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const qw={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"||er(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 ti(t,e,s={}){const r=(i,n,o)=>{const a=qw[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 Fw=()=>{throw new Error("not implemented")};function Xo(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 Ww=Object.freeze({__proto__:null,isBytes:er,abytes:Vi,abool:Wr,bytesToHex:Hr,numberToHexUnpadded:Tr,hexToNumber:Ta,hexToBytes:zr,bytesToNumberBE:Gs,bytesToNumberLE:Ui,numberToBytesBE:Kr,numberToBytesLE:Gn,numberToVarBytesBE:Dw,ensureBytes:vt,concatBytes:Di,equalBytes:Lw,utf8ToBytes:Mw,inRange:Jn,aInRange:hs,bitLen:vh,bitGet:Bw,bitSet:jw,bitMask:xa,createHmacDrbg:Eh,validateObject:ti,notImplemented:Fw,memoized:Xo});const Ge=BigInt(0),xe=BigInt(1),Fs=BigInt(2),Hw=BigInt(3),Zo=BigInt(4),Hc=BigInt(5),zc=BigInt(8);function ft(t,e){const s=t%e;return s>=Ge?s:e+s}function Ch(t,e,s){if(e<Ge)throw new Error("invalid exponent, negatives unsupported");if(s<=Ge)throw new Error("invalid modulus");if(s===xe)return Ge;let r=xe;for(;e>Ge;)e&xe&&(r=r*t%s),t=t*t%s,e>>=xe;return r}function Mt(t,e,s){let r=t;for(;e-- >Ge;)r*=r,r%=s;return r}function Qo(t,e){if(t===Ge)throw new Error("invert: expected non-zero number");if(e<=Ge)throw new Error("invert: expected positive modulus, got "+e);let s=ft(t,e),r=e,i=Ge,n=xe;for(;s!==Ge;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==xe)throw new Error("invert: does not exist");return ft(i,e)}function zw(t){const e=(t-xe)/Fs;let s,r,i;for(s=t-xe,r=0;s%Fs===Ge;s/=Fs,r++);for(i=Fs;i<t&&Ch(i,e,t)!==t-xe;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+xe)/Zo;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+xe)/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 w=o.sqr(h);d<c&&!o.eql(w,o.ONE);d++)w=o.sqr(w);const p=o.pow(l,xe<<BigInt(c-d-1));l=o.sqr(p),u=o.mul(u,p),h=o.mul(h,l),c=d}return u}}function Kw(t){if(t%Zo===Hw){const e=(t+xe)/Zo;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%zc===Hc){const e=(t-Hc)/zc;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 zw(t)}const Vw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gw(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=Vw.reduce((r,i)=>(r[i]="function",r),e);return ti(t,s)}function Jw(t,e,s){if(s<Ge)throw new Error("invalid exponent, negatives unsupported");if(s===Ge)return t.ONE;if(s===xe)return e;let r=t.ONE,i=e;for(;s>Ge;)s&xe&&(r=t.mul(r,i)),i=t.sqr(i),s>>=xe;return r}function Yw(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 Ih(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function _h(t,e,s=!1,r={}){if(t<=Ge)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=Ih(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:xa(i),ZERO:Ge,ONE:xe,create:c=>ft(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Ge<=c&&c<t},is0:c=>c===Ge,isOdd:c=>(c&xe)===xe,neg:c=>ft(-c,t),eql:(c,l)=>c===l,sqr:c=>ft(c*c,t),add:(c,l)=>ft(c+l,t),sub:(c,l)=>ft(c-l,t),mul:(c,l)=>ft(c*l,t),pow:(c,l)=>Jw(a,c,l),div:(c,l)=>ft(c*Qo(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Qo(c,t),sqrt:r.sqrt||(c=>(o||(o=Kw(t)),o(a,c))),invertBatch:c=>Yw(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?Gn(c,n):Kr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?Ui(c):Gs(c)}});return Object.freeze(a)}function Ah(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 Nh(t){const e=Ah(t);return e+Math.ceil(e/2)}function Xw(t,e,s=!1){const r=t.length,i=Ah(e),n=Nh(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?Ui(t):Gs(t),a=ft(o,e-xe)+xe;return s?Gn(a,i):Kr(a,i)}const Kc=BigInt(0),cn=BigInt(1);function fo(t,e){const s=e.negate();return t?s:e}function Sh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function go(t,e){Sh(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function Zw(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 Qw(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 mo=new WeakMap,Ph=new WeakMap;function wo(t){return Ph.get(t)||1}function ey(t,e){return{constTimeNegate:fo,hasPrecomputes(s){return wo(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>Kc;)r&cn&&(i=i.add(n)),n=n.double(),r>>=cn;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=go(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}=go(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 p=d*o;let w=Number(i&l);i>>=h,w>o&&(w-=u,i+=cn);const f=p,m=p+Math.abs(w)-1,y=d%2!==0,b=w<0;w===0?c=c.add(fo(y,r[f])):a=a.add(fo(b,r[m]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=go(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===Kc)break;let p=Number(i&c);if(i>>=u,p>a&&(p-=l,i+=cn),p===0)continue;let w=r[d+Math.abs(p)-1];p<0&&(w=w.negate()),n=n.add(w)}return n},getPrecomputes(s,r,i){let n=mo.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&mo.set(r,i(n))),n},wNAFCached(s,r,i){const n=wo(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=wo(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){Sh(r,e),Ph.set(s,r),mo.delete(s)}}}function ty(t,e,s,r){if(Zw(s,t),Qw(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=vh(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 p=0;p<r.length;p++){const w=r[p],f=Number(w>>BigInt(h)&BigInt(a));c[f]=c[f].add(s[p])}let d=i;for(let p=c.length-1,w=i;p>0;p--)w=w.add(c[p]),d=d.add(w);if(u=u.add(d),h!==0)for(let p=0;p<o;p++)u=u.double()}return u}function Oh(t){return Gw(t.Fp),ti(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ih(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const hr=BigInt(0),yo=BigInt(1);function sy(t){return ti(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function ry(t){const e=sy(t),{P:s}=e,r=b=>ft(b,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>Ch(b,s-BigInt(2),s));function l(b,v,C){const I=r(b*(v-C));return v=r(v-I),C=r(C+I),[v,C]}const u=(e.a-BigInt(2))/BigInt(4);function h(b,v){hs("u",b,hr,s),hs("scalar",v,hr,s);const C=v,I=b;let _=yo,S=hr,U=b,E=yo,$=hr,A;for(let z=BigInt(i-1);z>=hr;z--){const N=C>>z&yo;$^=N,A=l($,_,U),_=A[0],U=A[1],A=l($,S,E),S=A[0],E=A[1],$=N;const x=_+S,O=r(x*x),B=_-S,F=r(B*B),k=O-F,G=U+E,Q=U-E,se=r(Q*x),_e=r(G*B),de=se+_e,ke=se-_e;U=r(de*de),E=r(I*r(ke*ke)),_=r(O*F),S=r(k*(O+r(u*k)))}A=l($,_,U),_=A[0],U=A[1],A=l($,S,E),S=A[0],E=A[1];const L=c(S);return r(_*L)}function d(b){return Gn(r(b),n)}function p(b){const v=vt("u coordinate",b,n);return o===32&&(v[31]&=127),Ui(v)}function w(b){const v=vt("scalar",b),C=v.length;if(C!==n&&C!==o){let I=""+n+" or "+o;throw new Error("invalid scalar, expected "+I+" bytes, got "+C)}return Ui(a(v))}function f(b,v){const C=p(v),I=w(b),_=h(C,I);if(_===hr)throw new Error("invalid private or public key received");return d(_)}const m=d(e.Gu);function y(b){return f(b,m)}return{scalarMult:f,scalarMultBase:y,getSharedSecret:(b,v)=>f(b,v),getPublicKey:b=>y(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:m}}const ea=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const iy=BigInt(1),Vc=BigInt(2),ny=BigInt(3),oy=BigInt(5);BigInt(8);function ay(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=ea,o=t*t%n*t%n,a=Mt(o,Vc,n)*o%n,c=Mt(a,iy,n)*t%n,l=Mt(c,oy,n)*c%n,u=Mt(l,e,n)*l%n,h=Mt(u,s,n)*u%n,d=Mt(h,r,n)*h%n,p=Mt(d,i,n)*d%n,w=Mt(p,i,n)*d%n,f=Mt(w,e,n)*l%n;return{pow_p_5_8:Mt(f,Vc,n)*t%n,b2:o}}function cy(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const ta=ry({P:ea,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=ea,{pow_p_5_8:s,b2:r}=ay(t);return ft(Mt(s,ny,e)*r,e)},adjustScalarBytes:cy,randomBytes:ei});function Gc(t){t.lowS!==void 0&&Wr("lowS",t.lowS),t.prehash!==void 0&&Wr("prehash",t.prehash)}function ly(t){const e=Oh(t);ti(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:uy,hexToBytes:hy}=Ww;class dy extends Error{constructor(e=""){super(e)}}const ls={Err:dy,_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=Tr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?Tr(i.length/2|128):"";return Tr(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=Tr(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 uy(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=ls,i=typeof t=="string"?hy(t):t;Vi(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),He=BigInt(1);BigInt(2);const Jc=BigInt(3);BigInt(4);function py(t){const e=ly(t),{Fp:s}=e,r=_h(e.n,e.nBitLength),i=e.toBytes||((f,m,y)=>{const b=m.toAffine();return Di(Uint8Array.from([4]),s.toBytes(b.x),s.toBytes(b.y))}),n=e.fromBytes||(f=>{const m=f.subarray(1),y=s.fromBytes(m.subarray(0,s.BYTES)),b=s.fromBytes(m.subarray(s.BYTES,2*s.BYTES));return{x:y,y:b}});function o(f){const{a:m,b:y}=e,b=s.sqr(f),v=s.mul(b,f);return s.add(s.add(v,s.mul(f,m)),y)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(f){return Jn(f,He,e.n)}function c(f){const{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:b,n:v}=e;if(m&&typeof f!="bigint"){if(er(f)&&(f=Hr(f)),typeof f!="string"||!m.includes(f.length))throw new Error("invalid private key");f=f.padStart(y*2,"0")}let C;try{C=typeof f=="bigint"?f:Gs(vt("private key",f,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof f)}return b&&(C=ft(C,v)),hs("private key",C,He,v),C}function l(f){if(!(f instanceof d))throw new Error("ProjectivePoint expected")}const u=Xo((f,m)=>{const{px:y,py:b,pz:v}=f;if(s.eql(v,s.ONE))return{x:y,y:b};const C=f.is0();m==null&&(m=C?s.ONE:s.inv(v));const I=s.mul(y,m),_=s.mul(b,m),S=s.mul(v,m);if(C)return{x:s.ZERO,y:s.ZERO};if(!s.eql(S,s.ONE))throw new Error("invZ was invalid");return{x:I,y:_}}),h=Xo(f=>{if(f.is0()){if(e.allowInfinityPoint&&!s.is0(f.py))return;throw new Error("bad point: ZERO")}const{x:m,y}=f.toAffine();if(!s.isValid(m)||!s.isValid(y))throw new Error("bad point: x or y not FE");const b=s.sqr(y),v=o(m);if(!s.eql(b,v))throw new Error("bad point: equation left != right");if(!f.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(m,y,b){if(this.px=m,this.py=y,this.pz=b,m==null||!s.isValid(m))throw new Error("x required");if(y==null||!s.isValid(y))throw new Error("y required");if(b==null||!s.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(m){const{x:y,y:b}=m||{};if(!m||!s.isValid(y)||!s.isValid(b))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const v=C=>s.eql(C,s.ZERO);return v(y)&&v(b)?d.ZERO:new d(y,b,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const y=s.invertBatch(m.map(b=>b.pz));return m.map((b,v)=>b.toAffine(y[v])).map(d.fromAffine)}static fromHex(m){const y=d.fromAffine(n(vt("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return d.BASE.multiply(c(m))}static msm(m,y){return ty(d,r,m,y)}_setWindowSize(m){w.setWindowSize(this,m)}assertValidity(){h(this)}hasEvenY(){const{y:m}=this.toAffine();if(s.isOdd)return!s.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){l(m);const{px:y,py:b,pz:v}=this,{px:C,py:I,pz:_}=m,S=s.eql(s.mul(y,_),s.mul(C,v)),U=s.eql(s.mul(b,_),s.mul(I,v));return S&&U}negate(){return new d(this.px,s.neg(this.py),this.pz)}double(){const{a:m,b:y}=e,b=s.mul(y,Jc),{px:v,py:C,pz:I}=this;let _=s.ZERO,S=s.ZERO,U=s.ZERO,E=s.mul(v,v),$=s.mul(C,C),A=s.mul(I,I),L=s.mul(v,C);return L=s.add(L,L),U=s.mul(v,I),U=s.add(U,U),_=s.mul(m,U),S=s.mul(b,A),S=s.add(_,S),_=s.sub($,S),S=s.add($,S),S=s.mul(_,S),_=s.mul(L,_),U=s.mul(b,U),A=s.mul(m,A),L=s.sub(E,A),L=s.mul(m,L),L=s.add(L,U),U=s.add(E,E),E=s.add(U,E),E=s.add(E,A),E=s.mul(E,L),S=s.add(S,E),A=s.mul(C,I),A=s.add(A,A),E=s.mul(A,L),_=s.sub(_,E),U=s.mul(A,$),U=s.add(U,U),U=s.add(U,U),new d(_,S,U)}add(m){l(m);const{px:y,py:b,pz:v}=this,{px:C,py:I,pz:_}=m;let S=s.ZERO,U=s.ZERO,E=s.ZERO;const $=e.a,A=s.mul(e.b,Jc);let L=s.mul(y,C),z=s.mul(b,I),N=s.mul(v,_),x=s.add(y,b),O=s.add(C,I);x=s.mul(x,O),O=s.add(L,z),x=s.sub(x,O),O=s.add(y,v);let B=s.add(C,_);return O=s.mul(O,B),B=s.add(L,N),O=s.sub(O,B),B=s.add(b,v),S=s.add(I,_),B=s.mul(B,S),S=s.add(z,N),B=s.sub(B,S),E=s.mul($,O),S=s.mul(A,N),E=s.add(S,E),S=s.sub(z,E),E=s.add(z,E),U=s.mul(S,E),z=s.add(L,L),z=s.add(z,L),N=s.mul($,N),O=s.mul(A,O),z=s.add(z,N),N=s.sub(L,N),N=s.mul($,N),O=s.add(O,N),L=s.mul(z,O),U=s.add(U,L),L=s.mul(B,O),S=s.mul(x,S),S=s.sub(S,L),L=s.mul(x,z),E=s.mul(B,E),E=s.add(E,L),new d(S,U,E)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return w.wNAFCached(this,m,d.normalizeZ)}multiplyUnsafe(m){const{endo:y,n:b}=e;hs("scalar",m,us,b);const v=d.ZERO;if(m===us)return v;if(this.is0()||m===He)return this;if(!y||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,m,d.normalizeZ);let{k1neg:C,k1:I,k2neg:_,k2:S}=y.splitScalar(m),U=v,E=v,$=this;for(;I>us||S>us;)I&He&&(U=U.add($)),S&He&&(E=E.add($)),$=$.double(),I>>=He,S>>=He;return C&&(U=U.negate()),_&&(E=E.negate()),E=new d(s.mul(E.px,y.beta),E.py,E.pz),U.add(E)}multiply(m){const{endo:y,n:b}=e;hs("scalar",m,He,b);let v,C;if(y){const{k1neg:I,k1:_,k2neg:S,k2:U}=y.splitScalar(m);let{p:E,f:$}=this.wNAF(_),{p:A,f:L}=this.wNAF(U);E=w.constTimeNegate(I,E),A=w.constTimeNegate(S,A),A=new d(s.mul(A.px,y.beta),A.py,A.pz),v=E.add(A),C=$.add(L)}else{const{p:I,f:_}=this.wNAF(m);v=I,C=_}return d.normalizeZ([v,C])[0]}multiplyAndAddUnsafe(m,y,b){const v=d.BASE,C=(_,S)=>S===us||S===He||!_.equals(v)?_.multiplyUnsafe(S):_.multiply(S),I=C(this,y).add(C(m,b));return I.is0()?void 0:I}toAffine(m){return u(this,m)}isTorsionFree(){const{h:m,isTorsionFree:y}=e;if(m===He)return!0;if(y)return y(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:y}=e;return m===He?this:y?y(d,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return Wr("isCompressed",m),this.assertValidity(),i(d,this,m)}toHex(m=!0){return Wr("isCompressed",m),Hr(this.toRawBytes(m))}}d.BASE=new d(e.Gx,e.Gy,s.ONE),d.ZERO=new d(s.ZERO,s.ONE,s.ZERO);const p=e.nBitLength,w=ey(d,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function fy(t){const e=Oh(t);return ti(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function gy(t){const e=fy(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(N){return ft(N,r)}function a(N){return Qo(N,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=py({...e,toBytes(N,x,O){const B=x.toAffine(),F=s.toBytes(B.x),k=Di;return Wr("isCompressed",O),O?k(Uint8Array.from([x.hasEvenY()?2:3]),F):k(Uint8Array.from([4]),F,s.toBytes(B.y))},fromBytes(N){const x=N.length,O=N[0],B=N.subarray(1);if(x===i&&(O===2||O===3)){const F=Gs(B);if(!Jn(F,He,s.ORDER))throw new Error("Point is not on curve");const k=u(F);let G;try{G=s.sqrt(k)}catch(se){const _e=se instanceof Error?": "+se.message:"";throw new Error("Point is not on curve"+_e)}const Q=(G&He)===He;return(O&1)===1!==Q&&(G=s.neg(G)),{x:F,y:G}}else if(x===n&&O===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 "+x)}}}),d=N=>Hr(Kr(N,e.nByteLength));function p(N){const x=r>>He;return N>x}function w(N){return p(N)?o(-N):N}const f=(N,x,O)=>Gs(N.slice(x,O));class m{constructor(x,O,B){this.r=x,this.s=O,this.recovery=B,this.assertValidity()}static fromCompact(x){const O=e.nByteLength;return x=vt("compactSignature",x,O*2),new m(f(x,0,O),f(x,O,2*O))}static fromDER(x){const{r:O,s:B}=ls.toSig(vt("DER",x));return new m(O,B)}assertValidity(){hs("r",this.r,He,r),hs("s",this.s,He,r)}addRecoveryBit(x){return new m(this.r,this.s,x)}recoverPublicKey(x){const{r:O,s:B,recovery:F}=this,k=_(vt("msgHash",x));if(F==null||![0,1,2,3].includes(F))throw new Error("recovery id invalid");const G=F===2||F===3?O+e.n:O;if(G>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const Q=F&1?"03":"02",se=c.fromHex(Q+d(G)),_e=a(G),de=o(-k*_e),ke=o(B*_e),je=c.BASE.multiplyAndAddUnsafe(se,de,ke);if(!je)throw new Error("point at infinify");return je.assertValidity(),je}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return zr(this.toDERHex())}toDERHex(){return ls.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const y={isValidPrivateKey(N){try{return l(N),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const N=Nh(e.n);return Xw(e.randomBytes(N),e.n)},precompute(N=8,x=c.BASE){return x._setWindowSize(N),x.multiply(BigInt(3)),x}};function b(N,x=!0){return c.fromPrivateKey(N).toRawBytes(x)}function v(N){const x=er(N),O=typeof N=="string",B=(x||O)&&N.length;return x?B===i||B===n:O?B===2*i||B===2*n:N instanceof c}function C(N,x,O=!0){if(v(N))throw new Error("first arg must be private key");if(!v(x))throw new Error("second arg must be public key");return c.fromHex(x).multiply(l(N)).toRawBytes(O)}const I=e.bits2int||function(N){if(N.length>8192)throw new Error("input is too large");const x=Gs(N),O=N.length*8-e.nBitLength;return O>0?x>>BigInt(O):x},_=e.bits2int_modN||function(N){return o(I(N))},S=xa(e.nBitLength);function U(N){return hs("num < 2^"+e.nBitLength,N,us,S),Kr(N,e.nByteLength)}function E(N,x,O=$){if(["recovered","canonical"].some(Ue=>Ue in O))throw new Error("sign() legacy options not supported");const{hash:B,randomBytes:F}=e;let{lowS:k,prehash:G,extraEntropy:Q}=O;k==null&&(k=!0),N=vt("msgHash",N),Gc(O),G&&(N=vt("prehashed msgHash",B(N)));const se=_(N),_e=l(x),de=[U(_e),U(se)];if(Q!=null&&Q!==!1){const Ue=Q===!0?F(s.BYTES):Q;de.push(vt("extraEntropy",Ue))}const ke=Di(...de),je=se;function Qe(Ue){const De=I(Ue);if(!h(De))return;const Rs=a(De),es=c.BASE.multiply(De).toAffine(),Wt=o(es.x);if(Wt===us)return;const ts=o(Rs*o(je+Wt*_e));if(ts===us)return;let ss=(es.x===Wt?0:2)|Number(es.y&He),Qi=ts;return k&&p(ts)&&(Qi=w(ts),ss^=1),new m(Wt,Qi,ss)}return{seed:ke,k2sig:Qe}}const $={lowS:e.lowS,prehash:!1},A={lowS:e.lowS,prehash:!1};function L(N,x,O=$){const{seed:B,k2sig:F}=E(N,x,O),k=e;return Eh(k.hash.outputLen,k.nByteLength,k.hmac)(B,F)}c.BASE._setWindowSize(8);function z(N,x,O,B=A){var ts;const F=N;x=vt("msgHash",x),O=vt("publicKey",O);const{lowS:k,prehash:G,format:Q}=B;if(Gc(B),"strict"in B)throw new Error("options.strict was renamed to lowS");if(Q!==void 0&&Q!=="compact"&&Q!=="der")throw new Error("format must be compact or der");const se=typeof F=="string"||er(F),_e=!se&&!Q&&typeof F=="object"&&F!==null&&typeof F.r=="bigint"&&typeof F.s=="bigint";if(!se&&!_e)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let de,ke;try{if(_e&&(de=new m(F.r,F.s)),se){try{Q!=="compact"&&(de=m.fromDER(F))}catch(ss){if(!(ss instanceof ls.Err))throw ss}!de&&Q!=="der"&&(de=m.fromCompact(F))}ke=c.fromHex(O)}catch{return!1}if(!de||k&&de.hasHighS())return!1;G&&(x=e.hash(x));const{r:je,s:Qe}=de,Ue=_(x),De=a(Qe),Rs=o(Ue*De),es=o(je*De),Wt=(ts=c.BASE.multiplyAndAddUnsafe(ke,Rs,es))==null?void 0:ts.toAffine();return Wt?o(Wt.x)===je:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:C,sign:L,verify:z,ProjectivePoint:c,Signature:m,utils:y}}function my(t){return{hash:t,hmac:(e,...s)=>zn(t,e,vm(...s)),randomBytes:ei}}function wy(t,e){const s=r=>gy({...t,...my(r)});return{...s(e),create:s}}const Th=_h(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),yy=Th.create(BigInt("-3")),by=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),vy=wy({a:yy,b:by,Fp:Th,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Ki),xh="base10",nt="base16",qt="base64pad",Es="base64url",Gi="utf8",kh=0,ds=1,Ji=2,Ey=0,Yc=1,Ai=12,ka=32;function Cy(){const t=ta.utils.randomPrivateKey(),e=ta.getPublicKey(t);return{privateKey:gt(t,nt),publicKey:gt(e,nt)}}function sa(){const t=ei(ka);return gt(t,nt)}function Iy(t,e){const s=ta.getSharedSecret(kt(t,nt),kt(e,nt)),r=Sw(Ki,s,void 0,void 0,ka);return gt(r,nt)}function Cn(t){const e=Ki(kt(t,nt));return gt(e,nt)}function Yt(t){const e=Ki(kt(t,Gi));return gt(e,nt)}function $h(t){return kt(`${t}`,xh)}function tr(t){return Number(gt(t,xh))}function Rh(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Uh(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function _y(t){const e=$h(typeof t.type<"u"?t.type:kh);if(tr(e)===ds&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?kt(t.senderPublicKey,nt):void 0,r=typeof t.iv<"u"?kt(t.iv,nt):ei(Ai),i=kt(t.symKey,nt),n=yh(i,r).encrypt(kt(t.message,Gi)),o=Dh({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===Es?Rh(o):o}function Ay(t){const e=kt(t.symKey,nt),{sealed:s,iv:r}=Li({encoded:t.encoded,encoding:t.encoding}),i=yh(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return gt(i,Gi)}function Ny(t,e){const s=$h(Ji),r=ei(Ai),i=kt(t,Gi),n=Dh({type:s,sealed:i,iv:r});return e===Es?Rh(n):n}function Sy(t,e){const{sealed:s}=Li({encoded:t,encoding:e});return gt(s,Gi)}function Dh(t){if(tr(t.type)===Ji)return gt(vi([t.type,t.sealed]),qt);if(tr(t.type)===ds){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return gt(vi([t.type,t.senderPublicKey,t.iv,t.sealed]),qt)}return gt(vi([t.type,t.iv,t.sealed]),qt)}function Li(t){const e=(t.encoding||qt)===Es?Uh(t.encoded):t.encoded,s=kt(e,qt),r=s.slice(Ey,Yc),i=Yc;if(tr(r)===ds){const c=i+ka,l=c+Ai,u=s.slice(i,c),h=s.slice(c,l),d=s.slice(l);return{type:r,sealed:d,iv:h,senderPublicKey:u}}if(tr(r)===Ji){const c=s.slice(i),l=ei(Ai);return{type:r,sealed:c,iv:l}}const n=i+Ai,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function Py(t,e){const s=Li({encoded:t,encoding:e==null?void 0:e.encoding});return Lh({type:tr(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?gt(s.senderPublicKey,nt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Lh(t){const e=(t==null?void 0:t.type)||kh;if(e===ds){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function Xc(t){return t.type===ds&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Zc(t){return t.type===Ji}function Oy(t){const e=Buffer.from(t.x,"base64"),s=Buffer.from(t.y,"base64");return vi([new Uint8Array([4]),e,s])}function Ty(t,e){const[s,r,i]=t.split("."),n=Buffer.from(Uh(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=Ki(c),u=Oy(e);if(!vy.verify(vi([o,a]),l,u))throw new Error("Invalid signature");return Lo(t).payload}const xy="irn";function Rn(t){return(t==null?void 0:t.relay)||{protocol:xy}}function wi(t){const e=Rd[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function ky(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 Qc(t){if(!t.includes("wc:")){const l=nh(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:$y(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:ky(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function $y(t){return t.startsWith("//")?t.substring(2):t}function Ry(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 el(t){const e=new URLSearchParams,s=Ry(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 ln(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var Uy=Object.defineProperty,Dy=Object.defineProperties,Ly=Object.getOwnPropertyDescriptors,tl=Object.getOwnPropertySymbols,My=Object.prototype.hasOwnProperty,By=Object.prototype.propertyIsEnumerable,sl=(t,e,s)=>e in t?Uy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jy=(t,e)=>{for(var s in e||(e={}))My.call(e,s)&&sl(t,s,e[s]);if(tl)for(var s of tl(e))By.call(e,s)&&sl(t,s,e[s]);return t},qy=(t,e)=>Dy(t,Ly(e));function si(t){const e=[];return t.forEach(s=>{const[r,i]=s.split(":");e.push(`${r}:${i}`)}),e}function Fy(t){const e=[];return Object.values(t).forEach(s=>{e.push(...si(s.accounts))}),e}function Wy(t,e){const s=[];return Object.values(t).forEach(r=>{si(r.accounts).includes(e)&&s.push(...r.methods)}),s}function Hy(t,e){const s=[];return Object.values(t).forEach(r=>{si(r.accounts).includes(e)&&s.push(...r.events)}),s}function Yn(t){return t.includes(":")}function xr(t){return Yn(t)?t.split(":")[0]:t}function rl(t){var e,s,r;const i={};if(!Ps(t))return i;for(const[n,o]of Object.entries(t)){const a=Yn(n)?[n]:o.chains,c=o.methods||[],l=o.events||[],u=xr(n);i[u]=qy(jy({},i[u]),{chains:Zt(a,(e=i[u])==null?void 0:e.chains),methods:Zt(c,(s=i[u])==null?void 0:s.methods),events:Zt(l,(r=i[u])==null?void 0:r.events)})}return i}function zy(t){const e={};return t==null||t.forEach(s=>{var r;const[i,n]=s.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[],methods:[]}),e[i].accounts.push(s),(r=e[i].chains)==null||r.push(`${i}:${n}`)}),e}function il(t,e){e=e.map(r=>r.replace("did:pkh:",""));const s=zy(e);for(const[r,i]of Object.entries(s))i.methods?i.methods=Zt(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return s}function Ky(t,e){var s,r,i,n,o,a;const c=rl(t),l=rl(e),u={},h=Object.keys(c).concat(Object.keys(l));for(const d of h)u[d]={chains:Zt((s=c[d])==null?void 0:s.chains,(r=l[d])==null?void 0:r.chains),methods:Zt((i=c[d])==null?void 0:i.methods,(n=l[d])==null?void 0:n.methods),events:Zt((o=c[d])==null?void 0:o.events,(a=l[d])==null?void 0:a.events)};return u}const Vy={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}},Gy={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}=Gy[t];return{message:e?`${s} ${e}`:s,code:r}}function we(t,e){const{message:s,code:r}=Vy[t];return{message:e?`${s} ${e}`:s,code:r}}function Ss(t,e){return!!Array.isArray(t)}function Ps(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function tt(t){return typeof t>"u"}function Re(t,e){return e&&tt(t)?!0:typeof t=="string"&&!!t.trim().length}function $a(t,e){return typeof t=="number"&&!isNaN(t)}function Jy(t,e){const{requiredNamespaces:s}=e,r=Object.keys(t.namespaces),i=Object.keys(s);let n=!0;return Ks(i,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=si(a),h=s[o];(!Ks(eh(o,h),u)||!Ks(h.methods,c)||!Ks(h.events,l))&&(n=!1)}),n):!1}function Un(t){return Re(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Yy(t){if(Re(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&Un(s)}}return!1}function Xy(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(Re(t,!1)){if(e(t))return!0;const s=nh(t);return e(s)}}catch{}return!1}function Zy(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function Qy(t){return t==null?void 0:t.topic}function eb(t,e){let s=null;return Re(t==null?void 0:t.publicKey,!1)||(s=R("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function nl(t){let e=!0;return Ss(t)?t.length&&(e=t.every(s=>Re(s,!1))):e=!1,e}function tb(t,e,s){let r=null;return Ss(e)&&e.length?e.forEach(i=>{r||Un(i)||(r=we("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):Un(t)||(r=we("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 sb(t,e,s){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const o=tb(i,eh(i,n),`${e} ${s}`);o&&(r=o)}),r}function rb(t,e){let s=null;return Ss(t)?t.forEach(r=>{s||Yy(r)||(s=we("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`))}):s=we("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function ib(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=rb(r==null?void 0:r.accounts,`${e} namespace`);i&&(s=i)}),s}function nb(t,e){let s=null;return nl(t==null?void 0:t.methods)?nl(t==null?void 0:t.events)||(s=we("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=we("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function Mh(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=nb(r,`${e}, namespace`);i&&(s=i)}),s}function ob(t,e,s){let r=null;if(t&&Ps(t)){const i=Mh(t,e);i&&(r=i);const n=sb(t,e,s);n&&(r=n)}else r=R("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return r}function bo(t,e){let s=null;if(t&&Ps(t)){const r=Mh(t,e);r&&(s=r);const i=ib(t,e);i&&(s=i)}else s=R("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function Bh(t){return Re(t.protocol,!0)}function ab(t,e){let s=!1;return t?t&&Ss(t)&&t.length&&t.forEach(r=>{s=Bh(r)}):s=!0,s}function cb(t){return typeof t=="number"}function pt(t){return typeof t<"u"&&typeof t!==null}function lb(t){return!(!t||typeof t!="object"||!t.code||!$a(t.code)||!t.message||!Re(t.message,!1))}function ub(t){return!(tt(t)||!Re(t.method,!1))}function hb(t){return!(tt(t)||tt(t.result)&&tt(t.error)||!$a(t.id)||!Re(t.jsonrpc,!1))}function db(t){return!(tt(t)||!Re(t.name,!1))}function ol(t,e){return!(!Un(e)||!Fy(t).includes(e))}function pb(t,e,s){return Re(s,!1)?Wy(t,e).includes(s):!1}function fb(t,e,s){return Re(s,!1)?Hy(t,e).includes(s):!1}function al(t,e,s){let r=null;const i=gb(t),n=mb(e),o=Object.keys(i),a=Object.keys(n),c=cl(Object.keys(t)),l=cl(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.
|
|
@@ -905,4 +905,4 @@ ${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(xm(s)).toStr
|
|
|
905
905
|
.wui-color-fg-350 {
|
|
906
906
|
background-color: var(--wui-color-fg-350);
|
|
907
907
|
}
|
|
908
|
-
`,bi={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 Zi(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const uu=Zi({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"}),hu=Zi({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"});Zi({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"});Zi({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Zi({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 $I={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"]},Pn={getMethodsByChainNamespace(t){return $I[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 uu.caipNetworkId:u.chains.push(uu.deprecatedCaipNetworkId);break;case hu.caipNetworkId:u.chains.push(hu.deprecatedCaipNetworkId);break}return u!=null&&u.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await Ii.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class _d{constructor({provider:e,namespace:s}){this.id=j.CONNECTOR_ID.WALLET_CONNECT,this.name=Ln.ConnectorNamesMap[j.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=Ln.ConnectorImageIds[j.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=g.getCaipNetworks.bind(g),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=T.state.universalProviderConfigOverride,i=Pn.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 _i.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:RI})}}const RI=["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 UI{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>g.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:Ln.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){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=H.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof _d);if(!e)throw new Error("WalletConnectConnector not found");return e}}class DI extends UI{setUniversalProvider(e){this.addConnector(new _d({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,u)=>u.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Ie.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(H.state.balanceLoading&&e.chainId===((c=g.state.activeCaipNetwork)==null?void 0:c.id))return{balance:H.state.balance||"0.00",symbol:H.state.balanceSymbol||""};const i=(await H.fetchTokenBalance()).find(u=>{var h,d;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=g.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===j.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:Qu.encode(new TextEncoder().encode(r)),pubkey:i}},(a=g.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===j.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:qa(s.id)}]}))}catch(u){if(u.code===bi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===bi.ERROR_INVALID_CHAIN_ID||u.code===bi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===bi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:qa(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const LI=["email","socials","swaps","onramp","activity","reownBranding"],mn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ie.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?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!=null&&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!=null&&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}},MI={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=mn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=mn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return mn[t].processApi(e)},processFallbackFeature(t,e){return mn[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 K.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 LI){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 BI{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=g.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(h=>h.id===r);if(c)return c;const l=(o=g.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=g.getRequestedCaipNetworks(s).filter(h=>h.chainNamespace===s))==null?void 0:a[0])}return g.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>g.getCaipNetworks(s),this.getActiveChainNamespace=()=>g.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{g.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>g.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>g.state.activeChain===s||!s?g.state.activeCaipAddress:g.getAccountProp("caipAddress",s),this.setClientId=s=>{J.setClientId(s)},this.getProvider=s=>Oe.getProvider(s),this.getProviderType=s=>Oe.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=H.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{H.setCaipAddress(s,r),s&&T.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=>{g.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{g.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{H.setAllAccounts(s,r),T.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{H.setStatus(s,r),q.isConnected()?W.setConnectionStatus("connected"):W.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>g.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=>Ii.getNamesForAddress(s),this.getConnectors=()=>q.getConnectors(),this.getConnectorImage=s=>Eu.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=Oe.getProviderId(r),n=s?{...s,type:i}:void 0;H.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!g.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{H.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{H.removeAddressLabel(s,r)},this.getAddress=s=>g.state.activeChain===s||!s?H.state.address:g.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>g.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{g.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)=>{g.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{H.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{T.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await MI.fetchRemoteFeatures(e),T.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&qo.setOnrampProviders(this.remoteFeatures.onramp),((s=T.state.remoteFeatures)!=null&&s.email||Array.isArray((r=T.state.remoteFeatures)==null?void 0:r.socials)&&((i=T.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await K.fetchAllowedOrigins();if(e&&X.isClient()){const s=window.location.origin;Pn.isOriginAllowed(s,e,bi.DEFAULT_ALLOWED_ANCESTORS)||qs.open(Ar.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else qs.open(Ar.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Te.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&bt.setThemeMode(e.themeMode),e.themeVariables&&bt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");g.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&g.setActiveCaipNetwork(s)}initializeConnectionController(e){Y.setWcBasic(e.basic??!1)}initializeConnectorController(){q.initialize(this.chainNamespaces)}initializeProjectSettings(e){T.setProjectId(e.projectId),T.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;T.setDebug(e.debug!==!1),T.setEnableWalletConnect(e.enableWalletConnect!==!1),T.setEnableWalletGuide(e.enableWalletGuide!==!1),T.setEnableWallets(e.enableWallets!==!1),T.setEIP6963Enabled(e.enableEIP6963!==!1),T.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),T.setEnableAuthLogger(e.enableAuthLogger!==!1),T.setCustomRpcUrls(e.customRpcUrls),T.setEnableEmbedded(e.enableEmbedded),T.setAllWallets(e.allWallets),T.setIncludeWalletIds(e.includeWalletIds),T.setExcludeWalletIds(e.excludeWalletIds),T.setFeaturedWalletIds(e.featuredWalletIds),T.setTokens(e.tokens),T.setTermsConditionsUrl(e.termsConditionsUrl),T.setPrivacyPolicyUrl(e.privacyPolicyUrl),T.setCustomWallets(e.customWallets),T.setFeatures(e.features),T.setAllowUnsupportedChain(e.allowUnsupportedChain),T.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),T.setPreferUniversalLinks(e.experimental_preferUniversalLinks),T.setDefaultAccountTypes(e.defaultAccountTypes);const s=W.getPreferredAccountTypes()||{},r={...T.state.defaultAccountTypes,...s};H.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),T.setMetadata(e.metadata),T.setDisableAppend(e.disableAppend),T.setEnableEmbedded(e.enableEmbedded),T.setSIWX(e.siwx),!e.projectId){qs.open(Ar.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===j.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");T.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return X.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=Sr.getUnsupportedNetwork(`${s}:${e}`);g.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Sr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Sr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Sr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?Sr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=Oe.getProvider(e),i=Oe.getProviderId(e),{caipAddress:n}=g.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),W.removeConnectedNamespace(e),Oe.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),q.removeConnectorId(e),g.resetAccount(e),g.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=g.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),W.setConnectedNamespaces([...g.state.chains.keys()]),this.chainNamespaces.forEach(o=>{q.setConnectorId(Be.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var f,m,y,b,v,C;const c=g.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const I=this.getCaipNetworks().find(_=>_.chainNamespace===n);I&&this.setCaipNetwork(I)}if(!u)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),d=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((y=(m=(f=o==null?void 0:o.rpcUrls)==null?void 0:f.default)==null?void 0:m.http)==null?void 0:y[0])||((C=(v=(b=h==null?void 0:h.rpcUrls)==null?void 0:b.default)==null?void 0:v.http)==null?void 0:C[0])});if(!d)return;W.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const p=H.state.allAccounts,{accounts:w}=(p==null?void 0:p.length)>0?{accounts:[...p]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(w,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=g.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),W.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=lI(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));he.resetSend(),Y.resetWcConnection(),await _i.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(),Te.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(g.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:H.state.address,provider:Oe.getProvider(g.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Ie.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(g.state.activeChain),i=Oe.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===j.CHAIN.EVM){const s=this.getAdapter(g.state.activeChain),r=Oe.getProvider(g.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:H.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:g.state.activeChain}),H.state.profileImage||!1},getEnsAddress:async e=>await Pn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(g.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=Oe.getProvider(g.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(g.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(g.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(g.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!H.state.address||this.updateNativeBalance(H.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},Y.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(Oe.getProviderId(g.state.activeChain)===Be.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=Oe.getProvider(s),n=Oe.getProviderId(s);if(e.chainNamespace===g.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===Be.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)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new DI({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=W.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(W.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=g.state.activeChain===e,c=g.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=g.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=g.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=g.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=g.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===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){var a,c,l;const s=this.getAdapter(e),r=q.getConnectorId(e),i=this.getCaipNetwork(e),o=q.getConnectors(e).find(u=>u.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const u=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(u){const h=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([X.createAccount(e,u.address,"eoa")],e),this.syncProvider({...u,chainNamespace:e}),await this.syncAccount({...u,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,u,h;const r=this.getAdapter(s),i=((u=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:u.accounts)||[],n=(h=g.state.activeCaipNetwork)==null?void 0:h.id,o=i.find(d=>{const{chainId:p}=fs.parseCaipAddress(d);return p===(n==null?void 0:n.toString())})||i[0];if(o){const d=fs.validateCaipAddress(o),{chainId:p,address:w}=fs.parseCaipAddress(d);if(Oe.setProviderId(s,Be.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&g.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==j.CHAIN.EVM){const f=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:g.state.activeCaipNetwork});Oe.setProvider(s,f)}else Oe.setProvider(s,this.universalProvider);q.setConnectorId(j.CONNECTOR_ID.WALLET_CONNECT,s),W.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:w,chainId:p,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await g.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=fs.parseCaipAddress(c);return l}).filter((c,l,u)=>u.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){Oe.setProviderId(i,e),Oe.setProvider(i,s),q.setConnectorId(r,i)}async syncAllAccounts(e){const s=q.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var h,d;const s=e.chainNamespace===g.state.activeChain,r=g.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=W.getActiveNetworkProps(),c=n||a,l=((h=g.state.activeCaipNetwork)==null?void 0:h.name)===j.UNSUPPORTED_NETWORK_NAME,u=g.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let p=this.getCaipNetworks().find(m=>m.id.toString()===c.toString()),w=this.getCaipNetworks().find(m=>m.chainNamespace===o);if(!u&&!p&&!w){const m=this.getApprovedCaipNetworkIds()||[],y=m.find(v=>{var C;return((C=fs.parseCaipNetworkId(v))==null?void 0:C.chainId)===c.toString()}),b=m.find(v=>{var C;return((C=fs.parseCaipNetworkId(v))==null?void 0:C.chainNamespace)===o});p=this.getCaipNetworks().find(v=>v.caipNetworkId===y),w=this.getCaipNetworks().find(v=>v.caipNetworkId===b||"deprecatedCaipNetworkId"in v&&v.deprecatedCaipNetworkId===b)}const f=p||w;(f==null?void 0:f.chainNamespace)===g.state.activeChain?T.state.enableNetworkSwitch&&!T.state.allowUnsupportedChain&&((d=g.state.activeCaipNetwork)==null?void 0:d.name)===j.UNSUPPORTED_NETWORK_NAME?g.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),La.isLowerCaseMatch(i,H.state.address)||this.syncAccountInfo(i,f==null?void 0:f.id,o),s?await this.syncBalance({address:i,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=q.getConnectorId(e),r=Oe.getProviderId(e);if(r===Be.CONNECTOR_TYPE_ANNOUNCED||r===Be.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===Be.CONNECTOR_TYPE_WALLET_CONNECT){const n=Oe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===j.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===j.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!wu.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=g.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,u,h,d;const e=dI.createLogger((p,...w)=>{p&&this.handleAlertError(p),console.error(...w)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};T.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await cI.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==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(Pn.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(){var e;return!this.universalProviderInitPromise&&X.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Te.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(Ar.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=Ar.ALERT_ERRORS[o];a&&(qs.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&Y.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return Ve.open({...e,data:{swap:e.arguments}})}return Ve.open(e)}async close(){await this.injectModalUi(),Ve.close()}setLoading(e,s){Ve.setLoading(e,s)}async disconnect(e){await Y.disconnect(e)}getSIWX(){return T.state.siwx}getError(){return""}getChainId(){var e;return(e=g.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){qs.open(Ar.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await g.switchActiveNetwork(s)}getWalletProvider(){return g.state.activeChain?Oe.state.providers[g.state.activeChain]:null}getWalletProviderType(){return Oe.getProviderId(g.state.activeChain)}subscribeProviders(e){return Oe.subscribeProviders(e)}getThemeMode(){return bt.state.themeMode}getThemeVariables(){return bt.state.themeVariables}setThemeMode(e){bt.setThemeMode(e),Id(bt.state.themeMode)}setTermsConditionsUrl(e){T.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){T.setPrivacyPolicyUrl(e)}setThemeVariables(e){bt.setThemeVariables(e),kI(bt.state.themeVariables)}subscribeTheme(e){return bt.subscribe(e)}getWalletInfo(){return H.state.connectedWalletInfo}getAccount(e){var o;const s=q.getAuthConnector(e),r=g.getAccountData(e),i=g.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:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?g.subscribeChainProp("accountState",r,s):g.subscribe(r),q.subscribe(r)}subscribeNetwork(e){return g.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return H.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){H.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){g.subscribeKey("activeCaipNetwork",e)}getState(){return As.state}subscribeState(e){return As.subscribe(e)}showErrorMessage(e){jt.showError(e)}showSuccessMessage(e){jt.showSuccess(e)}getEvent(){return{...Te.state}}subscribeEvents(e){return Te.subscribe(e)}replace(e){re.replace(e)}redirect(e){re.push(e)}popTransactionStack(e){re.popTransactionStack(e)}isOpen(){return Ve.state.open}isTransactionStackEmpty(){return re.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){T.setFeatures(e)}updateRemoteFeatures(e){T.setRemoteFeatures(e)}updateOptions(e){const r={...T.state||{},...e};T.setOptions(r)}setConnectMethodsOrder(e){T.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){T.setWalletFeaturesOrder(e)}setCollapseWallets(e){T.setCollapseWallets(e)}setSocialsOrder(e){T.setSocialsOrder(e)}getConnectMethodsOrder(){return wa.getConnectOrderMethod(T.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)||g.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)&&g.removeNetwork(e,s)}}let du=!1;class Ad extends BI{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(!du&&X.isClient()){if(await Do(()=>import("./basic-PxGakulR.js"),__vite__mapDeps([4,5,1,2,3])),await Do(()=>import("./w3m-modal-CGtztDSc.js"),__vite__mapDeps([6,5,1,2,3])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!T.state.disableAppend&&!T.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}du=!0}}}const jI="1.7.8";function qI(t){return new Ad({...t,basic:!0,sdkVersion:`html-core-${jI}`})}const __=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Ad,createAppKit:qI},Symbol.toStringTag,{value:"Module"}));export{K as A,ya as B,q as C,wd as D,Te as E,Vr as F,c_ as G,yg as H,hc as I,Gu as J,cg as K,bg as L,Ve as M,l_ as N,T as O,a_ as P,Hn as Q,re as R,W as S,bt as T,u_ as U,h_ as V,wa as W,__ as X,Sn as a,y_ as b,X as c,An as d,C_ as e,Eu as f,Y as g,j as h,Dr as i,g as j,Bt as k,jt as l,Ie as m,Ke as n,I_ as o,Pe as p,At as q,E_ as r,st as s,rt as t,_i as u,qs as v,b_ as w,fI as x,H as y,v_ as z};
|
|
908
|
+
`,bi={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 Zi(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const uu=Zi({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"}),hu=Zi({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"});Zi({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"});Zi({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Zi({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 $I={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"]},Pn={getMethodsByChainNamespace(t){return $I[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 uu.caipNetworkId:u.chains.push(uu.deprecatedCaipNetworkId);break;case hu.caipNetworkId:u.chains.push(hu.deprecatedCaipNetworkId);break}return u!=null&&u.rpcMap&&c&&(u.rpcMap[n]=c),r},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{var r;const e=await Ii.resolveName(t);return((r=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:r.address)||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],r=e.accounts.map(i=>{const[n,o]=i.split(":");return`${n}:${o}`});return Array.from(new Set([...s,...r]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isOriginAllowed(t,e,s){for(const r of[...e,...s])if(r.includes("*")){const n=`^${r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(n,"u").test(t))return!0}else try{if(new URL(r).origin===t)return!0}catch{if(r===t)return!0}return!1}};class _d{constructor({provider:e,namespace:s}){this.id=j.CONNECTOR_ID.WALLET_CONNECT,this.name=Ln.ConnectorNamesMap[j.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=Ln.ConnectorImageIds[j.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=g.getCaipNetworks.bind(g),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=T.state.universalProviderConfigOverride,i=Pn.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 _i.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:RI})}}const RI=["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 UI{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>g.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:Ln.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){var r;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(r=this.eventListeners.get(e))==null||r.add(s)}off(e,s){const r=this.eventListeners.get(e);r&&r.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const r=this.eventListeners.get(e);r&&r.forEach(i=>i(s))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){var n;const{caipNetwork:s,providerType:r}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if(r==="WALLET_CONNECT"){i.setDefaultChain(s.caipNetworkId);return}if(i&&r==="AUTH"){const o=i,a=(n=H.state.preferredAccountTypes)==null?void 0:n[s.chainNamespace];await o.switchNetwork(s.caipNetworkId);const c=await o.getUser({chainId:s.caipNetworkId,preferredAccountType:a});this.emit("switchNetwork",c)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof _d);if(!e)throw new Error("WalletConnectConnector not found");return e}}class DI extends UI{setUniversalProvider(e){this.addConnector(new _d({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var i,n,o,a;const s=this.provider,r=((a=(o=(n=(i=s==null?void 0:s.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,u)=>u.indexOf(c)===l))||[];return Promise.resolve({accounts:r.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,c,l;if(!(e.caipNetwork&&Ie.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(H.state.balanceLoading&&e.chainId===((c=g.state.activeCaipNetwork)==null?void 0:c.id))return{balance:H.state.balance||"0.00",symbol:H.state.balanceSymbol||""};const i=(await H.fetchTokenBalance()).find(u=>{var h,d;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((l=e.caipNetwork)==null?void 0:l.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:r,address:i}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=g.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===j.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:Qu.encode(new TextEncoder().encode(r)),pubkey:i}},(a=g.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var i,n,o,a,c,l;const{caipNetwork:s}=e,r=this.getWalletConnectConnector();if(s.chainNamespace===j.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:qa(s.id)}]}))}catch(u){if(u.code===bi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===bi.ERROR_INVALID_CHAIN_ID||u.code===bi.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===bi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:qa(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}r.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(r=>r.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const LI=["email","socials","swaps","onramp","activity","reownBranding"],mn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ie.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?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!=null&&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!=null&&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}},MI={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=mn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=mn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return mn[t].processApi(e)},processFallbackFeature(t,e){return mn[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 K.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 LI){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 BI{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=g.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(h=>h.id===r);if(c)return c;const l=(o=g.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=g.getRequestedCaipNetworks(s).filter(h=>h.chainNamespace===s))==null?void 0:a[0])}return g.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>g.getCaipNetworks(s),this.getActiveChainNamespace=()=>g.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{g.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>g.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>g.state.activeChain===s||!s?g.state.activeCaipAddress:g.getAccountProp("caipAddress",s),this.setClientId=s=>{J.setClientId(s)},this.getProvider=s=>Oe.getProvider(s),this.getProviderType=s=>Oe.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=H.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{H.setCaipAddress(s,r),s&&T.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=>{g.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{g.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{H.setAllAccounts(s,r),T.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{H.setStatus(s,r),q.isConnected()?W.setConnectionStatus("connected"):W.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>g.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=>Ii.getNamesForAddress(s),this.getConnectors=()=>q.getConnectors(),this.getConnectorImage=s=>Eu.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=Oe.getProviderId(r),n=s?{...s,type:i}:void 0;H.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!g.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{H.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{H.removeAddressLabel(s,r)},this.getAddress=s=>g.state.activeChain===s||!s?H.state.address:g.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>g.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{g.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)=>{g.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{H.setPreferredAccountType(s,r)},this.setEIP6963Enabled=s=>{T.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const r=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(r!=null&&r.length)return[...new Set(r)];const i=s==null?void 0:s.map(n=>n.chainNamespace);return[...new Set(i)]}async initialize(e){var s,r,i;this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await MI.fetchRemoteFeatures(e),T.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&qo.setOnrampProviders(this.remoteFeatures.onramp),((s=T.state.remoteFeatures)!=null&&s.email||Array.isArray((r=T.state.remoteFeatures)==null?void 0:r.socials)&&((i=T.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await K.fetchAllowedOrigins();if(e&&X.isClient()){const s=window.location.origin;Pn.isOriginAllowed(s,e,bi.DEFAULT_ALLOWED_ANCESTORS)||qs.open(Ar.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else qs.open(Ar.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Te.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(i=>i.id),siweConfig:{options:((r=e.siweConfig)==null?void 0:r.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&bt.setThemeMode(e.themeMode),e.themeVariables&&bt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");g.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&g.setActiveCaipNetwork(s)}initializeConnectionController(e){Y.setWcBasic(e.basic??!1)}initializeConnectorController(){q.initialize(this.chainNamespaces)}initializeProjectSettings(e){T.setProjectId(e.projectId),T.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var o;T.setDebug(e.debug!==!1),T.setEnableWalletConnect(e.enableWalletConnect!==!1),T.setEnableWalletGuide(e.enableWalletGuide!==!1),T.setEnableWallets(e.enableWallets!==!1),T.setEIP6963Enabled(e.enableEIP6963!==!1),T.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),T.setEnableAuthLogger(e.enableAuthLogger!==!1),T.setCustomRpcUrls(e.customRpcUrls),T.setEnableEmbedded(e.enableEmbedded),T.setAllWallets(e.allWallets),T.setIncludeWalletIds(e.includeWalletIds),T.setExcludeWalletIds(e.excludeWalletIds),T.setFeaturedWalletIds(e.featuredWalletIds),T.setTokens(e.tokens),T.setTermsConditionsUrl(e.termsConditionsUrl),T.setPrivacyPolicyUrl(e.privacyPolicyUrl),T.setCustomWallets(e.customWallets),T.setFeatures(e.features),T.setAllowUnsupportedChain(e.allowUnsupportedChain),T.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),T.setPreferUniversalLinks(e.experimental_preferUniversalLinks),T.setDefaultAccountTypes(e.defaultAccountTypes);const s=W.getPreferredAccountTypes()||{},r={...T.state.defaultAccountTypes,...s};H.setPreferredAccountTypes(r);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),T.setMetadata(e.metadata),T.setDisableAppend(e.disableAppend),T.setEnableEmbedded(e.enableEmbedded),T.setSIWX(e.siwx),!e.projectId){qs.open(Ar.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===j.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");T.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,r,i;return X.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((r=document.querySelector('meta[property="og:description"]'))==null?void 0:r.content)||"",url:window.location.origin,icons:[((i=document.querySelector('link[rel~="icon"]'))==null?void 0:i.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const r=Sr.getUnsupportedNetwork(`${s}:${e}`);g.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Sr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Sr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Sr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(i=>{var n;return i.id===((n=e.defaultNetwork)==null?void 0:n.id)});return s?Sr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=Oe.getProvider(e),i=Oe.getProviderId(e),{caipAddress:n}=g.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),W.removeConnectedNamespace(e),Oe.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),q.removeConnectorId(e),g.resetAccount(e),g.resetNetwork(e),this.setLoading(!1,e)}catch(s){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${s.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=g.state.activeChain,s=this.getAdapter(e),r=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!s)throw new Error("Adapter not found");const i=await s.connectWalletConnect(r);this.close(),this.setClientId((i==null?void 0:i.clientId)||null),W.setConnectedNamespaces([...g.state.chains.keys()]),this.chainNamespaces.forEach(o=>{q.setConnectorId(Be.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:s,type:r,provider:i,chain:n,caipNetwork:o,socialUri:a})=>{var f,m,y,b,v,C;const c=g.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const I=this.getCaipNetworks().find(_=>_.chainNamespace===n);I&&this.setCaipNetwork(I)}if(!u)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),d=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((y=(m=(f=o==null?void 0:o.rpcUrls)==null?void 0:f.default)==null?void 0:m.http)==null?void 0:y[0])||((C=(v=(b=h==null?void 0:h.rpcUrls)==null?void 0:b.default)==null?void 0:v.http)==null?void 0:C[0])});if(!d)return;W.addConnectedNamespace(l),this.syncProvider({...d,chainNamespace:l});const p=H.state.allAccounts,{accounts:w}=(p==null?void 0:p.length)>0?{accounts:[...p]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(w,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=g.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:r,provider:i,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),W.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnect:async e=>{const s=lI(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));he.resetSend(),Y.resetWcConnection(),await _i.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(),Te.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(r){throw new Error(`Failed to disconnect chains: ${r.message}`)}},checkInstalled:e=>e?e.some(s=>{var r;return!!((r=window.ethereum)!=null&&r[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=this.getAdapter(g.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:H.state.address,provider:Oe.getProvider(g.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Ie.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(g.state.activeChain),i=Oe.getProvider(s),n=await(r==null?void 0:r.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===j.CHAIN.EVM){const s=this.getAdapter(g.state.activeChain),r=Oe.getProvider(g.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const n=await(s==null?void 0:s.estimateGas({...e,provider:r,caipNetwork:i}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;return await this.syncIdentity({address:H.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:g.state.activeChain}),H.state.profileImage||!1},getEnsAddress:async e=>await Pn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(g.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=Oe.getProvider(g.state.activeChain);if(!r||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(s==null?void 0:s.writeContract({...e,caipNetwork:r,provider:n,caipAddress:i}));return o==null?void 0:o.hash},parseUnits:(e,s)=>{const r=this.getAdapter(g.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(g.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(g.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(g.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!H.state.address||this.updateNativeBalance(H.state.address,s==null?void 0:s.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},Y.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var s,r,i,n,o;if(Oe.getProviderId(g.state.activeChain)===Be.CONNECTOR_TYPE_WALLET_CONNECT){const a=(r=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:r.namespaces;return{supportsAllNetworks:((o=(n=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=Oe.getProvider(s),n=Oe.getProviderId(s);if(e.chainNamespace===g.state.activeChain){const o=this.getAdapter(s);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:i,providerType:n}))}else if(this.setCaipNetwork(e),n===Be.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)=>{var n;const i=e==null?void 0:e.find(o=>o.namespace===r);return i?(i.construct({namespace:r,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.getCaipNetworks()}),s[r]=i):s[r]=new DI({namespace:r,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){var s;this.onConnectors(e),this.listenAdapter(e),await((s=this.chainAdapters)==null?void 0:s[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const r=W.getConnectionStatus();r==="connected"?this.setStatus("connecting",e):r==="disconnected"?(W.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),s.on("switchNetwork",({address:i,chainId:n})=>{const o=this.getCaipNetworks().find(l=>l.id===n||l.caipNetworkId===n),a=g.state.activeChain===e,c=g.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=g.state.activeCaipNetwork;!i||!(n!=null&&n.id)||this.updateNativeBalance(i,n.id,n.chainNamespace)}),s.on("accountChanged",({address:i,chainId:n})=>{var a,c;const o=g.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=g.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=g.state.activeCaipNetwork)==null?void 0:c.id,chainNamespace:e}):this.syncAccountInfo(i,n,e),this.syncAllAccounts(e)})}async createUniversalProviderForAdapter(e){var s,r,i;await this.getUniversalProvider(),this.universalProvider&&((i=(r=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:r.setUniversalProvider)==null||i.call(r,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{e===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){var a,c,l;const s=this.getAdapter(e),r=q.getConnectorId(e),i=this.getCaipNetwork(e),o=q.getConnectors(e).find(u=>u.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const u=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));if(u){const h=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([X.createAccount(e,u.address,"eoa")],e),this.syncProvider({...u,chainNamespace:e}),await this.syncAccount({...u,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async s=>{var a,c,l,u,h;const r=this.getAdapter(s),i=((u=(l=(c=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:c.namespaces)==null?void 0:l[s])==null?void 0:u.accounts)||[],n=(h=g.state.activeCaipNetwork)==null?void 0:h.id,o=i.find(d=>{const{chainId:p}=fs.parseCaipAddress(d);return p===(n==null?void 0:n.toString())})||i[0];if(o){const d=fs.validateCaipAddress(o),{chainId:p,address:w}=fs.parseCaipAddress(d);if(Oe.setProviderId(s,Be.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&g.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==j.CHAIN.EVM){const f=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:g.state.activeCaipNetwork});Oe.setProvider(s,f)}else Oe.setProvider(s,this.universalProvider);q.setConnectorId(j.CONNECTOR_ID.WALLET_CONNECT,s),W.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:w,chainId:p,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await g.setApprovedCaipNetworksData(s)});await Promise.all(e)}syncWalletConnectAccounts(e){var r,i,n,o,a;const s=(a=(o=(n=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const{address:l}=fs.parseCaipAddress(c);return l}).filter((c,l,u)=>u.indexOf(c)===l);s&&this.setAllAccounts(s.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:s,id:r,chainNamespace:i}){Oe.setProviderId(i,e),Oe.setProvider(i,s),q.setConnectorId(r,i)}async syncAllAccounts(e){const s=q.getConnectorId(e);if(!s)return;const r=this.getAdapter(e),i=await(r==null?void 0:r.getAccounts({namespace:e,id:s}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){var h,d;const s=e.chainNamespace===g.state.activeChain,r=g.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=W.getActiveNetworkProps(),c=n||a,l=((h=g.state.activeCaipNetwork)==null?void 0:h.name)===j.UNSUPPORTED_NETWORK_NAME,u=g.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let p=this.getCaipNetworks().find(m=>m.id.toString()===c.toString()),w=this.getCaipNetworks().find(m=>m.chainNamespace===o);if(!u&&!p&&!w){const m=this.getApprovedCaipNetworkIds()||[],y=m.find(v=>{var C;return((C=fs.parseCaipNetworkId(v))==null?void 0:C.chainId)===c.toString()}),b=m.find(v=>{var C;return((C=fs.parseCaipNetworkId(v))==null?void 0:C.chainNamespace)===o});p=this.getCaipNetworks().find(v=>v.caipNetworkId===y),w=this.getCaipNetworks().find(v=>v.caipNetworkId===b||"deprecatedCaipNetworkId"in v&&v.deprecatedCaipNetworkId===b)}const f=p||w;(f==null?void 0:f.chainNamespace)===g.state.activeChain?T.state.enableNetworkSwitch&&!T.state.allowUnsupportedChain&&((d=g.state.activeCaipNetwork)==null?void 0:d.name)===j.UNSUPPORTED_NETWORK_NAME?g.showUnsupportedChainUI():this.setCaipNetwork(f):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),La.isLowerCaseMatch(i,H.state.address)||this.syncAccountInfo(i,f==null?void 0:f.id,o),s?await this.syncBalance({address:i,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:i,chainId:r==null?void 0:r.id,chainNamespace:o})}}async syncAccountInfo(e,s,r){const i=this.getCaipAddress(r),n=s||(i==null?void 0:i.split(":")[1]);if(!n)return;const o=`${r}:${n}:${e}`;this.setCaipAddress(o,r),await this.syncIdentity({address:e,chainId:n,chainNamespace:r})}async syncReownName(e,s){try{const r=await this.getReownName(e);if(r[0]){const i=r[0];this.setProfileName(i.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var i;const s=q.getConnectorId(e),r=Oe.getProviderId(e);if(r===Be.CONNECTOR_TYPE_ANNOUNCED||r===Be.CONNECTOR_TYPE_INJECTED){if(s){const n=this.getConnectors().find(o=>o.id===s);if(n){const{info:o,name:a,imageUrl:c}=n,l=c||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(r===Be.CONNECTOR_TYPE_WALLET_CONNECT){const n=Oe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(i=n.session.peer.metadata.icons)==null?void 0:i[0]},e)}else if(s&&s===j.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===j.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!wu.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(r=>{var i;return r.id.toString()===((i=e.chainId)==null?void 0:i.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,r){const i=this.getAdapter(r),n=g.getCaipNetworkByNamespace(r,s);if(i){const o=await i.getBalance({address:e,chainId:s,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,r),o}}async initializeUniversalAdapter(){var r,i,n,o,a,c,l,u,h,d;const e=dI.createLogger((p,...w)=>{p&&this.handleAlertError(p),console.error(...w)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(c=this.options)!=null&&c.metadata?(l=this.options)==null?void 0:l.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};T.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await cI.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==null?void 0:r.id)!==(s==null?void 0:s.id)&&this.setCaipNetwork(s)}),this.universalProvider.on("session_event",e=>{if(Pn.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(){var e;return!this.universalProviderInitPromise&&X.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Te.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(Ar.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=Ar.ALERT_ERRORS[o];a&&(qs.open(a,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const r=e;r.namespace=s,r.construct({namespace:s,projectId:(i=this.options)==null?void 0:i.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=r)}async open(e){if(await this.injectModalUi(),e!=null&&e.uri&&Y.setUri(e.uri),e!=null&&e.arguments)switch(e==null?void 0:e.view){case"Swap":return Ve.open({...e,data:{swap:e.arguments}})}return Ve.open(e)}async close(){await this.injectModalUi(),Ve.close()}setLoading(e,s){Ve.setLoading(e,s)}async disconnect(e){await Y.disconnect(e)}getSIWX(){return T.state.siwx}getError(){return""}getChainId(){var e;return(e=g.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){qs.open(Ar.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await g.switchActiveNetwork(s)}getWalletProvider(){return g.state.activeChain?Oe.state.providers[g.state.activeChain]:null}getWalletProviderType(){return Oe.getProviderId(g.state.activeChain)}subscribeProviders(e){return Oe.subscribeProviders(e)}getThemeMode(){return bt.state.themeMode}getThemeVariables(){return bt.state.themeVariables}setThemeMode(e){bt.setThemeMode(e),Id(bt.state.themeMode)}setTermsConditionsUrl(e){T.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){T.setPrivacyPolicyUrl(e)}setThemeVariables(e){bt.setThemeVariables(e),kI(bt.state.themeVariables)}subscribeTheme(e){return bt.subscribe(e)}getWalletInfo(){return H.state.connectedWalletInfo}getAccount(e){var o;const s=q.getAuthConnector(e),r=g.getAccountData(e),i=g.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:(o=r.preferredAccountTypes)==null?void 0:o[e||i],isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const r=()=>{const i=this.getAccount(s);i&&e(i)};s?g.subscribeChainProp("accountState",r,s):g.subscribe(r),q.subscribe(r)}subscribeNetwork(e){return g.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return H.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){H.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){g.subscribeKey("activeCaipNetwork",e)}getState(){return As.state}subscribeState(e){return As.subscribe(e)}showErrorMessage(e){jt.showError(e)}showSuccessMessage(e){jt.showSuccess(e)}getEvent(){return{...Te.state}}subscribeEvents(e){return Te.subscribe(e)}replace(e){re.replace(e)}redirect(e){re.push(e)}popTransactionStack(e){re.popTransactionStack(e)}isOpen(){return Ve.state.open}isTransactionStackEmpty(){return re.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){T.setFeatures(e)}updateRemoteFeatures(e){T.setRemoteFeatures(e)}updateOptions(e){const r={...T.state||{},...e};T.setOptions(r)}setConnectMethodsOrder(e){T.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){T.setWalletFeaturesOrder(e)}setCollapseWallets(e){T.setCollapseWallets(e)}setSocialsOrder(e){T.setSocialsOrder(e)}getConnectMethodsOrder(){return wa.getConnectOrderMethod(T.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)||g.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)&&g.removeNetwork(e,s)}}let du=!1;class Ad extends BI{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(!du&&X.isClient()){if(await Do(()=>import("./basic-BNAPw1FU.js"),__vite__mapDeps([4,5,1,2,3])),await Do(()=>import("./w3m-modal-o69qIUHV.js"),__vite__mapDeps([6,5,1,2,3])),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!T.state.disableAppend&&!T.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}du=!0}}}const jI="1.7.8";function qI(t){return new Ad({...t,basic:!0,sdkVersion:`html-core-${jI}`})}const __=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Ad,createAppKit:qI},Symbol.toStringTag,{value:"Module"}));export{K as A,ya as B,q as C,wd as D,Te as E,Vr as F,c_ as G,yg as H,hc as I,Gu as J,cg as K,bg as L,Ve as M,l_ as N,T as O,a_ as P,Hn as Q,re as R,W as S,bt as T,u_ as U,h_ as V,wa as W,__ as X,Sn as a,y_ as b,X as c,An as d,C_ as e,Eu as f,Y as g,j as h,Dr as i,g as j,Bt as k,jt as l,Ie as m,Ke as n,I_ as o,Pe as p,At as q,E_ as r,st as s,rt as t,_i as u,qs as v,b_ as w,fI as x,H as y,v_ as z};
|