@dcl/vesting-dashboard 3.6.1-16577537275.commit-a4c65b5 → 3.7.1-19868070294.commit-e76f047
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/PhArrowCircleDown-b4d1b9f0.js +14 -0
- package/assets/PhArrowClockwise-35e72491.js +14 -0
- package/assets/PhArrowDown-57c22b7e.js +14 -0
- package/assets/PhArrowLeft-f48f6a32.js +14 -0
- package/assets/PhArrowRight-86fee956.js +14 -0
- package/assets/PhArrowSquareOut-7b8bc76d.js +14 -0
- package/assets/PhArrowUp-cb14a0b1.js +14 -0
- package/assets/PhArrowUpRight-72a93a0e.js +14 -0
- package/assets/PhArrowsClockwise-ecc02e05.js +14 -0
- package/assets/PhArrowsDownUp-336a1435.js +14 -0
- package/assets/PhArrowsLeftRight-fbdccc02.js +14 -0
- package/assets/PhBank-31d2eba3.js +14 -0
- package/assets/PhBrowser-90d21d12.js +14 -0
- package/assets/PhCaretDown-3aabbdc5.js +14 -0
- package/assets/PhCaretLeft-282326ec.js +14 -0
- package/assets/PhCaretRight-7b09ae84.js +14 -0
- package/assets/PhCaretUp-e4584d94.js +14 -0
- package/assets/PhCheck-5730aae2.js +14 -0
- package/assets/PhCircleHalf-7d16bc06.js +14 -0
- package/assets/PhClock-8b060e99.js +14 -0
- package/assets/PhCompass-45d3bde6.js +14 -0
- package/assets/PhCopy-f77992ef.js +14 -0
- package/assets/PhCreditCard-c353277e.js +14 -0
- package/assets/PhCurrencyDollar-510272c7.js +14 -0
- package/assets/PhDesktop-49e8128e.js +14 -0
- package/assets/PhDeviceMobile-cfdf19ef.js +14 -0
- package/assets/PhDotsThree-69a484e4.js +14 -0
- package/assets/PhEnvelope-fc3dd2a0.js +14 -0
- package/assets/PhFunnelSimple-5abe9858.js +14 -0
- package/assets/PhGlobe-a1b4ca91.js +14 -0
- package/assets/PhIdentificationCard-80541484.js +14 -0
- package/assets/PhImage-6bbac6b7.js +14 -0
- package/assets/PhInfo-3481abef.js +14 -0
- package/assets/PhLightbulb-26b52ed2.js +14 -0
- package/assets/PhMagnifyingGlass-4dfb76cc.js +14 -0
- package/assets/PhPaperPlaneRight-e6cf54ef.js +14 -0
- package/assets/PhPlus-f5753116.js +14 -0
- package/assets/PhPower-8bf5c9c7.js +14 -0
- package/assets/PhPuzzlePiece-93f1c92b.js +14 -0
- package/assets/PhQrCode-03aa9f8a.js +14 -0
- package/assets/PhQuestion-6c2bd1ad.js +14 -0
- package/assets/PhQuestionMark-820f14af.js +14 -0
- package/assets/PhSealCheck-137e0b1b.js +14 -0
- package/assets/PhSignOut-ed65c268.js +14 -0
- package/assets/PhSpinner-19f53f69.js +14 -0
- package/assets/PhTrash-acb3ad59.js +14 -0
- package/assets/PhUser-92aa32ba.js +14 -0
- package/assets/PhVault-ed94ef20.js +14 -0
- package/assets/PhWarning-b2396b99.js +14 -0
- package/assets/PhWarningCircle-0f363973.js +14 -0
- package/assets/PhX-522d79dd.js +14 -0
- package/assets/basic-eeeaaaeb.js +1435 -0
- package/assets/core-84b3ed1e.js +254 -0
- package/assets/features-21cad012.js +5 -0
- package/assets/{fortmatic-38f79735.js → fortmatic-f30106eb.js} +1 -1
- package/assets/{index-5fe88343.js → index-04415554.js} +1 -1
- package/assets/index-069f2f19.js +40 -0
- package/assets/index-388893ce.js +1321 -0
- package/assets/index-516a1ffc.js +26 -0
- package/assets/{index-9c03b9eb.css → index-91d98a83.css} +7 -7
- package/assets/{index-d9a3300d.js → index-be0620a9.js} +1 -1
- package/assets/{index-db35fe51.js → index-cf405d3f.js} +1 -1
- package/assets/index-ec27bc27.js +7 -0
- package/assets/{index-1e0cfb06.js → index-fec77d48.js} +136 -130
- package/assets/native-bf1092f7.js +1 -0
- package/assets/property-70d704fc.js +27 -0
- package/assets/w3m-modal-4a2f6c0b.js +1209 -0
- package/index.html +4 -4
- package/package.json +3 -3
- package/assets/add-423b3765.js +0 -15
- package/assets/all-wallets-6318b594.js +0 -6
- package/assets/app-store-c30317c0.js +0 -17
- package/assets/apple-248aca7f.js +0 -18
- package/assets/arrow-bottom-99c2809a.js +0 -8
- package/assets/arrow-bottom-circle-52aa2a11.js +0 -11
- package/assets/arrow-left-69c01e2b.js +0 -8
- package/assets/arrow-right-1c1b5b19.js +0 -8
- package/assets/arrow-top-741c53b5.js +0 -8
- package/assets/bank-24f6d02d.js +0 -14
- package/assets/basic-9dc8174a.js +0 -2128
- package/assets/browser-95dd5a39.js +0 -14
- package/assets/card-2db2dba3.js +0 -14
- package/assets/checkmark-b219f135.js +0 -11
- package/assets/checkmark-bold-25fa686a.js +0 -8
- package/assets/chevron-bottom-f075ffbd.js +0 -8
- package/assets/chevron-left-71e407e9.js +0 -8
- package/assets/chevron-right-6189a026.js +0 -8
- package/assets/chevron-top-3b0f639b.js +0 -8
- package/assets/chrome-store-bcf03a9a.js +0 -61
- package/assets/clock-ccbbd268.js +0 -8
- package/assets/close-7a27f645.js +0 -8
- package/assets/coinPlaceholder-ae5a3855.js +0 -8
- package/assets/compass-313e8cfe.js +0 -8
- package/assets/copy-12ca4475.js +0 -15
- package/assets/core-10800243.js +0 -910
- package/assets/cursor-07342d1b.js +0 -3
- package/assets/cursor-transparent-4c6027d5.js +0 -12
- package/assets/desktop-739920a7.js +0 -9
- package/assets/disconnect-4c3a444c.js +0 -8
- package/assets/discord-15059aa1.js +0 -17
- package/assets/etherscan-94f3dd64.js +0 -6
- package/assets/exclamation-triangle-2f387115.js +0 -4
- package/assets/extension-9d4a1b73.js +0 -8
- package/assets/external-link-a8b07c98.js +0 -8
- package/assets/facebook-55d423f7.js +0 -26
- package/assets/farcaster-dd4a3e14.js +0 -12
- package/assets/filters-602ee0e2.js +0 -8
- package/assets/github-bec58e5b.js +0 -18
- package/assets/google-98d84a2c.js +0 -18
- package/assets/help-circle-ef60da9e.js +0 -12
- package/assets/id-d31bfc51.js +0 -12
- package/assets/image-fb1f3e63.js +0 -4
- package/assets/index-376d9ca5.js +0 -394
- package/assets/index-4c3c4c35.js +0 -7
- package/assets/index.es-63034a59.js +0 -26
- package/assets/info-8e7d9734.js +0 -3
- package/assets/info-circle-beb255df.js +0 -12
- package/assets/lightbulb-9b5bc46f.js +0 -3
- package/assets/mail-a8cb5474.js +0 -8
- package/assets/mobile-830dba07.js +0 -9
- package/assets/more-94154d68.js +0 -11
- package/assets/network-placeholder-feda2a74.js +0 -14
- package/assets/nftPlaceholder-3500f4ec.js +0 -8
- package/assets/off-514e4de1.js +0 -8
- package/assets/play-store-2e9bbeb8.js +0 -32
- package/assets/plus-a33257e8.js +0 -13
- package/assets/qr-code-2dd8cc67.js +0 -6
- package/assets/recycle-horizontal-1cac807c.js +0 -9
- package/assets/refresh-1a3f6cce.js +0 -8
- package/assets/reown-logo-f43b0e23.js +0 -12
- package/assets/search-3bd8cbcb.js +0 -8
- package/assets/secp256k1-68a098fa.js +0 -1
- package/assets/secp256k1-bb840cb1.js +0 -1
- package/assets/send-10d3ed06.js +0 -15
- package/assets/swapHorizontal-5baadf98.js +0 -8
- package/assets/swapHorizontalBold-f2a3ad00.js +0 -8
- package/assets/swapHorizontalMedium-cf44b565.js +0 -16
- package/assets/swapHorizontalRoundedBold-342fa240.js +0 -8
- package/assets/swapVertical-178d166c.js +0 -8
- package/assets/telegram-795f2864.js +0 -16
- package/assets/three-dots-0198b4c0.js +0 -5
- package/assets/twitch-27573001.js +0 -18
- package/assets/twitterIcon-cb8f65cb.js +0 -6
- package/assets/verify-37b11cb7.js +0 -8
- package/assets/verify-filled-f1000698.js +0 -8
- package/assets/w3m-modal-22f5aa95.js +0 -642
- package/assets/wallet-97c0e814.js +0 -8
- package/assets/wallet-placeholder-24cab014.js +0 -14
- package/assets/walletconnect-63e804b2.js +0 -30
- package/assets/warning-circle-d5eaf6d9.js +0 -12
- package/assets/x-44f57cce.js +0 -12
package/assets/core-10800243.js
DELETED
|
@@ -1,910 +0,0 @@
|
|
|
1
|
-
import{p as Ns,h as ni,B as Ve,a as Q,_ as ia,e as or,N as Wa}from"./index-1e0cfb06.js";import{d as An,s as za,c as jh,g as pc,a as qh,b as Wh,k as zh,e as Hh,f as Qn,I as Xr,h as fc,i as Kh,j as D,l as Lr,m as Du,n as Lu,o as Vh,p as Gh,q as na,C as Jh,E as nt,y as At,r as hn,A as Mu,t as Yh,O as Ha,u as Rt,v as Xh,w as Ka,x as Va,z as lo,B as Zr,D as Ks,P as gc,Q as Zh,F as Qh,G as Tr,H as Bu,J as cs,K as Jt,L as fs,M as Wt}from"./index.es-63034a59.js";const F={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 Ns<"u"&&typeof{}<"u"?{}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},Fu={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=F.CHAIN_NAME_MAP)==null?void 0:i[r])||void 0}},ep={bigNumber(t){return t?new ni(t):new ni(0)},multiply(t,e){if(t===void 0||e===void 0)return new ni(0);const s=new ni(t),r=new ni(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,""))}},tp=[{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"}]}],sp=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],rp=[{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"}]}],ip={getERC20Abi:t=>F.USDT_CONTRACT_ADDRESSES.includes(t)?rp:tp,getSwapAbi:()=>sp},gs={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}}},te={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function 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){wi()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(wi())return localStorage.getItem(t)||void 0},removeItem(t){wi()&&localStorage.removeItem(t)},clear(){wi()&&localStorage.clear()}};function wi(){return typeof window<"u"&&typeof localStorage<"u"}function As(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 np=Symbol(),mc=Object.getPrototypeOf,oa=new WeakMap,op=t=>t&&(oa.has(t)?oa.get(t):mc(t)===Object.prototype||mc(t)===Array.prototype),ap=t=>op(t)&&t[np]||null,wc=(t,e=!0)=>{oa.set(t,e)},Co=t=>typeof t=="object"&&t!==null,vs=new WeakMap,yi=new WeakSet,cp=(t=Object.is,e=(l,u)=>new Proxy(l,u),s=l=>Co(l)&&!yi.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,d=r)=>{const h=i.get(l);if((h==null?void 0:h[0])===u)return h[1];const p=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return wc(p,!0),i.set(l,[u,p]),Reflect.ownKeys(l).forEach(g=>{if(Object.getOwnPropertyDescriptor(p,g))return;const m=Reflect.get(l,g),{enumerable:w}=Reflect.getOwnPropertyDescriptor(l,g),y={value:m,enumerable:w,configurable:!0};if(yi.has(m))wc(m,!1);else if(m instanceof Promise)delete y.value,y.get=()=>d(m);else if(vs.has(m)){const[b,v]=vs.get(m);y.value=n(b,v(),d)}Object.defineProperty(p,g,y)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],c=l=>{if(!Co(l))throw new Error("object required");const u=o.get(l);if(u)return u;let d=a[0];const h=new Set,p=(E,k=++a[0])=>{d!==k&&(d=k,h.forEach(C=>C(E,k)))};let g=a[1];const m=(E=++a[1])=>(g!==E&&!h.size&&(g=E,y.forEach(([k])=>{const C=k[1](E);C>d&&(d=C)})),d),w=E=>(k,C)=>{const L=[...k];L[1]=[E,...L[1]],p(L,C)},y=new Map,b=(E,k)=>{if(h.size){const C=k[3](w(E));y.set(E,[k,C])}else y.set(E,[k])},v=E=>{var k;const C=y.get(E);C&&(y.delete(E),(k=C[1])==null||k.call(C))},I=E=>(h.add(E),h.size===1&&y.forEach(([C,L],H)=>{const N=C[3](w(H));y.set(H,[C,N])}),()=>{h.delete(E),h.size===0&&y.forEach(([C,L],H)=>{L&&(L(),y.set(H,[C]))})}),S=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),_=e(S,{deleteProperty(E,k){const C=Reflect.get(E,k);v(k);const L=Reflect.deleteProperty(E,k);return L&&p(["delete",[k],C]),L},set(E,k,C,L){const H=Reflect.has(E,k),N=Reflect.get(E,k,L);if(H&&(t(N,C)||o.has(C)&&t(N,o.get(C))))return!0;v(k),Co(C)&&(C=ap(C)||C);let x=C;if(C instanceof Promise)C.then(O=>{C.status="fulfilled",C.value=O,p(["resolve",[k],O])}).catch(O=>{C.status="rejected",C.reason=O,p(["reject",[k],O])});else{!vs.has(C)&&s(C)&&(x=c(C));const O=!yi.has(x)&&vs.get(x);O&&b(k,O)}return Reflect.set(E,k,x,L),p(["set",[k],C,N]),!0}});o.set(l,_);const R=[S,m,n,I];return vs.set(_,R),Reflect.ownKeys(l).forEach(E=>{const k=Object.getOwnPropertyDescriptor(l,E);"value"in k&&(_[E]=l[E],delete k.value,delete k.writable),Object.defineProperty(S,E,k)}),_})=>[c,vs,yi,t,e,s,r,i,n,o,a],[lp]=cp();function Ne(t={}){return lp(t)}function tt(t,e,s){const r=vs.get(t);let i;const n=[],o=r[3];let a=!1;const l=o(u=>{if(n.push(u),s){e(n.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Ui(t,e){const s=vs.get(t),[r,i,n]=s;return n(r,i(),e)}function er(t){return yi.add(t),t}function st(t,e,s,r){let i=t[e];return tt(t,()=>{const n=t[e];Object.is(i,n)||s(i=n)},r)}function up(t){const e=Ne({data:Array.from(t||[]),has(s){return this.data.some(r=>r[0]===s)},set(s,r){const i=this.data.find(n=>n[0]===s);return i?i[1]=r:this.data.push([s,r]),this},get(s){var r;return(r=this.data.find(i=>i[0]===s))==null?void 0:r[1]},delete(s){const r=this.data.findIndex(i=>i[0]===s);return r===-1?!1:(this.data.splice(r,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(s){this.data.forEach(r=>{s(r[1],r[0],this)})},keys(){return this.data.map(s=>s[0]).values()},values(){return this.data.map(s=>s[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const Io=(typeof Ns<"u"&&typeof{}<"u"?{}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",ju=[{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"]}],dp="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Ee={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:Io,SECURE_SITE_DASHBOARD:`${Io}/dashboard`,SECURE_SITE_FAVICON:`${Io}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},W={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=W.getActiveNamespace(),e=W.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,r=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:r}},setWalletConnectDeepLink({name:t,href:e}){try{Z.setItem(te.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Z.getItem(te.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Z.removeItem(te.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Z.setItem(te.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Z.setItem(te.ACTIVE_CAIP_NETWORK_ID,t),W.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return Z.getItem(te.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Z.removeItem(te.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=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(te.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Z.getItem(te.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const s=Eo(t);Z.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Z.getItem(te.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=Eo(t);return Z.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{Z.setItem(te.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Z.getItem(te.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Z.removeItem(te.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Z.getItem(te.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=Z.getItem(te.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{Z.setItem(te.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Z.getItem(te.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Z.getItem(te.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Z.setItem(te.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=W.getConnectedNamespaces();e.includes(t)||(e.push(t),W.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=W.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),W.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return Z.getItem(te.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Z.setItem(te.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Z.removeItem(te.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Z.getItem(te.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=W.getBalanceCache();Z.setItem(te.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=W.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;W.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=W.getBalanceCache();e[t.caipAddress]=t,Z.setItem(te.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Z.getItem(te.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=W.getBalanceCache();Z.setItem(te.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=W.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),W.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=W.getNativeBalanceCache();e[t.caipAddress]=t,Z.setItem(te.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Z.getItem(te.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=W.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;W.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=W.getEnsCache();e[t.address]=t,Z.setItem(te.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=W.getEnsCache();Z.setItem(te.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=Z.getItem(te.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=W.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;W.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=W.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},Z.setItem(te.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=W.getIdentityCache();Z.setItem(te.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Z.removeItem(te.PORTFOLIO_CACHE),Z.removeItem(te.NATIVE_BALANCE_CACHE),Z.removeItem(te.ENS_CACHE),Z.removeItem(te.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Z.setItem(te.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Z.getItem(te.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s={...W.getConnections(),[e]:t};Z.setItem(te.CONNECTIONS,JSON.stringify(s))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=Z.getItem(te.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},X={isMobile(){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()<=Ee.TEN_SEC_MS:!0},isAllowedRetry(t,e=Ee.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()+Ee.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 F.W3M_API_URL},getBlockchainApiUrl(){return F.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return F.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?Ee.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 F.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const i="provider_authorization_url=",n=t.substring(t.indexOf(i)+i.length),o=this.injectIntoUrl(decodeURIComponent(n),s,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const r=t.indexOf(e);if(r===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",r),n=e.length,o=i!==-1?i:t.length,a=t.substring(0,r+n),c=t.substring(r+n,o),l=t.substring(i),u=c+s;return a+u+l}};async function oi(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class pn{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:r,...i}){const n=this.createUrl(i);return(await oi(n,{method:"GET",headers:e,signal:s,cache:r})).json()}async getBlob({headers:e,signal:s,...r}){const i=this.createUrl(r);return(await oi(i,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await oi(n,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await oi(n,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:s,signal:r,...i}){const n=this.createUrl(i);return(await oi(n,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:s}){const r=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([i,n])=>{n&&r.searchParams.append(i,n)}),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}const hp={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Ee.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=Ne({features:Ee.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ee.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),T={state:V,subscribeKey(t,e){return st(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=hp.filterSocialsByPlatform(V.remoteFeatures.socials))},setFeatures(t){if(!t)return;V.features||(V.features=Ee.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 Ui(V)}},pp=Object.freeze({enabled:!0,events:[]}),fp=new pn({baseUrl:X.getAnalyticsUrl(),clientId:null}),gp=5,mp=60*1e3,ms=Ne({...pp}),wp={state:ms,subscribeKey(t,e){return st(ms,t,e)},async sendError(t,e){if(!ms.enabled)return;const s=Date.now();if(ms.events.filter(n=>{const o=new Date(n.properties.timestamp||"").getTime();return s-o<mp}).length>=gp)return;const i={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};ms.events.push(i);try{if(typeof window>"u")return;const{projectId:n,sdkType:o,sdkVersion:a}=T.state;await fp.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(){ms.enabled=!0},disable(){ms.enabled=!1},clearEvents(){ms.events=[]}};class Mr extends Error{constructor(e,s,r){super(e),this.name="AppKitError",this.category=s,this.originalError=r,Object.setPrototypeOf(this,Mr.prototype);let i=!1;if(r instanceof Error&&typeof r.stack=="string"&&r.stack){const n=r.stack,o=n.indexOf(`
|
|
2
|
-
`);if(o>-1){const a=n.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
3
|
-
${a}`,i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,Mr):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function yc(t,e){const s=t instanceof Mr?t:new Mr(t instanceof Error?t.message:String(t),e,t);throw wp.sendError(s,s.category),s}function _t(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 yc(a,e)}}:n=(...o)=>{try{return i(...o)}catch(a){return yc(a,e)}},s[r]=n}else s[r]=i}),s}const Yt={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},yp={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,r=encodeURIComponent(s);if(t===Yt.PHANTOM.id&&!("phantom"in window)){const i=s.startsWith("https")?"https":"http",n=s.split("/")[2],o=encodeURIComponent(`${i}://${n}`);window.location.href=`${Yt.PHANTOM.url}/ul/browse/${r}?ref=${o}`}t===Yt.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${Yt.SOLFLARE.url}/ul/v1/browse/${r}?ref=${r}`),e===F.CHAIN.SOLANA&&t===Yt.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${Yt.COINBASE.url}/dapp?cb_url=${r}`)}},mt=Ne({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),bp={state:mt,subscribeNetworkImages(t){return tt(mt.networkImages,()=>t(mt.networkImages))},subscribeKey(t,e){return st(mt,t,e)},subscribe(t){return tt(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}},Ft=_t(bp),vp={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},Ao=Ne({networkImagePromises:{}}),qu={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||(Ao.networkImagePromises[t]||(Ao.networkImagePromises[t]=K._fetchNetworkImage(t)),await Ao.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Ft.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 Ft.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 Ft.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Ft.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Ft.state.connectorImages[t.imageId]},getChainImage(t){return Ft.state.networkImages[vp[t]]}},ws=Ne({message:"",variant:"info",open:!1}),Ep={state:ws,subscribeKey(t,e){return st(ws,t,e)},open(t,e){const{debug:s}=T.state,{shortMessage:r,longMessage:i}=t;s&&(ws.message=r,ws.variant=e,ws.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){ws.open=!1,ws.message="",ws.variant="info"}},qs=_t(Ep),Cp=X.getAnalyticsUrl(),Ip=new pn({baseUrl:Cp,clientId:null}),Ap=["MODAL_CREATED"],is=Ne({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),Pe={state:is,subscribe(t){return tt(is,()=>t(is))},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=z.state.address;if(Ap.includes(t.data.event)||typeof window>"u")return;await Ip.post({path:"/e",params:Pe.getSdkProperties(),body:{eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),is.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===F.HTTP_STATUS_CODES.FORBIDDEN&&!is.reportedErrors.FORBIDDEN&&(qs.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${wi()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),is.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;is.timestamp=Date.now(),is.data=t,(e=T.state.features)!=null&&e.analytics&&Pe._sendAnalyticsEvent(is)}},_p=X.getApiUrl(),ot=new pn({baseUrl:_p,clientId:null}),Np=40,bc=4,Sp=20,se=Ne({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),K={state:se,subscribeKey(t,e){return st(se,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=`${ot.baseUrl}/getWalletImage/${t}`,s=await ot.getBlob({path:e,params:K._getSdkProperties()});Ft.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${ot.baseUrl}/public/getAssetImage/${t}`,s=await ot.getBlob({path:e,params:K._getSdkProperties()});Ft.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${ot.baseUrl}/public/getAssetImage/${t}`,s=await ot.getBlob({path:e,params:K._getSdkProperties()});Ft.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${ot.baseUrl}/public/getCurrencyImage/${t}`,s=await ot.getBlob({path:e,params:K._getSdkProperties()});Ft.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${ot.baseUrl}/public/getTokenImage/${t}`,s=await ot.getBlob({path:e,params:K._getSdkProperties()});Ft.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){return X.isMobile()?t==null?void 0:t.filter(s=>s.mobile_link||s.id===Yt.COINBASE.id?!0:f.state.activeChain==="solana"&&(s.id===Yt.SOLFLARE.id||s.id===Yt.PHANTOM.id)):t},async fetchProjectConfig(){return(await ot.get({path:"/appkit/v1/config",params:K._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await ot.get({path:"/projects/v1/origins",params:K._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=f.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!qu.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>K._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=j.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(Yt).map(o=>o.id));const r=await ot.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)??bc,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))),se.featured=r,se.allFeatured=r}},async fetchRecommendedWallets(){try{se.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=T.state,r=[...e??[],...s??[]].filter(Boolean),i=f.getRequestedCaipNetworkIds().join(","),n={page:1,entries:bc,include:t,exclude:r,chains:i},{data:o,count:a}=await K.fetchWallets(n),c=W.getRecentWallets(),l=o.map(d=>d.image_id).filter(Boolean),u=c.map(d=>d.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(d=>K._fetchWalletImage(d))),se.recommended=o,se.allRecommended=o,se.count=a??0}catch{}finally{se.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:r}=T.state,i=f.getRequestedCaipNetworkIds().join(","),n=[...se.recommended.map(({id:u})=>u),...s??[],...r??[]].filter(Boolean),o={page:t,entries:Np,include:e,exclude:n,chains:i},{data:a,count:c}=await K.fetchWallets(o),l=a.slice(0,Sp).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>K._fetchWalletImage(u))),se.wallets=X.uniqueBy([...se.wallets,...K._filterOutExtensions(a)],"id").filter(u=>{var d;return(d=u.chains)==null?void 0:d.some(h=>i.includes(h))}),se.count=c>se.count?c:se.count,se.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await K.fetchWallets(e);s&&s.forEach(r=>{se.excludedWallets.push({rdns:r.rdns,name:r.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:r}=T.state,i=f.getRequestedCaipNetworkIds().join(",");se.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);Pe.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)]),se.search=K._filterOutExtensions(o)},initPromise(t,e){const s=se.promises[t];return s||(se.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:r=!0}={}){const i=[t&&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 ot.get({path:"/getAnalyticsConfig",params:K._getSdkProperties()});T.setFeatures({analytics:t})}catch{T.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){se.featured=se.allFeatured,se.recommended=se.allRecommended;return}const e=f.getRequestedCaipNetworkIds().join(",");se.featured=se.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),se.recommended=se.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),se.filteredWallets=se.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})},clearFilterByNamespaces(){se.filteredWallets=[]},setFilterByNamespace(t){if(!t){se.featured=se.allFeatured,se.recommended=se.allRecommended;return}const e=f.getRequestedCaipNetworkIds().join(",");se.featured=se.allFeatured.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),se.recommended=se.allRecommended.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))}),se.filteredWallets=se.wallets.filter(s=>{var r;return(r=s.chains)==null?void 0:r.some(i=>e.includes(i))})}},me=Ne({view:"Connect",history:["Connect"],transactionStack:[]}),Pp={state:me,subscribeKey(t,e){return st(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(),ie.goBack();break;case"cancel":i==null||i(),ie.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=f.state.activeCaipAddress,e=ie.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 He.close();(r=me.data)!=null&&r.wallet&&(me.data.wallet=void 0),setTimeout(()=>{var i,n,o;if(s){z.setFarcasterUrl(void 0,f.state.activeChain);const a=j.getAuthConnector();(i=a==null?void 0:a.provider)==null||i.reload();const c=Ui(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(){ie.state.history.length>1?ie.goBack():He.close()}},ie=_t(Pp),ns=Ne({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),aa={state:ns,subscribe(t){return tt(ns,()=>t(ns))},setThemeMode(t){ns.themeMode=t;try{const e=j.getAuthConnector();if(e){const s=aa.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:As(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){ns.themeVariables={...ns.themeVariables,...t};try{const e=j.getAuthConnector();if(e){const s=aa.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:As(ns.themeVariables,ns.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Ui(ns)}},bt=_t(aa),Wu={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ce=Ne({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Wu},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),Op={state:ce,subscribe(t){return tt(ce,()=>{t(ce)})},subscribeKey(t,e){return st(ce,t,e)},initialize(t){t.forEach(e=>{const s=W.getConnectedConnectorId(e);s&&j.setConnectorId(s,e)})},setActiveConnector(t){t&&(ce.activeConnector=er(t))},setConnectors(t){t.filter(i=>!ce.allConnectors.some(n=>n.id===i.id&&j.getConnectorName(n.name)===j.getConnectorName(i.name)&&n.chain===i.chain)).forEach(i=>{i.type!=="MULTI_CHAIN"&&ce.allConnectors.push(er(i))});const s=j.getEnabledNamespaces(),r=j.getEnabledConnectors(s);ce.connectors=j.mergeMultiChainConnectors(r)},filterByNamespaces(t){Object.keys(ce.filterByNamespaceMap).forEach(e=>{ce.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ce.filterByNamespaceMap[e]=!0}),j.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ce.filterByNamespaceMap[t]=e,j.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=j.getEnabledNamespaces(),e=j.getEnabledConnectors(t),s=j.areAllNamespacesEnabled();ce.connectors=j.mergeMultiChainConnectors(e),s?K.clearFilterByNamespaces():K.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ce.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ce.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ce.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=j.generateConnectorMapByName(t),s=[];return e.forEach(r=>{const i=r[0],n=(i==null?void 0:i.id)===F.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=j.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===F.CONNECTOR_ID.AUTH){const i=t,n=Ui(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:As(a,o)}),j.setConnectors([t])}else j.setConnectors([t])},getAuthConnector(t){var r;const e=t||f.state.activeChain,s=ce.connectors.find(i=>i.id===F.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 ce.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return ce.allConnectors.find(e=>e.id===t)},getConnector(t,e){return ce.allConnectors.filter(r=>r.chain===f.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=Ui(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:As(i,r)})},getConnectorsByNamespace(t){const e=ce.allConnectors.filter(s=>s.chain===t);return j.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=j.getConnector(t.id,t.rdns),s=f.state.activeChain;yp.handleMobileDeeplinkRedirect((e==null?void 0:e.explorerId)||t.id,s),e?ie.push("ConnectingExternal",{connector:e}):ie.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?j.getConnectorsByNamespace(t):j.mergeMultiChainConnectors(ce.allConnectors)},setFilterByNamespace(t){ce.filterByNamespace=t,ce.connectors=j.getConnectors(t),K.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ce.activeConnectorIds={...ce.activeConnectorIds,[e]:t},W.setConnectedConnectorId(e,t))},removeConnectorId(t){ce.activeConnectorIds={...ce.activeConnectorIds,[t]:void 0},W.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ce.activeConnectorIds[t]},isConnected(t){return t?!!ce.activeConnectorIds[t]:Object.values(ce.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ce.activeConnectorIds={...Wu}}},j=_t(Op),Ii={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"}},Fs=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Ue=Ne({...Fs}),Tp={state:Ue,subscribeKey(t,e){return st(Ue,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(){Ue.message=Fs.message,Ue.variant=Fs.variant,Ue.svg=Fs.svg,Ue.open=Fs.open,Ue.autoClose=Fs.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:r=Fs.autoClose}){Ue.open?(Ue.open=!1,setTimeout(()=>{Ue.message=t,Ue.variant=s,Ue.svg=e,Ue.open=!0,Ue.autoClose=r},150)):(Ue.message=t,Ue.variant=s,Ue.svg=e,Ue.open=!0,Ue.autoClose=r)}},jt=Tp,Ie=Ne({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),xp={state:Ie,subscribe(t){return tt(Ie,()=>t(Ie))},setLastNetworkInView(t){Ie.lastNetworkInView=t},async fetchTransactions(t,e){var s,r;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Ie.loading=!0;try{const i=await J.fetchTransactions({account:t,cursor:Ie.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(s=f.state.activeCaipNetwork)==null?void 0:s.caipNetworkId}),n=bi.filterSpamTransactions(i.data),o=bi.filterByConnectedChain(n),a=[...Ie.transactions,...o];Ie.loading=!1,e==="coinbase"?Ie.coinbaseTransactions=bi.groupTransactionsByYearAndMonth(Ie.coinbaseTransactions,i.data):(Ie.transactions=a,Ie.transactionsByYear=bi.groupTransactionsByYearAndMonth(Ie.transactionsByYear,o)),Ie.empty=a.length===0,Ie.next=i.next?i.next:void 0}catch{const n=f.state.activeChain;Pe.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:T.state.projectId,cursor:Ie.next,isSmartAccount:((r=z.state.preferredAccountTypes)==null?void 0:r[n])===Ii.ACCOUNT_TYPES.SMART_ACCOUNT}}),jt.showError("Failed to fetch transactions"),Ie.loading=!1,Ie.empty=!0,Ie.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=f.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){Ie.next=void 0},resetTransactions(){Ie.transactions=[],Ie.transactionsByYear={},Ie.lastNetworkInView=void 0,Ie.loading=!1,Ie.empty=!1,Ie.next=void 0}},bi=_t(xp,"API_ERROR"),ye=Ne({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let Ds;const $p={state:ye,subscribeKey(t,e){return st(ye,t,e)},_getClient(){return ye._client},setClient(t){ye._client=er(t)},async connectWalletConnect(){var t,e,s,r;if(X.isTelegram()||X.isSafari()&&X.isIos()){if(Ds){await Ds,Ds=void 0;return}if(!X.isPairingExpired(ye==null?void 0:ye.wcPairingExpiry)){const i=ye.wcUri;ye.wcUri=i;return}Ds=(e=(t=Y._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),Y.state.status="connecting",await Ds,Ds=void 0,ye.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&&f.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||f.state.activeChain;e&&j.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var r;He.setLoading(!0,f.state.activeChain);const s=j.getAuthConnector();s&&(z.setPreferredAccountType(t,e),await s.provider.setPreferredAccount(t),W.setPreferredAccountTypes(z.state.preferredAccountTypes??{[e]:t}),await Y.reconnectExternal(s),He.setLoading(!1,f.state.activeChain),Pe.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((r=f.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(){ye.wcUri=void 0,ye.wcPairingExpiry=void 0,ye.wcLinking=void 0,ye.recentWallet=void 0,ye.status="disconnected",bi.resetTransactions(),W.deleteWalletConnectDeepLink()},resetUri(){ye.wcUri=void 0,ye.wcPairingExpiry=void 0,Ds=void 0},finalizeWcConnection(){var s,r;const{wcLinking:t,recentWallet:e}=Y.state;t&&W.setWalletConnectDeepLink(t),e&&W.setAppKitRecent(e),Pe.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((r=(s=ie.state.data)==null?void 0:s.wallet)==null?void 0:r.name)||"Unknown"}})},setWcBasic(t){ye.wcBasic=t},setUri(t){ye.wcUri=t,ye.wcPairingExpiry=X.getPairingExpiry()},setWcLinking(t){ye.wcLinking=t},setWcError(t){ye.wcError=t,ye.buffering=!1},setRecentWallet(t){ye.recentWallet=t},setBuffering(t){ye.buffering=t},setStatus(t){ye.status=t},async disconnect(t){var e;try{await((e=Y._getClient())==null?void 0:e.disconnect(t))}catch(s){throw new Mr("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){ye.connections.set(e,t)},switchAccount({connection:t,address:e,namespace:s}){if(j.state.activeConnectorIds[s]===t.connectorId){const n=f.state.activeCaipNetwork;if(n){const o=`${s}:${n.id}:${e}`;z.setCaipAddress(o,s)}else console.warn(`No current network found for namespace "${s}"`)}else{const n=j.getConnector(t.connectorId);n?Y.connectExternal(n,s):console.warn(`No connector found for namespace "${s}"`)}}},Y=_t($p),lr=Ne({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Ss={state:lr,subscribe(t){return tt(lr,()=>t(lr))},subscribeOpen(t){return st(lr,"open",t)},set(t){Object.assign(lr,{...lr,...t})}};function kp(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function vc(t){return kp(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const zu="2.31.6";let ai={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${zu}`},es=class ca extends Error{constructor(e,s={}){var a;const r=(()=>{var c;return s.cause instanceof ca?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),i=(()=>s.cause instanceof ca&&s.cause.docsPath||s.docsPath)(),n=(a=ai.getDocsUrl)==null?void 0:a.call(ai,{...s,docsPath:i}),o=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...r?[`Details: ${r}`]:[],...ai.version?[`Version: ${ai.version}`]:[]].join(`
|
|
4
|
-
`);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=zu}walk(e){return Hu(this,e)}};function Hu(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Hu(t.cause,e):e?null:t}let Ku=class extends es{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 Ga(t,{dir:e,size:s=32}={}){return typeof t=="string"?Rp(t,{dir:e,size:s}):Up(t,{dir:e,size:s})}function Rp(t,{dir:e,size:s=32}={}){if(s===null)return t;const r=t.replace("0x","");if(r.length>s*2)throw new Ku({size:Math.ceil(r.length/2),targetSize:s,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Up(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Ku({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}let Dp=class extends es{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"})}},Lp=class extends es{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Vu(t,{size:e}){if(vc(t)>e)throw new Lp({givenSize:vc(t),maxSize:e})}const Mp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ec(t,e={}){return typeof t=="number"||typeof t=="bigint"?Fp(t,e):typeof t=="string"?Ju(t,e):typeof t=="boolean"?Bp(t,e):Gu(t,e)}function Bp(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(Vu(s,{size:e.size}),Ga(s,{size:e.size})):s}function Gu(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=Mp[t[i]];const r=`0x${s}`;return typeof e.size=="number"?(Vu(r,{size:e.size}),Ga(r,{dir:"right",size:e.size})):r}function Fp(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 Dp({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?Ga(a,{size:r}):a}const jp=new TextEncoder;function Ju(t,e={}){const s=jp.encode(t);return Gu(s,e)}let qp=class 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 Ys=(t,e,s)=>JSON.stringify(t,(r,i)=>{const n=typeof i=="bigint"?i.toString():i;return typeof e=="function"?e(r,n):n},s);function Wp(t,e){let s=t.toString();const r=s.startsWith("-");r&&(s=s.slice(1)),s=s.padStart(e,"0");let[i,n]=[s.slice(0,s.length-e),s.slice(s.length-e)];return n=n.replace(/(0+)$/,""),`${r?"-":""}${i||"0"}${n?`.${n}`:""}`}const Ja=t=>t;class Ai extends es{constructor({body:e,cause:s,details:r,headers:i,status:n,url:o}){super("HTTP request failed.",{cause:s,details:r,metaMessages:[n&&`Status: ${n}`,`URL: ${Ja(o)}`,e&&`Request body: ${Ys(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=i,this.status=n,this.url=o}}class Yu extends es{constructor({body:e,error:s,url:r}){super("RPC Request failed.",{cause:s,details:s.message,metaMessages:[`URL: ${Ja(r)}`,`Request body: ${Ys(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=s.code,this.data=s.data}}class Cc extends es{constructor({body:e,url:s}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${Ja(s)}`,`Request body: ${Ys(e)}`],name:"TimeoutError"})}}const zp=-1;class gt extends es{constructor(e,{code:s,docsPath:r,metaMessages:i,name:n,shortMessage:o}){super(o,{cause:e,docsPath:r,metaMessages:i||(e==null?void 0:e.metaMessages),name:n||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n||e.name,this.code=e instanceof Yu?e.code:s??zp}}class Nt extends gt{constructor(e,s){super(e,s),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=s.data}}class Di extends gt{constructor(e){super(e,{code:Di.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Di,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Li extends gt{constructor(e){super(e,{code:Li.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Li,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Mi extends gt{constructor(e,{method:s}={}){super(e,{code:Mi.code,name:"MethodNotFoundRpcError",shortMessage:`The method${s?` "${s}"`:""} does not exist / is not available.`})}}Object.defineProperty(Mi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Bi extends gt{constructor(e){super(e,{code:Bi.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
|
|
5
|
-
`)})}}Object.defineProperty(Bi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Br extends gt{constructor(e){super(e,{code:Br.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(Br,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Fi extends gt{constructor(e){super(e,{code:Fi.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|
|
6
|
-
`)})}}Object.defineProperty(Fi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ji extends gt{constructor(e){super(e,{code:ji.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ji,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class qi extends gt{constructor(e){super(e,{code:qi.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(qi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Fr extends gt{constructor(e){super(e,{code:Fr.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(Fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Vs extends gt{constructor(e,{method:s}={}){super(e,{code:Vs.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${s?` "${s}"`:""} is not supported.`})}}Object.defineProperty(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class jr extends gt{constructor(e){super(e,{code:jr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(jr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Wi extends gt{constructor(e){super(e,{code:Wi.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Wi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Xs extends Nt{constructor(e){super(e,{code:Xs.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(Xs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class zi extends Nt{constructor(e){super(e,{code:zi.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(zi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Hi extends Nt{constructor(e,{method:s}={}){super(e,{code:Hi.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${s?` " ${s}"`:""}.`})}}Object.defineProperty(Hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Ki extends Nt{constructor(e){super(e,{code:Ki.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(Ki,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Vi extends Nt{constructor(e){super(e,{code:Vi.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Vi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Gi extends Nt{constructor(e){super(e,{code:Gi.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Ji extends Nt{constructor(e){super(e,{code:Ji.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Ji,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Yi extends Nt{constructor(e){super(e,{code:Yi.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Yi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Xi extends Nt{constructor(e){super(e,{code:Xi.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Xi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Zi extends Nt{constructor(e){super(e,{code:Zi.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Zi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Qi extends Nt{constructor(e){super(e,{code:Qi.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Qi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class en extends Nt{constructor(e){super(e,{code:en.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(en,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class tn extends Nt{constructor(e){super(e,{code:tn.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Hp extends gt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}class Ya extends es{constructor({cause:e,message:s}={}){var i;const r=(i=s==null?void 0:s.replace("execution reverted: ",""))==null?void 0:i.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ya,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});function Kp(){let t=()=>{},e=()=>{};return{promise:new Promise((r,i)=>{t=r,e=i}),resolve:t,reject:e}}const _o=new Map;function Vp({fn:t,id:e,shouldSplitBatch:s,wait:r=0,sort:i}){const n=async()=>{const u=c();o();const d=u.map(({args:h})=>h);d.length!==0&&t(d).then(h=>{i&&Array.isArray(h)&&h.sort(i);for(let p=0;p<u.length;p++){const{resolve:g}=u[p];g==null||g([h[p],h])}}).catch(h=>{for(let p=0;p<u.length;p++){const{reject:g}=u[p];g==null||g(h)}})},o=()=>_o.delete(e),a=()=>c().map(({args:u})=>u),c=()=>_o.get(e)||[],l=u=>_o.set(e,[...c(),u]);return{flush:o,async schedule(u){const{promise:d,resolve:h,reject:p}=Kp();return(s==null?void 0:s([...a(),u]))&&n(),c().length>0?(l({args:u,resolve:h,reject:p}),d):(l({args:u,resolve:h,reject:p}),setTimeout(n,r),d)}}}async function Xu(t){return new Promise(e=>setTimeout(e,t))}const la=256;let _n=la,Nn;function Gp(t=11){if(!Nn||_n+t>la*2){Nn="",_n=0;for(let e=0;e<la;e++)Nn+=(256+Math.random()*256|0).toString(16).substring(1)}return Nn.substring(_n,_n+++t)}const Sn=new qp(8192);function Jp(t,{enabled:e=!0,id:s}){if(!e||!s)return t();if(Sn.get(s))return Sn.get(s);const r=t().finally(()=>Sn.delete(s));return Sn.set(s,r),r}function Yp(t,{delay:e=100,retryCount:s=2,shouldRetry:r=()=>!0}={}){return new Promise((i,n)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const u=typeof e=="function"?e({count:a,error:l}):e;u&&await Xu(u),o({count:a+1})};try{const l=await t();i(l)}catch(l){if(a<s&&await r({count:a,error:l}))return c({error:l});n(l)}};o()})}function Xp(t,e={}){return async(s,r={})=>{var d;const{dedupe:i=!1,methods:n,retryDelay:o=150,retryCount:a=3,uid:c}={...e,...r},{method:l}=s;if((d=n==null?void 0:n.exclude)!=null&&d.includes(l))throw new Vs(new Error("method not supported"),{method:l});if(n!=null&&n.include&&!n.include.includes(l))throw new Vs(new Error("method not supported"),{method:l});const u=i?Ju(`${c}.${Ys(s)}`):void 0;return Jp(()=>Yp(async()=>{try{return await t(s)}catch(h){const p=h;switch(p.code){case Di.code:throw new Di(p);case Li.code:throw new Li(p);case Mi.code:throw new Mi(p,{method:s.method});case Bi.code:throw new Bi(p);case Br.code:throw new Br(p);case Fi.code:throw new Fi(p);case ji.code:throw new ji(p);case qi.code:throw new qi(p);case Fr.code:throw new Fr(p);case Vs.code:throw new Vs(p,{method:s.method});case jr.code:throw new jr(p);case Wi.code:throw new Wi(p);case Xs.code:throw new Xs(p);case zi.code:throw new zi(p);case Hi.code:throw new Hi(p);case Ki.code:throw new Ki(p);case Vi.code:throw new Vi(p);case Gi.code:throw new Gi(p);case Ji.code:throw new Ji(p);case Yi.code:throw new Yi(p);case Xi.code:throw new Xi(p);case Zi.code:throw new Zi(p);case Qi.code:throw new Qi(p);case en.code:throw new en(p);case tn.code:throw new tn(p);case 5e3:throw new Xs(p);default:throw h instanceof es?h:new Hp(p)}}},{delay:({count:h,error:p})=>{var g;if(p&&p instanceof Ai){const m=(g=p==null?void 0:p.headers)==null?void 0:g.get("Retry-After");if(m!=null&&m.match(/\d/))return Number.parseInt(m)*1e3}return~~(1<<h)*o},retryCount:a,shouldRetry:({error:h})=>Zp(h)}),{enabled:i,id:u})}}function Zp(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===jr.code||t.code===Br.code:t instanceof Ai&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Zu({key:t,methods:e,name:s,request:r,retryCount:i=3,retryDelay:n=150,timeout:o,type:a},c){const l=Gp();return{config:{key:t,methods:e,name:s,request:r,retryCount:i,retryDelay:n,timeout:o,type:a},request:Xp(r,{methods:e,retryCount:i,retryDelay:n,uid:l}),value:c}}function Ic(t,e={}){const{key:s="fallback",name:r="Fallback",rank:i=!1,shouldThrow:n=Qp,retryCount:o,retryDelay:a}=e;return({chain:c,pollingInterval:l=4e3,timeout:u,...d})=>{let h=t,p=()=>{};const g=Zu({key:s,name:r,async request({method:m,params:w}){let y;const b=async(v=0)=>{const I=h[v]({...d,chain:c,retryCount:0,timeout:u});try{const S=await I.request({method:m,params:w});return p({method:m,params:w,response:S,transport:I,status:"success"}),S}catch(S){if(p({error:S,method:m,params:w,transport:I,status:"error"}),n(S)||v===h.length-1||(y??(y=h.slice(v+1).some(A=>{const{include:_,exclude:R}=A({chain:c}).config.methods||{};return _?_.includes(m):R?!R.includes(m):!0})),!y))throw S;return b(v+1)}};return b()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:m=>p=m,transports:h.map(m=>m({chain:c,retryCount:0}))});if(i){const m=typeof i=="object"?i:{};ef({chain:c,interval:m.interval??l,onTransports:w=>h=w,ping:m.ping,sampleCount:m.sampleCount,timeout:m.timeout,transports:h,weights:m.weights})}return g}}function Qp(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Fr.code||t.code===Xs.code||Ya.nodeMessage.test(t.message)||t.code===5e3))}function ef({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=[],d=async()=>{const h=await Promise.all(o.map(async m=>{const w=m({chain:t,retryCount:0,timeout:n}),y=Date.now();let b,v;try{await(r?r({transport:w}):w.request({method:"net_listening"})),v=1}catch{v=0}finally{b=Date.now()}return{latency:b-y,success:v}}));u.push(h),u.length>i&&u.shift();const p=Math.max(...u.map(m=>Math.max(...m.map(({latency:w})=>w)))),g=o.map((m,w)=>{const y=u.map(A=>A[w].latency),v=1-y.reduce((A,_)=>A+_,0)/y.length/p,I=u.map(A=>A[w].success),S=I.reduce((A,_)=>A+_,0)/I.length;return S===0?[0,w]:[l*v+c*S,w]}).sort((m,w)=>w[0]-m[0]);s(g.map(([,m])=>o[m])),await Xu(e),d()};d()}class tf extends es{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function sf(t,{errorInstance:e=new Error("timed out"),timeout:s,signal:r}){return new Promise((i,n)=>{(async()=>{let o;try{const a=new AbortController;s>0&&(o=setTimeout(()=>{r?a.abort():n(e)},s)),i(await t({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&n(e),n(a)}finally{clearTimeout(o)}})()})}function rf(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Ac=rf();function nf(t,e={}){return{async request(s){var d;const{body:r,onRequest:i=e.onRequest,onResponse:n=e.onResponse,timeout:o=e.timeout??1e4}=s,a={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:c,method:l,signal:u}=a;try{const h=await sf(async({signal:g})=>{const m={...a,body:Array.isArray(r)?Ys(r.map(v=>({jsonrpc:"2.0",id:v.id??Ac.take(),...v}))):Ys({jsonrpc:"2.0",id:r.id??Ac.take(),...r}),headers:{"Content-Type":"application/json",...c},method:l||"POST",signal:u||(o>0?g:null)},w=new Request(t,m),y=await(i==null?void 0:i(w,m))??{...m,url:t};return await fetch(y.url??t,y)},{errorInstance:new Cc({body:r,url:t}),timeout:o,signal:!0});n&&await n(h);let p;if((d=h.headers.get("Content-Type"))!=null&&d.startsWith("application/json"))p=await h.json();else{p=await h.text();try{p=JSON.parse(p||"{}")}catch(g){if(h.ok)throw g;p={error:p}}}if(!h.ok)throw new Ai({body:r,details:Ys(p.error)||h.statusText,headers:h.headers,status:h.status,url:t});return p}catch(h){throw h instanceof Ai||h instanceof Cc?h:new Ai({body:r,cause:h,url:t})}}}}function Pn(t,e={}){const{batch:s,fetchOptions:r,key:i="http",methods:n,name:o="HTTP JSON-RPC",onFetchRequest:a,onFetchResponse:c,retryDelay:l,raw:u}=e;return({chain:d,retryCount:h,timeout:p})=>{const{batchSize:g=1e3,wait:m=0}=typeof s=="object"?s:{},w=e.retryCount??h,y=p??e.timeout??1e4,b=t||(d==null?void 0:d.rpcUrls.default.http[0]);if(!b)throw new tf;const v=nf(b,{fetchOptions:r,onRequest:a,onResponse:c,timeout:y});return Zu({key:i,methods:n,name:o,async request({method:I,params:S}){const A={method:I,params:S},{schedule:_}=Vp({id:b,wait:m,shouldSplitBatch(C){return C.length>g},fn:C=>v.request({body:C}),sort:(C,L)=>C.id-L.id}),R=async C=>s?_(C):[await v.request({body:C})],[{error:E,result:k}]=await R(A);if(u)return{error:E,result:k};if(E)throw new Yu({body:A,error:E,url:b});return k},retryCount:w,retryDelay:l,timeout:y,type:"http"},{fetchOptions:r,url:b})}}const No={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 Wp(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"}},_c={async getMyTokensWithBalance(t){const e=z.state.address,s=f.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=No.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 No.isWalletGetAssetsResponse(o)?(o[i]||[]).map(c=>No.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:f.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},ge=Ne({tokenBalances:[],loading:!1}),of={state:ge,subscribe(t){return tt(ge,()=>t(ge))},subscribeKey(t,e){return st(ge,t,e)},setToken(t){t&&(ge.token=er(t))},setTokenAmount(t){ge.sendTokenAmount=t},setReceiverAddress(t){ge.receiverAddress=t},setReceiverProfileImageUrl(t){ge.receiverProfileImageUrl=t},setReceiverProfileName(t){ge.receiverProfileName=t},setNetworkBalanceInUsd(t){ge.networkBalanceInUSD=t},setLoading(t){ge.loading=t},async sendToken(){var t;try{switch(he.setLoading(!0),(t=f.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=f.state.activeChain,e=(s=z.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?(Pe.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ii.ACCOUNT_TYPES.SMART_ACCOUNT,token:he.state.token.address,amount:he.state.sendTokenAmount,network:((i=f.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})):(Pe.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Ii.ACCOUNT_TYPES.SMART_ACCOUNT,token:he.state.token.symbol||"",amount:he.state.sendTokenAmount,network:((n=f.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;ge.loading=!0;const e=(n=f.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=f.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=f.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(ge.lastRetry&&!X.isAllowedRetry(ge.lastRetry,30*Ee.ONE_SEC_MS))return ge.loading=!1,[];try{if(i&&e&&s){const a=await _c.getMyTokensWithBalance();return ge.tokenBalances=a,ge.lastRetry=void 0,a}}catch(a){ge.lastRetry=Date.now(),t==null||t(a),jt.showError("Token Balance Unavailable")}finally{ge.loading=!1}return[]},fetchNetworkBalance(){if(ge.tokenBalances.length===0)return;const t=_c.mapBalancesToSwapTokens(ge.tokenBalances);if(!t)return;const e=t.find(s=>s.address===f.getActiveNetworkTokenAddress());e&&(ge.networkBalanceInUSD=e?ep.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var n,o,a,c;ie.pushTransactionStack({});const e=t.receiverAddress,s=z.state.address,r=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),i="0x";await Y.sendTransaction({chainNamespace:"eip155",to:e,address:s,data:i,value:r??BigInt(0)}),Pe.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:((n=z.state.preferredAccountTypes)==null?void 0:n.eip155)===Ii.ACCOUNT_TYPES.SMART_ACCOUNT,token:((o=he.state.token)==null?void 0:o.symbol)||"",amount:t.sendTokenAmount,network:((a=f.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)||""}}),(c=Y._getClient())==null||c.updateBalance("eip155"),he.resetSend()},async sendERC20Token(t){ie.pushTransactionStack({onSuccess(){ie.replace("Account")}});const e=Y.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));if(z.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const s=X.getPlainAddress(t.tokenAddress);await Y.writeContract({fromAddress:z.state.address,tokenAddress:s,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:ip.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");ie.pushTransactionStack({onSuccess(){ie.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(){ge.token=void 0,ge.sendTokenAmount=void 0,ge.receiverAddress=void 0,ge.receiverProfileImageUrl=void 0,ge.receiverProfileName=void 0,ge.loading=!1,ge.tokenBalances=[]}},he=_t(of),So={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},On={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},M=Ne({chains:up(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),af={state:M,subscribe(t){return tt(M,()=>{t(M)})},subscribeKey(t,e){return st(M,t,e)},subscribeChainProp(t,e,s){let r;return tt(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,f.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),M.activeChain&&Ss.set({activeChain:a==null?void 0:a.namespace})),l.forEach(u=>{const d=e==null?void 0:e.filter(h=>h.chainNamespace===u);f.state.chains.set(u,{namespace:u,networkState:Ne({...On,caipNetwork:d==null?void 0:d[0]}),accountState:Ne(So),caipNetworks:d??[],...s}),f.setRequestedCaipNetworks(d??[],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&&f.setActiveCaipNetwork(i)}}M.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},r){M.chains.set(t.namespace,{namespace:t.namespace,networkState:{...On,caipNetwork:r[0]},accountState:So,caipNetworks:r,connectionControllerClient:s,networkControllerClient:e}),f.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}),f.setRequestedCaipNetworks(r,t.chainNamespace),j.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])&&f.setActiveCaipNetwork(s.caipNetworks[0]),M.chains.set(t,{...s,caipNetworks:a}),f.setRequestedCaipNetworks(a||[],t),a.length===0&&j.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=M.chains.get(t);s&&(s.networkState={...s.networkState||On,...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||So,...e};M.chains.set(t,{...r,accountState:i}),(M.chains.size===1||M.activeChain===t)&&(e.caipAddress&&(M.activeCaipAddress=e.caipAddress),z.replaceState(i))}},setChainNetworkData(t,e){if(!t)return;const s=M.chains.get(t);if(s){const r={...s.networkState||On,...e};M.chains.set(t,{...s,networkState:r})}},setAccountProp(t,e,s,r=!0){f.setChainAccountData(s,{[t]:e},r),t==="status"&&e==="disconnected"&&s&&j.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,f.setChainNetworkData(t,{caipNetwork:s}),W.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),Ss.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var r,i,n;if(!t)return;M.activeChain!==t.chainNamespace&&f.setIsSwitchingNamespace(!0);const e=M.chains.get(t.chainNamespace);M.activeChain=t.chainNamespace,M.activeCaipNetwork=t,f.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,f.setAccountProp("caipAddress",M.activeCaipAddress,t.chainNamespace),e&&z.replaceState(e.accountState),he.resetSend(),Ss.set({activeChain:M.activeChain,selectedNetworkId:(n=M.activeCaipNetwork)==null?void 0:n.caipNetworkId}),W.setActiveCaipNetworkId(t.caipNetworkId),!f.checkIfSupportedNetwork(t.chainNamespace)&&T.state.enableNetworkSwitch&&!T.state.allowUnsupportedChain&&!Y.state.wcBasic&&f.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!==f.state.activeChain,s=(i=f.getNetworkData(t))==null?void 0:i.caipNetwork,r=f.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&r&&await f.switchActiveNetwork(r)},async switchActiveNetwork(t){var i;const e=f.state.chains.get(f.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=f.getNetworkControllerClient(t.chainNamespace);if(r){try{await r.switchCaipNetwork(t),s&&He.close()}catch{ie.goBack()}Pe.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=f.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){f.setAdapterNetworkState(e,{requestedCaipNetworks:t});const r=f.getAllRequestedCaipNetworks().map(n=>n.chainNamespace),i=Array.from(new Set(r));j.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const t=[];return M.chains.forEach(e=>{const s=f.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=f.getNetworkControllerClient(),s=await(e==null?void 0:e.getApprovedCaipNetworksData());f.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=f.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=f.getRequestedCaipNetworks(M.activeChain);return e==null?void 0:e.some(s=>s.id===t)},setSmartAccountEnabledNetworks(t,e){f.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){var r;const t=Fu.caipNetworkIdToNumber((r=M.activeCaipNetwork)==null?void 0:r.caipNetworkId),e=M.activeChain;if(!e||!t)return!1;const s=f.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=Ee.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`},showUnsupportedChainUI(){He.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=M.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Ee.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){f.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,f.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"}),j.removeConnectorId(e)},setIsSwitchingNamespace(t){M.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,r;const t=[];let e;if(M.chains.forEach(i=>{F.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=f.state.chains.get(t))==null?void 0:e.accountState:z.state},getNetworkData(t){var s;const e=t||M.activeChain;if(e)return(s=f.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var i,n,o;if(!t)return;const s=f.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=j.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?f.getRequestedCaipNetworks(t):f.getAllRequestedCaipNetworks()}},f=_t(af),cf={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"}]}]},Qu=X.getBlockchainApiUrl(),at=Ne({clientId:null,api:new pn({baseUrl:Qu,clientId:null}),supportedChains:{http:[],ws:[]}}),J={state:at,async get(t){const{st:e,sv:s}=J.getSdkProperties(),r=T.state.projectId,i={...t.params||{},st:e,sv:s,projectId:r};return at.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{at.supportedChains.http.length||await J.getSupportedNetworks()}catch{return!1}return at.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await J.get({path:"v1/supported-chains"});return at.supportedChains=t,t}catch{return at.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:f.state.activeCaipAddress?X.getPlainAddress(f.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=f.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=f.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=f.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=f.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?at.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=f.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=f.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=f.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return at.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ee.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=f.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=f.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=f.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=f.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?J.get({path:`/v1/profile/reverse/${t}`,params:{sender:z.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){var s;return await J.isNetworkSupported((s=f.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=f.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?at.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=f.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await at.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=f.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await J.get({path:"/v1/onramp/options"})}catch{return cf}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:r}){var i;try{return await J.isNetworkSupported((i=f.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?await at.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=f.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=f.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?at.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:T.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){at.clientId=t,at.api=new pn({baseUrl:Qu,clientId:t})}},St=Ne({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),lf={state:St,replaceState(t){t&&Object.assign(St,er(t))},subscribe(t){return f.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,s){let r;return f.subscribeChainProp("accountState",i=>{if(i){const n=i[t];r!==n&&(r=n,e(n))}},s)},setStatus(t,e){f.setAccountProp("status",t,e)},getCaipAddress(t){return f.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const s=t?X.getPlainAddress(t):void 0;e===f.state.activeChain&&(f.state.activeCaipAddress=t),f.setAccountProp("caipAddress",t,e),f.setAccountProp("address",s,e)},setBalance(t,e,s){f.setAccountProp("balance",t,s),f.setAccountProp("balanceSymbol",e,s)},setProfileName(t,e){f.setAccountProp("profileName",t,e)},setProfileImage(t,e){f.setAccountProp("profileImage",t,e)},setUser(t,e){f.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){f.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){f.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){f.setAccountProp("currentTab",t,f.state.activeChain)},setTokenBalance(t,e){t&&f.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){f.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){f.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,s){const r=f.getAccountProp("addressLabels",s)||new Map;r.set(t,e),f.setAccountProp("addressLabels",r,s)},removeAddressLabel(t,e){const s=f.getAccountProp("addressLabels",e)||new Map;s.delete(t),f.setAccountProp("addressLabels",s,e)},setConnectedWalletInfo(t,e){f.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){f.setAccountProp("preferredAccountTypes",{...St.preferredAccountTypes,[e]:t},e)},setPreferredAccountTypes(t){St.preferredAccountTypes=t},setSocialProvider(t,e){t&&f.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){f.setAccountProp("socialWindow",t?er(t):void 0,e)},setFarcasterUrl(t,e){f.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){var n,o;St.balanceLoading=!0;const e=(n=f.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,s=(o=f.state.activeCaipNetwork)==null?void 0:o.chainNamespace,r=f.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(St.lastRetry&&!X.isAllowedRetry(St.lastRetry,30*Ee.ONE_SEC_MS))return St.balanceLoading=!1,[];try{if(i&&e&&s){const c=(await J.getBalance(i,e)).balances.filter(l=>l.quantity.decimals!=="0");return z.setTokenBalance(c,s),St.lastRetry=void 0,St.balanceLoading=!1,c}}catch(a){St.lastRetry=Date.now(),t==null||t(a),jt.showError("Token Balance Unavailable")}finally{St.balanceLoading=!1}return[]},resetAccount(t){f.resetAccount(t)}},z=_t(lf),uf={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=f.state.activeCaipNetwork,r=ie.state.data;if(t.id===(s==null?void 0:s.id))return;const n=z.getCaipAddress(f.state.activeChain),o=t.chainNamespace!==f.state.activeChain,a=z.getCaipAddress(t.chainNamespace),l=j.getConnectorId(f.state.activeChain)===F.CONNECTOR_ID.AUTH,u=F.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(d=>d===t.chainNamespace);e||l&&u?ie.push("SwitchNetwork",{...r,network:t}):n&&o&&!a?ie.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ie.push("SwitchNetwork",{...r,network:t})}},ct=Ne({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),df={state:ct,subscribe(t){return tt(ct,()=>t(ct))},subscribeKey(t,e){return st(ct,t,e)},async open(t){var o,a;const e=z.state.status==="connected",s=t==null?void 0:t.namespace,r=f.state.activeChain,i=s&&s!==r,n=(o=f.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}),j.setFilterByNamespace(t==null?void 0:t.namespace),He.setLoading(!0,s),s&&i){const c=((a=f.getNetworkData(s))==null?void 0:a.caipNetwork)||f.getRequestedCaipNetworks(s)[0];c&&uf.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0})}else{const c=f.state.noAdapters;T.state.manualWCControl||c&&!n?X.isMobile()?ie.reset("AllWallets"):ie.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?ie.reset(t.view,t.data):n?ie.reset("Account"):ie.reset("Connect")}ct.open=!0,Ss.set({open:!0}),Pe.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!n}})},close(){const t=T.state.enableEmbedded,e=!!f.state.activeCaipAddress;ct.open&&Pe.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),ct.open=!1,ie.reset("Connect"),He.clearLoading(),t?e?ie.replace("Account"):ie.push("Connect"):Ss.set({open:!1}),Y.resetUri()},setLoading(t,e){e&&ct.loadingNamespaceMap.set(e,t),ct.loading=t,Ss.set({loading:t})},clearLoading(){ct.loadingNamespaceMap.clear(),ct.loading=!1},shake(){ct.shake||(ct.shake=!0,setTimeout(()=>{ct.shake=!1},500))}},He=_t(df),_i={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"}]},ua={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},hf={providers:ju,selectedProvider:null,error:null,purchaseCurrency:_i,paymentCurrency:ua,purchaseCurrencies:[_i],paymentCurrencies:[],quotesLoading:!1},ae=Ne(hf),pf={state:ae,subscribe(t){return tt(ae,()=>t(ae))},subscribeKey(t,e){return st(ae,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=f.state.activeChain===F.CHAIN.SOLANA?"SOL":"USDC",s=z.state.address??"",r=new URL(t.url);r.searchParams.append("publicKey",dp),r.searchParams.append("destinationCurrencyCode",e),r.searchParams.append("walletAddress",s),r.searchParams.append("externalCustomerId",T.state.projectId),ae.selectedProvider={...t,url:r.toString()}}else ae.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=ju.filter(r=>e.includes(r.name));ae.providers=s}else ae.providers=[]},setPurchaseCurrency(t){ae.purchaseCurrency=t},setPaymentCurrency(t){ae.paymentCurrency=t},setPurchaseAmount(t){da.state.purchaseAmount=t},setPaymentAmount(t){da.state.paymentAmount=t},async getAvailableCurrencies(){const t=await J.getOnrampOptions();ae.purchaseCurrencies=t.purchaseCurrencies,ae.paymentCurrencies=t.paymentCurrencies,ae.paymentCurrency=t.paymentCurrencies[0]||ua,ae.purchaseCurrency=t.purchaseCurrencies[0]||_i,await K.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await K.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;ae.quotesLoading=!0;try{const s=await J.getOnrampQuote({purchaseCurrency:ae.purchaseCurrency,paymentCurrency:ae.paymentCurrency,amount:((t=ae.paymentAmount)==null?void 0:t.toString())||"0",network:(e=ae.purchaseCurrency)==null?void 0:e.symbol});return ae.quotesLoading=!1,ae.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return ae.error=s.message,ae.quotesLoading=!1,null}finally{ae.quotesLoading=!1}},resetState(){ae.selectedProvider=null,ae.error=null,ae.purchaseCurrency=_i,ae.paymentCurrency=ua,ae.purchaseCurrencies=[_i],ae.paymentCurrencies=[],ae.paymentAmount=void 0,ae.purchaseAmount=void 0,ae.quotesLoading=!1}},da=_t(pf),Nc=2147483648,ff={convertEVMChainIdToCoinType(t){if(t>=Nc)throw new Error("Invalid chainId");return(Nc|t)>>>0}},Pt=Ne({suggestions:[],loading:!1}),gf={state:Pt,subscribe(t){return tt(Pt,()=>t(Pt))},subscribeKey(t,e){return st(Pt,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{Pt.loading=!0,Pt.suggestions=[];const e=await J.getEnsNameSuggestions(t);return Pt.suggestions=e.suggestions.map(s=>({...s,name:s.name}))||[],Pt.suggestions}catch(e){const s=Ni.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Pt.loading=!1}},async getNamesForAddress(t){try{if(!f.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=Ni.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=f.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const s=z.state.address,r=j.getAuthConnector();if(!s||!r)throw new Error("Address or auth connector not found");Pt.loading=!0;try{const i=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});ie.pushTransactionStack({onCancel(){ie.replace("RegisterAccountName")}});const n=await Y.signMessage(i);Pt.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=ff.convertEVMChainIdToCoinType(Number(o));await J.registerEnsName({coinType:a,address:s,signature:n,message:i}),z.setProfileName(t,e.chainNamespace),ie.replace("RegisterAccountNameSuccess")}catch(i){const n=Ni.parseEnsApiError(i,`Error registering name ${t}`);throw ie.replace("RegisterAccountName"),new Error(n)}finally{Pt.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}},Ni=_t(gf),Si={getSIWX(){return T.state.siwx},async initializeIfEnabled(){var n;const t=T.state.siwx,e=f.getActiveCaipAddress();if(!(t&&e))return;const[s,r,i]=e.split(":");if(f.checkIfSupportedNetwork(s))try{if((await t.getSessions(`${s}:${r}`,i)).length)return;await He.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),Pe.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=Y._getClient())==null?void 0:n.disconnect().catch(console.error)),ie.reset("Connect"),jt.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=T.state.siwx,e=X.getPlainAddress(f.getActiveCaipAddress()),s=f.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();j.getConnectorId(s.chainNamespace)===F.CONNECTOR_ID.AUTH&&ie.pushTransactionStack({});const a=await r.signMessage(n);await t.addSession({data:i,message:n,signature:a}),He.close(),Pe.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const n=this.getSIWXEventProperties();(!He.state.open||ie.state.view==="ApproveTransaction")&&await He.open({view:"SIWXSignMessage"}),n.isSmartAccount?jt.showError("This application might not support Smart Accounts"):jt.showError("Signature declined"),Pe.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():He.close(),ie.reset("Connect"),Pe.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(f.getActiveCaipAddress()),s=f.getActiveCaipNetwork();return t&&e&&s?t.getSessions(s.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const s=ie.state.view==="ApproveTransaction",r=ie.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=Si.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=f.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}),z.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(d=>{const h=t.client.formatAuthMessage({request:d.p,iss:d.p.iss});return{data:{...d.p,accountAddress:d.p.iss.split(":").slice(-1).join(""),chainId:d.p.iss.split(":").slice(2,4).join(":"),uri:d.p.aud,version:d.p.version||n.version,expirationTime:d.p.exp,issuedAt:d.p.iat,notBefore:d.p.nbf},message:h,signature:d.s.s,cacao:d}});try{await r.setSessions(u),Pe.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:Si.getSIWXEventProperties()})}catch(d){throw console.error("SIWX:universalProviderAuth - failed to set sessions",d),Pe.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:Si.getSIWXEventProperties()}),await t.disconnect().catch(console.error),d}finally{jt.hide()}}return!0},getSIWXEventProperties(){var e,s;const t=f.state.activeChain;return{network:((e=f.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((s=z.state.preferredAccountTypes)==null?void 0:s[t])===Ii.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};function mf(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function je(t,...e){try{return mf(t(...e))}catch(s){return Promise.reject(s)}}function wf(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function yf(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Wn(t){if(wf(t))return String(t);if(yf(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Wn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const ha="base64:";function bf(t){return typeof t=="string"?t:ha+Cf(t)}function vf(t){return typeof t!="string"||!t.startsWith(ha)?t:Ef(t.slice(ha.length))}function Ef(t){return globalThis.Buffer?Ve.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function Cf(t){return globalThis.Buffer?Ve.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 If(...t){return dt(t.join(":"))}function Tn(t){return t=dt(t),t?t+":":""}function Af(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 _f(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const Nf="memory",Sf=()=>{const t=new Map;return{name:Nf,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 Pf(t={}){const e={mounts:{"":t.driver||Sf()},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(d=>d.startsWith(l)||u&&l.startsWith(d)).map(d=>({relativeBase:l.length>d.length?l.slice(d.length):void 0,mountpoint:d,driver:e.mounts[d]})),i=(l,u)=>{if(e.watching){u=dt(u);for(const d of e.watchListeners)d(l,u)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Sc(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,d)=>{const h=new Map,p=g=>{let m=h.get(g.base);return m||(m={driver:g.driver,base:g.base,items:[]},h.set(g.base,m)),m};for(const g of l){const m=typeof g=="string",w=dt(m?g:g.key),y=m?void 0:g.value,b=m||!g.options?u:{...u,...g.options},v=s(w);p(v).items.push({key:w,value:y,relativeKey:v.relativeKey,options:b})}return Promise.all([...h.values()].map(g=>d(g))).then(g=>g.flat())},c={hasItem(l,u={}){l=dt(l);const{relativeKey:d,driver:h}=s(l);return je(h.hasItem,d,u)},getItem(l,u={}){l=dt(l);const{relativeKey:d,driver:h}=s(l);return je(h.getItem,d,u).then(p=>An(p))},getItems(l,u={}){return a(l,u,d=>d.driver.getItems?je(d.driver.getItems,d.items.map(h=>({key:h.relativeKey,options:h.options})),u).then(h=>h.map(p=>({key:If(d.base,p.key),value:An(p.value)}))):Promise.all(d.items.map(h=>je(d.driver.getItem,h.relativeKey,h.options).then(p=>({key:h.key,value:An(p)})))))},getItemRaw(l,u={}){l=dt(l);const{relativeKey:d,driver:h}=s(l);return h.getItemRaw?je(h.getItemRaw,d,u):je(h.getItem,d,u).then(p=>vf(p))},async setItem(l,u,d={}){if(u===void 0)return c.removeItem(l);l=dt(l);const{relativeKey:h,driver:p}=s(l);p.setItem&&(await je(p.setItem,h,Wn(u),d),p.watch||i("update",l))},async setItems(l,u){await a(l,u,async d=>{if(d.driver.setItems)return je(d.driver.setItems,d.items.map(h=>({key:h.relativeKey,value:Wn(h.value),options:h.options})),u);d.driver.setItem&&await Promise.all(d.items.map(h=>je(d.driver.setItem,h.relativeKey,Wn(h.value),h.options)))})},async setItemRaw(l,u,d={}){if(u===void 0)return c.removeItem(l,d);l=dt(l);const{relativeKey:h,driver:p}=s(l);if(p.setItemRaw)await je(p.setItemRaw,h,u,d);else if(p.setItem)await je(p.setItem,h,bf(u),d);else return;p.watch||i("update",l)},async removeItem(l,u={}){typeof u=="boolean"&&(u={removeMeta:u}),l=dt(l);const{relativeKey:d,driver:h}=s(l);h.removeItem&&(await je(h.removeItem,d,u),(u.removeMeta||u.removeMata)&&await je(h.removeItem,d+"$",u),h.watch||i("remove",l))},async getMeta(l,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),l=dt(l);const{relativeKey:d,driver:h}=s(l),p=Object.create(null);if(h.getMeta&&Object.assign(p,await je(h.getMeta,d,u)),!u.nativeOnly){const g=await je(h.getItem,d+"$",u).then(m=>An(m));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(l,u,d={}){return this.setItem(l+"$",u,d)},removeMeta(l,u={}){return this.removeItem(l+"$",u)},async getKeys(l,u={}){var w;l=Tn(l);const d=r(l,!0);let h=[];const p=[];let g=!0;for(const y of d){(w=y.driver.flags)!=null&&w.maxDepth||(g=!1);const b=await je(y.driver.getKeys,y.relativeBase,u);for(const v of b){const I=y.mountpoint+dt(v);h.some(S=>I.startsWith(S))||p.push(I)}h=[y.mountpoint,...h.filter(v=>!v.startsWith(y.mountpoint))]}const m=u.maxDepth!==void 0&&!g;return p.filter(y=>(!m||Af(y,u.maxDepth))&&_f(y,l))},async clear(l,u={}){l=Tn(l),await Promise.all(r(l,!1).map(async d=>{if(d.driver.clear)return je(d.driver.clear,d.relativeBase,u);if(d.driver.removeItem){const h=await d.driver.getKeys(d.relativeBase||"",u);return Promise.all(h.map(p=>d.driver.removeItem(p,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Pc(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=Tn(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((d,h)=>h.length-d.length)),e.mounts[l]=u,e.watching&&Promise.resolve(Sc(u,i,l)).then(d=>{e.unwatch[l]=d}).catch(console.error),c},async unmount(l,u=!0){var d,h;l=Tn(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((h=(d=e.unwatch)[l])==null||h.call(d),delete e.unwatch[l]),u&&await Pc(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(h=>({driver:h.driver,base:h.mountpoint}))},keys:(l,u={})=>c.getKeys(l,u),get:(l,u={})=>c.getItem(l,u),set:(l,u,d={})=>c.setItem(l,u,d),has:(l,u={})=>c.hasItem(l,u),del:(l,u={})=>c.removeItem(l,u),remove:(l,u={})=>c.removeItem(l,u)};return c}function Sc(t,e,s){return t.watch?t.watch((r,i)=>e(r,s+i)):()=>{}}async function Pc(t){typeof t.dispose=="function"&&await je(t.dispose)}const Of="idb-keyval";var Tf=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=i=>e+i;let r;return t.dbName&&t.storeName&&(r=jh(t.dbName,t.storeName)),{name:Of,options:t,async hasItem(i){return!(typeof await pc(s(i),r)>"u")},async getItem(i){return await pc(s(i),r)??null},setItem(i,n){return qh(s(i),n,r)},removeItem(i){return Wh(s(i),r)},getKeys(){return zh(r)},clear(){return Hh(r)}}};const xf="WALLET_CONNECT_V2_INDEXED_DB",$f="keyvaluestorage";let kf=class{constructor(){this.indexedDb=Pf({driver:Tf({dbName:xf,storeName:$f})})}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,za(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Po=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Q<"u"?Q:typeof self<"u"?self:{},zn={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 Po<"u"&&Po.localStorage?zn.exports=Po.localStorage:typeof window<"u"&&window.localStorage?zn.exports=window.localStorage:zn.exports=new e})();function Rf(t){var e;return[t[0],Qn((e=t[1])!=null?e:"")]}let Uf=class{constructor(){this.localStorage=zn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Rf)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return Qn(s)}async setItem(e,s){this.localStorage.setItem(e,za(s))}async removeItem(e){this.localStorage.removeItem(e)}};const Df="wc_storage_version",Oc=1,Lf=async(t,e,s)=>{const r=Df,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),Mf(t,o)},Mf=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let Bf=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new Uf;this.storage=e;try{const s=new kf;Lf(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 Ff=Object.defineProperty,jf=(t,e,s)=>e in t?Ff(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Tc=(t,e,s)=>jf(t,typeof e!="symbol"?e+"":e,s);let qf=class extends Xr{constructor(e){super(),this.opts=e,Tc(this,"protocol","wc"),Tc(this,"version",2)}};var Wf=Object.defineProperty,zf=(t,e,s)=>e in t?Wf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Hf=(t,e,s)=>zf(t,typeof e!="symbol"?e+"":e,s);let Kf=class extends Xr{constructor(e,s){super(),this.core=e,this.logger=s,Hf(this,"records",new Map)}},Vf=class{constructor(e,s){this.logger=e,this.core=s}},Gf=class extends Xr{constructor(e,s){super(),this.relayer=e,this.logger=s}},Jf=class extends Xr{constructor(e){super()}},Yf=class{constructor(e,s,r,i){this.core=e,this.logger=s,this.name=r}},Xf=class extends Xr{constructor(e,s){super(),this.relayer=e,this.logger=s}},Zf=class extends Xr{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}},eg=class{constructor(e,s){this.projectId=e,this.logger=s}},tg=class{constructor(e,s,r){this.core=e,this.logger=s,this.telemetryEnabled=r}};var sg=Object.defineProperty,rg=(t,e,s)=>e in t?sg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xc=(t,e,s)=>rg(t,typeof e!="symbol"?e+"":e,s);let ig=class{constructor(e){this.opts=e,xc(this,"protocol","wc"),xc(this,"version",2)}},ng=class{constructor(e){this.client=e}};function sn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function $c(t){return sn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ed="2.23.2";let ci={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${ed}`};class tr extends Error{constructor(e,s={}){var a;const r=(()=>{var c;return s.cause instanceof tr?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),i=(()=>s.cause instanceof tr&&s.cause.docsPath||s.docsPath)(),n=(a=ci.getDocsUrl)==null?void 0:a.call(ci,{...s,docsPath:i}),o=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...r?[`Details: ${r}`]:[],...ci.version?[`Version: ${ci.version}`]:[]].join(`
|
|
7
|
-
`);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=ed}walk(e){return td(this,e)}}function td(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?td(t.cause,e):e?null:t}class sd extends tr{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 Qr(t,{dir:e,size:s=32}={}){return typeof t=="string"?og(t,{dir:e,size:s}):ag(t,{dir:e,size:s})}function og(t,{dir:e,size:s=32}={}){if(s===null)return t;const r=t.replace("0x","");if(r.length>s*2)throw new sd({size:Math.ceil(r.length/2),targetSize:s,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function ag(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new sd({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 cg extends tr{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 lg extends tr{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function ei(t,{size:e}){if($c(t)>e)throw new lg({givenSize:$c(t),maxSize:e})}function pa(t,e={}){const{signed:s}=e;e.size&&ei(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 ug(t,e={}){return Number(pa(t,e))}const dg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fa(t,e={}){return typeof t=="number"||typeof t=="bigint"?id(t,e):typeof t=="string"?fg(t,e):typeof t=="boolean"?hg(t,e):rd(t,e)}function hg(t,e={}){const s=`0x${Number(t)}`;return typeof e.size=="number"?(ei(s,{size:e.size}),Qr(s,{size:e.size})):s}function rd(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=dg[t[i]];const r=`0x${s}`;return typeof e.size=="number"?(ei(r,{size:e.size}),Qr(r,{dir:"right",size:e.size})):r}function id(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 cg({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?Qr(a,{size:r}):a}const pg=new TextEncoder;function fg(t,e={}){const s=pg.encode(t);return rd(s,e)}const gg=new TextEncoder;function mg(t,e={}){return typeof t=="number"||typeof t=="bigint"?yg(t,e):typeof t=="boolean"?wg(t,e):sn(t)?nd(t,e):od(t,e)}function wg(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(ei(s,{size:e.size}),Qr(s,{size:e.size})):s}const os={zero:48,nine:57,A:65,F:70,a:97,f:102};function kc(t){if(t>=os.zero&&t<=os.nine)return t-os.zero;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 nd(t,e={}){let s=t;e.size&&(ei(s,{size:e.size}),s=Qr(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=kc(r.charCodeAt(a++)),l=kc(r.charCodeAt(a++));if(c===void 0||l===void 0)throw new tr(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);n[o]=c*16+l}return n}function yg(t,e){const s=id(t,e);return nd(s)}function od(t,e={}){const s=gg.encode(t);return typeof e.size=="number"?(ei(s,{size:e.size}),Qr(s,{dir:"right",size:e.size})):s}function eo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function uo(t,...e){if(!bg(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 yA(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");eo(t.outputLen),eo(t.blockLen)}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 vg(t,e){uo(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const xn=BigInt(2**32-1),Uc=BigInt(32);function Eg(t,e=!1){return e?{h:Number(t&xn),l:Number(t>>Uc&xn)}:{h:Number(t>>Uc&xn)|0,l:Number(t&xn)|0}}function Cg(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}=Eg(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Ig=(t,e,s)=>t<<s|e>>>32-s,Ag=(t,e,s)=>e<<s|t>>>32-s,_g=(t,e,s)=>e<<s-32|t>>>64-s,Ng=(t,e,s)=>t<<s-32|e>>>64-s,ur=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Sg(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function bA(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function vA(t,e){return t<<32-e|t>>>e}const Dc=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Pg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Lc(t){for(let e=0;e<t.length;e++)t[e]=Pg(t[e])}function Og(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ad(t){return typeof t=="string"&&(t=Og(t)),uo(t),t}function EA(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];uo(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 Tg{clone(){return this._cloneInto()}}function xg(t){const e=r=>t().update(ad(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function CA(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 cd=[],ld=[],ud=[],$g=BigInt(0),li=BigInt(1),kg=BigInt(2),Rg=BigInt(7),Ug=BigInt(256),Dg=BigInt(113);for(let t=0,e=li,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],cd.push(2*(5*r+s)),ld.push((t+1)*(t+2)/2%64);let i=$g;for(let n=0;n<7;n++)e=(e<<li^(e>>Rg)*Dg)%Ug,e&kg&&(i^=li<<(li<<BigInt(n))-li);ud.push(i)}const[Lg,Mg]=Cg(ud,!0),Mc=(t,e,s)=>s>32?_g(t,e,s):Ig(t,e,s),Bc=(t,e,s)=>s>32?Ng(t,e,s):Ag(t,e,s);function Bg(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],d=Mc(l,u,1)^s[a],h=Bc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=d,t[o+p+1]^=h}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=ld[o],c=Mc(i,n,a),l=Bc(i,n,a),u=cd[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]^=Lg[r],t[1]^=Mg[r]}s.fill(0)}class Xa extends Tg{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,eo(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Sg(this.state)}keccak(){Dc||Lc(this.state32),Bg(this.state32,this.rounds),Dc||Lc(this.state32),this.posOut=0,this.pos=0}update(e){Rc(this);const{blockLen:s,state:r}=this;e=ad(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){Rc(this,!1),uo(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 eo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vg(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 Xa(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 Fg=(t,e,s)=>xg(()=>new Xa(e,t,s)),jg=Fg(1,136,256/8);function dd(t,e){const s=e||"hex",r=jg(sn(t,{strict:!1})?mg(t):t);return s==="bytes"?r:fa(r)}class qg 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 Oo=new qg(8192);function Wg(t,e){if(Oo.has(`${t}.${e}`))return Oo.get(`${t}.${e}`);const s=e?`${e}${t.toLowerCase()}`:t.substring(2).toLowerCase(),r=dd(od(s),"bytes"),i=(e?s.substring(`${e}0x`.length):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 Oo.set(`${t}.${e}`,n),n}function zg(t){const e=dd(`0x${t.substring(4)}`).substring(26);return Wg(`0x${e}`)}async function Hg({hash:t,signature:e}){const s=sn(t)?t:fa(t),{secp256k1:r}=await ia(()=>import("./secp256k1-68a098fa.js"),["assets/secp256k1-68a098fa.js","assets/index-1e0cfb06.js","assets/index-9c03b9eb.css","assets/index.es-63034a59.js"]);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:d,yParity:h}=e,p=Number(h??d),g=Fc(p);return new r.Signature(pa(l),pa(u)).addRecoveryBit(g)}const o=sn(e)?e:fa(e),a=ug(`0x${o.slice(130)}`),c=Fc(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(s.substring(2)).toHex(!1)}`}function Fc(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 Kg({hash:t,signature:e}){return zg(await Hg({hash:t,signature:e}))}function hd(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Pi(t,e){e||(e=t.reduce((i,n)=>i+n.length,0));const s=hd(e);let r=0;for(const i of t)s.set(i,r),r+=i.length;return s}function pd(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const jc=pd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),To=pd("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=hd(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),fd={utf8:jc,"utf-8":jc,hex:fc.base16,latin1:To,ascii:To,binary:To,...fc};function kt(t,e="utf8"){const s=fd[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):s.decoder.decode(`${s.prefix}${t}`)}function ft(t,e="utf8"){const s=fd[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):s.encoder.encode(t).substring(1)}const Vg=":";function Rr(t){const[e,s]=t.split(Vg);return{namespace:e,reference:s}}function gd(t,e){return t.includes(":")?[t]:e.chains||[]}var Gg=Object.defineProperty,Jg=Object.defineProperties,Yg=Object.getOwnPropertyDescriptors,qc=Object.getOwnPropertySymbols,Xg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,Wc=(t,e,s)=>e in t?Gg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,zc=(t,e)=>{for(var s in e||(e={}))Xg.call(e,s)&&Wc(t,s,e[s]);if(qc)for(var s of qc(e))Zg.call(e,s)&&Wc(t,s,e[s]);return t},Qg=(t,e)=>Jg(t,Yg(e));const em="ReactNative",Ct={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},tm="js";function to(){return typeof Ns<"u"&&typeof Ns.versions<"u"&&typeof Ns.versions.node<"u"}function Rs(){return!Lr()&&!!Du()&&navigator.product===em}function sm(){return Rs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="android"}function rm(){return Rs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"&&(Q==null?void 0:Q.Platform.OS)==="ios"}function ti(){return!to()&&!!Du()&&!!Lr()}function fn(){return Rs()?Ct.reactNative:to()?Ct.node:ti()?Ct.browser:Ct.unknown}function Hc(){var t;try{return Rs()&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Application)<"u"?(t=Q.Application)==null?void 0:t.applicationId:void 0}catch{return}}function im(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 nm(t){var e,s;const r=md();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!=="")),Qg(zc(zc({},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 md(){return Kh()||{name:"",description:"",url:"",icons:[""]}}function om(){if(fn()===Ct.reactNative&&typeof Q<"u"&&typeof(Q==null?void 0:Q.Platform)<"u"){const{OS:s,Version:r}=Q.Platform;return[s,r].join("-")}const t=Vh();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 am(){var t;const e=fn();return e===Ct.browser?[e,((t=Gh())==null?void 0:t.host)||"unknown"].join(":"):e}function wd(t,e,s){const r=om(),i=am();return[[t,e].join("-"),[tm,s].join("-"),r,i].join("/")}function cm({protocol:t,version:e,relayUrl:s,sdkVersion:r,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=wd(t,e,r),d={auth:i,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},h=im(l[1]||"",d);return l[0]+"?"+h}function Gs(t,e){return t.filter(s=>e.includes(s)).length===t.length}function ga(t){return Object.fromEntries(t.entries())}function ma(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 yd(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 lm(t){return yd("topic",t)}function um(t){return yd("id",t)}function bd(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 De(t,e){return D.fromMiliseconds((e||Date.now())+D.toMiliseconds(t))}function Es(t){return Date.now()>=D.toMiliseconds(t)}function fe(t,e){return`${t}${e?`:${e}`:""}`}function Zt(t=[],e=[]){return[...new Set([...t,...e])]}async function dm({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=hm(n,t,e),a=fn();if(a===Ct.browser){if(!((r=Lr())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}pm(o)}else a===Ct.reactNative&&typeof(Q==null?void 0:Q.Linking)<"u"&&await Q.Linking.openURL(o)}catch(i){console.error(i)}}function hm(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}${wm(r,!0)}`}else i=`${i}/wc?${r}`;return i}function pm(t){let e="_self";mm()?e="_top":(gm()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function fm(t,e){let s="";try{if(ti()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(r){console.error(r)}return s}function Kc(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),r=s.indexOf(e);return s[r+2]}function Vc(){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 Za(){return typeof Ns<"u"&&{}.IS_VITEST==="true"}function gm(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function mm(){try{return window.self!==window.top}catch{return!1}}function wm(t,e=!1){const s=Ve.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function vd(t){return Ve.from(t,"base64").toString("utf-8")}function ym(t){return new Promise(e=>setTimeout(e,t))}function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function gn(t,...e){if(!bm(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 Qa(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rn(t.outputLen),rn(t.blockLen)}function qr(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 Ed(t,e){gn(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const $n=BigInt(2**32-1),Gc=BigInt(32);function vm(t,e=!1){return e?{h:Number(t&$n),l:Number(t>>Gc&$n)}:{h:Number(t>>Gc&$n)|0,l:Number(t&$n)|0}}function Em(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}=vm(t[i],e);[s[i],r[i]]=[n,o]}return[s,r]}const Cm=(t,e,s)=>t<<s|e>>>32-s,Im=(t,e,s)=>e<<s|t>>>32-s,Am=(t,e,s)=>e<<s-32|t>>>64-s,_m=(t,e,s)=>t<<s-32|e>>>64-s,dr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Nm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function xo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ht(t,e){return t<<32-e|t>>>e}const Jc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Sm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Yc(t){for(let e=0;e<t.length;e++)t[e]=Sm(t[e])}function Pm(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Wr(t){return typeof t=="string"&&(t=Pm(t)),gn(t),t}function Om(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];gn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}let ec=class{clone(){return this._cloneInto()}};function Cd(t){const e=r=>t().update(Wr(r)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function si(t=32){if(dr&&typeof dr.getRandomValues=="function")return dr.getRandomValues(new Uint8Array(t));if(dr&&typeof dr.randomBytes=="function")return dr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Id=[],Ad=[],_d=[],Tm=BigInt(0),ui=BigInt(1),xm=BigInt(2),$m=BigInt(7),km=BigInt(256),Rm=BigInt(113);for(let t=0,e=ui,s=1,r=0;t<24;t++){[s,r]=[r,(2*s+3*r)%5],Id.push(2*(5*r+s)),Ad.push((t+1)*(t+2)/2%64);let i=Tm;for(let n=0;n<7;n++)e=(e<<ui^(e>>$m)*Rm)%km,e&xm&&(i^=ui<<(ui<<BigInt(n))-ui);_d.push(i)}const[Um,Dm]=Em(_d,!0),Xc=(t,e,s)=>s>32?Am(t,e,s):Cm(t,e,s),Zc=(t,e,s)=>s>32?_m(t,e,s):Im(t,e,s);function Lm(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],d=Xc(l,u,1)^s[a],h=Zc(l,u,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=d,t[o+p+1]^=h}let i=t[2],n=t[3];for(let o=0;o<24;o++){const a=Ad[o],c=Xc(i,n,a),l=Zc(i,n,a),u=Id[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]^=Um[r],t[1]^=Dm[r]}s.fill(0)}let Mm=class Nd extends ec{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,rn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Nm(this.state)}keccak(){Jc||Yc(this.state32),Lm(this.state32,this.rounds),Jc||Yc(this.state32),this.posOut=0,this.pos=0}update(e){qr(this);const{blockLen:s,state:r}=this;e=Wr(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){qr(this,!1),gn(e),this.finish();const s=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ed(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 Nd(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 Bm=(t,e,s)=>Cd(()=>new Mm(e,t,s)),Fm=Bm(1,136,256/8),jm="https://rpc.walletconnect.org/v1";function Sd(t){const e=`Ethereum Signed Message:
|
|
8
|
-
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Ve.from(Fm(s)).toString("hex")}async function qm(t,e,s,r,i,n){switch(s.t){case"eip191":return await Wm(t,e,s.s);case"eip1271":return await zm(t,e,s.s,r,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function Wm(t,e,s){return(await Kg({hash:Sd(e),signature:s})).toLowerCase()===t.toLowerCase()}async function zm(t,e,s,r,i,n){const o=Rr(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),d=Sd(e).substring(2),h=a+d+c+l+u,p=await fetch(`${n||jm}/?chainId=${r}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:Hm(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:h},"latest"]})}),{result:g}=await p.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Hm(){return Date.now()+Math.floor(Math.random()*1e3)}function Km(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=Ve.from(t,"base64").slice(1,65);return Lu.encode(n)}var Vm=Object.defineProperty,Gm=Object.defineProperties,Jm=Object.getOwnPropertyDescriptors,Qc=Object.getOwnPropertySymbols,Ym=Object.prototype.hasOwnProperty,Xm=Object.prototype.propertyIsEnumerable,el=(t,e,s)=>e in t?Vm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Zm=(t,e)=>{for(var s in e||(e={}))Ym.call(e,s)&&el(t,s,e[s]);if(Qc)for(var s of Qc(e))Xm.call(e,s)&&el(t,s,e[s]);return t},Qm=(t,e)=>Gm(t,Jm(e));const ew="did:pkh:",tc=t=>t==null?void 0:t.split(":"),tw=t=>{const e=t&&tc(t);if(e)return t.includes(ew)?e[3]:e[1]},wa=t=>{const e=t&&tc(t);if(e)return e[2]+":"+e[3]},so=t=>{const e=t&&tc(t);if(e)return e.pop()};async function tl(t){const{cacao:e,projectId:s}=t,{s:r,p:i}=e,n=Pd(i,i.iss),o=so(i.iss);return await qm(o,n,r,wa(i.iss),s)}const Pd=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,r=so(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: ${tw(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,d=t.nbf?`Not Before: ${t.nbf}`:void 0,h=t.requestId?`Request ID: ${t.requestId}`:void 0,p=t.resources?`Resources:${t.resources.map(m=>`
|
|
9
|
-
- ${m}`).join("")}`:void 0,g=Hn(t.resources);if(g){const m=nn(g);i=uw(i,m)}return[s,r,"",i,"",n,o,a,c,l,u,d,h,p].filter(m=>m!=null).join(`
|
|
10
|
-
`)};function sw(t){return Ve.from(JSON.stringify(t)).toString("base64")}function rw(t){return JSON.parse(Ve.from(t,"base64").toString("utf-8"))}function sr(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 iw(t,e,s,r={}){return s==null||s.sort((i,n)=>i.localeCompare(n)),{att:{[t]:nw(e,s,r)}}}function nw(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 Od(t){return sr(t),`urn:recap:${sw(t).replace(/=/g,"")}`}function nn(t){const e=rw(t.replace("urn:recap:",""));return sr(e),e}function ow(t,e,s){const r=iw(t,e,s);return Od(r)}function aw(t){return t&&t.includes("urn:recap:")}function cw(t,e){const s=nn(t),r=nn(e),i=lw(s,r);return Od(i)}function lw(t,e){sr(t),sr(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]=Qm(Zm({},r.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),r}function uw(t="",e){sr(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(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,h)=>d.action.localeCompare(h.action));const l={};c.forEach(d=>{l[d.ability]||(l[d.ability]=[]),l[d.ability].push(d.action)});const u=Object.keys(l).map(d=>(i++,`(${i}) '${d}': '${l[d].join("', '")}' for '${a}'.`));r.push(u.join(", ").replace(".,","."))});const n=r.join(" "),o=`${s}${n}`;return`${t?t+" ":""}${o}`}function sl(t){var e;const s=nn(t);sr(s);const r=(e=s.att)==null?void 0:e.eip155;return r?Object.keys(r).map(i=>i.split("/")[1]):[]}function rl(t){const e=nn(t);sr(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 Hn(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return aw(e)?e:void 0}function $o(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Td(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Et(t,...e){if(!Td(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 il(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 dw(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 nl(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ps=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),hw=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),pw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!pw)throw new Error("Non little-endian hardware is not supported");function fw(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ya(t){if(typeof t=="string")t=fw(t);else if(Td(t))t=ba(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function gw(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function mw(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 ww=(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 ol(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&&!yw(e))throw new Error("invalid output, must be aligned");return e}function al(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 yw(t){return t.byteOffset%4===0}function ba(t){return Uint8Array.from(t)}function zr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const xd=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),bw=xd("expand 16-byte k"),vw=xd("expand 32-byte k"),Ew=Ps(bw),Cw=Ps(vw);function le(t,e){return t<<e|t>>>32-e}function va(t){return t.byteOffset%4===0}const kn=64,Iw=16,$d=2**32-1,cl=new Uint32Array;function Aw(t,e,s,r,i,n,o,a){const c=i.length,l=new Uint8Array(kn),u=Ps(l),d=va(i)&&va(n),h=d?Ps(i):cl,p=d?Ps(n):cl;for(let g=0;g<c;o++){if(t(e,s,r,u,o,a),o>=$d)throw new Error("arx: counter overflow");const m=Math.min(kn,c-g);if(d&&m===kn){const w=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let y=0,b;y<Iw;y++)b=w+y,p[b]=h[b]^u[y];g+=kn;continue}for(let w=0,y;w<m;w++)y=g+w,n[y]=i[y]^l[w];g+=m}}function _w(t,e){const{allowShortKeys:s,extendNonceFn:r,counterLength:i,counterRight:n,rounds:o}=gw({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return $o(i),$o(o),nl(n),nl(s),(a,c,l,u,d=0)=>{Et(a),Et(c),Et(l);const h=l.length;if(u===void 0&&(u=new Uint8Array(h)),Et(u),$o(d),d<0||d>=$d)throw new Error("arx: counter overflow");if(u.length<h)throw new Error(`arx: output (${u.length}) is shorter than data (${h})`);const p=[];let g=a.length,m,w;if(g===32)p.push(m=ba(a)),w=Cw;else if(g===16&&s)m=new Uint8Array(32),m.set(a),m.set(a,16),w=Ew,p.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);va(c)||p.push(c=ba(c));const y=Ps(m);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(w,y,Ps(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 I=new Uint8Array(12);I.set(c,n?0:12-c.length),c=I,p.push(c)}const v=Ps(c);return Aw(t,w,y,v,l,u,d,o),zr(...p),u}}const Ge=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class Nw{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=ya(e),Et(e,32);const s=Ge(e,0),r=Ge(e,2),i=Ge(e,4),n=Ge(e,6),o=Ge(e,8),a=Ge(e,10),c=Ge(e,12),l=Ge(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]=Ge(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],d=o[4],h=o[5],p=o[6],g=o[7],m=o[8],w=o[9],y=Ge(e,s+0),b=Ge(e,s+2),v=Ge(e,s+4),I=Ge(e,s+6),S=Ge(e,s+8),A=Ge(e,s+10),_=Ge(e,s+12),R=Ge(e,s+14);let E=n[0]+(y&8191),k=n[1]+((y>>>13|b<<3)&8191),C=n[2]+((b>>>10|v<<6)&8191),L=n[3]+((v>>>7|I<<9)&8191),H=n[4]+((I>>>4|S<<12)&8191),N=n[5]+(S>>>1&8191),x=n[6]+((S>>>14|A<<2)&8191),O=n[7]+((A>>>11|_<<5)&8191),B=n[8]+((_>>>8|R<<8)&8191),q=n[9]+(R>>>5|i),$=0,G=$+E*a+k*(5*w)+C*(5*m)+L*(5*g)+H*(5*p);$=G>>>13,G&=8191,G+=N*(5*h)+x*(5*d)+O*(5*u)+B*(5*l)+q*(5*c),$+=G>>>13,G&=8191;let ee=$+E*c+k*a+C*(5*w)+L*(5*m)+H*(5*g);$=ee>>>13,ee&=8191,ee+=N*(5*p)+x*(5*h)+O*(5*d)+B*(5*u)+q*(5*l),$+=ee>>>13,ee&=8191;let re=$+E*l+k*c+C*a+L*(5*w)+H*(5*m);$=re>>>13,re&=8191,re+=N*(5*g)+x*(5*p)+O*(5*h)+B*(5*d)+q*(5*u),$+=re>>>13,re&=8191;let Ce=$+E*u+k*l+C*c+L*a+H*(5*w);$=Ce>>>13,Ce&=8191,Ce+=N*(5*m)+x*(5*g)+O*(5*p)+B*(5*h)+q*(5*d),$+=Ce>>>13,Ce&=8191;let pe=$+E*d+k*u+C*l+L*c+H*a;$=pe>>>13,pe&=8191,pe+=N*(5*w)+x*(5*m)+O*(5*g)+B*(5*p)+q*(5*h),$+=pe>>>13,pe&=8191;let Te=$+E*h+k*d+C*u+L*l+H*c;$=Te>>>13,Te&=8191,Te+=N*a+x*(5*w)+O*(5*m)+B*(5*g)+q*(5*p),$+=Te>>>13,Te&=8191;let Me=$+E*p+k*h+C*d+L*u+H*l;$=Me>>>13,Me&=8191,Me+=N*c+x*a+O*(5*w)+B*(5*m)+q*(5*g),$+=Me>>>13,Me&=8191;let Qe=$+E*g+k*p+C*h+L*d+H*u;$=Qe>>>13,Qe&=8191,Qe+=N*l+x*c+O*a+B*(5*w)+q*(5*m),$+=Qe>>>13,Qe&=8191;let ke=$+E*m+k*g+C*p+L*h+H*d;$=ke>>>13,ke&=8191,ke+=N*u+x*l+O*c+B*a+q*(5*w),$+=ke>>>13,ke&=8191;let Re=$+E*w+k*m+C*g+L*p+H*h;$=Re>>>13,Re&=8191,Re+=N*d+x*u+O*l+B*c+q*a,$+=Re>>>13,Re&=8191,$=($<<2)+$|0,$=$+G|0,G=$&8191,$=$>>>13,ee+=$,n[0]=G,n[1]=ee,n[2]=re,n[3]=Ce,n[4]=pe,n[5]=Te,n[6]=Me,n[7]=Qe,n[8]=ke,n[9]=Re}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;zr(r)}update(e){il(this);const{buffer:s,blockLen:r}=this;e=ya(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(){zr(this.h,this.r,this.buffer,this.pad)}digestInto(e){il(this),dw(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 Sw(t){const e=(r,i)=>t(i).update(ya(r)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=r=>t(r),e}const Pw=Sw(t=>new Nw(t));function Ow(t,e,s,r,i,n=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],d=e[1],h=e[2],p=e[3],g=e[4],m=e[5],w=e[6],y=e[7],b=i,v=s[0],I=s[1],S=s[2],A=o,_=a,R=c,E=l,k=u,C=d,L=h,H=p,N=g,x=m,O=w,B=y,q=b,$=v,G=I,ee=S;for(let Ce=0;Ce<n;Ce+=2)A=A+k|0,q=le(q^A,16),N=N+q|0,k=le(k^N,12),A=A+k|0,q=le(q^A,8),N=N+q|0,k=le(k^N,7),_=_+C|0,$=le($^_,16),x=x+$|0,C=le(C^x,12),_=_+C|0,$=le($^_,8),x=x+$|0,C=le(C^x,7),R=R+L|0,G=le(G^R,16),O=O+G|0,L=le(L^O,12),R=R+L|0,G=le(G^R,8),O=O+G|0,L=le(L^O,7),E=E+H|0,ee=le(ee^E,16),B=B+ee|0,H=le(H^B,12),E=E+H|0,ee=le(ee^E,8),B=B+ee|0,H=le(H^B,7),A=A+C|0,ee=le(ee^A,16),O=O+ee|0,C=le(C^O,12),A=A+C|0,ee=le(ee^A,8),O=O+ee|0,C=le(C^O,7),_=_+L|0,q=le(q^_,16),B=B+q|0,L=le(L^B,12),_=_+L|0,q=le(q^_,8),B=B+q|0,L=le(L^B,7),R=R+H|0,$=le($^R,16),N=N+$|0,H=le(H^N,12),R=R+H|0,$=le($^R,8),N=N+$|0,H=le(H^N,7),E=E+k|0,G=le(G^E,16),x=x+G|0,k=le(k^x,12),E=E+k|0,G=le(G^E,8),x=x+G|0,k=le(k^x,7);let re=0;r[re++]=o+A|0,r[re++]=a+_|0,r[re++]=c+R|0,r[re++]=l+E|0,r[re++]=u+k|0,r[re++]=d+C|0,r[re++]=h+L|0,r[re++]=p+H|0,r[re++]=g+N|0,r[re++]=m+x|0,r[re++]=w+O|0,r[re++]=y+B|0,r[re++]=b+q|0,r[re++]=v+$|0,r[re++]=I+G|0,r[re++]=S+ee|0}const Tw=_w(Ow,{counterRight:!1,counterLength:4,allowShortKeys:!1}),xw=new Uint8Array(16),ll=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(xw.subarray(s))},$w=new Uint8Array(32);function ul(t,e,s,r,i){const n=t(e,s,$w),o=Pw.create(n);i&&ll(o,i),ll(o,r);const a=new Uint8Array(16),c=hw(a);al(c,0,BigInt(i?i.length:0),!0),al(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return zr(n,a),l}const kw=t=>(e,s,r)=>({encrypt(i,n){const o=i.length;n=ol(o+16,n,!1),n.set(i);const a=n.subarray(0,-16);t(e,s,a,a,1);const c=ul(t,e,s,a,r);return n.set(c,o),zr(c),n},decrypt(i,n){n=ol(i.length-16,n,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=ul(t,e,s,o,r);if(!mw(a,c))throw new Error("invalid tag");return n.set(i.subarray(0,-16)),t(e,s,n,n,1),zr(c),n}}),kd=ww({blockSize:64,nonceLength:12,tagLength:16},kw(Tw));let Rd=class extends ec{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,Qa(e);const r=Wr(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 qr(this),this.iHash.update(e),this}digestInto(e){qr(this),gn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const ho=(t,e,s)=>new Rd(t,e).update(s).digest();ho.create=(t,e)=>new Rd(t,e);function Rw(t,e,s){return Qa(t),s===void 0&&(s=new Uint8Array(t.outputLen)),ho(t,Wr(s),Wr(e))}const ko=new Uint8Array([0]),dl=new Uint8Array;function Uw(t,e,s,r=32){if(Qa(t),rn(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);s===void 0&&(s=dl);const n=new Uint8Array(i*t.outputLen),o=ho.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)ko[0]=l+1,a.update(l===0?dl:c).update(s).update(ko).digestInto(c),n.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),ko.fill(0),n.slice(0,r)}const Dw=(t,e,s,r,i)=>Uw(t,Rw(t,e,s),r,i);function Lw(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 Mw(t,e,s){return t&e^~t&s}function Bw(t,e,s){return t&e^t&s^e&s}let Fw=class extends ec{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=xo(this.buffer)}update(e){qr(this);const{view:s,buffer:r,blockLen:i}=this;e=Wr(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=xo(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){qr(this),Ed(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 d=o;d<i;d++)s[d]=0;Lw(r,i-8,BigInt(this.length*8),n),this.process(r,0);const a=xo(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 d=0;d<l;d++)a.setUint32(4*d,u[d],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 jw=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]),ys=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bs=new Uint32Array(64);class qw extends Fw{constructor(){super(64,32,8,!1),this.A=ys[0]|0,this.B=ys[1]|0,this.C=ys[2]|0,this.D=ys[3]|0,this.E=ys[4]|0,this.F=ys[5]|0,this.G=ys[6]|0,this.H=ys[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 d=0;d<16;d++,s+=4)bs[d]=e.getUint32(s,!1);for(let d=16;d<64;d++){const h=bs[d-15],p=bs[d-2],g=Ht(h,7)^Ht(h,18)^h>>>3,m=Ht(p,17)^Ht(p,19)^p>>>10;bs[d]=m+bs[d-7]+g+bs[d-16]|0}let{A:r,B:i,C:n,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const h=Ht(a,6)^Ht(a,11)^Ht(a,25),p=u+h+Mw(a,c,l)+jw[d]+bs[d]|0,g=(Ht(r,2)^Ht(r,13)^Ht(r,22))+Bw(r,i,n)|0;u=l,l=c,c=a,a=o+p|0,o=n,n=i,i=r,r=p+g|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(){bs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const mn=Cd(()=>new qw);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const po=BigInt(0),fo=BigInt(1),Ww=BigInt(2);function rr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function wn(t){if(!rr(t))throw new Error("Uint8Array expected")}function Hr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const zw=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Kr(t){wn(t);let e="";for(let s=0;s<t.length;s++)e+=zw[t[s]];return e}function xr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function sc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?po:BigInt("0x"+t)}const as={_0:48,_9:57,A:65,F:70,a:97,f:102};function hl(t){if(t>=as._0&&t<=as._9)return t-as._0;if(t>=as.A&&t<=as.F)return t-(as.A-10);if(t>=as.a&&t<=as.f)return t-(as.a-10)}function Vr(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=hl(t.charCodeAt(n)),a=hl(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 Zs(t){return sc(Kr(t))}function on(t){return wn(t),sc(Kr(Uint8Array.from(t).reverse()))}function Gr(t,e){return Vr(t.toString(16).padStart(e*2,"0"))}function go(t,e){return Gr(t,e).reverse()}function Hw(t){return Vr(xr(t))}function vt(t,e,s){let r;if(typeof e=="string")try{r=Vr(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(rr(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 an(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];wn(i),e+=i.length}const s=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const n=t[r];s.set(n,i),i+=n.length}return s}function Kw(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 Vw(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Ro=t=>typeof t=="bigint"&&po<=t;function mo(t,e,s){return Ro(t)&&Ro(e)&&Ro(s)&&e<=t&&t<s}function hs(t,e,s,r){if(!mo(e,s,r))throw new Error("expected valid "+t+": "+s+" <= n < "+r+", got "+e)}function Ud(t){let e;for(e=0;t>po;t>>=fo,e+=1);return e}function Gw(t,e){return t>>BigInt(e)&fo}function Jw(t,e,s){return t|(s?fo:po)<<BigInt(e)}const rc=t=>(Ww<<BigInt(t-1))-fo,Uo=t=>new Uint8Array(t),pl=t=>Uint8Array.from(t);function Dd(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=Uo(t),i=Uo(t),n=0;const o=()=>{r.fill(1),i.fill(0),n=0},a=(...u)=>s(i,r,...u),c=(u=Uo())=>{i=a(pl([0]),u),r=a(),u.length!==0&&(i=a(pl([1]),u),r=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){r=a();const h=r.slice();d.push(h),u+=r.length}return an(...d)};return(u,d)=>{o(),c(u);let h;for(;!(h=d(l()));)c();return o(),h}}const Yw={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"||rr(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 ri(t,e,s={}){const r=(i,n,o)=>{const a=Yw[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 Xw=()=>{throw new Error("not implemented")};function Ea(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 Zw=Object.freeze({__proto__:null,isBytes:rr,abytes:wn,abool:Hr,bytesToHex:Kr,numberToHexUnpadded:xr,hexToNumber:sc,hexToBytes:Vr,bytesToNumberBE:Zs,bytesToNumberLE:on,numberToBytesBE:Gr,numberToBytesLE:go,numberToVarBytesBE:Hw,ensureBytes:vt,concatBytes:an,equalBytes:Kw,utf8ToBytes:Vw,inRange:mo,aInRange:hs,bitLen:Ud,bitGet:Gw,bitSet:Jw,bitMask:rc,createHmacDrbg:Dd,validateObject:ri,notImplemented:Xw,memoized:Ea});const Ke=BigInt(0),Oe=BigInt(1),Ws=BigInt(2),Qw=BigInt(3),Ca=BigInt(4),fl=BigInt(5),gl=BigInt(8);function pt(t,e){const s=t%e;return s>=Ke?s:e+s}function Ld(t,e,s){if(e<Ke)throw new Error("invalid exponent, negatives unsupported");if(s<=Ke)throw new Error("invalid modulus");if(s===Oe)return Ke;let r=Oe;for(;e>Ke;)e&Oe&&(r=r*t%s),t=t*t%s,e>>=Oe;return r}function Bt(t,e,s){let r=t;for(;e-- >Ke;)r*=r,r%=s;return r}function Ia(t,e){if(t===Ke)throw new Error("invert: expected non-zero number");if(e<=Ke)throw new Error("invert: expected positive modulus, got "+e);let s=pt(t,e),r=e,i=Ke,n=Oe;for(;s!==Ke;){const o=r/s,a=r%s,c=i-n*o;r=s,s=a,i=n,n=c}if(r!==Oe)throw new Error("invert: does not exist");return pt(i,e)}function ey(t){const e=(t-Oe)/Ws;let s,r,i;for(s=t-Oe,r=0;s%Ws===Ke;s/=Ws,r++);for(i=Ws;i<t&&Ld(i,e,t)!==t-Oe;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(t+Oe)/Ca;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+Oe)/Ws;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),d=o.pow(a,s);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let h=1;for(let g=o.sqr(d);h<c&&!o.eql(g,o.ONE);h++)g=o.sqr(g);const p=o.pow(l,Oe<<BigInt(c-h-1));l=o.sqr(p),u=o.mul(u,p),d=o.mul(d,l),c=h}return u}}function ty(t){if(t%Ca===Qw){const e=(t+Oe)/Ca;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%gl===fl){const e=(t-fl)/gl;return function(s,r){const i=s.mul(r,Ws),n=s.pow(i,e),o=s.mul(r,n),a=s.mul(s.mul(o,Ws),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 ey(t)}const sy=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ry(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=sy.reduce((r,i)=>(r[i]="function",r),e);return ri(t,s)}function iy(t,e,s){if(s<Ke)throw new Error("invalid exponent, negatives unsupported");if(s===Ke)return t.ONE;if(s===Oe)return e;let r=t.ONE,i=e;for(;s>Ke;)s&Oe&&(r=t.mul(r,i)),i=t.sqr(i),s>>=Oe;return r}function ny(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 Md(t,e){const s=e!==void 0?e:t.toString(2).length,r=Math.ceil(s/8);return{nBitLength:s,nByteLength:r}}function Bd(t,e,s=!1,r={}){if(t<=Ke)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:n}=Md(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:n,MASK:rc(i),ZERO:Ke,ONE:Oe,create:c=>pt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Ke<=c&&c<t},is0:c=>c===Ke,isOdd:c=>(c&Oe)===Oe,neg:c=>pt(-c,t),eql:(c,l)=>c===l,sqr:c=>pt(c*c,t),add:(c,l)=>pt(c+l,t),sub:(c,l)=>pt(c-l,t),mul:(c,l)=>pt(c*l,t),pow:(c,l)=>iy(a,c,l),div:(c,l)=>pt(c*Ia(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ia(c,t),sqrt:r.sqrt||(c=>(o||(o=ty(t)),o(a,c))),invertBatch:c=>ny(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>s?go(c,n):Gr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return s?on(c):Zs(c)}});return Object.freeze(a)}function Fd(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 jd(t){const e=Fd(t);return e+Math.ceil(e/2)}function oy(t,e,s=!1){const r=t.length,i=Fd(e),n=jd(e);if(r<16||r<n||r>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+r);const o=s?on(t):Zs(t),a=pt(o,e-Oe)+Oe;return s?go(a,i):Gr(a,i)}const ml=BigInt(0),Rn=BigInt(1);function Do(t,e){const s=e.negate();return t?s:e}function qd(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Lo(t,e){qd(t,e);const s=Math.ceil(e/t)+1,r=2**(t-1);return{windows:s,windowSize:r}}function ay(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 cy(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,Wd=new WeakMap;function Bo(t){return Wd.get(t)||1}function ly(t,e){return{constTimeNegate:Do,hasPrecomputes(s){return Bo(s)!==1},unsafeLadder(s,r,i=t.ZERO){let n=s;for(;r>ml;)r&Rn&&(i=i.add(n)),n=n.double(),r>>=Rn;return i},precomputeWindow(s,r){const{windows:i,windowSize:n}=Lo(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}=Lo(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),u=2**s,d=BigInt(s);for(let h=0;h<n;h++){const p=h*o;let g=Number(i&l);i>>=d,g>o&&(g-=u,i+=Rn);const m=p,w=p+Math.abs(g)-1,y=h%2!==0,b=g<0;g===0?c=c.add(Do(y,r[m])):a=a.add(Do(b,r[w]))}return{p:a,f:c}},wNAFUnsafe(s,r,i,n=t.ZERO){const{windows:o,windowSize:a}=Lo(s,e),c=BigInt(2**s-1),l=2**s,u=BigInt(s);for(let d=0;d<o;d++){const h=d*a;if(i===ml)break;let p=Number(i&c);if(i>>=u,p>a&&(p-=l,i+=Rn),p===0)continue;let g=r[h+Math.abs(p)-1];p<0&&(g=g.negate()),n=n.add(g)}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=Bo(s);return this.wNAF(n,this.getPrecomputes(n,s,i),r)},wNAFCachedUnsafe(s,r,i,n){const o=Bo(s);return o===1?this.unsafeLadder(s,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),r,n)},setWindowSize(s,r){qd(r,e),Wd.set(s,r),Mo.delete(s)}}}function uy(t,e,s,r){if(ay(s,t),cy(r,e),s.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,n=Ud(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 d=l;d>=0;d-=o){c.fill(i);for(let p=0;p<r.length;p++){const g=r[p],m=Number(g>>BigInt(d)&BigInt(a));c[m]=c[m].add(s[p])}let h=i;for(let p=c.length-1,g=i;p>0;p--)g=g.add(c[p]),h=h.add(g);if(u=u.add(h),d!==0)for(let p=0;p<o;p++)u=u.double()}return u}function zd(t){return ry(t.Fp),ri(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Md(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const hr=BigInt(0),Fo=BigInt(1);function dy(t){return ri(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function hy(t){const e=dy(t),{P:s}=e,r=b=>pt(b,s),i=e.montgomeryBits,n=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>Ld(b,s-BigInt(2),s));function l(b,v,I){const S=r(b*(v-I));return v=r(v-S),I=r(I+S),[v,I]}const u=(e.a-BigInt(2))/BigInt(4);function d(b,v){hs("u",b,hr,s),hs("scalar",v,hr,s);const I=v,S=b;let A=Fo,_=hr,R=b,E=Fo,k=hr,C;for(let H=BigInt(i-1);H>=hr;H--){const N=I>>H&Fo;k^=N,C=l(k,A,R),A=C[0],R=C[1],C=l(k,_,E),_=C[0],E=C[1],k=N;const x=A+_,O=r(x*x),B=A-_,q=r(B*B),$=O-q,G=R+E,ee=R-E,re=r(ee*x),Ce=r(G*B),pe=re+Ce,Te=re-Ce;R=r(pe*pe),E=r(S*r(Te*Te)),A=r(O*q),_=r($*(O+r(u*$)))}C=l(k,A,R),A=C[0],R=C[1],C=l(k,_,E),_=C[0],E=C[1];const L=c(_);return r(A*L)}function h(b){return go(r(b),n)}function p(b){const v=vt("u coordinate",b,n);return o===32&&(v[31]&=127),on(v)}function g(b){const v=vt("scalar",b),I=v.length;if(I!==n&&I!==o){let S=""+n+" or "+o;throw new Error("invalid scalar, expected "+S+" bytes, got "+I)}return on(a(v))}function m(b,v){const I=p(v),S=g(b),A=d(I,S);if(A===hr)throw new Error("invalid private or public key received");return h(A)}const w=h(e.Gu);function y(b){return m(b,w)}return{scalarMult:m,scalarMultBase:y,getSharedSecret:(b,v)=>m(b,v),getPublicKey:b=>y(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:w}}const Aa=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const py=BigInt(1),wl=BigInt(2),fy=BigInt(3),gy=BigInt(5);BigInt(8);function my(t){const e=BigInt(10),s=BigInt(20),r=BigInt(40),i=BigInt(80),n=Aa,o=t*t%n*t%n,a=Bt(o,wl,n)*o%n,c=Bt(a,py,n)*t%n,l=Bt(c,gy,n)*c%n,u=Bt(l,e,n)*l%n,d=Bt(u,s,n)*u%n,h=Bt(d,r,n)*d%n,p=Bt(h,i,n)*h%n,g=Bt(p,i,n)*h%n,m=Bt(g,e,n)*l%n;return{pow_p_5_8:Bt(m,wl,n)*t%n,b2:o}}function wy(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const _a=hy({P:Aa,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Aa,{pow_p_5_8:s,b2:r}=my(t);return pt(Bt(s,fy,e)*r,e)},adjustScalarBytes:wy,randomBytes:si});function yl(t){t.lowS!==void 0&&Hr("lowS",t.lowS),t.prehash!==void 0&&Hr("prehash",t.prehash)}function yy(t){const e=zd(t);ri(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:by,hexToBytes:vy}=Zw;class Ey extends Error{constructor(e=""){super(e)}}const us={Err:Ey,_tlv:{encode:(t,e)=>{const{Err:s}=us;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=xr(r);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const n=r>127?xr(i.length/2|128):"";return xr(t)+n+i+e},decode(t,e){const{Err:s}=us;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}=us;if(t<ds)throw new e("integer: negative integers are not allowed");let s=xr(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}=us;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 by(t)}},toSig(t){const{Err:e,_int:s,_tlv:r}=us,i=typeof t=="string"?vy(t):t;wn(i);const{v:n,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,n),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=us,r=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),n=r+i;return e.encode(48,n)}},ds=BigInt(0),qe=BigInt(1);BigInt(2);const bl=BigInt(3);BigInt(4);function Cy(t){const e=yy(t),{Fp:s}=e,r=Bd(e.n,e.nBitLength),i=e.toBytes||((m,w,y)=>{const b=w.toAffine();return an(Uint8Array.from([4]),s.toBytes(b.x),s.toBytes(b.y))}),n=e.fromBytes||(m=>{const w=m.subarray(1),y=s.fromBytes(w.subarray(0,s.BYTES)),b=s.fromBytes(w.subarray(s.BYTES,2*s.BYTES));return{x:y,y:b}});function o(m){const{a:w,b:y}=e,b=s.sqr(m),v=s.mul(b,m);return s.add(s.add(v,s.mul(m,w)),y)}if(!s.eql(s.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return mo(m,qe,e.n)}function c(m){const{allowedPrivateKeyLengths:w,nByteLength:y,wrapPrivateKey:b,n:v}=e;if(w&&typeof m!="bigint"){if(rr(m)&&(m=Kr(m)),typeof m!="string"||!w.includes(m.length))throw new Error("invalid private key");m=m.padStart(y*2,"0")}let I;try{I=typeof m=="bigint"?m:Zs(vt("private key",m,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof m)}return b&&(I=pt(I,v)),hs("private key",I,qe,v),I}function l(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}const u=Ea((m,w)=>{const{px:y,py:b,pz:v}=m;if(s.eql(v,s.ONE))return{x:y,y:b};const I=m.is0();w==null&&(w=I?s.ONE:s.inv(v));const S=s.mul(y,w),A=s.mul(b,w),_=s.mul(v,w);if(I)return{x:s.ZERO,y:s.ZERO};if(!s.eql(_,s.ONE))throw new Error("invZ was invalid");return{x:S,y:A}}),d=Ea(m=>{if(m.is0()){if(e.allowInfinityPoint&&!s.is0(m.py))return;throw new Error("bad point: ZERO")}const{x:w,y}=m.toAffine();if(!s.isValid(w)||!s.isValid(y))throw new Error("bad point: x or y not FE");const b=s.sqr(y),v=o(w);if(!s.eql(b,v))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(w,y,b){if(this.px=w,this.py=y,this.pz=b,w==null||!s.isValid(w))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(w){const{x:y,y:b}=w||{};if(!w||!s.isValid(y)||!s.isValid(b))throw new Error("invalid affine point");if(w instanceof h)throw new Error("projective point not allowed");const v=I=>s.eql(I,s.ZERO);return v(y)&&v(b)?h.ZERO:new h(y,b,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const y=s.invertBatch(w.map(b=>b.pz));return w.map((b,v)=>b.toAffine(y[v])).map(h.fromAffine)}static fromHex(w){const y=h.fromAffine(n(vt("pointHex",w)));return y.assertValidity(),y}static fromPrivateKey(w){return h.BASE.multiply(c(w))}static msm(w,y){return uy(h,r,w,y)}_setWindowSize(w){g.setWindowSize(this,w)}assertValidity(){d(this)}hasEvenY(){const{y:w}=this.toAffine();if(s.isOdd)return!s.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){l(w);const{px:y,py:b,pz:v}=this,{px:I,py:S,pz:A}=w,_=s.eql(s.mul(y,A),s.mul(I,v)),R=s.eql(s.mul(b,A),s.mul(S,v));return _&&R}negate(){return new h(this.px,s.neg(this.py),this.pz)}double(){const{a:w,b:y}=e,b=s.mul(y,bl),{px:v,py:I,pz:S}=this;let A=s.ZERO,_=s.ZERO,R=s.ZERO,E=s.mul(v,v),k=s.mul(I,I),C=s.mul(S,S),L=s.mul(v,I);return L=s.add(L,L),R=s.mul(v,S),R=s.add(R,R),A=s.mul(w,R),_=s.mul(b,C),_=s.add(A,_),A=s.sub(k,_),_=s.add(k,_),_=s.mul(A,_),A=s.mul(L,A),R=s.mul(b,R),C=s.mul(w,C),L=s.sub(E,C),L=s.mul(w,L),L=s.add(L,R),R=s.add(E,E),E=s.add(R,E),E=s.add(E,C),E=s.mul(E,L),_=s.add(_,E),C=s.mul(I,S),C=s.add(C,C),E=s.mul(C,L),A=s.sub(A,E),R=s.mul(C,k),R=s.add(R,R),R=s.add(R,R),new h(A,_,R)}add(w){l(w);const{px:y,py:b,pz:v}=this,{px:I,py:S,pz:A}=w;let _=s.ZERO,R=s.ZERO,E=s.ZERO;const k=e.a,C=s.mul(e.b,bl);let L=s.mul(y,I),H=s.mul(b,S),N=s.mul(v,A),x=s.add(y,b),O=s.add(I,S);x=s.mul(x,O),O=s.add(L,H),x=s.sub(x,O),O=s.add(y,v);let B=s.add(I,A);return O=s.mul(O,B),B=s.add(L,N),O=s.sub(O,B),B=s.add(b,v),_=s.add(S,A),B=s.mul(B,_),_=s.add(H,N),B=s.sub(B,_),E=s.mul(k,O),_=s.mul(C,N),E=s.add(_,E),_=s.sub(H,E),E=s.add(H,E),R=s.mul(_,E),H=s.add(L,L),H=s.add(H,L),N=s.mul(k,N),O=s.mul(C,O),H=s.add(H,N),N=s.sub(L,N),N=s.mul(k,N),O=s.add(O,N),L=s.mul(H,O),R=s.add(R,L),L=s.mul(B,O),_=s.mul(x,_),_=s.sub(_,L),L=s.mul(x,H),E=s.mul(B,E),E=s.add(E,L),new h(_,R,E)}subtract(w){return this.add(w.negate())}is0(){return this.equals(h.ZERO)}wNAF(w){return g.wNAFCached(this,w,h.normalizeZ)}multiplyUnsafe(w){const{endo:y,n:b}=e;hs("scalar",w,ds,b);const v=h.ZERO;if(w===ds)return v;if(this.is0()||w===qe)return this;if(!y||g.hasPrecomputes(this))return g.wNAFCachedUnsafe(this,w,h.normalizeZ);let{k1neg:I,k1:S,k2neg:A,k2:_}=y.splitScalar(w),R=v,E=v,k=this;for(;S>ds||_>ds;)S&qe&&(R=R.add(k)),_&qe&&(E=E.add(k)),k=k.double(),S>>=qe,_>>=qe;return I&&(R=R.negate()),A&&(E=E.negate()),E=new h(s.mul(E.px,y.beta),E.py,E.pz),R.add(E)}multiply(w){const{endo:y,n:b}=e;hs("scalar",w,qe,b);let v,I;if(y){const{k1neg:S,k1:A,k2neg:_,k2:R}=y.splitScalar(w);let{p:E,f:k}=this.wNAF(A),{p:C,f:L}=this.wNAF(R);E=g.constTimeNegate(S,E),C=g.constTimeNegate(_,C),C=new h(s.mul(C.px,y.beta),C.py,C.pz),v=E.add(C),I=k.add(L)}else{const{p:S,f:A}=this.wNAF(w);v=S,I=A}return h.normalizeZ([v,I])[0]}multiplyAndAddUnsafe(w,y,b){const v=h.BASE,I=(A,_)=>_===ds||_===qe||!A.equals(v)?A.multiplyUnsafe(_):A.multiply(_),S=I(this,y).add(I(w,b));return S.is0()?void 0:S}toAffine(w){return u(this,w)}isTorsionFree(){const{h:w,isTorsionFree:y}=e;if(w===qe)return!0;if(y)return y(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:y}=e;return w===qe?this:y?y(h,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return Hr("isCompressed",w),this.assertValidity(),i(h,this,w)}toHex(w=!0){return Hr("isCompressed",w),Kr(this.toRawBytes(w))}}h.BASE=new h(e.Gx,e.Gy,s.ONE),h.ZERO=new h(s.ZERO,s.ONE,s.ZERO);const p=e.nBitLength,g=ly(h,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Iy(t){const e=zd(t);return ri(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ay(t){const e=Iy(t),{Fp:s,n:r}=e,i=s.BYTES+1,n=2*s.BYTES+1;function o(N){return pt(N,r)}function a(N){return Ia(N,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:d}=Cy({...e,toBytes(N,x,O){const B=x.toAffine(),q=s.toBytes(B.x),$=an;return Hr("isCompressed",O),O?$(Uint8Array.from([x.hasEvenY()?2:3]),q):$(Uint8Array.from([4]),q,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 q=Zs(B);if(!mo(q,qe,s.ORDER))throw new Error("Point is not on curve");const $=u(q);let G;try{G=s.sqrt($)}catch(re){const Ce=re instanceof Error?": "+re.message:"";throw new Error("Point is not on curve"+Ce)}const ee=(G&qe)===qe;return(O&1)===1!==ee&&(G=s.neg(G)),{x:q,y:G}}else if(x===n&&O===4){const q=s.fromBytes(B.subarray(0,s.BYTES)),$=s.fromBytes(B.subarray(s.BYTES,2*s.BYTES));return{x:q,y:$}}else{const q=i,$=n;throw new Error("invalid Point, expected length of "+q+", or uncompressed "+$+", got "+x)}}}),h=N=>Kr(Gr(N,e.nByteLength));function p(N){const x=r>>qe;return N>x}function g(N){return p(N)?o(-N):N}const m=(N,x,O)=>Zs(N.slice(x,O));class w{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 w(m(x,0,O),m(x,O,2*O))}static fromDER(x){const{r:O,s:B}=us.toSig(vt("DER",x));return new w(O,B)}assertValidity(){hs("r",this.r,qe,r),hs("s",this.s,qe,r)}addRecoveryBit(x){return new w(this.r,this.s,x)}recoverPublicKey(x){const{r:O,s:B,recovery:q}=this,$=A(vt("msgHash",x));if(q==null||![0,1,2,3].includes(q))throw new Error("recovery id invalid");const G=q===2||q===3?O+e.n:O;if(G>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const ee=q&1?"03":"02",re=c.fromHex(ee+h(G)),Ce=a(G),pe=o(-$*Ce),Te=o(B*Ce),Me=c.BASE.multiplyAndAddUnsafe(re,pe,Te);if(!Me)throw new Error("point at infinify");return Me.assertValidity(),Me}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Vr(this.toDERHex())}toDERHex(){return us.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Vr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(N){try{return l(N),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const N=jd(e.n);return oy(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=rr(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 I(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 S=e.bits2int||function(N){if(N.length>8192)throw new Error("input is too large");const x=Zs(N),O=N.length*8-e.nBitLength;return O>0?x>>BigInt(O):x},A=e.bits2int_modN||function(N){return o(S(N))},_=rc(e.nBitLength);function R(N){return hs("num < 2^"+e.nBitLength,N,ds,_),Gr(N,e.nByteLength)}function E(N,x,O=k){if(["recovered","canonical"].some(ke=>ke in O))throw new Error("sign() legacy options not supported");const{hash:B,randomBytes:q}=e;let{lowS:$,prehash:G,extraEntropy:ee}=O;$==null&&($=!0),N=vt("msgHash",N),yl(O),G&&(N=vt("prehashed msgHash",B(N)));const re=A(N),Ce=l(x),pe=[R(Ce),R(re)];if(ee!=null&&ee!==!1){const ke=ee===!0?q(s.BYTES):ee;pe.push(vt("extraEntropy",ke))}const Te=an(...pe),Me=re;function Qe(ke){const Re=S(ke);if(!d(Re))return;const Us=a(Re),ts=c.BASE.multiply(Re).toAffine(),zt=o(ts.x);if(zt===ds)return;const ss=o(Us*o(Me+zt*Ce));if(ss===ds)return;let rs=(ts.x===zt?0:2)|Number(ts.y&qe),In=ss;return $&&p(ss)&&(In=g(ss),rs^=1),new w(zt,In,rs)}return{seed:Te,k2sig:Qe}}const k={lowS:e.lowS,prehash:!1},C={lowS:e.lowS,prehash:!1};function L(N,x,O=k){const{seed:B,k2sig:q}=E(N,x,O),$=e;return Dd($.hash.outputLen,$.nByteLength,$.hmac)(B,q)}c.BASE._setWindowSize(8);function H(N,x,O,B=C){var ss;const q=N;x=vt("msgHash",x),O=vt("publicKey",O);const{lowS:$,prehash:G,format:ee}=B;if(yl(B),"strict"in B)throw new Error("options.strict was renamed to lowS");if(ee!==void 0&&ee!=="compact"&&ee!=="der")throw new Error("format must be compact or der");const re=typeof q=="string"||rr(q),Ce=!re&&!ee&&typeof q=="object"&&q!==null&&typeof q.r=="bigint"&&typeof q.s=="bigint";if(!re&&!Ce)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let pe,Te;try{if(Ce&&(pe=new w(q.r,q.s)),re){try{ee!=="compact"&&(pe=w.fromDER(q))}catch(rs){if(!(rs instanceof us.Err))throw rs}!pe&&ee!=="der"&&(pe=w.fromCompact(q))}Te=c.fromHex(O)}catch{return!1}if(!pe||$&&pe.hasHighS())return!1;G&&(x=e.hash(x));const{r:Me,s:Qe}=pe,ke=A(x),Re=a(Qe),Us=o(ke*Re),ts=o(Me*Re),zt=(ss=c.BASE.multiplyAndAddUnsafe(Te,Us,ts))==null?void 0:ss.toAffine();return zt?o(zt.x)===Me:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:I,sign:L,verify:H,ProjectivePoint:c,Signature:w,utils:y}}function _y(t){return{hash:t,hmac:(e,...s)=>ho(t,e,Om(...s)),randomBytes:si}}function Ny(t,e){const s=r=>Ay({...t,..._y(r)});return{...s(e),create:s}}const Hd=Bd(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Sy=Hd.create(BigInt("-3")),Py=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Oy=Ny({a:Sy,b:Py,Fp:Hd,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},mn),Kd="base10",it="base16",qt="base64pad",Cs="base64url",yn="utf8",Vd=0,ps=1,bn=2,Ty=0,vl=1,Oi=12,ic=32;function xy(){const t=_a.utils.randomPrivateKey(),e=_a.getPublicKey(t);return{privateKey:ft(t,it),publicKey:ft(e,it)}}function Na(){const t=si(ic);return ft(t,it)}function $y(t,e){const s=_a.getSharedSecret(kt(t,it),kt(e,it)),r=Dw(mn,s,void 0,void 0,ic);return ft(r,it)}function Kn(t){const e=mn(kt(t,it));return ft(e,it)}function Xt(t){const e=mn(kt(t,yn));return ft(e,it)}function Gd(t){return kt(`${t}`,Kd)}function ir(t){return Number(ft(t,Kd))}function Jd(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Yd(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function ky(t){const e=Gd(typeof t.type<"u"?t.type:Vd);if(ir(e)===ps&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?kt(t.senderPublicKey,it):void 0,r=typeof t.iv<"u"?kt(t.iv,it):si(Oi),i=kt(t.symKey,it),n=kd(i,r).encrypt(kt(t.message,yn)),o=Xd({type:e,sealed:n,iv:r,senderPublicKey:s});return t.encoding===Cs?Jd(o):o}function Ry(t){const e=kt(t.symKey,it),{sealed:s,iv:r}=cn({encoded:t.encoded,encoding:t.encoding}),i=kd(e,r).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return ft(i,yn)}function Uy(t,e){const s=Gd(bn),r=si(Oi),i=kt(t,yn),n=Xd({type:s,sealed:i,iv:r});return e===Cs?Jd(n):n}function Dy(t,e){const{sealed:s}=cn({encoded:t,encoding:e});return ft(s,yn)}function Xd(t){if(ir(t.type)===bn)return ft(Pi([t.type,t.sealed]),qt);if(ir(t.type)===ps){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(Pi([t.type,t.senderPublicKey,t.iv,t.sealed]),qt)}return ft(Pi([t.type,t.iv,t.sealed]),qt)}function cn(t){const e=(t.encoding||qt)===Cs?Yd(t.encoded):t.encoded,s=kt(e,qt),r=s.slice(Ty,vl),i=vl;if(ir(r)===ps){const c=i+ic,l=c+Oi,u=s.slice(i,c),d=s.slice(c,l),h=s.slice(l);return{type:r,sealed:h,iv:d,senderPublicKey:u}}if(ir(r)===bn){const c=s.slice(i),l=si(Oi);return{type:r,sealed:c,iv:l}}const n=i+Oi,o=s.slice(i,n),a=s.slice(n);return{type:r,sealed:a,iv:o}}function Ly(t,e){const s=cn({encoded:t,encoding:e==null?void 0:e.encoding});return Zd({type:ir(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?ft(s.senderPublicKey,it):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Zd(t){const e=(t==null?void 0:t.type)||Vd;if(e===ps){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 El(t){return t.type===ps&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Cl(t){return t.type===bn}function My(t){const e=Ve.from(t.x,"base64"),s=Ve.from(t.y,"base64");return Pi([new Uint8Array([4]),e,s])}function By(t,e){const[s,r,i]=t.split("."),n=Ve.from(Yd(i),"base64");if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=`${s}.${r}`,l=mn(c),u=My(e);if(!Oy.verify(Pi([o,a]),l,u))throw new Error("Invalid signature");return na(t).payload}const Fy="irn";function ro(t){return(t==null?void 0:t.relay)||{protocol:Fy}}function vi(t){const e=Jh[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function jy(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 Il(t){if(!t.includes("wc:")){const l=vd(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:qy(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:jy(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function qy(t){return t.startsWith("//")?t.substring(2):t}function Wy(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 Al(t){const e=new URLSearchParams,s=Wy(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 Un(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var zy=Object.defineProperty,Hy=Object.defineProperties,Ky=Object.getOwnPropertyDescriptors,_l=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Gy=Object.prototype.propertyIsEnumerable,Nl=(t,e,s)=>e in t?zy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Jy=(t,e)=>{for(var s in e||(e={}))Vy.call(e,s)&&Nl(t,s,e[s]);if(_l)for(var s of _l(e))Gy.call(e,s)&&Nl(t,s,e[s]);return t},Yy=(t,e)=>Hy(t,Ky(e));function ii(t){const e=[];return t.forEach(s=>{const[r,i]=s.split(":");e.push(`${r}:${i}`)}),e}function Xy(t){const e=[];return Object.values(t).forEach(s=>{e.push(...ii(s.accounts))}),e}function Zy(t,e){const s=[];return Object.values(t).forEach(r=>{ii(r.accounts).includes(e)&&s.push(...r.methods)}),s}function Qy(t,e){const s=[];return Object.values(t).forEach(r=>{ii(r.accounts).includes(e)&&s.push(...r.events)}),s}function wo(t){return t.includes(":")}function $r(t){return wo(t)?t.split(":")[0]:t}function Sl(t){var e,s,r;const i={};if(!Ts(t))return i;for(const[n,o]of Object.entries(t)){const a=wo(n)?[n]:o.chains,c=o.methods||[],l=o.events||[],u=$r(n);i[u]=Yy(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 eb(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 Pl(t,e){e=e.map(r=>r.replace("did:pkh:",""));const s=eb(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 tb(t,e){var s,r,i,n,o,a;const c=Sl(t),l=Sl(e),u={},d=Object.keys(c).concat(Object.keys(l));for(const h of d)u[h]={chains:Zt((s=c[h])==null?void 0:s.chains,(r=l[h])==null?void 0:r.chains),methods:Zt((i=c[h])==null?void 0:i.methods,(n=l[h])==null?void 0:n.methods),events:Zt((o=c[h])==null?void 0:o.events,(a=l[h])==null?void 0:a.events)};return u}const sb={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}},rb={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 U(t,e){const{message:s,code:r}=rb[t];return{message:e?`${s} ${e}`:s,code:r}}function we(t,e){const{message:s,code:r}=sb[t];return{message:e?`${s} ${e}`:s,code:r}}function Os(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Ts(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Xe(t){return typeof t>"u"}function $e(t,e){return e&&Xe(t)?!0:typeof t=="string"&&!!t.trim().length}function nc(t,e){return e&&Xe(t)?!0:typeof t=="number"&&!isNaN(t)}function ib(t,e){const{requiredNamespaces:s}=e,r=Object.keys(t.namespaces),i=Object.keys(s);let n=!0;return Gs(i,r)?(r.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=ii(a),d=s[o];(!Gs(gd(o,d),u)||!Gs(d.methods,c)||!Gs(d.events,l))&&(n=!1)}),n):!1}function io(t){return $e(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function nb(t){if($e(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&io(s)}}return!1}function ob(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if($e(t,!1)){if(e(t))return!0;const s=vd(t);return e(s)}}catch{}return!1}function ab(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function cb(t){return t==null?void 0:t.topic}function lb(t,e){let s=null;return $e(t==null?void 0:t.publicKey,!1)||(s=U("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function Ol(t){let e=!0;return Os(t)?t.length&&(e=t.every(s=>$e(s,!1))):e=!1,e}function ub(t,e,s){let r=null;return Os(e)&&e.length?e.forEach(i=>{r||io(i)||(r=we("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):io(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 db(t,e,s){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const o=ub(i,gd(i,n),`${e} ${s}`);o&&(r=o)}),r}function hb(t,e){let s=null;return Os(t)?t.forEach(r=>{s||nb(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 pb(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=hb(r==null?void 0:r.accounts,`${e} namespace`);i&&(s=i)}),s}function fb(t,e){let s=null;return Ol(t==null?void 0:t.methods)?Ol(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 Qd(t,e){let s=null;return Object.values(t).forEach(r=>{if(s)return;const i=fb(r,`${e}, namespace`);i&&(s=i)}),s}function gb(t,e,s){let r=null;if(t&&Ts(t)){const i=Qd(t,e);i&&(r=i);const n=db(t,e,s);n&&(r=n)}else r=U("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return r}function jo(t,e){let s=null;if(t&&Ts(t)){const r=Qd(t,e);r&&(s=r);const i=pb(t,e);i&&(s=i)}else s=U("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function eh(t){return $e(t.protocol,!0)}function mb(t,e){let s=!1;return e&&!t?s=!0:t&&Os(t)&&t.length&&t.forEach(r=>{s=eh(r)}),s}function wb(t){return typeof t=="number"}function ht(t){return typeof t<"u"&&typeof t!==null}function yb(t){return!(!t||typeof t!="object"||!t.code||!nc(t.code,!1)||!t.message||!$e(t.message,!1))}function bb(t){return!(Xe(t)||!$e(t.method,!1))}function vb(t){return!(Xe(t)||Xe(t.result)&&Xe(t.error)||!nc(t.id,!1)||!$e(t.jsonrpc,!1))}function Eb(t){return!(Xe(t)||!$e(t.name,!1))}function Tl(t,e){return!(!io(e)||!Xy(t).includes(e))}function Cb(t,e,s){return $e(s,!1)?Zy(t,e).includes(s):!1}function Ib(t,e,s){return $e(s,!1)?Qy(t,e).includes(s):!1}function xl(t,e,s){let r=null;const i=Ab(t),n=_b(e),o=Object.keys(i),a=Object.keys(n),c=$l(Object.keys(t)),l=$l(Object.keys(e)),u=c.filter(d=>!l.includes(d));return u.length&&(r=U("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.
|
|
11
|
-
Required: ${u.toString()}
|
|
12
|
-
Received: ${Object.keys(e).toString()}`)),Gs(o,a)||(r=U("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.
|
|
13
|
-
Required: ${o.toString()}
|
|
14
|
-
Approved: ${a.toString()}`)),Object.keys(e).forEach(d=>{if(!d.includes(":")||r)return;const h=ii(e[d].accounts);h.includes(d)||(r=U("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${d}
|
|
15
|
-
Required: ${d}
|
|
16
|
-
Approved: ${h.toString()}`))}),o.forEach(d=>{r||(Gs(i[d].methods,n[d].methods)?Gs(i[d].events,n[d].events)||(r=U("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${d}`)):r=U("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${d}`))}),r}function Ab(t){const e={};return Object.keys(t).forEach(s=>{var r;s.includes(":")?e[s]=t[s]:(r=t[s].chains)==null||r.forEach(i=>{e[i]={methods:t[s].methods,events:t[s].events}})}),e}function $l(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function _b(t){const e={};return Object.keys(t).forEach(s=>{if(s.includes(":"))e[s]=t[s];else{const r=ii(t[s].accounts);r==null||r.forEach(i=>{e[i]={accounts:t[s].accounts.filter(n=>n.includes(`${i}:`)),methods:t[s].methods,events:t[s].events}})}}),e}function Nb(t,e){return nc(t,!1)&&t<=e.max&&t>=e.min}function kl(){const t=fn();return new Promise(e=>{switch(t){case Ct.browser:e(Sb());break;case Ct.reactNative:e(Pb());break;case Ct.node:e(Ob());break;default:e(!0)}})}function Sb(){return ti()&&(navigator==null?void 0:navigator.onLine)}async function Pb(){if(Rs()&&typeof Q<"u"&&Q!=null&&Q.NetInfo){const t=await(Q==null?void 0:Q.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function Ob(){return!0}function Tb(t){switch(fn()){case Ct.browser:xb(t);break;case Ct.reactNative:$b(t);break}}function xb(t){!Rs()&&ti()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function $b(t){var e;Rs()&&typeof Q<"u"&&Q!=null&&Q.NetInfo&&((e=Q)==null||e.NetInfo.addEventListener(s=>t(s==null?void 0:s.isConnected)))}function kb(){var t;return ti()&&Lr()?((t=Lr())==null?void 0:t.visibilityState)==="visible":!0}const qo={};class di{static get(e){return qo[e]}static set(e,s){qo[e]=s}static delete(e){delete qo[e]}}const th="wc",sh=2,no="core",Qt=`${th}@2:${no}:`,Rb={name:no,logger:"error"},Ub={database:":memory:"},Db="crypto",Rl="client_ed25519_seed",Lb=D.ONE_DAY,Mb="keychain",Bb="0.3",Fb="messages",jb="0.3",Ul=D.SIX_HOURS,qb="publisher",rh="irn",Wb="error",ih="wss://relay.walletconnect.org",zb="relayer",We={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Hb="_subscription",Ot={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Kb=.1,Sa="2.21.0",_e={link_mode:"link_mode",relay:"relay"},Vn={inbound:"inbound",outbound:"outbound"},Vb="0.3",Gb="WALLETCONNECT_CLIENT_ID",Dl="WALLETCONNECT_LINK_MODE_APPS",yt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Jb="subscription",Yb="0.3",Xb="pairing",Zb="0.3",hi={wc_pairingDelete:{req:{ttl:D.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:D.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:D.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:D.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:D.ONE_DAY,prompt:!1,tag:0},res:{ttl:D.ONE_DAY,prompt:!1,tag:0}}},zs={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Dt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Qb="history",e0="0.3",t0="expirer",$t={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},s0="0.3",r0="verify-api",i0="https://verify.walletconnect.com",nh="https://verify.walletconnect.org",Ti=nh,n0=`${Ti}/v3`,o0=[i0,nh],a0="echo",c0="https://echo.walletconnect.com",Gt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ls={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Lt={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Ms={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},pi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},l0=.1,u0="event-client",d0=86400,h0="https://pulse.walletconnect.org/batch";function p0(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),r=0;r<s.length;r++)s[r]=255;for(var i=0;i<t.length;i++){var n=t.charAt(i),o=n.charCodeAt(0);if(s[o]!==255)throw new TypeError(n+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var m=0,w=0,y=0,b=g.length;y!==b&&g[y]===0;)y++,m++;for(var v=(b-y)*u+1>>>0,I=new Uint8Array(v);y!==b;){for(var S=g[y],A=0,_=v-1;(S!==0||A<w)&&_!==-1;_--,A++)S+=256*I[_]>>>0,I[_]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");w=A,y++}for(var R=v-w;R!==v&&I[R]===0;)R++;for(var E=c.repeat(m);R<v;++R)E+=t.charAt(I[R]);return E}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var m=0;if(g[m]!==" "){for(var w=0,y=0;g[m]===c;)w++,m++;for(var b=(g.length-m)*l+1>>>0,v=new Uint8Array(b);g[m];){var I=s[g.charCodeAt(m)];if(I===255)return;for(var S=0,A=b-1;(I!==0||S<y)&&A!==-1;A--,S++)I+=a*v[A]>>>0,v[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");y=S,m++}if(g[m]!==" "){for(var _=b-y;_!==b&&v[_]===0;)_++;for(var R=new Uint8Array(w+(b-_)),E=w;_!==b;)R[E++]=v[_++];return R}}}function p(g){var m=h(g);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:p}}var f0=p0,g0=f0;const oh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},m0=t=>new TextEncoder().encode(t),w0=t=>new TextDecoder().decode(t);class y0{constructor(e,s,r){this.name=e,this.prefix=s,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class b0{constructor(e,s,r){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ah(this,e)}}class v0{constructor(e){this.decoders=e}or(e){return ah(this,e)}decode(e){const s=e[0],r=this.decoders[s];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ah=(t,e)=>new v0({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class E0{constructor(e,s,r,i){this.name=e,this.prefix=s,this.baseEncode=r,this.baseDecode=i,this.encoder=new y0(e,s,r),this.decoder=new b0(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const yo=({name:t,prefix:e,encode:s,decode:r})=>new E0(t,e,s,r),vn=({prefix:t,name:e,alphabet:s})=>{const{encode:r,decode:i}=g0(s,e);return yo({prefix:t,name:e,encode:r,decode:n=>oh(i(n))})},C0=(t,e,s,r)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,l=0;for(let u=0;u<n;++u){const d=i[t[u]];if(d===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<s|d,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},I0=(t,e,s)=>{const r=e[e.length-1]==="=",i=(1<<s)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,n+=e[i&a>>o];if(o&&(n+=e[i&a<<s-o]),r)for(;n.length*s&7;)n+="=";return n},Ze=({name:t,prefix:e,bitsPerChar:s,alphabet:r})=>yo({prefix:e,name:t,encode(i){return I0(i,r,s)},decode(i){return C0(i,r,s,t)}}),A0=yo({prefix:"\0",name:"identity",encode:t=>w0(t),decode:t=>m0(t)});var _0=Object.freeze({__proto__:null,identity:A0});const N0=Ze({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var S0=Object.freeze({__proto__:null,base2:N0});const P0=Ze({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var O0=Object.freeze({__proto__:null,base8:P0});const T0=vn({prefix:"9",name:"base10",alphabet:"0123456789"});var x0=Object.freeze({__proto__:null,base10:T0});const $0=Ze({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),k0=Ze({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var R0=Object.freeze({__proto__:null,base16:$0,base16upper:k0});const U0=Ze({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),D0=Ze({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),L0=Ze({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),M0=Ze({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),B0=Ze({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),F0=Ze({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),j0=Ze({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),q0=Ze({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),W0=Ze({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var z0=Object.freeze({__proto__:null,base32:U0,base32upper:D0,base32pad:L0,base32padupper:M0,base32hex:B0,base32hexupper:F0,base32hexpad:j0,base32hexpadupper:q0,base32z:W0});const H0=vn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),K0=vn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var V0=Object.freeze({__proto__:null,base36:H0,base36upper:K0});const G0=vn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),J0=vn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Y0=Object.freeze({__proto__:null,base58btc:G0,base58flickr:J0});const X0=Ze({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Z0=Ze({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Q0=Ze({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ev=Ze({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tv=Object.freeze({__proto__:null,base64:X0,base64pad:Z0,base64url:Q0,base64urlpad:ev});const ch=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),sv=ch.reduce((t,e,s)=>(t[s]=e,t),[]),rv=ch.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function iv(t){return t.reduce((e,s)=>(e+=sv[s],e),"")}function nv(t){const e=[];for(const s of t){const r=rv[s.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(r)}return new Uint8Array(e)}const ov=yo({prefix:"🚀",name:"base256emoji",encode:iv,decode:nv});var av=Object.freeze({__proto__:null,base256emoji:ov}),cv=lh,Ll=128,lv=127,uv=~lv,dv=Math.pow(2,31);function lh(t,e,s){e=e||[],s=s||0;for(var r=s;t>=dv;)e[s++]=t&255|Ll,t/=128;for(;t&uv;)e[s++]=t&255|Ll,t>>>=7;return e[s]=t|0,lh.bytes=s-r+1,e}var hv=Pa,pv=128,Ml=127;function Pa(t,r){var s=0,r=r||0,i=0,n=r,o,a=t.length;do{if(n>=a)throw Pa.bytes=0,new RangeError("Could not decode varint");o=t[n++],s+=i<28?(o&Ml)<<i:(o&Ml)*Math.pow(2,i),i+=7}while(o>=pv);return Pa.bytes=n-r,s}var fv=Math.pow(2,7),gv=Math.pow(2,14),mv=Math.pow(2,21),wv=Math.pow(2,28),yv=Math.pow(2,35),bv=Math.pow(2,42),vv=Math.pow(2,49),Ev=Math.pow(2,56),Cv=Math.pow(2,63),Iv=function(t){return t<fv?1:t<gv?2:t<mv?3:t<wv?4:t<yv?5:t<bv?6:t<vv?7:t<Ev?8:t<Cv?9:10},Av={encode:cv,decode:hv,encodingLength:Iv},uh=Av;const Bl=(t,e,s=0)=>(uh.encode(t,e,s),e),Fl=t=>uh.encodingLength(t),Oa=(t,e)=>{const s=e.byteLength,r=Fl(t),i=r+Fl(s),n=new Uint8Array(i+s);return Bl(t,n,0),Bl(s,n,r),n.set(e,i),new _v(t,s,e,n)};class _v{constructor(e,s,r,i){this.code=e,this.size=s,this.digest=r,this.bytes=i}}const dh=({name:t,code:e,encode:s})=>new Nv(t,e,s);class Nv{constructor(e,s,r){this.name=e,this.code=s,this.encode=r}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?Oa(this.code,s):s.then(r=>Oa(this.code,r))}else throw Error("Unknown type, must be binary type")}}const hh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Sv=dh({name:"sha2-256",code:18,encode:hh("SHA-256")}),Pv=dh({name:"sha2-512",code:19,encode:hh("SHA-512")});var Ov=Object.freeze({__proto__:null,sha256:Sv,sha512:Pv});const ph=0,Tv="identity",fh=oh,xv=t=>Oa(ph,fh(t)),$v={code:ph,name:Tv,encode:fh,digest:xv};var kv=Object.freeze({__proto__:null,identity:$v});new TextEncoder,new TextDecoder;const jl={..._0,...S0,...O0,...x0,...R0,...z0,...V0,...Y0,...tv,...av};({...Ov,...kv});function Rv(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function gh(t,e,s,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:r}}}const ql=gh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Wo=gh("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=Rv(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Uv={utf8:ql,"utf-8":ql,hex:jl.base16,latin1:Wo,ascii:Wo,binary:Wo,...jl};function Dv(t,e="utf8"){const s=Uv[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):s.decoder.decode(`${s.prefix}${t}`)}var Lv=Object.defineProperty,Mv=(t,e,s)=>e in t?Lv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Kt=(t,e,s)=>Mv(t,typeof e!="symbol"?e+"":e,s);class Bv{constructor(e,s){this.core=e,this.logger=s,Kt(this,"keychain",new Map),Kt(this,"name",Mb),Kt(this,"version",Bb),Kt(this,"initialized",!1),Kt(this,"storagePrefix",Qt),Kt(this,"init",async()=>{if(!this.initialized){const r=await this.getKeyChain();typeof r<"u"&&(this.keychain=r),this.initialized=!0}}),Kt(this,"has",r=>(this.isInitialized(),this.keychain.has(r))),Kt(this,"set",async(r,i)=>{this.isInitialized(),this.keychain.set(r,i),await this.persist()}),Kt(this,"get",r=>{this.isInitialized();const i=this.keychain.get(r);if(typeof i>"u"){const{message:n}=U("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}),Kt(this,"del",async r=>{this.isInitialized(),this.keychain.delete(r),await this.persist()}),this.core=e,this.logger=nt(s,this.name)}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ga(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ma(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Fv=Object.defineProperty,jv=(t,e,s)=>e in t?Fv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Je=(t,e,s)=>jv(t,typeof e!="symbol"?e+"":e,s);class qv{constructor(e,s,r){this.core=e,this.logger=s,Je(this,"name",Db),Je(this,"keychain"),Je(this,"randomSessionIdentifier",Na()),Je(this,"initialized",!1),Je(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Je(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Je(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),n=gc(i);return Zh(n.publicKey)}),Je(this,"generateKeyPair",()=>{this.isInitialized();const i=xy();return this.setPrivateKey(i.publicKey,i.privateKey)}),Je(this,"signJWT",async i=>{this.isInitialized();const n=await this.getClientSeed(),o=gc(n),a=this.randomSessionIdentifier;return await Qh(a,i,Lb,o)}),Je(this,"generateSharedKey",(i,n,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=$y(a,n);return this.setSymKey(c,o)}),Je(this,"setSymKey",async(i,n)=>{this.isInitialized();const o=n||Kn(i);return await this.keychain.set(o,i),o}),Je(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Je(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Je(this,"encode",async(i,n,o)=>{this.isInitialized();const a=Zd(o),c=za(n);if(Cl(a))return Uy(c,o==null?void 0:o.encoding);if(El(a)){const h=a.senderPublicKey,p=a.receiverPublicKey;i=await this.generateSharedKey(h,p)}const l=this.getSymKey(i),{type:u,senderPublicKey:d}=a;return ky({type:u,symKey:l,message:c,senderPublicKey:d,encoding:o==null?void 0:o.encoding})}),Je(this,"decode",async(i,n,o)=>{this.isInitialized();const a=Ly(n,o);if(Cl(a)){const c=Dy(n,o==null?void 0:o.encoding);return Qn(c)}if(El(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=Ry({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return Qn(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Je(this,"getPayloadType",(i,n=qt)=>{const o=cn({encoded:i,encoding:n});return ir(o.type)}),Je(this,"getPayloadSenderPublicKey",(i,n=qt)=>{const o=cn({encoded:i,encoding:n});return o.senderPublicKey?ft(o.senderPublicKey,it):void 0}),this.core=e,this.logger=nt(s,this.name),this.keychain=r||new Bv(this.core,this.logger)}get context(){return At(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Rl)}catch{e=Na(),await this.keychain.set(Rl,e)}return Dv(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Wv=Object.defineProperty,zv=Object.defineProperties,Hv=Object.getOwnPropertyDescriptors,Wl=Object.getOwnPropertySymbols,Kv=Object.prototype.hasOwnProperty,Vv=Object.prototype.propertyIsEnumerable,Ta=(t,e,s)=>e in t?Wv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Gv=(t,e)=>{for(var s in e||(e={}))Kv.call(e,s)&&Ta(t,s,e[s]);if(Wl)for(var s of Wl(e))Vv.call(e,s)&&Ta(t,s,e[s]);return t},Jv=(t,e)=>zv(t,Hv(e)),wt=(t,e,s)=>Ta(t,typeof e!="symbol"?e+"":e,s);class Yv extends Vf{constructor(e,s){super(e,s),this.logger=e,this.core=s,wt(this,"messages",new Map),wt(this,"messagesWithoutClientAck",new Map),wt(this,"name",Fb),wt(this,"version",jb),wt(this,"initialized",!1),wt(this,"storagePrefix",Qt),wt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const r=await this.getRelayerMessages();typeof r<"u"&&(this.messages=r);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}finally{this.initialized=!0}}}),wt(this,"set",async(r,i,n)=>{this.isInitialized();const o=Xt(i);let a=this.messages.get(r);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(r,a),n===Vn.inbound){const c=this.messagesWithoutClientAck.get(r)||{};this.messagesWithoutClientAck.set(r,Jv(Gv({},c),{[o]:i}))}return await this.persist(),o}),wt(this,"get",r=>{this.isInitialized();let i=this.messages.get(r);return typeof i>"u"&&(i={}),i}),wt(this,"getWithoutAck",r=>{this.isInitialized();const i={};for(const n of r){const o=this.messagesWithoutClientAck.get(n)||{};i[n]=Object.values(o)}return i}),wt(this,"has",(r,i)=>{this.isInitialized();const n=this.get(r),o=Xt(i);return typeof n[o]<"u"}),wt(this,"ack",async(r,i)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(r);if(typeof n>"u")return;const o=Xt(i);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(r):this.messagesWithoutClientAck.set(r,n),await this.persist()}),wt(this,"del",async r=>{this.isInitialized(),this.messages.delete(r),this.messagesWithoutClientAck.delete(r),await this.persist()}),this.logger=nt(e,this.name),this.core=s}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ga(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ga(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ma(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?ma(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Xv=Object.defineProperty,Zv=Object.defineProperties,Qv=Object.getOwnPropertyDescriptors,zl=Object.getOwnPropertySymbols,e1=Object.prototype.hasOwnProperty,t1=Object.prototype.propertyIsEnumerable,xa=(t,e,s)=>e in t?Xv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Dn=(t,e)=>{for(var s in e||(e={}))e1.call(e,s)&&xa(t,s,e[s]);if(zl)for(var s of zl(e))t1.call(e,s)&&xa(t,s,e[s]);return t},zo=(t,e)=>Zv(t,Qv(e)),Mt=(t,e,s)=>xa(t,typeof e!="symbol"?e+"":e,s);class s1 extends Gf{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,Mt(this,"events",new or.EventEmitter),Mt(this,"name",qb),Mt(this,"queue",new Map),Mt(this,"publishTimeout",D.toMiliseconds(D.ONE_MINUTE)),Mt(this,"initialPublishTimeout",D.toMiliseconds(D.ONE_SECOND*15)),Mt(this,"needsTransportRestart",!1),Mt(this,"publish",async(r,i,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:r,message:i,opts:n}});const a=(n==null?void 0:n.ttl)||Ul,c=ro(n),l=(n==null?void 0:n.prompt)||!1,u=(n==null?void 0:n.tag)||0,d=(n==null?void 0:n.id)||Tr().toString(),h={topic:r,message:i,opts:{ttl:a,relay:c,prompt:l,tag:u,id:d,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},p=`Failed to publish payload, please try again. id:${d} tag:${u}`;try{const g=new Promise(async m=>{const w=({id:b})=>{h.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(We.publish,w),m(h))};this.relayer.events.on(We.publish,w);const y=_s(new Promise((b,v)=>{this.rpcPublish({topic:r,message:i,ttl:a,prompt:l,tag:u,id:d,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(b).catch(I=>{this.logger.warn(I,I==null?void 0:I.message),v(I)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${d} tag:${u}`);try{await y,this.events.removeListener(We.publish,w)}catch(b){this.queue.set(d,zo(Dn({},h),{attempt:1})),this.logger.warn(b,b==null?void 0:b.message)}});this.logger.trace({type:"method",method:"publish",params:{id:d,topic:r,message:i,opts:n}}),await _s(g,this.publishTimeout,p)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw g}finally{this.queue.delete(d)}}),Mt(this,"on",(r,i)=>{this.events.on(r,i)}),Mt(this,"once",(r,i)=>{this.events.once(r,i)}),Mt(this,"off",(r,i)=>{this.events.off(r,i)}),Mt(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.relayer=e,this.logger=nt(s,this.name),this.registerEventListeners()}get context(){return At(this.logger)}async rpcPublish(e){var s,r,i,n;const{topic:o,message:a,ttl:c=Ul,prompt:l,tag:u,id:d,attestation:h,tvf:p}=e,g={method:vi(ro().protocol).publish,params:Dn({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:h},p),id:d};Xe((s=g.params)==null?void 0:s.prompt)&&((r=g.params)==null||delete r.prompt),Xe((i=g.params)==null?void 0:i.tag)&&((n=g.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const m=await this.relayer.request(g);return this.relayer.events.emit(We.publish,e),this.logger.debug("Successfully Published Payload"),m}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{const r=e.attempt+1;this.queue.set(s,zo(Dn({},e),{attempt:r}));const{topic:i,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(zo(Dn({},e),{topic:i,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(Zr.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(We.connection_stalled);return}this.checkQueue()}),this.relayer.on(We.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var r1=Object.defineProperty,i1=(t,e,s)=>e in t?r1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,pr=(t,e,s)=>i1(t,typeof e!="symbol"?e+"":e,s);class n1{constructor(){pr(this,"map",new Map),pr(this,"set",(e,s)=>{const r=this.get(e);this.exists(e,s)||this.map.set(e,[...r,s])}),pr(this,"get",e=>this.map.get(e)||[]),pr(this,"exists",(e,s)=>this.get(e).includes(s)),pr(this,"delete",(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,s))return;const i=r.filter(n=>n!==s);if(!i.length){this.map.delete(e);return}this.map.set(e,i)}),pr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var o1=Object.defineProperty,a1=Object.defineProperties,c1=Object.getOwnPropertyDescriptors,Hl=Object.getOwnPropertySymbols,l1=Object.prototype.hasOwnProperty,u1=Object.prototype.propertyIsEnumerable,$a=(t,e,s)=>e in t?o1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,fi=(t,e)=>{for(var s in e||(e={}))l1.call(e,s)&&$a(t,s,e[s]);if(Hl)for(var s of Hl(e))u1.call(e,s)&&$a(t,s,e[s]);return t},Ho=(t,e)=>a1(t,c1(e)),be=(t,e,s)=>$a(t,typeof e!="symbol"?e+"":e,s);class d1 extends Xf{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,be(this,"subscriptions",new Map),be(this,"topicMap",new n1),be(this,"events",new or.EventEmitter),be(this,"name",Jb),be(this,"version",Yb),be(this,"pending",new Map),be(this,"cached",[]),be(this,"initialized",!1),be(this,"storagePrefix",Qt),be(this,"subscribeTimeout",D.toMiliseconds(D.ONE_MINUTE)),be(this,"initialSubscribeTimeout",D.toMiliseconds(D.ONE_SECOND*15)),be(this,"clientId"),be(this,"batchSubscribeTopicsLimit",500),be(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),be(this,"subscribe",async(r,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}});try{const n=ro(i),o={topic:r,relay:n,transportType:i==null?void 0:i.transportType};this.pending.set(r,o);const a=await this.rpcSubscribe(r,n,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:r,opts:i}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),be(this,"unsubscribe",async(r,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(r,i.id,i):await this.unsubscribeByTopic(r,i)}),be(this,"isSubscribed",r=>new Promise(i=>{i(this.topicMap.topics.includes(r))})),be(this,"isKnownTopic",r=>new Promise(i=>{i(this.topicMap.topics.includes(r)||this.pending.has(r)||this.cached.some(n=>n.topic===r))})),be(this,"on",(r,i)=>{this.events.on(r,i)}),be(this,"once",(r,i)=>{this.events.once(r,i)}),be(this,"off",(r,i)=>{this.events.off(r,i)}),be(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),be(this,"start",async()=>{await this.onConnect()}),be(this,"stop",async()=>{await this.onDisconnect()}),be(this,"restart",async()=>{await this.restore(),await this.onRestart()}),be(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}),be(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(Zr.pulse,async()=>{await this.checkPending()}),this.events.on(yt.created,async r=>{const i=yt.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(yt.deleted,async r=>{const i=yt.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}),this.relayer=e,this.logger=nt(s,this.name),this.clientId=""}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,s){let r=!1;try{r=this.getSubscription(e).topic===s}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const r=this.topicMap.get(e);await Promise.all(r.map(async i=>await this.unsubscribeById(e,i,s)))}async unsubscribeById(e,s,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}});try{const i=ro(r);await this.restartToComplete({topic:e,id:s,relay:i}),await this.rpcUnsubscribe(e,s,i);const n=we("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:r}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,s,r){var i;(!r||(r==null?void 0:r.transportType)===_e.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const n={method:vi(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((r==null?void 0:r.transportType)===_e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(u=>this.logger.warn(u))},D.toMiliseconds(D.ONE_SECOND)),a;const c=new Promise(async u=>{const d=h=>{h.topic===e&&(this.events.removeListener(yt.created,d),u(h.id))};this.events.on(yt.created,d);try{const h=await _s(new Promise((p,g)=>{this.relayer.request(n).catch(m=>{this.logger.warn(m,m==null?void 0:m.message),g(m)}).then(p)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(yt.created,d),u(h)}catch{}}),l=await _s(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(We.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const s=e[0].relay,r={method:vi(s.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await _s(new Promise(i=>{this.relayer.request(r).catch(n=>this.logger.warn(n)).then(i)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(We.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,r={method:vi(s.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});let i;try{i=await await _s(new Promise((n,o)=>{this.relayer.request(r).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(We.connection_stalled)}return i}rpcUnsubscribe(e,s,r){const i={method:vi(r.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,s){this.setSubscription(e,Ho(fi({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,fi({},s)),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,r){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,fi({},s)),this.topicMap.set(s.topic,e),this.events.emit(yt.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:r}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(yt.deleted,Ho(fi({},r),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(yt.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<s;r++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(yt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:s}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async s=>Ho(fi({},s),{id:await this.getSubscriptionId(s.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await ym(D.toMiliseconds(D.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Xt(e+await this.getClientId())}}var h1=Object.defineProperty,Kl=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,ka=(t,e,s)=>e in t?h1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Vl=(t,e)=>{for(var s in e||(e={}))p1.call(e,s)&&ka(t,s,e[s]);if(Kl)for(var s of Kl(e))f1.call(e,s)&&ka(t,s,e[s]);return t},ue=(t,e,s)=>ka(t,typeof e!="symbol"?e+"":e,s);class g1 extends Jf{constructor(e){super(e),ue(this,"protocol","wc"),ue(this,"version",2),ue(this,"core"),ue(this,"logger"),ue(this,"events",new or.EventEmitter),ue(this,"provider"),ue(this,"messages"),ue(this,"subscriber"),ue(this,"publisher"),ue(this,"name",zb),ue(this,"transportExplicitlyClosed",!1),ue(this,"initialized",!1),ue(this,"connectionAttemptInProgress",!1),ue(this,"relayUrl"),ue(this,"projectId"),ue(this,"packageName"),ue(this,"bundleId"),ue(this,"hasExperiencedNetworkDisruption",!1),ue(this,"pingTimeout"),ue(this,"heartBeatTimeout",D.toMiliseconds(D.THIRTY_SECONDS+D.FIVE_SECONDS)),ue(this,"reconnectTimeout"),ue(this,"connectPromise"),ue(this,"reconnectInProgress",!1),ue(this,"requestsInFlight",[]),ue(this,"connectTimeout",D.toMiliseconds(D.ONE_SECOND*15)),ue(this,"request",async s=>{var r,i;this.logger.debug("Publishing Request Payload");const n=s.id||Tr().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:s.method,topic:(r=s.params)==null?void 0:r.topic},"relayer.request - publishing...");const o=`${n}:${((i=s.params)==null?void 0:i.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),ue(this,"resetPingTimeout",()=>{to()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,r,i,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=(s=this.provider)==null?void 0:s.connection)==null?void 0:r.socket)==null?void 0:i.terminate)==null||n.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),ue(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),ue(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(We.connect)}),ue(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),ue(this,"onProviderErrorHandler",s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(We.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),ue(this,"registerProviderListeners",()=>{this.provider.on(Ot.payload,this.onPayloadHandler),this.provider.on(Ot.connect,this.onConnectHandler),this.provider.on(Ot.disconnect,this.onDisconnectHandler),this.provider.on(Ot.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?nt(e.logger,this.name):Ha(hn({level:e.logger||Wb})),this.messages=new Yv(this.logger,e.core),this.subscriber=new d1(this,this.logger),this.publisher=new s1(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||ih,this.projectId=e.projectId,sm()?this.packageName=Hc():rm()&&(this.bundleId=Hc()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return At(this.logger)}get connected(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===1||!1}get connecting(){var e,s,r;return((r=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:r.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,s,r){this.isInitialized(),await this.publisher.publish(e,s,r),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:_e.relay},Vn.outbound)}async subscribe(e,s){var r,i,n;this.isInitialized(),(!(s!=null&&s.transportType)||(s==null?void 0:s.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((r=s==null?void 0:s.internal)==null?void 0:r.throwOnFailedPublish)>"u"?!0:(i=s==null?void 0:s.internal)==null?void 0:i.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(yt.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(yt.created,l)}),new Promise(async(u,d)=>{a=await this.subscriber.subscribe(e,Vl({internal:{throwOnFailedPublish:o}},s)).catch(h=>{o&&d(h)})||a,u()})]),a}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await _s(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(s,r)=>{await this.connect(e).then(s).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await kl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const s=e.sort((r,i)=>r.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const r of s)try{await this.onMessageEvent(r)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:r}=e;if(!s.sessionExists){const i=De(D.FIVE_MINUTES),n={topic:r,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,n)}this.events.emit(We.message,e),await this.recordMessageEvent(e,Vn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(r,i)=>{const n=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ot.disconnect,n),await _s(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{i(o)}).finally(()=>{this.provider.off(Ot.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ot.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ot.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){await this.subscriber.stop();const i=r;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${s}`);break}await new Promise(r=>setTimeout(r,D.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,r,i,n;if(to())try{(s=(e=this.provider)==null?void 0:e.connection)!=null&&s.socket&&((n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Rt(new Xh(cm({sdkVersion:Sa,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,s){const{topic:r,message:i}=e;await this.messages.set(r,i,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:r}=e;if(!r||r.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const i=this.messages.has(s,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ka(e)){if(!e.method.endsWith(Hb))return;const s=e.params,{topic:r,message:i,publishedAt:n,attestation:o}=s.data,a={topic:r,message:i,publishedAt:n,transportType:_e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Vl({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Va(e)&&this.events.emit(We.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Vn.inbound),this.events.emit(We.message,e))}async acknowledgePayload(e){const s=lo(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(Ot.payload,this.onPayloadHandler),this.provider.off(Ot.connect,this.onConnectHandler),this.provider.off(Ot.disconnect,this.onDisconnectHandler),this.provider.off(Ot.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await kl();Tb(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(r=>this.logger.error(r,r==null?void 0:r.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(Zr.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&kb())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s==null?void 0:s.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(We.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},D.toMiliseconds(Kb)))))}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function m1(){}function Gl(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function Jl(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Yl(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const w1="[object RegExp]",y1="[object String]",b1="[object Number]",v1="[object Boolean]",Xl="[object Arguments]",E1="[object Symbol]",C1="[object Date]",I1="[object Map]",A1="[object Set]",_1="[object Array]",N1="[object Function]",S1="[object ArrayBuffer]",Ko="[object Object]",P1="[object Error]",O1="[object DataView]",T1="[object Uint8Array]",x1="[object Uint8ClampedArray]",$1="[object Uint16Array]",k1="[object Uint32Array]",R1="[object BigUint64Array]",U1="[object Int8Array]",D1="[object Int16Array]",L1="[object Int32Array]",M1="[object BigInt64Array]",B1="[object Float32Array]",F1="[object Float64Array]";function j1(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function q1(t,e,s){return Ei(t,e,void 0,void 0,void 0,void 0,s)}function Ei(t,e,s,r,i,n,o){const a=o(t,e,s,r,i,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return xi(t,e,n,o)}return xi(t,e,n,o)}function xi(t,e,s,r){if(Object.is(t,e))return!0;let i=Yl(t),n=Yl(e);if(i===Xl&&(i=Ko),n===Xl&&(n=Ko),i!==n)return!1;switch(i){case y1:return t.toString()===e.toString();case b1:{const c=t.valueOf(),l=e.valueOf();return j1(c,l)}case v1:case C1:case E1:return Object.is(t.valueOf(),e.valueOf());case w1:return t.source===e.source&&t.flags===e.flags;case N1:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(i){case I1:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Ei(l,e.get(c),c,t,e,s,r))return!1;return!0}case A1:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let u=0;u<c.length;u++){const d=c[u],h=l.findIndex(p=>Ei(d,p,void 0,t,e,s,r));if(h===-1)return!1;l.splice(h,1)}return!0}case _1:case T1:case x1:case $1:case k1:case R1:case U1:case D1:case L1:case M1:case B1:case F1:{if(typeof Ve<"u"&&Ve.isBuffer(t)!==Ve.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ei(t[c],e[c],c,t,e,s,r))return!1;return!0}case S1:return t.byteLength!==e.byteLength?!1:xi(new Uint8Array(t),new Uint8Array(e),s,r);case O1:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:xi(new Uint8Array(t),new Uint8Array(e),s,r);case P1:return t.name===e.name&&t.message===e.message;case Ko:{if(!(xi(t.constructor,e.constructor,s,r)||Gl(t)&&Gl(e)))return!1;const c=[...Object.keys(t),...Jl(t)],l=[...Object.keys(e),...Jl(e)];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){const d=c[u],h=t[d];if(!Object.hasOwn(e,d))return!1;const p=e[d];if(!Ei(h,p,d,t,e,s,r))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function W1(t,e){return q1(t,e,m1)}var z1=Object.defineProperty,Zl=Object.getOwnPropertySymbols,H1=Object.prototype.hasOwnProperty,K1=Object.prototype.propertyIsEnumerable,Ra=(t,e,s)=>e in t?z1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ql=(t,e)=>{for(var s in e||(e={}))H1.call(e,s)&&Ra(t,s,e[s]);if(Zl)for(var s of Zl(e))K1.call(e,s)&&Ra(t,s,e[s]);return t},lt=(t,e,s)=>Ra(t,typeof e!="symbol"?e+"":e,s);class ar extends Yf{constructor(e,s,r,i=Qt,n=void 0){super(e,s,r,i),this.core=e,this.logger=s,this.name=r,lt(this,"map",new Map),lt(this,"version",Vb),lt(this,"cached",[]),lt(this,"initialized",!1),lt(this,"getKey"),lt(this,"storagePrefix",Qt),lt(this,"recentlyDeleted",[]),lt(this,"recentlyDeletedLimit",200),lt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Xe(o)?this.map.set(this.getKey(o),o):ab(o)?this.map.set(o.id,o):cb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),lt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),lt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),lt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>W1(a[c],o[c]))):this.values)),lt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Ql(Ql({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),lt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=nt(s,this.name),this.storagePrefix=i,this.getKey=n}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:i}=U("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:r}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}return s}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:s}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var V1=Object.defineProperty,G1=(t,e,s)=>e in t?V1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e,s)=>G1(t,typeof e!="symbol"?e+"":e,s);class J1{constructor(e,s){this.core=e,this.logger=s,ne(this,"name",Xb),ne(this,"version",Zb),ne(this,"events",new Wa),ne(this,"pairings"),ne(this,"initialized",!1),ne(this,"storagePrefix",Qt),ne(this,"ignoredPayloadTypes",[ps]),ne(this,"registeredMethods",[]),ne(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ne(this,"register",({methods:r})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...r])]}),ne(this,"create",async r=>{this.isInitialized();const i=Na(),n=await this.core.crypto.setSymKey(i),o=De(D.FIVE_MINUTES),a={protocol:rh},c={topic:n,expiry:o,relay:a,active:!1,methods:r==null?void 0:r.methods},l=Al({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:a,expiryTimestamp:o,methods:r==null?void 0:r.methods});return this.events.emit(zs.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:r==null?void 0:r.transportType}),{topic:n,uri:l}}),ne(this,"pair",async r=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:r==null?void 0:r.uri,trace:[Gt.pairing_started]}});this.isValidPair(r,i);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Il(r.uri);i.props.properties.topic=n,i.addTrace(Gt.pairing_uri_validation_success),i.addTrace(Gt.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(n)){if(u=this.pairings.get(n),i.addTrace(Gt.existing_pairing),u.active)throw i.setError(ls.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);i.addTrace(Gt.pairing_not_expired)}const d=c||De(D.FIVE_MINUTES),h={topic:n,relay:a,expiry:d,active:!1,methods:l};this.core.expirer.set(n,d),await this.pairings.set(n,h),i.addTrace(Gt.store_new_pairing),r.activatePairing&&await this.activate({topic:n}),this.events.emit(zs.create,h),i.addTrace(Gt.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),i.addTrace(Gt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(ls.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(p){throw i.setError(ls.subscribe_pairing_topic_failure),p}return i.addTrace(Gt.subscribe_pairing_topic_success),h}),ne(this,"activate",async({topic:r})=>{this.isInitialized();const i=De(D.FIVE_MINUTES);this.core.expirer.set(r,i),await this.pairings.update(r,{active:!0,expiry:i})}),ne(this,"ping",async r=>{this.isInitialized(),await this.isValidPing(r),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=r;if(this.pairings.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=js();this.events.once(fe("pairing_ping",n),({error:l})=>{l?c(l):a()}),await o()}}),ne(this,"updateExpiry",async({topic:r,expiry:i})=>{this.isInitialized(),await this.pairings.update(r,{expiry:i})}),ne(this,"updateMetadata",async({topic:r,metadata:i})=>{this.isInitialized(),await this.pairings.update(r,{peerMetadata:i})}),ne(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ne(this,"disconnect",async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",we("USER_DISCONNECTED")),await this.deletePairing(i))}),ne(this,"formatUriFromPairing",r=>{this.isInitialized();const{topic:i,relay:n,expiry:o,methods:a}=r,c=this.core.crypto.keychain.get(i);return Al({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),ne(this,"sendRequest",async(r,i,n)=>{const o=Ks(i,n),a=await this.core.crypto.encode(r,o),c=hi[i].req;return this.core.history.set(r,o),this.core.relayer.publish(r,a,c),o.id}),ne(this,"sendResult",async(r,i,n)=>{const o=lo(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=hi[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ne(this,"sendError",async(r,i,n)=>{const o=Bu(r,n),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,r)).request.method,l=hi[c]?hi[c].res:hi.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),ne(this,"deletePairing",async(r,i)=>{await this.core.relayer.unsubscribe(r),await Promise.all([this.pairings.delete(r,we("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(r),i?Promise.resolve():this.core.expirer.del(r)])}),ne(this,"cleanup",async()=>{const r=this.pairings.getAll().filter(i=>Es(i.expiry));await Promise.all(r.map(i=>this.deletePairing(i.topic)))}),ne(this,"onRelayEventRequest",async r=>{const{topic:i,payload:n}=r;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,n);default:return await this.onUnknownRpcMethodRequest(i,n)}}),ne(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n}=r,o=(await this.core.history.get(i,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,n);default:return this.onUnknownRpcMethodResponse(o)}}),ne(this,"onPairingPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.events.emit(zs.ping,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ne(this,"onPairingPingResponse",(r,i)=>{const{id:n}=i;setTimeout(()=>{cs(i)?this.events.emit(fe("pairing_ping",n),{}):Jt(i)&&this.events.emit(fe("pairing_ping",n),{error:i.error})},500)}),ne(this,"onPairingDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r}),await this.deletePairing(r),this.events.emit(zs.delete,{id:n,topic:r})}catch(o){await this.sendError(n,r,o),this.logger.error(o)}}),ne(this,"onUnknownRpcMethodRequest",async(r,i)=>{const{id:n,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=we("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,r,a),this.logger.error(a)}catch(a){await this.sendError(n,r,a),this.logger.error(a)}}),ne(this,"onUnknownRpcMethodResponse",r=>{this.registeredMethods.includes(r)||this.logger.error(we("WC_METHOD_UNSUPPORTED",r))}),ne(this,"isValidPair",(r,i)=>{var n;if(!ht(r)){const{message:a}=U("MISSING_OR_INVALID",`pair() params: ${r}`);throw i.setError(ls.malformed_pairing_uri),new Error(a)}if(!ob(r.uri)){const{message:a}=U("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw i.setError(ls.malformed_pairing_uri),new Error(a)}const o=Il(r==null?void 0:r.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=U("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(ls.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=U("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(ls.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&D.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(ls.pairing_expired);const{message:a}=U("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ne(this,"isValidPing",async r=>{if(!ht(r)){const{message:n}=U("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ne(this,"isValidDisconnect",async r=>{if(!ht(r)){const{message:n}=U("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidPairingTopic(i)}),ne(this,"isValidPairingTopic",async r=>{if(!$e(r,!1)){const{message:i}=U("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.pairings.keys.includes(r)){const{message:i}=U("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(Es(this.pairings.get(r).expiry)){await this.deletePairing(r);const{message:i}=U("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}),this.core=e,this.logger=nt(s,this.name),this.pairings=new ar(this.core,this.logger,this.name,this.storagePrefix)}get context(){return At(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(We.message,async e=>{const{topic:s,message:r,transportType:i}=e;if(this.pairings.keys.includes(s)&&i!==_e.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const n=await this.core.crypto.decode(s,r);Ka(n)?(this.core.history.set(s,n),await this.onRelayEventRequest({topic:s,payload:n})):Va(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:s,payload:n}),this.core.history.delete(s,n.id)),await this.core.relayer.messages.ack(s,r)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on($t.expired,async e=>{const{topic:s}=bd(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(zs.expire,{topic:s}))})}}var Y1=Object.defineProperty,X1=(t,e,s)=>e in t?Y1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ye=(t,e,s)=>X1(t,typeof e!="symbol"?e+"":e,s);class Z1 extends Kf{constructor(e,s){super(e,s),this.core=e,this.logger=s,Ye(this,"records",new Map),Ye(this,"events",new or.EventEmitter),Ye(this,"name",Qb),Ye(this,"version",e0),Ye(this,"cached",[]),Ye(this,"initialized",!1),Ye(this,"storagePrefix",Qt),Ye(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.records.set(r.id,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ye(this,"set",(r,i,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:r,request:i,chainId:n}),this.records.has(i.id))return;const o={id:i.id,topic:r,request:{method:i.method,params:i.params||null},chainId:n,expiry:De(D.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Dt.created,o)}),Ye(this,"resolve",async r=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:r}),!this.records.has(r.id))return;const i=await this.getRecord(r.id);typeof i.response>"u"&&(i.response=Jt(r)?{error:r.error}:{result:r.result},this.records.set(i.id,i),this.persist(),this.events.emit(Dt.updated,i))}),Ye(this,"get",async(r,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:r,id:i}),await this.getRecord(i))),Ye(this,"delete",(r,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(n=>{if(n.topic===r){if(typeof i<"u"&&n.id!==i)return;this.records.delete(n.id),this.events.emit(Dt.deleted,n)}}),this.persist()}),Ye(this,"exists",async(r,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===r:!1)),Ye(this,"on",(r,i)=>{this.events.on(r,i)}),Ye(this,"once",(r,i)=>{this.events.once(r,i)}),Ye(this,"off",(r,i)=>{this.events.off(r,i)}),Ye(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=nt(s,this.name)}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(s=>{if(typeof s.response<"u")return;const r={topic:s.topic,request:Ks(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const s=this.records.get(e);if(!s){const{message:r}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(r)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Dt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Dt.created,e=>{const s=Dt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Dt.updated,e=>{const s=Dt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Dt.deleted,e=>{const s=Dt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(Zr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{D.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(Dt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Q1=Object.defineProperty,eE=(t,e,s)=>e in t?Q1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,et=(t,e,s)=>eE(t,typeof e!="symbol"?e+"":e,s);class tE extends Zf{constructor(e,s){super(e,s),this.core=e,this.logger=s,et(this,"expirations",new Map),et(this,"events",new or.EventEmitter),et(this,"name",t0),et(this,"version",s0),et(this,"cached",[]),et(this,"initialized",!1),et(this,"storagePrefix",Qt),et(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(r=>this.expirations.set(r.target,r)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),et(this,"has",r=>{try{const i=this.formatTarget(r);return typeof this.getExpiration(i)<"u"}catch{return!1}}),et(this,"set",(r,i)=>{this.isInitialized();const n=this.formatTarget(r),o={target:n,expiry:i};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit($t.created,{target:n,expiration:o})}),et(this,"get",r=>{this.isInitialized();const i=this.formatTarget(r);return this.getExpiration(i)}),et(this,"del",r=>{if(this.isInitialized(),this.has(r)){const i=this.formatTarget(r),n=this.getExpiration(i);this.expirations.delete(i),this.events.emit($t.deleted,{target:i,expiration:n})}}),et(this,"on",(r,i)=>{this.events.on(r,i)}),et(this,"once",(r,i)=>{this.events.once(r,i)}),et(this,"off",(r,i)=>{this.events.off(r,i)}),et(this,"removeListener",(r,i)=>{this.events.removeListener(r,i)}),this.logger=nt(s,this.name)}get context(){return At(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lm(e);if(typeof e=="number")return um(e);const{message:s}=U("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit($t.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=U("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const s=this.expirations.get(e);if(!s){const{message:r}=U("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(r),new Error(r)}return s}checkExpiry(e,s){const{expiry:r}=s;D.toMiliseconds(r)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit($t.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(Zr.pulse,()=>this.checkExpirations()),this.events.on($t.created,e=>{const s=$t.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on($t.expired,e=>{const s=$t.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on($t.deleted,e=>{const s=$t.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}}var sE=Object.defineProperty,rE=(t,e,s)=>e in t?sE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xe=(t,e,s)=>rE(t,typeof e!="symbol"?e+"":e,s);class iE extends Qf{constructor(e,s,r){super(e,s,r),this.core=e,this.logger=s,this.store=r,xe(this,"name",r0),xe(this,"abortController"),xe(this,"isDevEnv"),xe(this,"verifyUrlV3",n0),xe(this,"storagePrefix",Qt),xe(this,"version",sh),xe(this,"publicKey"),xe(this,"fetchPromise"),xe(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&D.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),xe(this,"register",async i=>{if(!ti()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const l=Lr(),u=this.startAbortTimer(D.ONE_SECOND*5),d=await new Promise((h,p)=>{const g=()=>{window.removeEventListener("message",w),l.body.removeChild(m),p("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const m=l.createElement("iframe");m.src=c,m.style.display="none",m.addEventListener("error",g,{signal:this.abortController.signal});const w=y=>{if(y.data&&typeof y.data=="string")try{const b=JSON.parse(y.data);if(b.type==="verify_attestation"){if(na(b.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(m),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",w),h(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};l.body.appendChild(m),window.addEventListener("message",w,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",d),d}catch(l){this.logger.warn(l)}return""}),xe(this,"resolve",async i=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=i;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(na(n).payload.id!==a)return;const l=await this.isValidJwtAttestation(n);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),xe(this,"fetchAttestation",async(i,n)=>{this.logger.debug(`resolving attestation: ${i} from url: ${n}`);const o=this.startAbortTimer(D.ONE_SECOND*5),a=await fetch(`${n}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),xe(this,"getVerifyUrl",i=>{let n=i||Ti;return o0.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Ti}`),n=Ti),n}),xe(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(D.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await n.json()}catch(i){this.logger.warn(i)}}),xe(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),xe(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),xe(this,"isValidJwtAttestation",async i=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(i,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),xe(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),xe(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i}),xe(this,"validateAttestation",(i,n)=>{const o=By(i,n.publicKey),a={hasExpired:D.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=nt(s,this.name),this.abortController=new AbortController,this.isDevEnv=Za(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return At(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),D.toMiliseconds(e))}}var nE=Object.defineProperty,oE=(t,e,s)=>e in t?nE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,eu=(t,e,s)=>oE(t,typeof e!="symbol"?e+"":e,s);class aE extends eg{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,eu(this,"context",a0),eu(this,"registerDeviceToken",async r=>{const{clientId:i,token:n,notificationType:o,enableEncrypted:a=!1}=r,c=`${c0}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:n,always_raw:a})})}),this.logger=nt(s,this.context)}}var cE=Object.defineProperty,tu=Object.getOwnPropertySymbols,lE=Object.prototype.hasOwnProperty,uE=Object.prototype.propertyIsEnumerable,Ua=(t,e,s)=>e in t?cE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,gi=(t,e)=>{for(var s in e||(e={}))lE.call(e,s)&&Ua(t,s,e[s]);if(tu)for(var s of tu(e))uE.call(e,s)&&Ua(t,s,e[s]);return t},Be=(t,e,s)=>Ua(t,typeof e!="symbol"?e+"":e,s);class dE extends tg{constructor(e,s,r=!0){super(e,s,r),this.core=e,this.logger=s,Be(this,"context",u0),Be(this,"storagePrefix",Qt),Be(this,"storageVersion",l0),Be(this,"events",new Map),Be(this,"shouldPersist",!1),Be(this,"init",async()=>{if(!Za())try{const i={eventId:Vc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:wd(this.core.relayer.protocol,this.core.relayer.version,Sa)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),Be(this,"createEvent",i=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=Vc(),u=this.core.projectId||"",d=Date.now(),h=gi({eventId:l,timestamp:d,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,h),this.shouldPersist=!0),h}),Be(this,"getEvent",i=>{const{eventId:n,topic:o}=i;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return gi(gi({},a),this.setMethods(a.eventId))}),Be(this,"deleteEvent",i=>{const{eventId:n}=i;this.events.delete(n),this.shouldPersist=!0}),Be(this,"setEventListeners",()=>{this.core.heartbeat.on(Zr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{D.fromMiliseconds(Date.now())-D.fromMiliseconds(i.timestamp)>d0&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),Be(this,"setMethods",i=>({addTrace:n=>this.addTrace(i,n),setError:n=>this.setError(i,n)})),Be(this,"addTrace",(i,n)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(n),this.events.set(i,o),this.shouldPersist=!0)}),Be(this,"setError",(i,n)=>{const o=this.events.get(i);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)}),Be(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Be(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(n=>{this.events.set(n.eventId,gi(gi({},n),this.setMethods(n.eventId)))})}catch(i){this.logger.warn(i)}}),Be(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[n,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const n of i)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),Be(this,"sendEvent",async i=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${h0}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Sa}${n}`,{method:"POST",body:JSON.stringify(i)})}),Be(this,"getAppDomain",()=>md().url),this.logger=nt(s,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var hE=Object.defineProperty,su=Object.getOwnPropertySymbols,pE=Object.prototype.hasOwnProperty,fE=Object.prototype.propertyIsEnumerable,Da=(t,e,s)=>e in t?hE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ru=(t,e)=>{for(var s in e||(e={}))pE.call(e,s)&&Da(t,s,e[s]);if(su)for(var s of su(e))fE.call(e,s)&&Da(t,s,e[s]);return t},Ae=(t,e,s)=>Da(t,typeof e!="symbol"?e+"":e,s);let gE=class mh extends qf{constructor(e){var s;super(e),Ae(this,"protocol",th),Ae(this,"version",sh),Ae(this,"name",no),Ae(this,"relayUrl"),Ae(this,"projectId"),Ae(this,"customStoragePrefix"),Ae(this,"events",new or.EventEmitter),Ae(this,"logger"),Ae(this,"heartbeat"),Ae(this,"relayer"),Ae(this,"crypto"),Ae(this,"storage"),Ae(this,"history"),Ae(this,"expirer"),Ae(this,"pairing"),Ae(this,"verify"),Ae(this,"echoClient"),Ae(this,"linkModeSupportedApps"),Ae(this,"eventClient"),Ae(this,"initialized",!1),Ae(this,"logChunkController"),Ae(this,"on",(a,c)=>this.events.on(a,c)),Ae(this,"once",(a,c)=>this.events.once(a,c)),Ae(this,"off",(a,c)=>this.events.off(a,c)),Ae(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Ae(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:_e.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const r=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||ih,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=hn({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Rb.logger,name:no}),{logger:n,chunkLoggerController:o}=Mu({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(s=this.logChunkController)!=null&&s.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=nt(n,this.name),this.heartbeat=new Yh,this.crypto=new qv(this,this.logger,e==null?void 0:e.keychain),this.history=new Z1(this,this.logger),this.expirer=new tE(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Bf(ru(ru({},Ub),e==null?void 0:e.storageOptions)),this.relayer=new g1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new J1(this,this.logger),this.verify=new iE(this,this.logger,this.storage),this.echoClient=new aE(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new dE(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new mh(e);await s.initialize();const r=await s.crypto.getClientId();return await s.storage.setItem(Gb,r),s}get context(){return At(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Dl,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Dl)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,r=`${s}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[r]=e}catch(r){console.warn("Failed to set global WalletConnect core",r)}}isGlobalCoreDisabled(){try{return typeof Ns<"u"&&{}.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const mE=gE,wh="wc",yh=2,bh="client",oc=`${wh}@${yh}:${bh}:`,Vo={name:bh,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},iu="WALLETCONNECT_DEEPLINK_CHOICE",wE="proposal",nu="Proposal expired",yE="session",fr=D.SEVEN_DAYS,bE="engine",Fe={wc_sessionPropose:{req:{ttl:D.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:D.ONE_DAY,prompt:!1,tag:1104},res:{ttl:D.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:D.ONE_DAY,prompt:!1,tag:1106},res:{ttl:D.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:D.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:D.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:D.ONE_DAY,prompt:!1,tag:1112},res:{ttl:D.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:D.ONE_DAY,prompt:!1,tag:1114},res:{ttl:D.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:D.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:D.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:D.FIVE_MINUTES,prompt:!1,tag:1119}}},Go={min:D.FIVE_MINUTES,max:D.SEVEN_DAYS},Vt={idle:"IDLE",active:"ACTIVE"},ou={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},vE="request",EE=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],CE="wc",IE="auth",AE="authKeys",_E="pairingTopics",NE="requests",bo=`${CE}@${1.5}:${IE}:`,Gn=`${bo}:PUB_KEY`;var SE=Object.defineProperty,PE=Object.defineProperties,OE=Object.getOwnPropertyDescriptors,au=Object.getOwnPropertySymbols,TE=Object.prototype.hasOwnProperty,xE=Object.prototype.propertyIsEnumerable,La=(t,e,s)=>e in t?SE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ve=(t,e)=>{for(var s in e||(e={}))TE.call(e,s)&&La(t,s,e[s]);if(au)for(var s of au(e))xE.call(e,s)&&La(t,s,e[s]);return t},rt=(t,e)=>PE(t,OE(e)),P=(t,e,s)=>La(t,typeof e!="symbol"?e+"":e,s);class $E extends ng{constructor(e){super(e),P(this,"name",bE),P(this,"events",new Wa),P(this,"initialized",!1),P(this,"requestQueue",{state:Vt.idle,queue:[]}),P(this,"sessionRequestQueue",{state:Vt.idle,queue:[]}),P(this,"requestQueueDelay",D.ONE_SECOND),P(this,"expectedPairingMethodMap",new Map),P(this,"recentlyDeletedMap",new Map),P(this,"recentlyDeletedLimit",200),P(this,"relayMessageCache",[]),P(this,"pendingSessions",new Map),P(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Fe)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},D.toMiliseconds(this.requestQueueDelay)))}),P(this,"connect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const r=rt(ve({},s),{requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}});await this.isValidConnect(r),r.optionalNamespaces=tb(r.requiredNamespaces,r.optionalNamespaces),r.requiredNamespaces={};const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l}=r;let u=i,d,h=!1;try{if(u){const A=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=A.active}}catch(A){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),A}if(!u||!h){const{topic:A,uri:_}=await this.client.core.pairing.create();u=A,d=_}if(!u){const{message:A}=U("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(A)}const p=await this.client.core.crypto.generateKeyPair(),g=Fe.wc_sessionPropose.req.ttl||D.FIVE_MINUTES,m=De(g),w=rt(ve(ve({requiredNamespaces:n,optionalNamespaces:o,relays:l??[{protocol:rh}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:m,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:fs()}),y=fe("session_connect",w.id),{reject:b,resolve:v,done:I}=js(g,nu),S=({id:A})=>{A===w.id&&(this.client.events.off("proposal_expire",S),this.pendingSessions.delete(w.id),this.events.emit(y,{error:{message:nu,code:0}}))};return this.client.events.on("proposal_expire",S),this.events.once(y,({error:A,session:_})=>{this.client.events.off("proposal_expire",S),A?b(A):_&&v(_)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:d,approval:I}}),P(this,"pair",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(s)}catch(r){throw this.client.logger.error("pair() failed"),r}}),P(this,"approve",async s=>{var r,i,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(r=s==null?void 0:s.id)==null?void 0:r.toString(),trace:[Lt.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(E){throw o.setError(Ls.no_internet_connection),E}try{await this.isValidProposalId(s==null?void 0:s.id)}catch(E){throw this.client.logger.error(`approve() -> proposal.get(${s==null?void 0:s.id}) failed`),o.setError(Ls.proposal_not_found),E}try{await this.isValidApprove(s)}catch(E){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ls.session_approve_namespace_validation_failure),E}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,scopedProperties:d,sessionConfig:h}=s,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:g,proposer:m,requiredNamespaces:w,optionalNamespaces:y}=p;let b=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:g});b||(b=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Lt.session_approve_started,properties:{topic:g,trace:[Lt.session_approve_started,Lt.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),I=m.publicKey,S=await this.client.core.crypto.generateSharedKey(v,I),A=ve(ve(ve({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:v,metadata:this.client.metadata},expiry:De(fr)},u&&{sessionProperties:u}),d&&{scopedProperties:d}),h&&{sessionConfig:h}),_=_e.relay;b.addTrace(Lt.subscribing_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:_})}catch(E){throw b.setError(Ls.subscribe_session_topic_failure),E}b.addTrace(Lt.subscribe_session_topic_success);const R=rt(ve({},A),{topic:S,requiredNamespaces:w,optionalNamespaces:y,pairingTopic:g,acknowledged:!1,self:A.controller,peer:{publicKey:m.publicKey,metadata:m.metadata},controller:v,transportType:_e.relay});await this.client.session.set(S,R),b.addTrace(Lt.store_session);try{b.addTrace(Lt.publishing_session_settle),await this.sendRequest({topic:S,method:"wc_sessionSettle",params:A,throwOnFailedPublish:!0}).catch(E=>{throw b==null||b.setError(Ls.session_settle_publish_failure),E}),b.addTrace(Lt.session_settle_publish_success),b.addTrace(Lt.publishing_session_approve),await this.sendResult({id:a,topic:g,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(E=>{throw b==null||b.setError(Ls.session_approve_publish_failure),E}),b.addTrace(Lt.session_approve_publish_success)}catch(E){throw this.client.logger.error(E),this.client.session.delete(S,we("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(S),E}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:m.metadata}),await this.client.proposal.delete(a,we("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(S,De(fr)),{topic:S,acknowledged:()=>Promise.resolve(this.client.session.get(S))}}),P(this,"reject",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(s)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:r,reason:i}=s;let n;try{n=this.client.proposal.get(r).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),o}n&&(await this.sendError({id:r,topic:n,error:i,rpcOpts:Fe.wc_sessionPropose.reject}),await this.client.proposal.delete(r,we("USER_DISCONNECTED")))}),P(this,"update",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(s)}catch(d){throw this.client.logger.error("update() -> isValidUpdate() failed"),d}const{topic:r,namespaces:i}=s,{done:n,resolve:o,reject:a}=js(),c=fs(),l=Tr().toString(),u=this.client.session.get(r).namespaces;return this.events.once(fe("session_update",c),({error:d})=>{d?a(d):o()}),await this.client.session.update(r,{namespaces:i}),await this.sendRequest({topic:r,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(d=>{this.client.logger.error(d),this.client.session.update(r,{namespaces:u}),a(d)}),{acknowledged:n}}),P(this,"extend",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(s)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:r}=s,i=fs(),{done:n,resolve:o,reject:a}=js();return this.events.once(fe("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(r,De(fr)),this.sendRequest({topic:r,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),P(this,"request",async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(y){throw this.client.logger.error("request() -> isValidRequest() failed"),y}const{chainId:r,request:i,topic:n,expiry:o=Fe.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(n);(a==null?void 0:a.transportType)===_e.relay&&await this.confirmOnlineStateOrThrow();const c=fs(),l=Tr().toString(),{done:u,resolve:d,reject:h}=js(o,"Request expired. Please try again.");this.events.once(fe("session_request",c),({error:y,result:b})=>{y?h(y):d(b)});const p="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:n,method:p,params:{request:rt(ve({},i),{expiryTimestamp:De(o)}),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(y=>h(y)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),await u();const m={request:rt(ve({},i),{expiryTimestamp:De(o)}),chainId:r},w=this.shouldSetTVF(p,m);return await Promise.all([new Promise(async y=>{await this.sendRequest(ve({clientRpcId:c,relayRpcId:l,topic:n,method:p,params:m,expiry:o,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,m)})).catch(b=>h(b)),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:r,id:c}),y()}),new Promise(async y=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const v=await fm(this.client.core.storage,iu);await dm({id:c,topic:n,wcDeepLink:v})}y()}),u()]).then(y=>y[2])}),P(this,"respond",async s=>{this.isInitialized(),await this.isValidRespond(s);const{topic:r,response:i}=s,{id:n}=i,o=this.client.session.get(r);o.transportType===_e.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);cs(i)?await this.sendResult({id:n,topic:r,result:i.result,throwOnFailedPublish:!0,appLink:a}):Jt(i)&&await this.sendError({id:n,topic:r,error:i.error,appLink:a}),this.cleanupAfterResponse(s)}),P(this,"ping",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(s)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:r}=s;if(this.client.session.keys.includes(r)){const i=fs(),n=Tr().toString(),{done:o,resolve:a,reject:c}=js();this.events.once(fe("session_ping",i),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:r,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(r)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:r}))}),P(this,"emit",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:r,event:i,chainId:n}=s,o=Tr().toString(),a=fs();await this.sendRequest({topic:r,method:"wc_sessionEvent",params:{event:i,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),P(this,"disconnect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(s);const{topic:r}=s;if(this.client.session.keys.includes(r))await this.sendRequest({topic:r,method:"wc_sessionDelete",params:we("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:r,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(r))await this.client.core.pairing.disconnect({topic:r});else{const{message:i}=U("MISMATCHED_TOPIC",`Session or pairing topic not found: ${r}`);throw new Error(i)}}),P(this,"find",s=>(this.isInitialized(),this.client.session.getAll().filter(r=>ib(r,s)))),P(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),P(this,"authenticate",async(s,r)=>{var i;this.isInitialized(),this.isValidAuthenticate(s);const n=r&&this.client.core.linkModeSupportedApps.includes(r)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=n?_e.link_mode:_e.relay;o===_e.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:d,type:h,exp:p,nbf:g,methods:m=[],expiry:w}=s,y=[...s.resources||[]],{topic:b,uri:v}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:v}});const I=await this.client.core.crypto.generateKeyPair(),S=Kn(I);if(await Promise.all([this.client.auth.authKeys.set(Gn,{responseTopic:S,publicKey:I}),this.client.auth.pairingTopics.set(S,{topic:S,pairingTopic:b})]),await this.client.core.relayer.subscribe(S,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),m.length>0){const{namespace:$}=Rr(a[0]);let G=ow($,"request",m);Hn(y)&&(G=cw(G,y.pop())),y.push(G)}const A=w&&w>Fe.wc_sessionAuthenticate.req.ttl?w:Fe.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:h??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:d,iat:new Date().toISOString(),exp:p,nbf:g,resources:y},requester:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:De(A)},R={eip155:{chains:a,methods:[...new Set(["personal_sign",...m])],events:["chainChanged","accountsChanged"]}},E={requiredNamespaces:{},optionalNamespaces:R,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:De(Fe.wc_sessionPropose.req.ttl),id:fs()},{done:k,resolve:C,reject:L}=js(A,"Request expired"),H=fs(),N=fe("session_connect",E.id),x=fe("session_request",H),O=async({error:$,session:G})=>{this.events.off(x,B),$?L($):G&&C({session:G})},B=async $=>{var G,ee,re;if(await this.deletePendingAuthRequest(H,{message:"fulfilled",code:0}),$.error){const Re=we("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return $.error.code===Re.code?void 0:(this.events.off(N,O),L($.error.message))}await this.deleteProposal(E.id),this.events.off(N,O);const{cacaos:Ce,responder:pe}=$.result,Te=[],Me=[];for(const Re of Ce){await tl({cacao:Re,projectId:this.client.core.projectId})||(this.client.logger.error(Re,"Signature verification failed"),L(we("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Us}=Re,ts=Hn(Us.resources),zt=[wa(Us.iss)],ss=so(Us.iss);if(ts){const rs=sl(ts),In=rl(ts);Te.push(...rs),zt.push(...In)}for(const rs of zt)Me.push(`${rs}:${ss}`)}const Qe=await this.client.core.crypto.generateSharedKey(I,pe.publicKey);let ke;Te.length>0&&(ke={topic:Qe,acknowledged:!0,self:{publicKey:I,metadata:this.client.metadata},peer:pe,controller:pe.publicKey,expiry:De(fr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:Pl([...new Set(Te)],[...new Set(Me)]),transportType:o},await this.client.core.relayer.subscribe(Qe,{transportType:o}),await this.client.session.set(Qe,ke),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:pe.metadata}),ke=this.client.session.get(Qe)),(G=this.client.metadata.redirect)!=null&&G.linkMode&&(ee=pe.metadata.redirect)!=null&&ee.linkMode&&(re=pe.metadata.redirect)!=null&&re.universal&&r&&(this.client.core.addLinkModeSupportedApp(pe.metadata.redirect.universal),this.client.session.update(Qe,{transportType:_e.link_mode})),C({auths:Ce,session:ke})};this.events.once(N,O),this.events.once(x,B);let q;try{if(n){const $=Ks("wc_sessionAuthenticate",_,H);this.client.core.history.set(b,$);const G=await this.client.core.crypto.encode("",$,{type:bn,encoding:Cs});q=Un(r,b,G)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:_,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:H}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:E,expiry:Fe.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:E.id})])}catch($){throw this.events.off(N,O),this.events.off(x,B),$}return await this.setProposal(E.id,E),await this.setAuthRequest(H,{request:rt(ve({},_),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:q??v,response:k}}),P(this,"approveSessionAuthenticate",async s=>{const{id:r,auths:i}=s,n=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:[Ms.authenticated_session_approve_started]}});try{this.isInitialized()}catch(w){throw n.setError(pi.no_internet_connection),w}const o=this.getPendingAuthRequest(r);if(!o)throw n.setError(pi.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${r}`);const a=o.transportType||_e.relay;a===_e.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=Kn(c),d={type:ps,receiverPublicKey:c,senderPublicKey:l},h=[],p=[];for(const w of i){if(!await tl({cacao:w,projectId:this.client.core.projectId})){n.setError(pi.invalid_cacao);const S=we("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:r,topic:u,error:S,encodeOpts:d}),new Error(S.message)}n.addTrace(Ms.cacaos_verified);const{p:y}=w,b=Hn(y.resources),v=[wa(y.iss)],I=so(y.iss);if(b){const S=sl(b),A=rl(b);h.push(...S),v.push(...A)}for(const S of v)p.push(`${S}:${I}`)}const g=await this.client.core.crypto.generateSharedKey(l,c);n.addTrace(Ms.create_authenticated_session_topic);let m;if((h==null?void 0:h.length)>0){m={topic:g,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:De(fr),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Pl([...new Set(h)],[...new Set(p)]),transportType:a},n.addTrace(Ms.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(w){throw n.setError(pi.subscribe_authenticated_session_topic_failure),w}n.addTrace(Ms.subscribe_authenticated_session_topic_success),await this.client.session.set(g,m),n.addTrace(Ms.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Ms.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:r,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(w){throw n.setError(pi.authenticated_session_approve_publish_failure),w}return await this.client.auth.requests.delete(r,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:m}}),P(this,"rejectSessionAuthenticate",async s=>{this.isInitialized();const{id:r,reason:i}=s,n=this.getPendingAuthRequest(r);if(!n)throw new Error(`Could not find pending auth request with id ${r}`);n.transportType===_e.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Kn(o),l={type:ps,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:c,error:i,encodeOpts:l,rpcOpts:Fe.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(r,{message:"rejected",code:0}),await this.client.proposal.delete(r,we("USER_DISCONNECTED"))}),P(this,"formatAuthMessage",s=>{this.isInitialized();const{request:r,iss:i}=s;return Pd(r,i)}),P(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const s=this.relayMessageCache.shift();s&&await this.onRelayMessage(s)}catch(s){this.client.logger.error(s)}},50)}),P(this,"cleanupDuplicatePairings",async s=>{if(s.pairingTopic)try{const r=this.client.core.pairing.pairings.get(s.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===s.peer.metadata.url&&n.topic&&n.topic!==r.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(r){this.client.logger.error(r)}}),P(this,"deleteSession",async s=>{var r;const{topic:i,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=s,{self:c}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,we("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),n||this.client.core.expirer.del(i),this.client.core.storage.removeItem(iu).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,we("USER_DISCONNECTED"))}),i===((r=this.sessionRequestQueue.queue[0])==null?void 0:r.topic)&&(this.sessionRequestQueue.state=Vt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})}),P(this,"deleteProposal",async(s,r)=>{if(r)try{const i=this.client.proposal.get(s),n=this.client.core.eventClient.getEvent({topic:i.pairingTopic});n==null||n.setError(Ls.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,we("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")}),P(this,"deletePendingSessionRequest",async(s,r,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==s),i&&(this.sessionRequestQueue.state=Vt.idle,this.client.events.emit("session_request_expire",{id:s}))}),P(this,"deletePendingAuthRequest",async(s,r,i=!1)=>{await Promise.all([this.client.auth.requests.delete(s,r),i?Promise.resolve():this.client.core.expirer.del(s)])}),P(this,"setExpiry",async(s,r)=>{this.client.session.keys.includes(s)&&(this.client.core.expirer.set(s,r),await this.client.session.update(s,{expiry:r}))}),P(this,"setProposal",async(s,r)=>{this.client.core.expirer.set(s,De(Fe.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,r)}),P(this,"setAuthRequest",async(s,r)=>{const{request:i,pairingTopic:n,transportType:o=_e.relay}=r;this.client.core.expirer.set(s,i.expiryTimestamp),await this.client.auth.requests.set(s,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:s,pairingTopic:n,verifyContext:i.verifyContext,transportType:o})}),P(this,"setPendingSessionRequest",async s=>{const{id:r,topic:i,params:n,verifyContext:o}=s,a=n.request.expiryTimestamp||De(Fe.wc_sessionRequest.req.ttl);this.client.core.expirer.set(r,a),await this.client.pendingRequest.set(r,{id:r,topic:i,params:n,verifyContext:o})}),P(this,"sendRequest",async s=>{const{topic:r,method:i,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:d}=s,h=Ks(i,n,c);let p;const g=!!u;try{const y=g?Cs:qt;p=await this.client.core.crypto.encode(r,h,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${r} failed`),y}let m;if(EE.includes(i)){const y=Xt(JSON.stringify(h)),b=Xt(p);m=await this.client.core.verify.register({id:b,decryptedId:y})}const w=Fe[i].req;if(w.attestation=m,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(r,h),g){const y=Un(u,r,p);await Q.Linking.openURL(y,this.client.name)}else{const y=Fe[i].req;o&&(y.ttl=o),a&&(y.id=a),y.tvf=rt(ve({},d),{correlationId:h.id}),l?(y.internal=rt(ve({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,p,y)):this.client.core.relayer.publish(r,p,y).catch(b=>this.client.logger.error(b))}return h.id}),P(this,"sendResult",async s=>{const{id:r,topic:i,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=lo(r,n);let u;const d=c&&typeof(Q==null?void 0:Q.Linking)<"u";try{const g=d?Cs:qt;u=await this.client.core.crypto.encode(i,l,rt(ve({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),g}let h,p;try{h=await this.client.core.history.get(i,r);const g=h.request;try{this.shouldSetTVF(g.method,g.params)&&(p=this.getTVFParams(r,g.params,n))}catch(m){this.client.logger.warn("sendResult() -> getTVFParams() failed",m)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${r}) failed`),g}if(d){const g=Un(c,i,u);await Q.Linking.openURL(g,this.client.name)}else{const g=h.request.method,m=Fe[g].res;m.tvf=rt(ve({},p),{correlationId:r}),o?(m.internal=rt(ve({},m.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,m)):this.client.core.relayer.publish(i,u,m).catch(w=>this.client.logger.error(w))}await this.client.core.history.resolve(l)}),P(this,"sendError",async s=>{const{id:r,topic:i,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=Bu(r,n);let u;const d=c&&typeof(Q==null?void 0:Q.Linking)<"u";try{const p=d?Cs:qt;u=await this.client.core.crypto.encode(i,l,rt(ve({},o||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),p}let h;try{h=await this.client.core.history.get(i,r)}catch(p){throw this.client.logger.error(`sendError() -> history.get(${i}, ${r}) failed`),p}if(d){const p=Un(c,i,u);await Q.Linking.openURL(p,this.client.name)}else{const p=h.request.method,g=a||Fe[p].res;this.client.core.relayer.publish(i,u,g)}await this.client.core.history.resolve(l)}),P(this,"cleanup",async()=>{const s=[],r=[];this.client.session.getAll().forEach(i=>{let n=!1;Es(i.expiry)&&(n=!0),this.client.core.crypto.keychain.has(i.topic)||(n=!0),n&&s.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Es(i.expiryTimestamp)&&r.push(i.id)}),await Promise.all([...s.map(i=>this.deleteSession({topic:i})),...r.map(i=>this.deleteProposal(i))])}),P(this,"onProviderMessageEvent",async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)}),P(this,"onRelayEventRequest",async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()}),P(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Vt.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Vt.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(r){this.client.logger.warn(r)}}this.requestQueue.state=Vt.idle}),P(this,"processRequest",async s=>{const{topic:r,payload:i,attestation:n,transportType:o,encryptedId:a}=s,c=i.method;if(!this.shouldIgnorePairingRequest({topic:r,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:r,payload:i,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(r,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(r,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(r,i);case"wc_sessionPing":return await this.onSessionPingRequest(r,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(r,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(r,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:r,payload:i,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),P(this,"onRelayEventResponse",async s=>{const{topic:r,payload:i,transportType:n}=s,o=(await this.client.core.history.get(r,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(r,i,n);case"wc_sessionSettle":return this.onSessionSettleResponse(r,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(r,i);case"wc_sessionExtend":return this.onSessionExtendResponse(r,i);case"wc_sessionPing":return this.onSessionPingResponse(r,i);case"wc_sessionRequest":return this.onSessionRequestResponse(r,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(r,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),P(this,"onRelayEventUnknownPayload",s=>{const{topic:r}=s,{message:i}=U("MISSING_OR_INVALID",`Decoded payload on topic ${r} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),P(this,"shouldIgnorePairingRequest",s=>{const{topic:r,requestMethod:i}=s,n=this.expectedPairingMethodMap.get(r);return!n||n.includes(i)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),P(this,"onSessionProposeRequest",async s=>{const{topic:r,payload:i,attestation:n,encryptedId:o}=s,{params:a,id:c}=i;try{const l=this.client.core.eventClient.getEvent({topic:r});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(ls.proposal_listener_not_found)),this.isValidConnect(ve({},i.params));const u=a.expiryTimestamp||De(Fe.wc_sessionPropose.req.ttl),d=ve({id:c,pairingTopic:r,expiryTimestamp:u},a);await this.setProposal(c,d);const h=await this.getVerifyContext({attestationId:n,hash:Xt(JSON.stringify(i)),encryptedId:o,metadata:d.proposer.metadata});l==null||l.addTrace(Gt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:h})}catch(l){await this.sendError({id:c,topic:r,error:l,rpcOpts:Fe.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),P(this,"onSessionProposeResponse",async(s,r,i)=>{const{id:n}=r;if(cs(r)){const{result:o}=r;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(n,{sessionTopic:u,pairingTopic:s,proposalId:n,publicKey:c});const d=await this.client.core.relayer.subscribe(u,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:s})}else if(Jt(r)){await this.client.proposal.delete(n,we("USER_DISCONNECTED"));const o=fe("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:r.error})}}),P(this,"onSessionSettleRequest",async(s,r)=>{const{id:i,params:n}=r;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,scopedProperties:d,sessionConfig:h}=r.params,p=[...this.pendingSessions.values()].find(w=>w.sessionTopic===s);if(!p)return this.client.logger.error(`Pending session not found for topic ${s}`);const g=this.client.proposal.get(p.proposalId),m=rt(ve(ve(ve({topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,controller:a.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),d&&{scopedProperties:d}),h&&{sessionConfig:h}),{transportType:_e.relay});await this.client.session.set(m.topic,m),await this.setExpiry(m.topic,m.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:m.peer.metadata}),this.client.events.emit("session_connect",{session:m}),this.events.emit(fe("session_connect",p.proposalId),{session:m}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(m),await this.sendResult({id:r.id,topic:s,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),P(this,"onSessionSettleResponse",async(s,r)=>{const{id:i}=r;cs(r)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(fe("session_approve",i),{})):Jt(r)&&(await this.client.session.delete(s,we("USER_DISCONNECTED")),this.events.emit(fe("session_approve",i),{error:r.error}))}),P(this,"onSessionUpdateRequest",async(s,r)=>{const{params:i,id:n}=r;try{const o=`${s}_session_update`,a=di.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:s,error:we("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ve({topic:s},i));try{di.set(o,n),await this.client.session.update(s,{namespaces:i.namespaces}),await this.sendResult({id:n,topic:s,result:!0,throwOnFailedPublish:!0})}catch(c){throw di.delete(o),c}this.client.events.emit("session_update",{id:n,topic:s,params:i})}catch(o){await this.sendError({id:n,topic:s,error:o}),this.client.logger.error(o)}}),P(this,"isRequestOutOfSync",(s,r)=>r.toString().slice(0,-3)<s.toString().slice(0,-3)),P(this,"onSessionUpdateResponse",(s,r)=>{const{id:i}=r,n=fe("session_update",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);cs(r)?this.events.emit(fe("session_update",i),{}):Jt(r)&&this.events.emit(fe("session_update",i),{error:r.error})}),P(this,"onSessionExtendRequest",async(s,r)=>{const{id:i}=r;try{this.isValidExtend({topic:s}),await this.setExpiry(s,De(fr)),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),P(this,"onSessionExtendResponse",(s,r)=>{const{id:i}=r,n=fe("session_extend",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);cs(r)?this.events.emit(fe("session_extend",i),{}):Jt(r)&&this.events.emit(fe("session_extend",i),{error:r.error})}),P(this,"onSessionPingRequest",async(s,r)=>{const{id:i}=r;try{this.isValidPing({topic:s}),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:s})}catch(n){await this.sendError({id:i,topic:s,error:n}),this.client.logger.error(n)}}),P(this,"onSessionPingResponse",(s,r)=>{const{id:i}=r,n=fe("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);cs(r)?this.events.emit(fe("session_ping",i),{}):Jt(r)&&this.events.emit(fe("session_ping",i),{error:r.error})},500)}),P(this,"onSessionDeleteRequest",async(s,r)=>{const{id:i}=r;try{this.isValidDisconnect({topic:s,reason:r.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(We.publish,async()=>{n(await this.deleteSession({topic:s,id:i}))})}),this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:s,error:we("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),P(this,"onSessionRequest",async s=>{var r,i,n;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=s,{id:d,params:h}=a;try{await this.isValidRequest(ve({topic:o},h));const p=this.client.session.get(o),g=await this.getVerifyContext({attestationId:c,hash:Xt(JSON.stringify(Ks("wc_sessionRequest",h,d))),encryptedId:l,metadata:p.peer.metadata,transportType:u}),m={id:d,topic:o,params:h,verifyContext:g};await this.setPendingSessionRequest(m),u===_e.link_mode&&(r=p.peer.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp((i=p.peer.metadata.redirect)==null?void 0:i.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(m):(this.addSessionRequestToSessionRequestQueue(m),this.processSessionRequestQueue())}catch(p){await this.sendError({id:d,topic:o,error:p}),this.client.logger.error(p)}}),P(this,"onSessionRequestResponse",(s,r)=>{const{id:i}=r,n=fe("session_request",i);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);cs(r)?this.events.emit(fe("session_request",i),{result:r.result}):Jt(r)&&this.events.emit(fe("session_request",i),{error:r.error})}),P(this,"onSessionEventRequest",async(s,r)=>{const{id:i,params:n}=r;try{const o=`${s}_session_event_${n.event.name}`,a=di.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(ve({topic:s},n)),this.client.events.emit("session_event",{id:i,topic:s,params:n}),di.set(o,i)}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),P(this,"onSessionAuthenticateResponse",(s,r)=>{const{id:i}=r;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:r}),cs(r)?this.events.emit(fe("session_request",i),{result:r.result}):Jt(r)&&this.events.emit(fe("session_request",i),{error:r.error})}),P(this,"onSessionAuthenticateRequest",async s=>{var r;const{topic:i,payload:n,attestation:o,encryptedId:a,transportType:c}=s;try{const{requester:l,authPayload:u,expiryTimestamp:d}=n.params,h=await this.getVerifyContext({attestationId:o,hash:Xt(JSON.stringify(n)),encryptedId:a,metadata:l.metadata,transportType:c}),p={requester:l,pairingTopic:i,id:n.id,authPayload:u,verifyContext:h,expiryTimestamp:d};await this.setAuthRequest(n.id,{request:p,pairingTopic:i,transportType:c}),c===_e.link_mode&&(r=l.metadata.redirect)!=null&&r.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:n.params,id:n.id,verifyContext:h})}catch(l){this.client.logger.error(l);const u=n.params.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),h=this.getAppLinkIfEnabled(n.params.requester.metadata,c),p={type:ps,receiverPublicKey:u,senderPublicKey:d};await this.sendError({id:n.id,topic:i,error:l,encodeOpts:p,rpcOpts:Fe.wc_sessionAuthenticate.autoReject,appLink:h})}}),P(this,"addSessionRequestToSessionRequestQueue",s=>{this.sessionRequestQueue.queue.push(s)}),P(this,"cleanupAfterResponse",s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Vt.idle,this.processSessionRequestQueue()},D.toMiliseconds(this.requestQueueDelay))}),P(this,"cleanupPendingSentRequestsForTopic",({topic:s,error:r})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(n=>n.topic===s&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(fe("session_request",n.request.id),{error:r})})}),P(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Vt.active){this.client.logger.info("session request queue is already active.");return}const s=this.sessionRequestQueue.queue[0];if(!s){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Vt.active,this.emitSessionRequest(s)}catch(r){this.client.logger.error(r)}}),P(this,"emitSessionRequest",s=>{this.client.events.emit("session_request",s)}),P(this,"onPairingCreated",s=>{if(s.methods&&this.expectedPairingMethodMap.set(s.topic,s.methods),s.active)return;const r=this.client.proposal.getAll().find(i=>i.pairingTopic===s.topic);r&&this.onSessionProposeRequest({topic:s.topic,payload:Ks("wc_sessionPropose",rt(ve({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces,relays:r.relays,proposer:r.proposer,sessionProperties:r.sessionProperties,scopedProperties:r.scopedProperties}),r.id)})}),P(this,"isValidConnect",async s=>{if(!ht(s)){const{message:l}=U("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(s)}`);throw new Error(l)}const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:c}=s;if(Xe(r)||await this.isValidPairingTopic(r),!mb(c,!0)){const{message:l}=U("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!Xe(i)&&Ts(i)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(i,"requiredNamespaces")}if(!Xe(n)&&Ts(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Xe(o)||this.validateSessionProps(o,"sessionProperties"),!Xe(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(i||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(u=>l.includes(u)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),P(this,"validateNamespaces",(s,r)=>{const i=gb(s,"connect()",r);if(i)throw new Error(i.message)}),P(this,"isValidApprove",async s=>{if(!ht(s))throw new Error(U("MISSING_OR_INVALID",`approve() params: ${s}`).message);const{id:r,namespaces:i,relayProtocol:n,sessionProperties:o,scopedProperties:a}=s;this.checkRecentlyDeleted(r),await this.isValidProposalId(r);const c=this.client.proposal.get(r),l=jo(i,"approve()");if(l)throw new Error(l.message);const u=xl(c.requiredNamespaces,i,"approve()");if(u)throw new Error(u.message);if(!$e(n,!0)){const{message:d}=U("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(d)}if(Xe(o)||this.validateSessionProps(o,"sessionProperties"),!Xe(a)){this.validateSessionProps(a,"scopedProperties");const d=new Set(Object.keys(i));if(!Object.keys(a).every(h=>d.has(h)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(d).join(", ")}`)}}),P(this,"isValidReject",async s=>{if(!ht(s)){const{message:n}=U("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(n)}const{id:r,reason:i}=s;if(this.checkRecentlyDeleted(r),await this.isValidProposalId(r),!yb(i)){const{message:n}=U("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(n)}}),P(this,"isValidSessionSettleRequest",s=>{if(!ht(s)){const{message:l}=U("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:r,controller:i,namespaces:n,expiry:o}=s;if(!eh(r)){const{message:l}=U("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=lb(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=jo(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Es(o)){const{message:l}=U("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),P(this,"isValidUpdate",async s=>{if(!ht(s)){const{message:c}=U("MISSING_OR_INVALID",`update() params: ${s}`);throw new Error(c)}const{topic:r,namespaces:i}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const n=this.client.session.get(r),o=jo(i,"update()");if(o)throw new Error(o.message);const a=xl(n.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)}),P(this,"isValidExtend",async s=>{if(!ht(s)){const{message:i}=U("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(i)}const{topic:r}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r)}),P(this,"isValidRequest",async s=>{if(!ht(s)){const{message:c}=U("MISSING_OR_INVALID",`request() params: ${s}`);throw new Error(c)}const{topic:r,request:i,chainId:n,expiry:o}=s;this.checkRecentlyDeleted(r),await this.isValidSessionTopic(r);const{namespaces:a}=this.client.session.get(r);if(!Tl(a,n)){const{message:c}=U("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!bb(i)){const{message:c}=U("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!Cb(a,n,i.method)){const{message:c}=U("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}if(o&&!Nb(o,Go)){const{message:c}=U("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Go.min} and ${Go.max}`);throw new Error(c)}}),P(this,"isValidRespond",async s=>{var r;if(!ht(s)){const{message:o}=U("MISSING_OR_INVALID",`respond() params: ${s}`);throw new Error(o)}const{topic:i,response:n}=s;try{await this.isValidSessionTopic(i)}catch(o){throw(r=s==null?void 0:s.response)!=null&&r.id&&this.cleanupAfterResponse(s),o}if(!vb(n)){const{message:o}=U("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),P(this,"isValidPing",async s=>{if(!ht(s)){const{message:i}=U("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),P(this,"isValidEmit",async s=>{if(!ht(s)){const{message:a}=U("MISSING_OR_INVALID",`emit() params: ${s}`);throw new Error(a)}const{topic:r,event:i,chainId:n}=s;await this.isValidSessionTopic(r);const{namespaces:o}=this.client.session.get(r);if(!Tl(o,n)){const{message:a}=U("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!Eb(i)){const{message:a}=U("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!Ib(o,n,i.name)){const{message:a}=U("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}}),P(this,"isValidDisconnect",async s=>{if(!ht(s)){const{message:i}=U("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(i)}const{topic:r}=s;await this.isValidSessionOrPairingTopic(r)}),P(this,"isValidAuthenticate",s=>{const{chains:r,uri:i,domain:n,nonce:o}=s;if(!Array.isArray(r)||r.length===0)throw new Error("chains is required and must be a non-empty array");if(!$e(i,!1))throw new Error("uri is required parameter");if(!$e(n,!1))throw new Error("domain is required parameter");if(!$e(o,!1))throw new Error("nonce is required parameter");if([...new Set(r.map(c=>Rr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Rr(r[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),P(this,"getVerifyContext",async s=>{const{attestationId:r,hash:i,encryptedId:n,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||Ti,validation:"UNKNOWN",origin:o.url||""}};try{if(a===_e.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:r,hash:i,encryptedId:n,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),P(this,"validateSessionProps",(s,r)=>{Object.values(s).forEach((i,n)=>{if(i==null){const{message:o}=U("MISSING_OR_INVALID",`${r} must contain an existing value for each key. Received: ${i} for key ${Object.keys(s)[n]}`);throw new Error(o)}})}),P(this,"getPendingAuthRequest",s=>{const r=this.client.auth.requests.get(s);return typeof r=="object"?r:void 0}),P(this,"addToRecentlyDeleted",(s,r)=>{if(this.recentlyDeletedMap.set(s,r),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=n)break;this.recentlyDeletedMap.delete(o)}}}),P(this,"checkRecentlyDeleted",s=>{const r=this.recentlyDeletedMap.get(s);if(r){const{message:i}=U("MISSING_OR_INVALID",`Record was recently deleted - ${r}: ${s}`);throw new Error(i)}}),P(this,"isLinkModeEnabled",(s,r)=>{var i,n,o,a,c,l,u,d,h;return!s||r!==_e.link_mode?!1:((n=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=s==null?void 0:s.redirect)==null?void 0:u.universal)!==void 0&&((d=s==null?void 0:s.redirect)==null?void 0:d.universal)!==""&&((h=s==null?void 0:s.redirect)==null?void 0:h.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(Q==null?void 0:Q.Linking)<"u"}),P(this,"getAppLinkIfEnabled",(s,r)=>{var i;return this.isLinkModeEnabled(s,r)?(i=s==null?void 0:s.redirect)==null?void 0:i.universal:void 0}),P(this,"handleLinkModeMessage",({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const r=Kc(s,"topic")||"",i=decodeURIComponent(Kc(s,"wc_ev")||""),n=this.client.session.keys.includes(r);n&&this.client.session.update(r,{transportType:_e.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:i,sessionExists:n})}),P(this,"registerLinkModeListeners",async()=>{var s;if(Za()||Rs()&&(s=this.client.metadata.redirect)!=null&&s.linkMode){const r=Q==null?void 0:Q.Linking;if(typeof r<"u"){r.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await r.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}),P(this,"shouldSetTVF",(s,r)=>{if(!r||s!=="wc_sessionRequest")return!1;const{request:i}=r;return Object.keys(ou).includes(i.method)}),P(this,"getTVFParams",(s,r,i)=>{var n,o;try{const a=r.request.method,c=this.extractTxHashesFromResult(a,i);return rt(ve({correlationId:s,rpcMethods:[a],chainId:r.chainId},this.isValidContractData(r.request.params)&&{contractAddresses:[(o=(n=r.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),P(this,"isValidContractData",s=>{var r;if(!s)return!1;try{const i=(s==null?void 0:s.data)||((r=s==null?void 0:s[0])==null?void 0:r.data);if(!i.startsWith("0x"))return!1;const n=i.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),P(this,"extractTxHashesFromResult",(s,r)=>{try{const i=ou[s];if(typeof r=="string")return[r];const n=r[i.key];if(Os(n))return s==="solana_signAllTransactions"?n.map(o=>Km(o)):n;if(typeof n=="string")return[n]}catch(i){this.client.logger.warn("Error extracting tx hashes from result",i)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,s=this.client.core.relayer.messages.getWithoutAck(e);for(const[r,i]of Object.entries(s))for(const n of i)try{await this.onProviderMessageEvent({topic:r,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${r}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=U("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(We.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:s,message:r,attestation:i,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Gn)?this.client.auth.authKeys.get(Gn):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,r,{receiverPublicKey:o,encoding:n===_e.link_mode?Cs:qt});Ka(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:i,transportType:n,encryptedId:Xt(r)})):Va(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:s,payload:a,transportType:n}),this.client.core.history.delete(s,a.id)):await this.onRelayEventUnknownPayload({topic:s,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(s,r)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on($t.expired,async e=>{const{topic:s,id:r}=bd(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,U("EXPIRED"),!0);if(r&&this.client.auth.requests.keys.includes(r))return await this.deletePendingAuthRequest(r,U("EXPIRED"),!0);s?this.client.session.keys.includes(s)&&(await this.deleteSession({topic:s,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:s})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))})}registerPairingEvents(){this.client.core.pairing.events.on(zs.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(zs.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!$e(e,!1)){const{message:s}=U("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(s)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:s}=U("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(Es(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=U("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!$e(e,!1)){const{message:s}=U("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(s)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:s}=U("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(Es(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=U("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=U("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(s)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if($e(e,!1)){const{message:s}=U("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=U("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!wb(e)){const{message:s}=U("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=U("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(Es(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=U("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}}class kE extends ar{constructor(e,s){super(e,s,wE,oc),this.core=e,this.logger=s}}let RE=class extends ar{constructor(e,s){super(e,s,yE,oc),this.core=e,this.logger=s}};class UE extends ar{constructor(e,s){super(e,s,vE,oc,r=>r.id),this.core=e,this.logger=s}}class DE extends ar{constructor(e,s){super(e,s,AE,bo,()=>Gn),this.core=e,this.logger=s}}class LE extends ar{constructor(e,s){super(e,s,_E,bo),this.core=e,this.logger=s}}class ME extends ar{constructor(e,s){super(e,s,NE,bo,r=>r.id),this.core=e,this.logger=s}}var BE=Object.defineProperty,FE=(t,e,s)=>e in t?BE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Jo=(t,e,s)=>FE(t,typeof e!="symbol"?e+"":e,s);class jE{constructor(e,s){this.core=e,this.logger=s,Jo(this,"authKeys"),Jo(this,"pairingTopics"),Jo(this,"requests"),this.authKeys=new DE(this.core,this.logger),this.pairingTopics=new LE(this.core,this.logger),this.requests=new ME(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var qE=Object.defineProperty,WE=(t,e,s)=>e in t?qE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,oe=(t,e,s)=>WE(t,typeof e!="symbol"?e+"":e,s);let zE=class vh extends ig{constructor(e){super(e),oe(this,"protocol",wh),oe(this,"version",yh),oe(this,"name",Vo.name),oe(this,"metadata"),oe(this,"core"),oe(this,"logger"),oe(this,"events",new or.EventEmitter),oe(this,"engine"),oe(this,"session"),oe(this,"proposal"),oe(this,"pendingRequest"),oe(this,"auth"),oe(this,"signConfig"),oe(this,"on",(r,i)=>this.events.on(r,i)),oe(this,"once",(r,i)=>this.events.once(r,i)),oe(this,"off",(r,i)=>this.events.off(r,i)),oe(this,"removeListener",(r,i)=>this.events.removeListener(r,i)),oe(this,"removeAllListeners",r=>this.events.removeAllListeners(r)),oe(this,"connect",async r=>{try{return await this.engine.connect(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"pair",async r=>{try{return await this.engine.pair(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"approve",async r=>{try{return await this.engine.approve(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"reject",async r=>{try{return await this.engine.reject(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"update",async r=>{try{return await this.engine.update(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"extend",async r=>{try{return await this.engine.extend(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"request",async r=>{try{return await this.engine.request(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"respond",async r=>{try{return await this.engine.respond(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"ping",async r=>{try{return await this.engine.ping(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"emit",async r=>{try{return await this.engine.emit(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"disconnect",async r=>{try{return await this.engine.disconnect(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"find",r=>{try{return this.engine.find(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(r){throw this.logger.error(r.message),r}}),oe(this,"authenticate",async(r,i)=>{try{return await this.engine.authenticate(r,i)}catch(n){throw this.logger.error(n.message),n}}),oe(this,"formatAuthMessage",r=>{try{return this.engine.formatAuthMessage(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"approveSessionAuthenticate",async r=>{try{return await this.engine.approveSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),oe(this,"rejectSessionAuthenticate",async r=>{try{return await this.engine.rejectSessionAuthenticate(r)}catch(i){throw this.logger.error(i.message),i}}),this.name=(e==null?void 0:e.name)||Vo.name,this.metadata=nm(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const s=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ha(hn({level:(e==null?void 0:e.logger)||Vo.logger}));this.core=(e==null?void 0:e.core)||new mE(e),this.logger=nt(s,this.name),this.session=new RE(this.core,this.logger),this.proposal=new kE(this.core,this.logger),this.pendingRequest=new UE(this.core,this.logger),this.engine=new $E(this),this.auth=new jE(this.core,this.logger)}static async init(e){const s=new vh(e);return await s.initialize(),s}get context(){return At(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},D.toMiliseconds(D.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const cu="error",HE="wss://relay.walletconnect.org",KE="wc",VE="universal_provider",Ln=`${KE}@2:${VE}:`,Eh="https://rpc.walletconnect.org/v1/",Sr="generic",GE=`${Eh}bundler`,Ut={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function JE(){}function ac(t){return t==null||typeof t!="object"&&typeof t!="function"}function cc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function YE(t){if(ac(t))return t;if(Array.isArray(t)||cc(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const r=new s(t);return r.lastIndex=t.lastIndex,r}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const r=new s(t.message);return r.stack=t.stack,r.name=t.name,r.cause=t.cause,r}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const r=Object.create(e);return Object.assign(r,t)}return t}function lu(t){return typeof t=="object"&&t!==null}function Ch(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Ih(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const XE="[object RegExp]",Ah="[object String]",_h="[object Number]",Nh="[object Boolean]",Sh="[object Arguments]",ZE="[object Symbol]",QE="[object Date]",eC="[object Map]",tC="[object Set]",sC="[object Array]",rC="[object ArrayBuffer]",iC="[object Object]",nC="[object DataView]",oC="[object Uint8Array]",aC="[object Uint8ClampedArray]",cC="[object Uint16Array]",lC="[object Uint32Array]",uC="[object Int8Array]",dC="[object Int16Array]",hC="[object Int32Array]",pC="[object Float32Array]",fC="[object Float64Array]";function gC(t,e){return kr(t,void 0,t,new Map,e)}function kr(t,e,s,r=new Map,i=void 0){const n=i==null?void 0:i(t,e,s,r);if(n!=null)return n;if(ac(t))return t;if(r.has(t))return r.get(t);if(Array.isArray(t)){const o=new Array(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=kr(t[a],a,s,r,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;r.set(t,o);for(const[a,c]of t)o.set(a,kr(c,a,s,r,i));return o}if(t instanceof Set){const o=new Set;r.set(t,o);for(const a of t)o.add(kr(a,void 0,s,r,i));return o}if(typeof Ve<"u"&&Ve.isBuffer(t))return t.subarray();if(cc(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);r.set(t,o);for(let a=0;a<t.length;a++)o[a]=kr(t[a],a,s,r,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return r.set(t,o),Hs(o,t,s,r,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return r.set(t,o),Hs(o,t,s,r,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return r.set(t,o),Hs(o,t,s,r,i),o}if(t instanceof Error){const o=new t.constructor;return r.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Hs(o,t,s,r,i),o}if(typeof t=="object"&&mC(t)){const o=Object.create(Object.getPrototypeOf(t));return r.set(t,o),Hs(o,t,s,r,i),o}return t}function Hs(t,e,s=t,r,i){const n=[...Object.keys(e),...Ch(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=kr(e[a],a,s,r,i))}}function mC(t){switch(Ih(t)){case Sh:case sC:case rC:case nC:case Nh:case QE:case pC:case fC:case uC:case dC:case hC:case eC:case _h:case iC:case XE:case tC:case Ah:case ZE:case oC:case aC:case cC:case lC:return!0;default:return!1}}function wC(t,e){return gC(t,(s,r,i,n)=>{const o=e==null?void 0:e(s,r,i,n);if(o!=null)return o;if(typeof t=="object")switch(Object.prototype.toString.call(t)){case _h:case Ah:case Nh:{const a=new t.constructor(t==null?void 0:t.valueOf());return Hs(a,t),a}case Sh:{const a={};return Hs(a,t),a.length=t.length,a[Symbol.iterator]=t[Symbol.iterator],a}default:return}})}function uu(t){return wC(t)}function du(t){return t!==null&&typeof t=="object"&&Ih(t)==="[object Arguments]"}function yC(t){return cc(t)}function bC(t){var s;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!((s=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&s.writable)?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function vC(t,...e){const s=e.slice(0,-1),r=e[e.length-1];let i=t;for(let n=0;n<s.length;n++){const o=s[n];i=Ma(i,o,r,new Map)}return i}function Ma(t,e,s,r){if(ac(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(r.has(e))return YE(r.get(e));if(r.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const i=[...Object.keys(e),...Ch(e)];for(let n=0;n<i.length;n++){const o=i[n];let a=e[o],c=t[o];if(du(a)&&(a={...a}),du(c)&&(c={...c}),typeof Ve<"u"&&Ve.isBuffer(a)&&(a=uu(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],d=Reflect.ownKeys(c);for(let h=0;h<d.length;h++){const p=d[h];u[p]=c[p]}c=u}else c=[];const l=s(c,a,o,t,e,r);l!=null?t[o]=l:Array.isArray(a)||lu(c)&&lu(a)?t[o]=Ma(c,a,s,r):c==null&&bC(a)?t[o]=Ma({},a,s,r):c==null&&yC(a)?t[o]=uu(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function EC(t,...e){return vC(t,...e,JE)}var CC=Object.defineProperty,IC=Object.defineProperties,AC=Object.getOwnPropertyDescriptors,hu=Object.getOwnPropertySymbols,_C=Object.prototype.hasOwnProperty,NC=Object.prototype.propertyIsEnumerable,pu=(t,e,s)=>e in t?CC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Mn=(t,e)=>{for(var s in e||(e={}))_C.call(e,s)&&pu(t,s,e[s]);if(hu)for(var s of hu(e))NC.call(e,s)&&pu(t,s,e[s]);return t},SC=(t,e)=>IC(t,AC(e));function It(t,e,s){var r;const i=Rr(t);return((r=e.rpcMap)==null?void 0:r[i.reference])||`${Eh}?chainId=${i.namespace}:${i.reference}&projectId=${s}`}function cr(t){return t.includes(":")?t.split(":")[1]:t}function Ph(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function PC(t,e){const s=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!s.length)return[];const r=[];return s.forEach(i=>{const n=e.namespaces[i].accounts;r.push(...n)}),r}function Bn(t={},e={}){const s=fu(t),r=fu(e);return EC(s,r)}function fu(t){var e,s,r,i,n;const o={};if(!Ts(t))return o;for(const[a,c]of Object.entries(t)){const l=wo(a)?[a]:c.chains,u=c.methods||[],d=c.events||[],h=c.rpcMap||{},p=$r(a);o[p]=SC(Mn(Mn({},o[p]),c),{chains:Zt(l,(e=o[p])==null?void 0:e.chains),methods:Zt(u,(s=o[p])==null?void 0:s.methods),events:Zt(d,(r=o[p])==null?void 0:r.events)}),(Ts(h)||Ts(((i=o[p])==null?void 0:i.rpcMap)||{}))&&(o[p].rpcMap=Mn(Mn({},h),(n=o[p])==null?void 0:n.rpcMap))}return o}function gu(t){return t.includes(":")?t.split(":")[2]:t}function mu(t){const e={};for(const[s,r]of Object.entries(t)){const i=r.methods||[],n=r.events||[],o=r.accounts||[],a=wo(s)?[s]:r.chains?r.chains:Ph(r.accounts);e[s]={chains:a,methods:i,events:n,accounts:o}}return e}function Yo(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Oh={},de=t=>Oh[t],Xo=(t,e)=>{Oh[t]=e};var OC=Object.defineProperty,TC=(t,e,s)=>e in t?OC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,gr=(t,e,s)=>TC(t,typeof e!="symbol"?e+"":e,s);class xC{constructor(e){gr(this,"name","polkadot"),gr(this,"client"),gr(this,"httpProviders"),gr(this,"events"),gr(this,"namespace"),gr(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=cr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var $C=Object.defineProperty,kC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,wu=Object.getOwnPropertySymbols,UC=Object.prototype.hasOwnProperty,DC=Object.prototype.propertyIsEnumerable,Ba=(t,e,s)=>e in t?$C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,yu=(t,e)=>{for(var s in e||(e={}))UC.call(e,s)&&Ba(t,s,e[s]);if(wu)for(var s of wu(e))DC.call(e,s)&&Ba(t,s,e[s]);return t},bu=(t,e)=>kC(t,RC(e)),mr=(t,e,s)=>Ba(t,typeof e!="symbol"?e+"":e,s);class LC{constructor(e){mr(this,"name","eip155"),mr(this,"client"),mr(this,"chainId"),mr(this,"namespace"),mr(this,"httpProviders"),mr(this,"events"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s),this.chainId=parseInt(e),this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const r=s||It(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=parseInt(cr(s));e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}async handleSwitchChain(e){var s,r;let i=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const n=parseInt(i,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(r=this.namespace.chains)==null?void 0:r[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var s,r,i,n,o;const a=(r=(s=e.request)==null?void 0:s.params)==null?void 0:r[0],c=((n=(i=e.request)==null?void 0:i.params)==null?void 0:n[1])||[],l=`${a}${c.join(",")}`;if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(e.topic),d=((o=u==null?void 0:u.sessionProperties)==null?void 0:o.capabilities)||{};if(d!=null&&d[l])return d==null?void 0:d[l];const h=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:bu(yu({},u.sessionProperties||{}),{capabilities:bu(yu({},d||{}),{[l]:h})})})}catch(p){console.warn("Failed to update session with capabilities",p)}return h}async getCallStatus(e){var s,r;const i=this.client.session.get(e.topic),n=(s=i.sessionProperties)==null?void 0:s.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(r=i.sessionProperties)==null?void 0:r.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var r;const i=new URL(e),n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ks("eth_getUserOperationReceipt",[(r=s.request.params)==null?void 0:r[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,s){return`${GE}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}}var MC=Object.defineProperty,BC=(t,e,s)=>e in t?MC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,wr=(t,e,s)=>BC(t,typeof e!="symbol"?e+"":e,s);class FC{constructor(e){wr(this,"name","solana"),wr(this,"client"),wr(this,"httpProviders"),wr(this,"events"),wr(this,"namespace"),wr(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=cr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var jC=Object.defineProperty,qC=(t,e,s)=>e in t?jC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,yr=(t,e,s)=>qC(t,typeof e!="symbol"?e+"":e,s);class WC{constructor(e){yr(this,"name","cosmos"),yr(this,"client"),yr(this,"httpProviders"),yr(this,"events"),yr(this,"namespace"),yr(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=cr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var zC=Object.defineProperty,HC=(t,e,s)=>e in t?zC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,br=(t,e,s)=>HC(t,typeof e!="symbol"?e+"":e,s);class KC{constructor(e){br(this,"name","algorand"),br(this,"client"),br(this,"httpProviders"),br(this,"events"),br(this,"namespace"),br(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(!this.httpProviders[e]){const r=s||It(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Rt(new Wt(r,de("disableProviderPing")))}}var VC=Object.defineProperty,GC=(t,e,s)=>e in t?VC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vr=(t,e,s)=>GC(t,typeof e!="symbol"?e+"":e,s);class JC{constructor(e){vr(this,"name","cip34"),vr(this,"client"),vr(this,"httpProviders"),vr(this,"events"),vr(this,"namespace"),vr(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{const r=this.getCardanoRPCUrl(s),i=cr(s);e[i]=this.createHttpProvider(i,r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}getCardanoRPCUrl(e){const s=this.namespace.rpcMap;if(s)return s[e]}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var YC=Object.defineProperty,XC=(t,e,s)=>e in t?YC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Er=(t,e,s)=>XC(t,typeof e!="symbol"?e+"":e,s);class ZC{constructor(e){Er(this,"name","elrond"),Er(this,"client"),Er(this,"httpProviders"),Er(this,"events"),Er(this,"namespace"),Er(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=cr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var QC=Object.defineProperty,eI=(t,e,s)=>e in t?QC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Cr=(t,e,s)=>eI(t,typeof e!="symbol"?e+"":e,s);class tI{constructor(e){Cr(this,"name","multiversx"),Cr(this,"client"),Cr(this,"httpProviders"),Cr(this,"events"),Cr(this,"namespace"),Cr(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;const i=cr(s);e[i]=this.createHttpProvider(i,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var sI=Object.defineProperty,rI=(t,e,s)=>e in t?sI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ir=(t,e,s)=>rI(t,typeof e!="symbol"?e+"":e,s);class iI{constructor(e){Ir(this,"name","near"),Ir(this,"client"),Ir(this,"httpProviders"),Ir(this,"events"),Ir(this,"namespace"),Ir(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||It(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var r;e[s]=this.createHttpProvider(s,(r=this.namespace.rpcMap)==null?void 0:r[s])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace);return typeof r>"u"?void 0:new Rt(new Wt(r,de("disableProviderPing")))}}var nI=Object.defineProperty,oI=(t,e,s)=>e in t?nI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ar=(t,e,s)=>oI(t,typeof e!="symbol"?e+"":e,s);class aI{constructor(e){Ar(this,"name","tezos"),Ar(this,"client"),Ar(this,"httpProviders"),Ar(this,"events"),Ar(this,"namespace"),Ar(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,s){if(this.chainId=e,!this.httpProviders[e]){const r=s||It(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{e[s]=this.createHttpProvider(s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace);return typeof r>"u"?void 0:new Rt(new Wt(r))}}var cI=Object.defineProperty,lI=(t,e,s)=>e in t?cI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,_r=(t,e,s)=>lI(t,typeof e!="symbol"?e+"":e,s);class uI{constructor(e){_r(this,"name",Sr),_r(this,"client"),_r(this,"httpProviders"),_r(this,"events"),_r(this,"namespace"),_r(this,"chainId"),this.namespace=e.namespace,this.events=de("events"),this.client=de("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s),this.chainId=e,this.events.emit(Ut.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const r={};return(s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(i=>{const n=Rr(i);r[`${n.namespace}:${n.reference}`]=this.createHttpProvider(i)}),r}getHttpProvider(e){const s=this.httpProviders[e];if(typeof s>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return s}setHttpProvider(e,s){const r=this.createHttpProvider(e,s);r&&(this.httpProviders[e]=r)}createHttpProvider(e,s){const r=s||It(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new Rt(new Wt(r,de("disableProviderPing")))}}var dI=Object.defineProperty,hI=Object.defineProperties,pI=Object.getOwnPropertyDescriptors,vu=Object.getOwnPropertySymbols,fI=Object.prototype.hasOwnProperty,gI=Object.prototype.propertyIsEnumerable,Fa=(t,e,s)=>e in t?dI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Fn=(t,e)=>{for(var s in e||(e={}))fI.call(e,s)&&Fa(t,s,e[s]);if(vu)for(var s of vu(e))gI.call(e,s)&&Fa(t,s,e[s]);return t},Zo=(t,e)=>hI(t,pI(e)),Tt=(t,e,s)=>Fa(t,typeof e!="symbol"?e+"":e,s);let mI=class Th{constructor(e){Tt(this,"client"),Tt(this,"namespaces"),Tt(this,"optionalNamespaces"),Tt(this,"sessionProperties"),Tt(this,"scopedProperties"),Tt(this,"events",new Wa),Tt(this,"rpcProviders",{}),Tt(this,"session"),Tt(this,"providerOpts"),Tt(this,"logger"),Tt(this,"uri"),Tt(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ha(hn({level:(e==null?void 0:e.logger)||cu})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const s=new Th(e);return await s.initialize(),s}async request(e,s,r){const[i,n]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Fn({},e),chainId:`${i}:${n}`,topic:this.session.topic,expiry:r})}sendAsync(e,s,r,i){const n=new Date().getTime();this.request(e,r,i).then(o=>s(null,lo(n,o))).catch(o=>s(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:we("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:r,response:i}=await this.client.authenticate(e,s);r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();if(this.session=n.session,this.session){const o=mu(this.session.namespaces);this.namespaces=Bn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}removeListener(e,s){this.events.removeListener(e,s)}off(e,s){this.events.off(e,s)}get isWalletConnect(){return!0}async pair(e){const{uri:s,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const i=await r();this.session=i;const n=mu(i.namespaces);return this.namespaces=Bn(this.namespaces,n),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[r,i]=this.validateChain(e),n=this.getProvider(r);n.name===Sr?n.setDefaultChain(`${r}:${i}`,s):n.setDefaultChain(i,s)}catch(r){if(!/Please call connect/.test(r.message))throw r}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(Os(s)){for(const r of s)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,s;if(this.client=this.providerOpts.client||await zE.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cu,relayUrl:this.providerOpts.relayUrl||HE,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else{const r=this.client.session.getAll();this.session=r[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>$r(s)))];Xo("client",this.client),Xo("events",this.events),Xo("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const r=PC(s,this.session),i=Ph(r),n=Bn(this.namespaces,this.optionalNamespaces),o=Zo(Fn({},n[s]),{accounts:r,chains:i});switch(s){case"eip155":this.rpcProviders[s]=new LC({namespace:o});break;case"algorand":this.rpcProviders[s]=new KC({namespace:o});break;case"solana":this.rpcProviders[s]=new FC({namespace:o});break;case"cosmos":this.rpcProviders[s]=new WC({namespace:o});break;case"polkadot":this.rpcProviders[s]=new xC({namespace:o});break;case"cip34":this.rpcProviders[s]=new JC({namespace:o});break;case"elrond":this.rpcProviders[s]=new ZC({namespace:o});break;case"multiversx":this.rpcProviders[s]=new tI({namespace:o});break;case"near":this.rpcProviders[s]=new iI({namespace:o});break;case"tezos":this.rpcProviders[s]=new aI({namespace:o});break;default:this.rpcProviders[Sr]?this.rpcProviders[Sr].updateNamespace(o):this.rpcProviders[Sr]=new uI({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:r}=e;r===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var s;const{params:r,topic:i}=e;if(i!==((s=this.session)==null?void 0:s.topic))return;const{event:n}=r;if(n.name==="accountsChanged"){const o=n.data;o&&Os(o)&&this.events.emit("accountsChanged",o.map(gu))}else if(n.name==="chainChanged"){const o=r.chainId,a=r.event.data,c=$r(o),l=Yo(o)!==Yo(a)?`${c}:${Yo(a)}`:o;this.onChainChanged(l)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:s})=>{var r,i;if(e!==((r=this.session)==null?void 0:r.topic))return;const{namespaces:n}=s,o=(i=this.client)==null?void 0:i.session.get(e);this.session=Zo(Fn({},o),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s})}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Zo(Fn({},we("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Ut.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Sr]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e])})}setNamespaces(e){const{namespaces:s={},optionalNamespaces:r={},sessionProperties:i,scopedProperties:n}=e;this.optionalNamespaces=Bn(s,r),this.sessionProperties=i,this.scopedProperties=n}validateChain(e){const[s,r]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,r];if(s&&!Object.keys(this.namespaces||{}).map(o=>$r(o)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&r)return[s,r];const i=$r(Object.keys(this.namespaces)[0]),n=this.rpcProviders[i].getDefaultChain();return[i,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,s=!1){if(!this.namespaces)return;const[r,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(r,i),this.events.emit("chainChanged",i);const n=this.getProvider(r).getDefaultChain();s||this.getProvider(r).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:n,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:s,newChainId:r}){var i,n;try{if(s===r)return;const o=(n=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:n.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${r}:`)).map(gu);if(!Os(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,s){if(!this.namespaces)return;const r=this.namespaces[e]?e:`${e}:${s}`,i={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=s):this.namespaces[r]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,s){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.setItem(`${Ln}/${e}${i}`,s)}async getFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${Ln}/${e}${r}`)}async deleteFromStore(e){var s;const r=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${Ln}/${e}${r}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const r of s)r.startsWith(Ln)&&await this.client.core.storage.removeItem(r)}catch(s){this.logger.warn("Failed to cleanup storage",s)}}};function jn(t,e){return j.getConnectorId(t)===e}function wI(t){const e=Array.from(f.state.chains.keys());let s=[];return t?(s.push([t,f.state.chains.get(t)]),jn(t,F.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(r=>{r!==t&&jn(r,F.CONNECTOR_ID.WALLET_CONNECT)&&s.push([r,f.state.chains.get(r)])}):jn(t,F.CONNECTOR_ID.AUTH)&&e.forEach(r=>{r!==t&&jn(r,F.CONNECTOR_ID.AUTH)&&s.push([r,f.state.chains.get(r)])})):s=Array.from(f.state.chains.entries()),s}const Le={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"},oo={ConnectorExplorerIds:{[F.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[F.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[F.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[F.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[F.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[Le.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[Le.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[Le.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[Le.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[Le.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[Le.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[Le.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[Le.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[Le.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[Le.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[Le.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[F.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[F.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[F.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[F.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[F.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[F.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[F.CONNECTOR_ID.INJECTED]:"Browser Wallet",[F.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[F.CONNECTOR_ID.COINBASE]:"Coinbase",[F.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[F.CONNECTOR_ID.LEDGER]:"Ledger",[F.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[F.CONNECTOR_ID.INJECTED]:"INJECTED",[F.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[F.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[F.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]},lc={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([s,r])=>{e[`${Le.EIP155}:${s}`]=r}),e},isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())}},yI=new AbortController,Nr={EmbeddedWalletAbortController:yI,UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${bI()?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},IFRAME_LOAD_FAILED:{shortMessage:"Network Error - Could not load embedded wallet",longMessage:()=>"There was an issue loading the embedded wallet. Please try again later."},IFRAME_REQUEST_TIMEOUT:{shortMessage:"Embedded Wallet Request Timed Out",longMessage:()=>"There was an issue doing the request to the embedded wallet. Please try again later."},UNVERIFIED_DOMAIN:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}};function bI(){return typeof window<"u"}const vI={createLogger(t,e="error"){const s=hn({level:e}),{logger:r}=Mu({opts:s});return r.error=(...i)=>{for(const n of i)if(n instanceof Error){t(n,...i);return}t(void 0,...i)},r}},EI="rpc.walletconnect.org";function Eu(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()}const Qo=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],Pr={extendRpcUrlWithProjectId(t,e){let s=!1;try{s=new URL(t).host===EI}catch{s=!1}if(s){const r=new URL(t);return r.searchParams.has("projectId")||r.searchParams.set("projectId",e),r.toString()}return t},isCaipNetwork(t){return"chainNamespace"in t&&"caipNetworkId"in t},getChainNamespace(t){return this.isCaipNetwork(t)?t.chainNamespace:F.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${F.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,s){var i,n,o;const r=(o=(n=(i=t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null?void 0:o[0];return Qo.includes(e)?Eu(e,s):r||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){var h,p,g,m,w;const i=this.getChainNamespace(t),n=this.getCaipNetworkId(t),o=(h=t.rpcUrls.default.http)==null?void 0:h[0],a=this.getDefaultRpcUrl(t,n,s),c=((m=(g=(p=t==null?void 0:t.rpcUrls)==null?void 0:p.chainDefault)==null?void 0:g.http)==null?void 0:m[0])||o,l=((w=r==null?void 0:r[n])==null?void 0:w.map(y=>y.url))||[],u=[...l,a],d=[...l];return c&&!d.includes(c)&&d.push(c),{...t,chainNamespace:i,caipNetworkId:n,assets:{imageId:oo.NetworkImageIds[t.id],imageUrl:e==null?void 0:e[t.id]},rpcUrls:{...t.rpcUrls,default:{http:u},chainDefault:{http:d}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:r}){return t.map(i=>Pr.extendCaipNetwork(i,{customNetworkImageUrls:e,customRpcUrls:r,projectId:s}))},getViemTransport(t,e,s){var i,n,o;const r=[];return s==null||s.forEach(a=>{r.push(Pn(a.url,a.config))}),Qo.includes(t.caipNetworkId)&&r.push(Pn(Eu(t.caipNetworkId,e),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),(o=(n=(i=t==null?void 0:t.rpcUrls)==null?void 0:i.default)==null?void 0:n.http)==null||o.forEach(a=>{r.push(Pn(a))}),Ic(r)},extendWagmiTransports(t,e,s){if(Qo.includes(t.caipNetworkId)){const r=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return Ic([s,Pn(r)])}return s},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:F.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){var c;const e=W.getActiveCaipNetworkId(),s=f.getAllRequestedCaipNetworks(),r=Array.from(((c=f.state.chains)==null?void 0:c.keys())||[]),i=e==null?void 0:e.split(":")[0],n=i?r.includes(i):!1,o=s==null?void 0:s.find(l=>l.caipNetworkId===e);return n&&!o&&e?this.getUnsupportedNetwork(e):o||t||(s==null?void 0:s[0])}},ao={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ut=Ne({providers:{...ao},providerIds:{...ao}}),Se={state:ut,subscribeKey(t,e){return st(ut,t,e)},subscribe(t){return tt(ut,()=>{t(ut)})},subscribeProviders(t){return tt(ut.providers,()=>t(ut.providers))},setProvider(t,e){e&&(ut.providers[t]=er(e))},getProvider(t){return ut.providers[t]},setProviderId(t,e){e&&(ut.providerIds[t]=e)},getProviderId(t){if(t)return ut.providerIds[t]},reset(){ut.providers={...ao},ut.providerIds={...ao}},resetChain(t){ut.providers[t]=void 0,ut.providerIds[t]=void 0}},CI={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(typeof Ns<"u"&&typeof{}<"u"?{}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}},ja={filterOutDuplicatesByRDNS(t){const e=T.state.enableEIP6963?j.state.connectors:[],s=W.getRecentWallets(),r=e.map(a=>{var c;return(c=a.info)==null?void 0:c.rdns}).filter(Boolean),i=s.map(a=>a.rdns).filter(Boolean),n=r.concat(i);if(n.includes("io.metamask.mobile")&&X.isMobile()){const a=n.indexOf("io.metamask.mobile");n[a]="io.metamask"}return t.filter(a=>!n.includes(String(a==null?void 0:a.rdns)))},filterOutDuplicatesByIds(t){const e=j.state.connectors.filter(a=>a.type==="ANNOUNCED"||a.type==="INJECTED"),s=W.getRecentWallets(),r=e.map(a=>a.explorerId),i=s.map(a=>a.id),n=r.concat(i);return t.filter(a=>!n.includes(a==null?void 0:a.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=j.state,{featuredWalletIds:s}=T.state,r=e.filter(o=>o.type==="ANNOUNCED").reduce((o,a)=>{var c;return(c=a.info)!=null&&c.rdns&&(o[a.info.rdns]=!0),o},{});return t.map(o=>({...o,installed:!!o.rdns&&!!r[o.rdns??""]})).sort((o,a)=>{const c=Number(a.installed)-Number(o.installed);if(c!==0)return c;if(s!=null&&s.length){const l=s.indexOf(o.id),u=s.indexOf(a.id);if(l!==-1&&u!==-1)return l-u;if(l!==-1)return-1;if(u!==-1)return 1}return 0})},getConnectOrderMethod(t,e){var c;const s=(t==null?void 0:t.connectMethodsOrder)||((c=T.state.features)==null?void 0:c.connectMethodsOrder),r=e||j.state.connectors;if(s)return s;const{injected:i,announced:n}=Jn.getConnectorsByType(r,K.state.recommended,K.state.featured),o=i.filter(Jn.showConnector),a=n.filter(Jn.showConnector);return o.length||a.length?["wallet","email","social"]:CI.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(t){const e=!!t.rdns&&K.state.excludedWallets.some(r=>r.rdns===t.rdns),s=!!t.name&&K.state.excludedWallets.some(r=>lc.isLowerCaseMatch(r.name,t.name));return e||s}},Jn={getConnectorsByType(t,e,s){const{customWallets:r}=T.state,i=W.getRecentWallets(),n=ja.filterOutDuplicateWallets(e),o=ja.filterOutDuplicateWallets(s),a=t.filter(d=>d.type==="MULTI_CHAIN"),c=t.filter(d=>d.type==="ANNOUNCED"),l=t.filter(d=>d.type==="INJECTED"),u=t.filter(d=>d.type==="EXTERNAL");return{custom:r,recent:i,external:u,multiChain:a,announced:c,injected:l,recommended:n,featured:o}},showConnector(t){var i;const e=(i=t.info)==null?void 0:i.rdns,s=!!e&&K.state.excludedWallets.some(n=>!!n.rdns&&n.rdns===e),r=!!t.name&&K.state.excludedWallets.some(n=>lc.isLowerCaseMatch(n.name,t.name));return!(t.type==="INJECTED"&&(t.name==="Browser Wallet"&&(!X.isMobile()||X.isMobile()&&!e&&!Y.checkInstalled())||s||r)||(t.type==="ANNOUNCED"||t.type==="EXTERNAL")&&(s||r))},getIsConnectedWithWC(){return Array.from(f.state.chains.values()).some(s=>j.getConnectorId(s.namespace)===F.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:s,recent:r,announced:i,injected:n,multiChain:o,external:a,overriddenConnectors:c=(l=>(l=T.state.features)==null?void 0:l.connectorTypeOrder)()??[]}){const u=Jn.getIsConnectedWithWC(),p=[{type:"walletConnect",isEnabled:T.state.enableWalletConnect&&!u},{type:"recent",isEnabled:r.length>0},{type:"injected",isEnabled:[...n,...i,...o].length>0},{type:"featured",isEnabled:e.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:t.length>0}].filter(y=>y.isEnabled),g=new Set(p.map(y=>y.type)),m=c.filter(y=>g.has(y)).map(y=>({type:y,isEnabled:!0})),w=p.filter(({type:y})=>!m.some(({type:v})=>v===y));return Array.from(new Set([...m,...w].map(({type:y})=>y)))}};/**
|
|
17
|
-
* @license
|
|
18
|
-
* Copyright 2019 Google LLC
|
|
19
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
20
|
-
*/const Yn=globalThis,uc=Yn.ShadowRoot&&(Yn.ShadyCSS===void 0||Yn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dc=Symbol(),Cu=new WeakMap;let xh=class{constructor(e,s,r){if(this._$cssResult$=!0,r!==dc)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=s}get styleSheet(){let e=this.o;const s=this.t;if(uc&&e===void 0){const r=s!==void 0&&s.length===1;r&&(e=Cu.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Cu.set(s,e))}return e}toString(){return this.cssText}};const xt=t=>new xh(typeof t=="string"?t:t+"",void 0,dc),Ur=(t,...e)=>{const s=t.length===1?t[0]:e.reduce((r,i,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1],t[0]);return new xh(s,t,dc)},II=(t,e)=>{if(uc)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const r=document.createElement("style"),i=Yn.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=s.cssText,t.appendChild(r)}},Iu=uc?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const r of e.cssRules)s+=r.cssText;return xt(s)})(t):t;/**
|
|
21
|
-
* @license
|
|
22
|
-
* Copyright 2017 Google LLC
|
|
23
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
24
|
-
*/const{is:AI,defineProperty:_I,getOwnPropertyDescriptor:NI,getOwnPropertyNames:SI,getOwnPropertySymbols:PI,getPrototypeOf:OI}=Object,xs=globalThis,Au=xs.trustedTypes,TI=Au?Au.emptyScript:"",ea=xs.reactiveElementPolyfillSupport,$i=(t,e)=>t,qa={toAttribute(t,e){switch(e){case Boolean:t=t?TI:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=t!==null;break;case Number:s=t===null?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},$h=(t,e)=>!AI(t,e),_u={attribute:!0,type:String,converter:qa,reflect:!1,useDefault:!1,hasChanged:$h};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),xs.litPropertyMetadata??(xs.litPropertyMetadata=new WeakMap);let Or=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,s=_u){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(e,s),!s.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,s);i!==void 0&&_I(this.prototype,e,i)}}static getPropertyDescriptor(e,s,r){const{get:i,set:n}=NI(this.prototype,e)??{get(){return this[s]},set(o){this[s]=o}};return{get:i,set(o){const a=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_u}static _$Ei(){if(this.hasOwnProperty($i("elementProperties")))return;const e=OI(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty($i("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($i("properties"))){const s=this.properties,r=[...SI(s),...PI(s)];for(const i of r)this.createProperty(i,s[i])}const e=this[Symbol.metadata];if(e!==null){const s=litPropertyMetadata.get(e);if(s!==void 0)for(const[r,i]of s)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[s,r]of this.elementProperties){const i=this._$Eu(s,r);i!==void 0&&this._$Eh.set(i,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const s=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const i of r)s.unshift(Iu(i))}else e!==void 0&&s.push(Iu(e));return s}static _$Eu(e,s){const r=s.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(s=>this.enableUpdating=s),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(s=>s(this))}addController(e){var s;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((s=e.hostConnected)==null||s.call(e))}removeController(e){var s;(s=this._$EO)==null||s.delete(e)}_$E_(){const e=new Map,s=this.constructor.elementProperties;for(const r of s.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return II(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostConnected)==null?void 0:r.call(s)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostDisconnected)==null?void 0:r.call(s)})}attributeChangedCallback(e,s,r){this._$AK(e,r)}_$ET(e,s){var n;const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const o=(((n=r.converter)==null?void 0:n.toAttribute)!==void 0?r.converter:qa).toAttribute(s,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,s){var n,o;const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const a=r.getPropertyOptions(i),c=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:qa;this._$Em=i,this[i]=c.fromAttribute(s,a.type)??((o=this._$Ej)==null?void 0:o.get(i))??null,this._$Em=null}}requestUpdate(e,s,r){var i;if(e!==void 0){const n=this.constructor,o=this[e];if(r??(r=n.getPropertyOptions(e)),!((r.hasChanged??$h)(o,s)||r.useDefault&&r.reflect&&o===((i=this._$Ej)==null?void 0:i.get(e))&&!this.hasAttribute(n._$Eu(e,r))))return;this.C(e,s,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,s,{useDefault:r,reflect:i,wrapped:n},o){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??s??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(s=void 0),this._$AL.set(e,s)),i===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:a}=o,c=this[n];a!==!0||this._$AL.has(n)||c===void 0||this.C(n,void 0,o,c)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),(r=this._$EO)==null||r.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(s)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(s)}willUpdate(e){}_$AE(e){var s;(s=this._$EO)==null||s.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(s=>this._$ET(s,this[s]))),this._$EM()}updated(e){}firstUpdated(e){}};Or.elementStyles=[],Or.shadowRootOptions={mode:"open"},Or[$i("elementProperties")]=new Map,Or[$i("finalized")]=new Map,ea==null||ea({ReactiveElement:Or}),(xs.reactiveElementVersions??(xs.reactiveElementVersions=[])).push("2.1.0");/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/const ki=globalThis,co=ki.trustedTypes,Nu=co?co.createPolicy("lit-html",{createHTML:t=>t}):void 0,kh="$lit$",Is=`lit$${Math.random().toFixed(9).slice(2)}$`,Rh="?"+Is,xI=`<${Rh}>`,nr=document,ln=()=>nr.createComment(""),un=t=>t===null||typeof t!="object"&&typeof t!="function",hc=Array.isArray,$I=t=>hc(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",ta=`[
|
|
29
|
-
\f\r]`,mi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Su=/-->/g,Pu=/>/g,Bs=RegExp(`>|${ta}(?:([^\\s"'>=/]+)(${ta}*=${ta}*(?:[^
|
|
30
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ou=/'/g,Tu=/"/g,Uh=/^(?:script|style|textarea|title)$/i,Dh=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),OA=Dh(1),TA=Dh(2),Jr=Symbol.for("lit-noChange"),ze=Symbol.for("lit-nothing"),xu=new WeakMap,Js=nr.createTreeWalker(nr,129);function Lh(t,e){if(!hc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Nu!==void 0?Nu.createHTML(e):e}const kI=(t,e)=>{const s=t.length-1,r=[];let i,n=e===2?"<svg>":e===3?"<math>":"",o=mi;for(let a=0;a<s;a++){const c=t[a];let l,u,d=-1,h=0;for(;h<c.length&&(o.lastIndex=h,u=o.exec(c),u!==null);)h=o.lastIndex,o===mi?u[1]==="!--"?o=Su:u[1]!==void 0?o=Pu:u[2]!==void 0?(Uh.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=Bs):u[3]!==void 0&&(o=Bs):o===Bs?u[0]===">"?(o=i??mi,d=-1):u[1]===void 0?d=-2:(d=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?Bs:u[3]==='"'?Tu:Ou):o===Tu||o===Ou?o=Bs:o===Su||o===Pu?o=mi:(o=Bs,i=void 0);const p=o===Bs&&t[a+1].startsWith("/>")?" ":"";n+=o===mi?c+xI:d>=0?(r.push(l),c.slice(0,d)+kh+c.slice(d)+Is+p):c+Is+(d===-2?a:p)}return[Lh(t,n+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class dn{constructor({strings:e,_$litType$:s},r){let i;this.parts=[];let n=0,o=0;const a=e.length-1,c=this.parts,[l,u]=kI(e,s);if(this.el=dn.createElement(l,r),Js.currentNode=this.el.content,s===2||s===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Js.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(kh)){const h=u[o++],p=i.getAttribute(d).split(Is),g=/([.?@])?(.*)/.exec(h);c.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?UI:g[1]==="?"?DI:g[1]==="@"?LI:vo}),i.removeAttribute(d)}else d.startsWith(Is)&&(c.push({type:6,index:n}),i.removeAttribute(d));if(Uh.test(i.tagName)){const d=i.textContent.split(Is),h=d.length-1;if(h>0){i.textContent=co?co.emptyScript:"";for(let p=0;p<h;p++)i.append(d[p],ln()),Js.nextNode(),c.push({type:2,index:++n});i.append(d[h],ln())}}}else if(i.nodeType===8)if(i.data===Rh)c.push({type:2,index:n});else{let d=-1;for(;(d=i.data.indexOf(Is,d+1))!==-1;)c.push({type:7,index:n}),d+=Is.length-1}n++}}static createElement(e,s){const r=nr.createElement("template");return r.innerHTML=e,r}}function Yr(t,e,s=t,r){var o,a;if(e===Jr)return e;let i=r!==void 0?(o=s._$Co)==null?void 0:o[r]:s._$Cl;const n=un(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),n===void 0?i=void 0:(i=new n(t),i._$AT(t,s,r)),r!==void 0?(s._$Co??(s._$Co=[]))[r]=i:s._$Cl=i),i!==void 0&&(e=Yr(t,i._$AS(t,e.values),i,r)),e}class RI{constructor(e,s){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:s},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??nr).importNode(s,!0);Js.currentNode=i;let n=Js.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new En(n,n.nextSibling,this,e):c.type===1?l=new c.ctor(n,c.name,c.strings,this,e):c.type===6&&(l=new MI(n,this,e)),this._$AV.push(l),c=r[++a]}o!==(c==null?void 0:c.index)&&(n=Js.nextNode(),o++)}return Js.currentNode=nr,i}p(e){let s=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,s),s+=r.strings.length-2):r._$AI(e[s])),s++}}class En{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,s,r,i){this.type=2,this._$AH=ze,this._$AN=void 0,this._$AA=e,this._$AB=s,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=Yr(this,e,s),un(e)?e===ze||e==null||e===""?(this._$AH!==ze&&this._$AR(),this._$AH=ze):e!==this._$AH&&e!==Jr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):$I(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ze&&un(this._$AH)?this._$AA.nextSibling.data=e:this.T(nr.createTextNode(e)),this._$AH=e}$(e){var n;const{values:s,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=dn.createElement(Lh(r.h,r.h[0]),this.options)),r);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(s);else{const o=new RI(i,this),a=o.u(this.options);o.p(s),this.T(a),this._$AH=o}}_$AC(e){let s=xu.get(e.strings);return s===void 0&&xu.set(e.strings,s=new dn(e)),s}k(e){hc(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let r,i=0;for(const n of e)i===s.length?s.push(r=new En(this.O(ln()),this.O(ln()),this,this.options)):r=s[i],r._$AI(n),i++;i<s.length&&(this._$AR(r&&r._$AB.nextSibling,i),s.length=i)}_$AR(e=this._$AA.nextSibling,s){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,s);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var s;this._$AM===void 0&&(this._$Cv=e,(s=this._$AP)==null||s.call(this,e))}}class vo{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,s,r,i,n){this.type=1,this._$AH=ze,this._$AN=void 0,this.element=e,this.name=s,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ze}_$AI(e,s=this,r,i){const n=this.strings;let o=!1;if(n===void 0)e=Yr(this,e,s,0),o=!un(e)||e!==this._$AH&&e!==Jr,o&&(this._$AH=e);else{const a=e;let c,l;for(e=n[0],c=0;c<n.length-1;c++)l=Yr(this,a[r+c],s,c),l===Jr&&(l=this._$AH[c]),o||(o=!un(l)||l!==this._$AH[c]),l===ze?e=ze:e!==ze&&(e+=(l??"")+n[c+1]),this._$AH[c]=l}o&&!i&&this.j(e)}j(e){e===ze?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class UI extends vo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ze?void 0:e}}class DI extends vo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ze)}}class LI extends vo{constructor(e,s,r,i,n){super(e,s,r,i,n),this.type=5}_$AI(e,s=this){if((e=Yr(this,e,s,0)??ze)===Jr)return;const r=this._$AH,i=e===ze&&r!==ze||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,n=e!==ze&&(r===ze||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var s;typeof this._$AH=="function"?this._$AH.call(((s=this.options)==null?void 0:s.host)??this.element,e):this._$AH.handleEvent(e)}}class MI{constructor(e,s,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=s,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Yr(this,e)}}const sa=ki.litHtmlPolyfillSupport;sa==null||sa(dn,En),(ki.litHtmlVersions??(ki.litHtmlVersions=[])).push("3.3.0");const BI=(t,e,s)=>{const r=(s==null?void 0:s.renderBefore)??e;let i=r._$litPart$;if(i===void 0){const n=(s==null?void 0:s.renderBefore)??null;r._$litPart$=i=new En(e.insertBefore(ln(),n),n,void 0,s??{})}return i._$AI(t),i};/**
|
|
31
|
-
* @license
|
|
32
|
-
* Copyright 2017 Google LLC
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*/const Qs=globalThis;class Xn extends Or{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;const e=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=e.firstChild),e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=BI(s,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Jr}}var Uu;Xn._$litElement$=!0,Xn.finalized=!0,(Uu=Qs.litElementHydrateSupport)==null||Uu.call(Qs,{LitElement:Xn});const ra=Qs.litElementPolyfillSupport;ra==null||ra({LitElement:Xn});(Qs.litElementVersions??(Qs.litElementVersions=[])).push("4.2.0");let Ri,$s,ks;function xA(t,e){Ri=document.createElement("style"),$s=document.createElement("style"),ks=document.createElement("style"),Ri.textContent=Dr(t).core.cssText,$s.textContent=Dr(t).dark.cssText,ks.textContent=Dr(t).light.cssText,document.head.appendChild(Ri),document.head.appendChild($s),document.head.appendChild(ks),Mh(e)}function Mh(t){$s&&ks&&(t==="light"?($s.removeAttribute("media"),ks.media="enabled"):(ks.removeAttribute("media"),$s.media="enabled"))}function FI(t){Ri&&$s&&ks&&(Ri.textContent=Dr(t).core.cssText,$s.textContent=Dr(t).dark.cssText,ks.textContent=Dr(t).light.cssText)}function Dr(t){return{core:Ur`
|
|
35
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
36
|
-
@keyframes w3m-shake {
|
|
37
|
-
0% {
|
|
38
|
-
transform: scale(1) rotate(0deg);
|
|
39
|
-
}
|
|
40
|
-
20% {
|
|
41
|
-
transform: scale(1) rotate(-1deg);
|
|
42
|
-
}
|
|
43
|
-
40% {
|
|
44
|
-
transform: scale(1) rotate(1.5deg);
|
|
45
|
-
}
|
|
46
|
-
60% {
|
|
47
|
-
transform: scale(1) rotate(-1.5deg);
|
|
48
|
-
}
|
|
49
|
-
80% {
|
|
50
|
-
transform: scale(1) rotate(1deg);
|
|
51
|
-
}
|
|
52
|
-
100% {
|
|
53
|
-
transform: scale(1) rotate(0deg);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
@keyframes w3m-iframe-fade-out {
|
|
57
|
-
0% {
|
|
58
|
-
opacity: 1;
|
|
59
|
-
}
|
|
60
|
-
100% {
|
|
61
|
-
opacity: 0;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
@keyframes w3m-iframe-zoom-in {
|
|
65
|
-
0% {
|
|
66
|
-
transform: translateY(50px);
|
|
67
|
-
opacity: 0;
|
|
68
|
-
}
|
|
69
|
-
100% {
|
|
70
|
-
transform: translateY(0px);
|
|
71
|
-
opacity: 1;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
@keyframes w3m-iframe-zoom-in-mobile {
|
|
75
|
-
0% {
|
|
76
|
-
transform: scale(0.95);
|
|
77
|
-
opacity: 0;
|
|
78
|
-
}
|
|
79
|
-
100% {
|
|
80
|
-
transform: scale(1);
|
|
81
|
-
opacity: 1;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
:root {
|
|
85
|
-
--w3m-modal-width: 360px;
|
|
86
|
-
--w3m-color-mix-strength: ${xt(t!=null&&t["--w3m-color-mix-strength"]?`${t["--w3m-color-mix-strength"]}%`:"0%")};
|
|
87
|
-
--w3m-font-family: ${xt((t==null?void 0:t["--w3m-font-family"])||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
88
|
-
--w3m-font-size-master: ${xt((t==null?void 0:t["--w3m-font-size-master"])||"10px")};
|
|
89
|
-
--w3m-border-radius-master: ${xt((t==null?void 0:t["--w3m-border-radius-master"])||"4px")};
|
|
90
|
-
--w3m-z-index: ${xt((t==null?void 0:t["--w3m-z-index"])||999)};
|
|
91
|
-
|
|
92
|
-
--wui-font-family: var(--w3m-font-family);
|
|
93
|
-
|
|
94
|
-
--wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
|
|
95
|
-
--wui-font-size-micro: var(--w3m-font-size-master);
|
|
96
|
-
--wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
|
|
97
|
-
--wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
|
|
98
|
-
--wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
|
|
99
|
-
--wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
|
|
100
|
-
--wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
|
|
101
|
-
--wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
|
|
102
|
-
--wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
|
|
103
|
-
--wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
|
|
104
|
-
|
|
105
|
-
--wui-border-radius-5xs: var(--w3m-border-radius-master);
|
|
106
|
-
--wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
|
|
107
|
-
--wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
|
|
108
|
-
--wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
|
|
109
|
-
--wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
|
|
110
|
-
--wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
|
|
111
|
-
--wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
|
|
112
|
-
--wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
|
|
113
|
-
--wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
|
|
114
|
-
|
|
115
|
-
--wui-font-weight-light: 400;
|
|
116
|
-
--wui-font-weight-regular: 500;
|
|
117
|
-
--wui-font-weight-medium: 600;
|
|
118
|
-
--wui-font-weight-bold: 700;
|
|
119
|
-
|
|
120
|
-
--wui-letter-spacing-2xl: -1.6px;
|
|
121
|
-
--wui-letter-spacing-medium-title: -0.96px;
|
|
122
|
-
--wui-letter-spacing-title-6: -0.88px;
|
|
123
|
-
--wui-letter-spacing-large: -0.8px;
|
|
124
|
-
--wui-letter-spacing-medium: -0.72px;
|
|
125
|
-
--wui-letter-spacing-paragraph: -0.64px;
|
|
126
|
-
--wui-letter-spacing-small: -0.56px;
|
|
127
|
-
--wui-letter-spacing-tiny: -0.48px;
|
|
128
|
-
--wui-letter-spacing-micro: -0.2px;
|
|
129
|
-
--wui-letter-spacing-mini: -0.16px;
|
|
130
|
-
|
|
131
|
-
--wui-spacing-0: 0px;
|
|
132
|
-
--wui-spacing-4xs: 2px;
|
|
133
|
-
--wui-spacing-3xs: 4px;
|
|
134
|
-
--wui-spacing-xxs: 6px;
|
|
135
|
-
--wui-spacing-2xs: 7px;
|
|
136
|
-
--wui-spacing-xs: 8px;
|
|
137
|
-
--wui-spacing-1xs: 10px;
|
|
138
|
-
--wui-spacing-s: 12px;
|
|
139
|
-
--wui-spacing-m: 14px;
|
|
140
|
-
--wui-spacing-l: 16px;
|
|
141
|
-
--wui-spacing-2l: 18px;
|
|
142
|
-
--wui-spacing-xl: 20px;
|
|
143
|
-
--wui-spacing-xxl: 24px;
|
|
144
|
-
--wui-spacing-2xl: 32px;
|
|
145
|
-
--wui-spacing-3xl: 40px;
|
|
146
|
-
--wui-spacing-4xl: 90px;
|
|
147
|
-
--wui-spacing-5xl: 95px;
|
|
148
|
-
|
|
149
|
-
--wui-icon-box-size-xxs: 14px;
|
|
150
|
-
--wui-icon-box-size-xs: 20px;
|
|
151
|
-
--wui-icon-box-size-sm: 24px;
|
|
152
|
-
--wui-icon-box-size-md: 32px;
|
|
153
|
-
--wui-icon-box-size-mdl: 36px;
|
|
154
|
-
--wui-icon-box-size-lg: 40px;
|
|
155
|
-
--wui-icon-box-size-2lg: 48px;
|
|
156
|
-
--wui-icon-box-size-xl: 64px;
|
|
157
|
-
|
|
158
|
-
--wui-icon-size-inherit: inherit;
|
|
159
|
-
--wui-icon-size-xxs: 10px;
|
|
160
|
-
--wui-icon-size-xs: 12px;
|
|
161
|
-
--wui-icon-size-sm: 14px;
|
|
162
|
-
--wui-icon-size-md: 16px;
|
|
163
|
-
--wui-icon-size-mdl: 18px;
|
|
164
|
-
--wui-icon-size-lg: 20px;
|
|
165
|
-
--wui-icon-size-xl: 24px;
|
|
166
|
-
--wui-icon-size-xxl: 28px;
|
|
167
|
-
|
|
168
|
-
--wui-wallet-image-size-inherit: inherit;
|
|
169
|
-
--wui-wallet-image-size-sm: 40px;
|
|
170
|
-
--wui-wallet-image-size-md: 56px;
|
|
171
|
-
--wui-wallet-image-size-lg: 80px;
|
|
172
|
-
|
|
173
|
-
--wui-visual-size-size-inherit: inherit;
|
|
174
|
-
--wui-visual-size-sm: 40px;
|
|
175
|
-
--wui-visual-size-md: 55px;
|
|
176
|
-
--wui-visual-size-lg: 80px;
|
|
177
|
-
|
|
178
|
-
--wui-box-size-md: 100px;
|
|
179
|
-
--wui-box-size-lg: 120px;
|
|
180
|
-
|
|
181
|
-
--wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
|
|
182
|
-
--wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
|
|
183
|
-
|
|
184
|
-
--wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
|
|
185
|
-
--wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
|
|
186
|
-
--wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
|
|
187
|
-
|
|
188
|
-
--wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
|
|
189
|
-
|
|
190
|
-
--wui-duration-lg: 200ms;
|
|
191
|
-
--wui-duration-md: 125ms;
|
|
192
|
-
--wui-duration-sm: 75ms;
|
|
193
|
-
|
|
194
|
-
--wui-path-network-sm: path(
|
|
195
|
-
'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
--wui-path-network-md: path(
|
|
199
|
-
'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
--wui-path-network-lg: path(
|
|
203
|
-
'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
--wui-width-network-sm: 36px;
|
|
207
|
-
--wui-width-network-md: 48px;
|
|
208
|
-
--wui-width-network-lg: 86px;
|
|
209
|
-
|
|
210
|
-
--wui-height-network-sm: 40px;
|
|
211
|
-
--wui-height-network-md: 54px;
|
|
212
|
-
--wui-height-network-lg: 96px;
|
|
213
|
-
|
|
214
|
-
--wui-icon-size-network-xs: 12px;
|
|
215
|
-
--wui-icon-size-network-sm: 16px;
|
|
216
|
-
--wui-icon-size-network-md: 24px;
|
|
217
|
-
--wui-icon-size-network-lg: 42px;
|
|
218
|
-
|
|
219
|
-
--wui-color-inherit: inherit;
|
|
220
|
-
|
|
221
|
-
--wui-color-inverse-100: #fff;
|
|
222
|
-
--wui-color-inverse-000: #000;
|
|
223
|
-
|
|
224
|
-
--wui-cover: rgba(20, 20, 20, 0.8);
|
|
225
|
-
|
|
226
|
-
--wui-color-modal-bg: var(--wui-color-modal-bg-base);
|
|
227
|
-
|
|
228
|
-
--wui-color-accent-100: var(--wui-color-accent-base-100);
|
|
229
|
-
--wui-color-accent-090: var(--wui-color-accent-base-090);
|
|
230
|
-
--wui-color-accent-080: var(--wui-color-accent-base-080);
|
|
231
|
-
|
|
232
|
-
--wui-color-success-100: var(--wui-color-success-base-100);
|
|
233
|
-
--wui-color-success-125: var(--wui-color-success-base-125);
|
|
234
|
-
|
|
235
|
-
--wui-color-warning-100: var(--wui-color-warning-base-100);
|
|
236
|
-
|
|
237
|
-
--wui-color-error-100: var(--wui-color-error-base-100);
|
|
238
|
-
--wui-color-error-125: var(--wui-color-error-base-125);
|
|
239
|
-
|
|
240
|
-
--wui-color-blue-100: var(--wui-color-blue-base-100);
|
|
241
|
-
--wui-color-blue-90: var(--wui-color-blue-base-90);
|
|
242
|
-
|
|
243
|
-
--wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
|
|
244
|
-
--wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
|
|
245
|
-
--wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
|
|
246
|
-
--wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
|
|
247
|
-
|
|
248
|
-
--wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
|
|
249
|
-
|
|
250
|
-
--wui-avatar-border: var(--wui-avatar-border-base);
|
|
251
|
-
|
|
252
|
-
--wui-thumbnail-border: var(--wui-thumbnail-border-base);
|
|
253
|
-
|
|
254
|
-
--wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
|
|
255
|
-
|
|
256
|
-
--wui-box-shadow-blue: var(--wui-color-accent-glass-020);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@supports (background: color-mix(in srgb, white 50%, black)) {
|
|
260
|
-
:root {
|
|
261
|
-
--wui-color-modal-bg: color-mix(
|
|
262
|
-
in srgb,
|
|
263
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
264
|
-
var(--wui-color-modal-bg-base)
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
--wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
|
|
268
|
-
|
|
269
|
-
--wui-color-accent-100: color-mix(
|
|
270
|
-
in srgb,
|
|
271
|
-
var(--wui-color-accent-base-100) 100%,
|
|
272
|
-
transparent
|
|
273
|
-
);
|
|
274
|
-
--wui-color-accent-090: color-mix(
|
|
275
|
-
in srgb,
|
|
276
|
-
var(--wui-color-accent-base-100) 90%,
|
|
277
|
-
transparent
|
|
278
|
-
);
|
|
279
|
-
--wui-color-accent-080: color-mix(
|
|
280
|
-
in srgb,
|
|
281
|
-
var(--wui-color-accent-base-100) 80%,
|
|
282
|
-
transparent
|
|
283
|
-
);
|
|
284
|
-
--wui-color-accent-glass-090: color-mix(
|
|
285
|
-
in srgb,
|
|
286
|
-
var(--wui-color-accent-base-100) 90%,
|
|
287
|
-
transparent
|
|
288
|
-
);
|
|
289
|
-
--wui-color-accent-glass-080: color-mix(
|
|
290
|
-
in srgb,
|
|
291
|
-
var(--wui-color-accent-base-100) 80%,
|
|
292
|
-
transparent
|
|
293
|
-
);
|
|
294
|
-
--wui-color-accent-glass-020: color-mix(
|
|
295
|
-
in srgb,
|
|
296
|
-
var(--wui-color-accent-base-100) 20%,
|
|
297
|
-
transparent
|
|
298
|
-
);
|
|
299
|
-
--wui-color-accent-glass-015: color-mix(
|
|
300
|
-
in srgb,
|
|
301
|
-
var(--wui-color-accent-base-100) 15%,
|
|
302
|
-
transparent
|
|
303
|
-
);
|
|
304
|
-
--wui-color-accent-glass-010: color-mix(
|
|
305
|
-
in srgb,
|
|
306
|
-
var(--wui-color-accent-base-100) 10%,
|
|
307
|
-
transparent
|
|
308
|
-
);
|
|
309
|
-
--wui-color-accent-glass-005: color-mix(
|
|
310
|
-
in srgb,
|
|
311
|
-
var(--wui-color-accent-base-100) 5%,
|
|
312
|
-
transparent
|
|
313
|
-
);
|
|
314
|
-
--wui-color-accent-002: color-mix(
|
|
315
|
-
in srgb,
|
|
316
|
-
var(--wui-color-accent-base-100) 2%,
|
|
317
|
-
transparent
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
--wui-color-fg-100: color-mix(
|
|
321
|
-
in srgb,
|
|
322
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
323
|
-
var(--wui-color-fg-100)
|
|
324
|
-
);
|
|
325
|
-
--wui-color-fg-125: color-mix(
|
|
326
|
-
in srgb,
|
|
327
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
328
|
-
var(--wui-color-fg-125)
|
|
329
|
-
);
|
|
330
|
-
--wui-color-fg-150: color-mix(
|
|
331
|
-
in srgb,
|
|
332
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
333
|
-
var(--wui-color-fg-150)
|
|
334
|
-
);
|
|
335
|
-
--wui-color-fg-175: color-mix(
|
|
336
|
-
in srgb,
|
|
337
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
338
|
-
var(--wui-color-fg-175)
|
|
339
|
-
);
|
|
340
|
-
--wui-color-fg-200: color-mix(
|
|
341
|
-
in srgb,
|
|
342
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
343
|
-
var(--wui-color-fg-200)
|
|
344
|
-
);
|
|
345
|
-
--wui-color-fg-225: color-mix(
|
|
346
|
-
in srgb,
|
|
347
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
348
|
-
var(--wui-color-fg-225)
|
|
349
|
-
);
|
|
350
|
-
--wui-color-fg-250: color-mix(
|
|
351
|
-
in srgb,
|
|
352
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
353
|
-
var(--wui-color-fg-250)
|
|
354
|
-
);
|
|
355
|
-
--wui-color-fg-275: color-mix(
|
|
356
|
-
in srgb,
|
|
357
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
358
|
-
var(--wui-color-fg-275)
|
|
359
|
-
);
|
|
360
|
-
--wui-color-fg-300: color-mix(
|
|
361
|
-
in srgb,
|
|
362
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
363
|
-
var(--wui-color-fg-300)
|
|
364
|
-
);
|
|
365
|
-
--wui-color-fg-325: color-mix(
|
|
366
|
-
in srgb,
|
|
367
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
368
|
-
var(--wui-color-fg-325)
|
|
369
|
-
);
|
|
370
|
-
--wui-color-fg-350: color-mix(
|
|
371
|
-
in srgb,
|
|
372
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
373
|
-
var(--wui-color-fg-350)
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
--wui-color-bg-100: color-mix(
|
|
377
|
-
in srgb,
|
|
378
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
379
|
-
var(--wui-color-bg-100)
|
|
380
|
-
);
|
|
381
|
-
--wui-color-bg-125: color-mix(
|
|
382
|
-
in srgb,
|
|
383
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
384
|
-
var(--wui-color-bg-125)
|
|
385
|
-
);
|
|
386
|
-
--wui-color-bg-150: color-mix(
|
|
387
|
-
in srgb,
|
|
388
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
389
|
-
var(--wui-color-bg-150)
|
|
390
|
-
);
|
|
391
|
-
--wui-color-bg-175: color-mix(
|
|
392
|
-
in srgb,
|
|
393
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
394
|
-
var(--wui-color-bg-175)
|
|
395
|
-
);
|
|
396
|
-
--wui-color-bg-200: color-mix(
|
|
397
|
-
in srgb,
|
|
398
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
399
|
-
var(--wui-color-bg-200)
|
|
400
|
-
);
|
|
401
|
-
--wui-color-bg-225: color-mix(
|
|
402
|
-
in srgb,
|
|
403
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
404
|
-
var(--wui-color-bg-225)
|
|
405
|
-
);
|
|
406
|
-
--wui-color-bg-250: color-mix(
|
|
407
|
-
in srgb,
|
|
408
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
409
|
-
var(--wui-color-bg-250)
|
|
410
|
-
);
|
|
411
|
-
--wui-color-bg-275: color-mix(
|
|
412
|
-
in srgb,
|
|
413
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
414
|
-
var(--wui-color-bg-275)
|
|
415
|
-
);
|
|
416
|
-
--wui-color-bg-300: color-mix(
|
|
417
|
-
in srgb,
|
|
418
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
419
|
-
var(--wui-color-bg-300)
|
|
420
|
-
);
|
|
421
|
-
--wui-color-bg-325: color-mix(
|
|
422
|
-
in srgb,
|
|
423
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
424
|
-
var(--wui-color-bg-325)
|
|
425
|
-
);
|
|
426
|
-
--wui-color-bg-350: color-mix(
|
|
427
|
-
in srgb,
|
|
428
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
429
|
-
var(--wui-color-bg-350)
|
|
430
|
-
);
|
|
431
|
-
|
|
432
|
-
--wui-color-success-100: color-mix(
|
|
433
|
-
in srgb,
|
|
434
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
435
|
-
var(--wui-color-success-base-100)
|
|
436
|
-
);
|
|
437
|
-
--wui-color-success-125: color-mix(
|
|
438
|
-
in srgb,
|
|
439
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
440
|
-
var(--wui-color-success-base-125)
|
|
441
|
-
);
|
|
442
|
-
|
|
443
|
-
--wui-color-warning-100: color-mix(
|
|
444
|
-
in srgb,
|
|
445
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
446
|
-
var(--wui-color-warning-base-100)
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
--wui-color-error-100: color-mix(
|
|
450
|
-
in srgb,
|
|
451
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
452
|
-
var(--wui-color-error-base-100)
|
|
453
|
-
);
|
|
454
|
-
--wui-color-blue-100: color-mix(
|
|
455
|
-
in srgb,
|
|
456
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
457
|
-
var(--wui-color-blue-base-100)
|
|
458
|
-
);
|
|
459
|
-
--wui-color-blue-90: color-mix(
|
|
460
|
-
in srgb,
|
|
461
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
462
|
-
var(--wui-color-blue-base-90)
|
|
463
|
-
);
|
|
464
|
-
--wui-color-error-125: color-mix(
|
|
465
|
-
in srgb,
|
|
466
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
467
|
-
var(--wui-color-error-base-125)
|
|
468
|
-
);
|
|
469
|
-
|
|
470
|
-
--wui-icon-box-bg-error-100: color-mix(
|
|
471
|
-
in srgb,
|
|
472
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
473
|
-
var(--wui-icon-box-bg-error-base-100)
|
|
474
|
-
);
|
|
475
|
-
--wui-icon-box-bg-accent-100: color-mix(
|
|
476
|
-
in srgb,
|
|
477
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
478
|
-
var(--wui-icon-box-bg-blue-base-100)
|
|
479
|
-
);
|
|
480
|
-
--wui-icon-box-bg-success-100: color-mix(
|
|
481
|
-
in srgb,
|
|
482
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
483
|
-
var(--wui-icon-box-bg-success-base-100)
|
|
484
|
-
);
|
|
485
|
-
--wui-icon-box-bg-inverse-100: color-mix(
|
|
486
|
-
in srgb,
|
|
487
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
488
|
-
var(--wui-icon-box-bg-inverse-base-100)
|
|
489
|
-
);
|
|
490
|
-
|
|
491
|
-
--wui-all-wallets-bg-100: color-mix(
|
|
492
|
-
in srgb,
|
|
493
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
494
|
-
var(--wui-all-wallets-bg-100)
|
|
495
|
-
);
|
|
496
|
-
|
|
497
|
-
--wui-avatar-border: color-mix(
|
|
498
|
-
in srgb,
|
|
499
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
500
|
-
var(--wui-avatar-border-base)
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
--wui-thumbnail-border: color-mix(
|
|
504
|
-
in srgb,
|
|
505
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
506
|
-
var(--wui-thumbnail-border-base)
|
|
507
|
-
);
|
|
508
|
-
|
|
509
|
-
--wui-wallet-button-bg: color-mix(
|
|
510
|
-
in srgb,
|
|
511
|
-
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
512
|
-
var(--wui-wallet-button-bg-base)
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
`,light:Ur`
|
|
517
|
-
:root {
|
|
518
|
-
--w3m-color-mix: ${xt((t==null?void 0:t["--w3m-color-mix"])||"#fff")};
|
|
519
|
-
--w3m-accent: ${xt(As(t,"dark")["--w3m-accent"])};
|
|
520
|
-
--w3m-default: #fff;
|
|
521
|
-
|
|
522
|
-
--wui-color-modal-bg-base: ${xt(As(t,"dark")["--w3m-background"])};
|
|
523
|
-
--wui-color-accent-base-100: var(--w3m-accent);
|
|
524
|
-
|
|
525
|
-
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
526
|
-
--wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
|
|
527
|
-
--wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
|
|
528
|
-
--wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
|
|
529
|
-
|
|
530
|
-
--wui-color-fg-100: #e4e7e7;
|
|
531
|
-
--wui-color-fg-125: #d0d5d5;
|
|
532
|
-
--wui-color-fg-150: #a8b1b1;
|
|
533
|
-
--wui-color-fg-175: #a8b0b0;
|
|
534
|
-
--wui-color-fg-200: #949e9e;
|
|
535
|
-
--wui-color-fg-225: #868f8f;
|
|
536
|
-
--wui-color-fg-250: #788080;
|
|
537
|
-
--wui-color-fg-275: #788181;
|
|
538
|
-
--wui-color-fg-300: #6e7777;
|
|
539
|
-
--wui-color-fg-325: #9a9a9a;
|
|
540
|
-
--wui-color-fg-350: #363636;
|
|
541
|
-
|
|
542
|
-
--wui-color-bg-100: #141414;
|
|
543
|
-
--wui-color-bg-125: #191a1a;
|
|
544
|
-
--wui-color-bg-150: #1e1f1f;
|
|
545
|
-
--wui-color-bg-175: #222525;
|
|
546
|
-
--wui-color-bg-200: #272a2a;
|
|
547
|
-
--wui-color-bg-225: #2c3030;
|
|
548
|
-
--wui-color-bg-250: #313535;
|
|
549
|
-
--wui-color-bg-275: #363b3b;
|
|
550
|
-
--wui-color-bg-300: #3b4040;
|
|
551
|
-
--wui-color-bg-325: #252525;
|
|
552
|
-
--wui-color-bg-350: #ffffff;
|
|
553
|
-
|
|
554
|
-
--wui-color-success-base-100: #26d962;
|
|
555
|
-
--wui-color-success-base-125: #30a46b;
|
|
556
|
-
|
|
557
|
-
--wui-color-warning-base-100: #f3a13f;
|
|
558
|
-
|
|
559
|
-
--wui-color-error-base-100: #f25a67;
|
|
560
|
-
--wui-color-error-base-125: #df4a34;
|
|
561
|
-
|
|
562
|
-
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
563
|
-
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
564
|
-
|
|
565
|
-
--wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
|
|
566
|
-
--wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
|
|
567
|
-
--wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
|
|
568
|
-
--wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
|
|
569
|
-
--wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
|
|
570
|
-
--wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
|
|
571
|
-
--wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
|
|
572
|
-
--wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
|
|
573
|
-
--wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
|
|
574
|
-
--wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
|
|
575
|
-
|
|
576
|
-
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
577
|
-
|
|
578
|
-
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
579
|
-
|
|
580
|
-
--wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
|
|
581
|
-
--wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
|
|
582
|
-
--wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
|
|
583
|
-
--wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
|
|
584
|
-
--wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
|
|
585
|
-
--wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
|
|
586
|
-
--wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
|
|
587
|
-
--wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
|
|
588
|
-
--wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
|
|
589
|
-
--wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
|
|
590
|
-
|
|
591
|
-
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
592
|
-
|
|
593
|
-
--wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
|
|
594
|
-
--wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
|
|
595
|
-
--wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
|
|
596
|
-
--wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
|
|
597
|
-
--wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
|
|
598
|
-
--wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
|
|
599
|
-
--wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
|
|
600
|
-
--wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
|
|
601
|
-
--wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
|
|
602
|
-
--wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
|
|
603
|
-
--wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
|
|
604
|
-
|
|
605
|
-
--wui-color-dark-glass-100: rgba(42, 42, 42, 1);
|
|
606
|
-
|
|
607
|
-
--wui-icon-box-bg-error-base-100: #3c2426;
|
|
608
|
-
--wui-icon-box-bg-blue-base-100: #20303f;
|
|
609
|
-
--wui-icon-box-bg-success-base-100: #1f3a28;
|
|
610
|
-
--wui-icon-box-bg-inverse-base-100: #243240;
|
|
611
|
-
|
|
612
|
-
--wui-all-wallets-bg-100: #222b35;
|
|
613
|
-
|
|
614
|
-
--wui-avatar-border-base: #252525;
|
|
615
|
-
|
|
616
|
-
--wui-thumbnail-border-base: #252525;
|
|
617
|
-
|
|
618
|
-
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
619
|
-
|
|
620
|
-
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
621
|
-
}
|
|
622
|
-
`,dark:Ur`
|
|
623
|
-
:root {
|
|
624
|
-
--w3m-color-mix: ${xt((t==null?void 0:t["--w3m-color-mix"])||"#000")};
|
|
625
|
-
--w3m-accent: ${xt(As(t,"light")["--w3m-accent"])};
|
|
626
|
-
--w3m-default: #000;
|
|
627
|
-
|
|
628
|
-
--wui-color-modal-bg-base: ${xt(As(t,"light")["--w3m-background"])};
|
|
629
|
-
--wui-color-accent-base-100: var(--w3m-accent);
|
|
630
|
-
|
|
631
|
-
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
632
|
-
--wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
|
|
633
|
-
--wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
|
|
634
|
-
|
|
635
|
-
--wui-color-fg-100: #141414;
|
|
636
|
-
--wui-color-fg-125: #2d3131;
|
|
637
|
-
--wui-color-fg-150: #474d4d;
|
|
638
|
-
--wui-color-fg-175: #636d6d;
|
|
639
|
-
--wui-color-fg-200: #798686;
|
|
640
|
-
--wui-color-fg-225: #828f8f;
|
|
641
|
-
--wui-color-fg-250: #8b9797;
|
|
642
|
-
--wui-color-fg-275: #95a0a0;
|
|
643
|
-
--wui-color-fg-300: #9ea9a9;
|
|
644
|
-
--wui-color-fg-325: #9a9a9a;
|
|
645
|
-
--wui-color-fg-350: #d0d0d0;
|
|
646
|
-
|
|
647
|
-
--wui-color-bg-100: #ffffff;
|
|
648
|
-
--wui-color-bg-125: #f5fafa;
|
|
649
|
-
--wui-color-bg-150: #f3f8f8;
|
|
650
|
-
--wui-color-bg-175: #eef4f4;
|
|
651
|
-
--wui-color-bg-200: #eaf1f1;
|
|
652
|
-
--wui-color-bg-225: #e5eded;
|
|
653
|
-
--wui-color-bg-250: #e1e9e9;
|
|
654
|
-
--wui-color-bg-275: #dce7e7;
|
|
655
|
-
--wui-color-bg-300: #d8e3e3;
|
|
656
|
-
--wui-color-bg-325: #f3f3f3;
|
|
657
|
-
--wui-color-bg-350: #202020;
|
|
658
|
-
|
|
659
|
-
--wui-color-success-base-100: #26b562;
|
|
660
|
-
--wui-color-success-base-125: #30a46b;
|
|
661
|
-
|
|
662
|
-
--wui-color-warning-base-100: #f3a13f;
|
|
663
|
-
|
|
664
|
-
--wui-color-error-base-100: #f05142;
|
|
665
|
-
--wui-color-error-base-125: #df4a34;
|
|
666
|
-
|
|
667
|
-
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
668
|
-
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
669
|
-
|
|
670
|
-
--wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
|
|
671
|
-
--wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
|
|
672
|
-
--wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
|
|
673
|
-
--wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
|
|
674
|
-
--wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
|
|
675
|
-
--wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
|
|
676
|
-
--wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
|
|
677
|
-
--wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
|
|
678
|
-
--wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
|
|
679
|
-
--wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
|
|
680
|
-
|
|
681
|
-
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
682
|
-
|
|
683
|
-
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
684
|
-
|
|
685
|
-
--wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
|
|
686
|
-
--wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
|
|
687
|
-
--wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
|
|
688
|
-
--wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
|
|
689
|
-
--wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
|
|
690
|
-
--wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
|
|
691
|
-
--wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
|
|
692
|
-
--wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
|
|
693
|
-
--wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
|
|
694
|
-
--wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
|
|
695
|
-
|
|
696
|
-
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
697
|
-
|
|
698
|
-
--wui-icon-box-bg-error-base-100: #f4dfdd;
|
|
699
|
-
--wui-icon-box-bg-blue-base-100: #d9ecfb;
|
|
700
|
-
--wui-icon-box-bg-success-base-100: #daf0e4;
|
|
701
|
-
--wui-icon-box-bg-inverse-base-100: #dcecfc;
|
|
702
|
-
|
|
703
|
-
--wui-all-wallets-bg-100: #e8f1fa;
|
|
704
|
-
|
|
705
|
-
--wui-avatar-border-base: #f3f4f4;
|
|
706
|
-
|
|
707
|
-
--wui-thumbnail-border-base: #eaefef;
|
|
708
|
-
|
|
709
|
-
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
710
|
-
|
|
711
|
-
--wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
|
|
712
|
-
--wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
|
|
713
|
-
--wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
|
|
714
|
-
--wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
|
|
715
|
-
--wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
|
|
716
|
-
--wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
|
|
717
|
-
--wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
|
|
718
|
-
--wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
|
|
719
|
-
--wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
|
|
720
|
-
--wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
|
|
721
|
-
--wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
|
|
722
|
-
|
|
723
|
-
--wui-color-dark-glass-100: rgba(233, 233, 233, 1);
|
|
724
|
-
|
|
725
|
-
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
726
|
-
}
|
|
727
|
-
`}}const $A=Ur`
|
|
728
|
-
*,
|
|
729
|
-
*::after,
|
|
730
|
-
*::before,
|
|
731
|
-
:host {
|
|
732
|
-
margin: 0;
|
|
733
|
-
padding: 0;
|
|
734
|
-
box-sizing: border-box;
|
|
735
|
-
font-style: normal;
|
|
736
|
-
text-rendering: optimizeSpeed;
|
|
737
|
-
-webkit-font-smoothing: antialiased;
|
|
738
|
-
-moz-osx-font-smoothing: grayscale;
|
|
739
|
-
-webkit-tap-highlight-color: transparent;
|
|
740
|
-
font-family: var(--wui-font-family);
|
|
741
|
-
backface-visibility: hidden;
|
|
742
|
-
}
|
|
743
|
-
`,kA=Ur`
|
|
744
|
-
button,
|
|
745
|
-
a {
|
|
746
|
-
cursor: pointer;
|
|
747
|
-
display: flex;
|
|
748
|
-
justify-content: center;
|
|
749
|
-
align-items: center;
|
|
750
|
-
position: relative;
|
|
751
|
-
transition:
|
|
752
|
-
color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
753
|
-
background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
754
|
-
border var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
755
|
-
border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
756
|
-
box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
757
|
-
will-change: background-color, color, border, box-shadow, border-radius;
|
|
758
|
-
outline: none;
|
|
759
|
-
border: none;
|
|
760
|
-
column-gap: var(--wui-spacing-3xs);
|
|
761
|
-
background-color: transparent;
|
|
762
|
-
text-decoration: none;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
wui-flex {
|
|
766
|
-
transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
767
|
-
will-change: border-radius;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
button:disabled > wui-wallet-image,
|
|
771
|
-
button:disabled > wui-all-wallets-image,
|
|
772
|
-
button:disabled > wui-network-image,
|
|
773
|
-
button:disabled > wui-image,
|
|
774
|
-
button:disabled > wui-transaction-visual,
|
|
775
|
-
button:disabled > wui-logo {
|
|
776
|
-
filter: grayscale(1);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
@media (hover: hover) and (pointer: fine) {
|
|
780
|
-
button:hover:enabled {
|
|
781
|
-
background-color: var(--wui-color-gray-glass-005);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
button:active:enabled {
|
|
785
|
-
background-color: var(--wui-color-gray-glass-010);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
button:disabled > wui-icon-box {
|
|
790
|
-
opacity: 0.5;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
input {
|
|
794
|
-
border: none;
|
|
795
|
-
outline: none;
|
|
796
|
-
appearance: none;
|
|
797
|
-
}
|
|
798
|
-
`,RA=Ur`
|
|
799
|
-
.wui-color-inherit {
|
|
800
|
-
color: var(--wui-color-inherit);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
.wui-color-accent-100 {
|
|
804
|
-
color: var(--wui-color-accent-100);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
.wui-color-error-100 {
|
|
808
|
-
color: var(--wui-color-error-100);
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
.wui-color-blue-100 {
|
|
812
|
-
color: var(--wui-color-blue-100);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
.wui-color-blue-90 {
|
|
816
|
-
color: var(--wui-color-blue-90);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
.wui-color-error-125 {
|
|
820
|
-
color: var(--wui-color-error-125);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
.wui-color-success-100 {
|
|
824
|
-
color: var(--wui-color-success-100);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
.wui-color-success-125 {
|
|
828
|
-
color: var(--wui-color-success-125);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
.wui-color-inverse-100 {
|
|
832
|
-
color: var(--wui-color-inverse-100);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
.wui-color-inverse-000 {
|
|
836
|
-
color: var(--wui-color-inverse-000);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
.wui-color-fg-100 {
|
|
840
|
-
color: var(--wui-color-fg-100);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
.wui-color-fg-200 {
|
|
844
|
-
color: var(--wui-color-fg-200);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
.wui-color-fg-300 {
|
|
848
|
-
color: var(--wui-color-fg-300);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
.wui-color-fg-325 {
|
|
852
|
-
color: var(--wui-color-fg-325);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
.wui-color-fg-350 {
|
|
856
|
-
color: var(--wui-color-fg-350);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
.wui-bg-color-inherit {
|
|
860
|
-
background-color: var(--wui-color-inherit);
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
.wui-bg-color-blue-100 {
|
|
864
|
-
background-color: var(--wui-color-accent-100);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
.wui-bg-color-error-100 {
|
|
868
|
-
background-color: var(--wui-color-error-100);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
.wui-bg-color-error-125 {
|
|
872
|
-
background-color: var(--wui-color-error-125);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
.wui-bg-color-success-100 {
|
|
876
|
-
background-color: var(--wui-color-success-100);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
.wui-bg-color-success-125 {
|
|
880
|
-
background-color: var(--wui-color-success-100);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
.wui-bg-color-inverse-100 {
|
|
884
|
-
background-color: var(--wui-color-inverse-100);
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
.wui-bg-color-inverse-000 {
|
|
888
|
-
background-color: var(--wui-color-inverse-000);
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
.wui-bg-color-fg-100 {
|
|
892
|
-
background-color: var(--wui-color-fg-100);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
.wui-bg-color-fg-200 {
|
|
896
|
-
background-color: var(--wui-color-fg-200);
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
.wui-bg-color-fg-300 {
|
|
900
|
-
background-color: var(--wui-color-fg-300);
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
.wui-color-fg-325 {
|
|
904
|
-
background-color: var(--wui-color-fg-325);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
.wui-color-fg-350 {
|
|
908
|
-
background-color: var(--wui-color-fg-350);
|
|
909
|
-
}
|
|
910
|
-
`,Ci={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 Cn(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const $u=Cn({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"}),ku=Cn({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"});Cn({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"});Cn({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});Cn({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 jI={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"]},Zn={getMethodsByChainNamespace(t){return jI[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 $u.caipNetworkId:u.chains.push($u.deprecatedCaipNetworkId);break;case ku.caipNetworkId:u.chains.push(ku.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 Ni.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 Bh{constructor({provider:e,namespace:s}){this.id=F.CONNECTOR_ID.WALLET_CONNECT,this.name=oo.ConnectorNamesMap[F.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=oo.ConnectorImageIds[F.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=f.getCaipNetworks.bind(f),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=Zn.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 Si.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:qI})}}const qI=["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 WI{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=s=>f.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:F.CONNECTOR_ID.AUTH,type:"AUTH",name:F.CONNECTOR_NAMES.AUTH,provider:e,imageId:oo.ConnectorImageIds[F.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){z.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=z.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 Bh);if(!e)throw new Error("WalletConnectConnector not found");return e}}class zI extends WI{setUniversalProvider(e){this.addConnector(new Bh({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&&Ee.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(z.state.balanceLoading&&e.chainId===((c=f.state.activeCaipNetwork)==null?void 0:c.id))return{balance:z.state.balance||"0.00",symbol:z.state.balanceSymbol||""};const i=(await z.fetchTokenBalance()).find(u=>{var d,h;return u.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&u.symbol===((h=e.caipNetwork)==null?void 0:h.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=f.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===F.CHAIN.SOLANA?n=(await s.request({method:"solana_signMessage",params:{message:Lu.encode(new TextEncoder().encode(r)),pubkey:i}},(a=f.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await s.request({method:"personal_sign",params:[r,i]},(c=f.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===F.CHAIN.EVM)try{await((i=r.provider)==null?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:Ec(s.id)}]}))}catch(u){if(u.code===Ci.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||u.code===Ci.ERROR_INVALID_CHAIN_ID||u.code===Ci.ERROR_CODE_DEFAULT||((o=(n=u==null?void 0:u.data)==null?void 0:n.originalError)==null?void 0:o.code)===Ci.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=r.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Ec(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 HI=["email","socials","swaps","onramp","activity","reownBranding"],qn={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ee.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?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Ee.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?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Ee.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?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Ee.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?Ee.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?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!t}},KI={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=qn[e],r=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(r)}},processFeature(t,e,s,r,i){const n=qn[t],o=e[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(r){const a=this.getApiConfig(n.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return qn[t].processApi(e)},processFallbackFeature(t,e){return qn[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let r=null,i=!1;try{r=await 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?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of HI){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),Ee.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 VI{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,r)=>{var i,n,o,a;if(s){const c=(n=(i=f.getNetworkData(s))==null?void 0:i.requestedCaipNetworks)==null?void 0:n.find(d=>d.id===r);if(c)return c;const l=(o=f.getNetworkData(s))==null?void 0:o.caipNetwork;return l||((a=f.getRequestedCaipNetworks(s).filter(d=>d.chainNamespace===s))==null?void 0:a[0])}return f.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>f.getCaipNetworks(s),this.getActiveChainNamespace=()=>f.state.activeChain,this.setRequestedCaipNetworks=(s,r)=>{f.setRequestedCaipNetworks(s,r)},this.getApprovedCaipNetworkIds=()=>f.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>f.state.activeChain===s||!s?f.state.activeCaipAddress:f.getAccountProp("caipAddress",s),this.setClientId=s=>{J.setClientId(s)},this.getProvider=s=>Se.getProvider(s),this.getProviderType=s=>Se.getProviderId(s),this.getPreferredAccountType=s=>{var r;return(r=z.state.preferredAccountTypes)==null?void 0:r[s]},this.setCaipAddress=(s,r)=>{z.setCaipAddress(s,r),s&&T.state.enableEmbedded&&this.close()},this.setBalance=(s,r,i)=>{z.setBalance(s,r,i)},this.setProfileName=(s,r)=>{z.setProfileName(s,r)},this.setProfileImage=(s,r)=>{z.setProfileImage(s,r)},this.setUser=(s,r)=>{z.setUser(s,r)},this.resetAccount=s=>{z.resetAccount(s)},this.setCaipNetwork=s=>{f.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,r)=>{f.setChainNetworkData(r,{caipNetwork:s})},this.setAllAccounts=(s,r)=>{z.setAllAccounts(s,r),T.setHasMultipleAddresses((s==null?void 0:s.length)>1)},this.setStatus=(s,r)=>{z.setStatus(s,r),j.isConnected()?W.setConnectionStatus("connected"):W.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>f.getAccountProp("address",s),this.setConnectors=s=>{const r=[...j.state.allConnectors,...s];j.setConnectors(r)},this.setConnections=(s,r)=>{Y.setConnections(s,r)},this.fetchIdentity=s=>J.fetchIdentity(s),this.getReownName=s=>Ni.getNamesForAddress(s),this.getConnectors=()=>j.getConnectors(),this.getConnectorImage=s=>qu.getConnectorImage(s),this.setConnectedWalletInfo=(s,r)=>{const i=Se.getProviderId(r),n=s?{...s,type:i}:void 0;z.setConnectedWalletInfo(n,r)},this.getIsConnectedState=()=>!!f.state.activeCaipAddress,this.addAddressLabel=(s,r,i)=>{z.addAddressLabel(s,r,i)},this.removeAddressLabel=(s,r)=>{z.removeAddressLabel(s,r)},this.getAddress=s=>f.state.activeChain===s||!s?z.state.address:f.getAccountProp("address",s),this.setApprovedCaipNetworksData=s=>f.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{f.resetNetwork(s)},this.addConnector=s=>{j.addConnector(s)},this.resetWcConnection=()=>{Y.resetWcConnection()},this.setAddressExplorerUrl=(s,r)=>{z.setAddressExplorerUrl(s,r)},this.setSmartAccountDeployed=(s,r)=>{z.setSmartAccountDeployed(s,r)},this.setSmartAccountEnabledNetworks=(s,r)=>{f.setSmartAccountEnabledNetworks(s,r)},this.setPreferredAccountType=(s,r)=>{z.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 KI.fetchRemoteFeatures(e),T.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&da.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;Zn.isOriginAllowed(s,e,Ci.DEFAULT_ALLOWED_ANCESTORS)||qs.open(Nr.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else qs.open(Nr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){var r;const{...s}=e;delete s.adapters,delete s.universalProvider,Pe.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");f.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&f.setActiveCaipNetwork(s)}initializeConnectionController(e){Y.setWcBasic(e.basic??!1)}initializeConnectorController(){j.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};z.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(Nr.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((o=e.adapters)==null?void 0:o.find(a=>a.namespace===F.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=Pr.getUnsupportedNetwork(`${s}:${e}`);f.setActiveCaipNetwork(r)}}getDefaultNetwork(){return Pr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Pr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Pr.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?Pr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const s=this.getAdapter(e),r=Se.getProvider(e),i=Se.getProviderId(e),{caipAddress:n}=f.getAccountData(e)||{};this.setLoading(!0,e),n&&(s!=null&&s.disconnect)&&await s.disconnect({provider:r,providerType:i}),W.removeConnectedNamespace(e),Se.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),j.removeConnectorId(e),f.resetAccount(e),f.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=f.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([...f.state.chains.keys()]),this.chainNamespaces.forEach(o=>{j.setConnectorId(Le.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 m,w,y,b,v,I;const c=f.state.activeChain,l=n||c,u=this.getAdapter(l);if(n&&n!==c&&!o){const S=this.getCaipNetworks().find(A=>A.chainNamespace===n);S&&this.setCaipNetwork(S)}if(!u)throw new Error("Adapter not found");const d=this.getCaipNetwork(l),h=await u.connect({id:e,info:s,type:r,provider:i,socialUri:a,chainId:(o==null?void 0:o.id)||(d==null?void 0:d.id),rpcUrl:((y=(w=(m=o==null?void 0:o.rpcUrls)==null?void 0:m.default)==null?void 0:w.http)==null?void 0:y[0])||((I=(v=(b=d==null?void 0:d.rpcUrls)==null?void 0:b.default)==null?void 0:v.http)==null?void 0:I[0])});if(!h)return;W.addConnectedNamespace(l),this.syncProvider({...h,chainNamespace:l});const p=z.state.allAccounts,{accounts:g}=(p==null?void 0:p.length)>0?{accounts:[...p]}:await u.getAccounts({namespace:l,id:e});this.setAllAccounts(g,l),this.setStatus("connected",l),this.syncConnectedWalletInfo(l)},reconnectExternal:async({id:e,info:s,type:r,provider:i})=>{var a;const n=f.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=wI(e);try{const r=await Promise.allSettled(s.map(async([n])=>this.disconnectNamespace(n)));he.resetSend(),Y.resetWcConnection(),await Si.clearSessions(),j.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(),Pe.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(f.state.activeChain),r=await(s==null?void 0:s.signMessage({message:e,address:z.state.address,provider:Se.getProvider(f.state.activeChain)}));return(r==null?void 0:r.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(Ee.SEND_SUPPORTED_NAMESPACES.includes(s)){const r=this.getAdapter(f.state.activeChain),i=Se.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===F.CHAIN.EVM){const s=this.getAdapter(f.state.activeChain),r=Se.getProvider(f.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:z.state.address,chainId:Number((e=this.getCaipNetwork())==null?void 0:e.id),chainNamespace:f.state.activeChain}),z.state.profileImage||!1},getEnsAddress:async e=>await Zn.resolveReownName(e),writeContract:async e=>{const s=this.getAdapter(f.state.activeChain),r=this.getCaipNetwork(),i=this.getCaipAddress(),n=Se.getProvider(f.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(f.state.activeChain);return(r==null?void 0:r.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const r=this.getAdapter(f.state.activeChain);return(r==null?void 0:r.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(f.state.activeChain);return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(f.state.activeChain);return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(f.state.activeChain);return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(f.state.activeChain);return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getCaipNetwork(e);!s||!z.state.address||this.updateNativeBalance(z.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(Se.getProviderId(f.state.activeChain)===Le.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=Se.getProvider(s),n=Se.getProviderId(s);if(e.chainNamespace===f.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===Le.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}=gs.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 zI({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=f.state.activeChain===e,c=f.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=z.state.address,n=f.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=f.state.activeChain===e;o&&n?this.syncAccount({address:i,chainId:n,chainNamespace:e}):o&&((a=f.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:i,chainId:(c=f.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===F.CHAIN.EVM&&X.isSafeApp()&&j.setConnectorId(F.CONNECTOR_ID.SAFE,e);const s=j.getConnectorId(e);switch(this.setStatus("connecting",e),s){case F.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case F.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=j.getConnectorId(e),i=this.getCaipNetwork(e),o=j.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 d=await(s==null?void 0:s.getAccounts({namespace:e,id:o.id}));d&&d.accounts.length>0?this.setAllAccounts(d.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,d;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=(d=f.state.activeCaipNetwork)==null?void 0:d.id,o=i.find(h=>{const{chainId:p}=gs.parseCaipAddress(h);return p===(n==null?void 0:n.toString())})||i[0];if(o){const h=gs.validateCaipAddress(o),{chainId:p,address:g}=gs.parseCaipAddress(h);if(Se.setProviderId(s,Le.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&f.state.activeCaipNetwork&&(r==null?void 0:r.namespace)!==F.CHAIN.EVM){const m=r==null?void 0:r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:f.state.activeCaipNetwork});Se.setProvider(s,m)}else Se.setProvider(s,this.universalProvider);j.setConnectorId(F.CONNECTOR_ID.WALLET_CONNECT,s),W.addConnectedNamespace(s),this.syncWalletConnectAccounts(s),await this.syncAccount({address:g,chainId:p,chainNamespace:s})}else this.setStatus("disconnected",s);this.syncConnectedWalletInfo(s),await f.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}=gs.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}){Se.setProviderId(i,e),Se.setProvider(i,s),j.setConnectorId(r,i)}async syncAllAccounts(e){const s=j.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 d,h;const s=e.chainNamespace===f.state.activeChain,r=f.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:n,chainNamespace:o}=e,{chainId:a}=W.getActiveNetworkProps(),c=n||a,l=((d=f.state.activeCaipNetwork)==null?void 0:d.name)===F.UNSUPPORTED_NETWORK_NAME,u=f.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let p=this.getCaipNetworks().find(w=>w.id.toString()===c.toString()),g=this.getCaipNetworks().find(w=>w.chainNamespace===o);if(!u&&!p&&!g){const w=this.getApprovedCaipNetworkIds()||[],y=w.find(v=>{var I;return((I=gs.parseCaipNetworkId(v))==null?void 0:I.chainId)===c.toString()}),b=w.find(v=>{var I;return((I=gs.parseCaipNetworkId(v))==null?void 0:I.chainNamespace)===o});p=this.getCaipNetworks().find(v=>v.caipNetworkId===y),g=this.getCaipNetworks().find(v=>v.caipNetworkId===b||"deprecatedCaipNetworkId"in v&&v.deprecatedCaipNetworkId===b)}const m=p||g;(m==null?void 0:m.chainNamespace)===f.state.activeChain?T.state.enableNetworkSwitch&&!T.state.allowUnsupportedChain&&((h=f.state.activeCaipNetwork)==null?void 0:h.name)===F.UNSUPPORTED_NETWORK_NAME?f.showUnsupportedChainUI():this.setCaipNetwork(m):s||r&&this.setCaipNetworkOfNamespace(r,o),this.syncConnectedWalletInfo(o),lc.isLowerCaseMatch(i,z.state.address)||this.syncAccountInfo(i,m==null?void 0:m.id,o),s?await this.syncBalance({address:i,chainId:m==null?void 0:m.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=j.getConnectorId(e),r=Se.getProviderId(e);if(r===Le.CONNECTOR_TYPE_ANNOUNCED||r===Le.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===Le.CONNECTOR_TYPE_WALLET_CONNECT){const n=Se.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===F.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===F.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}}async syncBalance(e){!Fu.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=f.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,d,h;const e=vI.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),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?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};T.setManualWCControl(!!((h=this.options)!=null&&h.manualWCControl)),this.universalProvider=this.options.universalProvider??await mI.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(Zn.isSessionEventData(e)){const{name:s,data:r}=e.params.event;s==="accountsChanged"&&Array.isArray(r)&&X.isCaipAddress(r[0])&&this.syncAccount(gs.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){Pe.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(Nr.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[r,i]=s??[],{message:n,alertErrorKey:o}=i??{};if(r&&n&&!this.reportedAlertErrors[r]){const a=Nr.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 He.open({...e,data:{swap:e.arguments}})}return He.open(e)}async close(){await this.injectModalUi(),He.close()}setLoading(e,s){He.setLoading(e,s)}async disconnect(e){await Y.disconnect(e)}getSIWX(){return T.state.siwx}getError(){return""}getChainId(){var e;return(e=f.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){const s=this.getCaipNetworks().find(r=>r.id===e.id);if(!s){qs.open(Nr.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await f.switchActiveNetwork(s)}getWalletProvider(){return f.state.activeChain?Se.state.providers[f.state.activeChain]:null}getWalletProviderType(){return Se.getProviderId(f.state.activeChain)}subscribeProviders(e){return Se.subscribeProviders(e)}getThemeMode(){return bt.state.themeMode}getThemeVariables(){return bt.state.themeVariables}setThemeMode(e){bt.setThemeMode(e),Mh(bt.state.themeMode)}setTermsConditionsUrl(e){T.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){T.setPrivacyPolicyUrl(e)}setThemeVariables(e){bt.setThemeVariables(e),FI(bt.state.themeVariables)}subscribeTheme(e){return bt.subscribe(e)}getWalletInfo(){return z.state.connectedWalletInfo}getAccount(e){var o;const s=j.getAuthConnector(e),r=f.getAccountData(e),i=f.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===F.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?f.subscribeChainProp("accountState",r,s):f.subscribe(r),j.subscribe(r)}subscribeNetwork(e){return f.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e){return z.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){z.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){f.subscribeKey("activeCaipNetwork",e)}getState(){return Ss.state}subscribeState(e){return Ss.subscribe(e)}showErrorMessage(e){jt.showError(e)}showSuccessMessage(e){jt.showSuccess(e)}getEvent(){return{...Pe.state}}subscribeEvents(e){return Pe.subscribe(e)}replace(e){ie.replace(e)}redirect(e){ie.push(e)}popTransactionStack(e){ie.popTransactionStack(e)}isOpen(){return He.state.open}isTransactionStackEmpty(){return ie.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 ja.getConnectOrderMethod(T.state.features,j.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)||f.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)&&f.removeNetwork(e,s)}}let Ru=!1;class Fh extends VI{async open(e){j.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(!Ru&&X.isClient()){if(await ia(()=>import("./basic-9dc8174a.js"),["assets/basic-9dc8174a.js","assets/index-376d9ca5.js","assets/index-1e0cfb06.js","assets/index-9c03b9eb.css","assets/index.es-63034a59.js"]),await ia(()=>import("./w3m-modal-22f5aa95.js"),["assets/w3m-modal-22f5aa95.js","assets/index-376d9ca5.js","assets/index-1e0cfb06.js","assets/index-9c03b9eb.css","assets/index.es-63034a59.js"]),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!T.state.disableAppend&&!T.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}Ru=!0}}}const GI="1.7.8";function JI(t){return new Fh({...t,basic:!0,sdkVersion:`html-core-${GI}`})}const UA=Object.freeze(Object.defineProperty({__proto__:null,AppKit:Fh,createAppKit:JI},Symbol.toStringTag,{value:"Module"}));export{K as A,qa as B,j as C,$h as D,Pe as E,Jr as F,bA as G,Tg as H,Rc as I,ad as J,vg as K,xg as L,He as M,vA as N,T as O,yA as P,uo as Q,ie as R,W as S,bt as T,EA as U,CA as V,ja as W,UA as X,Xn as a,X as b,Jn as c,qu as d,kA as e,Y as f,F as g,f as h,Ur as i,Ft as j,jt as k,Ee as l,TA as m,ze as n,RA as o,Ne as p,st as q,$A as r,tt as s,Si as t,qs as u,CI as v,_t as w,OA as x,z as y,xA as z};
|