From 2ba314bb30b9efbf583f8f6645fc437a2eb0acc7 Mon Sep 17 00:00:00 2001 From: SamueleA Date: Wed, 29 Nov 2023 19:15:42 +0000 Subject: [PATCH] Build: (269b98f) coinbase wallet logo dimensions --- assets/{ccip-bb77ee49.js => ccip-288a0685.js} | 2 +- assets/{events-d5745873.js => events-90d6e183.js} | 2 +- assets/{index-da732aeb.js => index-1b4dc470.js} | 6 +++--- assets/{index-3a237630.js => index-73787080.js} | 2 +- assets/{index-748504a6.js => index-9afd0bf9.js} | 2 +- assets/{index-e4b650d6.js => index-f6657797.js} | 2 +- assets/{index.es-69483be7.js => index.es-5337afc7.js} | 4 ++-- index.html | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) rename assets/{ccip-bb77ee49.js => ccip-288a0685.js} (97%) rename assets/{events-d5745873.js => events-90d6e183.js} (98%) rename assets/{index-da732aeb.js => index-1b4dc470.js} (98%) rename assets/{index-3a237630.js => index-73787080.js} (99%) rename assets/{index-748504a6.js => index-9afd0bf9.js} (99%) rename assets/{index-e4b650d6.js => index-f6657797.js} (98%) rename assets/{index.es-69483be7.js => index.es-5337afc7.js} (99%) diff --git a/assets/ccip-bb77ee49.js b/assets/ccip-288a0685.js similarity index 97% rename from assets/ccip-bb77ee49.js rename to assets/ccip-288a0685.js index f4067587..e8242451 100644 --- a/assets/ccip-bb77ee49.js +++ b/assets/ccip-288a0685.js @@ -1 +1 @@ -import{as as f,at as w,au as y,av as p,aw as h,ax as g,ay as k,az as O,aA as L,aB as m,aC as E}from"./index-da732aeb.js";class x extends f{constructor({callbackSelector:e,cause:t,data:n,extraData:c,sender:d,urls:a}){var i;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(i=t.metaMessages)!=null&&i.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(u=>` ${w(u)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${c}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class M extends f{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(t)}`,`Response: ${y(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class R extends f{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}function $(s,e){if(!p(s))throw new h({address:s});if(!p(e))throw new h({address:e});return s.toLowerCase()===e.toLowerCase()}const C="0x556f1830",A={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function P(s,{blockNumber:e,blockTag:t,data:n,to:c}){const{args:d}=g({data:n,abi:[A]}),[a,i,u,r,o]=d;try{if(!$(c,a))throw new R({sender:a,to:c});const l=await S({data:u,sender:a,urls:i}),{data:b}=await k(s,{blockNumber:e,blockTag:t,data:O([r,L([{type:"bytes"},{type:"bytes"}],[l,o])]),to:c});return b}catch(l){throw new x({callbackSelector:r,cause:l,data:n,extraData:o,sender:a,urls:i})}}async function S({data:s,sender:e,urls:t}){var c;let n=new Error("An unknown error occurred.");for(let d=0;d` ${w(u)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${c}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class M extends f{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(t)}`,`Response: ${y(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class R extends f{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}function $(s,e){if(!p(s))throw new h({address:s});if(!p(e))throw new h({address:e});return s.toLowerCase()===e.toLowerCase()}const C="0x556f1830",A={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function P(s,{blockNumber:e,blockTag:t,data:n,to:c}){const{args:d}=g({data:n,abi:[A]}),[a,i,u,r,o]=d;try{if(!$(c,a))throw new R({sender:a,to:c});const l=await S({data:u,sender:a,urls:i}),{data:b}=await k(s,{blockNumber:e,blockTag:t,data:O([r,L([{type:"bytes"},{type:"bytes"}],[l,o])]),to:c});return b}catch(l){throw new x({callbackSelector:r,cause:l,data:n,extraData:o,sender:a,urls:i})}}async function S({data:s,sender:e,urls:t}){var c;let n=new Error("An unknown error occurred.");for(let d=0;d0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function N(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=N.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():R(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function N(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=N.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():R(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r"data"in d)||t.walk():{};let f=t;return t instanceof mb?f=new Ade({functionName:s}):[Ide,qf.code].includes(a)&&(c||l||u)&&(f=new RC({abi:e,data:typeof c=="object"?c.data:c,functionName:s,message:u??l})),new kde(f,{abi:e,args:n,contractAddress:r,docsPath:i,functionName:s,sender:o})}class xd extends le{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the WalletClient."].join(` -`),{docsPath:e,docsSlug:"account"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AccountNotFoundError"})}}class Ode extends le{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d}){const h=B1({from:r==null?void 0:r.address,to:f,value:typeof d<"u"&&`${PS(d)} ${(i==null?void 0:i.nativeCurrency.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${ti(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${ti(c)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${ti(l)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",h].filter(Boolean)}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EstimateGasExecutionError"}),this.cause=e}}function BS(t,e){const r=(t.details||"").toLowerCase(),n=t.walk(i=>i.code===Zu.code);return n instanceof le?new Zu({cause:t,message:n.details}):Zu.nodeMessage.test(r)?new Zu({cause:t,message:t.details}):vy.nodeMessage.test(r)?new vy({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):CC.nodeMessage.test(r)?new CC({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):SC.nodeMessage.test(r)?new SC({cause:t,nonce:e==null?void 0:e.nonce}):kC.nodeMessage.test(r)?new kC({cause:t,nonce:e==null?void 0:e.nonce}):AC.nodeMessage.test(r)?new AC({cause:t,nonce:e==null?void 0:e.nonce}):_C.nodeMessage.test(r)?new _C({cause:t}):PC.nodeMessage.test(r)?new PC({cause:t,gas:e==null?void 0:e.gas}):TC.nodeMessage.test(r)?new TC({cause:t,gas:e==null?void 0:e.gas}):IC.nodeMessage.test(r)?new IC({cause:t}):my.nodeMessage.test(r)?new my({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas,maxPriorityFeePerGas:e==null?void 0:e.maxPriorityFeePerGas}):new pb({cause:t})}function Rde(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new Ode(n,{docsPath:e,...r})}function jS(t,{format:e}){return e?Object.keys(e({})).reduce((n,i)=>(t!=null&&t.hasOwnProperty(i)&&(n[i]=t[i]),n),{}):{}}function H1(t){const{account:e,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:i,to:s}=t,o=e?Yi(e):void 0;if(o&&!Hf(o.address))throw new U0({address:o.address});if(s&&!Hf(s))throw new U0({address:s});if(typeof r<"u"&&(typeof n<"u"||typeof i<"u"))throw new cfe;if(n&&n>2n**256n-1n)throw new vy({maxFeePerGas:n});if(i&&n&&i>n)throw new my({maxFeePerGas:n,maxPriorityFeePerGas:i})}class $de extends le{constructor(){super("`baseFeeMultiplier` must be greater than 1."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseFeeScalarError"})}}class US extends le{constructor(){super("Chain does not support EIP-1559 fees."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Eip1559FeesNotSupportedError"})}}class Mde extends le{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${ti(e)} gwei).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"MaxFeePerGasTooLowError"})}}class Nde extends le{constructor({blockHash:e,blockNumber:r}){let n="Block";e&&(n=`Block at hash "${e}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BlockNotFoundError"})}}async function yc(t,{blockHash:e,blockNumber:r,blockTag:n,includeTransactions:i}={}){var u,f,d;const s=n??"latest",o=i??!1,a=r!==void 0?Ue(r):void 0;let c=null;if(e?c=await t.request({method:"eth_getBlockByHash",params:[e,o]}):c=await t.request({method:"eth_getBlockByNumber",params:[a||s,o]}),!c)throw new Nde({blockHash:e,blockNumber:r});return(((d=(f=(u=t.chain)==null?void 0:u.formatters)==null?void 0:f.block)==null?void 0:d.format)||oF)(c)}async function zS(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function Dde(t,e){return _F(t,e)}async function _F(t,e){var s,o,a;const{block:r,chain:n=t.chain,request:i}=e||{};if(typeof((s=n==null?void 0:n.fees)==null?void 0:s.defaultPriorityFee)=="function"){const c=r||await yc(t);return n.fees.defaultPriorityFee({block:c,client:t,request:i})}else if((o=n==null?void 0:n.fees)!=null&&o.defaultPriorityFee)return(a=n==null?void 0:n.fees)==null?void 0:a.defaultPriorityFee;try{const c=await t.request({method:"eth_maxPriorityFeePerGas"});return db(c)}catch{const[c,l]=await Promise.all([r?Promise.resolve(r):yc(t),zS(t)]);if(typeof c.baseFeePerGas!="bigint")throw new US;const u=l-c.baseFeePerGas;return u<0n?0n:u}}async function Lde(t,e){return MC(t,e)}async function MC(t,e){var d;const{block:r,chain:n=t.chain,request:i,type:s="eip1559"}=e||{},o=await(async()=>{var h,p;return typeof((h=n==null?void 0:n.fees)==null?void 0:h.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:t,request:i}):((p=n==null?void 0:n.fees)==null?void 0:p.baseFeeMultiplier)??1.2})();if(o<1)throw new $de;const c=10**o.toString().split(".")[1].length,l=h=>h*BigInt(o*c)/BigInt(c),u=r||await yc(t);if(typeof((d=n==null?void 0:n.fees)==null?void 0:d.estimateFeesPerGas)=="function")return n.fees.estimateFeesPerGas({block:r,client:t,multiply:l,request:i,type:s});if(s==="eip1559"){if(typeof u.baseFeePerGas!="bigint")throw new US;const h=i!=null&&i.maxPriorityFeePerGas?i.maxPriorityFeePerGas:await _F(t,{block:u,chain:n,request:i}),p=l(u.baseFeePerGas);return{maxFeePerGas:(i==null?void 0:i.maxFeePerGas)??p+h,maxPriorityFeePerGas:h}}return{gasPrice:(i==null?void 0:i.gasPrice)??l(await zS(t))}}async function PF(t,{address:e,blockTag:r="latest",blockNumber:n}){const i=await t.request({method:"eth_getTransactionCount",params:[e,n?Ue(n):r]});return Nn(i)}async function wb(t,e){const{account:r=t.account,chain:n,gas:i,nonce:s,type:o}=e;if(!r)throw new xd;const a=Yi(r),c=await yc(t,{blockTag:"latest"}),l={...e,from:a.address};if(typeof s>"u"&&(l.nonce=await PF(t,{address:a.address,blockTag:"pending"})),typeof o>"u")try{l.type=dfe(l)}catch{l.type=typeof c.baseFeePerGas=="bigint"?"eip1559":"legacy"}if(l.type==="eip1559"){const{maxFeePerGas:u,maxPriorityFeePerGas:f}=await MC(t,{block:c,chain:n,request:l});if(typeof e.maxPriorityFeePerGas>"u"&&e.maxFeePerGas&&e.maxFeePerGas"u"&&(l.gas=await WS(t,{...l,account:{address:a.address,type:"json-rpc"}})),H1(l),l}async function WS(t,e){var i,s,o;const r=e.account??t.account;if(!r)throw new xd({docsPath:"/docs/actions/public/estimateGas"});const n=Yi(r);try{const{accessList:a,blockNumber:c,blockTag:l,data:u,gas:f,gasPrice:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:v,to:b,value:y,...m}=n.type==="local"?await wb(t,e):e,S=(c?Ue(c):void 0)||l;H1(e);const P=((o=(s=(i=t.chain)==null?void 0:i.formatters)==null?void 0:s.transactionRequest)==null?void 0:o.format)||hb,T=P({...jS(m,{format:P}),from:n.address,accessList:a,data:u,gas:f,gasPrice:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:v,to:b,value:y}),w=await t.request({method:"eth_estimateGas",params:S?[T,S]:[T]});return BigInt(w)}catch(a){throw Rde(a,{...e,account:n,chain:t.chain})}}async function Fde(t,{abi:e,address:r,args:n,functionName:i,...s}){const o=Dc({abi:e,args:n,functionName:i});try{return await WS(t,{data:o,to:r,...s})}catch(a){const c=s.account?Yi(s.account):void 0;throw t1(a,{abi:e,address:r,args:n,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:c==null?void 0:c.address})}}const j2="/docs/contract/decodeFunctionResult";function Cd({abi:t,args:e,functionName:r,data:n}){let i=t[0];if(r&&(i=z1({abi:t,args:e,name:r}),!i))throw new yy(r,{docsPath:j2});if(i.type!=="function")throw new yy(void 0,{docsPath:j2});if(!i.outputs)throw new kfe(i.name,{docsPath:j2});const s=bb(i.outputs,n);if(s&&s.length>1)return s;if(s&&s.length===1)return s[0]}const Bde="modulepreload",jde=function(t,e){return new URL(t,e).href},uT={},HS=function(e,r,n){if(!r||r.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(r.map(s=>{if(s=jde(s,n),s in uT)return;uT[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!n)for(let u=i.length-1;u>=0;u--){const f=i[u];if(f.href===s&&(!o||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const l=document.createElement("link");if(l.rel=o?"stylesheet":Bde,o||(l.as="script",l.crossOrigin=""),l.href=s,document.head.appendChild(l),o)return new Promise((u,f)=>{l.addEventListener("load",u),l.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})},NC=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],TF=[{inputs:[],name:"ResolverNotFound",type:"error"},{inputs:[],name:"ResolverWildcardNotSupported",type:"error"}],IF=[...TF,{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],Ude=[...TF,{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]}],fT=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],dT=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],zde=[{inputs:[{internalType:"address",name:"_signer",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"}],Wde="0x82ad56cb";function Hde(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new AF(n,{docsPath:e,...r})}const U2=new Map;function qS({fn:t,id:e,shouldSplitBatch:r,wait:n=0}){const i=async()=>{const l=a();s();const u=l.map(({args:f})=>f);u.length!==0&&t(u).then(f=>{l.forEach(({pendingPromise:d},h)=>{var p;return(p=d.resolve)==null?void 0:p.call(d,[f[h],f])})}).catch(f=>{l.forEach(({pendingPromise:d})=>{var h;return(h=d.reject)==null?void 0:h.call(d,f)})})},s=()=>U2.delete(e),o=()=>a().map(({args:l})=>l),a=()=>U2.get(e)||[],c=l=>U2.set(e,[...a(),l]);return{flush:s,async schedule(l){const u={},f=new Promise((p,v)=>{u.resolve=p,u.reject=v});return(r==null?void 0:r([...o(),l]))&&i(),a().length>0?(c({args:l,pendingPromise:u}),f):(c({args:l,pendingPromise:u}),setTimeout(i,n),f)}}}async function Eb(t,e){var y,m,g,S;const{account:r=t.account,batch:n=!!((y=t.batch)!=null&&y.multicall),blockNumber:i,blockTag:s="latest",accessList:o,data:a,gas:c,gasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:f,nonce:d,to:h,value:p,...v}=e,b=r?Yi(r):void 0;try{H1(e);const T=(i?Ue(i):void 0)||s,w=((S=(g=(m=t.chain)==null?void 0:m.formatters)==null?void 0:g.transactionRequest)==null?void 0:S.format)||hb,I=w({...jS(v,{format:w}),from:b==null?void 0:b.address,accessList:o,data:a,gas:c,gasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:f,nonce:d,to:h,value:p});if(n&&qde({request:I}))try{return await Vde(t,{...I,blockNumber:i,blockTag:s})}catch(j){if(!(j instanceof ZL)&&!(j instanceof xC))throw j}const F=await t.request({method:"eth_call",params:T?[I,T]:[I]});return F==="0x"?{data:void 0}:{data:F}}catch(P){const T=Gde(P),{offchainLookup:w,offchainLookupSignature:I}=await HS(()=>import("./ccip-bb77ee49.js"),[],import.meta.url);if((T==null?void 0:T.slice(0,10))===I&&h)return{data:await w(t,{data:T,to:h})};throw Hde(P,{...e,account:b,chain:t.chain})}}function qde({request:t}){const{data:e,to:r,...n}=t;return!(!e||e.startsWith(Wde)||!r||Object.values(n).filter(i=>typeof i<"u").length>0)}async function Vde(t,e){var v;const{batchSize:r=1024,wait:n=0}=typeof((v=t.batch)==null?void 0:v.multicall)=="object"?t.batch.multicall:{},{blockNumber:i,blockTag:s="latest",data:o,multicallAddress:a,to:c}=e;let l=a;if(!l){if(!t.chain)throw new ZL;l=gd({blockNumber:i,chain:t.chain,contract:"multicall3"})}const f=(i?Ue(i):void 0)||s,{schedule:d}=qS({id:`${t.uid}.${f}`,wait:n,shouldSplitBatch(b){return b.reduce((m,{data:g})=>m+(g.length-2),0)>r*2},fn:async b=>{const y=b.map(S=>({allowFailure:!0,callData:S.data,target:S.to})),m=Dc({abi:NC,args:[y],functionName:"aggregate3"}),g=await t.request({method:"eth_call",params:[{data:m,to:l},f]});return Cd({abi:NC,args:[y],functionName:"aggregate3",data:g||"0x"})}}),[{returnData:h,success:p}]=await d({data:o,to:c});if(!p)throw new LS({data:h});return h==="0x"?{data:void 0}:{data:h}}function Gde(t){if(!(t instanceof le))return;const e=t.walk();return typeof e.data=="object"?e.data.data:e.data}async function gc(t,{abi:e,address:r,args:n,functionName:i,...s}){const o=Dc({abi:e,args:n,functionName:i});try{const{data:a}=await Eb(t,{data:o,to:r,...s});return Cd({abi:e,args:n,functionName:i,data:a||"0x"})}catch(a){throw t1(a,{abi:e,address:r,args:n,docsPath:"/docs/contract/readContract",functionName:i})}}async function Kde(t,{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}){const a=o.account?Yi(o.account):void 0,c=Dc({abi:e,args:n,functionName:s});try{const{data:l}=await Eb(t,{batch:!1,data:`${c}${i?i.replace("0x",""):""}`,to:r,...o});return{result:Cd({abi:e,args:n,functionName:s,data:l||"0x"}),request:{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}}}catch(l){throw t1(l,{abi:e,address:r,args:n,docsPath:"/docs/contract/simulateContract",functionName:s,sender:a==null?void 0:a.address})}}const z2=new Map,hT=new Map;let Qde=0;function Sd(t,e,r){const n=++Qde,i=()=>z2.get(t)||[],s=()=>{const u=i();z2.set(t,u.filter(f=>f.id!==n))},o=()=>{const u=hT.get(t);i().length===1&&u&&u(),s()},a=i();if(z2.set(t,[...a,{id:n,fns:e}]),a&&a.length>0)return o;const c={};for(const u in e)c[u]=(...f)=>{const d=i();d.length!==0&&d.forEach(h=>{var p,v;return(v=(p=h.fns)[u])==null?void 0:v.call(p,...f)})};const l=r(c);return typeof l=="function"&&hT.set(t,l),o}async function by(t){return new Promise(e=>setTimeout(e,t))}function q1(t,{emitOnBegin:e,initialWaitTime:r,interval:n}){let i=!0;const s=()=>i=!1;return(async()=>{let a;e&&(a=await t({unpoll:s}));const c=await(r==null?void 0:r(a))??n;await by(c);const l=async()=>{i&&(await t({unpoll:s}),await by(n),l())};l()})(),s}const pT="/docs/contract/decodeEventLog";function V1({abi:t,data:e,strict:r,topics:n}){const i=r??!0,[s,...o]=n;if(!s)throw new Cfe({docsPath:pT});const a=t.find(p=>p.type==="event"&&s===RS(Nc(p)));if(!(a&&"name"in a)||a.type!=="event")throw new Sfe(s,{docsPath:pT});const{name:c,inputs:l}=a,u=l==null?void 0:l.some(p=>!("name"in p&&p.name));let f=u?[]:{};const d=l.filter(p=>"indexed"in p&&p.indexed);if(o.length>0)for(let p=0;p!("indexed"in p&&p.indexed));if(h.length>0){if(e&&e!=="0x")try{const p=bb(h,e);if(p)if(u)f=[...f,...p];else for(let v=0;v0?f:void 0}}function Yde({param:t,value:e}){return t.type==="string"||t.type==="bytes"||t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/)?e:(bb([t],e)||[])[0]}const Jde=new Map,Xde=new Map;function Zde(t){const e=(i,s)=>({clear:()=>s.delete(i),get:()=>s.get(i),set:o=>s.set(i,o)}),r=e(t,Jde),n=e(t,Xde);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function ehe(t,{cacheKey:e,cacheTime:r=1/0}){const n=Zde(e),i=n.response.get();if(i&&r>0&&new Date().getTime()-i.created.getTime()`blockNumber.${t}`;async function G1(t,{cacheTime:e=t.cacheTime,maxAge:r}={}){const n=await ehe(()=>t.request({method:"eth_blockNumber"}),{cacheKey:the(t.uid),cacheTime:r??e});return BigInt(n)}async function xb(t,{filter:e}){const r="strict"in e&&e.strict;return(await e.request({method:"eth_getFilterChanges",params:[e.id]})).map(i=>{var s;if(typeof i=="string")return i;try{const{eventName:o,args:a}="abi"in e&&e.abi?V1({abi:e.abi,data:i.data,topics:i.topics,strict:r}):{eventName:void 0,args:void 0};return ks(i,{args:a,eventName:o})}catch(o){let a,c;if(o instanceof zl||o instanceof wd){if("strict"in e&&e.strict)return;a=o.abiItem.name,c=(s=o.abiItem.inputs)==null?void 0:s.some(l=>!("name"in l&&l.name))}return ks(i,{args:c?[]:{},eventName:a})}}).filter(Boolean)}async function VS(t,{address:e,blockHash:r,fromBlock:n,toBlock:i,event:s,events:o,args:a,strict:c}={}){const l=c??!1,u=o??(s?[s]:void 0);let f=[];u&&(f=[u.flatMap(h=>W1({abi:[h],eventName:h.name,args:a}))],s&&(f=f[0]));let d;return r?d=await t.request({method:"eth_getLogs",params:[{address:e,topics:f,blockHash:r}]}):d=await t.request({method:"eth_getLogs",params:[{address:e,topics:f,fromBlock:typeof n=="bigint"?Ue(n):n,toBlock:typeof i=="bigint"?Ue(i):i}]}),d.map(h=>{var p;try{const{eventName:v,args:b}=u?V1({abi:u,data:h.data,topics:h.topics,strict:l}):{eventName:void 0,args:void 0};return ks(h,{args:b,eventName:v})}catch(v){let b,y;if(v instanceof zl||v instanceof wd){if(l)return;b=v.abiItem.name,y=(p=v.abiItem.inputs)==null?void 0:p.some(m=>!("name"in m&&m.name))}return ks(h,{args:y?[]:{},eventName:b})}}).filter(Boolean)}async function Cb(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}function rhe(t,{abi:e,address:r,args:n,batch:i=!0,eventName:s,onError:o,onLogs:a,poll:c,pollingInterval:l=t.pollingInterval,strict:u}){return(typeof c<"u"?c:t.transport.type!=="webSocket")?(()=>{const p=Ln(["watchContractEvent",r,n,i,t.uid,s,l]),v=u??!1;return Sd(p,{onLogs:a,onError:o},b=>{let y,m,g=!1;const S=q1(async()=>{var P;if(!g){try{m=await CF(t,{abi:e,address:r,args:n,eventName:s,strict:v})}catch{}g=!0;return}try{let T;if(m)T=await xb(t,{filter:m});else{const w=await G1(t);y&&y!==w?T=await VS(t,{address:r,args:n,fromBlock:y+1n,toBlock:w,event:z1({abi:e,name:s})}):T=[],y=w}if(T.length===0)return;i?b.onLogs(T):T.forEach(w=>b.onLogs([w]))}catch(T){m&&T instanceof Wl&&(g=!1),(P=b.onError)==null||P.call(b,T)}},{emitOnBegin:!0,interval:l});return async()=>{m&&await Cb(t,{filter:m}),S()}})})():(()=>{let p=!0,v=()=>p=!1;return(async()=>{try{const b=s?W1({abi:e,eventName:s,args:n}):[],{unsubscribe:y}=await t.transport.subscribe({params:["logs",{address:r,topics:b}],onData(m){var S;if(!p)return;const g=m.result;try{const{eventName:P,args:T}=V1({abi:e,data:g.data,topics:g.topics,strict:u}),w=ks(g,{args:T,eventName:P});a([w])}catch(P){let T,w;if(P instanceof zl||P instanceof wd){if(u)return;T=P.abiItem.name,w=(S=P.abiItem.inputs)==null?void 0:S.some(F=>!("name"in F&&F.name))}const I=ks(g,{args:w?[]:{},eventName:T});a([I])}},onError(m){o==null||o(m)}});v=y,p||v()}catch(b){o==null||o(b)}})(),v})()}function nhe(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new ufe(n,{docsPath:e,...r})}async function r1(t){const e=await t.request({method:"eth_chainId"});return Nn(e)}async function GS(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]})}async function KS(t,e){var v,b,y;const{account:r=t.account,chain:n=t.chain,accessList:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d,...h}=e;if(!r)throw new xd({docsPath:"/docs/actions/wallet/sendTransaction"});const p=Yi(r);try{H1(e);let m;if(n!==null&&(m=await r1(t),eF({currentChainId:m,chain:n})),p.type==="local"){const P=await wb(t,{account:p,accessList:i,chain:n,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d,...h});m||(m=await r1(t));const T=(v=n==null?void 0:n.serializers)==null?void 0:v.transaction,w=await p.signTransaction({...P,chainId:m},{serializer:T});return await GS(t,{serializedTransaction:w})}const g=((y=(b=n==null?void 0:n.formatters)==null?void 0:b.transactionRequest)==null?void 0:y.format)||hb,S=g({...jS(h,{format:g}),accessList:i,data:s,from:p.address,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d});return await t.request({method:"eth_sendTransaction",params:[S]})}catch(m){throw nhe(m,{...e,account:p,chain:e.chain||void 0})}}async function ihe(t,{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}){const a=Dc({abi:e,args:n,functionName:s});return await KS(t,{data:`${a}${i?i.replace("0x",""):""}`,to:r,...o})}async function she(t,{chain:e}){const{id:r,name:n,nativeCurrency:i,rpcUrls:s,blockExplorers:o}=e;await t.request({method:"wallet_addEthereumChain",params:[{chainId:Ue(r),chainName:n,nativeCurrency:i,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:a})=>a):void 0}]})}const DC=256;let Zp=DC,ev;function ohe(t=11){if(!ev||Zp+t>DC*2){ev="",Zp=0;for(let e=0;e{const y=b(v);for(const g in h)delete y[g];const m={...v,...y};return Object.assign(m,{extend:p(m)})}}return Object.assign(h,{extend:p(h)})}function RF(t,{delay:e=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((i,s)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const u=typeof e=="function"?e({count:a,error:l}):e;u&&await by(u),o({count:a+1})};try{const l=await t();i(l)}catch(l){if(a"code"in t?t.code!==-1&&t.code!==-32004&&t.code!==-32005&&t.code!==-32042&&t.code!==-32603:t instanceof Wh&&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:!1;function ahe(t,{retryDelay:e=150,retryCount:r=3}={}){return async n=>RF(async()=>{try{return await t(n)}catch(i){const s=i;switch(s.code){case z0.code:throw new z0(s);case W0.code:throw new W0(s);case H0.code:throw new H0(s);case q0.code:throw new q0(s);case qf.code:throw new qf(s);case Wl.code:throw new Wl(s);case V0.code:throw new V0(s);case mc.code:throw new mc(s);case G0.code:throw new G0(s);case K0.code:throw new K0(s);case Q0.code:throw new Q0(s);case Y0.code:throw new Y0(s);case Pr.code:throw new Pr(s);case J0.code:throw new J0(s);case X0.code:throw new X0(s);case Z0.code:throw new Z0(s);case e1.code:throw new e1(s);case ea.code:throw new ea(s);case 5e3:throw new Pr(s);default:throw i instanceof le?i:new Tde(s)}}},{delay:({count:i,error:s})=>{var o;if(s&&s instanceof Wh){const a=(o=s==null?void 0:s.headers)==null?void 0:o.get("Retry-After");if(a!=null&&a.match(/\d/))return parseInt(a)*1e3}return~~(1<!$F(i)})}function Sb({key:t,name:e,request:r,retryCount:n=3,retryDelay:i=150,timeout:s,type:o},a){return{config:{key:t,name:e,request:r,retryCount:n,retryDelay:i,timeout:s,type:o},request:ahe(r,{retryCount:n,retryDelay:i}),value:a}}function kb(t,e={}){const{key:r="custom",name:n="Custom Provider",retryDelay:i}=e;return({retryCount:s})=>Sb({key:r,name:n,request:t.request.bind(t),retryCount:e.retryCount??s,retryDelay:i,type:"custom"})}function vT(t,e={}){const{key:r="fallback",name:n="Fallback",rank:i=!1,retryCount:s,retryDelay:o}=e;return({chain:a,pollingInterval:c=4e3,timeout:l})=>{let u=t,f=()=>{};const d=Sb({key:r,name:n,async request({method:h,params:p}){const v=async(b=0)=>{const y=u[b]({chain:a,retryCount:0,timeout:l});try{const m=await y.request({method:h,params:p});return f({method:h,params:p,response:m,transport:y,status:"success"}),m}catch(m){if(f({error:m,method:h,params:p,transport:y,status:"error"}),$F(m)||b===u.length-1)throw m;return v(b+1)}};return v()},retryCount:s,retryDelay:o,type:"fallback"},{onResponse:h=>f=h,transports:u.map(h=>h({chain:a,retryCount:0}))});if(i){const h=typeof i=="object"?i:{};che({chain:a,interval:h.interval??c,onTransports:p=>u=p,sampleCount:h.sampleCount,timeout:h.timeout,transports:u,weights:h.weights})}return d}}function che({chain:t,interval:e=4e3,onTransports:r,sampleCount:n=10,timeout:i=1e3,transports:s,weights:o={}}){const{stability:a=.7,latency:c=.3}=o,l=[],u=async()=>{const f=await Promise.all(s.map(async p=>{const v=p({chain:t,retryCount:0,timeout:i}),b=Date.now();let y,m;try{await v.request({method:"net_listening"}),m=1}catch{m=0}finally{y=Date.now()}return{latency:y-b,success:m}}));l.push(f),l.length>n&&l.shift();const d=Math.max(...l.map(p=>Math.max(...p.map(({latency:v})=>v)))),h=s.map((p,v)=>{const b=l.map(P=>P[v].latency),m=1-b.reduce((P,T)=>P+T,0)/b.length/d,g=l.map(P=>P[v].success),S=g.reduce((P,T)=>P+T,0)/g.length;return S===0?[0,v]:[c*m+a*S,v]}).sort((p,v)=>v[0]-p[0]);r(h.map(([,p])=>s[p])),await by(e),u()};u()}class MF extends le{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro"})}}var Ou=null;typeof WebSocket<"u"?Ou=WebSocket:typeof MozWebSocket<"u"?Ou=MozWebSocket:typeof global<"u"?Ou=global.WebSocket||global.MozWebSocket:typeof window<"u"?Ou=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(Ou=self.WebSocket||self.MozWebSocket);const mT=Ou;function NF(t,{errorInstance:e,timeout:r,signal:n}){return new Promise((i,s)=>{(async()=>{let o;try{const a=new AbortController;r>0&&(o=setTimeout(()=>{n?a.abort():s(e)},r)),i(await t({signal:a==null?void 0:a.signal}))}catch(a){a.name==="AbortError"&&s(e),s(a)}finally{clearTimeout(o)}})()})}let LC=0;async function lhe(t,{body:e,fetchOptions:r={},timeout:n=1e4}){var a;const{headers:i,method:s,signal:o}=r;try{const c=await NF(async({signal:u})=>await fetch(t,{...r,body:Array.isArray(e)?Ln(e.map(d=>({jsonrpc:"2.0",id:d.id??LC++,...d}))):Ln({jsonrpc:"2.0",id:e.id??LC++,...e}),headers:{...i,"Content-Type":"application/json"},method:s||"POST",signal:o||(n>0?u:void 0)}),{errorInstance:new $C({body:e,url:t}),timeout:n,signal:!0});let l;if((a=c.headers.get("Content-Type"))!=null&&a.startsWith("application/json")?l=await c.json():l=await c.text(),!c.ok)throw new Wh({body:e,details:Ln(l.error)||c.statusText,headers:c.headers,status:c.status,url:t});return l}catch(c){throw c instanceof Wh||c instanceof $C?c:new Wh({body:e,details:c.message,url:t})}}const W2=new Map;async function H2(t){let e=W2.get(t);if(e)return e;const{schedule:r}=qS({id:t,fn:async()=>{const s=new mT(t),o=new Map,a=new Map,c=({data:u})=>{const f=JSON.parse(u),d=f.method==="eth_subscription",h=d?f.params.subscription:f.id,p=d?a:o,v=p.get(h);v&&v({data:u}),d||p.delete(h)},l=()=>{W2.delete(t),s.removeEventListener("close",l),s.removeEventListener("message",c)};return s.addEventListener("close",l),s.addEventListener("message",c),s.readyState===mT.CONNECTING&&await new Promise((u,f)=>{s&&(s.onopen=u,s.onerror=f)}),e=Object.assign(s,{requests:o,subscriptions:a}),W2.set(t,e),[e]}}),[n,[i]]=await r();return i}function uhe(t,{body:e,onResponse:r}){if(t.readyState===t.CLOSED||t.readyState===t.CLOSING)throw new _de({body:e,url:t.url,details:"Socket is closed."});const n=LC++,i=({data:s})=>{var a;const o=JSON.parse(s);typeof o.id=="number"&&n!==o.id||(r==null||r(o),e.method==="eth_subscribe"&&typeof o.result=="string"&&t.subscriptions.set(o.result,i),e.method==="eth_unsubscribe"&&t.subscriptions.delete((a=e.params)==null?void 0:a[0]))};return t.requests.set(n,i),t.send(JSON.stringify({jsonrpc:"2.0",...e,id:n})),t}async function fhe(t,{body:e,timeout:r=1e4}){return NF(()=>new Promise(n=>gf.webSocket(t,{body:e,onResponse:n})),{errorInstance:new $C({body:e,url:t.url}),timeout:r})}const gf={http:lhe,webSocket:uhe,webSocketAsync:fhe};function DF(t,e={}){const{batch:r,fetchOptions:n,key:i="http",name:s="HTTP JSON-RPC",retryDelay:o}=e;return({chain:a,retryCount:c,timeout:l})=>{const{batchSize:u=1e3,wait:f=0}=typeof r=="object"?r:{},d=e.retryCount??c,h=l??e.timeout??1e4,p=t||(a==null?void 0:a.rpcUrls.default.http[0]);if(!p)throw new MF;return Sb({key:i,name:s,async request({method:v,params:b}){const y={method:v,params:b},{schedule:m}=qS({id:`${t}`,wait:f,shouldSplitBatch(T){return T.length>u},fn:T=>gf.http(p,{body:T,fetchOptions:n,timeout:h})}),g=async T=>r?m(T):[await gf.http(p,{body:T,fetchOptions:n,timeout:h})],[{error:S,result:P}]=await g(y);if(S)throw new FS({body:y,error:S,url:p});return P},retryCount:d,retryDelay:o,timeout:h,type:"http"},{url:t})}}function QS(t,e){var n,i,s;if(!(t instanceof le))return!1;const r=t.walk(o=>o instanceof RC);return r instanceof RC?!!(((n=r.data)==null?void 0:n.errorName)==="ResolverNotFound"||((i=r.data)==null?void 0:i.errorName)==="ResolverWildcardNotSupported"||(s=r.reason)!=null&&s.includes("Wildcard on non-extended resolvers is not supported")||e==="reverse"&&r.reason===SF[50]):!1}function LF(t){if(t.length!==66||t.indexOf("[")!==0||t.indexOf("]")!==65)return null;const e=`0x${t.slice(1,65)}`;return mo(e)?e:null}function zv(t){let e=new Uint8Array(32).fill(0);if(!t)return j0(e);const r=t.split(".");for(let n=r.length-1;n>=0;n-=1){const i=LF(r[n]),s=i?Ul(i):Yn(Fo(r[n]),"bytes");e=Yn(Zo([e,s]),"bytes")}return j0(e)}function dhe(t){return`[${t.slice(2)}]`}function hhe(t){const e=new Uint8Array(32).fill(0);return t?LF(t)||Yn(Fo(t)):j0(e)}function Ab(t){const e=t.replace(/^\.|\.$/gm,"");if(e.length===0)return new Uint8Array(1);const r=new Uint8Array(Fo(e).byteLength+2);let n=0;const i=e.split(".");for(let s=0;s255&&(o=Fo(dhe(hhe(i[s])))),r[n]=o.length,r.set(o,n+1),n+=o.length+1}return r.byteLength!==n+1?r.slice(0,n+1):r}async function phe(t,{blockNumber:e,blockTag:r,coinType:n,name:i,universalResolverAddress:s}){let o=s;if(!o){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");o=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}try{const a=Dc({abi:dT,functionName:"addr",...n!=null?{args:[zv(i),BigInt(n)]}:{args:[zv(i)]}}),c=await gc(t,{address:o,abi:IF,functionName:"resolve",args:[da(Ab(i)),a],blockNumber:e,blockTag:r});if(c[0]==="0x")return null;const l=Cd({abi:dT,args:n!=null?[zv(i),BigInt(n)]:void 0,functionName:"addr",data:c[0]});return l==="0x"||mf(l)==="0x00"?null:l}catch(a){if(QS(a,"resolve"))return null;throw a}}class vhe extends le{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarInvalidMetadataError"})}}class rh extends le{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarInvalidNftUriError"})}}class YS extends le{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarUriResolutionError"})}}class mhe extends le{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarUnsupportedNamespaceError"})}}const yhe=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ghe=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,bhe=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,whe=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function Ehe(t){try{const e=await fetch(t,{method:"HEAD"});if(e.status===200){const r=e.headers.get("content-type");return r==null?void 0:r.startsWith("image/")}return!1}catch(e){return typeof e=="object"&&typeof e.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(r=>{const n=new Image;n.onload=()=>{r(!0)},n.onerror=()=>{r(!1)},n.src=t})}}function yT(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function FF({uri:t,gatewayUrls:e}){const r=bhe.test(t);if(r)return{uri:t,isOnChain:!0,isEncoded:r};const n=yT(e==null?void 0:e.ipfs,"https://ipfs.io"),i=yT(e==null?void 0:e.arweave,"https://arweave.net"),s=t.match(yhe),{protocol:o,subpath:a,target:c,subtarget:l=""}=(s==null?void 0:s.groups)||{},u=o==="ipns:/"||a==="ipns/",f=o==="ipfs:/"||a==="ipfs/"||ghe.test(t);if(t.startsWith("http")&&!u&&!f){let h=t;return e!=null&&e.arweave&&(h=t.replace(/https:\/\/arweave.net/g,e==null?void 0:e.arweave)),{uri:h,isOnChain:!1,isEncoded:!1}}if((u||f)&&c)return{uri:`${n}/${u?"ipns":"ipfs"}/${c}${l}`,isOnChain:!1,isEncoded:!1};if(o==="ar:/"&&c)return{uri:`${i}/${c}${l||""}`,isOnChain:!1,isEncoded:!1};let d=t.replace(whe,"");if(d.startsWith("i.json());return await JS({gatewayUrls:t,uri:BF(r)})}catch{throw new YS({uri:e})}}async function JS({gatewayUrls:t,uri:e}){const{uri:r,isOnChain:n}=FF({uri:e,gatewayUrls:t});if(n||await Ehe(r))return r;throw new YS({uri:e})}function Che(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[r,n,i]=e.split("/"),[s,o]=r.split(":"),[a,c]=n.split(":");if(!s||s.toLowerCase()!=="eip155")throw new rh({reason:"Only EIP-155 supported"});if(!o)throw new rh({reason:"Chain ID not found"});if(!c)throw new rh({reason:"Contract address not found"});if(!i)throw new rh({reason:"Token ID not found"});if(!a)throw new rh({reason:"ERC namespace not found"});return{chainID:parseInt(o),namespace:a.toLowerCase(),contractAddress:c,tokenID:i}}async function She(t,{nft:e}){if(e.namespace==="erc721")return gc(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if(e.namespace==="erc1155")return gc(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new mhe({namespace:e.namespace})}async function khe(t,{gatewayUrls:e,record:r}){return/eip155:/i.test(r)?Ahe(t,{gatewayUrls:e,record:r}):JS({uri:r,gatewayUrls:e})}async function Ahe(t,{gatewayUrls:e,record:r}){const n=Che(r),i=await She(t,{nft:n}),{uri:s,isOnChain:o,isEncoded:a}=FF({uri:i,gatewayUrls:e});if(o&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const l=a?atob(s.replace("data:application/json;base64,","")):s,u=JSON.parse(l);return JS({uri:BF(u),gatewayUrls:e})}let c=n.tokenID;return n.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),xhe({gatewayUrls:e,uri:s.replace(/(?:0x)?{id}/,c)})}async function jF(t,{blockNumber:e,blockTag:r,name:n,key:i,universalResolverAddress:s}){let o=s;if(!o){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");o=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}try{const a=await gc(t,{address:o,abi:IF,functionName:"resolve",args:[da(Ab(n)),Dc({abi:fT,functionName:"text",args:[zv(n),i]})],blockNumber:e,blockTag:r});if(a[0]==="0x")return null;const c=Cd({abi:fT,functionName:"text",data:a[0]});return c===""?null:c}catch(a){if(QS(a,"resolve"))return null;throw a}}async function _he(t,{blockNumber:e,blockTag:r,gatewayUrls:n,name:i,universalResolverAddress:s}){const o=await jF(t,{blockNumber:e,blockTag:r,key:"avatar",name:i,universalResolverAddress:s});if(!o)return null;try{return await khe(t,{record:o,gatewayUrls:n})}catch{return null}}async function Phe(t,{address:e,blockNumber:r,blockTag:n,universalResolverAddress:i}){let s=i;if(!s){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");s=gd({blockNumber:r,chain:t.chain,contract:"ensUniversalResolver"})}const o=`${e.toLowerCase().substring(2)}.addr.reverse`;try{return(await gc(t,{address:s,abi:Ude,functionName:"reverse",args:[da(Ab(o))],blockNumber:r,blockTag:n}))[0]}catch(a){if(QS(a,"reverse"))return null;throw a}}async function The(t,{blockNumber:e,blockTag:r,name:n,universalResolverAddress:i}){let s=i;if(!s){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");s=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}const[o]=await gc(t,{address:s,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[da(Ab(n))],blockNumber:e,blockTag:r});return o}async function Ihe(t){const e=gb(t,{method:"eth_newBlockFilter"}),r=await t.request({method:"eth_newBlockFilter"});return{id:r,request:e(r),type:"block"}}async function UF(t,{address:e,args:r,event:n,events:i,fromBlock:s,strict:o,toBlock:a}={}){const c=i??(n?[n]:void 0),l=gb(t,{method:"eth_newFilter"});let u=[];c&&(u=[c.flatMap(d=>W1({abi:[d],eventName:d.name,args:r}))],n&&(u=u[0]));const f=await t.request({method:"eth_newFilter",params:[{address:e,fromBlock:typeof s=="bigint"?Ue(s):s,toBlock:typeof a=="bigint"?Ue(a):a,...u.length?{topics:u}:{}}]});return{abi:c,args:r,eventName:n?n.name:void 0,fromBlock:s,id:f,request:l(f),strict:o,toBlock:a,type:"event"}}async function zF(t){const e=gb(t,{method:"eth_newPendingTransactionFilter"}),r=await t.request({method:"eth_newPendingTransactionFilter"});return{id:r,request:e(r),type:"transaction"}}async function Ohe(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=r?Ue(r):void 0,s=await t.request({method:"eth_getBalance",params:[e,i||n]});return BigInt(s)}async function Rhe(t,{blockHash:e,blockNumber:r,blockTag:n="latest"}={}){const i=r!==void 0?Ue(r):void 0;let s;return e?s=await t.request({method:"eth_getBlockTransactionCountByHash",params:[e]}):s=await t.request({method:"eth_getBlockTransactionCountByNumber",params:[i||n]}),Nn(s)}async function $he(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=r!==void 0?Ue(r):void 0,s=await t.request({method:"eth_getCode",params:[e,i||n]});if(s!=="0x")return s}function Mhe(t){var e;return{baseFeePerGas:t.baseFeePerGas.map(r=>BigInt(r)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:(e=t.reward)==null?void 0:e.map(r=>r.map(n=>BigInt(n)))}}async function Nhe(t,{blockCount:e,blockNumber:r,blockTag:n="latest",rewardPercentiles:i}){const s=r?Ue(r):void 0,o=await t.request({method:"eth_feeHistory",params:[Ue(e),s||n,i]});return Mhe(o)}async function Dhe(t,{filter:e}){const r=e.strict??!1;return(await e.request({method:"eth_getFilterLogs",params:[e.id]})).map(i=>{var s;try{const{eventName:o,args:a}="abi"in e&&e.abi?V1({abi:e.abi,data:i.data,topics:i.topics,strict:r}):{eventName:void 0,args:void 0};return ks(i,{args:a,eventName:o})}catch(o){let a,c;if(o instanceof zl||o instanceof wd){if("strict"in e&&e.strict)return;a=o.abiItem.name,c=(s=o.abiItem.inputs)==null?void 0:s.some(l=>!("name"in l&&l.name))}return ks(i,{args:c?[]:{},eventName:a})}}).filter(Boolean)}async function Lhe(t,{address:e,blockNumber:r,blockTag:n="latest",slot:i}){const s=r!==void 0?Ue(r):void 0;return await t.request({method:"eth_getStorageAt",params:[e,i,s||n]})}async function XS(t,{blockHash:e,blockNumber:r,blockTag:n,hash:i,index:s}){var u,f,d;const o=n||"latest",a=r!==void 0?Ue(r):void 0;let c=null;if(i?c=await t.request({method:"eth_getTransactionByHash",params:[i]}):e?c=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[e,Ue(s)]}):(a||o)&&(c=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[a||o,Ue(s)]})),!c)throw new cF({blockHash:e,blockNumber:r,blockTag:o,hash:i,index:s});return(((d=(f=(u=t.chain)==null?void 0:u.formatters)==null?void 0:f.transaction)==null?void 0:d.format)||sF)(c)}async function Fhe(t,{hash:e,transactionReceipt:r}){const[n,i]=await Promise.all([G1(t),e?XS(t,{hash:e}):void 0]),s=(r==null?void 0:r.blockNumber)||(i==null?void 0:i.blockNumber);return s?n-s+1n:0n}async function FC(t,{hash:e}){var i,s,o;const r=await t.request({method:"eth_getTransactionReceipt",params:[e]});if(!r)throw new lF({hash:e});return(((o=(s=(i=t.chain)==null?void 0:i.formatters)==null?void 0:s.transactionReceipt)==null?void 0:o.format)||rfe)(r)}async function Bhe(t,e){var v;const{allowFailure:r=!0,batchSize:n,blockNumber:i,blockTag:s,contracts:o,multicallAddress:a}=e,c=n??(typeof((v=t.batch)==null?void 0:v.multicall)=="object"&&t.batch.multicall.batchSize||1024);let l=a;if(!l){if(!t.chain)throw new Error("client chain not configured. multicallAddress is required.");l=gd({blockNumber:i,chain:t.chain,contract:"multicall3"})}const u=[[]];let f=0,d=0;for(let b=0;b0&&d>c&&u[f].length>0&&(f++,d=(P.length-2)/2,u[f]=[]),u[f]=[...u[f],{allowFailure:!0,callData:P,target:m}]}catch(P){const T=t1(P,{abi:y,address:m,args:g,docsPath:"/docs/contract/multicall",functionName:S});if(!r)throw T;u[f]=[...u[f],{allowFailure:!0,callData:"0x",target:m}]}}const h=await Promise.allSettled(u.map(b=>gc(t,{abi:NC,address:l,args:[b],blockNumber:i,blockTag:s,functionName:"aggregate3"}))),p=[];for(let b=0;b"u"?{}:t,s={EIP712Domain:KF({domain:i}),...n};GF({domain:i,message:e,primaryType:r,types:s});const o=["0x1901"];return i&&o.push(Whe({domain:i,types:s})),r!=="EIP712Domain"&&o.push(WF({data:e,primaryType:r,types:s})),Yn(Zo(o))}function Whe({domain:t,types:e}){return WF({data:t,primaryType:"EIP712Domain",types:e})}function WF({data:t,primaryType:e,types:r}){const n=HF({data:t,primaryType:e,types:r});return Yn(n)}function HF({data:t,primaryType:e,types:r}){const n=[{type:"bytes32"}],i=[Hhe({primaryType:e,types:r})];for(const s of r[e]){const[o,a]=VF({types:r,name:s.name,type:s.type,value:t[s.name]});n.push(o),i.push(a)}return U1(n,i)}function Hhe({primaryType:t,types:e}){const r=da(qhe({primaryType:t,types:e}));return Yn(r)}function qhe({primaryType:t,types:e}){let r="";const n=qF({primaryType:t,types:e});n.delete(t);const i=[t,...Array.from(n).sort()];for(const s of i)r+=`${s}(${e[s].map(({name:o,type:a})=>`${a} ${o}`).join(",")})`;return r}function qF({primaryType:t,types:e},r=new Set){const n=t.match(/^\w*/u),i=n==null?void 0:n[0];if(r.has(i)||e[i]===void 0)return r;r.add(i);for(const s of e[i])qF({primaryType:s.type,types:e},r);return r}function VF({types:t,name:e,type:r,value:n}){if(t[r]!==void 0)return[{type:"bytes32"},Yn(HF({data:n,primaryType:r,types:t}))];if(r==="bytes")return n=`0x${(n.length%2?"0":"")+n.slice(2)}`,[{type:"bytes32"},Yn(n)];if(r==="string")return[{type:"bytes32"},Yn(da(n))];if(r.lastIndexOf("]")===r.length-1){const i=r.slice(0,r.lastIndexOf("[")),s=n.map(o=>VF({name:e,type:i,types:t,value:o}));return[{type:"bytes32"},Yn(U1(s.map(([o])=>o),s.map(([,o])=>o)))]}return[{type:r},n]}function GF({domain:t,message:e,primaryType:r,types:n}){const i=n,s=(o,a)=>{for(const c of o){const{name:l,type:u}=c,f=u,d=a[l],h=f.match(Uhe);if(h&&(typeof d=="number"||typeof d=="bigint")){const[b,y,m]=h;Ue(d,{signed:y==="int",size:parseInt(m)/8})}if(f==="address"&&typeof d=="string"&&!Hf(d))throw new U0({address:d});const p=f.match(jhe);if(p){const[b,y]=p;if(y&&Br(d)!==parseInt(y))throw new Afe({expectedSize:parseInt(y),givenSize:Br(d)})}const v=i[f];v&&s(v,d)}};if(i.EIP712Domain&&t&&s(i.EIP712Domain,t),r!=="EIP712Domain"){const o=i[r];s(o,e)}}function KF({domain:t}){return[typeof(t==null?void 0:t.name)=="string"&&{name:"name",type:"string"},(t==null?void 0:t.version)&&{name:"version",type:"string"},typeof(t==null?void 0:t.chainId)=="number"&&{name:"chainId",type:"uint256"},(t==null?void 0:t.verifyingContract)&&{name:"verifyingContract",type:"address"},(t==null?void 0:t.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}const q2="/docs/contract/encodeDeployData";function QF({abi:t,args:e,bytecode:r}){if(!e||e.length===0)return r;const n=t.find(s=>"type"in s&&s.type==="constructor");if(!n)throw new bfe({docsPath:q2});if(!("inputs"in n))throw new rT({docsPath:q2});if(!n.inputs||n.inputs.length===0)throw new rT({docsPath:q2});const i=U1(n.inputs,e);return _S([r,i])}function Vhe(t,e){const r=(()=>typeof t=="string"?Fo(t):t.raw instanceof Uint8Array?t.raw:Ul(t.raw))(),n=Fo(`Ethereum Signed Message: +`),{docsPath:e,docsSlug:"account"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AccountNotFoundError"})}}class Ode extends le{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d}){const h=B1({from:r==null?void 0:r.address,to:f,value:typeof d<"u"&&`${PS(d)} ${(i==null?void 0:i.nativeCurrency.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${ti(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${ti(c)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${ti(l)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",h].filter(Boolean)}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EstimateGasExecutionError"}),this.cause=e}}function BS(t,e){const r=(t.details||"").toLowerCase(),n=t.walk(i=>i.code===Zu.code);return n instanceof le?new Zu({cause:t,message:n.details}):Zu.nodeMessage.test(r)?new Zu({cause:t,message:t.details}):vy.nodeMessage.test(r)?new vy({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):CC.nodeMessage.test(r)?new CC({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):SC.nodeMessage.test(r)?new SC({cause:t,nonce:e==null?void 0:e.nonce}):kC.nodeMessage.test(r)?new kC({cause:t,nonce:e==null?void 0:e.nonce}):AC.nodeMessage.test(r)?new AC({cause:t,nonce:e==null?void 0:e.nonce}):_C.nodeMessage.test(r)?new _C({cause:t}):PC.nodeMessage.test(r)?new PC({cause:t,gas:e==null?void 0:e.gas}):TC.nodeMessage.test(r)?new TC({cause:t,gas:e==null?void 0:e.gas}):IC.nodeMessage.test(r)?new IC({cause:t}):my.nodeMessage.test(r)?new my({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas,maxPriorityFeePerGas:e==null?void 0:e.maxPriorityFeePerGas}):new pb({cause:t})}function Rde(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new Ode(n,{docsPath:e,...r})}function jS(t,{format:e}){return e?Object.keys(e({})).reduce((n,i)=>(t!=null&&t.hasOwnProperty(i)&&(n[i]=t[i]),n),{}):{}}function H1(t){const{account:e,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:i,to:s}=t,o=e?Yi(e):void 0;if(o&&!Hf(o.address))throw new U0({address:o.address});if(s&&!Hf(s))throw new U0({address:s});if(typeof r<"u"&&(typeof n<"u"||typeof i<"u"))throw new cfe;if(n&&n>2n**256n-1n)throw new vy({maxFeePerGas:n});if(i&&n&&i>n)throw new my({maxFeePerGas:n,maxPriorityFeePerGas:i})}class $de extends le{constructor(){super("`baseFeeMultiplier` must be greater than 1."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseFeeScalarError"})}}class US extends le{constructor(){super("Chain does not support EIP-1559 fees."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Eip1559FeesNotSupportedError"})}}class Mde extends le{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${ti(e)} gwei).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"MaxFeePerGasTooLowError"})}}class Nde extends le{constructor({blockHash:e,blockNumber:r}){let n="Block";e&&(n=`Block at hash "${e}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BlockNotFoundError"})}}async function yc(t,{blockHash:e,blockNumber:r,blockTag:n,includeTransactions:i}={}){var u,f,d;const s=n??"latest",o=i??!1,a=r!==void 0?Ue(r):void 0;let c=null;if(e?c=await t.request({method:"eth_getBlockByHash",params:[e,o]}):c=await t.request({method:"eth_getBlockByNumber",params:[a||s,o]}),!c)throw new Nde({blockHash:e,blockNumber:r});return(((d=(f=(u=t.chain)==null?void 0:u.formatters)==null?void 0:f.block)==null?void 0:d.format)||oF)(c)}async function zS(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function Dde(t,e){return _F(t,e)}async function _F(t,e){var s,o,a;const{block:r,chain:n=t.chain,request:i}=e||{};if(typeof((s=n==null?void 0:n.fees)==null?void 0:s.defaultPriorityFee)=="function"){const c=r||await yc(t);return n.fees.defaultPriorityFee({block:c,client:t,request:i})}else if((o=n==null?void 0:n.fees)!=null&&o.defaultPriorityFee)return(a=n==null?void 0:n.fees)==null?void 0:a.defaultPriorityFee;try{const c=await t.request({method:"eth_maxPriorityFeePerGas"});return db(c)}catch{const[c,l]=await Promise.all([r?Promise.resolve(r):yc(t),zS(t)]);if(typeof c.baseFeePerGas!="bigint")throw new US;const u=l-c.baseFeePerGas;return u<0n?0n:u}}async function Lde(t,e){return MC(t,e)}async function MC(t,e){var d;const{block:r,chain:n=t.chain,request:i,type:s="eip1559"}=e||{},o=await(async()=>{var h,p;return typeof((h=n==null?void 0:n.fees)==null?void 0:h.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:t,request:i}):((p=n==null?void 0:n.fees)==null?void 0:p.baseFeeMultiplier)??1.2})();if(o<1)throw new $de;const c=10**o.toString().split(".")[1].length,l=h=>h*BigInt(o*c)/BigInt(c),u=r||await yc(t);if(typeof((d=n==null?void 0:n.fees)==null?void 0:d.estimateFeesPerGas)=="function")return n.fees.estimateFeesPerGas({block:r,client:t,multiply:l,request:i,type:s});if(s==="eip1559"){if(typeof u.baseFeePerGas!="bigint")throw new US;const h=i!=null&&i.maxPriorityFeePerGas?i.maxPriorityFeePerGas:await _F(t,{block:u,chain:n,request:i}),p=l(u.baseFeePerGas);return{maxFeePerGas:(i==null?void 0:i.maxFeePerGas)??p+h,maxPriorityFeePerGas:h}}return{gasPrice:(i==null?void 0:i.gasPrice)??l(await zS(t))}}async function PF(t,{address:e,blockTag:r="latest",blockNumber:n}){const i=await t.request({method:"eth_getTransactionCount",params:[e,n?Ue(n):r]});return Nn(i)}async function wb(t,e){const{account:r=t.account,chain:n,gas:i,nonce:s,type:o}=e;if(!r)throw new xd;const a=Yi(r),c=await yc(t,{blockTag:"latest"}),l={...e,from:a.address};if(typeof s>"u"&&(l.nonce=await PF(t,{address:a.address,blockTag:"pending"})),typeof o>"u")try{l.type=dfe(l)}catch{l.type=typeof c.baseFeePerGas=="bigint"?"eip1559":"legacy"}if(l.type==="eip1559"){const{maxFeePerGas:u,maxPriorityFeePerGas:f}=await MC(t,{block:c,chain:n,request:l});if(typeof e.maxPriorityFeePerGas>"u"&&e.maxFeePerGas&&e.maxFeePerGas"u"&&(l.gas=await WS(t,{...l,account:{address:a.address,type:"json-rpc"}})),H1(l),l}async function WS(t,e){var i,s,o;const r=e.account??t.account;if(!r)throw new xd({docsPath:"/docs/actions/public/estimateGas"});const n=Yi(r);try{const{accessList:a,blockNumber:c,blockTag:l,data:u,gas:f,gasPrice:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:v,to:b,value:y,...m}=n.type==="local"?await wb(t,e):e,S=(c?Ue(c):void 0)||l;H1(e);const P=((o=(s=(i=t.chain)==null?void 0:i.formatters)==null?void 0:s.transactionRequest)==null?void 0:o.format)||hb,T=P({...jS(m,{format:P}),from:n.address,accessList:a,data:u,gas:f,gasPrice:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:v,to:b,value:y}),w=await t.request({method:"eth_estimateGas",params:S?[T,S]:[T]});return BigInt(w)}catch(a){throw Rde(a,{...e,account:n,chain:t.chain})}}async function Fde(t,{abi:e,address:r,args:n,functionName:i,...s}){const o=Dc({abi:e,args:n,functionName:i});try{return await WS(t,{data:o,to:r,...s})}catch(a){const c=s.account?Yi(s.account):void 0;throw t1(a,{abi:e,address:r,args:n,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:c==null?void 0:c.address})}}const j2="/docs/contract/decodeFunctionResult";function Cd({abi:t,args:e,functionName:r,data:n}){let i=t[0];if(r&&(i=z1({abi:t,args:e,name:r}),!i))throw new yy(r,{docsPath:j2});if(i.type!=="function")throw new yy(void 0,{docsPath:j2});if(!i.outputs)throw new kfe(i.name,{docsPath:j2});const s=bb(i.outputs,n);if(s&&s.length>1)return s;if(s&&s.length===1)return s[0]}const Bde="modulepreload",jde=function(t,e){return new URL(t,e).href},uT={},HS=function(e,r,n){if(!r||r.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(r.map(s=>{if(s=jde(s,n),s in uT)return;uT[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!n)for(let u=i.length-1;u>=0;u--){const f=i[u];if(f.href===s&&(!o||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const l=document.createElement("link");if(l.rel=o?"stylesheet":Bde,o||(l.as="script",l.crossOrigin=""),l.href=s,document.head.appendChild(l),o)return new Promise((u,f)=>{l.addEventListener("load",u),l.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})},NC=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],TF=[{inputs:[],name:"ResolverNotFound",type:"error"},{inputs:[],name:"ResolverWildcardNotSupported",type:"error"}],IF=[...TF,{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],Ude=[...TF,{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]}],fT=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],dT=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],zde=[{inputs:[{internalType:"address",name:"_signer",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"}],Wde="0x82ad56cb";function Hde(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new AF(n,{docsPath:e,...r})}const U2=new Map;function qS({fn:t,id:e,shouldSplitBatch:r,wait:n=0}){const i=async()=>{const l=a();s();const u=l.map(({args:f})=>f);u.length!==0&&t(u).then(f=>{l.forEach(({pendingPromise:d},h)=>{var p;return(p=d.resolve)==null?void 0:p.call(d,[f[h],f])})}).catch(f=>{l.forEach(({pendingPromise:d})=>{var h;return(h=d.reject)==null?void 0:h.call(d,f)})})},s=()=>U2.delete(e),o=()=>a().map(({args:l})=>l),a=()=>U2.get(e)||[],c=l=>U2.set(e,[...a(),l]);return{flush:s,async schedule(l){const u={},f=new Promise((p,v)=>{u.resolve=p,u.reject=v});return(r==null?void 0:r([...o(),l]))&&i(),a().length>0?(c({args:l,pendingPromise:u}),f):(c({args:l,pendingPromise:u}),setTimeout(i,n),f)}}}async function Eb(t,e){var y,m,g,S;const{account:r=t.account,batch:n=!!((y=t.batch)!=null&&y.multicall),blockNumber:i,blockTag:s="latest",accessList:o,data:a,gas:c,gasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:f,nonce:d,to:h,value:p,...v}=e,b=r?Yi(r):void 0;try{H1(e);const T=(i?Ue(i):void 0)||s,w=((S=(g=(m=t.chain)==null?void 0:m.formatters)==null?void 0:g.transactionRequest)==null?void 0:S.format)||hb,I=w({...jS(v,{format:w}),from:b==null?void 0:b.address,accessList:o,data:a,gas:c,gasPrice:l,maxFeePerGas:u,maxPriorityFeePerGas:f,nonce:d,to:h,value:p});if(n&&qde({request:I}))try{return await Vde(t,{...I,blockNumber:i,blockTag:s})}catch(j){if(!(j instanceof ZL)&&!(j instanceof xC))throw j}const F=await t.request({method:"eth_call",params:T?[I,T]:[I]});return F==="0x"?{data:void 0}:{data:F}}catch(P){const T=Gde(P),{offchainLookup:w,offchainLookupSignature:I}=await HS(()=>import("./ccip-288a0685.js"),[],import.meta.url);if((T==null?void 0:T.slice(0,10))===I&&h)return{data:await w(t,{data:T,to:h})};throw Hde(P,{...e,account:b,chain:t.chain})}}function qde({request:t}){const{data:e,to:r,...n}=t;return!(!e||e.startsWith(Wde)||!r||Object.values(n).filter(i=>typeof i<"u").length>0)}async function Vde(t,e){var v;const{batchSize:r=1024,wait:n=0}=typeof((v=t.batch)==null?void 0:v.multicall)=="object"?t.batch.multicall:{},{blockNumber:i,blockTag:s="latest",data:o,multicallAddress:a,to:c}=e;let l=a;if(!l){if(!t.chain)throw new ZL;l=gd({blockNumber:i,chain:t.chain,contract:"multicall3"})}const f=(i?Ue(i):void 0)||s,{schedule:d}=qS({id:`${t.uid}.${f}`,wait:n,shouldSplitBatch(b){return b.reduce((m,{data:g})=>m+(g.length-2),0)>r*2},fn:async b=>{const y=b.map(S=>({allowFailure:!0,callData:S.data,target:S.to})),m=Dc({abi:NC,args:[y],functionName:"aggregate3"}),g=await t.request({method:"eth_call",params:[{data:m,to:l},f]});return Cd({abi:NC,args:[y],functionName:"aggregate3",data:g||"0x"})}}),[{returnData:h,success:p}]=await d({data:o,to:c});if(!p)throw new LS({data:h});return h==="0x"?{data:void 0}:{data:h}}function Gde(t){if(!(t instanceof le))return;const e=t.walk();return typeof e.data=="object"?e.data.data:e.data}async function gc(t,{abi:e,address:r,args:n,functionName:i,...s}){const o=Dc({abi:e,args:n,functionName:i});try{const{data:a}=await Eb(t,{data:o,to:r,...s});return Cd({abi:e,args:n,functionName:i,data:a||"0x"})}catch(a){throw t1(a,{abi:e,address:r,args:n,docsPath:"/docs/contract/readContract",functionName:i})}}async function Kde(t,{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}){const a=o.account?Yi(o.account):void 0,c=Dc({abi:e,args:n,functionName:s});try{const{data:l}=await Eb(t,{batch:!1,data:`${c}${i?i.replace("0x",""):""}`,to:r,...o});return{result:Cd({abi:e,args:n,functionName:s,data:l||"0x"}),request:{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}}}catch(l){throw t1(l,{abi:e,address:r,args:n,docsPath:"/docs/contract/simulateContract",functionName:s,sender:a==null?void 0:a.address})}}const z2=new Map,hT=new Map;let Qde=0;function Sd(t,e,r){const n=++Qde,i=()=>z2.get(t)||[],s=()=>{const u=i();z2.set(t,u.filter(f=>f.id!==n))},o=()=>{const u=hT.get(t);i().length===1&&u&&u(),s()},a=i();if(z2.set(t,[...a,{id:n,fns:e}]),a&&a.length>0)return o;const c={};for(const u in e)c[u]=(...f)=>{const d=i();d.length!==0&&d.forEach(h=>{var p,v;return(v=(p=h.fns)[u])==null?void 0:v.call(p,...f)})};const l=r(c);return typeof l=="function"&&hT.set(t,l),o}async function by(t){return new Promise(e=>setTimeout(e,t))}function q1(t,{emitOnBegin:e,initialWaitTime:r,interval:n}){let i=!0;const s=()=>i=!1;return(async()=>{let a;e&&(a=await t({unpoll:s}));const c=await(r==null?void 0:r(a))??n;await by(c);const l=async()=>{i&&(await t({unpoll:s}),await by(n),l())};l()})(),s}const pT="/docs/contract/decodeEventLog";function V1({abi:t,data:e,strict:r,topics:n}){const i=r??!0,[s,...o]=n;if(!s)throw new Cfe({docsPath:pT});const a=t.find(p=>p.type==="event"&&s===RS(Nc(p)));if(!(a&&"name"in a)||a.type!=="event")throw new Sfe(s,{docsPath:pT});const{name:c,inputs:l}=a,u=l==null?void 0:l.some(p=>!("name"in p&&p.name));let f=u?[]:{};const d=l.filter(p=>"indexed"in p&&p.indexed);if(o.length>0)for(let p=0;p!("indexed"in p&&p.indexed));if(h.length>0){if(e&&e!=="0x")try{const p=bb(h,e);if(p)if(u)f=[...f,...p];else for(let v=0;v0?f:void 0}}function Yde({param:t,value:e}){return t.type==="string"||t.type==="bytes"||t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/)?e:(bb([t],e)||[])[0]}const Jde=new Map,Xde=new Map;function Zde(t){const e=(i,s)=>({clear:()=>s.delete(i),get:()=>s.get(i),set:o=>s.set(i,o)}),r=e(t,Jde),n=e(t,Xde);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function ehe(t,{cacheKey:e,cacheTime:r=1/0}){const n=Zde(e),i=n.response.get();if(i&&r>0&&new Date().getTime()-i.created.getTime()`blockNumber.${t}`;async function G1(t,{cacheTime:e=t.cacheTime,maxAge:r}={}){const n=await ehe(()=>t.request({method:"eth_blockNumber"}),{cacheKey:the(t.uid),cacheTime:r??e});return BigInt(n)}async function xb(t,{filter:e}){const r="strict"in e&&e.strict;return(await e.request({method:"eth_getFilterChanges",params:[e.id]})).map(i=>{var s;if(typeof i=="string")return i;try{const{eventName:o,args:a}="abi"in e&&e.abi?V1({abi:e.abi,data:i.data,topics:i.topics,strict:r}):{eventName:void 0,args:void 0};return ks(i,{args:a,eventName:o})}catch(o){let a,c;if(o instanceof zl||o instanceof wd){if("strict"in e&&e.strict)return;a=o.abiItem.name,c=(s=o.abiItem.inputs)==null?void 0:s.some(l=>!("name"in l&&l.name))}return ks(i,{args:c?[]:{},eventName:a})}}).filter(Boolean)}async function VS(t,{address:e,blockHash:r,fromBlock:n,toBlock:i,event:s,events:o,args:a,strict:c}={}){const l=c??!1,u=o??(s?[s]:void 0);let f=[];u&&(f=[u.flatMap(h=>W1({abi:[h],eventName:h.name,args:a}))],s&&(f=f[0]));let d;return r?d=await t.request({method:"eth_getLogs",params:[{address:e,topics:f,blockHash:r}]}):d=await t.request({method:"eth_getLogs",params:[{address:e,topics:f,fromBlock:typeof n=="bigint"?Ue(n):n,toBlock:typeof i=="bigint"?Ue(i):i}]}),d.map(h=>{var p;try{const{eventName:v,args:b}=u?V1({abi:u,data:h.data,topics:h.topics,strict:l}):{eventName:void 0,args:void 0};return ks(h,{args:b,eventName:v})}catch(v){let b,y;if(v instanceof zl||v instanceof wd){if(l)return;b=v.abiItem.name,y=(p=v.abiItem.inputs)==null?void 0:p.some(m=>!("name"in m&&m.name))}return ks(h,{args:y?[]:{},eventName:b})}}).filter(Boolean)}async function Cb(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}function rhe(t,{abi:e,address:r,args:n,batch:i=!0,eventName:s,onError:o,onLogs:a,poll:c,pollingInterval:l=t.pollingInterval,strict:u}){return(typeof c<"u"?c:t.transport.type!=="webSocket")?(()=>{const p=Ln(["watchContractEvent",r,n,i,t.uid,s,l]),v=u??!1;return Sd(p,{onLogs:a,onError:o},b=>{let y,m,g=!1;const S=q1(async()=>{var P;if(!g){try{m=await CF(t,{abi:e,address:r,args:n,eventName:s,strict:v})}catch{}g=!0;return}try{let T;if(m)T=await xb(t,{filter:m});else{const w=await G1(t);y&&y!==w?T=await VS(t,{address:r,args:n,fromBlock:y+1n,toBlock:w,event:z1({abi:e,name:s})}):T=[],y=w}if(T.length===0)return;i?b.onLogs(T):T.forEach(w=>b.onLogs([w]))}catch(T){m&&T instanceof Wl&&(g=!1),(P=b.onError)==null||P.call(b,T)}},{emitOnBegin:!0,interval:l});return async()=>{m&&await Cb(t,{filter:m}),S()}})})():(()=>{let p=!0,v=()=>p=!1;return(async()=>{try{const b=s?W1({abi:e,eventName:s,args:n}):[],{unsubscribe:y}=await t.transport.subscribe({params:["logs",{address:r,topics:b}],onData(m){var S;if(!p)return;const g=m.result;try{const{eventName:P,args:T}=V1({abi:e,data:g.data,topics:g.topics,strict:u}),w=ks(g,{args:T,eventName:P});a([w])}catch(P){let T,w;if(P instanceof zl||P instanceof wd){if(u)return;T=P.abiItem.name,w=(S=P.abiItem.inputs)==null?void 0:S.some(F=>!("name"in F&&F.name))}const I=ks(g,{args:w?[]:{},eventName:T});a([I])}},onError(m){o==null||o(m)}});v=y,p||v()}catch(b){o==null||o(b)}})(),v})()}function nhe(t,{docsPath:e,...r}){let n=BS(t,r);return n instanceof pb&&(n=t),new ufe(n,{docsPath:e,...r})}async function r1(t){const e=await t.request({method:"eth_chainId"});return Nn(e)}async function GS(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]})}async function KS(t,e){var v,b,y;const{account:r=t.account,chain:n=t.chain,accessList:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d,...h}=e;if(!r)throw new xd({docsPath:"/docs/actions/wallet/sendTransaction"});const p=Yi(r);try{H1(e);let m;if(n!==null&&(m=await r1(t),eF({currentChainId:m,chain:n})),p.type==="local"){const P=await wb(t,{account:p,accessList:i,chain:n,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d,...h});m||(m=await r1(t));const T=(v=n==null?void 0:n.serializers)==null?void 0:v.transaction,w=await p.signTransaction({...P,chainId:m},{serializer:T});return await GS(t,{serializedTransaction:w})}const g=((y=(b=n==null?void 0:n.formatters)==null?void 0:b.transactionRequest)==null?void 0:y.format)||hb,S=g({...jS(h,{format:g}),accessList:i,data:s,from:p.address,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:f,value:d});return await t.request({method:"eth_sendTransaction",params:[S]})}catch(m){throw nhe(m,{...e,account:p,chain:e.chain||void 0})}}async function ihe(t,{abi:e,address:r,args:n,dataSuffix:i,functionName:s,...o}){const a=Dc({abi:e,args:n,functionName:s});return await KS(t,{data:`${a}${i?i.replace("0x",""):""}`,to:r,...o})}async function she(t,{chain:e}){const{id:r,name:n,nativeCurrency:i,rpcUrls:s,blockExplorers:o}=e;await t.request({method:"wallet_addEthereumChain",params:[{chainId:Ue(r),chainName:n,nativeCurrency:i,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:a})=>a):void 0}]})}const DC=256;let Zp=DC,ev;function ohe(t=11){if(!ev||Zp+t>DC*2){ev="",Zp=0;for(let e=0;e{const y=b(v);for(const g in h)delete y[g];const m={...v,...y};return Object.assign(m,{extend:p(m)})}}return Object.assign(h,{extend:p(h)})}function RF(t,{delay:e=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((i,s)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const u=typeof e=="function"?e({count:a,error:l}):e;u&&await by(u),o({count:a+1})};try{const l=await t();i(l)}catch(l){if(a"code"in t?t.code!==-1&&t.code!==-32004&&t.code!==-32005&&t.code!==-32042&&t.code!==-32603:t instanceof Wh&&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:!1;function ahe(t,{retryDelay:e=150,retryCount:r=3}={}){return async n=>RF(async()=>{try{return await t(n)}catch(i){const s=i;switch(s.code){case z0.code:throw new z0(s);case W0.code:throw new W0(s);case H0.code:throw new H0(s);case q0.code:throw new q0(s);case qf.code:throw new qf(s);case Wl.code:throw new Wl(s);case V0.code:throw new V0(s);case mc.code:throw new mc(s);case G0.code:throw new G0(s);case K0.code:throw new K0(s);case Q0.code:throw new Q0(s);case Y0.code:throw new Y0(s);case Pr.code:throw new Pr(s);case J0.code:throw new J0(s);case X0.code:throw new X0(s);case Z0.code:throw new Z0(s);case e1.code:throw new e1(s);case ea.code:throw new ea(s);case 5e3:throw new Pr(s);default:throw i instanceof le?i:new Tde(s)}}},{delay:({count:i,error:s})=>{var o;if(s&&s instanceof Wh){const a=(o=s==null?void 0:s.headers)==null?void 0:o.get("Retry-After");if(a!=null&&a.match(/\d/))return parseInt(a)*1e3}return~~(1<!$F(i)})}function Sb({key:t,name:e,request:r,retryCount:n=3,retryDelay:i=150,timeout:s,type:o},a){return{config:{key:t,name:e,request:r,retryCount:n,retryDelay:i,timeout:s,type:o},request:ahe(r,{retryCount:n,retryDelay:i}),value:a}}function kb(t,e={}){const{key:r="custom",name:n="Custom Provider",retryDelay:i}=e;return({retryCount:s})=>Sb({key:r,name:n,request:t.request.bind(t),retryCount:e.retryCount??s,retryDelay:i,type:"custom"})}function vT(t,e={}){const{key:r="fallback",name:n="Fallback",rank:i=!1,retryCount:s,retryDelay:o}=e;return({chain:a,pollingInterval:c=4e3,timeout:l})=>{let u=t,f=()=>{};const d=Sb({key:r,name:n,async request({method:h,params:p}){const v=async(b=0)=>{const y=u[b]({chain:a,retryCount:0,timeout:l});try{const m=await y.request({method:h,params:p});return f({method:h,params:p,response:m,transport:y,status:"success"}),m}catch(m){if(f({error:m,method:h,params:p,transport:y,status:"error"}),$F(m)||b===u.length-1)throw m;return v(b+1)}};return v()},retryCount:s,retryDelay:o,type:"fallback"},{onResponse:h=>f=h,transports:u.map(h=>h({chain:a,retryCount:0}))});if(i){const h=typeof i=="object"?i:{};che({chain:a,interval:h.interval??c,onTransports:p=>u=p,sampleCount:h.sampleCount,timeout:h.timeout,transports:u,weights:h.weights})}return d}}function che({chain:t,interval:e=4e3,onTransports:r,sampleCount:n=10,timeout:i=1e3,transports:s,weights:o={}}){const{stability:a=.7,latency:c=.3}=o,l=[],u=async()=>{const f=await Promise.all(s.map(async p=>{const v=p({chain:t,retryCount:0,timeout:i}),b=Date.now();let y,m;try{await v.request({method:"net_listening"}),m=1}catch{m=0}finally{y=Date.now()}return{latency:y-b,success:m}}));l.push(f),l.length>n&&l.shift();const d=Math.max(...l.map(p=>Math.max(...p.map(({latency:v})=>v)))),h=s.map((p,v)=>{const b=l.map(P=>P[v].latency),m=1-b.reduce((P,T)=>P+T,0)/b.length/d,g=l.map(P=>P[v].success),S=g.reduce((P,T)=>P+T,0)/g.length;return S===0?[0,v]:[c*m+a*S,v]}).sort((p,v)=>v[0]-p[0]);r(h.map(([,p])=>s[p])),await by(e),u()};u()}class MF extends le{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro"})}}var Ou=null;typeof WebSocket<"u"?Ou=WebSocket:typeof MozWebSocket<"u"?Ou=MozWebSocket:typeof global<"u"?Ou=global.WebSocket||global.MozWebSocket:typeof window<"u"?Ou=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(Ou=self.WebSocket||self.MozWebSocket);const mT=Ou;function NF(t,{errorInstance:e,timeout:r,signal:n}){return new Promise((i,s)=>{(async()=>{let o;try{const a=new AbortController;r>0&&(o=setTimeout(()=>{n?a.abort():s(e)},r)),i(await t({signal:a==null?void 0:a.signal}))}catch(a){a.name==="AbortError"&&s(e),s(a)}finally{clearTimeout(o)}})()})}let LC=0;async function lhe(t,{body:e,fetchOptions:r={},timeout:n=1e4}){var a;const{headers:i,method:s,signal:o}=r;try{const c=await NF(async({signal:u})=>await fetch(t,{...r,body:Array.isArray(e)?Ln(e.map(d=>({jsonrpc:"2.0",id:d.id??LC++,...d}))):Ln({jsonrpc:"2.0",id:e.id??LC++,...e}),headers:{...i,"Content-Type":"application/json"},method:s||"POST",signal:o||(n>0?u:void 0)}),{errorInstance:new $C({body:e,url:t}),timeout:n,signal:!0});let l;if((a=c.headers.get("Content-Type"))!=null&&a.startsWith("application/json")?l=await c.json():l=await c.text(),!c.ok)throw new Wh({body:e,details:Ln(l.error)||c.statusText,headers:c.headers,status:c.status,url:t});return l}catch(c){throw c instanceof Wh||c instanceof $C?c:new Wh({body:e,details:c.message,url:t})}}const W2=new Map;async function H2(t){let e=W2.get(t);if(e)return e;const{schedule:r}=qS({id:t,fn:async()=>{const s=new mT(t),o=new Map,a=new Map,c=({data:u})=>{const f=JSON.parse(u),d=f.method==="eth_subscription",h=d?f.params.subscription:f.id,p=d?a:o,v=p.get(h);v&&v({data:u}),d||p.delete(h)},l=()=>{W2.delete(t),s.removeEventListener("close",l),s.removeEventListener("message",c)};return s.addEventListener("close",l),s.addEventListener("message",c),s.readyState===mT.CONNECTING&&await new Promise((u,f)=>{s&&(s.onopen=u,s.onerror=f)}),e=Object.assign(s,{requests:o,subscriptions:a}),W2.set(t,e),[e]}}),[n,[i]]=await r();return i}function uhe(t,{body:e,onResponse:r}){if(t.readyState===t.CLOSED||t.readyState===t.CLOSING)throw new _de({body:e,url:t.url,details:"Socket is closed."});const n=LC++,i=({data:s})=>{var a;const o=JSON.parse(s);typeof o.id=="number"&&n!==o.id||(r==null||r(o),e.method==="eth_subscribe"&&typeof o.result=="string"&&t.subscriptions.set(o.result,i),e.method==="eth_unsubscribe"&&t.subscriptions.delete((a=e.params)==null?void 0:a[0]))};return t.requests.set(n,i),t.send(JSON.stringify({jsonrpc:"2.0",...e,id:n})),t}async function fhe(t,{body:e,timeout:r=1e4}){return NF(()=>new Promise(n=>gf.webSocket(t,{body:e,onResponse:n})),{errorInstance:new $C({body:e,url:t.url}),timeout:r})}const gf={http:lhe,webSocket:uhe,webSocketAsync:fhe};function DF(t,e={}){const{batch:r,fetchOptions:n,key:i="http",name:s="HTTP JSON-RPC",retryDelay:o}=e;return({chain:a,retryCount:c,timeout:l})=>{const{batchSize:u=1e3,wait:f=0}=typeof r=="object"?r:{},d=e.retryCount??c,h=l??e.timeout??1e4,p=t||(a==null?void 0:a.rpcUrls.default.http[0]);if(!p)throw new MF;return Sb({key:i,name:s,async request({method:v,params:b}){const y={method:v,params:b},{schedule:m}=qS({id:`${t}`,wait:f,shouldSplitBatch(T){return T.length>u},fn:T=>gf.http(p,{body:T,fetchOptions:n,timeout:h})}),g=async T=>r?m(T):[await gf.http(p,{body:T,fetchOptions:n,timeout:h})],[{error:S,result:P}]=await g(y);if(S)throw new FS({body:y,error:S,url:p});return P},retryCount:d,retryDelay:o,timeout:h,type:"http"},{url:t})}}function QS(t,e){var n,i,s;if(!(t instanceof le))return!1;const r=t.walk(o=>o instanceof RC);return r instanceof RC?!!(((n=r.data)==null?void 0:n.errorName)==="ResolverNotFound"||((i=r.data)==null?void 0:i.errorName)==="ResolverWildcardNotSupported"||(s=r.reason)!=null&&s.includes("Wildcard on non-extended resolvers is not supported")||e==="reverse"&&r.reason===SF[50]):!1}function LF(t){if(t.length!==66||t.indexOf("[")!==0||t.indexOf("]")!==65)return null;const e=`0x${t.slice(1,65)}`;return mo(e)?e:null}function zv(t){let e=new Uint8Array(32).fill(0);if(!t)return j0(e);const r=t.split(".");for(let n=r.length-1;n>=0;n-=1){const i=LF(r[n]),s=i?Ul(i):Yn(Fo(r[n]),"bytes");e=Yn(Zo([e,s]),"bytes")}return j0(e)}function dhe(t){return`[${t.slice(2)}]`}function hhe(t){const e=new Uint8Array(32).fill(0);return t?LF(t)||Yn(Fo(t)):j0(e)}function Ab(t){const e=t.replace(/^\.|\.$/gm,"");if(e.length===0)return new Uint8Array(1);const r=new Uint8Array(Fo(e).byteLength+2);let n=0;const i=e.split(".");for(let s=0;s255&&(o=Fo(dhe(hhe(i[s])))),r[n]=o.length,r.set(o,n+1),n+=o.length+1}return r.byteLength!==n+1?r.slice(0,n+1):r}async function phe(t,{blockNumber:e,blockTag:r,coinType:n,name:i,universalResolverAddress:s}){let o=s;if(!o){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");o=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}try{const a=Dc({abi:dT,functionName:"addr",...n!=null?{args:[zv(i),BigInt(n)]}:{args:[zv(i)]}}),c=await gc(t,{address:o,abi:IF,functionName:"resolve",args:[da(Ab(i)),a],blockNumber:e,blockTag:r});if(c[0]==="0x")return null;const l=Cd({abi:dT,args:n!=null?[zv(i),BigInt(n)]:void 0,functionName:"addr",data:c[0]});return l==="0x"||mf(l)==="0x00"?null:l}catch(a){if(QS(a,"resolve"))return null;throw a}}class vhe extends le{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarInvalidMetadataError"})}}class rh extends le{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarInvalidNftUriError"})}}class YS extends le{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarUriResolutionError"})}}class mhe extends le{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"EnsAvatarUnsupportedNamespaceError"})}}const yhe=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ghe=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,bhe=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,whe=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function Ehe(t){try{const e=await fetch(t,{method:"HEAD"});if(e.status===200){const r=e.headers.get("content-type");return r==null?void 0:r.startsWith("image/")}return!1}catch(e){return typeof e=="object"&&typeof e.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(r=>{const n=new Image;n.onload=()=>{r(!0)},n.onerror=()=>{r(!1)},n.src=t})}}function yT(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function FF({uri:t,gatewayUrls:e}){const r=bhe.test(t);if(r)return{uri:t,isOnChain:!0,isEncoded:r};const n=yT(e==null?void 0:e.ipfs,"https://ipfs.io"),i=yT(e==null?void 0:e.arweave,"https://arweave.net"),s=t.match(yhe),{protocol:o,subpath:a,target:c,subtarget:l=""}=(s==null?void 0:s.groups)||{},u=o==="ipns:/"||a==="ipns/",f=o==="ipfs:/"||a==="ipfs/"||ghe.test(t);if(t.startsWith("http")&&!u&&!f){let h=t;return e!=null&&e.arweave&&(h=t.replace(/https:\/\/arweave.net/g,e==null?void 0:e.arweave)),{uri:h,isOnChain:!1,isEncoded:!1}}if((u||f)&&c)return{uri:`${n}/${u?"ipns":"ipfs"}/${c}${l}`,isOnChain:!1,isEncoded:!1};if(o==="ar:/"&&c)return{uri:`${i}/${c}${l||""}`,isOnChain:!1,isEncoded:!1};let d=t.replace(whe,"");if(d.startsWith("i.json());return await JS({gatewayUrls:t,uri:BF(r)})}catch{throw new YS({uri:e})}}async function JS({gatewayUrls:t,uri:e}){const{uri:r,isOnChain:n}=FF({uri:e,gatewayUrls:t});if(n||await Ehe(r))return r;throw new YS({uri:e})}function Che(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[r,n,i]=e.split("/"),[s,o]=r.split(":"),[a,c]=n.split(":");if(!s||s.toLowerCase()!=="eip155")throw new rh({reason:"Only EIP-155 supported"});if(!o)throw new rh({reason:"Chain ID not found"});if(!c)throw new rh({reason:"Contract address not found"});if(!i)throw new rh({reason:"Token ID not found"});if(!a)throw new rh({reason:"ERC namespace not found"});return{chainID:parseInt(o),namespace:a.toLowerCase(),contractAddress:c,tokenID:i}}async function She(t,{nft:e}){if(e.namespace==="erc721")return gc(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if(e.namespace==="erc1155")return gc(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new mhe({namespace:e.namespace})}async function khe(t,{gatewayUrls:e,record:r}){return/eip155:/i.test(r)?Ahe(t,{gatewayUrls:e,record:r}):JS({uri:r,gatewayUrls:e})}async function Ahe(t,{gatewayUrls:e,record:r}){const n=Che(r),i=await She(t,{nft:n}),{uri:s,isOnChain:o,isEncoded:a}=FF({uri:i,gatewayUrls:e});if(o&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const l=a?atob(s.replace("data:application/json;base64,","")):s,u=JSON.parse(l);return JS({uri:BF(u),gatewayUrls:e})}let c=n.tokenID;return n.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),xhe({gatewayUrls:e,uri:s.replace(/(?:0x)?{id}/,c)})}async function jF(t,{blockNumber:e,blockTag:r,name:n,key:i,universalResolverAddress:s}){let o=s;if(!o){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");o=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}try{const a=await gc(t,{address:o,abi:IF,functionName:"resolve",args:[da(Ab(n)),Dc({abi:fT,functionName:"text",args:[zv(n),i]})],blockNumber:e,blockTag:r});if(a[0]==="0x")return null;const c=Cd({abi:fT,functionName:"text",data:a[0]});return c===""?null:c}catch(a){if(QS(a,"resolve"))return null;throw a}}async function _he(t,{blockNumber:e,blockTag:r,gatewayUrls:n,name:i,universalResolverAddress:s}){const o=await jF(t,{blockNumber:e,blockTag:r,key:"avatar",name:i,universalResolverAddress:s});if(!o)return null;try{return await khe(t,{record:o,gatewayUrls:n})}catch{return null}}async function Phe(t,{address:e,blockNumber:r,blockTag:n,universalResolverAddress:i}){let s=i;if(!s){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");s=gd({blockNumber:r,chain:t.chain,contract:"ensUniversalResolver"})}const o=`${e.toLowerCase().substring(2)}.addr.reverse`;try{return(await gc(t,{address:s,abi:Ude,functionName:"reverse",args:[da(Ab(o))],blockNumber:r,blockTag:n}))[0]}catch(a){if(QS(a,"reverse"))return null;throw a}}async function The(t,{blockNumber:e,blockTag:r,name:n,universalResolverAddress:i}){let s=i;if(!s){if(!t.chain)throw new Error("client chain not configured. universalResolverAddress is required.");s=gd({blockNumber:e,chain:t.chain,contract:"ensUniversalResolver"})}const[o]=await gc(t,{address:s,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[da(Ab(n))],blockNumber:e,blockTag:r});return o}async function Ihe(t){const e=gb(t,{method:"eth_newBlockFilter"}),r=await t.request({method:"eth_newBlockFilter"});return{id:r,request:e(r),type:"block"}}async function UF(t,{address:e,args:r,event:n,events:i,fromBlock:s,strict:o,toBlock:a}={}){const c=i??(n?[n]:void 0),l=gb(t,{method:"eth_newFilter"});let u=[];c&&(u=[c.flatMap(d=>W1({abi:[d],eventName:d.name,args:r}))],n&&(u=u[0]));const f=await t.request({method:"eth_newFilter",params:[{address:e,fromBlock:typeof s=="bigint"?Ue(s):s,toBlock:typeof a=="bigint"?Ue(a):a,...u.length?{topics:u}:{}}]});return{abi:c,args:r,eventName:n?n.name:void 0,fromBlock:s,id:f,request:l(f),strict:o,toBlock:a,type:"event"}}async function zF(t){const e=gb(t,{method:"eth_newPendingTransactionFilter"}),r=await t.request({method:"eth_newPendingTransactionFilter"});return{id:r,request:e(r),type:"transaction"}}async function Ohe(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=r?Ue(r):void 0,s=await t.request({method:"eth_getBalance",params:[e,i||n]});return BigInt(s)}async function Rhe(t,{blockHash:e,blockNumber:r,blockTag:n="latest"}={}){const i=r!==void 0?Ue(r):void 0;let s;return e?s=await t.request({method:"eth_getBlockTransactionCountByHash",params:[e]}):s=await t.request({method:"eth_getBlockTransactionCountByNumber",params:[i||n]}),Nn(s)}async function $he(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=r!==void 0?Ue(r):void 0,s=await t.request({method:"eth_getCode",params:[e,i||n]});if(s!=="0x")return s}function Mhe(t){var e;return{baseFeePerGas:t.baseFeePerGas.map(r=>BigInt(r)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:(e=t.reward)==null?void 0:e.map(r=>r.map(n=>BigInt(n)))}}async function Nhe(t,{blockCount:e,blockNumber:r,blockTag:n="latest",rewardPercentiles:i}){const s=r?Ue(r):void 0,o=await t.request({method:"eth_feeHistory",params:[Ue(e),s||n,i]});return Mhe(o)}async function Dhe(t,{filter:e}){const r=e.strict??!1;return(await e.request({method:"eth_getFilterLogs",params:[e.id]})).map(i=>{var s;try{const{eventName:o,args:a}="abi"in e&&e.abi?V1({abi:e.abi,data:i.data,topics:i.topics,strict:r}):{eventName:void 0,args:void 0};return ks(i,{args:a,eventName:o})}catch(o){let a,c;if(o instanceof zl||o instanceof wd){if("strict"in e&&e.strict)return;a=o.abiItem.name,c=(s=o.abiItem.inputs)==null?void 0:s.some(l=>!("name"in l&&l.name))}return ks(i,{args:c?[]:{},eventName:a})}}).filter(Boolean)}async function Lhe(t,{address:e,blockNumber:r,blockTag:n="latest",slot:i}){const s=r!==void 0?Ue(r):void 0;return await t.request({method:"eth_getStorageAt",params:[e,i,s||n]})}async function XS(t,{blockHash:e,blockNumber:r,blockTag:n,hash:i,index:s}){var u,f,d;const o=n||"latest",a=r!==void 0?Ue(r):void 0;let c=null;if(i?c=await t.request({method:"eth_getTransactionByHash",params:[i]}):e?c=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[e,Ue(s)]}):(a||o)&&(c=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[a||o,Ue(s)]})),!c)throw new cF({blockHash:e,blockNumber:r,blockTag:o,hash:i,index:s});return(((d=(f=(u=t.chain)==null?void 0:u.formatters)==null?void 0:f.transaction)==null?void 0:d.format)||sF)(c)}async function Fhe(t,{hash:e,transactionReceipt:r}){const[n,i]=await Promise.all([G1(t),e?XS(t,{hash:e}):void 0]),s=(r==null?void 0:r.blockNumber)||(i==null?void 0:i.blockNumber);return s?n-s+1n:0n}async function FC(t,{hash:e}){var i,s,o;const r=await t.request({method:"eth_getTransactionReceipt",params:[e]});if(!r)throw new lF({hash:e});return(((o=(s=(i=t.chain)==null?void 0:i.formatters)==null?void 0:s.transactionReceipt)==null?void 0:o.format)||rfe)(r)}async function Bhe(t,e){var v;const{allowFailure:r=!0,batchSize:n,blockNumber:i,blockTag:s,contracts:o,multicallAddress:a}=e,c=n??(typeof((v=t.batch)==null?void 0:v.multicall)=="object"&&t.batch.multicall.batchSize||1024);let l=a;if(!l){if(!t.chain)throw new Error("client chain not configured. multicallAddress is required.");l=gd({blockNumber:i,chain:t.chain,contract:"multicall3"})}const u=[[]];let f=0,d=0;for(let b=0;b0&&d>c&&u[f].length>0&&(f++,d=(P.length-2)/2,u[f]=[]),u[f]=[...u[f],{allowFailure:!0,callData:P,target:m}]}catch(P){const T=t1(P,{abi:y,address:m,args:g,docsPath:"/docs/contract/multicall",functionName:S});if(!r)throw T;u[f]=[...u[f],{allowFailure:!0,callData:"0x",target:m}]}}const h=await Promise.allSettled(u.map(b=>gc(t,{abi:NC,address:l,args:[b],blockNumber:i,blockTag:s,functionName:"aggregate3"}))),p=[];for(let b=0;b"u"?{}:t,s={EIP712Domain:KF({domain:i}),...n};GF({domain:i,message:e,primaryType:r,types:s});const o=["0x1901"];return i&&o.push(Whe({domain:i,types:s})),r!=="EIP712Domain"&&o.push(WF({data:e,primaryType:r,types:s})),Yn(Zo(o))}function Whe({domain:t,types:e}){return WF({data:t,primaryType:"EIP712Domain",types:e})}function WF({data:t,primaryType:e,types:r}){const n=HF({data:t,primaryType:e,types:r});return Yn(n)}function HF({data:t,primaryType:e,types:r}){const n=[{type:"bytes32"}],i=[Hhe({primaryType:e,types:r})];for(const s of r[e]){const[o,a]=VF({types:r,name:s.name,type:s.type,value:t[s.name]});n.push(o),i.push(a)}return U1(n,i)}function Hhe({primaryType:t,types:e}){const r=da(qhe({primaryType:t,types:e}));return Yn(r)}function qhe({primaryType:t,types:e}){let r="";const n=qF({primaryType:t,types:e});n.delete(t);const i=[t,...Array.from(n).sort()];for(const s of i)r+=`${s}(${e[s].map(({name:o,type:a})=>`${a} ${o}`).join(",")})`;return r}function qF({primaryType:t,types:e},r=new Set){const n=t.match(/^\w*/u),i=n==null?void 0:n[0];if(r.has(i)||e[i]===void 0)return r;r.add(i);for(const s of e[i])qF({primaryType:s.type,types:e},r);return r}function VF({types:t,name:e,type:r,value:n}){if(t[r]!==void 0)return[{type:"bytes32"},Yn(HF({data:n,primaryType:r,types:t}))];if(r==="bytes")return n=`0x${(n.length%2?"0":"")+n.slice(2)}`,[{type:"bytes32"},Yn(n)];if(r==="string")return[{type:"bytes32"},Yn(da(n))];if(r.lastIndexOf("]")===r.length-1){const i=r.slice(0,r.lastIndexOf("[")),s=n.map(o=>VF({name:e,type:i,types:t,value:o}));return[{type:"bytes32"},Yn(U1(s.map(([o])=>o),s.map(([,o])=>o)))]}return[{type:r},n]}function GF({domain:t,message:e,primaryType:r,types:n}){const i=n,s=(o,a)=>{for(const c of o){const{name:l,type:u}=c,f=u,d=a[l],h=f.match(Uhe);if(h&&(typeof d=="number"||typeof d=="bigint")){const[b,y,m]=h;Ue(d,{signed:y==="int",size:parseInt(m)/8})}if(f==="address"&&typeof d=="string"&&!Hf(d))throw new U0({address:d});const p=f.match(jhe);if(p){const[b,y]=p;if(y&&Br(d)!==parseInt(y))throw new Afe({expectedSize:parseInt(y),givenSize:Br(d)})}const v=i[f];v&&s(v,d)}};if(i.EIP712Domain&&t&&s(i.EIP712Domain,t),r!=="EIP712Domain"){const o=i[r];s(o,e)}}function KF({domain:t}){return[typeof(t==null?void 0:t.name)=="string"&&{name:"name",type:"string"},(t==null?void 0:t.version)&&{name:"version",type:"string"},typeof(t==null?void 0:t.chainId)=="number"&&{name:"chainId",type:"uint256"},(t==null?void 0:t.verifyingContract)&&{name:"verifyingContract",type:"address"},(t==null?void 0:t.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}const q2="/docs/contract/encodeDeployData";function QF({abi:t,args:e,bytecode:r}){if(!e||e.length===0)return r;const n=t.find(s=>"type"in s&&s.type==="constructor");if(!n)throw new bfe({docsPath:q2});if(!("inputs"in n))throw new rT({docsPath:q2});if(!n.inputs||n.inputs.length===0)throw new rT({docsPath:q2});const i=U1(n.inputs,e);return _S([r,i])}function Vhe(t,e){const r=(()=>typeof t=="string"?Fo(t):t.raw instanceof Uint8Array?t.raw:Ul(t.raw))(),n=Fo(`Ethereum Signed Message: ${r.length}`);return Yn(Zo([n,r]),e)}const Ghe="0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);BigInt(1);BigInt(2);function Khe(t,e){if(t.length!==e.length)return!1;for(let r=0;r{const f=Ln(["watchBlockNumber",t.uid,e,r,o]);return Sd(f,{onBlockNumber:n,onError:i},d=>q1(async()=>{var h;try{const p=await G1(t,{cacheTime:0});if(c){if(p===c)return;if(p-c>1&&r)for(let v=c+1n;vc)&&(d.onBlockNumber(p,c),c=p)}catch(p){(h=d.onError)==null||h.call(d,p)}},{emitOnBegin:e,interval:o}))})():(()=>{let f=!0,d=()=>f=!1;return(async()=>{try{const{unsubscribe:h}=await t.transport.subscribe({params:["newHeads"],onData(p){var b;if(!f)return;const v=db((b=p.result)==null?void 0:b.number);n(v,c),c=v},onError(p){i==null||i(p)}});d=h,f||d()}catch(h){i==null||i(h)}})(),d})()}async function Xhe(t,{confirmations:e=1,hash:r,onReplaced:n,pollingInterval:i=t.pollingInterval,timeout:s}){const o=Ln(["waitForTransactionReceipt",t.uid,r]);let a,c,l,u=!1;return new Promise((f,d)=>{s&&setTimeout(()=>d(new ffe({hash:r})),s);const h=Sd(o,{onReplaced:n,resolve:f,reject:d},p=>{const v=JF(t,{emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:i,async onBlockNumber(b){if(u)return;let y=b;const m=g=>{v(),g(),h()};try{if(l){if(y-l.blockNumber+1np.resolve(l));return}if(a||(u=!0,await RF(async()=>{a=await XS(t,{hash:r}),a.blockNumber&&(y=a.blockNumber)},{delay:({count:g})=>~~(1<0&&y-l.blockNumber+1np.resolve(l))}catch(g){if(a&&(g instanceof cF||g instanceof lF))try{c=a;const P=(await yc(t,{blockNumber:y,includeTransactions:!0})).transactions.find(({from:w,nonce:I})=>w===c.from&&I===c.nonce);if(!P||(l=await FC(t,{hash:P.hash}),y-l.blockNumber+1n{var w;(w=p.onReplaced)==null||w.call(p,{reason:T,replacedTransaction:c,transaction:P,transactionReceipt:l}),p.resolve(l)})}catch(S){m(()=>p.reject(S))}else m(()=>p.reject(g))}}})})})}function Zhe(t,{blockTag:e="latest",emitMissed:r=!1,emitOnBegin:n=!1,onBlock:i,onError:s,includeTransactions:o,poll:a,pollingInterval:c=t.pollingInterval}){const l=typeof a<"u"?a:t.transport.type!=="webSocket",u=o??!1;let f;return l?(()=>{const p=Ln(["watchBlocks",t.uid,r,n,u,c]);return Sd(p,{onBlock:i,onError:s},v=>q1(async()=>{var b;try{const y=await yc(t,{blockTag:e,includeTransactions:u});if(y.number&&(f!=null&&f.number)){if(y.number===f.number)return;if(y.number-f.number>1&&r)for(let m=(f==null?void 0:f.number)+1n;mf.number)&&(v.onBlock(y,f),f=y)}catch(y){(b=v.onError)==null||b.call(v,y)}},{emitOnBegin:n,interval:c}))})():(()=>{let p=!0,v=()=>p=!1;return(async()=>{try{const{unsubscribe:b}=await t.transport.subscribe({params:["newHeads"],onData(y){var S,P,T;if(!p)return;const g=(((T=(P=(S=t.chain)==null?void 0:S.formatters)==null?void 0:P.block)==null?void 0:T.format)||oF)(y.result);i(g,f),f=g},onError(y){s==null||s(y)}});v=b,p||v()}catch(b){s==null||s(b)}})(),v})()}function e0e(t,{address:e,args:r,batch:n=!0,event:i,events:s,onError:o,onLogs:a,poll:c,pollingInterval:l=t.pollingInterval,strict:u}){const f=typeof c<"u"?c:t.transport.type!=="webSocket",d=u??!1;return f?(()=>{const v=Ln(["watchEvent",e,r,n,t.uid,i,l]);return Sd(v,{onLogs:a,onError:o},b=>{let y,m,g=!1;const S=q1(async()=>{var P;if(!g){try{m=await UF(t,{address:e,args:r,event:i,events:s,strict:d})}catch{}g=!0;return}try{let T;if(m)T=await xb(t,{filter:m});else{const w=await G1(t);y&&y!==w?T=await VS(t,{address:e,args:r,event:i,events:s,fromBlock:y+1n,toBlock:w}):T=[],y=w}if(T.length===0)return;n?b.onLogs(T):T.forEach(w=>b.onLogs([w]))}catch(T){m&&T instanceof Wl&&(g=!1),(P=b.onError)==null||P.call(b,T)}},{emitOnBegin:!0,interval:l});return async()=>{m&&await Cb(t,{filter:m}),S()}})})():(()=>{let v=!0,b=()=>v=!1;return(async()=>{try{const y=s??(i?[i]:void 0);let m=[];y&&(m=[y.flatMap(S=>W1({abi:[S],eventName:S.name,args:r}))],i&&(m=m[0]));const{unsubscribe:g}=await t.transport.subscribe({params:["logs",{address:e,topics:m}],onData(S){var T;if(!v)return;const P=S.result;try{const{eventName:w,args:I}=V1({abi:y,data:P.data,topics:P.topics,strict:d}),F=ks(P,{args:I,eventName:w});a([F])}catch(w){let I,F;if(w instanceof zl||w instanceof wd){if(u)return;I=w.abiItem.name,F=(T=w.abiItem.inputs)==null?void 0:T.some(H=>!("name"in H&&H.name))}const j=ks(P,{args:F?[]:{},eventName:I});a([j])}},onError(S){o==null||o(S)}});b=g,v||b()}catch(y){o==null||o(y)}})(),b})()}function t0e(t,{batch:e=!0,onError:r,onTransactions:n,poll:i,pollingInterval:s=t.pollingInterval}){return(typeof i<"u"?i:t.transport.type!=="webSocket")?(()=>{const l=Ln(["watchPendingTransactions",t.uid,e,s]);return Sd(l,{onTransactions:n,onError:r},u=>{let f;const d=q1(async()=>{var h;try{if(!f)try{f=await zF(t);return}catch(v){throw d(),v}const p=await xb(t,{filter:f});if(p.length===0)return;e?u.onTransactions(p):p.forEach(v=>u.onTransactions([v]))}catch(p){(h=u.onError)==null||h.call(u,p)}},{emitOnBegin:!0,interval:s});return async()=>{f&&await Cb(t,{filter:f}),d()}})})():(()=>{let l=!0,u=()=>l=!1;return(async()=>{try{const{unsubscribe:f}=await t.transport.subscribe({params:["newPendingTransactions"],onData(d){if(!l)return;const h=d.result;n([h])},onError(d){r==null||r(d)}});u=f,l||u()}catch(f){r==null||r(f)}})(),u})()}function r0e(t){return{call:e=>Eb(t,e),createBlockFilter:()=>Ihe(t),createContractEventFilter:e=>CF(t,e),createEventFilter:e=>UF(t,e),createPendingTransactionFilter:()=>zF(t),estimateContractGas:e=>Fde(t,e),estimateGas:e=>WS(t,e),getBalance:e=>Ohe(t,e),getBlock:e=>yc(t,e),getBlockNumber:e=>G1(t,e),getBlockTransactionCount:e=>Rhe(t,e),getBytecode:e=>$he(t,e),getChainId:()=>r1(t),getEnsAddress:e=>phe(t,e),getEnsAvatar:e=>_he(t,e),getEnsName:e=>Phe(t,e),getEnsResolver:e=>The(t,e),getEnsText:e=>jF(t,e),getFeeHistory:e=>Nhe(t,e),estimateFeesPerGas:e=>Lde(t,e),getFilterChanges:e=>xb(t,e),getFilterLogs:e=>Dhe(t,e),getGasPrice:()=>zS(t),getLogs:e=>VS(t,e),estimateMaxPriorityFeePerGas:e=>Dde(t,e),getStorageAt:e=>Lhe(t,e),getTransaction:e=>XS(t,e),getTransactionConfirmations:e=>Fhe(t,e),getTransactionCount:e=>PF(t,e),getTransactionReceipt:e=>FC(t,e),multicall:e=>Bhe(t,e),prepareTransactionRequest:e=>wb(t,e),readContract:e=>gc(t,e),sendRawTransaction:e=>GS(t,e),simulateContract:e=>Kde(t,e),verifyMessage:e=>Yhe(t,e),verifyTypedData:e=>Jhe(t,e),uninstallFilter:e=>Cb(t,e),waitForTransactionReceipt:e=>Xhe(t,e),watchBlocks:e=>Zhe(t,e),watchBlockNumber:e=>JF(t,e),watchContractEvent:e=>rhe(t,e),watchEvent:e=>e0e(t,e),watchPendingTransactions:e=>t0e(t,e)}}function gT(t){const{key:e="public",name:r="Public Client"}=t;return OF({...t,key:e,name:r,type:"publicClient"}).extend(r0e)}function n0e(t,{abi:e,args:r,bytecode:n,...i}){const s=QF({abi:e,args:r,bytecode:n});return KS(t,{...i,data:s})}async function i0e(t){return(await t.request({method:"eth_accounts"})).map(r=>DS(r))}async function s0e(t){return await t.request({method:"wallet_getPermissions"})}async function o0e(t){return(await t.request({method:"eth_requestAccounts"})).map(r=>Dn(r))}async function a0e(t,e){return t.request({method:"wallet_requestPermissions",params:[e]})}async function c0e(t,{account:e=t.account,message:r}){if(!e)throw new xd({docsPath:"/docs/actions/wallet/signMessage"});const n=Yi(e);if(n.type==="local")return n.signMessage({message:r});const i=(()=>typeof r=="string"?kS(r):r.raw instanceof Uint8Array?da(r.raw):r.raw)();return t.request({method:"personal_sign",params:[i,n.address]})}async function l0e(t,e){var l,u,f,d;const{account:r=t.account,chain:n=t.chain,...i}=e;if(!r)throw new xd({docsPath:"/docs/actions/wallet/signTransaction"});const s=Yi(r);H1({account:s,...e});const o=await r1(t);n!==null&&eF({currentChainId:o,chain:n});const a=(n==null?void 0:n.formatters)||((l=t.chain)==null?void 0:l.formatters),c=((u=a==null?void 0:a.transactionRequest)==null?void 0:u.format)||hb;return s.type==="local"?s.signTransaction({chainId:o,...i},{serializer:(d=(f=t.chain)==null?void 0:f.serializers)==null?void 0:d.transaction}):await t.request({method:"eth_signTransaction",params:[{...c(i),chainId:Ue(o),from:s.address}]})}async function u0e(t,{account:e=t.account,domain:r,message:n,primaryType:i,types:s}){if(!e)throw new xd({docsPath:"/docs/actions/wallet/signTypedData"});const o=Yi(e),a={EIP712Domain:KF({domain:r}),...s};if(GF({domain:r,message:n,primaryType:i,types:a}),o.type==="local")return o.signTypedData({domain:r,primaryType:i,types:a,message:n});const c=Ln({domain:r??{},primaryType:i,types:a,message:n},(l,u)=>mo(u)?u.toLowerCase():u);return t.request({method:"eth_signTypedData_v4",params:[o.address,c]})}async function f0e(t,{id:e}){await t.request({method:"wallet_switchEthereumChain",params:[{chainId:Ue(e)}]})}async function d0e(t,e){return await t.request({method:"wallet_watchAsset",params:e})}function h0e(t){return{addChain:e=>she(t,e),deployContract:e=>n0e(t,e),getAddresses:()=>i0e(t),getChainId:()=>r1(t),getPermissions:()=>s0e(t),prepareTransactionRequest:e=>wb(t,e),requestAddresses:()=>o0e(t),requestPermissions:e=>a0e(t,e),sendRawTransaction:e=>GS(t,e),sendTransaction:e=>KS(t,e),signMessage:e=>c0e(t,e),signTransaction:e=>l0e(t,e),signTypedData:e=>u0e(t,e),switchChain:e=>f0e(t,e),watchAsset:e=>d0e(t,e),writeContract:e=>ihe(t,e)}}function K1(t){const{key:e="wallet",name:r="Wallet Client",transport:n}=t;return OF({...t,key:e,name:r,transport:s=>n({...s,retryCount:0}),type:"walletClient"}).extend(h0e)}function p0e(t,e={}){const{key:r="webSocket",name:n="WebSocket JSON-RPC",retryDelay:i}=e;return({chain:s,retryCount:o,timeout:a})=>{var f;const c=e.retryCount??o,l=a??e.timeout??1e4,u=t||((f=s==null?void 0:s.rpcUrls.default.webSocket)==null?void 0:f[0]);if(!u)throw new MF;return Sb({key:r,name:n,async request({method:d,params:h}){const p={method:d,params:h},v=await H2(u),{error:b,result:y}=await gf.webSocketAsync(v,{body:p,timeout:l});if(b)throw new FS({body:p,error:b,url:u});return y},retryCount:c,retryDelay:i,timeout:l,type:"webSocket"},{getSocket(){return H2(u)},async subscribe({params:d,onData:h,onError:p}){const v=await H2(u),{result:b}=await new Promise((y,m)=>gf.webSocket(v,{body:{method:"eth_subscribe",params:d},onResponse(g){if(g.error){m(g.error),p==null||p(g.error);return}if(typeof g.id=="number"){y(g);return}g.method==="eth_subscription"&&h(g.params)}}));return{subscriptionId:b,async unsubscribe(){return new Promise(y=>gf.webSocket(v,{body:{method:"eth_unsubscribe",params:[b]},onResponse:y}))}}}})}}function v0e(t){var r;if(!t)return"Injected";const e=n=>{if(n.isApexWallet)return"Apex Wallet";if(n.isAvalanche)return"Core Wallet";if(n.isBackpack)return"Backpack";if(n.isBifrost)return"Bifrost Wallet";if(n.isBitKeep)return"BitKeep";if(n.isBitski)return"Bitski";if(n.isBlockWallet)return"BlockWallet";if(n.isBraveWallet)return"Brave Wallet";if(n.isCoinbaseWallet)return"Coinbase Wallet";if(n.isDawn)return"Dawn Wallet";if(n.isDefiant)return"Defiant";if(n.isEnkrypt)return"Enkrypt";if(n.isExodus)return"Exodus";if(n.isFrame)return"Frame";if(n.isFrontier)return"Frontier Wallet";if(n.isGamestop)return"GameStop Wallet";if(n.isHaqqWallet)return"HAQQ Wallet";if(n.isHyperPay)return"HyperPay Wallet";if(n.isImToken)return"ImToken";if(n.isHaloWallet)return"Halo Wallet";if(n.isKuCoinWallet)return"KuCoin Wallet";if(n.isMathWallet)return"MathWallet";if(n.isNovaWallet)return"Nova Wallet";if(n.isOkxWallet||n.isOKExWallet)return"OKX Wallet";if(n.isOneInchIOSWallet||n.isOneInchAndroidWallet)return"1inch Wallet";if(n.isOpera)return"Opera";if(n.isPhantom)return"Phantom";if(n.isPortal)return"Ripio Portal";if(n.isRabby)return"Rabby Wallet";if(n.isRainbow)return"Rainbow";if(n.isStatus)return"Status";if(n.isTalisman)return"Talisman";if(n.isTally)return"Taho";if(n.isTokenPocket)return"TokenPocket";if(n.isTokenary)return"Tokenary";if(n.isTrust||n.isTrustWallet)return"Trust Wallet";if(n.isTTWallet)return"TTWallet";if(n.isXDEFI)return"XDEFI Wallet";if(n.isZerion)return"Zerion";if(n.isMetaMask)return"MetaMask"};if((r=t.providers)!=null&&r.length){const n=new Set;let i=1;for(const o of t.providers){let a=e(o);a||(a=`Unknown Wallet #${i}`,i+=1),n.add(a)}const s=[...n];return s.length?s:s[0]??"Injected"}return e(t)??"Injected"}var Wv,XF=class extends j1{constructor({chains:t,options:e}={}){const r={shimDisconnect:!0,getProvider(){if(typeof window>"u")return;const i=window.ethereum;return i!=null&&i.providers?i.providers[0]:i},...e};super({chains:t,options:r}),Ke(this,"id","injected"),Ke(this,"name"),Ke(this,"ready"),Mr(this,Wv,void 0),Ke(this,"shimDisconnectKey",`${this.id}.shimDisconnect`),Ke(this,"onAccountsChanged",i=>{i.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(i[0])})}),Ke(this,"onChainChanged",i=>{const s=El(i),o=this.isChainUnsupported(s);this.emit("change",{chain:{id:s,unsupported:o}})}),Ke(this,"onDisconnect",async i=>{var s;i.code===1013&&await this.getProvider()&&await this.getAccount()||(this.emit("disconnect"),this.options.shimDisconnect&&((s=this.storage)==null||s.removeItem(this.shimDisconnectKey)))});const n=r.getProvider();if(typeof r.name=="string")this.name=r.name;else if(n){const i=v0e(n);r.name?this.name=r.name(i):typeof i=="string"?this.name=i:this.name=i[0]}else this.name="Injected";this.ready=!!n}async connect({chainId:t}={}){var e;try{const r=await this.getProvider();if(!r)throw new Ma;r.on&&(r.on("accountsChanged",this.onAccountsChanged),r.on("chainChanged",this.onChainChanged),r.on("disconnect",this.onDisconnect)),this.emit("message",{type:"connecting"});const n=await r.request({method:"eth_requestAccounts"}),i=Dn(n[0]);let s=await this.getChainId(),o=this.isChainUnsupported(s);return t&&s!==t&&(s=(await this.switchChain(t)).id,o=this.isChainUnsupported(s)),this.options.shimDisconnect&&((e=this.storage)==null||e.setItem(this.shimDisconnectKey,!0)),{account:i,chain:{id:s,unsupported:o}}}catch(r){throw this.isUserRejectedRequestError(r)?new Pr(r):r.code===-32002?new mc(r):r}}async disconnect(){var e;const t=await this.getProvider();t!=null&&t.removeListener&&(t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect),this.options.shimDisconnect&&((e=this.storage)==null||e.removeItem(this.shimDisconnectKey)))}async getAccount(){const t=await this.getProvider();if(!t)throw new Ma;const e=await t.request({method:"eth_accounts"});return Dn(e[0])}async getChainId(){const t=await this.getProvider();if(!t)throw new Ma;return t.request({method:"eth_chainId"}).then(El)}async getProvider(){const t=this.options.getProvider();return t&&ys(this,Wv,t),We(this,Wv)}async getWalletClient({chainId:t}={}){const[e,r]=await Promise.all([this.getProvider(),this.getAccount()]),n=this.chains.find(i=>i.id===t);if(!e)throw new Error("provider is required.");return K1({account:r,chain:n,transport:kb(e)})}async isAuthorized(){var t;try{if(this.options.shimDisconnect&&!((t=this.storage)!=null&&t.getItem(this.shimDisconnectKey)))return!1;if(!await this.getProvider())throw new Ma;return!!await this.getAccount()}catch{return!1}}async switchChain(t){var n,i,s;const e=await this.getProvider();if(!e)throw new Ma;const r=Ue(t);try{return await Promise.all([e.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]}),new Promise(o=>this.on("change",({chain:a})=>{(a==null?void 0:a.id)===t&&o()}))]),this.chains.find(o=>o.id===t)??{id:t,name:`Chain ${r}`,network:`${r}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}}}catch(o){const a=this.chains.find(c=>c.id===t);if(!a)throw new uF({chainId:t,connectorId:this.id});if(o.code===4902||((i=(n=o==null?void 0:o.data)==null?void 0:n.originalError)==null?void 0:i.code)===4902)try{if(await e.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:a.name,nativeCurrency:a.nativeCurrency,rpcUrls:[((s=a.rpcUrls.public)==null?void 0:s.http[0])??""],blockExplorerUrls:this.getBlockExplorerUrls(a)}]}),await this.getChainId()!==t)throw new Pr(new Error("User rejected switch after adding network."));return a}catch(c){throw new Pr(c)}throw this.isUserRejectedRequestError(o)?new Pr(o):new ea(o)}}async watchAsset({address:t,decimals:e=18,image:r,symbol:n}){const i=await this.getProvider();if(!i)throw new Ma;return i.request({method:"wallet_watchAsset",params:{type:"ERC20",options:{address:t,decimals:e,image:r,symbol:n}}})}isUserRejectedRequestError(t){return t.code===4001}};Wv=new WeakMap;var ZS=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},V2=(t,e,r)=>(ZS(t,e,"read from private field"),r?r.call(t):e.get(t)),G2=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},tv=(t,e,r,n)=>(ZS(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),m0e=(t,e,r)=>(ZS(t,e,"access private method"),r);const y0e=t=>(e,r,n)=>{const i=n.subscribe;return n.subscribe=(o,a,c)=>{let l=o;if(a){const u=(c==null?void 0:c.equalityFn)||Object.is;let f=o(n.getState());l=d=>{const h=o(d);if(!u(f,h)){const p=f;a(f=h,p)}},c!=null&&c.fireImmediately&&a(f,f)}return i(l)},t(e,r,n)},g0e=y0e;function b0e(t,e){let r;try{r=t()}catch{return}return{getItem:i=>{var s;const o=c=>c===null?null:JSON.parse(c,e==null?void 0:e.reviver),a=(s=r.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>r.setItem(i,JSON.stringify(s,e==null?void 0:e.replacer)),removeItem:i=>r.removeItem(i)}}const n1=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return n1(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return n1(n)(r)}}}},w0e=(t,e)=>(r,n,i)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,y)=>({...y,...b}),...e},o=!1;const a=new Set,c=new Set;let l;try{l=s.getStorage()}catch{}if(!l)return t((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...b)},n,i);const u=n1(s.serialize),f=()=>{const b=s.partialize({...n()});let y;const m=u({state:b,version:s.version}).then(g=>l.setItem(s.name,g)).catch(g=>{y=g});if(y)throw y;return m},d=i.setState;i.setState=(b,y)=>{d(b,y),f()};const h=t((...b)=>{r(...b),f()},n,i);let p;const v=()=>{var b;if(!l)return;o=!1,a.forEach(m=>m(n()));const y=((b=s.onRehydrateStorage)==null?void 0:b.call(s,n()))||void 0;return n1(l.getItem.bind(l))(s.name).then(m=>{if(m)return s.deserialize(m)}).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==s.version){if(s.migrate)return s.migrate(m.state,m.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return m.state}).then(m=>{var g;return p=s.merge(m,(g=n())!=null?g:h),r(p,!0),f()}).then(()=>{y==null||y(p,void 0),o=!0,c.forEach(m=>m(p))}).catch(m=>{y==null||y(void 0,m)})};return i.persist={setOptions:b=>{s={...s,...b},b.getStorage&&(l=b.getStorage())},clearStorage:()=>{l==null||l.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>o,onHydrate:b=>(a.add(b),()=>{a.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},v(),p||h},E0e=(t,e)=>(r,n,i)=>{let s={storage:b0e(()=>localStorage),partialize:v=>v,version:0,merge:(v,b)=>({...b,...v}),...e},o=!1;const a=new Set,c=new Set;let l=s.storage;if(!l)return t((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...v)},n,i);const u=()=>{const v=s.partialize({...n()});return l.setItem(s.name,{state:v,version:s.version})},f=i.setState;i.setState=(v,b)=>{f(v,b),u()};const d=t((...v)=>{r(...v),u()},n,i);let h;const p=()=>{var v,b;if(!l)return;o=!1,a.forEach(m=>{var g;return m((g=n())!=null?g:d)});const y=((b=s.onRehydrateStorage)==null?void 0:b.call(s,(v=n())!=null?v:d))||void 0;return n1(l.getItem.bind(l))(s.name).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==s.version){if(s.migrate)return s.migrate(m.state,m.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return m.state}).then(m=>{var g;return h=s.merge(m,(g=n())!=null?g:d),r(h,!0),u()}).then(()=>{y==null||y(h,void 0),h=n(),o=!0,c.forEach(m=>m(h))}).catch(m=>{y==null||y(void 0,m)})};return i.persist={setOptions:v=>{s={...s,...v},v.storage&&(l=v.storage)},clearStorage:()=>{l==null||l.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>p(),hasHydrated:()=>o,onHydrate:v=>(a.add(v),()=>{a.delete(v)}),onFinishHydration:v=>(c.add(v),()=>{c.delete(v)})},s.skipHydration||p(),h||d},x0e=(t,e)=>"getStorage"in e||"serialize"in e||"deserialize"in e?w0e(t,e):E0e(t,e),C0e=x0e,bT=t=>{let e;const r=new Set,n=(c,l)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=l??typeof u!="object"?u:Object.assign({},e,u),r.forEach(d=>d(e,f))}},i=()=>e,a={setState:n,getState:i,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{r.clear()}};return e=t(n,i,a),a},S0e=t=>t?bT(t):bT;function e8(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[n,i]of t)if(!Object.is(i,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;nv===f.id)||(c=[...c,p.chain]),l[f.id]=[...l[f.id]||[],...p.rpcUrls.http],p.rpcUrls.webSocket&&(u[f.id]=[...u[f.id]||[],...p.rpcUrls.webSocket]))}if(!d)throw new Error([`Could not find valid provider configuration for chain "${f.name}". `,"You may need to add `jsonRpcProvider` to `configureChains` with the chain's RPC URLs.","Read more: https://wagmi.sh/core/providers/jsonRpc"].join(` `))}return{chains:c,publicClient:({chainId:f})=>{const d=c.find(v=>v.id===f)??t[0],h=l[d.id];if(!h||!h[0])throw new Error(`No providers configured for chain "${d.id}"`);const p=gT({batch:r,chain:d,transport:vT(h.map(v=>DF(v,{timeout:a})),{rank:i,retryCount:s,retryDelay:o}),pollingInterval:n});return Object.assign(p,{chains:c})},webSocketPublicClient:({chainId:f})=>{const d=c.find(v=>v.id===f)??t[0],h=u[d.id];if(!h||!h[0])return;const p=gT({batch:r,chain:d,transport:vT(h.map(v=>p0e(v,{timeout:a})),{rank:i,retryCount:s,retryDelay:o}),pollingInterval:n});return Object.assign(p,{chains:c})}}}var A0e=class extends Error{constructor(){super(...arguments),this.name="ConnectorAlreadyConnectedError",this.message="Connector already connected"}},_0e=class extends Error{constructor({connector:t}){super(`"${t.name}" does not support programmatic chain switching.`),this.name="SwitchChainNotSupportedError"}};function BC(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let r,n;if(Array.isArray(t)&&Array.isArray(e)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(!BC(t[n],e[n]))return!1;return!0}if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const i=Object.keys(t);if(r=i.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;n--!==0;){const s=i[n];if(s&&!BC(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}var jC=(t,{find:e,replace:r})=>t&&e(t)?r(t):typeof t!="object"?t:Array.isArray(t)?t.map(n=>jC(n,{find:e,replace:r})):t instanceof Object?Object.entries(t).reduce((n,[i,s])=>({...n,[i]:jC(s,{find:e,replace:r})}),{}):t;function P0e(t){const e=JSON.parse(t);return jC(e,{find:n=>typeof n=="string"&&n.startsWith("#bigint."),replace:n=>BigInt(n.replace("#bigint.",""))})}function wT(t,e){return t.slice(0,e).join(".")||"."}function ET(t,e){const{length:r}=t;for(let n=0;n{const o=typeof s=="bigint"?`#bigint.${s.toString()}`:s;return(e==null?void 0:e(i,o))||o},n),r??void 0)}var ZF={getItem:t=>"",setItem:(t,e)=>null,removeItem:t=>null};function eB({deserialize:t=P0e,key:e="wagmi",serialize:r=I0e,storage:n}){return{...n,getItem:(i,s=null)=>{const o=n.getItem(`${e}.${i}`);try{return o?t(o):s}catch(a){return console.warn(a),s}},setItem:(i,s)=>{if(s===null)n.removeItem(`${e}.${i}`);else try{n.setItem(`${e}.${i}`,r(s))}catch(o){console.error(o)}},removeItem:i=>n.removeItem(`${e}.${i}`)}}var xT="store",Ru,mh,UC,tB,O0e=class{constructor({autoConnect:e=!1,connectors:r=[new XF],publicClient:n,storage:i=eB({storage:typeof window<"u"?window.localStorage:ZF}),logger:s={warn:console.warn},webSocketPublicClient:o}){var u,f;G2(this,UC),this.publicClients=new Map,this.webSocketPublicClients=new Map,G2(this,Ru,void 0),G2(this,mh,void 0),this.args={autoConnect:e,connectors:r,logger:s,publicClient:n,storage:i,webSocketPublicClient:o};let a="disconnected",c;if(e)try{const d=i.getItem(xT),h=(u=d==null?void 0:d.state)==null?void 0:u.data;a=h!=null&&h.account?"reconnecting":"connecting",c=(f=h==null?void 0:h.chain)==null?void 0:f.id}catch{}const l=typeof r=="function"?r():r;l.forEach(d=>d.setStorage(i)),this.store=S0e(g0e(C0e(()=>({connectors:l,publicClient:this.getPublicClient({chainId:c}),status:a,webSocketPublicClient:this.getWebSocketPublicClient({chainId:c})}),{name:xT,storage:i,partialize:d=>{var h,p;return{...e&&{data:{account:(h=d==null?void 0:d.data)==null?void 0:h.account,chain:(p=d==null?void 0:d.data)==null?void 0:p.chain}},chains:d==null?void 0:d.chains}},version:2}))),this.storage=i,tv(this,mh,i==null?void 0:i.getItem("wallet")),m0e(this,UC,tB).call(this),e&&typeof window<"u"&&setTimeout(async()=>await this.autoConnect(),0)}get chains(){return this.store.getState().chains}get connectors(){return this.store.getState().connectors}get connector(){return this.store.getState().connector}get data(){return this.store.getState().data}get error(){return this.store.getState().error}get lastUsedChainId(){var e,r;return(r=(e=this.data)==null?void 0:e.chain)==null?void 0:r.id}get publicClient(){return this.store.getState().publicClient}get status(){return this.store.getState().status}get subscribe(){return this.store.subscribe}get webSocketPublicClient(){return this.store.getState().webSocketPublicClient}setState(e){const r=typeof e=="function"?e(this.store.getState()):e;this.store.setState(r,!0)}clearState(){this.setState(e=>({...e,chains:void 0,connector:void 0,data:void 0,error:void 0,status:"disconnected"}))}async destroy(){var e,r;this.connector&&await((r=(e=this.connector).disconnect)==null?void 0:r.call(e)),tv(this,Ru,!1),this.clearState(),this.store.destroy()}async autoConnect(){if(V2(this,Ru))return;tv(this,Ru,!0),this.setState(n=>{var i;return{...n,status:(i=n.data)!=null&&i.account?"reconnecting":"connecting"}});const e=V2(this,mh)?[...this.connectors].sort(n=>n.id===V2(this,mh)?-1:1):this.connectors;let r=!1;for(const n of e){if(!n.ready||!n.isAuthorized||!await n.isAuthorized())continue;const s=await n.connect();this.setState(o=>({...o,connector:n,chains:n==null?void 0:n.chains,data:s,status:"connected"})),r=!0;break}return r||this.setState(n=>({...n,data:void 0,status:"disconnected"})),tv(this,Ru,!1),this.data}setConnectors(e){this.args={...this.args,connectors:e};const r=typeof e=="function"?e():e;r.forEach(n=>n.setStorage(this.args.storage)),this.setState(n=>({...n,connectors:r}))}getPublicClient({chainId:e}={}){let r=this.publicClients.get(-1);if(r&&(r==null?void 0:r.chain.id)===e||(r=this.publicClients.get(e??-1),r))return r;const{publicClient:n}=this.args;return r=typeof n=="function"?n({chainId:e}):n,this.publicClients.set(e??-1,r),r}setPublicClient(e){var n,i;const r=(i=(n=this.data)==null?void 0:n.chain)==null?void 0:i.id;this.args={...this.args,publicClient:e},this.publicClients.clear(),this.setState(s=>({...s,publicClient:this.getPublicClient({chainId:r})}))}getWebSocketPublicClient({chainId:e}={}){let r=this.webSocketPublicClients.get(-1);if(r&&(r==null?void 0:r.chain.id)===e||(r=this.webSocketPublicClients.get(e??-1),r))return r;const{webSocketPublicClient:n}=this.args;return r=typeof n=="function"?n({chainId:e}):n,r&&this.webSocketPublicClients.set(e??-1,r),r}setWebSocketPublicClient(e){var n,i;const r=(i=(n=this.data)==null?void 0:n.chain)==null?void 0:i.id;this.args={...this.args,webSocketPublicClient:e},this.webSocketPublicClients.clear(),this.setState(s=>({...s,webSocketPublicClient:this.getWebSocketPublicClient({chainId:r})}))}setLastUsedConnector(e=null){var r;(r=this.storage)==null||r.setItem("wallet",e)}};Ru=new WeakMap;mh=new WeakMap;UC=new WeakSet;tB=function(){const t=a=>{this.setState(c=>({...c,data:{...c.data,...a}}))},e=()=>{this.clearState()},r=a=>{this.setState(c=>({...c,error:a}))};this.store.subscribe(({connector:a})=>a,(a,c)=>{var l,u,f,d,h,p;(l=c==null?void 0:c.off)==null||l.call(c,"change",t),(u=c==null?void 0:c.off)==null||u.call(c,"disconnect",e),(f=c==null?void 0:c.off)==null||f.call(c,"error",r),a&&((d=a.on)==null||d.call(a,"change",t),(h=a.on)==null||h.call(a,"disconnect",e),(p=a.on)==null||p.call(a,"error",r))});const{publicClient:n,webSocketPublicClient:i}=this.args;(typeof n=="function"||typeof i=="function")&&this.store.subscribe(({data:a})=>{var c;return(c=a==null?void 0:a.chain)==null?void 0:c.id},a=>{this.setState(c=>({...c,publicClient:this.getPublicClient({chainId:a}),webSocketPublicClient:this.getWebSocketPublicClient({chainId:a})}))})};var zC;function R0e(t){const e=new O0e(t);return zC=e,e}function Vi(){if(!zC)throw new Error("No wagmi config found. Ensure you have set up a config: https://wagmi.sh/react/config");return zC}async function $0e({chainId:t,connector:e}){const r=Vi(),n=r.connector;if(n&&e.id===n.id)throw new A0e;try{r.setState(s=>({...s,status:"connecting"}));const i=await e.connect({chainId:t});return r.setLastUsedConnector(e.id),r.setState(s=>({...s,connector:e,chains:e==null?void 0:e.chains,data:i,status:"connected"})),r.storage.setItem("connected",!0),{...i,connector:e}}catch(i){throw r.setState(s=>({...s,status:s.connector?"connected":"disconnected"})),i}}async function M0e(){const t=Vi();t.connector&&await t.connector.disconnect(),t.clearState(),t.storage.removeItem("connected")}function WC({chainId:t}={}){const e=Vi();return t&&e.getPublicClient({chainId:t})||e.publicClient}async function rB({chainId:t}={}){var n,i;return await((i=(n=Vi().connector)==null?void 0:n.getWalletClient)==null?void 0:i.call(n,{chainId:t}))||null}function N0e(t,e){const r=Vi(),n=async()=>e(WC(t));return r.subscribe(({publicClient:s})=>s,n)}function D0e({chainId:t},e){const r=Vi(),n=async({chainId:s})=>{if(t&&s&&t!==s)return;const o=await rB({chainId:t});return Vi().connector?e(o):e(null)};return r.subscribe(({data:s,connector:o})=>{var a;return{account:s==null?void 0:s.account,chainId:(a=s==null?void 0:s.chain)==null?void 0:a.id,connector:o}},n,{equalityFn:e8})}function nB(){const{data:t,connector:e,status:r}=Vi();switch(r){case"connected":return{address:t==null?void 0:t.account,connector:e,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:r};case"reconnecting":return{address:t==null?void 0:t.account,connector:e,isConnected:!!(t!=null&&t.account),isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:r};case"connecting":return{address:t==null?void 0:t.account,connector:e,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:r};case"disconnected":return{address:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:r}}}function iB(){var i,s,o,a;const t=Vi(),e=(s=(i=t.data)==null?void 0:i.chain)==null?void 0:s.id,r=t.chains??[],n=[...((o=t.publicClient)==null?void 0:o.chains)||[],...r].find(c=>c.id===e)??{id:e,name:`Chain ${e}`,network:`${e}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}};return{chain:e?{...n,...(a=t.data)==null?void 0:a.chain,id:e}:void 0,chains:r}}async function L0e({chainId:t}){const{connector:e}=Vi();if(!e)throw new Ma;if(!e.switchChain)throw new _0e({connector:e});return e.switchChain(t)}function F0e(t,{selector:e=r=>r}={}){const r=Vi(),n=()=>t(nB());return r.subscribe(({data:s,connector:o,status:a})=>e({address:s==null?void 0:s.account,connector:o,status:a}),n,{equalityFn:e8})}function B0e(t,{selector:e=r=>r}={}){const r=Vi(),n=()=>t(iB());return r.subscribe(({data:s,chains:o})=>{var a;return e({chainId:(a=s==null?void 0:s.chain)==null?void 0:a.id,chains:o})},n,{equalityFn:e8})}var j0e={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62",blockCreated:16966585},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}},CT={id:137,name:"Polygon",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}},sB={exports:{}},oB={};/** @@ -184,7 +184,7 @@ ${r.length}`);return Yn(Zo([n,r]),e)}const Ghe="0x608060405234801562000011576000 * Copyright (c) 2013 hij1nx * Licensed under the MIT license. */(function(t,e){(function(r){var n=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function($){return Object.prototype.toString.call($)==="[object Array]"},s=10,o=typeof process=="object"&&typeof process.nextTick=="function",a=typeof Symbol=="function",c=typeof Reflect=="object",l=typeof setImmediate=="function",u=l?setImmediate:setTimeout,f=a?c&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(k){var $=Object.getOwnPropertyNames(k);return $.push.apply($,Object.getOwnPropertySymbols(k)),$}:Object.keys;function d(){this._events={},this._conf&&h.call(this,this._conf)}function h(k){k&&(this._conf=k,k.delimiter&&(this.delimiter=k.delimiter),k.maxListeners!==r&&(this._maxListeners=k.maxListeners),k.wildcard&&(this.wildcard=k.wildcard),k.newListener&&(this._newListener=k.newListener),k.removeListener&&(this._removeListener=k.removeListener),k.verboseMemoryLeak&&(this.verboseMemoryLeak=k.verboseMemoryLeak),k.ignoreErrors&&(this.ignoreErrors=k.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function p(k,$){var L="(node) warning: possible EventEmitter memory leak detected. "+k+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(L+=" Event name: "+$+"."),typeof process<"u"&&process.emitWarning){var M=new Error(L);M.name="MaxListenersExceededWarning",M.emitter=this,M.count=k,process.emitWarning(M)}else console.error(L),console.trace&&console.trace()}var v=function(k,$,L){var M=arguments.length;switch(M){case 0:return[];case 1:return[k];case 2:return[k,$];case 3:return[k,$,L];default:for(var A=new Array(M);M--;)A[M]=arguments[M];return A}};function b(k,$){for(var L={},M,A=k.length,D=$?$.length:0,V=0;V0;)k=D[U],V.call(R,k,L[k]);this._listeners={},this._listenersCount=0,W()}}});function m(k,$,L,M){var A=Object.assign({},$);if(!k)return A;if(typeof k!="object")throw TypeError("options must be an object");var D=Object.keys(k),V=D.length,R,U,W;function q(X){throw Error('Invalid "'+R+'" option value'+(X?". Reason: "+X:""))}for(var Y=0;Y0;)if(R===k[U])return D;V($)}}var P=S(["function"]),T=S(["object","function"]);function w(k,$,L){var M,A,D=0,V,R=new k(function(U,W,q){L=m(L,{timeout:0,overload:!1},{timeout:function(Z,ae){return Z*=1,(typeof Z!="number"||Z<0||!Number.isFinite(Z))&&ae("timeout must be a positive number"),Z}}),M=!L.overload&&typeof k.prototype.cancel=="function"&&typeof q=="function";function Y(){A&&(A=null),D&&(clearTimeout(D),D=0)}var X=function(Z){Y(),U(Z)},Q=function(Z){Y(),W(Z)};M?$(X,Q,q):(A=[function(Z){Q(Z||Error("canceled"))}],$(X,Q,function(Z){if(V)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof Z!="function")throw TypeError("onCancel callback must be a function");A.push(Z)}),V=!0),L.timeout>0&&(D=setTimeout(function(){var Z=Error("timeout");Z.code="ETIMEDOUT",D=0,R.cancel(Z),W(Z)},L.timeout))});return M||(R.cancel=function(U){if(A){for(var W=A.length,q=1;q0;)Q=_e[R],Q!=="_listeners"&&(at=F(k,$,L[Q],M+1,A),at&&(X?X.push.apply(X,at):X=at));return X}else if(ot==="**"){for(ue=M+1===A||M+2===A&&Te==="*",ue&&L._listeners&&(X=F(k,$,L,A,A)),_e=f(L),R=_e.length;R-- >0;)Q=_e[R],Q!=="_listeners"&&(Q==="*"||Q==="**"?(L[Q]._listeners&&!ue&&(at=F(k,$,L[Q],A,A),at&&(X?X.push.apply(X,at):X=at)),at=F(k,$,L[Q],M,A)):Q===Te?at=F(k,$,L[Q],M+2,A):at=F(k,$,L[Q],M,A),at&&(X?X.push.apply(X,at):X=at));return X}else L[ot]&&(X=F(k,$,L[ot],M+1,A));if(Z=L["*"],Z&&F(k,$,Z,M+1,A),ae=L["**"],ae)if(M0;)Q=_e[R],Q!=="_listeners"&&(Q===Te?F(k,$,ae[Q],M+2,A):Q===ot?F(k,$,ae[Q],M+1,A):(se={},se[Q]=ae[Q],F(k,$,{"**":se},M+1,A)));else ae._listeners?F(k,$,ae,A,A):ae["*"]&&ae["*"]._listeners&&F(k,$,ae["*"],A,A);return X}function j(k,$,L){var M=0,A=0,D,V=this.delimiter,R=V.length,U;if(typeof k=="string")if((D=k.indexOf(V))!==-1){U=new Array(5);do U[M++]=k.slice(A,D),A=D+R;while((D=k.indexOf(V,A))!==-1);U[M++]=k.slice(A)}else U=[k],M=1;else U=k,M=k.length;if(M>1){for(D=0;D+10&&W._listeners.length>this._maxListeners&&(W._listeners.warned=!0,p.call(this,W._listeners.length,q))):W._listeners=$,!0;return!0}function H(k,$,L,M){for(var A=f(k),D=A.length,V,R,U,W=k._listeners,q;D-- >0;)R=A[D],V=k[R],R==="_listeners"?U=L:U=L?L.concat(R):[R],q=M||typeof R=="symbol",W&&$.push(q?U:U.join(this.delimiter)),typeof V=="object"&&H.call(this,V,$,U,q);return $}function K(k){for(var $=f(k),L=$.length,M,A,D;L-- >0;)A=$[L],M=k[A],M&&(D=!0,A!=="_listeners"&&!K(M)&&delete k[A]);return D}function B(k,$,L){this.emitter=k,this.event=$,this.listener=L}B.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function E(k,$,L){if(L===!0)A=!0;else if(L===!1)M=!0;else{if(!L||typeof L!="object")throw TypeError("options should be an object or true");var M=L.async,A=L.promisify,D=L.nextTick,V=L.objectify}if(M||D||A){var R=$,U=$._origin||$;if(D&&!o)throw Error("process.nextTick is not supported");A===r&&(A=$.constructor.name==="AsyncFunction"),$=function(){var W=arguments,q=this,Y=this.event;return A?D?Promise.resolve():new Promise(function(X){u(X)}).then(function(){return q.event=Y,R.apply(q,W)}):(D?process.nextTick:u)(function(){q.event=Y,R.apply(q,W)})},$._async=!0,$._origin=U}return[$,V?new B(this,k,$):this]}function _(k){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,h.call(this,k)}_.EventEmitter2=_,_.prototype.listenTo=function(k,$,L){if(typeof k!="object")throw TypeError("target musts be an object");var M=this;L=m(L,{on:r,off:r,reducers:r},{on:P,off:P,reducers:T});function A(D){if(typeof D!="object")throw TypeError("events must be an object");var V=L.reducers,R=I.call(M,k),U;R===-1?U=new y(M,k,L):U=M._observers[R];for(var W=f(D),q=W.length,Y,X=typeof V=="function",Q=0;Q0;)A=L[M],(!k||A._target===k)&&(A.unsubscribe($),D=!0);return D},_.prototype.delimiter=".",_.prototype.setMaxListeners=function(k){k!==r&&(this._maxListeners=k,this._conf||(this._conf={}),this._conf.maxListeners=k)},_.prototype.getMaxListeners=function(){return this._maxListeners},_.prototype.event="",_.prototype.once=function(k,$,L){return this._once(k,$,!1,L)},_.prototype.prependOnceListener=function(k,$,L){return this._once(k,$,!0,L)},_.prototype._once=function(k,$,L,M){return this._many(k,1,$,L,M)},_.prototype.many=function(k,$,L,M){return this._many(k,$,L,!1,M)},_.prototype.prependMany=function(k,$,L,M){return this._many(k,$,L,!0,M)},_.prototype._many=function(k,$,L,M,A){var D=this;if(typeof L!="function")throw new Error("many only accepts instances of Function");function V(){return--$===0&&D.off(k,V),L.apply(this,arguments)}return V._origin=L,this._on(k,V,M,A)},_.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var k=arguments[0],$,L=this.wildcard,M,A,D,V,R;if(k==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(L&&($=k,k!=="newListener"&&k!=="removeListener"&&typeof k=="object")){if(A=k.length,a){for(D=0;D3)for(M=new Array(U-1),V=1;V3)for(A=new Array(W-1),R=1;R0&&this._events[k].length>this._maxListeners&&(this._events[k].warned=!0,p.call(this,this._events[k].length,k))):this._events[k]=$,A)},_.prototype.off=function(k,$){if(typeof $!="function")throw new Error("removeListener only takes instances of Function");var L,M=[];if(this.wildcard){var A=typeof k=="string"?k.split(this.delimiter):k.slice();if(M=F.call(this,null,A,this.listenerTree,0),!M)return this}else{if(!this._events[k])return this;L=this._events[k],M.push({_listeners:L})}for(var D=0;D0){for(M=this._all,$=0,L=M.length;$0;)M=$[L[D]],typeof M=="function"?A.push(M):A.push.apply(A,M);return A}else{if(this.wildcard){if(V=this.listenerTree,!V)return[];var R=[],U=typeof k=="string"?k.split(this.delimiter):k.slice();return F.call(this,R,U,V,0),R}return $?(M=$[k],M?typeof M=="function"?[M]:M:[]):[]}},_.prototype.eventNames=function(k){var $=this._events;return this.wildcard?H.call(this,this.listenerTree,[],null,k):$?f($):[]},_.prototype.listenerCount=function(k){return this.listeners(k).length},_.prototype.hasListeners=function(k){if(this.wildcard){var $=[],L=typeof k=="string"?k.split(this.delimiter):k.slice();return F.call(this,$,L,this.listenerTree,0),$.length>0}var M=this._events,A=this._all;return!!(A&&A.length||M&&(k===r?f(M).length:M[k]))},_.prototype.listenersAny=function(){return this._all?this._all:[]},_.prototype.waitFor=function(k,$){var L=this,M=typeof $;return M==="number"?$={timeout:$}:M==="function"&&($={filter:$}),$=m($,{timeout:0,filter:r,handleError:!1,Promise,overload:!1},{filter:P,Promise:g}),w($.Promise,function(A,D,V){function R(){var U=$.filter;if(!(U&&!U.apply(L,arguments)))if(L.off(k,R),$.handleError){var W=arguments[0];W?D(W):A(v.apply(null,arguments).slice(1))}else A(v.apply(null,arguments))}V(function(){L.off(k,R)}),L._on(k,R,!1)},{timeout:$.timeout,overload:$.overload})};function O(k,$,L){L=m(L,{Promise,timeout:0,overload:!1},{Promise:g});var M=L.Promise;return w(M,function(A,D,V){var R;if(typeof k.addEventListener=="function"){R=function(){A(v.apply(null,arguments))},V(function(){k.removeEventListener($,R)}),k.addEventListener($,R,{once:!0});return}var U=function(){W&&k.removeListener("error",W),A(v.apply(null,arguments))},W;$!=="error"&&(W=function(q){k.removeListener($,U),D(q)},k.once("error",W)),V(function(){W&&k.removeListener("error",W),k.removeListener($,U)}),k.once($,U)},{timeout:L.timeout,overload:L.overload})}var N=_.prototype;Object.defineProperties(_,{defaultMaxListeners:{get:function(){return N._maxListeners},set:function(k){if(typeof k!="number"||k<0||Number.isNaN(k))throw TypeError("n must be a non-negative number");N._maxListeners=k},enumerable:!0},once:{value:O,writable:!0,configurable:!0}}),Object.defineProperties(N,{_maxListeners:{value:s,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof r=="function"&&r.amd?r(function(){return _}):t.exports=_})()})(dU);var jb=dU.exports;function Jn(){return Jn=Object.assign?Object.assign.bind():function(t){for(var e=1;e++vye;class tp{constructor(){var e=this;this.pendingMessageRequests=[],this.responseCallbacks=new Map,this.confirmationOnly=!1,this.events=new jb.EventEmitter2,this.sendAsync=async function(r,n,i){e.state===Ri.CLOSED&&(e.confirmationOnly=!0),e.openWallet(void 0,{type:"jsonRpcRequest",method:r.method},i);try{e.isOpened()||await e.waitUntilOpened();const s=await e.sendMessageRequest({idx:mU(),type:Ye.MESSAGE,data:r,chainId:i});n(void 0,s.data)}catch(s){n(s)}},this.sendMessageRequest=async function(r){return new Promise((n,i)=>{(!r.idx||r.idx<=0)&&r.type!=="init"&&i(new Error("message idx not set"));const s=(a,c)=>{if(a)i(a);else if(c)n(c);else throw new Error("no valid response to return")},o=r.idx;e.responseCallbacks.get(o)?i(new Error("duplicate message idx, should never happen")):e.responseCallbacks.set(o,s),e.isOpened()?e.sendMessage(r):(ge.debug("pushing to pending requests",r),e.pendingMessageRequests.push(r))})},this.waitUntilOpened=async function(r=B8){let n=!1;return Promise.race([new Promise((i,s)=>{const o=setTimeout(()=>{clearTimeout(o),n||(e.state=Ri.CLOSED,e.events.emit("close",{code:1005,message:"opening wallet timed out"})),s(new Error("opening wallet timed out"))},r)}),new Promise(i=>{if(e.isOpened()){var s;n=!0,i((s=e.openPayload)==null?void 0:s.session);return}e.events.once("open",o=>{e.openPayload=o,n=!0,i(o.session)})})])},this.waitUntilConnected=async function(){await e.waitUntilOpened();const r=new Promise(i=>{if(e.connectPayload){i(e.connectPayload);return}e.events.once("connect",s=>{e.connectPayload=s,i(s)})}),n=new Promise((i,s)=>{e.events.once("close",o=>{s(o?new Error(`wallet closed due to ${JSON.stringify(o)}`):new Error("user closed the wallet"))})});return Promise.race([r,n])},this.state=Ri.CLOSED,this._registered=!1,this._init=Wt.NIL}get registered(){return this._registered}register(){throw new Error("abstract method")}unregister(){throw new Error("abstract method")}openWallet(e,r,n){throw new Error("abstract method")}closeWallet(){throw new Error("abstract method")}isOpened(){return this.registered&&this.state===Ri.OPENED}isConnected(){var e;const r=(e=this.openPayload)==null?void 0:e.session;return this.registered&&r!==void 0&&!!r.accountAddress&&r.accountAddress.length===42&&!!r.networks&&r.networks.length>0}handleMessage(e){var r=this;if(e.type===Ye.INIT){ge.debug("MessageProvider, received INIT message",e);const{nonce:c}=e.data;if(!c||c.length==0){ge.error("invalid init nonce");return}this._init=Wt.OK,this.sendMessage({idx:-1,type:Ye.INIT,data:{sessionId:this._sessionId,nonce:c}})}if(this._init!==Wt.OK)return;ge.debug("RECEIVED MESSAGE FROM WALLET",e.idx,e);const n=e.idx,i=this.responseCallbacks.get(n);if(n&&this.responseCallbacks.delete(n),e.type===Ye.OPEN&&!this.isOpened()){var s,o;if(this._sessionId&&this._sessionId!==((s=e.data)==null?void 0:s.sessionId)){ge.debug("open event received from wallet, but does not match sessionId",this._sessionId);return}if((o=e.data)!=null&&o.error){var a;const c=new Error(`opening wallet failed: received ${(a=e.data)==null?void 0:a.error}`);throw ge.error(c),this.close(),c}this.state=Ri.OPENED,this.openPayload=e.data,this.events.emit("open",this.openPayload),this.pendingMessageRequests.length!==0&&this.pendingMessageRequests.splice(0,this.pendingMessageRequests.length).forEach(async function(l){r.sendMessage(l)});return}if(e.type===Ye.MESSAGE){if(this.confirmationOnly&&setTimeout(()=>{this.responseCallbacks.size===0&&this.closeWallet()},500),!i)throw new Error("impossible state");if(i){this.events.emit("message",e),i(e.data.error,e);return}}if(e.type===Ye.ACCOUNTS_CHANGED){this.accountsChangedPayload={accounts:[]},e.data&&e.data.length>0?(this.accountsChangedPayload={accounts:[Ve(e.data[0])],origin:e.origin},this.events.emit("accountsChanged",this.accountsChangedPayload.accounts,this.accountsChangedPayload.origin)):this.events.emit("accountsChanged",[],e.origin);return}if(e.type===Ye.CHAIN_CHANGED){this.events.emit("chainChanged",e.data,e.origin);return}if(e.type===Ye.NETWORKS){this.networksPayload=e.data,this.events.emit("networks",this.networksPayload);return}if(e.type===Ye.WALLET_CONTEXT){this.walletContextPayload=e.data,this.events.emit("walletContext",this.walletContextPayload);return}e.type===Ye.CLOSE&&this.state!==Ri.CLOSED&&this.close(e.data),e.type===Ye.CONNECT&&(this.connectPayload=e.data,this.events.emit("connect",this.connectPayload)),e.type===Ye.DISCONNECT&&this.isConnected()&&(this.events.emit("disconnect",e.data,e.origin),this.close())}sendMessage(e){throw new Error("abstract method")}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}emit(e,...r){return this.events.emit(e,...r)}close(e){this.state!==Ri.CLOSED&&(this.state=Ri.CLOSED,this.confirmationOnly=!1,this._sessionId=void 0,ge.info("closing wallet and flushing!"),this.pendingMessageRequests.length=0,this.responseCallbacks.forEach(r=>{r(Jn({},new Error("wallet closed"),{code:4001}))}),this.responseCallbacks.clear(),this.connectPayload=void 0,this.openPayload=void 0,this.accountsChangedPayload=void 0,this.networksPayload=void 0,this.walletContextPayload=void 0,this.events.emit("close",e))}}function mye(t){return yye.some(e=>e.predicate(t))}const yye=[{name:"Decentraland Exception",predicate:bye},{name:"0x v3 Exception",predicate:wye}],gye=/^Decentraland Login\nEphemeral address: 0x[a-fA-F0-9]{40}\nExpiration: (\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)((-(\d{2}):(\d{2})|Z)?)$/;function bye(t){try{const e=ua(t);return gye.test(e)}catch{return!1}}function wye(t){const e=new jr(Eye);try{return e.decodeFunctionData("OrderWithHash",t),!0}catch{return!1}}const Eye=[{inputs:[{components:[{internalType:"address",name:"makerAddress",type:"address"},{internalType:"address",name:"takerAddress",type:"address"},{internalType:"address",name:"feeRecipientAddress",type:"address"},{internalType:"address",name:"senderAddress",type:"address"},{internalType:"uint256",name:"makerAssetAmount",type:"uint256"},{internalType:"uint256",name:"takerAssetAmount",type:"uint256"},{internalType:"uint256",name:"makerFee",type:"uint256"},{internalType:"uint256",name:"takerFee",type:"uint256"},{internalType:"uint256",name:"expirationTimeSeconds",type:"uint256"},{internalType:"uint256",name:"salt",type:"uint256"},{internalType:"bytes",name:"makerAssetData",type:"bytes"},{internalType:"bytes",name:"takerAssetData",type:"bytes"},{internalType:"bytes",name:"makerFeeAssetData",type:"bytes"},{internalType:"bytes",name:"takerFeeAssetData",type:"bytes"}],internalType:"struct IEIP1271Data.Order",name:"order",type:"tuple"},{internalType:"bytes32",name:"orderHash",type:"bytes32"}],name:"OrderWithHash",outputs:[],stateMutability:"pure",type:"function"}],Yv=wt(`Ethereum Signed Message: -`),yU=t=>ca(t)||je(t)?re(t):wt(t),Ub=t=>{const e=yU(t);return mye(e)?e:qt([Yv,wt(String(e.length)),e])},xye=t=>{if(JSON.stringify(t.slice(0,Yv.length))!==JSON.stringify(Yv))return t;const e=t.slice(Yv.length),r=String(e.length).length;let n,i;try{i=Number(ua(e.slice(0,r)))}catch{i=Number(te(e.slice(0,r)))}return i>e.length||!Number.isInteger(i)?n=r-1:n=r,e.slice(n)},Qf=async(t,e,r,n)=>new he.reader.OnChainReader(n).isValidSignature(t,e,r),gU=async(t,e,r,n)=>{const i=Ub(e),s=c8(i);return Qf(t,s,r,n)},bU=(t,e,r,n)=>Qf(t,Q1(e),r,n),$y=()=>window.location.protocol==="chrome-extension:"||window.location.protocol==="moz-extension:",wU=()=>!!navigator.userAgent.match(/UnitySequence/i),EU=t=>t.onChain.deployed&&t.fullyMigrated;class xU{constructor(){this.callbacks=[],this.store={}}getItem(e){return this.store[e]||null}setItem(e,r){this.store[e]=r,this.callbacks.filter(n=>n.key===e).forEach(n=>n.cb(r))}removeItem(e){delete this.store[e]}onItemChange(e,r){return this.callbacks.push({key:e,cb:r}),()=>{this.callbacks=this.callbacks.filter(n=>n.cb!==r)}}}class c1{static isAvailable(){return typeof window=="object"&&typeof window.localStorage=="object"}constructor(){if(this.callbacks=[],!c1.isAvailable())throw new Error("LocalStorage is not available");window.addEventListener("storage",e=>{const{key:r}=e;this.callbacks.filter(i=>i.key===r).forEach(i=>i.cb(this.getItem(r)))})}getItem(e){return window.localStorage.getItem(e)}setItem(e,r){window.localStorage.setItem(e,r),this.callbacks.filter(n=>n.key===e).forEach(n=>n.cb(r))}removeItem(e){window.localStorage.removeItem(e),this.callbacks.filter(r=>r.key===e).forEach(r=>r.cb(null))}onItemChange(e,r){return this.callbacks.push({key:e,cb:r}),()=>{this.callbacks=this.callbacks.filter(n=>n.cb!==r)}}}function My(){return c1.isAvailable()?new c1:new xU}async function CU(t){return Array.isArray(t)?Promise.all(t.map(e=>vt(e))):vt(t)}const WT="@sequence.transportSession";class rp{constructor(e){var r=this;this.sendAsync=async function(n,i,s){throw new Error("abstract method")},this.handleMessage=async function(n){const i=n;if(r._init!==Wt.OK){if(i.type===Ye.INIT)if(r.isValidInitAck(n))r._initCallback&&r._initCallback();else{r._initCallback&&r._initCallback("invalid init");return}return}switch(i.type){case Ye.OPEN:{if(r._init!==Wt.OK)return;const s={sessionId:i.data.sessionId,intent:i.data.intent,networkId:i.data.networkId};await r.open(s);return}case Ye.CLOSE:return r._init!==Wt.OK,void 0;case Ye.MESSAGE:{const s=await r.walletRequestHandler.sendMessageRequest(i);r.sendMessage(s),s.data.error;return}default:ge.error(`unexpected payload type ${i.type}`)}},this.sendMessageRequest=async function(n){return r.walletRequestHandler.sendMessageRequest(n)},this.open=async function({sessionId:n,intent:i,networkId:s}){n&&(r._sessionId=$B(n),r.saveTransportSession({sessionId:n,intent:i,networkId:s})),r.walletRequestHandler.setOpenIntent(i),await r.init();let o;try{if(s){const a=d8(s);if(a)o=a.chainId;else throw new Error(`unknown network ${s}`)}else o=r.walletRequestHandler.defaultChainId()}catch(a){console.error(a)}if(i&&i.type==="connect"&&i.options){const a=i.options,c=a;if(r.appOrigin&&c!=null&&c.origin){if(!$y()&&c.origin!==r.appOrigin)throw new Error("origin is invalid")}else!r.appOrigin&&c!=null&&c.origin?a.origin=NB(c.origin):r.appOrigin&&(a.origin=r.appOrigin);a.app&&(a.app=MB(a.app)),a.networkId?s=a.networkId:s&&(a.networkId=s),r.walletRequestHandler.setConnectOptions(a)}else r.walletRequestHandler.setConnectOptions(void 0);if(await r.walletRequestHandler.getAccount(),await r.walletRequestHandler.isSignedIn())if(i&&i.type==="connect"){(!o||o<=0)&&console.log("Failed to set default network on open"),r.notifyOpen({sessionId:r._sessionId});try{const a=await r.walletRequestHandler.promptConnect(i.options);a.connected&&r.walletRequestHandler.notifyConnect(a)}catch(a){ge.warn("promptConnect not connected:",a)}finally{(!i.options||i.options.keepWalletOpened!==!0)&&r.notifyClose()}}else{if(!o||o<=0)return r.notifyOpen({sessionId:r._sessionId,error:`failed to open wallet on network ${s}`}),!1;r.notifyOpen({sessionId:r._sessionId,chainId:`${o}`,session:await r.walletRequestHandler.walletSession(o)})}else return r.notifyOpen({sessionId:r._sessionId}),!0;return!0},this.saveTransportSession=n=>{My().setItem(WT,JSON.stringify(n))},this.getCachedTransportSession=async function(){const n=My().getItem(WT);try{return n?JSON.parse(n):null}catch{return console.error(`unable to parse transport session: ${n}`),null}},this.walletRequestHandler=e,this._init=Wt.NIL,this.walletRequestHandler.on("connect",n=>{this.registered&&this.notifyConnect(n)}),this.walletRequestHandler.on("disconnect",(n,i)=>{this.registered&&this.notifyDisconnect(n,i)}),this.walletRequestHandler.on("accountsChanged",(n,i)=>{this.registered&&this.notifyAccountsChanged(n,i)}),this.walletRequestHandler.on("networks",n=>{this.registered&&(this.notifyNetworks(n),!n||n.length===0?this.notifyChainChanged("0x0"):this.notifyChainChanged(Es(n.find(i=>i.isDefaultChain).chainId)))}),this.walletRequestHandler.on("chainChanged",(n,i)=>{this.notifyChainChanged(n,i)}),this.walletRequestHandler.on("walletContext",n=>{!this.registered||!n||this.notifyWalletContext(n)}),this.walletRequestHandler.on("close",n=>{this.registered&&this.notifyClose(n)})}get registered(){return this._registered}register(){throw new Error("abstract method")}unregister(){throw new Error("abstract method")}sendMessage(e){throw new Error("abstract method")}notifyOpen(e){const{chainId:r,sessionId:n,session:i,error:s}=e;this.sendMessage({idx:-1,type:Ye.OPEN,data:{chainId:r,sessionId:n,session:i,error:s}})}notifyClose(e){this.sendMessage({idx:-1,type:Ye.CLOSE,data:e?{error:e}:null})}notifyConnect(e){this.sendMessage({idx:-1,type:Ye.CONNECT,data:e})}notifyDisconnect(e,r){this.sendMessage({idx:-1,type:Ye.DISCONNECT,data:e?{error:e}:null,origin:r})}notifyAccountsChanged(e,r){this.sendMessage({idx:-1,type:Ye.ACCOUNTS_CHANGED,data:e,origin:r})}notifyChainChanged(e,r){this.sendMessage({idx:-1,type:Ye.CHAIN_CHANGED,data:e,origin:r})}notifyNetworks(e){this.sendMessage({idx:-1,type:Ye.NETWORKS,data:e})}notifyWalletContext(e){this.sendMessage({idx:-1,type:Ye.WALLET_CONTEXT,data:e})}isValidInitAck(e){if(this._init===Wt.OK)return ge.warn("isValidInitAck, already in init'd state, so inquiry is invalid."),!1;if(e.type!==Ye.INIT)return ge.warn("isValidInitAck, invalid message type, expecting init"),!1;const{sessionId:r,nonce:n}=e.data;return!r||r.length===0||!n||n.length===0?(ge.error("invalid init ack"),!1):r!==this._sessionId||n!==this._initNonce?(ge.error("invalid init ack match"),!1):!0}init(){return new Promise((e,r)=>{if(this._init===Wt.OK){e();return}if(this._init!==Wt.NIL||this._initCallback){r("transport init is in progress");return}const n=setTimeout(()=>{ge.warn("transport init timed out"),this._initCallback&&this._initCallback("transport init timed out")},B8/2);this._initCallback=i=>{this._initCallback=void 0,clearTimeout(n),i?r(i):(this._init=Wt.OK,e())},this._initNonce=`${performance.now()}`,this.sendMessage({idx:-1,type:Ye.INIT,data:{nonce:this._initNonce}}),this._init=Wt.SENT_NONCE})}}class Cye{constructor(){const e=new d5,r=new d5;e.conn=r,r.conn=e,this.app=e,this.wallet=r}}class d5{constructor(){this.events=new jb.EventEmitter2,this.handleMessage=e=>{throw new Error("ProxyMessageChannelPort is not registered")},this.sendMessage=e=>{this.conn.handleMessage(e),e.type==="open"&&this.events.emit("open",e),e.type==="close"&&this.events.emit("close",e),e.type==="connect"&&this.events.emit("connect",e),e.type==="disconnect"&&this.events.emit("disconnect",e)}}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}}class SU extends tp{constructor(e){if(super(),this.register=()=>{this.port.handleMessage=r=>{this.handleMessage(r)},this.on("open",(...r)=>{this.port.events.emit("open",...r)}),this.on("close",(...r)=>{this.port.events.emit("close",...r)}),this.on("connect",(...r)=>{this.port.events.emit("connect",...r)}),this.on("disconnect",(...r)=>{this.port.events.emit("disconnect",...r)}),this._registered=!0},this.unregister=()=>{this._registered=!1,this.closeWallet(),this.events.removeAllListeners(),this.port.handleMessage=void 0},this.openWallet=(r,n,i)=>{if(this.state===Ri.CLOSED){this.state=Ri.OPENING;const s=`${performance.now()}`;this._sessionId=s,this.sendMessage({idx:-1,type:Ye.OPEN,data:{path:r,intent:n,networkId:i,sessionId:s}})}},this.state=Ri.CLOSED,this.port=e,!e)throw new Error("port argument cannot be empty");this._init=Wt.OK}closeWallet(){this.sendMessage({idx:-1,type:Ye.CLOSE,data:null}),this.close()}sendMessage(e){if(!e.idx)throw new Error("message idx is empty");this.port.sendMessage(e)}}class Sye extends rp{constructor(e,r){super(e),this.port=r,this._init=Wt.OK}register(){this.port.handleMessage=e=>{this.handleMessage(e)},this._registered=!0}async restoreSession(){const e=await this.getCachedTransportSession();e&&this.open(e)}unregister(){this.port.handleMessage=void 0,this._registered=!1}sendMessage(e){this.port.sendMessage(e)}}function kU(t){var e;if((e=window.ue)!=null&&e.sequencewallettransport&&!window.logsOverriddenForUnreal){var r;const n=(r=window.ue)==null?void 0:r.sequencewallettransport;console.log=(...i)=>{n.logfromjs(`${t}: ${tE(i)}`)},console.warn=(...i)=>{n.warnfromjs(`${t}: ${tE(i)}`)},console.error=(...i)=>{n.errorfromjs(`${t}: ${tE(i)}`)},window.logsOverriddenForUnreal=!0}}function tE(t){return t.map(e=>typeof e=="object"?e instanceof Error?e.message:JSON.stringify(e):String(e)).join(" ")}let bu;class AU extends tp{constructor(e){super(),this.register=()=>{var r;kU("dapp"),bu&&(bu.unregister(),bu=this),(r=window.ue)!=null&&r.sequencewallettransport&&(window.ue.sequencewallettransport.onmessagefromwallet=this.onUnrealCallback),bu=this,this._registered=!0,console.log("registering transport!")},this.unregister=()=>{var r,n;this._registered=!1,this.closeWallet(),bu===this&&(bu=void 0),((r=window.ue)==null||(n=r.sequencewallettransport)==null?void 0:n.onmessagefromwallet)===this.onUnrealCallback&&delete window.ue.sequencewallettransport.onmessagefromwallet,this.events.removeAllListeners()},this.openWallet=(r,n,i)=>{if(this.isOpened()){console.log("wallet already open!");return}console.log("opening wallet!");const s=new URL(this.walletURL.href),o=new ep;r&&(s.pathname=r.toLowerCase()),this._init=Wt.NIL,this._sessionId=`${performance.now()}`,o.set("sid",this._sessionId),n&&o.set("intent",o8(n)),i&&o.set("net",`${i}`),s.search=o.toString(),console.log("opening wallet to",s.href),window.open(s.href)},this.onUnrealCallback=r=>{if(!r)throw new Error("ProviderMessage object is empty");this.handleMessage(r)},this.walletURL=new URL(e)}closeWallet(){this.close()}sendMessage(e){var r,n;const i=typeof e!="string"?JSON.stringify(e):e;console.log("Sending message to wallet:",i),(r=window.ue)==null||(n=r.sequencewallettransport)==null||n.sendmessagetowallet(i)}}class kye extends rp{constructor(e){super(e),this.onMessageFromUnreal=r=>{ge.debug("RECEIVED MESSAGE",r),this.handleMessage(r)},this.getUnrealTransportSession=r=>{const n=new ep(r);return{sessionId:n.get("sid"),networkId:n.get("net"),intent:a8(n.get("intent"))}},this._init=Wt.NIL}async register(e){var r;if(((r=window.ue)==null?void 0:r.sequencewallettransport)===void 0)return;kU("wallet");const{search:n}=new URL(e||window.location.href);let i=this.getUnrealTransportSession(n);if(!!i.sessionId||(i=await this.getCachedTransportSession()),!i){ge.error("unreal session is undefined");return}window.ue.sequencewallettransport.onmessagefromsequencejs=this.onMessageFromUnreal,this._registered=!0,this.open(i).then(o=>{if(!o){var a;const c=`failed to open to network ${(a=i)==null?void 0:a.networkId}`;ge.error(c),this.notifyClose({message:c}),window.close()}}).catch(o=>{var a;const c=`failed to open to network ${(a=i)==null?void 0:a.networkId}, due to: ${o}`;ge.error(c),this.notifyClose({message:c}),window.close()})}unregister(){var e,r;((e=window.ue)==null||(r=e.sequencewallettransport)==null?void 0:r.onmessagefromsequencejs)===this.onMessageFromUnreal&&delete window.ue.sequencewallettransport.onmessagefromsequencejs,this._registered=!1}sendMessage(e){var r,n;if(e.type!==Ye.INIT&&this._init!==Wt.OK){ge.error("impossible state, should not be calling postMessage until inited");return}const i=JSON.stringify(e);(r=window.ue)==null||(n=r.sequencewallettransport)==null||n.sendmessagetosequencejs(i)}}const j8="sequence-extension-message-handler";class Aye extends rp{constructor(e,r){super(e),this.runtime=r,this._init=Wt.OK}register(){this._registered=!0,this.port=this.runtime.connect({name:j8})}sendMessage(e){ge.info("[ExtensionMessageHandler send]",e),this.port.postMessage(e)}}class _U extends tp{constructor(e){super(),this.register=()=>{this._registered=!0},e.onConnect.addListener(r=>{r.name===j8&&(this._init=Wt.OK,r.onMessage.addListener(n=>{this.handleMessage(n)}))})}sendMessage(e){}unregister(){}openWallet(e,r,n){}closeWallet(){}}class _ye extends jb.EventEmitter2{constructor(e){var r;super(),r=this,this.responseCallbacks=new Map,this._messageIdx=0,this.nextMessageIdx=()=>++this._messageIdx,this.handleMessage=n=>{if(!n.type||!n.data)return;ge.info("[received message]",n);const i=n.idx,s=this.responseCallbacks.get(i);switch(i&&this.responseCallbacks.delete(i),n.type){case Ye.MESSAGE:if(s)this.emit(Ye.MESSAGE,n),s(n.data.error,n);else throw new Error("impossible state");break;case Ye.DISCONNECT:case Ye.ACCOUNTS_CHANGED:case Ye.CHAIN_CHANGED:this.emit(n.type,n.data);break;default:console.error("unknown message type",n);break}},this.sendMessageRequest=async function(n){return new Promise((i,s)=>{(!n.idx||n.idx<=0)&&s(new Error("message idx not set"));const o=(c,l)=>{if(c)s(c);else if(l)i(l);else throw new Error("no valid response to return")},{idx:a}=n;r.responseCallbacks.get(a)?s(new Error("duplicate message idx, should never happen")):r.responseCallbacks.set(a,o),r.sendMessage(n)})},this.stream=e,this.stream.on("data",this.handleMessage)}sendMessage(e){this.stream.writable||console.error("window post message stream is not writable"),this.stream.write(e)}}let wu;class PU extends tp{constructor(e){super(),this.register=()=>{wu&&(wu.unregister(),wu=this),window.addEventListener("message",this.onWindowEvent),wu=this,this.on("open",()=>{const r=this.walletWindow,n=setInterval(()=>{r&&r.closed&&(clearInterval(n),this.close())},500)}),this.on("close",()=>{this.walletWindow&&(this.walletWindow.close(),this.walletWindow=null)}),this._registered=!0},this.unregister=()=>{this._registered=!1,this.closeWallet(),wu===this&&(wu=void 0),window.removeEventListener("message",this.onWindowEvent),this.events.removeAllListeners()},this.openWallet=(r,n,i)=>{if(this.walletWindow&&this.isOpened()){this.walletWindow.focus();return}const s=new URL(this.walletURL.href),o=new ep;r&&r!==""&&(s.pathname=r.toLowerCase()),this._init=Wt.NIL,this._sessionId=`${performance.now()}`,o.set("sid",this._sessionId),n&&(n.type==="connect"&&(n.options||(n.options={app:window.location.origin}),!$y()&&!wU()&&n.options&&(n.options.origin=window.location.origin)),o.set("intent",o8(n))),i&&o.set("net",`${i}`);let a,c;$y()?(a=[450,750],c=[Math.abs(window.screen.width/2-a[0]/2),Math.abs(window.screen.height/2-a[1]/2)]):(a=[450,750],c=[Math.abs(window.screenX+window.innerWidth/2-a[0]/2),Math.abs(window.screenY+window.innerHeight/2-a[1]/2)]);const l=`toolbar=0,location=0,menubar=0,scrollbars=yes,status=yes,width=${a[0]},height=${a[1]},left=${c[0]},top=${c[1]}`;s.search=o.toString(),this.walletWindow=window.open(s.href,"sequence.app",l)},this.onWindowEvent=r=>{if(r.origin!==this.walletURL.origin)return;let n;try{n=JSON.parse(r.data)}catch{return}if(!n)throw new Error("ProviderMessage object is empty");this.handleMessage(n)},this.walletURL=new URL(e)}closeWallet(){var e;this.close(),(e=this.walletWindow)==null||e.close()}sendMessage(e){if(!this.walletWindow){ge.warn("WindowMessageProvider: sendMessage failed as walletWindow is unavailable");return}const r=typeof e!="string"?JSON.stringify(e):e;this.walletWindow.postMessage(r,this.walletURL.origin)}}class Pye extends rp{constructor(e){var r;super(e),r=this,this._isPopup=!1,this.onWindowEvent=async function(n){if(!n.origin||n.origin===""||r.appOrigin&&n.origin!==r.appOrigin)return;let i;try{i=JSON.parse(n.data)}catch{return}if(ge.debug("RECEIVED MESSAGE",i),r._init!==Wt.OK&&r.isValidInitAck(i)&&(r.appOrigin=n.origin),r._init===Wt.OK&&(!r.appOrigin||r.appOrigin.length<8)){ge.error("impossible state, init.OK and appOrigin required");return}r.handleMessage(i)},this.getWindowTransportSession=n=>{const i=new ep(n);return{sessionId:i.get("sid"),networkId:i.get("net"),intent:a8(i.get("intent"))}},this._init=Wt.NIL}async register(e){const r=parent.window.opener!==null;if(this._isPopup=r,r!==!0)return;const{pathname:n,search:i}=new URL(e||window.location.href);let s=this.getWindowTransportSession(i);if(!!s.sessionId||(s=await this.getCachedTransportSession()),!s){ge.error("window session is undefined");return}this.parentWindow=parent.window.opener,window.addEventListener("message",this.onWindowEvent,!1),this._registered=!0,this.open(s).then(a=>{if(!a){var c;const l=`failed to open to network ${(c=s)==null?void 0:c.networkId}`;ge.error(l),this.notifyClose({message:l}),window.close()}}).catch(a=>{var c;const l=`failed to open to network ${(c=s)==null?void 0:c.networkId}, due to: ${a}`;ge.error(l),this.notifyClose({message:l}),window.close()})}unregister(){window.removeEventListener("message",this.onWindowEvent),this._registered=!1}sendMessage(e){const r=JSON.stringify(e);e.type===Ye.INIT?this.postMessage(r,!0):this.postMessage(r)}get isPopup(){return this._isPopup}postMessage(e,r=!1){if(r!==!0&&this._init!==Wt.OK){ge.error("impossible state, should not be calling postMessage until inited");return}r?this.parentWindow.postMessage(e,"*"):this.appOrigin&&this.appOrigin.length>4?this.parentWindow.postMessage(e,this.appOrigin):ge.error("unable to postMessage as parentOrigin is invalid")}}function TU(t){return t&&typeof t=="object"&&(t.windowTransport&&typeof t.windowTransport=="object"||t.proxyTransport&&typeof t.proxyTransport=="object"||t.extensionTransport&&typeof t.extensionTransport=="object"||t.unrealTransport&&typeof t.unrealTransport=="object")&&(t.windowTransport&&t.windowTransport.enabled||t.proxyTransport&&t.proxyTransport.enabled||t.extensionTransport&&t.extensionTransport.enabled||t.unrealTransport&&t.unrealTransport.enabled)}class zb{constructor(...e){var r=this;this.register=()=>{if(this.messageProviders.length===1){this.provider=this.messageProviders[0],this.provider.register();return}this.messageProviders.forEach(n=>{n.register(),n.once("open",()=>{this.provider||(this.provider=n,this.messageProviders.forEach(i=>{this.provider!==i&&i.unregister()}))})})},this.unregister=()=>{this.messageProviders.forEach(n=>n.unregister()),this.provider=void 0},this.openWallet=(n,i,s)=>{if(this.provider){this.provider.openWallet(n,i,s);return}this.messageProviders.forEach(o=>o.openWallet(n,i,s))},this.sendAsync=async function(n,i,s){if(r.provider){r.provider.sendAsync(n,i,s);return}throw new Error("impossible state, wallet must be opened first")},this.sendMessageRequest=async function(n){if(r.provider)return r.provider.sendMessageRequest(n);throw new Error("impossible state, wallet must be opened first")},this.waitUntilOpened=async function(){return r.provider?r.provider.waitUntilOpened():Promise.race(r.messageProviders.map(n=>n.waitUntilOpened()))},this.waitUntilConnected=async function(){if(r.provider)return r.provider.waitUntilConnected();throw new Error("impossible state, wallet must be opened first")},this.messageProviders=e,this.provider=void 0}static new(e){var r,n,i,s;const o=new zb;if((r=e.windowTransport)!=null&&r.enabled&&typeof window=="object"&&e.walletAppURL){const a=new PU(e.walletAppURL);o.add(a)}if((n=e.proxyTransport)!=null&&n.enabled){const a=new SU(e.proxyTransport.appPort);o.add(a)}if((i=e.extensionTransport)!=null&&i.enabled){const a=new _U(e.extensionTransport.runtime);o.add(a)}if((s=e.unrealTransport)!=null&&s.enabled&&e.windowTransport&&e.walletAppURL){const a=new AU(e.walletAppURL);o.add(a)}return o.register(),o}add(...e){this.messageProviders.push(...e)}closeWallet(){this.provider&&this.provider.closeWallet()}isOpened(){return this.provider?this.provider.isOpened():!1}isConnected(){return this.provider?this.provider.isConnected():!1}on(e,r){if(this.provider){this.provider.on(e,r);return}this.messageProviders.forEach(n=>{n.on(e,r)})}once(e,r){if(this.provider){this.provider.once(e,r);return}this.messageProviders.forEach(n=>{n.once(e,r)})}emit(e,...r){if(this.provider)return this.provider.emit(e,...r);for(let n=0;nOye(t,i))}function Oye(t,e){if(e.to.toLowerCase()===t.toLowerCase()&&e.data){const r=re(e.data);if(r.length>=4&&!Rye(r))throw new Error("self calls are forbidden")}if(e.delegateCall)throw new Error("delegate calls are forbidden")}function Rye(t){const e=new jr(rn.mainModule.abi);try{return e.decodeFunctionData("createContract",t),!0}catch{return!1}}const $ye=1e4;class Mye{constructor(e,r,n){var i=this;this.signerReadyCallbacks=[],this.events=new jb.EventEmitter2,this.onConnectOptionsChange=void 0,this.promptConnect=async function(s){if(!s&&!i._connectOptions)throw new Error("prompter connect options are empty");if(!i.prompter)return i.connect(s);const o=await i.prompter.promptConnect(s||i._connectOptions).catch(c=>({connected:!1})),a=o;return a.connected&&!a.session&&(a.session=await i.walletSession(s==null?void 0:s.networkId)),o},this.sendAsync=async function(s,o,a){const c={jsonrpc:"2.0",id:s.id,result:null};await i.getAccount();try{var l;if((!i.account||i.account===null)&&!Nye.includes(s.method))throw vU;const f=i.account;if(!f)throw new Error("WalletRequestHandler: wallet account is not configured");const d=(l=i.account)==null?void 0:l.providerFor(a??i.defaultChainId());if(!d)throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${a}`);const h=d instanceof Ko?d:void 0;switch(s.method){case"net_version":{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send("net_version",[]);c.result=p;break}case"eth_chainId":{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send("eth_chainId",[]);c.result=p;break}case"eth_accounts":{const p=f.address;c.result=[p];break}case"eth_getBalance":{const[p,v]=s.params,b=await d.getBalance(p,v);c.result=b.toHexString();break}case"sequence_sign":case"personal_sign":case"eth_sign":{let p;switch(s.method){case"sequence_sign":case"personal_sign":{const[m,g]=s.params;p=m;break}case"eth_sign":{const[m,g]=s.params;p=g;break}}let v="";const b=Ub(p),y=s.method==="sequence_sign";if(i.prompter===null?v=await f.signMessage(b,a??i.defaultChainId(),y?"eip6492":"ignore"):v=await i.prompter.promptSignMessage({chainId:a,message:b,eip6492:y},i.connectOptions),v&&v.length>0)c.result=v;else throw new Error("declined by user");break}case"sequence_signTypedData_v4":case"eth_signTypedData":case"eth_signTypedData_v4":{const[p,v]=s.params;let b;if(typeof v=="string")try{b=JSON.parse(v)}catch(g){console.warn("walletRequestHandler: error parsing typedData",g)}else b=v;if(!b||!b.domain||!b.types||!b.message)throw new Error("invalid typedData object");let y="";const m=s.method==="sequence_signTypedData_v4";if(i.prompter===null?y=await f.signTypedData(b.domain,b.types,b.message,a??i.defaultChainId(),m?"eip6492":"ignore"):y=await i.prompter.promptSignMessage({chainId:a,typedData:b,eip6492:m},i.connectOptions),y&&y.length>0)c.result=y;else throw new Error("declined by user");break}case"eth_sendTransaction":{const p=Iye(s.params[0]).map(b=>("gas"in b&&b.gasLimit===void 0&&(b.gasLimit=b.gas,delete b.gas),b));HT(f.address,p);let v="";if(i.prompter===null){var u;const b=await f.sendTransaction(p,a??i.defaultChainId());v=(u=b==null?void 0:b.hash)!=null?u:""}else v=await i.prompter.promptSendTransaction(p,a,i.connectOptions);if(v)c.result=v;else throw new Error("declined by user");break}case"eth_signTransaction":{const[p]=s.params;if(Ve(p.from)!==f.address)throw new Error("sender address does not match wallet");HT(f.address,p),i.prompter===null?c.result=await f.signTransactions(p,a??i.defaultChainId()):c.result=await i.prompter.promptSignTransaction(p,a,i.connectOptions);break}case"eth_sendRawTransaction":{if(he.transaction.isSignedTransactionBundle(s.params[0])){const p=J.from(s.params[0].chainId).toNumber(),v=await f.relayer(p).relay(s.params[0]);c.result=v.hash}else{const p=await d.sendTransaction(s.params[0]);c.result=p.hash}break}case"eth_getTransactionCount":{const p=Ve(s.params[0]),v=s.params[1],b=await d.getTransactionCount(p,v);c.result=J.from(b).toHexString();break}case"eth_blockNumber":{c.result=await d.getBlockNumber();break}case"eth_getBlockByNumber":{c.result=await d.getBlock(s.params[0]);break}case"eth_getBlockByHash":{c.result=await d.getBlock(s.params[0]);break}case"eth_getTransactionByHash":{c.result=await d.getTransaction(s.params[0]);break}case"eth_call":{const[p,v]=s.params;c.result=await d.call(p,v);break}case"eth_getCode":{const[p,v]=s.params;c.result=await d.getCode(p,v);break}case"eth_estimateGas":{const[p]=s.params;c.result=await d.estimateGas(p);break}case"eth_gasPrice":{const p=await d.getGasPrice();c.result=p.toHexString();break}case"wallet_switchEthereumChain":{const[p]=s.params;if(!p.chainId||p.chainId.length===0)throw new Error("invalid chainId");const v=J.from(p.chainId);i.setDefaultChainId(v.toNumber()),c.result=null;break}case"sequence_getWalletContext":{c.result=f.contexts;break}case"sequence_getWalletConfig":{const[p]=s.params;p?c.result=[(await f.status(p)).onChain.config]:c.result=await Promise.all(f.networks.map(async function(v){return(await f.status(v.chainId)).onChain.config}));break}case"sequence_getWalletState":{const[p]=s.params;p?c.result=[qT(p,await f.status(p))]:c.result=await Promise.all(f.networks.map(async function(v){const b=await f.status(v.chainId);return qT(v.chainId,b)}));break}case"sequence_getNetworks":{c.result=await i.getNetworks(!0);break}case"sequence_isSequence":{c.result=!0;break}case"sequence_updateConfig":throw new Error("sequence_updateConfig method is not allowed from a dapp");case"sequence_publishConfig":throw new Error("sequence_publishConfig method is not allowed from a dapp");case"sequence_gasRefundOptions":break;case"sequence_getNonce":break;case"sequence_relay":break;case"sequence_setDefaultNetwork":{const[p]=s.params;if(!p)throw new Error("invalid request, method argument defaultChainId cannot be empty");i.setDefaultChainId(p),c.result=await i.getNetworks(!0);break}default:{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send(s.method,s.params);c.result=p}}}catch(f){ge.error(f),c.result=null,c.error=Jn({},new Error(f),{code:4001})}o(void 0,c)},this.isSignedIn=async function(){return await i.signerReady(),!!i.account},this.getAccount=async function(){if(await i.signerReady(),i.account===void 0)throw new Error("signerReady failed resolve");return i.account},this.account=e,this.prompter=r,this.networks=n}defaultChainId(){var e,r;return(e=(r=this.prompter)==null?void 0:r.getDefaultChainId())!=null?e:this.networks[0].chainId}async signIn(e,r={}){this.setAccount(e);const{connect:n,defaultNetworkId:i}=r;if(n){const a=this._connectOptions;let c;if(this.prompter!==null){var s;c=await((s=this.prompter)==null?void 0:s.promptSignInConnect(a))}else c=await this.connect(a);this.notifyConnect(c),(!a||a.keepWalletOpened!==!0)&&this.notifyClose()}if(i&&this.defaultChainId()!==i){var o;await((o=this.prompter)==null?void 0:o.promptChangeNetwork(i))}}signOut(){this.setAccount(null)}signerReset(){this.account=void 0}signerReady(e=$ye){return new Promise((r,n)=>{this.account!==void 0?r():(setTimeout(()=>{this.account===void 0&&(this.signerReadyCallbacks=[],n("signerReady timed out"))},e),this.signerReadyCallbacks.push(r))})}async connect(e){var r,n;if(!this.account)return{connected:!1,chainId:"0x0",error:"unable to connect without signed in account"};const i=(r=(n=e==null?void 0:e.networkId)!=null?n:this.defaultChainId())!=null?r:ce.MAINNET,s=d8(i).chainId,o={connected:!0,chainId:Es(s)};if(e&&e.authorize){const a={app:e.app,origin:e.origin,expiry:e.expiry,nonce:e.authorizeNonce};try{o.proof=await nU(this.account,s,a)}catch(c){return ge.warn(`connect, signAuthorization failed for options: ${JSON.stringify(e)}, due to: ${c.message}`),{connected:!1,chainId:"0x0",error:`signAuthorization failed: ${c.message}`}}}return o.session=this.walletSession(s),o}sendMessageRequest(e){return new Promise(r=>{this.sendAsync(e.data,(n,i)=>{const s=Jn({},e,{data:i});r(s)},e.chainId)})}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}async getAddress(){var e,r;return(e=(r=this.account)==null?void 0:r.address)!=null?e:""}get openIntent(){return this._openIntent}setOpenIntent(e){this._openIntent=e}get connectOptions(){return this._connectOptions}setConnectOptions(e){var r;this._connectOptions=e,(r=this.onConnectOptionsChange)==null||r.call(this,e)}async setDefaultChainId(e){var r;return await((r=this.prompter)==null?void 0:r.promptChangeNetwork(e)),this.defaultChainId()}async getNetworks(e){return this.account?e?this.account.networks.map(r=>{const n=Jn({},r);return n.provider=void 0,n.relayer=void 0,n}):this.account.networks:(ge.warn("signer not set: getNetworks is returning an empty list"),[])}walletSession(e){if(!this.account)return;const r={walletContext:this.account.contexts,accountAddress:this.account.address,networks:this.account.networks.map(i=>Jn({},i,{provider:void 0,relayer:void 0}))};if(e){const i=xs(r.networks,e);if(i){var n;(n=r.networks)==null||n.forEach(s=>delete s.isDefaultChain),i.isDefaultChain=!0}}return r}notifyConnect(e,r){var n;if(console.log("emit connect",e),this.events.emit("connect",e),(n=e.session)!=null&&n.accountAddress){var i;this.events.emit("accountsChanged",[(i=e.session)==null?void 0:i.accountAddress],r)}}notifyDisconnect(e){this.events.emit("accountsChanged",[],e),this.events.emit("disconnect",void 0,e)}notifyChainChanged(e,r){this.events.emit("chainChanged",Es(e),r)}async notifyNetworks(e){const r=e||await this.getNetworks(!0);if(this.events.emit("networks",r),r.length>0){const n=r.find(i=>i.chainId===this.defaultChainId());n&&this.events.emit("chainChanged",Es(n.chainId))}else this.events.emit("chainChanged","0x0")}async notifyWalletContext(){if(!this.account){ge.warn("signer not set: skipping to notify wallet context");return}const e=this.account.contexts;this.events.emit("walletContext",e)}notifyClose(e){this.events.emit("close",e)}setAccount(e){if(this.account=e,e!==void 0){for(let r=0;rc.canOnchainValidate||c.original.version===2&&n,o=await r.status(i);if(s(o))return!0;if(await e.promptConfirmWalletDeploy(i,this.connectOptions)){const c=await r.status(i);return s(c)?!0:(ge.error("WalletRequestHandler: result for promptConfirmWalletDeploy is not correct"),!1)}return!1}}function qT(t,e){return{context:e.original.context,config:e.onChain.config,address:he.context.addressOf(e.original.context,e.original.imageHash),chainId:t,deployed:e.onChain.deployed,imageHash:e.imageHash,lastImageHash:e.onChain.imageHash,published:!0,status:e}}const Nye=["net_version","eth_chainId","eth_getBalance","eth_getTransactionCount","eth_blockNumber","eth_getBlockByNumber","eth_getBlockByHash","eth_getTransactionByHash","eth_getCode","eth_estimateGas","eth_gasPrice","sequence_getWalletContext","sequence_getNetworks","sequence_setDefaultNetwork"];class _d{get utils(){return this.provider.utils}constructor(e,r){this.singleNetworkSigners={},this._isSigner=!0,this._isSequenceSigner=!0,this.client=e,this.provider=r}async getAddress(){return this.client.getAddress()}connect(e){if(!Pd.is(e))throw new Error("SequenceSigner can only be connected to a SequenceProvider");return new _d(this.client,e)}getSigner(e){if(!e)return this;const r=this.provider.toChainId(e);return this.singleNetworkSigners[r]||(this.singleNetworkSigners[r]=new U8(this.client,this.provider,r)),this.singleNetworkSigners[r]}useChainId(e){return this.provider.toChainId(e)||this.client.getChainId()}async signMessage(e,r){const{eip6492:n=!0}=r||{},i=this.useChainId(r==null?void 0:r.chainId);return this.client.signMessage(e,{eip6492:n,chainId:i})}async signTypedData(e,r,n,i){const{eip6492:s=!0}=i||{},o=this.useChainId(i==null?void 0:i.chainId);return this.client.signTypedData({domain:e,types:r,message:n},{eip6492:s,chainId:o})}getProvider(e){return this.provider.getProvider(e)}async sendTransaction(e,r){const n=this.useChainId(r==null?void 0:r.chainId),i=await CU(e),s=await this.client.sendTransaction(i,{chainId:n}),o=this.getProvider(n);try{return await Wa(async function(){const a=await o.getTransaction(s);return a?o._wrapTransaction(a,s):void 0},{onceBlock:o})}catch(a){throw a.transactionHash=s,a}}async getWalletConfig(e){const r=this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}getNetworks(){return this.client.getNetworks()}async getBalance(e,r){return this.getProvider(r==null?void 0:r.chainId).getBalance(this.getAddress(),e)}async estimateGas(e,r){return this.getProvider(r==null?void 0:r.chainId).estimateGas(e)}async call(e,r,n){return this.getProvider(n==null?void 0:n.chainId).call(e,r)}getChainId(){return Promise.resolve(this.client.getChainId())}async getGasPrice(e){return this.getProvider(e==null?void 0:e.chainId).getGasPrice()}async getFeeData(e){return this.getProvider(e==null?void 0:e.chainId).getFeeData()}async resolveName(e){const r=await this.provider.resolveName(e);if(r===null)throw new Error(`ENS name not found: ${e}`);return r}_checkProvider(e){}populateTransaction(e){throw new Error("SequenceSigner does not support populateTransaction")}checkTransaction(e){throw new Error("SequenceSigner does not support checkTransaction")}getTransactionCount(e){throw new Error("SequenceSigner does not support getTransactionCount")}signTransaction(e){throw new Error("SequenceWallet does not support signTransaction, use sendTransaction instead.")}static is(e){return e&&typeof e=="object"&&e._isSequenceSigner===!0}}class U8 extends _d{constructor(e,r,n){super(e,r.getProvider(n)),this._isSingleNetworkSequenceSigner=!0,this.chainId=n}_useChainId(e){const r=this.provider.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This signer only supports the network ${this.chainId}, but ${r} was requested.`);return r||this.provider.toChainId(this.chainId)}useChainId(e){return this._useChainId(e)}getChainId(){return Promise.resolve(this.provider.toChainId(this.chainId))}getProvider(e){return super.getProvider(this._useChainId(e))}getSigner(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceSigner===!0}}class Dye{constructor(e){if(this.signer=e,U8.is(e))throw new Error("WalletUtils does not support SingleNetworkSequenceSigner")}signMessage(e,r,n){return this.signer.signMessage(e,{chainId:r,eip6492:n})}signTypedData(e,r,n,i,s){return this.signer.signTypedData(e,r,n,{chainId:i,eip6492:s})}async isValidSignature(e,r,n,i){return Qf(e,r,n,this.signer.getProvider(i))}async isValidMessageSignature(e,r,n,i){const s=this.signer.getProvider(i),o=Ub(r),a=c8(o);return Qf(e,a,n,s)}isValidTypedDataSignature(e,r,n,i){return this.isValidSignature(e,Q1(r),n,i)}}class Pd extends Og{constructor(e,r,n=Vf){super(e.getChainId()),this.singleNetworkProviders={},this._isSequenceProvider=!0,this.client=e,this.providerFor=r,this.networks=n,e.onConnect(i=>{this.emit("connect",i)}),e.onDisconnect(i=>{this.emit("disconnect",i)}),e.onDefaultChainIdChanged(i=>{this.emit("chainChanged",i)}),e.onAccountsChanged(i=>{this.emit("accountsChanged",i)}),this.signer=new _d(this.client,this),this.utils=new Dye(this.signer)}getSigner(e){return this.signer.getSigner(e)}connect(e){return this.client.connect(e)}disconnect(){return this.client.disconnect()}isConnected(){return this.client.isConnected()}getSession(){return this.client.getSession()}listAccounts(){return[this.client.getAddress()]}getAddress(){return this.client.getAddress()}getNetworks(){return this.client.getNetworks()}getChainId(){return this.client.getChainId()}setDefaultChainId(e){return this.client.setDefaultChainId(this.toChainId(e))}isOpened(){return this.client.isOpened()}closeWallet(){return this.client.closeWallet()}getWalletContext(){return this.client.getWalletContext()}async getWalletConfig(e){const r=await this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}authorize(e){return this.client.connect(Jn({},e,{authorize:!0}))}async openWallet(e,r){return await this.client.openWallet(e,r),!0}toChainId(e){if(e===void 0)return;const r=xs(this.networks,e);if(!r)throw new Error(`Unsupported network ${e}`);return r.chainId}async useChainId(e){return this.toChainId(e)||this.client.getChainId()}getProvider(e){if(!e)return this;const r=this.toChainId(e);return this.singleNetworkProviders[r]||(this.singleNetworkProviders[r]=new OU(this.client,this.providerFor,r)),this.singleNetworkProviders[r]}async _getSubprovider(e){const r=await this.useChainId(e),n=this.providerFor(r);if(!n)throw new Error(`Unsupported network ${r}`);return n}async perform(e,r){var n;if(e==="eth_chainId")return Es(await this.useChainId());if(e==="eth_accounts")return[this.client.getAddress()];if(e==="wallet_switchEthereumChain"){const o=r[0],a=IU(o);return this.setDefaultChainId(a)}if(e==="eth_sendTransaction"||e==="eth_sign"||e==="eth_signTypedData"||e==="eth_signTypedData_v4"||e==="personal_sign"||e==="sequence_sign"||e==="sequence_signTypedData_v4")return this.client.send({method:e,params:r},this.getChainId());const i=await this._getSubprovider(),s=(n=i.prepareRequest(e,r))!=null?n:[e,r];return i.send(s[0],s[1])}send(e,r){return this.perform(e,r)}request(e){return this.perform(e.method,e.params)}async detectNetwork(){const e=this.client.getChainId(),r=xs(this.networks,e);if(!r)throw new Error(`Unknown network ${e}`);return r}async waitForTransaction(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).waitForTransaction(e,r,n)}async getBlockNumber(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getBlockNumber()}async getGasPrice(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getGasPrice()}async getBalance(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBalance(e,r)}async getTransactionCount(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getTransactionCount(e,r)}async getCode(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getCode(e,r)}async getStorageAt(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).getStorageAt(e,r,n)}async call(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).call(e,r)}async estimateGas(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).estimateGas(e)}async getBlock(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getBlock(e)}async getTransaction(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getTransaction(e)}async getLogs(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getLogs(e)}async supportsENS(){return(await this.getNetworks()).some(r=>r.chainId===1)}async getResolver(e){return await this.supportsENS()?(await this._getSubprovider(1)).getResolver(e):null}async resolveName(e){return UR(await e)?e:await this.supportsENS()?(await this._getSubprovider(1)).resolveName(e):null}async lookupAddress(e){return await this.supportsENS()?(await this._getSubprovider(1)).lookupAddress(e):null}async getAvatar(e){return await this.supportsENS()?(await this._getSubprovider(1)).getAvatar(e):null}}Pd.is=t=>t&&typeof t=="object"&&t._isSequenceProvider===!0;function IU(t){return typeof t=="object"?IU(t.chainId):J.from(t).toNumber()}class OU extends Pd{constructor(e,r,n){super(e,r),this._isSingleNetworkSequenceProvider=!0,this.chainId=n}_useChainId(e){const r=this.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This provider only supports the network ${this.chainId}, but ${r} was requested.`);return r||super.toChainId(this.chainId)}useChainId(e){return Promise.resolve(this._useChainId(e))}getChainId(){return super.toChainId(this.chainId)}async getNetwork(){const e=await this.client.getNetworks(),r=xs(e,this.chainId);if(!r)throw new Error(`Unsupported network ${this.chainId}`);return r}getProvider(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}getSigner(e){return super.getSigner(this._useChainId(e))}setDefaultChainId(e){throw new Error(`This provider only supports the network ${this.chainId}; use the parent provider to switch networks.`)}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceProvider===!0}}var Lye={name:"@0xsequence/provider",version:"1.4.9",description:"provider sub-package for Sequence",repository:"https://github.com/0xsequence/sequence.js/tree/master/packages/provider",source:"src/index.ts",main:"dist/0xsequence-provider.cjs.js",module:"dist/0xsequence-provider.esm.js",author:"Horizon Blockchain Games",license:"Apache-2.0",scripts:{test:"pnpm test:concurrently 'pnpm test:run'","test:run":"pnpm test:file tests/**/*.spec.ts","test:file":"NODE_OPTIONS='--loader tsx' mocha --timeout 30000",typecheck:"tsc --noEmit","test:concurrently":"concurrently -k --success first 'pnpm start:hardhat1' 'pnpm start:hardhat2'","start:hardhat1":"pnpm start:hardhat1:verbose > /dev/null 2>&1","start:hardhat2":"pnpm start:hardhat2:verbose > /dev/null 2>&1","start:hardhat1:verbose":"hardhat node --config hardhat1.config.js --hostname 0.0.0.0 --port 9595","start:hardhat2:verbose":"hardhat node --config hardhat2.config.js --hostname 0.0.0.0 --port 8595"},dependencies:{"@0xsequence/abi":"workspace:*","@0xsequence/account":"workspace:*","@0xsequence/auth":"workspace:*","@0xsequence/core":"workspace:*","@0xsequence/migration":"workspace:*","@0xsequence/network":"workspace:*","@0xsequence/relayer":"workspace:*","@0xsequence/utils":"workspace:*","@0xsequence/wallet":"workspace:*",eventemitter2:"^6.4.5","webextension-polyfill":"^0.10.0"},peerDependencies:{ethers:">=5.5 < 6"},devDependencies:{"@types/webextension-polyfill":"^0.10.0",hardhat:"^2.12.2",ethers:"^5.7.2"},files:["src","dist"]};class Sl{constructor(e){this.store=e}connectedSession(){const e=this.getSession();if(e&&e.accountAddress&&e.walletContext&&e.networks)return{accountAddress:e.accountAddress,walletContext:e.walletContext,networks:e.networks};throw new Error("Sequence session not connected")}hasSession(){var e;return((e=this.getSession())==null?void 0:e.accountAddress)!==void 0}setSession(e){return this.store.setItem(Sl.SESSION_LOCALSTORE_KEY,JSON.stringify(e))}getSession(){const e=this.store.getItem(Sl.SESSION_LOCALSTORE_KEY);if(e)return JSON.parse(e)}async clearSession(){return this.store.removeItem(Sl.SESSION_LOCALSTORE_KEY)}}Sl.SESSION_LOCALSTORE_KEY="@sequence.session";class kl{constructor(e,r=1){this.callbacks=[],this.store=e,this.startingChainId=r,e.onItemChange(kl.SESSION_CHAIN_ID_KEY,n=>{if(n){const i=parseInt(n);this.callbacks.forEach(s=>s(i))}})}onDefaultChainIdChanged(e){return this.callbacks.push(e),()=>{this.callbacks=this.callbacks.filter(r=>r!==e)}}setDefaultChainId(e){e!==this.getDefaultChainId()&&this.store.setItem(kl.SESSION_CHAIN_ID_KEY,e.toString())}getDefaultChainId(){const e=this.store.getItem(kl.SESSION_CHAIN_ID_KEY);return!e||e.length===0?this.startingChainId:parseInt(e)}}kl.SESSION_CHAIN_ID_KEY="@sequence.session.defaultChainId";class z8{constructor(e,r,n,i){var s;if(this.callbacks={},this.projectAccessKey=i,TU(e))this.transport=zb.new(e);else if(hU(e))this.transport=e;else throw new Error("Invalid transport");const o=typeof n=="number"?n:n==null?void 0:n.defaultChainId;this.defaultEIP6492=typeof n=="number"?!1:(s=n==null?void 0:n.defaultEIP6492)!=null?s:!1,this.session=new Sl(r),this.defaultChainId=new kl(r,o),this.transport.on("accountsChanged",a=>{var c;a.length>1&&console.warn("SequenceClient: wallet-webapp returned more than one account"),(c=this.callbacks.accountsChanged)==null||c.forEach(l=>l(a))}),this.transport.on("connect",a=>{var c;const l=Es(this.getChainId());(c=this.callbacks.connect)==null||c.forEach(u=>u(Jn({},a,{chainId:l})))}),this.transport.on("disconnect",(a,c)=>{var l;(l=this.callbacks.disconnect)==null||l.forEach(u=>u(a,c))}),this.transport.on("networks",a=>{var c;(c=this.callbacks.networks)==null||c.forEach(l=>l(a))}),this.transport.on("walletContext",a=>{var c;(c=this.callbacks.walletContext)==null||c.forEach(l=>l(a))}),this.transport.on("open",a=>{var c;(c=this.callbacks.open)==null||c.forEach(l=>l(a))}),this.transport.on("close",()=>{var a;(a=this.callbacks.close)==null||a.forEach(c=>c())}),this.transport.on("chainChanged",(a,c)=>{var l;(l=this.callbacks.chainChanged)==null||l.forEach(u=>u(a,c))}),this.defaultChainId.onDefaultChainIdChanged(a=>{var c;const l=Es(a);(c=this.callbacks.chainChanged)==null||c.forEach(u=>u(l))})}registerCallback(e,r){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(r),()=>{this.callbacks[e]=this.callbacks[e].filter(n=>n!==r)}}onOpen(e){return this.registerCallback("open",e)}onClose(e){return this.registerCallback("close",e)}onConnect(e){return this.registerCallback("connect",e)}onDisconnect(e){return this.registerCallback("disconnect",e)}onNetworks(e){return this.registerCallback("networks",e)}onAccountsChanged(e){return this.registerCallback("accountsChanged",e)}onWalletContext(e){return this.registerCallback("walletContext",e)}onChainChanged(e){return this.registerCallback("chainChanged",e)}onDefaultChainIdChanged(e){return this.registerCallback("chainChanged",e)}getChainId(){return this.defaultChainId.getDefaultChainId()}setDefaultChainId(e){return this.defaultChainId.setDefaultChainId(e)}async openWallet(e,r){return this.transport.openWallet(e,r,this.getChainId()),await this.transport.waitUntilOpened(),this.isOpened()}closeWallet(){return this.transport.closeWallet()}isOpened(){return this.transport.isOpened()}isConnected(){return this.session.hasSession()}getSession(){return this.session.getSession()}getAddress(){return this.session.connectedSession().accountAddress}async connect(e){if((e==null?void 0:e.authorizeVersion)===void 0&&(e.authorizeVersion=2),(e==null?void 0:e.refresh)===!0&&this.disconnect(),e.projectAccessKey=this.projectAccessKey,e&&e.authorize){if(!e.app)throw new Error("connecting with 'authorize' option also requires 'app' to be set");e.authorizeVersion===void 0&&(e.authorizeVersion=2)}await this.openWallet(void 0,{type:"connect",options:Jn({},e,{networkId:this.getChainId(),clientVersion:Lye.version})});const r=await this.transport.waitUntilConnected().catch(n=>n instanceof Error?{connected:!1,error:n.message}:{connected:!1,error:JSON.stringify(n)});if(r.chainId&&(r.chainId=J.from(r.chainId).toString()),r.connected){if(!r.session)throw new Error("impossible state, connect response is missing session");this.session.setSession(r.session)}return r}disconnect(){return this.isOpened()&&this.closeWallet(),this.session.clearSession()}send(e,r){return e.method=this.mapSignMethod(e.method),new Promise((n,i)=>{this.transport.sendAsync(e,(s,o)=>{s?i(s):o===void 0?i(new Error(`Got undefined response for request: ${e}`)):typeof o=="object"&&o.error?i(o.error):typeof o=="object"&&o.result?n(o.result):i(new Error(`Got invalid response for request: ${e}`))},r||this.getChainId())})}async getNetworks(e){const r=this.session.connectedSession();return e&&(r.networks=await this.send({method:"sequence_getNetworks"}),this.session.setSession(r)),r.networks}signMethod(e){return(e==null?void 0:e.eip6492)===void 0?"personal_sign":e.eip6492?"sequence_sign":"legacy_sign"}signTypedDataMethod(e){return(e==null?void 0:e.eip6492)===void 0?"eth_signTypedData_v4":e.eip6492?"sequence_signTypedData_v4":"legacy_signTypedData_v4"}mapSignMethod(e){return e==="personal_sign"?this.defaultEIP6492?"sequence_sign":"personal_sign":e==="eth_signTypedData_v4"?this.defaultEIP6492?"sequence_signTypedData_v4":"eth_signTypedData_v4":e==="legacy_sign"?"personal_sign":e==="legacy_signTypedData_v4"?"eth_signTypedData_v4":e}async signMessage(e,r){const n=this.signMethod(r);return this.send({method:n,params:[e,this.getAddress()]},r==null?void 0:r.chainId)}async signTypedData(e,r){const n=this.signTypedDataMethod(r),i=qr.getPayload(e.domain,e.types,e.message);return this.send({method:n,params:[this.getAddress(),i]},(r==null?void 0:r.chainId)||e.domain.chainId&&J.from(e.domain.chainId).toNumber()||this.getChainId())}async sendTransaction(e,r){const n=Array.isArray(e)?e:[e],i=Tye(n);return this.send({method:"eth_sendTransaction",params:[i]},r==null?void 0:r.chainId)}async getWalletContext(){return this.send({method:"sequence_getWalletContext"})}async getOnchainWalletConfig(e){const r=await this.send({method:"sequence_getWalletConfig",params:[(e==null?void 0:e.chainId)||this.getChainId()]},e==null?void 0:e.chainId);return Array.isArray(r)?r[0]:r}}const h5={transports:{walletAppURL:"https://sequence.app",windowTransport:{enabled:!0},proxyTransport:{enabled:!1}},defaultNetwork:1};let Js;const RU=t=>{var e,r,n;const i=t==null?void 0:t.projectAccessKey;if(i||console.warn("Please pass a projectAccessKey in initWallet config as it will be required in near future."),Js)return Js;const s=Jn({},h5,t,{transports:Jn({},h5.transports,t==null?void 0:t.transports)}),o={},a=(e=(r=s.networks)==null?void 0:r.filter(h=>{h.rpcUrl!==void 0&&h.chainId!==void 0&&Vf.find(p=>p.chainId===h.chainId)}))!=null?e:[],c=Vf.map(h=>{var p;const v=(p=s.networks)==null?void 0:p.find(b=>b.chainId===h.chainId);return v?Jn({},h,v):h}).concat(a).map(h=>{const p=i?`/${i}`:"";return h.rpcUrl=h.rpcUrl+p,h}),l=h=>{if(!o[h]){var p;const v=(p=c.find(m=>m.chainId===h))==null?void 0:p.rpcUrl;if(!v)throw new Error(`no rpcUrl found for chainId: ${h}`);const b=new Ko(v),y=new h8([YB,QB,new p8],new xy(b));o[h]=new tM(y,h)}return o[h]},u=s.defaultNetwork?(n=xs(c,s.defaultNetwork))==null?void 0:n.chainId:void 0;if(!u&&s.defaultNetwork)throw new Error(`defaultNetwork not found for chainId: ${s.defaultNetwork}`);const f=s.localStorage||My(),d=new z8(s.transports,f,{defaultChainId:u,defaultEIP6492:s.defaultEIP6492},i);return Js=new Pd(d,l),Js},$U=()=>{Js&&(Js.client.closeWallet(),Js.client.transport.unregister(),Js=void 0)},MU=()=>{if(!Js)throw new Error("Wallet has not been initialized, call sequence.initWallet(config) first.");return Js},Fye=Object.freeze(Object.defineProperty({__proto__:null,BaseInjectedTransport:_ye,BaseProviderTransport:tp,BaseWalletTransport:rp,CHANNEL_ID:j8,DefaultChainIdTracker:kl,DefaultProviderConfig:h5,ErrSignedInRequired:vU,EventType:Ye,ExtensionMessageHandler:Aye,ExtensionMessageProvider:_U,InitState:Wt,LocalStorage:c1,MemoryItemStore:xU,MuxMessageProvider:zb,OpenState:Ri,PROVIDER_OPEN_TIMEOUT:B8,ProviderError:pU,ProxyMessageChannel:Cye,ProxyMessageChannelPort:d5,ProxyMessageHandler:Sye,ProxyMessageProvider:SU,SequenceClient:z8,SequenceClientSession:Sl,SequenceProvider:Pd,SequenceSigner:_d,SingleNetworkSequenceProvider:OU,SingleNetworkSequenceSigner:U8,UnrealMessageHandler:kye,UnrealMessageProvider:AU,WalletRequestHandler:Mye,WindowMessageHandler:Pye,WindowMessageProvider:PU,WindowSessionParams:ep,getWallet:MU,initWallet:RU,isBrowserExtension:$y,isMuxTransportTemplate:TU,isProviderTransport:hU,isUnityPlugin:wU,isValidMessageSignature:gU,isValidSignature:Qf,isValidTypedDataSignature:bU,isWalletUpToDate:EU,messageToBytes:yU,nextMessageIdx:mU,prefixEIP191Message:Ub,resolveArrayProperties:CU,trimEIP191Prefix:xye,unregisterWallet:$U,useBestStore:My},Symbol.toStringTag,{value:"Module"}));function An(t,e){return e.forEach(function(r){r&&typeof r!="string"&&!Array.isArray(r)&&Object.keys(r).forEach(function(n){if(n!=="default"&&!(n in t)){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}})}),Object.freeze(t)}var Bye=An({__proto__:null},[R1e]),jye=An({__proto__:null},[B1e]),Uye=An({__proto__:null},[Zme]),zye=An({__proto__:null},[sye]),Wye=An({__proto__:null},[cme]),Hye=An({__proto__:null},[mme]),qye=An({__proto__:null},[pye]),Vye=An({__proto__:null},[Npe]),Gye=An({__proto__:null},[Fye]),Kye=An({__proto__:null},[qve]);const Qye=he.transaction;var Yye=Object.freeze({__proto__:null,transactions:Qye}),Jye=An({__proto__:null,isValidSignature:Qf,isValidMessageSignature:gU,isValidTypedDataSignature:bU,isWalletUpToDate:EU},[wpe]),Xye=An({__proto__:null},[Sve]),Zye=An({__proto__:null},[Vve]),ege=An({__proto__:null},[Yme]),tge=An({__proto__:null},[Ive]),rge=An({__proto__:null},[Zve]),NU=Object.freeze({__proto__:null,abi:Bye,api:jye,auth:Uye,guard:zye,indexer:Wye,metadata:Hye,multicall:qye,network:Vye,provider:Gye,relayer:Kye,transactions:Yye,utils:Jye,core:Xye,signhub:Zye,sessions:ege,migration:tge,account:rge,initWallet:RU,getWallet:MU,unregisterWallet:$U,SequenceProvider:Pd,SequenceClient:z8,SequenceSigner:_d}),bh,$u,nge=class extends j1{constructor({chains:t,options:e}){super({chains:t,options:{reloadOnDisconnect:!1,...e}}),Ke(this,"id","coinbaseWallet"),Ke(this,"name","Coinbase Wallet"),Ke(this,"ready",!0),Mr(this,bh,void 0),Mr(this,$u,void 0),Ke(this,"onAccountsChanged",r=>{r.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(r[0])})}),Ke(this,"onChainChanged",r=>{const n=El(r),i=this.isChainUnsupported(n);this.emit("change",{chain:{id:n,unsupported:i}})}),Ke(this,"onDisconnect",()=>{this.emit("disconnect")})}async connect({chainId:t}={}){try{const e=await this.getProvider();e.on("accountsChanged",this.onAccountsChanged),e.on("chainChanged",this.onChainChanged),e.on("disconnect",this.onDisconnect),this.emit("message",{type:"connecting"});const r=await e.enable(),n=Dn(r[0]);let i=await this.getChainId(),s=this.isChainUnsupported(i);return t&&i!==t&&(i=(await this.switchChain(t)).id,s=this.isChainUnsupported(i)),{account:n,chain:{id:i,unsupported:s}}}catch(e){throw/(user closed modal|accounts received is empty)/i.test(e.message)?new Pr(e):e}}async disconnect(){if(!We(this,$u))return;const t=await this.getProvider();t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect),t.disconnect(),t.close()}async getAccount(){const e=await(await this.getProvider()).request({method:"eth_accounts"});return Dn(e[0])}async getChainId(){const t=await this.getProvider();return El(t.chainId)}async getProvider(){var t;if(!We(this,$u)){let e=(await HS(()=>import("./index-748504a6.js").then(o=>o.i),["./index-748504a6.js","./events-d5745873.js","./index-cc134824.js"],import.meta.url)).default;typeof e!="function"&&typeof e.default=="function"&&(e=e.default),ys(this,bh,new e(this.options));const r=(t=We(this,bh).walletExtension)==null?void 0:t.getChainId(),n=this.chains.find(o=>this.options.chainId?o.id===this.options.chainId:o.id===r)||this.chains[0],i=this.options.chainId||(n==null?void 0:n.id),s=this.options.jsonRpcUrl||(n==null?void 0:n.rpcUrls.default.http[0]);ys(this,$u,We(this,bh).makeWeb3Provider(s,i))}return We(this,$u)}async getWalletClient({chainId:t}={}){const[e,r]=await Promise.all([this.getProvider(),this.getAccount()]),n=this.chains.find(i=>i.id===t);if(!e)throw new Error("provider is required.");return K1({account:r,chain:n,transport:kb(e)})}async isAuthorized(){try{return!!await this.getAccount()}catch{return!1}}async switchChain(t){var n;const e=await this.getProvider(),r=Ue(t);try{return await e.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]}),this.chains.find(i=>i.id===t)??{id:t,name:`Chain ${r}`,network:`${r}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}}}catch(i){const s=this.chains.find(o=>o.id===t);if(!s)throw new uF({chainId:t,connectorId:this.id});if(i.code===4902)try{return await e.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((n=s.rpcUrls.public)==null?void 0:n.http[0])??""],blockExplorerUrls:this.getBlockExplorerUrls(s)}]}),s}catch(o){throw new Pr(o)}throw new ea(i)}}async watchAsset({address:t,decimals:e=18,image:r,symbol:n}){return(await this.getProvider()).request({method:"wallet_watchAsset",params:{type:"ERC20",options:{address:t,decimals:e,image:r,symbol:n}}})}};bh=new WeakMap;$u=new WeakMap;var Jv,ige=class extends XF{constructor({chains:t,options:e}={}){const r={name:"MetaMask",shimDisconnect:!0,getProvider(){function n(s){if(s!=null&&s.isMetaMask&&!(s.isBraveWallet&&!s._events&&!s._state)&&!s.isApexWallet&&!s.isAvalanche&&!s.isBitKeep&&!s.isBlockWallet&&!s.isMathWallet&&!(s.isOkxWallet||s.isOKExWallet)&&!(s.isOneInchIOSWallet||s.isOneInchAndroidWallet)&&!s.isOpera&&!s.isPortal&&!s.isRabby&&!s.isDefiant&&!s.isTokenPocket&&!s.isTokenary&&!s.isZerion)return s}if(typeof window>"u")return;const i=window.ethereum;return i!=null&&i.providers?i.providers.find(n):n(i)},...e};super({chains:t,options:r}),Ke(this,"id","metaMask"),Ke(this,"shimDisconnectKey",`${this.id}.shimDisconnect`),Mr(this,Jv,void 0),ys(this,Jv,r.UNSTABLE_shimOnConnectSelectAccount)}async connect({chainId:t}={}){var e,r,n,i;try{const s=await this.getProvider();if(!s)throw new Ma;s.on&&(s.on("accountsChanged",this.onAccountsChanged),s.on("chainChanged",this.onChainChanged),s.on("disconnect",this.onDisconnect)),this.emit("message",{type:"connecting"});let o=null;if(We(this,Jv)&&((e=this.options)!=null&&e.shimDisconnect)&&!((r=this.storage)!=null&&r.getItem(this.shimDisconnectKey))&&(o=await this.getAccount().catch(()=>null),!!o))try{await s.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),o=await this.getAccount()}catch(u){if(this.isUserRejectedRequestError(u))throw new Pr(u);if(u.code===new mc(u).code)throw u}if(!o){const l=await s.request({method:"eth_requestAccounts"});o=Dn(l[0])}let a=await this.getChainId(),c=this.isChainUnsupported(a);return t&&a!==t&&(a=(await this.switchChain(t)).id,c=this.isChainUnsupported(a)),(n=this.options)!=null&&n.shimDisconnect&&((i=this.storage)==null||i.setItem(this.shimDisconnectKey,!0)),{account:o,chain:{id:a,unsupported:c},provider:s}}catch(s){throw this.isUserRejectedRequestError(s)?new Pr(s):s.code===-32002?new mc(s):s}}};Jv=new WeakMap;var nl,Bs,sge=class{constructor(t){Ke(this,"events",new JL),Ke(this,"chainId"),Mr(this,nl,void 0),Mr(this,Bs,void 0),this.chainId=t.chainId,ys(this,nl,t)}async enable(){var e;if((e=We(this,nl).flags)!=null&&e.failConnect)throw new Pr(new Error("Failed to connect."));We(this,Bs)||ys(this,Bs,We(this,nl).walletClient);const t=We(this,Bs).account.address;return this.events.emit("accountsChanged",[t]),[t]}async disconnect(){this.events.emit("disconnect"),ys(this,Bs,void 0)}async getAccounts(){var e;const t=(e=We(this,Bs))==null?void 0:e.account.address;return t?[Dn(t)]:[]}getWalletClient(){const t=We(this,Bs);if(!t)throw new Error("walletClient not found");return t}async switchChain(t){var e;if((e=We(this,nl).flags)!=null&&e.failSwitchChain)throw new Pr(new Error("Failed to switch chain."));We(this,nl).chainId=t,this.chainId=t,this.events.emit("chainChanged",t)}async switchWalletClient(t){const e=t.account.address;ys(this,Bs,t),this.events.emit("accountsChanged",[e])}async watchAsset(t){return!0}async request({method:t,params:e}){var r;return(r=We(this,Bs))==null?void 0:r.transport.request({method:t,params:e})}on(t,e){return this.events.on(t,e),this}removeListener(t,e){return this.events.removeListener(t,e),this}toJSON(){return""}};nl=new WeakMap;Bs=new WeakMap;var wh,p5,DU,oge=class extends j1{constructor({chains:t,options:e}){var r;super({chains:t,options:{...e,chainId:e.chainId??((r=t==null?void 0:t[0])==null?void 0:r.id)}}),Mr(this,p5),Ke(this,"id","mock"),Ke(this,"name","Mock"),Ke(this,"ready",!0),Mr(this,wh,void 0),Ke(this,"onAccountsChanged",n=>{n.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(n[0])})}),Ke(this,"onChainChanged",n=>{const i=El(n),s=this.isChainUnsupported(i);this.emit("change",{chain:{id:i,unsupported:s}})}),Ke(this,"onDisconnect",()=>{this.emit("disconnect")})}async connect({chainId:t}={}){var a;const e=await this.getProvider({chainId:t});e.on("accountsChanged",this.onAccountsChanged),e.on("chainChanged",this.onChainChanged),e.on("disconnect",this.onDisconnect),this.emit("message",{type:"connecting"});const r=await e.enable(),n=Dn(r[0]),i=El(e.chainId),s=this.isChainUnsupported(i),o={account:n,chain:{id:i,unsupported:s},provider:e};return(a=this.options.flags)!=null&&a.noSwitchChain||(this.switchChain=Rr(this,p5,DU)),new Promise(c=>setTimeout(()=>c(o),100))}async disconnect(){const t=await this.getProvider();await t.disconnect(),t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect)}async getAccount(){const r=(await(await this.getProvider()).getAccounts())[0];if(!r)throw new Error("Failed to get account");return Dn(r)}async getChainId(){const t=await this.getProvider();return El(t.chainId)}async getProvider({chainId:t}={}){return(!We(this,wh)||t)&&ys(this,wh,new sge({...this.options,chainId:t??this.options.chainId??this.chains[0].id})),We(this,wh)}async getWalletClient(){return(await this.getProvider()).getWalletClient()}async isAuthorized(){var t;try{const r=await(await this.getProvider()).getAccounts();return((t=this.options.flags)==null?void 0:t.isAuthorized)??!!r}catch{return!1}}async watchAsset(t){return(await this.getProvider()).watchAsset(t)}toJSON(){return""}};wh=new WeakMap;p5=new WeakSet;DU=async function(t){return await(await this.getProvider()).switchChain(t),this.chains.find(r=>r.id===t)??{id:t,name:`Chain ${t}`,network:`${t}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}}};var W8={},Wb={},ze={},LU={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(a,c){var l=a>>>16&65535,u=a&65535,f=c>>>16&65535,d=c&65535;return u*d+(l*d+u*f<<16>>>0)|0}t.mul=Math.imul||e;function r(a,c){return a+c|0}t.add=r;function n(a,c){return a-c|0}t.sub=n;function i(a,c){return a<>>32-c}t.rotl=i;function s(a,c){return a<<32-c|a>>>c}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(LU);Object.defineProperty(ze,"__esModule",{value:!0});var FU=LU;function age(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}ze.readInt16BE=age;function cge(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}ze.readUint16BE=cge;function lge(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}ze.readInt16LE=lge;function uge(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}ze.readUint16LE=uge;function BU(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}ze.writeUint16BE=BU;ze.writeInt16BE=BU;function jU(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}ze.writeUint16LE=jU;ze.writeInt16LE=jU;function v5(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}ze.readInt32BE=v5;function m5(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}ze.readUint32BE=m5;function y5(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}ze.readInt32LE=y5;function g5(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}ze.readUint32LE=g5;function Ny(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}ze.writeUint32BE=Ny;ze.writeInt32BE=Ny;function Dy(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}ze.writeUint32LE=Dy;ze.writeInt32LE=Dy;function fge(t,e){e===void 0&&(e=0);var r=v5(t,e),n=v5(t,e+4);return r*4294967296+n-(n>>31)*4294967296}ze.readInt64BE=fge;function dge(t,e){e===void 0&&(e=0);var r=m5(t,e),n=m5(t,e+4);return r*4294967296+n}ze.readUint64BE=dge;function hge(t,e){e===void 0&&(e=0);var r=y5(t,e),n=y5(t,e+4);return n*4294967296+r-(r>>31)*4294967296}ze.readInt64LE=hge;function pge(t,e){e===void 0&&(e=0);var r=g5(t,e),n=g5(t,e+4);return n*4294967296+r}ze.readUint64LE=pge;function UU(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Ny(t/4294967296>>>0,e,r),Ny(t>>>0,e,r+4),e}ze.writeUint64BE=UU;ze.writeInt64BE=UU;function zU(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Dy(t>>>0,e,r),Dy(t/4294967296>>>0,e,r+4),e}ze.writeUint64LE=zU;ze.writeInt64LE=zU;function vge(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}ze.readUintBE=vge;function mge(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s=n;s--)r[s]=e/i&255,i*=256;return r}ze.writeUintBE=yge;function gge(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!FU.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s>>32-16|_<<16,H=H+_|0,w^=H,w=w>>>32-12|w<<12,S=S+I|0,O^=S,O=O>>>32-16|O<<16,K=K+O|0,I^=K,I=I>>>32-12|I<<12,P=P+F|0,N^=P,N=N>>>32-16|N<<16,B=B+N|0,F^=B,F=F>>>32-12|F<<12,T=T+j|0,k^=T,k=k>>>32-16|k<<16,E=E+k|0,j^=E,j=j>>>32-12|j<<12,P=P+F|0,N^=P,N=N>>>32-8|N<<8,B=B+N|0,F^=B,F=F>>>32-7|F<<7,T=T+j|0,k^=T,k=k>>>32-8|k<<8,E=E+k|0,j^=E,j=j>>>32-7|j<<7,S=S+I|0,O^=S,O=O>>>32-8|O<<8,K=K+O|0,I^=K,I=I>>>32-7|I<<7,g=g+w|0,_^=g,_=_>>>32-8|_<<8,H=H+_|0,w^=H,w=w>>>32-7|w<<7,g=g+I|0,k^=g,k=k>>>32-16|k<<16,B=B+k|0,I^=B,I=I>>>32-12|I<<12,S=S+F|0,_^=S,_=_>>>32-16|_<<16,E=E+_|0,F^=E,F=F>>>32-12|F<<12,P=P+j|0,O^=P,O=O>>>32-16|O<<16,H=H+O|0,j^=H,j=j>>>32-12|j<<12,T=T+w|0,N^=T,N=N>>>32-16|N<<16,K=K+N|0,w^=K,w=w>>>32-12|w<<12,P=P+j|0,O^=P,O=O>>>32-8|O<<8,H=H+O|0,j^=H,j=j>>>32-7|j<<7,T=T+w|0,N^=T,N=N>>>32-8|N<<8,K=K+N|0,w^=K,w=w>>>32-7|w<<7,S=S+F|0,_^=S,_=_>>>32-8|_<<8,E=E+_|0,F^=E,F=F>>>32-7|F<<7,g=g+I|0,k^=g,k=k>>>32-8|k<<8,B=B+k|0,I^=B,I=I>>>32-7|I<<7;dn.writeUint32LE(g+n|0,t,0),dn.writeUint32LE(S+i|0,t,4),dn.writeUint32LE(P+s|0,t,8),dn.writeUint32LE(T+o|0,t,12),dn.writeUint32LE(w+a|0,t,16),dn.writeUint32LE(I+c|0,t,20),dn.writeUint32LE(F+l|0,t,24),dn.writeUint32LE(j+u|0,t,28),dn.writeUint32LE(H+f|0,t,32),dn.writeUint32LE(K+d|0,t,36),dn.writeUint32LE(B+h|0,t,40),dn.writeUint32LE(E+p|0,t,44),dn.writeUint32LE(_+v|0,t,48),dn.writeUint32LE(O+b|0,t,52),dn.writeUint32LE(N+y|0,t,56),dn.writeUint32LE(k+m|0,t,60)}function WU(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var HU={},Lc={};Object.defineProperty(Lc,"__esModule",{value:!0});function Rge(t,e,r){return~(t-1)&e|t-1&r}Lc.select=Rge;function $ge(t,e){return(t|0)-(e|0)-1>>>31&1}Lc.lessOrEqual=$ge;function qU(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n>>8}Lc.compare=qU;function Mge(t,e){return t.length===0||e.length===0?!1:qU(t,e)!==0}Lc.equal=Mge;(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Lc,r=Is;t.DIGEST_LENGTH=16;var n=function(){function o(a){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var c=a[0]|a[1]<<8;this._r[0]=c&8191;var l=a[2]|a[3]<<8;this._r[1]=(c>>>13|l<<3)&8191;var u=a[4]|a[5]<<8;this._r[2]=(l>>>10|u<<6)&7939;var f=a[6]|a[7]<<8;this._r[3]=(u>>>7|f<<9)&8191;var d=a[8]|a[9]<<8;this._r[4]=(f>>>4|d<<12)&255,this._r[5]=d>>>1&8190;var h=a[10]|a[11]<<8;this._r[6]=(d>>>14|h<<2)&8191;var p=a[12]|a[13]<<8;this._r[7]=(h>>>11|p<<5)&8065;var v=a[14]|a[15]<<8;this._r[8]=(p>>>8|v<<8)&8191,this._r[9]=v>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,c,l){for(var u=this._fin?0:2048,f=this._h[0],d=this._h[1],h=this._h[2],p=this._h[3],v=this._h[4],b=this._h[5],y=this._h[6],m=this._h[7],g=this._h[8],S=this._h[9],P=this._r[0],T=this._r[1],w=this._r[2],I=this._r[3],F=this._r[4],j=this._r[5],H=this._r[6],K=this._r[7],B=this._r[8],E=this._r[9];l>=16;){var _=a[c+0]|a[c+1]<<8;f+=_&8191;var O=a[c+2]|a[c+3]<<8;d+=(_>>>13|O<<3)&8191;var N=a[c+4]|a[c+5]<<8;h+=(O>>>10|N<<6)&8191;var k=a[c+6]|a[c+7]<<8;p+=(N>>>7|k<<9)&8191;var $=a[c+8]|a[c+9]<<8;v+=(k>>>4|$<<12)&8191,b+=$>>>1&8191;var L=a[c+10]|a[c+11]<<8;y+=($>>>14|L<<2)&8191;var M=a[c+12]|a[c+13]<<8;m+=(L>>>11|M<<5)&8191;var A=a[c+14]|a[c+15]<<8;g+=(M>>>8|A<<8)&8191,S+=A>>>5|u;var D=0,V=D;V+=f*P,V+=d*(5*E),V+=h*(5*B),V+=p*(5*K),V+=v*(5*H),D=V>>>13,V&=8191,V+=b*(5*j),V+=y*(5*F),V+=m*(5*I),V+=g*(5*w),V+=S*(5*T),D+=V>>>13,V&=8191;var R=D;R+=f*T,R+=d*P,R+=h*(5*E),R+=p*(5*B),R+=v*(5*K),D=R>>>13,R&=8191,R+=b*(5*H),R+=y*(5*j),R+=m*(5*F),R+=g*(5*I),R+=S*(5*w),D+=R>>>13,R&=8191;var U=D;U+=f*w,U+=d*T,U+=h*P,U+=p*(5*E),U+=v*(5*B),D=U>>>13,U&=8191,U+=b*(5*K),U+=y*(5*H),U+=m*(5*j),U+=g*(5*F),U+=S*(5*I),D+=U>>>13,U&=8191;var W=D;W+=f*I,W+=d*w,W+=h*T,W+=p*P,W+=v*(5*E),D=W>>>13,W&=8191,W+=b*(5*B),W+=y*(5*K),W+=m*(5*H),W+=g*(5*j),W+=S*(5*F),D+=W>>>13,W&=8191;var q=D;q+=f*F,q+=d*I,q+=h*w,q+=p*T,q+=v*P,D=q>>>13,q&=8191,q+=b*(5*E),q+=y*(5*B),q+=m*(5*K),q+=g*(5*H),q+=S*(5*j),D+=q>>>13,q&=8191;var Y=D;Y+=f*j,Y+=d*F,Y+=h*I,Y+=p*w,Y+=v*T,D=Y>>>13,Y&=8191,Y+=b*P,Y+=y*(5*E),Y+=m*(5*B),Y+=g*(5*K),Y+=S*(5*H),D+=Y>>>13,Y&=8191;var X=D;X+=f*H,X+=d*j,X+=h*F,X+=p*I,X+=v*w,D=X>>>13,X&=8191,X+=b*T,X+=y*P,X+=m*(5*E),X+=g*(5*B),X+=S*(5*K),D+=X>>>13,X&=8191;var Q=D;Q+=f*K,Q+=d*H,Q+=h*j,Q+=p*F,Q+=v*I,D=Q>>>13,Q&=8191,Q+=b*w,Q+=y*T,Q+=m*P,Q+=g*(5*E),Q+=S*(5*B),D+=Q>>>13,Q&=8191;var Z=D;Z+=f*B,Z+=d*K,Z+=h*H,Z+=p*j,Z+=v*F,D=Z>>>13,Z&=8191,Z+=b*I,Z+=y*w,Z+=m*T,Z+=g*P,Z+=S*(5*E),D+=Z>>>13,Z&=8191;var ae=D;ae+=f*E,ae+=d*B,ae+=h*K,ae+=p*H,ae+=v*j,D=ae>>>13,ae&=8191,ae+=b*F,ae+=y*I,ae+=m*w,ae+=g*T,ae+=S*P,D+=ae>>>13,ae&=8191,D=(D<<2)+D|0,D=D+V|0,V=D&8191,D=D>>>13,R+=D,f=V,d=R,h=U,p=W,v=q,b=Y,y=X,m=Q,g=Z,S=ae,c+=16,l-=16}this._h[0]=f,this._h[1]=d,this._h[2]=h,this._h[3]=p,this._h[4]=v,this._h[5]=b,this._h[6]=y,this._h[7]=m,this._h[8]=g,this._h[9]=S},o.prototype.finish=function(a,c){c===void 0&&(c=0);var l=new Uint16Array(10),u,f,d,h;if(this._leftover){for(h=this._leftover,this._buffer[h++]=1;h<16;h++)this._buffer[h]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(u=this._h[1]>>>13,this._h[1]&=8191,h=2;h<10;h++)this._h[h]+=u,u=this._h[h]>>>13,this._h[h]&=8191;for(this._h[0]+=u*5,u=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=u,u=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=u,l[0]=this._h[0]+5,u=l[0]>>>13,l[0]&=8191,h=1;h<10;h++)l[h]=this._h[h]+u,u=l[h]>>>13,l[h]&=8191;for(l[9]-=8192,f=(u^1)-1,h=0;h<10;h++)l[h]&=f;for(f=~f,h=0;h<10;h++)this._h[h]=this._h[h]&f|l[h];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,d=this._h[0]+this._pad[0],this._h[0]=d&65535,h=1;h<8;h++)d=(this._h[h]+this._pad[h]|0)+(d>>>16)|0,this._h[h]=d&65535;return a[c+0]=this._h[0]>>>0,a[c+1]=this._h[0]>>>8,a[c+2]=this._h[1]>>>0,a[c+3]=this._h[1]>>>8,a[c+4]=this._h[2]>>>0,a[c+5]=this._h[2]>>>8,a[c+6]=this._h[3]>>>0,a[c+7]=this._h[3]>>>8,a[c+8]=this._h[4]>>>0,a[c+9]=this._h[4]>>>8,a[c+10]=this._h[5]>>>0,a[c+11]=this._h[5]>>>8,a[c+12]=this._h[6]>>>0,a[c+13]=this._h[6]>>>8,a[c+14]=this._h[7]>>>0,a[c+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var c=0,l=a.length,u;if(this._leftover){u=16-this._leftover,u>l&&(u=l);for(var f=0;f=16&&(u=l-l%16,this._blocks(a,c,u),c+=u,l-=u),l){for(var f=0;f16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var h=new Uint8Array(16);h.set(l,h.length-l.length);var p=new Uint8Array(32);e.stream(this._key,h,p,4);var v=u.length+this.tagLength,b;if(d){if(d.length!==v)throw new Error("ChaCha20Poly1305: incorrect destination length");b=d}else b=new Uint8Array(v);return e.streamXOR(this._key,h,u,b,4),this._authenticate(b.subarray(b.length-this.tagLength,b.length),p,b.subarray(0,b.length-this.tagLength),f),n.wipe(h),b},c.prototype.open=function(l,u,f,d){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(u.length0&&h.update(o.subarray(d.length%16))),h.update(f),f.length%16>0&&h.update(o.subarray(f.length%16));var p=new Uint8Array(8);d&&i.writeUint64LE(d.length,p),h.update(p),i.writeUint64LE(f.length,p),h.update(p);for(var v=h.digest(),b=0;bthis.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n256)throw new Error("randomString charset is too long");let d="";const h=u.length,p=256-256%h;for(;l>0;){const v=i(Math.ceil(l*256/p),f);for(let b=0;b0;b++){const y=v[b];y0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=c[u++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(u=s(this._temp,this._state,c,u,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=c[u++],l--;return this},a.prototype.finish=function(c){if(!this._finished){var l=this._bytesHashed,u=this._bufferLength,f=l/536870912|0,d=l<<3,h=l%64<56?64:128;this._buffer[u]=128;for(var p=u+1;p0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(c){return this._state.set(c.state),this._bufferLength=c.bufferLength,c.buffer&&this._buffer.set(c.buffer),this._bytesHashed=c.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(c){r.wipe(c.state),c.buffer&&r.wipe(c.buffer),c.bufferLength=0,c.bytesHashed=0},a}();t.SHA256=n;var i=new Int32Array([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]);function s(a,c,l,u,f){for(;f>=64;){for(var d=c[0],h=c[1],p=c[2],v=c[3],b=c[4],y=c[5],m=c[6],g=c[7],S=0;S<16;S++){var P=u+S*4;a[S]=e.readUint32BE(l,P)}for(var S=16;S<64;S++){var T=a[S-2],w=(T>>>17|T<<32-17)^(T>>>19|T<<32-19)^T>>>10;T=a[S-15];var I=(T>>>7|T<<32-7)^(T>>>18|T<<32-18)^T>>>3;a[S]=(w+a[S-7]|0)+(I+a[S-16]|0)}for(var S=0;S<64;S++){var w=(((b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7))+(b&y^~b&m)|0)+(g+(i[S]+a[S]|0)|0)|0,I=((d>>>2|d<<32-2)^(d>>>13|d<<32-13)^(d>>>22|d<<32-22))+(d&h^d&p^h&p)|0;g=m,m=y,y=b,b=v+w|0,v=p,p=h,h=d,d=w+I|0}c[0]+=d,c[1]+=h,c[2]+=p,c[3]+=v,c[4]+=b,c[5]+=y,c[6]+=m,c[7]+=g,u+=64,f-=64}return u}function o(a){var c=new n;c.update(a);var l=c.digest();return c.clean(),l}t.hash=o})(Kb);var q8={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=Hb,r=Is;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(S){const P=new Float64Array(16);if(S)for(let T=0;T>16&1),T[j-1]&=65535;T[15]=w[15]-32767-(T[14]>>16&1);const F=T[15]>>16&1;T[14]&=65535,a(w,T,1-F)}for(let I=0;I<16;I++)S[2*I]=w[I]&255,S[2*I+1]=w[I]>>8}function l(S,P){for(let T=0;T<16;T++)S[T]=P[2*T]+(P[2*T+1]<<8);S[15]&=32767}function u(S,P,T){for(let w=0;w<16;w++)S[w]=P[w]+T[w]}function f(S,P,T){for(let w=0;w<16;w++)S[w]=P[w]-T[w]}function d(S,P,T){let w,I,F=0,j=0,H=0,K=0,B=0,E=0,_=0,O=0,N=0,k=0,$=0,L=0,M=0,A=0,D=0,V=0,R=0,U=0,W=0,q=0,Y=0,X=0,Q=0,Z=0,ae=0,se=0,ue=0,ot=0,Te=0,_e=0,at=0,xe=T[0],be=T[1],Kt=T[2],Ie=T[3],Oe=T[4],Qt=T[5],Re=T[6],$e=T[7],Yt=T[8],Me=T[9],Ne=T[10],Jt=T[11],De=T[12],Le=T[13],Xt=T[14],Fe=T[15];w=P[0],F+=w*xe,j+=w*be,H+=w*Kt,K+=w*Ie,B+=w*Oe,E+=w*Qt,_+=w*Re,O+=w*$e,N+=w*Yt,k+=w*Me,$+=w*Ne,L+=w*Jt,M+=w*De,A+=w*Le,D+=w*Xt,V+=w*Fe,w=P[1],j+=w*xe,H+=w*be,K+=w*Kt,B+=w*Ie,E+=w*Oe,_+=w*Qt,O+=w*Re,N+=w*$e,k+=w*Yt,$+=w*Me,L+=w*Ne,M+=w*Jt,A+=w*De,D+=w*Le,V+=w*Xt,R+=w*Fe,w=P[2],H+=w*xe,K+=w*be,B+=w*Kt,E+=w*Ie,_+=w*Oe,O+=w*Qt,N+=w*Re,k+=w*$e,$+=w*Yt,L+=w*Me,M+=w*Ne,A+=w*Jt,D+=w*De,V+=w*Le,R+=w*Xt,U+=w*Fe,w=P[3],K+=w*xe,B+=w*be,E+=w*Kt,_+=w*Ie,O+=w*Oe,N+=w*Qt,k+=w*Re,$+=w*$e,L+=w*Yt,M+=w*Me,A+=w*Ne,D+=w*Jt,V+=w*De,R+=w*Le,U+=w*Xt,W+=w*Fe,w=P[4],B+=w*xe,E+=w*be,_+=w*Kt,O+=w*Ie,N+=w*Oe,k+=w*Qt,$+=w*Re,L+=w*$e,M+=w*Yt,A+=w*Me,D+=w*Ne,V+=w*Jt,R+=w*De,U+=w*Le,W+=w*Xt,q+=w*Fe,w=P[5],E+=w*xe,_+=w*be,O+=w*Kt,N+=w*Ie,k+=w*Oe,$+=w*Qt,L+=w*Re,M+=w*$e,A+=w*Yt,D+=w*Me,V+=w*Ne,R+=w*Jt,U+=w*De,W+=w*Le,q+=w*Xt,Y+=w*Fe,w=P[6],_+=w*xe,O+=w*be,N+=w*Kt,k+=w*Ie,$+=w*Oe,L+=w*Qt,M+=w*Re,A+=w*$e,D+=w*Yt,V+=w*Me,R+=w*Ne,U+=w*Jt,W+=w*De,q+=w*Le,Y+=w*Xt,X+=w*Fe,w=P[7],O+=w*xe,N+=w*be,k+=w*Kt,$+=w*Ie,L+=w*Oe,M+=w*Qt,A+=w*Re,D+=w*$e,V+=w*Yt,R+=w*Me,U+=w*Ne,W+=w*Jt,q+=w*De,Y+=w*Le,X+=w*Xt,Q+=w*Fe,w=P[8],N+=w*xe,k+=w*be,$+=w*Kt,L+=w*Ie,M+=w*Oe,A+=w*Qt,D+=w*Re,V+=w*$e,R+=w*Yt,U+=w*Me,W+=w*Ne,q+=w*Jt,Y+=w*De,X+=w*Le,Q+=w*Xt,Z+=w*Fe,w=P[9],k+=w*xe,$+=w*be,L+=w*Kt,M+=w*Ie,A+=w*Oe,D+=w*Qt,V+=w*Re,R+=w*$e,U+=w*Yt,W+=w*Me,q+=w*Ne,Y+=w*Jt,X+=w*De,Q+=w*Le,Z+=w*Xt,ae+=w*Fe,w=P[10],$+=w*xe,L+=w*be,M+=w*Kt,A+=w*Ie,D+=w*Oe,V+=w*Qt,R+=w*Re,U+=w*$e,W+=w*Yt,q+=w*Me,Y+=w*Ne,X+=w*Jt,Q+=w*De,Z+=w*Le,ae+=w*Xt,se+=w*Fe,w=P[11],L+=w*xe,M+=w*be,A+=w*Kt,D+=w*Ie,V+=w*Oe,R+=w*Qt,U+=w*Re,W+=w*$e,q+=w*Yt,Y+=w*Me,X+=w*Ne,Q+=w*Jt,Z+=w*De,ae+=w*Le,se+=w*Xt,ue+=w*Fe,w=P[12],M+=w*xe,A+=w*be,D+=w*Kt,V+=w*Ie,R+=w*Oe,U+=w*Qt,W+=w*Re,q+=w*$e,Y+=w*Yt,X+=w*Me,Q+=w*Ne,Z+=w*Jt,ae+=w*De,se+=w*Le,ue+=w*Xt,ot+=w*Fe,w=P[13],A+=w*xe,D+=w*be,V+=w*Kt,R+=w*Ie,U+=w*Oe,W+=w*Qt,q+=w*Re,Y+=w*$e,X+=w*Yt,Q+=w*Me,Z+=w*Ne,ae+=w*Jt,se+=w*De,ue+=w*Le,ot+=w*Xt,Te+=w*Fe,w=P[14],D+=w*xe,V+=w*be,R+=w*Kt,U+=w*Ie,W+=w*Oe,q+=w*Qt,Y+=w*Re,X+=w*$e,Q+=w*Yt,Z+=w*Me,ae+=w*Ne,se+=w*Jt,ue+=w*De,ot+=w*Le,Te+=w*Xt,_e+=w*Fe,w=P[15],V+=w*xe,R+=w*be,U+=w*Kt,W+=w*Ie,q+=w*Oe,Y+=w*Qt,X+=w*Re,Q+=w*$e,Z+=w*Yt,ae+=w*Me,se+=w*Ne,ue+=w*Jt,ot+=w*De,Te+=w*Le,_e+=w*Xt,at+=w*Fe,F+=38*R,j+=38*U,H+=38*W,K+=38*q,B+=38*Y,E+=38*X,_+=38*Q,O+=38*Z,N+=38*ae,k+=38*se,$+=38*ue,L+=38*ot,M+=38*Te,A+=38*_e,D+=38*at,I=1,w=F+I+65535,I=Math.floor(w/65536),F=w-I*65536,w=j+I+65535,I=Math.floor(w/65536),j=w-I*65536,w=H+I+65535,I=Math.floor(w/65536),H=w-I*65536,w=K+I+65535,I=Math.floor(w/65536),K=w-I*65536,w=B+I+65535,I=Math.floor(w/65536),B=w-I*65536,w=E+I+65535,I=Math.floor(w/65536),E=w-I*65536,w=_+I+65535,I=Math.floor(w/65536),_=w-I*65536,w=O+I+65535,I=Math.floor(w/65536),O=w-I*65536,w=N+I+65535,I=Math.floor(w/65536),N=w-I*65536,w=k+I+65535,I=Math.floor(w/65536),k=w-I*65536,w=$+I+65535,I=Math.floor(w/65536),$=w-I*65536,w=L+I+65535,I=Math.floor(w/65536),L=w-I*65536,w=M+I+65535,I=Math.floor(w/65536),M=w-I*65536,w=A+I+65535,I=Math.floor(w/65536),A=w-I*65536,w=D+I+65535,I=Math.floor(w/65536),D=w-I*65536,w=V+I+65535,I=Math.floor(w/65536),V=w-I*65536,F+=I-1+37*(I-1),I=1,w=F+I+65535,I=Math.floor(w/65536),F=w-I*65536,w=j+I+65535,I=Math.floor(w/65536),j=w-I*65536,w=H+I+65535,I=Math.floor(w/65536),H=w-I*65536,w=K+I+65535,I=Math.floor(w/65536),K=w-I*65536,w=B+I+65535,I=Math.floor(w/65536),B=w-I*65536,w=E+I+65535,I=Math.floor(w/65536),E=w-I*65536,w=_+I+65535,I=Math.floor(w/65536),_=w-I*65536,w=O+I+65535,I=Math.floor(w/65536),O=w-I*65536,w=N+I+65535,I=Math.floor(w/65536),N=w-I*65536,w=k+I+65535,I=Math.floor(w/65536),k=w-I*65536,w=$+I+65535,I=Math.floor(w/65536),$=w-I*65536,w=L+I+65535,I=Math.floor(w/65536),L=w-I*65536,w=M+I+65535,I=Math.floor(w/65536),M=w-I*65536,w=A+I+65535,I=Math.floor(w/65536),A=w-I*65536,w=D+I+65535,I=Math.floor(w/65536),D=w-I*65536,w=V+I+65535,I=Math.floor(w/65536),V=w-I*65536,F+=I-1+37*(I-1),S[0]=F,S[1]=j,S[2]=H,S[3]=K,S[4]=B,S[5]=E,S[6]=_,S[7]=O,S[8]=N,S[9]=k,S[10]=$,S[11]=L,S[12]=M,S[13]=A,S[14]=D,S[15]=V}function h(S,P){d(S,P,P)}function p(S,P){const T=n();for(let w=0;w<16;w++)T[w]=P[w];for(let w=253;w>=0;w--)h(T,T),w!==2&&w!==4&&d(T,T,P);for(let w=0;w<16;w++)S[w]=T[w]}function v(S,P){const T=new Uint8Array(32),w=new Float64Array(80),I=n(),F=n(),j=n(),H=n(),K=n(),B=n();for(let N=0;N<31;N++)T[N]=S[N];T[31]=S[31]&127|64,T[0]&=248,l(w,P);for(let N=0;N<16;N++)F[N]=w[N];I[0]=H[0]=1;for(let N=254;N>=0;--N){const k=T[N>>>3]>>>(N&7)&1;a(I,F,k),a(j,H,k),u(K,I,j),f(I,I,j),u(j,F,H),f(F,F,H),h(H,K),h(B,I),d(I,j,I),d(j,F,K),u(K,I,j),f(I,I,j),h(F,I),f(j,H,B),d(I,j,s),u(I,I,H),d(j,j,I),d(I,H,B),d(H,F,w),h(F,K),a(I,F,k),a(j,H,k)}for(let N=0;N<16;N++)w[N+16]=I[N],w[N+32]=j[N],w[N+48]=F[N],w[N+64]=H[N];const E=w.subarray(32),_=w.subarray(16);p(E,E),d(_,_,E);const O=new Uint8Array(32);return c(O,_),O}t.scalarMult=v;function b(S){return v(S,i)}t.scalarMultBase=b;function y(S){if(S.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const P=new Uint8Array(S);return{publicKey:b(P),secretKey:P}}t.generateKeyPairFromSeed=y;function m(S){const P=(0,e.randomBytes)(32,S),T=y(P);return(0,r.wipe)(P),T}t.generateKeyPair=m;function g(S,P,T=!1){if(S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(P.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const w=v(S,P);if(T){let I=0;for(let F=0;Fi+s.length,0));const r=KU(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return V8(r)}function Kge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,S=new Uint8Array(g);y!==m;){for(var P=p[y],T=0,w=g-1;(P!==0||T>>0,S[w]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");b=T,y++}for(var I=g-b;I!==g&&S[I]===0;)I++;for(var F=c.repeat(v);I>>0,g=new Uint8Array(m);p[v];){var S=r[p.charCodeAt(v)];if(S===255)return;for(var P=0,T=m-1;(S!==0||P>>0,g[T]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");y=P,v++}if(p[v]!==" "){for(var w=m-y;w!==m&&g[w]===0;)w++;for(var I=new Uint8Array(b+(m-w)),F=b;w!==m;)I[F++]=g[w++];return I}}}function h(p){var v=d(p);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:h}}var Qge=Kge,Yge=Qge;const Jge=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")},Xge=t=>new TextEncoder().encode(t),Zge=t=>new TextDecoder().decode(t);class ebe{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class tbe{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}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 QU(this,e)}}class rbe{constructor(e){this.decoders=e}or(e){return QU(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const QU=(t,e)=>new rbe({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class nbe{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ebe(e,r,n),this.decoder=new tbe(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qb=({name:t,prefix:e,encode:r,decode:n})=>new nbe(t,e,r,n),ip=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Yge(r,e);return Qb({prefix:t,name:e,encode:n,decode:s=>Jge(i(s))})},ibe=(t,e,r,n)=>{const i={};for(let u=0;u=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},sbe=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<Qb({prefix:e,name:t,encode(i){return sbe(i,n,r)},decode(i){return ibe(i,n,r,t)}}),obe=Qb({prefix:"\0",name:"identity",encode:t=>Zge(t),decode:t=>Xge(t)}),abe=Object.freeze(Object.defineProperty({__proto__:null,identity:obe},Symbol.toStringTag,{value:"Module"})),cbe=cn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),lbe=Object.freeze(Object.defineProperty({__proto__:null,base2:cbe},Symbol.toStringTag,{value:"Module"})),ube=cn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),fbe=Object.freeze(Object.defineProperty({__proto__:null,base8:ube},Symbol.toStringTag,{value:"Module"})),dbe=ip({prefix:"9",name:"base10",alphabet:"0123456789"}),hbe=Object.freeze(Object.defineProperty({__proto__:null,base10:dbe},Symbol.toStringTag,{value:"Module"})),pbe=cn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vbe=cn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),mbe=Object.freeze(Object.defineProperty({__proto__:null,base16:pbe,base16upper:vbe},Symbol.toStringTag,{value:"Module"})),ybe=cn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gbe=cn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bbe=cn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wbe=cn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ebe=cn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xbe=cn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cbe=cn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sbe=cn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kbe=cn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Abe=Object.freeze(Object.defineProperty({__proto__:null,base32:ybe,base32hex:Ebe,base32hexpad:Cbe,base32hexpadupper:Sbe,base32hexupper:xbe,base32pad:bbe,base32padupper:wbe,base32upper:gbe,base32z:kbe},Symbol.toStringTag,{value:"Module"})),_be=ip({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pbe=ip({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Tbe=Object.freeze(Object.defineProperty({__proto__:null,base36:_be,base36upper:Pbe},Symbol.toStringTag,{value:"Module"})),Ibe=ip({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Obe=ip({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Rbe=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Ibe,base58flickr:Obe},Symbol.toStringTag,{value:"Module"})),$be=cn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mbe=cn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nbe=cn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dbe=cn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Lbe=Object.freeze(Object.defineProperty({__proto__:null,base64:$be,base64pad:Mbe,base64url:Nbe,base64urlpad:Dbe},Symbol.toStringTag,{value:"Module"})),YU=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Fbe=YU.reduce((t,e,r)=>(t[r]=e,t),[]),Bbe=YU.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function jbe(t){return t.reduce((e,r)=>(e+=Fbe[r],e),"")}function Ube(t){const e=[];for(const r of t){const n=Bbe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const zbe=Qb({prefix:"🚀",name:"base256emoji",encode:jbe,decode:Ube}),Wbe=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:zbe},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const YT={...abe,...lbe,...fbe,...hbe,...mbe,...Abe,...Tbe,...Rbe,...Lbe,...Wbe};function JU(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const JT=JU("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),rE=JU("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=KU(t.length);for(let r=0;r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Kbe:typeof navigator<"u"?t9(navigator.userAgent):twe()}function Zbe(t){return t!==""&&Jbe.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function t9(t){var e=Zbe(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Gbe;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.lengthca(t)||je(t)?re(t):wt(t),Ub=t=>{const e=yU(t);return mye(e)?e:qt([Yv,wt(String(e.length)),e])},xye=t=>{if(JSON.stringify(t.slice(0,Yv.length))!==JSON.stringify(Yv))return t;const e=t.slice(Yv.length),r=String(e.length).length;let n,i;try{i=Number(ua(e.slice(0,r)))}catch{i=Number(te(e.slice(0,r)))}return i>e.length||!Number.isInteger(i)?n=r-1:n=r,e.slice(n)},Qf=async(t,e,r,n)=>new he.reader.OnChainReader(n).isValidSignature(t,e,r),gU=async(t,e,r,n)=>{const i=Ub(e),s=c8(i);return Qf(t,s,r,n)},bU=(t,e,r,n)=>Qf(t,Q1(e),r,n),$y=()=>window.location.protocol==="chrome-extension:"||window.location.protocol==="moz-extension:",wU=()=>!!navigator.userAgent.match(/UnitySequence/i),EU=t=>t.onChain.deployed&&t.fullyMigrated;class xU{constructor(){this.callbacks=[],this.store={}}getItem(e){return this.store[e]||null}setItem(e,r){this.store[e]=r,this.callbacks.filter(n=>n.key===e).forEach(n=>n.cb(r))}removeItem(e){delete this.store[e]}onItemChange(e,r){return this.callbacks.push({key:e,cb:r}),()=>{this.callbacks=this.callbacks.filter(n=>n.cb!==r)}}}class c1{static isAvailable(){return typeof window=="object"&&typeof window.localStorage=="object"}constructor(){if(this.callbacks=[],!c1.isAvailable())throw new Error("LocalStorage is not available");window.addEventListener("storage",e=>{const{key:r}=e;this.callbacks.filter(i=>i.key===r).forEach(i=>i.cb(this.getItem(r)))})}getItem(e){return window.localStorage.getItem(e)}setItem(e,r){window.localStorage.setItem(e,r),this.callbacks.filter(n=>n.key===e).forEach(n=>n.cb(r))}removeItem(e){window.localStorage.removeItem(e),this.callbacks.filter(r=>r.key===e).forEach(r=>r.cb(null))}onItemChange(e,r){return this.callbacks.push({key:e,cb:r}),()=>{this.callbacks=this.callbacks.filter(n=>n.cb!==r)}}}function My(){return c1.isAvailable()?new c1:new xU}async function CU(t){return Array.isArray(t)?Promise.all(t.map(e=>vt(e))):vt(t)}const WT="@sequence.transportSession";class rp{constructor(e){var r=this;this.sendAsync=async function(n,i,s){throw new Error("abstract method")},this.handleMessage=async function(n){const i=n;if(r._init!==Wt.OK){if(i.type===Ye.INIT)if(r.isValidInitAck(n))r._initCallback&&r._initCallback();else{r._initCallback&&r._initCallback("invalid init");return}return}switch(i.type){case Ye.OPEN:{if(r._init!==Wt.OK)return;const s={sessionId:i.data.sessionId,intent:i.data.intent,networkId:i.data.networkId};await r.open(s);return}case Ye.CLOSE:return r._init!==Wt.OK,void 0;case Ye.MESSAGE:{const s=await r.walletRequestHandler.sendMessageRequest(i);r.sendMessage(s),s.data.error;return}default:ge.error(`unexpected payload type ${i.type}`)}},this.sendMessageRequest=async function(n){return r.walletRequestHandler.sendMessageRequest(n)},this.open=async function({sessionId:n,intent:i,networkId:s}){n&&(r._sessionId=$B(n),r.saveTransportSession({sessionId:n,intent:i,networkId:s})),r.walletRequestHandler.setOpenIntent(i),await r.init();let o;try{if(s){const a=d8(s);if(a)o=a.chainId;else throw new Error(`unknown network ${s}`)}else o=r.walletRequestHandler.defaultChainId()}catch(a){console.error(a)}if(i&&i.type==="connect"&&i.options){const a=i.options,c=a;if(r.appOrigin&&c!=null&&c.origin){if(!$y()&&c.origin!==r.appOrigin)throw new Error("origin is invalid")}else!r.appOrigin&&c!=null&&c.origin?a.origin=NB(c.origin):r.appOrigin&&(a.origin=r.appOrigin);a.app&&(a.app=MB(a.app)),a.networkId?s=a.networkId:s&&(a.networkId=s),r.walletRequestHandler.setConnectOptions(a)}else r.walletRequestHandler.setConnectOptions(void 0);if(await r.walletRequestHandler.getAccount(),await r.walletRequestHandler.isSignedIn())if(i&&i.type==="connect"){(!o||o<=0)&&console.log("Failed to set default network on open"),r.notifyOpen({sessionId:r._sessionId});try{const a=await r.walletRequestHandler.promptConnect(i.options);a.connected&&r.walletRequestHandler.notifyConnect(a)}catch(a){ge.warn("promptConnect not connected:",a)}finally{(!i.options||i.options.keepWalletOpened!==!0)&&r.notifyClose()}}else{if(!o||o<=0)return r.notifyOpen({sessionId:r._sessionId,error:`failed to open wallet on network ${s}`}),!1;r.notifyOpen({sessionId:r._sessionId,chainId:`${o}`,session:await r.walletRequestHandler.walletSession(o)})}else return r.notifyOpen({sessionId:r._sessionId}),!0;return!0},this.saveTransportSession=n=>{My().setItem(WT,JSON.stringify(n))},this.getCachedTransportSession=async function(){const n=My().getItem(WT);try{return n?JSON.parse(n):null}catch{return console.error(`unable to parse transport session: ${n}`),null}},this.walletRequestHandler=e,this._init=Wt.NIL,this.walletRequestHandler.on("connect",n=>{this.registered&&this.notifyConnect(n)}),this.walletRequestHandler.on("disconnect",(n,i)=>{this.registered&&this.notifyDisconnect(n,i)}),this.walletRequestHandler.on("accountsChanged",(n,i)=>{this.registered&&this.notifyAccountsChanged(n,i)}),this.walletRequestHandler.on("networks",n=>{this.registered&&(this.notifyNetworks(n),!n||n.length===0?this.notifyChainChanged("0x0"):this.notifyChainChanged(Es(n.find(i=>i.isDefaultChain).chainId)))}),this.walletRequestHandler.on("chainChanged",(n,i)=>{this.notifyChainChanged(n,i)}),this.walletRequestHandler.on("walletContext",n=>{!this.registered||!n||this.notifyWalletContext(n)}),this.walletRequestHandler.on("close",n=>{this.registered&&this.notifyClose(n)})}get registered(){return this._registered}register(){throw new Error("abstract method")}unregister(){throw new Error("abstract method")}sendMessage(e){throw new Error("abstract method")}notifyOpen(e){const{chainId:r,sessionId:n,session:i,error:s}=e;this.sendMessage({idx:-1,type:Ye.OPEN,data:{chainId:r,sessionId:n,session:i,error:s}})}notifyClose(e){this.sendMessage({idx:-1,type:Ye.CLOSE,data:e?{error:e}:null})}notifyConnect(e){this.sendMessage({idx:-1,type:Ye.CONNECT,data:e})}notifyDisconnect(e,r){this.sendMessage({idx:-1,type:Ye.DISCONNECT,data:e?{error:e}:null,origin:r})}notifyAccountsChanged(e,r){this.sendMessage({idx:-1,type:Ye.ACCOUNTS_CHANGED,data:e,origin:r})}notifyChainChanged(e,r){this.sendMessage({idx:-1,type:Ye.CHAIN_CHANGED,data:e,origin:r})}notifyNetworks(e){this.sendMessage({idx:-1,type:Ye.NETWORKS,data:e})}notifyWalletContext(e){this.sendMessage({idx:-1,type:Ye.WALLET_CONTEXT,data:e})}isValidInitAck(e){if(this._init===Wt.OK)return ge.warn("isValidInitAck, already in init'd state, so inquiry is invalid."),!1;if(e.type!==Ye.INIT)return ge.warn("isValidInitAck, invalid message type, expecting init"),!1;const{sessionId:r,nonce:n}=e.data;return!r||r.length===0||!n||n.length===0?(ge.error("invalid init ack"),!1):r!==this._sessionId||n!==this._initNonce?(ge.error("invalid init ack match"),!1):!0}init(){return new Promise((e,r)=>{if(this._init===Wt.OK){e();return}if(this._init!==Wt.NIL||this._initCallback){r("transport init is in progress");return}const n=setTimeout(()=>{ge.warn("transport init timed out"),this._initCallback&&this._initCallback("transport init timed out")},B8/2);this._initCallback=i=>{this._initCallback=void 0,clearTimeout(n),i?r(i):(this._init=Wt.OK,e())},this._initNonce=`${performance.now()}`,this.sendMessage({idx:-1,type:Ye.INIT,data:{nonce:this._initNonce}}),this._init=Wt.SENT_NONCE})}}class Cye{constructor(){const e=new d5,r=new d5;e.conn=r,r.conn=e,this.app=e,this.wallet=r}}class d5{constructor(){this.events=new jb.EventEmitter2,this.handleMessage=e=>{throw new Error("ProxyMessageChannelPort is not registered")},this.sendMessage=e=>{this.conn.handleMessage(e),e.type==="open"&&this.events.emit("open",e),e.type==="close"&&this.events.emit("close",e),e.type==="connect"&&this.events.emit("connect",e),e.type==="disconnect"&&this.events.emit("disconnect",e)}}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}}class SU extends tp{constructor(e){if(super(),this.register=()=>{this.port.handleMessage=r=>{this.handleMessage(r)},this.on("open",(...r)=>{this.port.events.emit("open",...r)}),this.on("close",(...r)=>{this.port.events.emit("close",...r)}),this.on("connect",(...r)=>{this.port.events.emit("connect",...r)}),this.on("disconnect",(...r)=>{this.port.events.emit("disconnect",...r)}),this._registered=!0},this.unregister=()=>{this._registered=!1,this.closeWallet(),this.events.removeAllListeners(),this.port.handleMessage=void 0},this.openWallet=(r,n,i)=>{if(this.state===Ri.CLOSED){this.state=Ri.OPENING;const s=`${performance.now()}`;this._sessionId=s,this.sendMessage({idx:-1,type:Ye.OPEN,data:{path:r,intent:n,networkId:i,sessionId:s}})}},this.state=Ri.CLOSED,this.port=e,!e)throw new Error("port argument cannot be empty");this._init=Wt.OK}closeWallet(){this.sendMessage({idx:-1,type:Ye.CLOSE,data:null}),this.close()}sendMessage(e){if(!e.idx)throw new Error("message idx is empty");this.port.sendMessage(e)}}class Sye extends rp{constructor(e,r){super(e),this.port=r,this._init=Wt.OK}register(){this.port.handleMessage=e=>{this.handleMessage(e)},this._registered=!0}async restoreSession(){const e=await this.getCachedTransportSession();e&&this.open(e)}unregister(){this.port.handleMessage=void 0,this._registered=!1}sendMessage(e){this.port.sendMessage(e)}}function kU(t){var e;if((e=window.ue)!=null&&e.sequencewallettransport&&!window.logsOverriddenForUnreal){var r;const n=(r=window.ue)==null?void 0:r.sequencewallettransport;console.log=(...i)=>{n.logfromjs(`${t}: ${tE(i)}`)},console.warn=(...i)=>{n.warnfromjs(`${t}: ${tE(i)}`)},console.error=(...i)=>{n.errorfromjs(`${t}: ${tE(i)}`)},window.logsOverriddenForUnreal=!0}}function tE(t){return t.map(e=>typeof e=="object"?e instanceof Error?e.message:JSON.stringify(e):String(e)).join(" ")}let bu;class AU extends tp{constructor(e){super(),this.register=()=>{var r;kU("dapp"),bu&&(bu.unregister(),bu=this),(r=window.ue)!=null&&r.sequencewallettransport&&(window.ue.sequencewallettransport.onmessagefromwallet=this.onUnrealCallback),bu=this,this._registered=!0,console.log("registering transport!")},this.unregister=()=>{var r,n;this._registered=!1,this.closeWallet(),bu===this&&(bu=void 0),((r=window.ue)==null||(n=r.sequencewallettransport)==null?void 0:n.onmessagefromwallet)===this.onUnrealCallback&&delete window.ue.sequencewallettransport.onmessagefromwallet,this.events.removeAllListeners()},this.openWallet=(r,n,i)=>{if(this.isOpened()){console.log("wallet already open!");return}console.log("opening wallet!");const s=new URL(this.walletURL.href),o=new ep;r&&(s.pathname=r.toLowerCase()),this._init=Wt.NIL,this._sessionId=`${performance.now()}`,o.set("sid",this._sessionId),n&&o.set("intent",o8(n)),i&&o.set("net",`${i}`),s.search=o.toString(),console.log("opening wallet to",s.href),window.open(s.href)},this.onUnrealCallback=r=>{if(!r)throw new Error("ProviderMessage object is empty");this.handleMessage(r)},this.walletURL=new URL(e)}closeWallet(){this.close()}sendMessage(e){var r,n;const i=typeof e!="string"?JSON.stringify(e):e;console.log("Sending message to wallet:",i),(r=window.ue)==null||(n=r.sequencewallettransport)==null||n.sendmessagetowallet(i)}}class kye extends rp{constructor(e){super(e),this.onMessageFromUnreal=r=>{ge.debug("RECEIVED MESSAGE",r),this.handleMessage(r)},this.getUnrealTransportSession=r=>{const n=new ep(r);return{sessionId:n.get("sid"),networkId:n.get("net"),intent:a8(n.get("intent"))}},this._init=Wt.NIL}async register(e){var r;if(((r=window.ue)==null?void 0:r.sequencewallettransport)===void 0)return;kU("wallet");const{search:n}=new URL(e||window.location.href);let i=this.getUnrealTransportSession(n);if(!!i.sessionId||(i=await this.getCachedTransportSession()),!i){ge.error("unreal session is undefined");return}window.ue.sequencewallettransport.onmessagefromsequencejs=this.onMessageFromUnreal,this._registered=!0,this.open(i).then(o=>{if(!o){var a;const c=`failed to open to network ${(a=i)==null?void 0:a.networkId}`;ge.error(c),this.notifyClose({message:c}),window.close()}}).catch(o=>{var a;const c=`failed to open to network ${(a=i)==null?void 0:a.networkId}, due to: ${o}`;ge.error(c),this.notifyClose({message:c}),window.close()})}unregister(){var e,r;((e=window.ue)==null||(r=e.sequencewallettransport)==null?void 0:r.onmessagefromsequencejs)===this.onMessageFromUnreal&&delete window.ue.sequencewallettransport.onmessagefromsequencejs,this._registered=!1}sendMessage(e){var r,n;if(e.type!==Ye.INIT&&this._init!==Wt.OK){ge.error("impossible state, should not be calling postMessage until inited");return}const i=JSON.stringify(e);(r=window.ue)==null||(n=r.sequencewallettransport)==null||n.sendmessagetosequencejs(i)}}const j8="sequence-extension-message-handler";class Aye extends rp{constructor(e,r){super(e),this.runtime=r,this._init=Wt.OK}register(){this._registered=!0,this.port=this.runtime.connect({name:j8})}sendMessage(e){ge.info("[ExtensionMessageHandler send]",e),this.port.postMessage(e)}}class _U extends tp{constructor(e){super(),this.register=()=>{this._registered=!0},e.onConnect.addListener(r=>{r.name===j8&&(this._init=Wt.OK,r.onMessage.addListener(n=>{this.handleMessage(n)}))})}sendMessage(e){}unregister(){}openWallet(e,r,n){}closeWallet(){}}class _ye extends jb.EventEmitter2{constructor(e){var r;super(),r=this,this.responseCallbacks=new Map,this._messageIdx=0,this.nextMessageIdx=()=>++this._messageIdx,this.handleMessage=n=>{if(!n.type||!n.data)return;ge.info("[received message]",n);const i=n.idx,s=this.responseCallbacks.get(i);switch(i&&this.responseCallbacks.delete(i),n.type){case Ye.MESSAGE:if(s)this.emit(Ye.MESSAGE,n),s(n.data.error,n);else throw new Error("impossible state");break;case Ye.DISCONNECT:case Ye.ACCOUNTS_CHANGED:case Ye.CHAIN_CHANGED:this.emit(n.type,n.data);break;default:console.error("unknown message type",n);break}},this.sendMessageRequest=async function(n){return new Promise((i,s)=>{(!n.idx||n.idx<=0)&&s(new Error("message idx not set"));const o=(c,l)=>{if(c)s(c);else if(l)i(l);else throw new Error("no valid response to return")},{idx:a}=n;r.responseCallbacks.get(a)?s(new Error("duplicate message idx, should never happen")):r.responseCallbacks.set(a,o),r.sendMessage(n)})},this.stream=e,this.stream.on("data",this.handleMessage)}sendMessage(e){this.stream.writable||console.error("window post message stream is not writable"),this.stream.write(e)}}let wu;class PU extends tp{constructor(e){super(),this.register=()=>{wu&&(wu.unregister(),wu=this),window.addEventListener("message",this.onWindowEvent),wu=this,this.on("open",()=>{const r=this.walletWindow,n=setInterval(()=>{r&&r.closed&&(clearInterval(n),this.close())},500)}),this.on("close",()=>{this.walletWindow&&(this.walletWindow.close(),this.walletWindow=null)}),this._registered=!0},this.unregister=()=>{this._registered=!1,this.closeWallet(),wu===this&&(wu=void 0),window.removeEventListener("message",this.onWindowEvent),this.events.removeAllListeners()},this.openWallet=(r,n,i)=>{if(this.walletWindow&&this.isOpened()){this.walletWindow.focus();return}const s=new URL(this.walletURL.href),o=new ep;r&&r!==""&&(s.pathname=r.toLowerCase()),this._init=Wt.NIL,this._sessionId=`${performance.now()}`,o.set("sid",this._sessionId),n&&(n.type==="connect"&&(n.options||(n.options={app:window.location.origin}),!$y()&&!wU()&&n.options&&(n.options.origin=window.location.origin)),o.set("intent",o8(n))),i&&o.set("net",`${i}`);let a,c;$y()?(a=[450,750],c=[Math.abs(window.screen.width/2-a[0]/2),Math.abs(window.screen.height/2-a[1]/2)]):(a=[450,750],c=[Math.abs(window.screenX+window.innerWidth/2-a[0]/2),Math.abs(window.screenY+window.innerHeight/2-a[1]/2)]);const l=`toolbar=0,location=0,menubar=0,scrollbars=yes,status=yes,width=${a[0]},height=${a[1]},left=${c[0]},top=${c[1]}`;s.search=o.toString(),this.walletWindow=window.open(s.href,"sequence.app",l)},this.onWindowEvent=r=>{if(r.origin!==this.walletURL.origin)return;let n;try{n=JSON.parse(r.data)}catch{return}if(!n)throw new Error("ProviderMessage object is empty");this.handleMessage(n)},this.walletURL=new URL(e)}closeWallet(){var e;this.close(),(e=this.walletWindow)==null||e.close()}sendMessage(e){if(!this.walletWindow){ge.warn("WindowMessageProvider: sendMessage failed as walletWindow is unavailable");return}const r=typeof e!="string"?JSON.stringify(e):e;this.walletWindow.postMessage(r,this.walletURL.origin)}}class Pye extends rp{constructor(e){var r;super(e),r=this,this._isPopup=!1,this.onWindowEvent=async function(n){if(!n.origin||n.origin===""||r.appOrigin&&n.origin!==r.appOrigin)return;let i;try{i=JSON.parse(n.data)}catch{return}if(ge.debug("RECEIVED MESSAGE",i),r._init!==Wt.OK&&r.isValidInitAck(i)&&(r.appOrigin=n.origin),r._init===Wt.OK&&(!r.appOrigin||r.appOrigin.length<8)){ge.error("impossible state, init.OK and appOrigin required");return}r.handleMessage(i)},this.getWindowTransportSession=n=>{const i=new ep(n);return{sessionId:i.get("sid"),networkId:i.get("net"),intent:a8(i.get("intent"))}},this._init=Wt.NIL}async register(e){const r=parent.window.opener!==null;if(this._isPopup=r,r!==!0)return;const{pathname:n,search:i}=new URL(e||window.location.href);let s=this.getWindowTransportSession(i);if(!!s.sessionId||(s=await this.getCachedTransportSession()),!s){ge.error("window session is undefined");return}this.parentWindow=parent.window.opener,window.addEventListener("message",this.onWindowEvent,!1),this._registered=!0,this.open(s).then(a=>{if(!a){var c;const l=`failed to open to network ${(c=s)==null?void 0:c.networkId}`;ge.error(l),this.notifyClose({message:l}),window.close()}}).catch(a=>{var c;const l=`failed to open to network ${(c=s)==null?void 0:c.networkId}, due to: ${a}`;ge.error(l),this.notifyClose({message:l}),window.close()})}unregister(){window.removeEventListener("message",this.onWindowEvent),this._registered=!1}sendMessage(e){const r=JSON.stringify(e);e.type===Ye.INIT?this.postMessage(r,!0):this.postMessage(r)}get isPopup(){return this._isPopup}postMessage(e,r=!1){if(r!==!0&&this._init!==Wt.OK){ge.error("impossible state, should not be calling postMessage until inited");return}r?this.parentWindow.postMessage(e,"*"):this.appOrigin&&this.appOrigin.length>4?this.parentWindow.postMessage(e,this.appOrigin):ge.error("unable to postMessage as parentOrigin is invalid")}}function TU(t){return t&&typeof t=="object"&&(t.windowTransport&&typeof t.windowTransport=="object"||t.proxyTransport&&typeof t.proxyTransport=="object"||t.extensionTransport&&typeof t.extensionTransport=="object"||t.unrealTransport&&typeof t.unrealTransport=="object")&&(t.windowTransport&&t.windowTransport.enabled||t.proxyTransport&&t.proxyTransport.enabled||t.extensionTransport&&t.extensionTransport.enabled||t.unrealTransport&&t.unrealTransport.enabled)}class zb{constructor(...e){var r=this;this.register=()=>{if(this.messageProviders.length===1){this.provider=this.messageProviders[0],this.provider.register();return}this.messageProviders.forEach(n=>{n.register(),n.once("open",()=>{this.provider||(this.provider=n,this.messageProviders.forEach(i=>{this.provider!==i&&i.unregister()}))})})},this.unregister=()=>{this.messageProviders.forEach(n=>n.unregister()),this.provider=void 0},this.openWallet=(n,i,s)=>{if(this.provider){this.provider.openWallet(n,i,s);return}this.messageProviders.forEach(o=>o.openWallet(n,i,s))},this.sendAsync=async function(n,i,s){if(r.provider){r.provider.sendAsync(n,i,s);return}throw new Error("impossible state, wallet must be opened first")},this.sendMessageRequest=async function(n){if(r.provider)return r.provider.sendMessageRequest(n);throw new Error("impossible state, wallet must be opened first")},this.waitUntilOpened=async function(){return r.provider?r.provider.waitUntilOpened():Promise.race(r.messageProviders.map(n=>n.waitUntilOpened()))},this.waitUntilConnected=async function(){if(r.provider)return r.provider.waitUntilConnected();throw new Error("impossible state, wallet must be opened first")},this.messageProviders=e,this.provider=void 0}static new(e){var r,n,i,s;const o=new zb;if((r=e.windowTransport)!=null&&r.enabled&&typeof window=="object"&&e.walletAppURL){const a=new PU(e.walletAppURL);o.add(a)}if((n=e.proxyTransport)!=null&&n.enabled){const a=new SU(e.proxyTransport.appPort);o.add(a)}if((i=e.extensionTransport)!=null&&i.enabled){const a=new _U(e.extensionTransport.runtime);o.add(a)}if((s=e.unrealTransport)!=null&&s.enabled&&e.windowTransport&&e.walletAppURL){const a=new AU(e.walletAppURL);o.add(a)}return o.register(),o}add(...e){this.messageProviders.push(...e)}closeWallet(){this.provider&&this.provider.closeWallet()}isOpened(){return this.provider?this.provider.isOpened():!1}isConnected(){return this.provider?this.provider.isConnected():!1}on(e,r){if(this.provider){this.provider.on(e,r);return}this.messageProviders.forEach(n=>{n.on(e,r)})}once(e,r){if(this.provider){this.provider.once(e,r);return}this.messageProviders.forEach(n=>{n.once(e,r)})}emit(e,...r){if(this.provider)return this.provider.emit(e,...r);for(let n=0;nOye(t,i))}function Oye(t,e){if(e.to.toLowerCase()===t.toLowerCase()&&e.data){const r=re(e.data);if(r.length>=4&&!Rye(r))throw new Error("self calls are forbidden")}if(e.delegateCall)throw new Error("delegate calls are forbidden")}function Rye(t){const e=new jr(rn.mainModule.abi);try{return e.decodeFunctionData("createContract",t),!0}catch{return!1}}const $ye=1e4;class Mye{constructor(e,r,n){var i=this;this.signerReadyCallbacks=[],this.events=new jb.EventEmitter2,this.onConnectOptionsChange=void 0,this.promptConnect=async function(s){if(!s&&!i._connectOptions)throw new Error("prompter connect options are empty");if(!i.prompter)return i.connect(s);const o=await i.prompter.promptConnect(s||i._connectOptions).catch(c=>({connected:!1})),a=o;return a.connected&&!a.session&&(a.session=await i.walletSession(s==null?void 0:s.networkId)),o},this.sendAsync=async function(s,o,a){const c={jsonrpc:"2.0",id:s.id,result:null};await i.getAccount();try{var l;if((!i.account||i.account===null)&&!Nye.includes(s.method))throw vU;const f=i.account;if(!f)throw new Error("WalletRequestHandler: wallet account is not configured");const d=(l=i.account)==null?void 0:l.providerFor(a??i.defaultChainId());if(!d)throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${a}`);const h=d instanceof Ko?d:void 0;switch(s.method){case"net_version":{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send("net_version",[]);c.result=p;break}case"eth_chainId":{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send("eth_chainId",[]);c.result=p;break}case"eth_accounts":{const p=f.address;c.result=[p];break}case"eth_getBalance":{const[p,v]=s.params,b=await d.getBalance(p,v);c.result=b.toHexString();break}case"sequence_sign":case"personal_sign":case"eth_sign":{let p;switch(s.method){case"sequence_sign":case"personal_sign":{const[m,g]=s.params;p=m;break}case"eth_sign":{const[m,g]=s.params;p=g;break}}let v="";const b=Ub(p),y=s.method==="sequence_sign";if(i.prompter===null?v=await f.signMessage(b,a??i.defaultChainId(),y?"eip6492":"ignore"):v=await i.prompter.promptSignMessage({chainId:a,message:b,eip6492:y},i.connectOptions),v&&v.length>0)c.result=v;else throw new Error("declined by user");break}case"sequence_signTypedData_v4":case"eth_signTypedData":case"eth_signTypedData_v4":{const[p,v]=s.params;let b;if(typeof v=="string")try{b=JSON.parse(v)}catch(g){console.warn("walletRequestHandler: error parsing typedData",g)}else b=v;if(!b||!b.domain||!b.types||!b.message)throw new Error("invalid typedData object");let y="";const m=s.method==="sequence_signTypedData_v4";if(i.prompter===null?y=await f.signTypedData(b.domain,b.types,b.message,a??i.defaultChainId(),m?"eip6492":"ignore"):y=await i.prompter.promptSignMessage({chainId:a,typedData:b,eip6492:m},i.connectOptions),y&&y.length>0)c.result=y;else throw new Error("declined by user");break}case"eth_sendTransaction":{const p=Iye(s.params[0]).map(b=>("gas"in b&&b.gasLimit===void 0&&(b.gasLimit=b.gas,delete b.gas),b));HT(f.address,p);let v="";if(i.prompter===null){var u;const b=await f.sendTransaction(p,a??i.defaultChainId());v=(u=b==null?void 0:b.hash)!=null?u:""}else v=await i.prompter.promptSendTransaction(p,a,i.connectOptions);if(v)c.result=v;else throw new Error("declined by user");break}case"eth_signTransaction":{const[p]=s.params;if(Ve(p.from)!==f.address)throw new Error("sender address does not match wallet");HT(f.address,p),i.prompter===null?c.result=await f.signTransactions(p,a??i.defaultChainId()):c.result=await i.prompter.promptSignTransaction(p,a,i.connectOptions);break}case"eth_sendRawTransaction":{if(he.transaction.isSignedTransactionBundle(s.params[0])){const p=J.from(s.params[0].chainId).toNumber(),v=await f.relayer(p).relay(s.params[0]);c.result=v.hash}else{const p=await d.sendTransaction(s.params[0]);c.result=p.hash}break}case"eth_getTransactionCount":{const p=Ve(s.params[0]),v=s.params[1],b=await d.getTransactionCount(p,v);c.result=J.from(b).toHexString();break}case"eth_blockNumber":{c.result=await d.getBlockNumber();break}case"eth_getBlockByNumber":{c.result=await d.getBlock(s.params[0]);break}case"eth_getBlockByHash":{c.result=await d.getBlock(s.params[0]);break}case"eth_getTransactionByHash":{c.result=await d.getTransaction(s.params[0]);break}case"eth_call":{const[p,v]=s.params;c.result=await d.call(p,v);break}case"eth_getCode":{const[p,v]=s.params;c.result=await d.getCode(p,v);break}case"eth_estimateGas":{const[p]=s.params;c.result=await d.estimateGas(p);break}case"eth_gasPrice":{const p=await d.getGasPrice();c.result=p.toHexString();break}case"wallet_switchEthereumChain":{const[p]=s.params;if(!p.chainId||p.chainId.length===0)throw new Error("invalid chainId");const v=J.from(p.chainId);i.setDefaultChainId(v.toNumber()),c.result=null;break}case"sequence_getWalletContext":{c.result=f.contexts;break}case"sequence_getWalletConfig":{const[p]=s.params;p?c.result=[(await f.status(p)).onChain.config]:c.result=await Promise.all(f.networks.map(async function(v){return(await f.status(v.chainId)).onChain.config}));break}case"sequence_getWalletState":{const[p]=s.params;p?c.result=[qT(p,await f.status(p))]:c.result=await Promise.all(f.networks.map(async function(v){const b=await f.status(v.chainId);return qT(v.chainId,b)}));break}case"sequence_getNetworks":{c.result=await i.getNetworks(!0);break}case"sequence_isSequence":{c.result=!0;break}case"sequence_updateConfig":throw new Error("sequence_updateConfig method is not allowed from a dapp");case"sequence_publishConfig":throw new Error("sequence_publishConfig method is not allowed from a dapp");case"sequence_gasRefundOptions":break;case"sequence_getNonce":break;case"sequence_relay":break;case"sequence_setDefaultNetwork":{const[p]=s.params;if(!p)throw new Error("invalid request, method argument defaultChainId cannot be empty");i.setDefaultChainId(p),c.result=await i.getNetworks(!0);break}default:{if(!h)throw new Error("Account provider doesn't support send method");const p=await h.send(s.method,s.params);c.result=p}}}catch(f){ge.error(f),c.result=null,c.error=Jn({},new Error(f),{code:4001})}o(void 0,c)},this.isSignedIn=async function(){return await i.signerReady(),!!i.account},this.getAccount=async function(){if(await i.signerReady(),i.account===void 0)throw new Error("signerReady failed resolve");return i.account},this.account=e,this.prompter=r,this.networks=n}defaultChainId(){var e,r;return(e=(r=this.prompter)==null?void 0:r.getDefaultChainId())!=null?e:this.networks[0].chainId}async signIn(e,r={}){this.setAccount(e);const{connect:n,defaultNetworkId:i}=r;if(n){const a=this._connectOptions;let c;if(this.prompter!==null){var s;c=await((s=this.prompter)==null?void 0:s.promptSignInConnect(a))}else c=await this.connect(a);this.notifyConnect(c),(!a||a.keepWalletOpened!==!0)&&this.notifyClose()}if(i&&this.defaultChainId()!==i){var o;await((o=this.prompter)==null?void 0:o.promptChangeNetwork(i))}}signOut(){this.setAccount(null)}signerReset(){this.account=void 0}signerReady(e=$ye){return new Promise((r,n)=>{this.account!==void 0?r():(setTimeout(()=>{this.account===void 0&&(this.signerReadyCallbacks=[],n("signerReady timed out"))},e),this.signerReadyCallbacks.push(r))})}async connect(e){var r,n;if(!this.account)return{connected:!1,chainId:"0x0",error:"unable to connect without signed in account"};const i=(r=(n=e==null?void 0:e.networkId)!=null?n:this.defaultChainId())!=null?r:ce.MAINNET,s=d8(i).chainId,o={connected:!0,chainId:Es(s)};if(e&&e.authorize){const a={app:e.app,origin:e.origin,expiry:e.expiry,nonce:e.authorizeNonce};try{o.proof=await nU(this.account,s,a)}catch(c){return ge.warn(`connect, signAuthorization failed for options: ${JSON.stringify(e)}, due to: ${c.message}`),{connected:!1,chainId:"0x0",error:`signAuthorization failed: ${c.message}`}}}return o.session=this.walletSession(s),o}sendMessageRequest(e){return new Promise(r=>{this.sendAsync(e.data,(n,i)=>{const s=Jn({},e,{data:i});r(s)},e.chainId)})}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}async getAddress(){var e,r;return(e=(r=this.account)==null?void 0:r.address)!=null?e:""}get openIntent(){return this._openIntent}setOpenIntent(e){this._openIntent=e}get connectOptions(){return this._connectOptions}setConnectOptions(e){var r;this._connectOptions=e,(r=this.onConnectOptionsChange)==null||r.call(this,e)}async setDefaultChainId(e){var r;return await((r=this.prompter)==null?void 0:r.promptChangeNetwork(e)),this.defaultChainId()}async getNetworks(e){return this.account?e?this.account.networks.map(r=>{const n=Jn({},r);return n.provider=void 0,n.relayer=void 0,n}):this.account.networks:(ge.warn("signer not set: getNetworks is returning an empty list"),[])}walletSession(e){if(!this.account)return;const r={walletContext:this.account.contexts,accountAddress:this.account.address,networks:this.account.networks.map(i=>Jn({},i,{provider:void 0,relayer:void 0}))};if(e){const i=xs(r.networks,e);if(i){var n;(n=r.networks)==null||n.forEach(s=>delete s.isDefaultChain),i.isDefaultChain=!0}}return r}notifyConnect(e,r){var n;if(console.log("emit connect",e),this.events.emit("connect",e),(n=e.session)!=null&&n.accountAddress){var i;this.events.emit("accountsChanged",[(i=e.session)==null?void 0:i.accountAddress],r)}}notifyDisconnect(e){this.events.emit("accountsChanged",[],e),this.events.emit("disconnect",void 0,e)}notifyChainChanged(e,r){this.events.emit("chainChanged",Es(e),r)}async notifyNetworks(e){const r=e||await this.getNetworks(!0);if(this.events.emit("networks",r),r.length>0){const n=r.find(i=>i.chainId===this.defaultChainId());n&&this.events.emit("chainChanged",Es(n.chainId))}else this.events.emit("chainChanged","0x0")}async notifyWalletContext(){if(!this.account){ge.warn("signer not set: skipping to notify wallet context");return}const e=this.account.contexts;this.events.emit("walletContext",e)}notifyClose(e){this.events.emit("close",e)}setAccount(e){if(this.account=e,e!==void 0){for(let r=0;rc.canOnchainValidate||c.original.version===2&&n,o=await r.status(i);if(s(o))return!0;if(await e.promptConfirmWalletDeploy(i,this.connectOptions)){const c=await r.status(i);return s(c)?!0:(ge.error("WalletRequestHandler: result for promptConfirmWalletDeploy is not correct"),!1)}return!1}}function qT(t,e){return{context:e.original.context,config:e.onChain.config,address:he.context.addressOf(e.original.context,e.original.imageHash),chainId:t,deployed:e.onChain.deployed,imageHash:e.imageHash,lastImageHash:e.onChain.imageHash,published:!0,status:e}}const Nye=["net_version","eth_chainId","eth_getBalance","eth_getTransactionCount","eth_blockNumber","eth_getBlockByNumber","eth_getBlockByHash","eth_getTransactionByHash","eth_getCode","eth_estimateGas","eth_gasPrice","sequence_getWalletContext","sequence_getNetworks","sequence_setDefaultNetwork"];class _d{get utils(){return this.provider.utils}constructor(e,r){this.singleNetworkSigners={},this._isSigner=!0,this._isSequenceSigner=!0,this.client=e,this.provider=r}async getAddress(){return this.client.getAddress()}connect(e){if(!Pd.is(e))throw new Error("SequenceSigner can only be connected to a SequenceProvider");return new _d(this.client,e)}getSigner(e){if(!e)return this;const r=this.provider.toChainId(e);return this.singleNetworkSigners[r]||(this.singleNetworkSigners[r]=new U8(this.client,this.provider,r)),this.singleNetworkSigners[r]}useChainId(e){return this.provider.toChainId(e)||this.client.getChainId()}async signMessage(e,r){const{eip6492:n=!0}=r||{},i=this.useChainId(r==null?void 0:r.chainId);return this.client.signMessage(e,{eip6492:n,chainId:i})}async signTypedData(e,r,n,i){const{eip6492:s=!0}=i||{},o=this.useChainId(i==null?void 0:i.chainId);return this.client.signTypedData({domain:e,types:r,message:n},{eip6492:s,chainId:o})}getProvider(e){return this.provider.getProvider(e)}async sendTransaction(e,r){const n=this.useChainId(r==null?void 0:r.chainId),i=await CU(e),s=await this.client.sendTransaction(i,{chainId:n}),o=this.getProvider(n);try{return await Wa(async function(){const a=await o.getTransaction(s);return a?o._wrapTransaction(a,s):void 0},{onceBlock:o})}catch(a){throw a.transactionHash=s,a}}async getWalletConfig(e){const r=this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}getNetworks(){return this.client.getNetworks()}async getBalance(e,r){return this.getProvider(r==null?void 0:r.chainId).getBalance(this.getAddress(),e)}async estimateGas(e,r){return this.getProvider(r==null?void 0:r.chainId).estimateGas(e)}async call(e,r,n){return this.getProvider(n==null?void 0:n.chainId).call(e,r)}getChainId(){return Promise.resolve(this.client.getChainId())}async getGasPrice(e){return this.getProvider(e==null?void 0:e.chainId).getGasPrice()}async getFeeData(e){return this.getProvider(e==null?void 0:e.chainId).getFeeData()}async resolveName(e){const r=await this.provider.resolveName(e);if(r===null)throw new Error(`ENS name not found: ${e}`);return r}_checkProvider(e){}populateTransaction(e){throw new Error("SequenceSigner does not support populateTransaction")}checkTransaction(e){throw new Error("SequenceSigner does not support checkTransaction")}getTransactionCount(e){throw new Error("SequenceSigner does not support getTransactionCount")}signTransaction(e){throw new Error("SequenceWallet does not support signTransaction, use sendTransaction instead.")}static is(e){return e&&typeof e=="object"&&e._isSequenceSigner===!0}}class U8 extends _d{constructor(e,r,n){super(e,r.getProvider(n)),this._isSingleNetworkSequenceSigner=!0,this.chainId=n}_useChainId(e){const r=this.provider.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This signer only supports the network ${this.chainId}, but ${r} was requested.`);return r||this.provider.toChainId(this.chainId)}useChainId(e){return this._useChainId(e)}getChainId(){return Promise.resolve(this.provider.toChainId(this.chainId))}getProvider(e){return super.getProvider(this._useChainId(e))}getSigner(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceSigner===!0}}class Dye{constructor(e){if(this.signer=e,U8.is(e))throw new Error("WalletUtils does not support SingleNetworkSequenceSigner")}signMessage(e,r,n){return this.signer.signMessage(e,{chainId:r,eip6492:n})}signTypedData(e,r,n,i,s){return this.signer.signTypedData(e,r,n,{chainId:i,eip6492:s})}async isValidSignature(e,r,n,i){return Qf(e,r,n,this.signer.getProvider(i))}async isValidMessageSignature(e,r,n,i){const s=this.signer.getProvider(i),o=Ub(r),a=c8(o);return Qf(e,a,n,s)}isValidTypedDataSignature(e,r,n,i){return this.isValidSignature(e,Q1(r),n,i)}}class Pd extends Og{constructor(e,r,n=Vf){super(e.getChainId()),this.singleNetworkProviders={},this._isSequenceProvider=!0,this.client=e,this.providerFor=r,this.networks=n,e.onConnect(i=>{this.emit("connect",i)}),e.onDisconnect(i=>{this.emit("disconnect",i)}),e.onDefaultChainIdChanged(i=>{this.emit("chainChanged",i)}),e.onAccountsChanged(i=>{this.emit("accountsChanged",i)}),this.signer=new _d(this.client,this),this.utils=new Dye(this.signer)}getSigner(e){return this.signer.getSigner(e)}connect(e){return this.client.connect(e)}disconnect(){return this.client.disconnect()}isConnected(){return this.client.isConnected()}getSession(){return this.client.getSession()}listAccounts(){return[this.client.getAddress()]}getAddress(){return this.client.getAddress()}getNetworks(){return this.client.getNetworks()}getChainId(){return this.client.getChainId()}setDefaultChainId(e){return this.client.setDefaultChainId(this.toChainId(e))}isOpened(){return this.client.isOpened()}closeWallet(){return this.client.closeWallet()}getWalletContext(){return this.client.getWalletContext()}async getWalletConfig(e){const r=await this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}authorize(e){return this.client.connect(Jn({},e,{authorize:!0}))}async openWallet(e,r){return await this.client.openWallet(e,r),!0}toChainId(e){if(e===void 0)return;const r=xs(this.networks,e);if(!r)throw new Error(`Unsupported network ${e}`);return r.chainId}async useChainId(e){return this.toChainId(e)||this.client.getChainId()}getProvider(e){if(!e)return this;const r=this.toChainId(e);return this.singleNetworkProviders[r]||(this.singleNetworkProviders[r]=new OU(this.client,this.providerFor,r)),this.singleNetworkProviders[r]}async _getSubprovider(e){const r=await this.useChainId(e),n=this.providerFor(r);if(!n)throw new Error(`Unsupported network ${r}`);return n}async perform(e,r){var n;if(e==="eth_chainId")return Es(await this.useChainId());if(e==="eth_accounts")return[this.client.getAddress()];if(e==="wallet_switchEthereumChain"){const o=r[0],a=IU(o);return this.setDefaultChainId(a)}if(e==="eth_sendTransaction"||e==="eth_sign"||e==="eth_signTypedData"||e==="eth_signTypedData_v4"||e==="personal_sign"||e==="sequence_sign"||e==="sequence_signTypedData_v4")return this.client.send({method:e,params:r},this.getChainId());const i=await this._getSubprovider(),s=(n=i.prepareRequest(e,r))!=null?n:[e,r];return i.send(s[0],s[1])}send(e,r){return this.perform(e,r)}request(e){return this.perform(e.method,e.params)}async detectNetwork(){const e=this.client.getChainId(),r=xs(this.networks,e);if(!r)throw new Error(`Unknown network ${e}`);return r}async waitForTransaction(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).waitForTransaction(e,r,n)}async getBlockNumber(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getBlockNumber()}async getGasPrice(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getGasPrice()}async getBalance(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBalance(e,r)}async getTransactionCount(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getTransactionCount(e,r)}async getCode(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getCode(e,r)}async getStorageAt(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).getStorageAt(e,r,n)}async call(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).call(e,r)}async estimateGas(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).estimateGas(e)}async getBlock(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getBlock(e)}async getTransaction(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getTransaction(e)}async getLogs(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getLogs(e)}async supportsENS(){return(await this.getNetworks()).some(r=>r.chainId===1)}async getResolver(e){return await this.supportsENS()?(await this._getSubprovider(1)).getResolver(e):null}async resolveName(e){return UR(await e)?e:await this.supportsENS()?(await this._getSubprovider(1)).resolveName(e):null}async lookupAddress(e){return await this.supportsENS()?(await this._getSubprovider(1)).lookupAddress(e):null}async getAvatar(e){return await this.supportsENS()?(await this._getSubprovider(1)).getAvatar(e):null}}Pd.is=t=>t&&typeof t=="object"&&t._isSequenceProvider===!0;function IU(t){return typeof t=="object"?IU(t.chainId):J.from(t).toNumber()}class OU extends Pd{constructor(e,r,n){super(e,r),this._isSingleNetworkSequenceProvider=!0,this.chainId=n}_useChainId(e){const r=this.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This provider only supports the network ${this.chainId}, but ${r} was requested.`);return r||super.toChainId(this.chainId)}useChainId(e){return Promise.resolve(this._useChainId(e))}getChainId(){return super.toChainId(this.chainId)}async getNetwork(){const e=await this.client.getNetworks(),r=xs(e,this.chainId);if(!r)throw new Error(`Unsupported network ${this.chainId}`);return r}getProvider(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}getSigner(e){return super.getSigner(this._useChainId(e))}setDefaultChainId(e){throw new Error(`This provider only supports the network ${this.chainId}; use the parent provider to switch networks.`)}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceProvider===!0}}var Lye={name:"@0xsequence/provider",version:"1.4.9",description:"provider sub-package for Sequence",repository:"https://github.com/0xsequence/sequence.js/tree/master/packages/provider",source:"src/index.ts",main:"dist/0xsequence-provider.cjs.js",module:"dist/0xsequence-provider.esm.js",author:"Horizon Blockchain Games",license:"Apache-2.0",scripts:{test:"pnpm test:concurrently 'pnpm test:run'","test:run":"pnpm test:file tests/**/*.spec.ts","test:file":"NODE_OPTIONS='--loader tsx' mocha --timeout 30000",typecheck:"tsc --noEmit","test:concurrently":"concurrently -k --success first 'pnpm start:hardhat1' 'pnpm start:hardhat2'","start:hardhat1":"pnpm start:hardhat1:verbose > /dev/null 2>&1","start:hardhat2":"pnpm start:hardhat2:verbose > /dev/null 2>&1","start:hardhat1:verbose":"hardhat node --config hardhat1.config.js --hostname 0.0.0.0 --port 9595","start:hardhat2:verbose":"hardhat node --config hardhat2.config.js --hostname 0.0.0.0 --port 8595"},dependencies:{"@0xsequence/abi":"workspace:*","@0xsequence/account":"workspace:*","@0xsequence/auth":"workspace:*","@0xsequence/core":"workspace:*","@0xsequence/migration":"workspace:*","@0xsequence/network":"workspace:*","@0xsequence/relayer":"workspace:*","@0xsequence/utils":"workspace:*","@0xsequence/wallet":"workspace:*",eventemitter2:"^6.4.5","webextension-polyfill":"^0.10.0"},peerDependencies:{ethers:">=5.5 < 6"},devDependencies:{"@types/webextension-polyfill":"^0.10.0",hardhat:"^2.12.2",ethers:"^5.7.2"},files:["src","dist"]};class Sl{constructor(e){this.store=e}connectedSession(){const e=this.getSession();if(e&&e.accountAddress&&e.walletContext&&e.networks)return{accountAddress:e.accountAddress,walletContext:e.walletContext,networks:e.networks};throw new Error("Sequence session not connected")}hasSession(){var e;return((e=this.getSession())==null?void 0:e.accountAddress)!==void 0}setSession(e){return this.store.setItem(Sl.SESSION_LOCALSTORE_KEY,JSON.stringify(e))}getSession(){const e=this.store.getItem(Sl.SESSION_LOCALSTORE_KEY);if(e)return JSON.parse(e)}async clearSession(){return this.store.removeItem(Sl.SESSION_LOCALSTORE_KEY)}}Sl.SESSION_LOCALSTORE_KEY="@sequence.session";class kl{constructor(e,r=1){this.callbacks=[],this.store=e,this.startingChainId=r,e.onItemChange(kl.SESSION_CHAIN_ID_KEY,n=>{if(n){const i=parseInt(n);this.callbacks.forEach(s=>s(i))}})}onDefaultChainIdChanged(e){return this.callbacks.push(e),()=>{this.callbacks=this.callbacks.filter(r=>r!==e)}}setDefaultChainId(e){e!==this.getDefaultChainId()&&this.store.setItem(kl.SESSION_CHAIN_ID_KEY,e.toString())}getDefaultChainId(){const e=this.store.getItem(kl.SESSION_CHAIN_ID_KEY);return!e||e.length===0?this.startingChainId:parseInt(e)}}kl.SESSION_CHAIN_ID_KEY="@sequence.session.defaultChainId";class z8{constructor(e,r,n,i){var s;if(this.callbacks={},this.projectAccessKey=i,TU(e))this.transport=zb.new(e);else if(hU(e))this.transport=e;else throw new Error("Invalid transport");const o=typeof n=="number"?n:n==null?void 0:n.defaultChainId;this.defaultEIP6492=typeof n=="number"?!1:(s=n==null?void 0:n.defaultEIP6492)!=null?s:!1,this.session=new Sl(r),this.defaultChainId=new kl(r,o),this.transport.on("accountsChanged",a=>{var c;a.length>1&&console.warn("SequenceClient: wallet-webapp returned more than one account"),(c=this.callbacks.accountsChanged)==null||c.forEach(l=>l(a))}),this.transport.on("connect",a=>{var c;const l=Es(this.getChainId());(c=this.callbacks.connect)==null||c.forEach(u=>u(Jn({},a,{chainId:l})))}),this.transport.on("disconnect",(a,c)=>{var l;(l=this.callbacks.disconnect)==null||l.forEach(u=>u(a,c))}),this.transport.on("networks",a=>{var c;(c=this.callbacks.networks)==null||c.forEach(l=>l(a))}),this.transport.on("walletContext",a=>{var c;(c=this.callbacks.walletContext)==null||c.forEach(l=>l(a))}),this.transport.on("open",a=>{var c;(c=this.callbacks.open)==null||c.forEach(l=>l(a))}),this.transport.on("close",()=>{var a;(a=this.callbacks.close)==null||a.forEach(c=>c())}),this.transport.on("chainChanged",(a,c)=>{var l;(l=this.callbacks.chainChanged)==null||l.forEach(u=>u(a,c))}),this.defaultChainId.onDefaultChainIdChanged(a=>{var c;const l=Es(a);(c=this.callbacks.chainChanged)==null||c.forEach(u=>u(l))})}registerCallback(e,r){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(r),()=>{this.callbacks[e]=this.callbacks[e].filter(n=>n!==r)}}onOpen(e){return this.registerCallback("open",e)}onClose(e){return this.registerCallback("close",e)}onConnect(e){return this.registerCallback("connect",e)}onDisconnect(e){return this.registerCallback("disconnect",e)}onNetworks(e){return this.registerCallback("networks",e)}onAccountsChanged(e){return this.registerCallback("accountsChanged",e)}onWalletContext(e){return this.registerCallback("walletContext",e)}onChainChanged(e){return this.registerCallback("chainChanged",e)}onDefaultChainIdChanged(e){return this.registerCallback("chainChanged",e)}getChainId(){return this.defaultChainId.getDefaultChainId()}setDefaultChainId(e){return this.defaultChainId.setDefaultChainId(e)}async openWallet(e,r){return this.transport.openWallet(e,r,this.getChainId()),await this.transport.waitUntilOpened(),this.isOpened()}closeWallet(){return this.transport.closeWallet()}isOpened(){return this.transport.isOpened()}isConnected(){return this.session.hasSession()}getSession(){return this.session.getSession()}getAddress(){return this.session.connectedSession().accountAddress}async connect(e){if((e==null?void 0:e.authorizeVersion)===void 0&&(e.authorizeVersion=2),(e==null?void 0:e.refresh)===!0&&this.disconnect(),e.projectAccessKey=this.projectAccessKey,e&&e.authorize){if(!e.app)throw new Error("connecting with 'authorize' option also requires 'app' to be set");e.authorizeVersion===void 0&&(e.authorizeVersion=2)}await this.openWallet(void 0,{type:"connect",options:Jn({},e,{networkId:this.getChainId(),clientVersion:Lye.version})});const r=await this.transport.waitUntilConnected().catch(n=>n instanceof Error?{connected:!1,error:n.message}:{connected:!1,error:JSON.stringify(n)});if(r.chainId&&(r.chainId=J.from(r.chainId).toString()),r.connected){if(!r.session)throw new Error("impossible state, connect response is missing session");this.session.setSession(r.session)}return r}disconnect(){return this.isOpened()&&this.closeWallet(),this.session.clearSession()}send(e,r){return e.method=this.mapSignMethod(e.method),new Promise((n,i)=>{this.transport.sendAsync(e,(s,o)=>{s?i(s):o===void 0?i(new Error(`Got undefined response for request: ${e}`)):typeof o=="object"&&o.error?i(o.error):typeof o=="object"&&o.result?n(o.result):i(new Error(`Got invalid response for request: ${e}`))},r||this.getChainId())})}async getNetworks(e){const r=this.session.connectedSession();return e&&(r.networks=await this.send({method:"sequence_getNetworks"}),this.session.setSession(r)),r.networks}signMethod(e){return(e==null?void 0:e.eip6492)===void 0?"personal_sign":e.eip6492?"sequence_sign":"legacy_sign"}signTypedDataMethod(e){return(e==null?void 0:e.eip6492)===void 0?"eth_signTypedData_v4":e.eip6492?"sequence_signTypedData_v4":"legacy_signTypedData_v4"}mapSignMethod(e){return e==="personal_sign"?this.defaultEIP6492?"sequence_sign":"personal_sign":e==="eth_signTypedData_v4"?this.defaultEIP6492?"sequence_signTypedData_v4":"eth_signTypedData_v4":e==="legacy_sign"?"personal_sign":e==="legacy_signTypedData_v4"?"eth_signTypedData_v4":e}async signMessage(e,r){const n=this.signMethod(r);return this.send({method:n,params:[e,this.getAddress()]},r==null?void 0:r.chainId)}async signTypedData(e,r){const n=this.signTypedDataMethod(r),i=qr.getPayload(e.domain,e.types,e.message);return this.send({method:n,params:[this.getAddress(),i]},(r==null?void 0:r.chainId)||e.domain.chainId&&J.from(e.domain.chainId).toNumber()||this.getChainId())}async sendTransaction(e,r){const n=Array.isArray(e)?e:[e],i=Tye(n);return this.send({method:"eth_sendTransaction",params:[i]},r==null?void 0:r.chainId)}async getWalletContext(){return this.send({method:"sequence_getWalletContext"})}async getOnchainWalletConfig(e){const r=await this.send({method:"sequence_getWalletConfig",params:[(e==null?void 0:e.chainId)||this.getChainId()]},e==null?void 0:e.chainId);return Array.isArray(r)?r[0]:r}}const h5={transports:{walletAppURL:"https://sequence.app",windowTransport:{enabled:!0},proxyTransport:{enabled:!1}},defaultNetwork:1};let Js;const RU=t=>{var e,r,n;const i=t==null?void 0:t.projectAccessKey;if(i||console.warn("Please pass a projectAccessKey in initWallet config as it will be required in near future."),Js)return Js;const s=Jn({},h5,t,{transports:Jn({},h5.transports,t==null?void 0:t.transports)}),o={},a=(e=(r=s.networks)==null?void 0:r.filter(h=>{h.rpcUrl!==void 0&&h.chainId!==void 0&&Vf.find(p=>p.chainId===h.chainId)}))!=null?e:[],c=Vf.map(h=>{var p;const v=(p=s.networks)==null?void 0:p.find(b=>b.chainId===h.chainId);return v?Jn({},h,v):h}).concat(a).map(h=>{const p=i?`/${i}`:"";return h.rpcUrl=h.rpcUrl+p,h}),l=h=>{if(!o[h]){var p;const v=(p=c.find(m=>m.chainId===h))==null?void 0:p.rpcUrl;if(!v)throw new Error(`no rpcUrl found for chainId: ${h}`);const b=new Ko(v),y=new h8([YB,QB,new p8],new xy(b));o[h]=new tM(y,h)}return o[h]},u=s.defaultNetwork?(n=xs(c,s.defaultNetwork))==null?void 0:n.chainId:void 0;if(!u&&s.defaultNetwork)throw new Error(`defaultNetwork not found for chainId: ${s.defaultNetwork}`);const f=s.localStorage||My(),d=new z8(s.transports,f,{defaultChainId:u,defaultEIP6492:s.defaultEIP6492},i);return Js=new Pd(d,l),Js},$U=()=>{Js&&(Js.client.closeWallet(),Js.client.transport.unregister(),Js=void 0)},MU=()=>{if(!Js)throw new Error("Wallet has not been initialized, call sequence.initWallet(config) first.");return Js},Fye=Object.freeze(Object.defineProperty({__proto__:null,BaseInjectedTransport:_ye,BaseProviderTransport:tp,BaseWalletTransport:rp,CHANNEL_ID:j8,DefaultChainIdTracker:kl,DefaultProviderConfig:h5,ErrSignedInRequired:vU,EventType:Ye,ExtensionMessageHandler:Aye,ExtensionMessageProvider:_U,InitState:Wt,LocalStorage:c1,MemoryItemStore:xU,MuxMessageProvider:zb,OpenState:Ri,PROVIDER_OPEN_TIMEOUT:B8,ProviderError:pU,ProxyMessageChannel:Cye,ProxyMessageChannelPort:d5,ProxyMessageHandler:Sye,ProxyMessageProvider:SU,SequenceClient:z8,SequenceClientSession:Sl,SequenceProvider:Pd,SequenceSigner:_d,SingleNetworkSequenceProvider:OU,SingleNetworkSequenceSigner:U8,UnrealMessageHandler:kye,UnrealMessageProvider:AU,WalletRequestHandler:Mye,WindowMessageHandler:Pye,WindowMessageProvider:PU,WindowSessionParams:ep,getWallet:MU,initWallet:RU,isBrowserExtension:$y,isMuxTransportTemplate:TU,isProviderTransport:hU,isUnityPlugin:wU,isValidMessageSignature:gU,isValidSignature:Qf,isValidTypedDataSignature:bU,isWalletUpToDate:EU,messageToBytes:yU,nextMessageIdx:mU,prefixEIP191Message:Ub,resolveArrayProperties:CU,trimEIP191Prefix:xye,unregisterWallet:$U,useBestStore:My},Symbol.toStringTag,{value:"Module"}));function An(t,e){return e.forEach(function(r){r&&typeof r!="string"&&!Array.isArray(r)&&Object.keys(r).forEach(function(n){if(n!=="default"&&!(n in t)){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}})}),Object.freeze(t)}var Bye=An({__proto__:null},[R1e]),jye=An({__proto__:null},[B1e]),Uye=An({__proto__:null},[Zme]),zye=An({__proto__:null},[sye]),Wye=An({__proto__:null},[cme]),Hye=An({__proto__:null},[mme]),qye=An({__proto__:null},[pye]),Vye=An({__proto__:null},[Npe]),Gye=An({__proto__:null},[Fye]),Kye=An({__proto__:null},[qve]);const Qye=he.transaction;var Yye=Object.freeze({__proto__:null,transactions:Qye}),Jye=An({__proto__:null,isValidSignature:Qf,isValidMessageSignature:gU,isValidTypedDataSignature:bU,isWalletUpToDate:EU},[wpe]),Xye=An({__proto__:null},[Sve]),Zye=An({__proto__:null},[Vve]),ege=An({__proto__:null},[Yme]),tge=An({__proto__:null},[Ive]),rge=An({__proto__:null},[Zve]),NU=Object.freeze({__proto__:null,abi:Bye,api:jye,auth:Uye,guard:zye,indexer:Wye,metadata:Hye,multicall:qye,network:Vye,provider:Gye,relayer:Kye,transactions:Yye,utils:Jye,core:Xye,signhub:Zye,sessions:ege,migration:tge,account:rge,initWallet:RU,getWallet:MU,unregisterWallet:$U,SequenceProvider:Pd,SequenceClient:z8,SequenceSigner:_d}),bh,$u,nge=class extends j1{constructor({chains:t,options:e}){super({chains:t,options:{reloadOnDisconnect:!1,...e}}),Ke(this,"id","coinbaseWallet"),Ke(this,"name","Coinbase Wallet"),Ke(this,"ready",!0),Mr(this,bh,void 0),Mr(this,$u,void 0),Ke(this,"onAccountsChanged",r=>{r.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(r[0])})}),Ke(this,"onChainChanged",r=>{const n=El(r),i=this.isChainUnsupported(n);this.emit("change",{chain:{id:n,unsupported:i}})}),Ke(this,"onDisconnect",()=>{this.emit("disconnect")})}async connect({chainId:t}={}){try{const e=await this.getProvider();e.on("accountsChanged",this.onAccountsChanged),e.on("chainChanged",this.onChainChanged),e.on("disconnect",this.onDisconnect),this.emit("message",{type:"connecting"});const r=await e.enable(),n=Dn(r[0]);let i=await this.getChainId(),s=this.isChainUnsupported(i);return t&&i!==t&&(i=(await this.switchChain(t)).id,s=this.isChainUnsupported(i)),{account:n,chain:{id:i,unsupported:s}}}catch(e){throw/(user closed modal|accounts received is empty)/i.test(e.message)?new Pr(e):e}}async disconnect(){if(!We(this,$u))return;const t=await this.getProvider();t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect),t.disconnect(),t.close()}async getAccount(){const e=await(await this.getProvider()).request({method:"eth_accounts"});return Dn(e[0])}async getChainId(){const t=await this.getProvider();return El(t.chainId)}async getProvider(){var t;if(!We(this,$u)){let e=(await HS(()=>import("./index-9afd0bf9.js").then(o=>o.i),["./index-9afd0bf9.js","./events-90d6e183.js","./index-cc134824.js"],import.meta.url)).default;typeof e!="function"&&typeof e.default=="function"&&(e=e.default),ys(this,bh,new e(this.options));const r=(t=We(this,bh).walletExtension)==null?void 0:t.getChainId(),n=this.chains.find(o=>this.options.chainId?o.id===this.options.chainId:o.id===r)||this.chains[0],i=this.options.chainId||(n==null?void 0:n.id),s=this.options.jsonRpcUrl||(n==null?void 0:n.rpcUrls.default.http[0]);ys(this,$u,We(this,bh).makeWeb3Provider(s,i))}return We(this,$u)}async getWalletClient({chainId:t}={}){const[e,r]=await Promise.all([this.getProvider(),this.getAccount()]),n=this.chains.find(i=>i.id===t);if(!e)throw new Error("provider is required.");return K1({account:r,chain:n,transport:kb(e)})}async isAuthorized(){try{return!!await this.getAccount()}catch{return!1}}async switchChain(t){var n;const e=await this.getProvider(),r=Ue(t);try{return await e.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]}),this.chains.find(i=>i.id===t)??{id:t,name:`Chain ${r}`,network:`${r}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}}}catch(i){const s=this.chains.find(o=>o.id===t);if(!s)throw new uF({chainId:t,connectorId:this.id});if(i.code===4902)try{return await e.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[((n=s.rpcUrls.public)==null?void 0:n.http[0])??""],blockExplorerUrls:this.getBlockExplorerUrls(s)}]}),s}catch(o){throw new Pr(o)}throw new ea(i)}}async watchAsset({address:t,decimals:e=18,image:r,symbol:n}){return(await this.getProvider()).request({method:"wallet_watchAsset",params:{type:"ERC20",options:{address:t,decimals:e,image:r,symbol:n}}})}};bh=new WeakMap;$u=new WeakMap;var Jv,ige=class extends XF{constructor({chains:t,options:e}={}){const r={name:"MetaMask",shimDisconnect:!0,getProvider(){function n(s){if(s!=null&&s.isMetaMask&&!(s.isBraveWallet&&!s._events&&!s._state)&&!s.isApexWallet&&!s.isAvalanche&&!s.isBitKeep&&!s.isBlockWallet&&!s.isMathWallet&&!(s.isOkxWallet||s.isOKExWallet)&&!(s.isOneInchIOSWallet||s.isOneInchAndroidWallet)&&!s.isOpera&&!s.isPortal&&!s.isRabby&&!s.isDefiant&&!s.isTokenPocket&&!s.isTokenary&&!s.isZerion)return s}if(typeof window>"u")return;const i=window.ethereum;return i!=null&&i.providers?i.providers.find(n):n(i)},...e};super({chains:t,options:r}),Ke(this,"id","metaMask"),Ke(this,"shimDisconnectKey",`${this.id}.shimDisconnect`),Mr(this,Jv,void 0),ys(this,Jv,r.UNSTABLE_shimOnConnectSelectAccount)}async connect({chainId:t}={}){var e,r,n,i;try{const s=await this.getProvider();if(!s)throw new Ma;s.on&&(s.on("accountsChanged",this.onAccountsChanged),s.on("chainChanged",this.onChainChanged),s.on("disconnect",this.onDisconnect)),this.emit("message",{type:"connecting"});let o=null;if(We(this,Jv)&&((e=this.options)!=null&&e.shimDisconnect)&&!((r=this.storage)!=null&&r.getItem(this.shimDisconnectKey))&&(o=await this.getAccount().catch(()=>null),!!o))try{await s.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),o=await this.getAccount()}catch(u){if(this.isUserRejectedRequestError(u))throw new Pr(u);if(u.code===new mc(u).code)throw u}if(!o){const l=await s.request({method:"eth_requestAccounts"});o=Dn(l[0])}let a=await this.getChainId(),c=this.isChainUnsupported(a);return t&&a!==t&&(a=(await this.switchChain(t)).id,c=this.isChainUnsupported(a)),(n=this.options)!=null&&n.shimDisconnect&&((i=this.storage)==null||i.setItem(this.shimDisconnectKey,!0)),{account:o,chain:{id:a,unsupported:c},provider:s}}catch(s){throw this.isUserRejectedRequestError(s)?new Pr(s):s.code===-32002?new mc(s):s}}};Jv=new WeakMap;var nl,Bs,sge=class{constructor(t){Ke(this,"events",new JL),Ke(this,"chainId"),Mr(this,nl,void 0),Mr(this,Bs,void 0),this.chainId=t.chainId,ys(this,nl,t)}async enable(){var e;if((e=We(this,nl).flags)!=null&&e.failConnect)throw new Pr(new Error("Failed to connect."));We(this,Bs)||ys(this,Bs,We(this,nl).walletClient);const t=We(this,Bs).account.address;return this.events.emit("accountsChanged",[t]),[t]}async disconnect(){this.events.emit("disconnect"),ys(this,Bs,void 0)}async getAccounts(){var e;const t=(e=We(this,Bs))==null?void 0:e.account.address;return t?[Dn(t)]:[]}getWalletClient(){const t=We(this,Bs);if(!t)throw new Error("walletClient not found");return t}async switchChain(t){var e;if((e=We(this,nl).flags)!=null&&e.failSwitchChain)throw new Pr(new Error("Failed to switch chain."));We(this,nl).chainId=t,this.chainId=t,this.events.emit("chainChanged",t)}async switchWalletClient(t){const e=t.account.address;ys(this,Bs,t),this.events.emit("accountsChanged",[e])}async watchAsset(t){return!0}async request({method:t,params:e}){var r;return(r=We(this,Bs))==null?void 0:r.transport.request({method:t,params:e})}on(t,e){return this.events.on(t,e),this}removeListener(t,e){return this.events.removeListener(t,e),this}toJSON(){return""}};nl=new WeakMap;Bs=new WeakMap;var wh,p5,DU,oge=class extends j1{constructor({chains:t,options:e}){var r;super({chains:t,options:{...e,chainId:e.chainId??((r=t==null?void 0:t[0])==null?void 0:r.id)}}),Mr(this,p5),Ke(this,"id","mock"),Ke(this,"name","Mock"),Ke(this,"ready",!0),Mr(this,wh,void 0),Ke(this,"onAccountsChanged",n=>{n.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(n[0])})}),Ke(this,"onChainChanged",n=>{const i=El(n),s=this.isChainUnsupported(i);this.emit("change",{chain:{id:i,unsupported:s}})}),Ke(this,"onDisconnect",()=>{this.emit("disconnect")})}async connect({chainId:t}={}){var a;const e=await this.getProvider({chainId:t});e.on("accountsChanged",this.onAccountsChanged),e.on("chainChanged",this.onChainChanged),e.on("disconnect",this.onDisconnect),this.emit("message",{type:"connecting"});const r=await e.enable(),n=Dn(r[0]),i=El(e.chainId),s=this.isChainUnsupported(i),o={account:n,chain:{id:i,unsupported:s},provider:e};return(a=this.options.flags)!=null&&a.noSwitchChain||(this.switchChain=Rr(this,p5,DU)),new Promise(c=>setTimeout(()=>c(o),100))}async disconnect(){const t=await this.getProvider();await t.disconnect(),t.removeListener("accountsChanged",this.onAccountsChanged),t.removeListener("chainChanged",this.onChainChanged),t.removeListener("disconnect",this.onDisconnect)}async getAccount(){const r=(await(await this.getProvider()).getAccounts())[0];if(!r)throw new Error("Failed to get account");return Dn(r)}async getChainId(){const t=await this.getProvider();return El(t.chainId)}async getProvider({chainId:t}={}){return(!We(this,wh)||t)&&ys(this,wh,new sge({...this.options,chainId:t??this.options.chainId??this.chains[0].id})),We(this,wh)}async getWalletClient(){return(await this.getProvider()).getWalletClient()}async isAuthorized(){var t;try{const r=await(await this.getProvider()).getAccounts();return((t=this.options.flags)==null?void 0:t.isAuthorized)??!!r}catch{return!1}}async watchAsset(t){return(await this.getProvider()).watchAsset(t)}toJSON(){return""}};wh=new WeakMap;p5=new WeakSet;DU=async function(t){return await(await this.getProvider()).switchChain(t),this.chains.find(r=>r.id===t)??{id:t,name:`Chain ${t}`,network:`${t}`,nativeCurrency:{name:"Ether",decimals:18,symbol:"ETH"},rpcUrls:{default:{http:[""]},public:{http:[""]}}}};var W8={},Wb={},ze={},LU={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(a,c){var l=a>>>16&65535,u=a&65535,f=c>>>16&65535,d=c&65535;return u*d+(l*d+u*f<<16>>>0)|0}t.mul=Math.imul||e;function r(a,c){return a+c|0}t.add=r;function n(a,c){return a-c|0}t.sub=n;function i(a,c){return a<>>32-c}t.rotl=i;function s(a,c){return a<<32-c|a>>>c}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(LU);Object.defineProperty(ze,"__esModule",{value:!0});var FU=LU;function age(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}ze.readInt16BE=age;function cge(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}ze.readUint16BE=cge;function lge(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}ze.readInt16LE=lge;function uge(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}ze.readUint16LE=uge;function BU(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}ze.writeUint16BE=BU;ze.writeInt16BE=BU;function jU(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}ze.writeUint16LE=jU;ze.writeInt16LE=jU;function v5(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}ze.readInt32BE=v5;function m5(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}ze.readUint32BE=m5;function y5(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}ze.readInt32LE=y5;function g5(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}ze.readUint32LE=g5;function Ny(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}ze.writeUint32BE=Ny;ze.writeInt32BE=Ny;function Dy(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}ze.writeUint32LE=Dy;ze.writeInt32LE=Dy;function fge(t,e){e===void 0&&(e=0);var r=v5(t,e),n=v5(t,e+4);return r*4294967296+n-(n>>31)*4294967296}ze.readInt64BE=fge;function dge(t,e){e===void 0&&(e=0);var r=m5(t,e),n=m5(t,e+4);return r*4294967296+n}ze.readUint64BE=dge;function hge(t,e){e===void 0&&(e=0);var r=y5(t,e),n=y5(t,e+4);return n*4294967296+r-(r>>31)*4294967296}ze.readInt64LE=hge;function pge(t,e){e===void 0&&(e=0);var r=g5(t,e),n=g5(t,e+4);return n*4294967296+r}ze.readUint64LE=pge;function UU(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Ny(t/4294967296>>>0,e,r),Ny(t>>>0,e,r+4),e}ze.writeUint64BE=UU;ze.writeInt64BE=UU;function zU(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Dy(t>>>0,e,r),Dy(t/4294967296>>>0,e,r+4),e}ze.writeUint64LE=zU;ze.writeInt64LE=zU;function vge(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}ze.readUintBE=vge;function mge(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s=n;s--)r[s]=e/i&255,i*=256;return r}ze.writeUintBE=yge;function gge(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!FU.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s>>32-16|_<<16,H=H+_|0,w^=H,w=w>>>32-12|w<<12,S=S+I|0,O^=S,O=O>>>32-16|O<<16,K=K+O|0,I^=K,I=I>>>32-12|I<<12,P=P+F|0,N^=P,N=N>>>32-16|N<<16,B=B+N|0,F^=B,F=F>>>32-12|F<<12,T=T+j|0,k^=T,k=k>>>32-16|k<<16,E=E+k|0,j^=E,j=j>>>32-12|j<<12,P=P+F|0,N^=P,N=N>>>32-8|N<<8,B=B+N|0,F^=B,F=F>>>32-7|F<<7,T=T+j|0,k^=T,k=k>>>32-8|k<<8,E=E+k|0,j^=E,j=j>>>32-7|j<<7,S=S+I|0,O^=S,O=O>>>32-8|O<<8,K=K+O|0,I^=K,I=I>>>32-7|I<<7,g=g+w|0,_^=g,_=_>>>32-8|_<<8,H=H+_|0,w^=H,w=w>>>32-7|w<<7,g=g+I|0,k^=g,k=k>>>32-16|k<<16,B=B+k|0,I^=B,I=I>>>32-12|I<<12,S=S+F|0,_^=S,_=_>>>32-16|_<<16,E=E+_|0,F^=E,F=F>>>32-12|F<<12,P=P+j|0,O^=P,O=O>>>32-16|O<<16,H=H+O|0,j^=H,j=j>>>32-12|j<<12,T=T+w|0,N^=T,N=N>>>32-16|N<<16,K=K+N|0,w^=K,w=w>>>32-12|w<<12,P=P+j|0,O^=P,O=O>>>32-8|O<<8,H=H+O|0,j^=H,j=j>>>32-7|j<<7,T=T+w|0,N^=T,N=N>>>32-8|N<<8,K=K+N|0,w^=K,w=w>>>32-7|w<<7,S=S+F|0,_^=S,_=_>>>32-8|_<<8,E=E+_|0,F^=E,F=F>>>32-7|F<<7,g=g+I|0,k^=g,k=k>>>32-8|k<<8,B=B+k|0,I^=B,I=I>>>32-7|I<<7;dn.writeUint32LE(g+n|0,t,0),dn.writeUint32LE(S+i|0,t,4),dn.writeUint32LE(P+s|0,t,8),dn.writeUint32LE(T+o|0,t,12),dn.writeUint32LE(w+a|0,t,16),dn.writeUint32LE(I+c|0,t,20),dn.writeUint32LE(F+l|0,t,24),dn.writeUint32LE(j+u|0,t,28),dn.writeUint32LE(H+f|0,t,32),dn.writeUint32LE(K+d|0,t,36),dn.writeUint32LE(B+h|0,t,40),dn.writeUint32LE(E+p|0,t,44),dn.writeUint32LE(_+v|0,t,48),dn.writeUint32LE(O+b|0,t,52),dn.writeUint32LE(N+y|0,t,56),dn.writeUint32LE(k+m|0,t,60)}function WU(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var HU={},Lc={};Object.defineProperty(Lc,"__esModule",{value:!0});function Rge(t,e,r){return~(t-1)&e|t-1&r}Lc.select=Rge;function $ge(t,e){return(t|0)-(e|0)-1>>>31&1}Lc.lessOrEqual=$ge;function qU(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n>>8}Lc.compare=qU;function Mge(t,e){return t.length===0||e.length===0?!1:qU(t,e)!==0}Lc.equal=Mge;(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Lc,r=Is;t.DIGEST_LENGTH=16;var n=function(){function o(a){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var c=a[0]|a[1]<<8;this._r[0]=c&8191;var l=a[2]|a[3]<<8;this._r[1]=(c>>>13|l<<3)&8191;var u=a[4]|a[5]<<8;this._r[2]=(l>>>10|u<<6)&7939;var f=a[6]|a[7]<<8;this._r[3]=(u>>>7|f<<9)&8191;var d=a[8]|a[9]<<8;this._r[4]=(f>>>4|d<<12)&255,this._r[5]=d>>>1&8190;var h=a[10]|a[11]<<8;this._r[6]=(d>>>14|h<<2)&8191;var p=a[12]|a[13]<<8;this._r[7]=(h>>>11|p<<5)&8065;var v=a[14]|a[15]<<8;this._r[8]=(p>>>8|v<<8)&8191,this._r[9]=v>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,c,l){for(var u=this._fin?0:2048,f=this._h[0],d=this._h[1],h=this._h[2],p=this._h[3],v=this._h[4],b=this._h[5],y=this._h[6],m=this._h[7],g=this._h[8],S=this._h[9],P=this._r[0],T=this._r[1],w=this._r[2],I=this._r[3],F=this._r[4],j=this._r[5],H=this._r[6],K=this._r[7],B=this._r[8],E=this._r[9];l>=16;){var _=a[c+0]|a[c+1]<<8;f+=_&8191;var O=a[c+2]|a[c+3]<<8;d+=(_>>>13|O<<3)&8191;var N=a[c+4]|a[c+5]<<8;h+=(O>>>10|N<<6)&8191;var k=a[c+6]|a[c+7]<<8;p+=(N>>>7|k<<9)&8191;var $=a[c+8]|a[c+9]<<8;v+=(k>>>4|$<<12)&8191,b+=$>>>1&8191;var L=a[c+10]|a[c+11]<<8;y+=($>>>14|L<<2)&8191;var M=a[c+12]|a[c+13]<<8;m+=(L>>>11|M<<5)&8191;var A=a[c+14]|a[c+15]<<8;g+=(M>>>8|A<<8)&8191,S+=A>>>5|u;var D=0,V=D;V+=f*P,V+=d*(5*E),V+=h*(5*B),V+=p*(5*K),V+=v*(5*H),D=V>>>13,V&=8191,V+=b*(5*j),V+=y*(5*F),V+=m*(5*I),V+=g*(5*w),V+=S*(5*T),D+=V>>>13,V&=8191;var R=D;R+=f*T,R+=d*P,R+=h*(5*E),R+=p*(5*B),R+=v*(5*K),D=R>>>13,R&=8191,R+=b*(5*H),R+=y*(5*j),R+=m*(5*F),R+=g*(5*I),R+=S*(5*w),D+=R>>>13,R&=8191;var U=D;U+=f*w,U+=d*T,U+=h*P,U+=p*(5*E),U+=v*(5*B),D=U>>>13,U&=8191,U+=b*(5*K),U+=y*(5*H),U+=m*(5*j),U+=g*(5*F),U+=S*(5*I),D+=U>>>13,U&=8191;var W=D;W+=f*I,W+=d*w,W+=h*T,W+=p*P,W+=v*(5*E),D=W>>>13,W&=8191,W+=b*(5*B),W+=y*(5*K),W+=m*(5*H),W+=g*(5*j),W+=S*(5*F),D+=W>>>13,W&=8191;var q=D;q+=f*F,q+=d*I,q+=h*w,q+=p*T,q+=v*P,D=q>>>13,q&=8191,q+=b*(5*E),q+=y*(5*B),q+=m*(5*K),q+=g*(5*H),q+=S*(5*j),D+=q>>>13,q&=8191;var Y=D;Y+=f*j,Y+=d*F,Y+=h*I,Y+=p*w,Y+=v*T,D=Y>>>13,Y&=8191,Y+=b*P,Y+=y*(5*E),Y+=m*(5*B),Y+=g*(5*K),Y+=S*(5*H),D+=Y>>>13,Y&=8191;var X=D;X+=f*H,X+=d*j,X+=h*F,X+=p*I,X+=v*w,D=X>>>13,X&=8191,X+=b*T,X+=y*P,X+=m*(5*E),X+=g*(5*B),X+=S*(5*K),D+=X>>>13,X&=8191;var Q=D;Q+=f*K,Q+=d*H,Q+=h*j,Q+=p*F,Q+=v*I,D=Q>>>13,Q&=8191,Q+=b*w,Q+=y*T,Q+=m*P,Q+=g*(5*E),Q+=S*(5*B),D+=Q>>>13,Q&=8191;var Z=D;Z+=f*B,Z+=d*K,Z+=h*H,Z+=p*j,Z+=v*F,D=Z>>>13,Z&=8191,Z+=b*I,Z+=y*w,Z+=m*T,Z+=g*P,Z+=S*(5*E),D+=Z>>>13,Z&=8191;var ae=D;ae+=f*E,ae+=d*B,ae+=h*K,ae+=p*H,ae+=v*j,D=ae>>>13,ae&=8191,ae+=b*F,ae+=y*I,ae+=m*w,ae+=g*T,ae+=S*P,D+=ae>>>13,ae&=8191,D=(D<<2)+D|0,D=D+V|0,V=D&8191,D=D>>>13,R+=D,f=V,d=R,h=U,p=W,v=q,b=Y,y=X,m=Q,g=Z,S=ae,c+=16,l-=16}this._h[0]=f,this._h[1]=d,this._h[2]=h,this._h[3]=p,this._h[4]=v,this._h[5]=b,this._h[6]=y,this._h[7]=m,this._h[8]=g,this._h[9]=S},o.prototype.finish=function(a,c){c===void 0&&(c=0);var l=new Uint16Array(10),u,f,d,h;if(this._leftover){for(h=this._leftover,this._buffer[h++]=1;h<16;h++)this._buffer[h]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(u=this._h[1]>>>13,this._h[1]&=8191,h=2;h<10;h++)this._h[h]+=u,u=this._h[h]>>>13,this._h[h]&=8191;for(this._h[0]+=u*5,u=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=u,u=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=u,l[0]=this._h[0]+5,u=l[0]>>>13,l[0]&=8191,h=1;h<10;h++)l[h]=this._h[h]+u,u=l[h]>>>13,l[h]&=8191;for(l[9]-=8192,f=(u^1)-1,h=0;h<10;h++)l[h]&=f;for(f=~f,h=0;h<10;h++)this._h[h]=this._h[h]&f|l[h];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,d=this._h[0]+this._pad[0],this._h[0]=d&65535,h=1;h<8;h++)d=(this._h[h]+this._pad[h]|0)+(d>>>16)|0,this._h[h]=d&65535;return a[c+0]=this._h[0]>>>0,a[c+1]=this._h[0]>>>8,a[c+2]=this._h[1]>>>0,a[c+3]=this._h[1]>>>8,a[c+4]=this._h[2]>>>0,a[c+5]=this._h[2]>>>8,a[c+6]=this._h[3]>>>0,a[c+7]=this._h[3]>>>8,a[c+8]=this._h[4]>>>0,a[c+9]=this._h[4]>>>8,a[c+10]=this._h[5]>>>0,a[c+11]=this._h[5]>>>8,a[c+12]=this._h[6]>>>0,a[c+13]=this._h[6]>>>8,a[c+14]=this._h[7]>>>0,a[c+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var c=0,l=a.length,u;if(this._leftover){u=16-this._leftover,u>l&&(u=l);for(var f=0;f=16&&(u=l-l%16,this._blocks(a,c,u),c+=u,l-=u),l){for(var f=0;f16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var h=new Uint8Array(16);h.set(l,h.length-l.length);var p=new Uint8Array(32);e.stream(this._key,h,p,4);var v=u.length+this.tagLength,b;if(d){if(d.length!==v)throw new Error("ChaCha20Poly1305: incorrect destination length");b=d}else b=new Uint8Array(v);return e.streamXOR(this._key,h,u,b,4),this._authenticate(b.subarray(b.length-this.tagLength,b.length),p,b.subarray(0,b.length-this.tagLength),f),n.wipe(h),b},c.prototype.open=function(l,u,f,d){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(u.length0&&h.update(o.subarray(d.length%16))),h.update(f),f.length%16>0&&h.update(o.subarray(f.length%16));var p=new Uint8Array(8);d&&i.writeUint64LE(d.length,p),h.update(p),i.writeUint64LE(f.length,p),h.update(p);for(var v=h.digest(),b=0;bthis.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n256)throw new Error("randomString charset is too long");let d="";const h=u.length,p=256-256%h;for(;l>0;){const v=i(Math.ceil(l*256/p),f);for(let b=0;b0;b++){const y=v[b];y0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=c[u++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(u=s(this._temp,this._state,c,u,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=c[u++],l--;return this},a.prototype.finish=function(c){if(!this._finished){var l=this._bytesHashed,u=this._bufferLength,f=l/536870912|0,d=l<<3,h=l%64<56?64:128;this._buffer[u]=128;for(var p=u+1;p0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(c){return this._state.set(c.state),this._bufferLength=c.bufferLength,c.buffer&&this._buffer.set(c.buffer),this._bytesHashed=c.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(c){r.wipe(c.state),c.buffer&&r.wipe(c.buffer),c.bufferLength=0,c.bytesHashed=0},a}();t.SHA256=n;var i=new Int32Array([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]);function s(a,c,l,u,f){for(;f>=64;){for(var d=c[0],h=c[1],p=c[2],v=c[3],b=c[4],y=c[5],m=c[6],g=c[7],S=0;S<16;S++){var P=u+S*4;a[S]=e.readUint32BE(l,P)}for(var S=16;S<64;S++){var T=a[S-2],w=(T>>>17|T<<32-17)^(T>>>19|T<<32-19)^T>>>10;T=a[S-15];var I=(T>>>7|T<<32-7)^(T>>>18|T<<32-18)^T>>>3;a[S]=(w+a[S-7]|0)+(I+a[S-16]|0)}for(var S=0;S<64;S++){var w=(((b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7))+(b&y^~b&m)|0)+(g+(i[S]+a[S]|0)|0)|0,I=((d>>>2|d<<32-2)^(d>>>13|d<<32-13)^(d>>>22|d<<32-22))+(d&h^d&p^h&p)|0;g=m,m=y,y=b,b=v+w|0,v=p,p=h,h=d,d=w+I|0}c[0]+=d,c[1]+=h,c[2]+=p,c[3]+=v,c[4]+=b,c[5]+=y,c[6]+=m,c[7]+=g,u+=64,f-=64}return u}function o(a){var c=new n;c.update(a);var l=c.digest();return c.clean(),l}t.hash=o})(Kb);var q8={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=Hb,r=Is;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(S){const P=new Float64Array(16);if(S)for(let T=0;T>16&1),T[j-1]&=65535;T[15]=w[15]-32767-(T[14]>>16&1);const F=T[15]>>16&1;T[14]&=65535,a(w,T,1-F)}for(let I=0;I<16;I++)S[2*I]=w[I]&255,S[2*I+1]=w[I]>>8}function l(S,P){for(let T=0;T<16;T++)S[T]=P[2*T]+(P[2*T+1]<<8);S[15]&=32767}function u(S,P,T){for(let w=0;w<16;w++)S[w]=P[w]+T[w]}function f(S,P,T){for(let w=0;w<16;w++)S[w]=P[w]-T[w]}function d(S,P,T){let w,I,F=0,j=0,H=0,K=0,B=0,E=0,_=0,O=0,N=0,k=0,$=0,L=0,M=0,A=0,D=0,V=0,R=0,U=0,W=0,q=0,Y=0,X=0,Q=0,Z=0,ae=0,se=0,ue=0,ot=0,Te=0,_e=0,at=0,xe=T[0],be=T[1],Kt=T[2],Ie=T[3],Oe=T[4],Qt=T[5],Re=T[6],$e=T[7],Yt=T[8],Me=T[9],Ne=T[10],Jt=T[11],De=T[12],Le=T[13],Xt=T[14],Fe=T[15];w=P[0],F+=w*xe,j+=w*be,H+=w*Kt,K+=w*Ie,B+=w*Oe,E+=w*Qt,_+=w*Re,O+=w*$e,N+=w*Yt,k+=w*Me,$+=w*Ne,L+=w*Jt,M+=w*De,A+=w*Le,D+=w*Xt,V+=w*Fe,w=P[1],j+=w*xe,H+=w*be,K+=w*Kt,B+=w*Ie,E+=w*Oe,_+=w*Qt,O+=w*Re,N+=w*$e,k+=w*Yt,$+=w*Me,L+=w*Ne,M+=w*Jt,A+=w*De,D+=w*Le,V+=w*Xt,R+=w*Fe,w=P[2],H+=w*xe,K+=w*be,B+=w*Kt,E+=w*Ie,_+=w*Oe,O+=w*Qt,N+=w*Re,k+=w*$e,$+=w*Yt,L+=w*Me,M+=w*Ne,A+=w*Jt,D+=w*De,V+=w*Le,R+=w*Xt,U+=w*Fe,w=P[3],K+=w*xe,B+=w*be,E+=w*Kt,_+=w*Ie,O+=w*Oe,N+=w*Qt,k+=w*Re,$+=w*$e,L+=w*Yt,M+=w*Me,A+=w*Ne,D+=w*Jt,V+=w*De,R+=w*Le,U+=w*Xt,W+=w*Fe,w=P[4],B+=w*xe,E+=w*be,_+=w*Kt,O+=w*Ie,N+=w*Oe,k+=w*Qt,$+=w*Re,L+=w*$e,M+=w*Yt,A+=w*Me,D+=w*Ne,V+=w*Jt,R+=w*De,U+=w*Le,W+=w*Xt,q+=w*Fe,w=P[5],E+=w*xe,_+=w*be,O+=w*Kt,N+=w*Ie,k+=w*Oe,$+=w*Qt,L+=w*Re,M+=w*$e,A+=w*Yt,D+=w*Me,V+=w*Ne,R+=w*Jt,U+=w*De,W+=w*Le,q+=w*Xt,Y+=w*Fe,w=P[6],_+=w*xe,O+=w*be,N+=w*Kt,k+=w*Ie,$+=w*Oe,L+=w*Qt,M+=w*Re,A+=w*$e,D+=w*Yt,V+=w*Me,R+=w*Ne,U+=w*Jt,W+=w*De,q+=w*Le,Y+=w*Xt,X+=w*Fe,w=P[7],O+=w*xe,N+=w*be,k+=w*Kt,$+=w*Ie,L+=w*Oe,M+=w*Qt,A+=w*Re,D+=w*$e,V+=w*Yt,R+=w*Me,U+=w*Ne,W+=w*Jt,q+=w*De,Y+=w*Le,X+=w*Xt,Q+=w*Fe,w=P[8],N+=w*xe,k+=w*be,$+=w*Kt,L+=w*Ie,M+=w*Oe,A+=w*Qt,D+=w*Re,V+=w*$e,R+=w*Yt,U+=w*Me,W+=w*Ne,q+=w*Jt,Y+=w*De,X+=w*Le,Q+=w*Xt,Z+=w*Fe,w=P[9],k+=w*xe,$+=w*be,L+=w*Kt,M+=w*Ie,A+=w*Oe,D+=w*Qt,V+=w*Re,R+=w*$e,U+=w*Yt,W+=w*Me,q+=w*Ne,Y+=w*Jt,X+=w*De,Q+=w*Le,Z+=w*Xt,ae+=w*Fe,w=P[10],$+=w*xe,L+=w*be,M+=w*Kt,A+=w*Ie,D+=w*Oe,V+=w*Qt,R+=w*Re,U+=w*$e,W+=w*Yt,q+=w*Me,Y+=w*Ne,X+=w*Jt,Q+=w*De,Z+=w*Le,ae+=w*Xt,se+=w*Fe,w=P[11],L+=w*xe,M+=w*be,A+=w*Kt,D+=w*Ie,V+=w*Oe,R+=w*Qt,U+=w*Re,W+=w*$e,q+=w*Yt,Y+=w*Me,X+=w*Ne,Q+=w*Jt,Z+=w*De,ae+=w*Le,se+=w*Xt,ue+=w*Fe,w=P[12],M+=w*xe,A+=w*be,D+=w*Kt,V+=w*Ie,R+=w*Oe,U+=w*Qt,W+=w*Re,q+=w*$e,Y+=w*Yt,X+=w*Me,Q+=w*Ne,Z+=w*Jt,ae+=w*De,se+=w*Le,ue+=w*Xt,ot+=w*Fe,w=P[13],A+=w*xe,D+=w*be,V+=w*Kt,R+=w*Ie,U+=w*Oe,W+=w*Qt,q+=w*Re,Y+=w*$e,X+=w*Yt,Q+=w*Me,Z+=w*Ne,ae+=w*Jt,se+=w*De,ue+=w*Le,ot+=w*Xt,Te+=w*Fe,w=P[14],D+=w*xe,V+=w*be,R+=w*Kt,U+=w*Ie,W+=w*Oe,q+=w*Qt,Y+=w*Re,X+=w*$e,Q+=w*Yt,Z+=w*Me,ae+=w*Ne,se+=w*Jt,ue+=w*De,ot+=w*Le,Te+=w*Xt,_e+=w*Fe,w=P[15],V+=w*xe,R+=w*be,U+=w*Kt,W+=w*Ie,q+=w*Oe,Y+=w*Qt,X+=w*Re,Q+=w*$e,Z+=w*Yt,ae+=w*Me,se+=w*Ne,ue+=w*Jt,ot+=w*De,Te+=w*Le,_e+=w*Xt,at+=w*Fe,F+=38*R,j+=38*U,H+=38*W,K+=38*q,B+=38*Y,E+=38*X,_+=38*Q,O+=38*Z,N+=38*ae,k+=38*se,$+=38*ue,L+=38*ot,M+=38*Te,A+=38*_e,D+=38*at,I=1,w=F+I+65535,I=Math.floor(w/65536),F=w-I*65536,w=j+I+65535,I=Math.floor(w/65536),j=w-I*65536,w=H+I+65535,I=Math.floor(w/65536),H=w-I*65536,w=K+I+65535,I=Math.floor(w/65536),K=w-I*65536,w=B+I+65535,I=Math.floor(w/65536),B=w-I*65536,w=E+I+65535,I=Math.floor(w/65536),E=w-I*65536,w=_+I+65535,I=Math.floor(w/65536),_=w-I*65536,w=O+I+65535,I=Math.floor(w/65536),O=w-I*65536,w=N+I+65535,I=Math.floor(w/65536),N=w-I*65536,w=k+I+65535,I=Math.floor(w/65536),k=w-I*65536,w=$+I+65535,I=Math.floor(w/65536),$=w-I*65536,w=L+I+65535,I=Math.floor(w/65536),L=w-I*65536,w=M+I+65535,I=Math.floor(w/65536),M=w-I*65536,w=A+I+65535,I=Math.floor(w/65536),A=w-I*65536,w=D+I+65535,I=Math.floor(w/65536),D=w-I*65536,w=V+I+65535,I=Math.floor(w/65536),V=w-I*65536,F+=I-1+37*(I-1),I=1,w=F+I+65535,I=Math.floor(w/65536),F=w-I*65536,w=j+I+65535,I=Math.floor(w/65536),j=w-I*65536,w=H+I+65535,I=Math.floor(w/65536),H=w-I*65536,w=K+I+65535,I=Math.floor(w/65536),K=w-I*65536,w=B+I+65535,I=Math.floor(w/65536),B=w-I*65536,w=E+I+65535,I=Math.floor(w/65536),E=w-I*65536,w=_+I+65535,I=Math.floor(w/65536),_=w-I*65536,w=O+I+65535,I=Math.floor(w/65536),O=w-I*65536,w=N+I+65535,I=Math.floor(w/65536),N=w-I*65536,w=k+I+65535,I=Math.floor(w/65536),k=w-I*65536,w=$+I+65535,I=Math.floor(w/65536),$=w-I*65536,w=L+I+65535,I=Math.floor(w/65536),L=w-I*65536,w=M+I+65535,I=Math.floor(w/65536),M=w-I*65536,w=A+I+65535,I=Math.floor(w/65536),A=w-I*65536,w=D+I+65535,I=Math.floor(w/65536),D=w-I*65536,w=V+I+65535,I=Math.floor(w/65536),V=w-I*65536,F+=I-1+37*(I-1),S[0]=F,S[1]=j,S[2]=H,S[3]=K,S[4]=B,S[5]=E,S[6]=_,S[7]=O,S[8]=N,S[9]=k,S[10]=$,S[11]=L,S[12]=M,S[13]=A,S[14]=D,S[15]=V}function h(S,P){d(S,P,P)}function p(S,P){const T=n();for(let w=0;w<16;w++)T[w]=P[w];for(let w=253;w>=0;w--)h(T,T),w!==2&&w!==4&&d(T,T,P);for(let w=0;w<16;w++)S[w]=T[w]}function v(S,P){const T=new Uint8Array(32),w=new Float64Array(80),I=n(),F=n(),j=n(),H=n(),K=n(),B=n();for(let N=0;N<31;N++)T[N]=S[N];T[31]=S[31]&127|64,T[0]&=248,l(w,P);for(let N=0;N<16;N++)F[N]=w[N];I[0]=H[0]=1;for(let N=254;N>=0;--N){const k=T[N>>>3]>>>(N&7)&1;a(I,F,k),a(j,H,k),u(K,I,j),f(I,I,j),u(j,F,H),f(F,F,H),h(H,K),h(B,I),d(I,j,I),d(j,F,K),u(K,I,j),f(I,I,j),h(F,I),f(j,H,B),d(I,j,s),u(I,I,H),d(j,j,I),d(I,H,B),d(H,F,w),h(F,K),a(I,F,k),a(j,H,k)}for(let N=0;N<16;N++)w[N+16]=I[N],w[N+32]=j[N],w[N+48]=F[N],w[N+64]=H[N];const E=w.subarray(32),_=w.subarray(16);p(E,E),d(_,_,E);const O=new Uint8Array(32);return c(O,_),O}t.scalarMult=v;function b(S){return v(S,i)}t.scalarMultBase=b;function y(S){if(S.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const P=new Uint8Array(S);return{publicKey:b(P),secretKey:P}}t.generateKeyPairFromSeed=y;function m(S){const P=(0,e.randomBytes)(32,S),T=y(P);return(0,r.wipe)(P),T}t.generateKeyPair=m;function g(S,P,T=!1){if(S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(P.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const w=v(S,P);if(T){let I=0;for(let F=0;Fi+s.length,0));const r=KU(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return V8(r)}function Kge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,S=new Uint8Array(g);y!==m;){for(var P=p[y],T=0,w=g-1;(P!==0||T>>0,S[w]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");b=T,y++}for(var I=g-b;I!==g&&S[I]===0;)I++;for(var F=c.repeat(v);I>>0,g=new Uint8Array(m);p[v];){var S=r[p.charCodeAt(v)];if(S===255)return;for(var P=0,T=m-1;(S!==0||P>>0,g[T]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");y=P,v++}if(p[v]!==" "){for(var w=m-y;w!==m&&g[w]===0;)w++;for(var I=new Uint8Array(b+(m-w)),F=b;w!==m;)I[F++]=g[w++];return I}}}function h(p){var v=d(p);if(v)return v;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:h}}var Qge=Kge,Yge=Qge;const Jge=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")},Xge=t=>new TextEncoder().encode(t),Zge=t=>new TextDecoder().decode(t);class ebe{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class tbe{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}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 QU(this,e)}}class rbe{constructor(e){this.decoders=e}or(e){return QU(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const QU=(t,e)=>new rbe({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class nbe{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ebe(e,r,n),this.decoder=new tbe(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qb=({name:t,prefix:e,encode:r,decode:n})=>new nbe(t,e,r,n),ip=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Yge(r,e);return Qb({prefix:t,name:e,encode:n,decode:s=>Jge(i(s))})},ibe=(t,e,r,n)=>{const i={};for(let u=0;u=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},sbe=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<Qb({prefix:e,name:t,encode(i){return sbe(i,n,r)},decode(i){return ibe(i,n,r,t)}}),obe=Qb({prefix:"\0",name:"identity",encode:t=>Zge(t),decode:t=>Xge(t)}),abe=Object.freeze(Object.defineProperty({__proto__:null,identity:obe},Symbol.toStringTag,{value:"Module"})),cbe=cn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),lbe=Object.freeze(Object.defineProperty({__proto__:null,base2:cbe},Symbol.toStringTag,{value:"Module"})),ube=cn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),fbe=Object.freeze(Object.defineProperty({__proto__:null,base8:ube},Symbol.toStringTag,{value:"Module"})),dbe=ip({prefix:"9",name:"base10",alphabet:"0123456789"}),hbe=Object.freeze(Object.defineProperty({__proto__:null,base10:dbe},Symbol.toStringTag,{value:"Module"})),pbe=cn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vbe=cn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),mbe=Object.freeze(Object.defineProperty({__proto__:null,base16:pbe,base16upper:vbe},Symbol.toStringTag,{value:"Module"})),ybe=cn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gbe=cn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bbe=cn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wbe=cn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ebe=cn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xbe=cn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cbe=cn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sbe=cn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kbe=cn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Abe=Object.freeze(Object.defineProperty({__proto__:null,base32:ybe,base32hex:Ebe,base32hexpad:Cbe,base32hexpadupper:Sbe,base32hexupper:xbe,base32pad:bbe,base32padupper:wbe,base32upper:gbe,base32z:kbe},Symbol.toStringTag,{value:"Module"})),_be=ip({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pbe=ip({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Tbe=Object.freeze(Object.defineProperty({__proto__:null,base36:_be,base36upper:Pbe},Symbol.toStringTag,{value:"Module"})),Ibe=ip({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Obe=ip({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Rbe=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Ibe,base58flickr:Obe},Symbol.toStringTag,{value:"Module"})),$be=cn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mbe=cn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nbe=cn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dbe=cn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Lbe=Object.freeze(Object.defineProperty({__proto__:null,base64:$be,base64pad:Mbe,base64url:Nbe,base64urlpad:Dbe},Symbol.toStringTag,{value:"Module"})),YU=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Fbe=YU.reduce((t,e,r)=>(t[r]=e,t),[]),Bbe=YU.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function jbe(t){return t.reduce((e,r)=>(e+=Fbe[r],e),"")}function Ube(t){const e=[];for(const r of t){const n=Bbe[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const zbe=Qb({prefix:"🚀",name:"base256emoji",encode:jbe,decode:Ube}),Wbe=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:zbe},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const YT={...abe,...lbe,...fbe,...hbe,...mbe,...Abe,...Tbe,...Rbe,...Lbe,...Wbe};function JU(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const JT=JU("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),rE=JU("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=KU(t.length);for(let r=0;r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Kbe:typeof navigator<"u"?t9(navigator.userAgent):twe()}function Zbe(t){return t!==""&&Jbe.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function t9(t){var e=Zbe(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Gbe;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length{if(!f.includes(":")||n)return;const d=Id(e[f].accounts);d.includes(f)||(n=Fa("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${f} Required: ${f} - Approved: ${d.toString()}`))}),o.forEach(f=>{n||(yl(i[f].methods,s[f].methods)?yl(i[f].events,s[f].events)||(n=Fa("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${f}`)):n=Fa("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${f}`))}),n}function B2e(t){const e={};return Object.keys(t).forEach(r=>{var n;r.includes(":")?e[r]=t[r]:(n=t[r].chains)==null||n.forEach(i=>{e[i]={methods:t[r].methods,events:t[r].events}})}),e}function C9(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function j2e(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const n=Id(t[r].accounts);n==null||n.forEach(i=>{e[i]={accounts:t[r].accounts.filter(s=>s.includes(`${i}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function h9e(t,e){return Z8(t,!1)&&t<=e.max&&t>=e.min}var pz="eip155",U2e="store",vz="requestedChains",A5="wallet_addEthereumChain",or,t0,Xv,_5,ek,mz,Zv,P5,T5,yz,Fy,tk,Mu,Eh,By,rk,jy,nk,Uy,ik,z2e=class extends j1{constructor(t){super({...t,options:{isNewChainsStale:!0,...t.options}}),Mr(this,Xv),Mr(this,ek),Mr(this,Zv),Mr(this,T5),Mr(this,Fy),Mr(this,Mu),Mr(this,By),Mr(this,jy),Mr(this,Uy),Ke(this,"id","walletConnect"),Ke(this,"name","WalletConnect"),Ke(this,"ready",!0),Mr(this,or,void 0),Mr(this,t0,void 0),Ke(this,"onAccountsChanged",e=>{e.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(e[0])})}),Ke(this,"onChainChanged",e=>{const r=Number(e),n=this.isChainUnsupported(r);this.emit("change",{chain:{id:r,unsupported:n}})}),Ke(this,"onDisconnect",()=>{Rr(this,Mu,Eh).call(this,[]),this.emit("disconnect")}),Ke(this,"onDisplayUri",e=>{this.emit("message",{type:"display_uri",data:e})}),Ke(this,"onConnect",()=>{this.emit("connect",{})}),Rr(this,Xv,_5).call(this)}async connect({chainId:t,pairingTopic:e}={}){var r,n,i,s,o;try{let a=t;if(!a){const p=(r=this.storage)==null?void 0:r.getItem(U2e),v=(s=(i=(n=p==null?void 0:p.state)==null?void 0:n.data)==null?void 0:i.chain)==null?void 0:s.id;v&&!this.isChainUnsupported(v)?a=v:a=(o=this.chains[0])==null?void 0:o.id}if(!a)throw new Error("No chains found on connector.");const c=await this.getProvider();Rr(this,T5,yz).call(this);const l=Rr(this,Zv,P5).call(this);if(c.session&&l&&await c.disconnect(),!c.session||l){const p=this.chains.filter(v=>v.id!==a).map(v=>v.id);this.emit("message",{type:"connecting"}),await c.connect({pairingTopic:e,chains:[a],optionalChains:p.length?p:void 0}),Rr(this,Mu,Eh).call(this,this.chains.map(({id:v})=>v))}const u=await c.enable(),f=Dn(u[0]),d=await this.getChainId(),h=this.isChainUnsupported(d);return{account:f,chain:{id:d,unsupported:h}}}catch(a){throw/user rejected/i.test(a==null?void 0:a.message)?new Pr(a):a}}async disconnect(){const t=await this.getProvider();try{await t.disconnect()}catch(e){if(!/No matching key/i.test(e.message))throw e}finally{Rr(this,Fy,tk).call(this),Rr(this,Mu,Eh).call(this,[])}}async getAccount(){const{accounts:t}=await this.getProvider();return Dn(t[0])}async getChainId(){const{chainId:t}=await this.getProvider();return t}async getProvider({chainId:t}={}){return We(this,or)||await Rr(this,Xv,_5).call(this),t&&await this.switchChain(t),We(this,or)}async getWalletClient({chainId:t}={}){const[e,r]=await Promise.all([this.getProvider({chainId:t}),this.getAccount()]),n=this.chains.find(i=>i.id===t);if(!e)throw new Error("provider is required.");return K1({account:r,chain:n,transport:kb(e)})}async isAuthorized(){try{const[t,e]=await Promise.all([this.getAccount(),this.getProvider()]),r=Rr(this,Zv,P5).call(this);if(!t)return!1;if(r&&e.session){try{await e.disconnect()}catch{}return!1}return!0}catch{return!1}}async switchChain(t){var r,n;const e=this.chains.find(i=>i.id===t);if(!e)throw new ea(new Error("chain not found on connector."));try{const i=await this.getProvider(),s=Rr(this,jy,nk).call(this),o=Rr(this,Uy,ik).call(this);if(!s.includes(t)&&o.includes(A5)){await i.request({method:A5,params:[{chainId:Ue(e.id),blockExplorerUrls:[(n=(r=e.blockExplorers)==null?void 0:r.default)==null?void 0:n.url],chainName:e.name,nativeCurrency:e.nativeCurrency,rpcUrls:[...e.rpcUrls.default.http]}]});const c=Rr(this,By,rk).call(this);c.push(t),Rr(this,Mu,Eh).call(this,c)}return await i.request({method:"wallet_switchEthereumChain",params:[{chainId:Ue(t)}]}),e}catch(i){const s=typeof i=="string"?i:i==null?void 0:i.message;throw/user rejected request/i.test(s)?new Pr(i):new ea(i)}}};or=new WeakMap;t0=new WeakMap;Xv=new WeakSet;_5=async function(){return!We(this,t0)&&typeof window<"u"&&ys(this,t0,Rr(this,ek,mz).call(this)),We(this,t0)};ek=new WeakSet;mz=async function(){const{EthereumProvider:t,OPTIONAL_EVENTS:e,OPTIONAL_METHODS:r}=await HS(()=>import("./index.es-69483be7.js"),["./index.es-69483be7.js","./events-d5745873.js"],import.meta.url),[n,...i]=this.chains.map(({id:s})=>s);if(n){const{projectId:s,showQrModal:o=!0,qrModalOptions:a,metadata:c,relayUrl:l}=this.options;ys(this,or,await t.init({showQrModal:o,qrModalOptions:a,projectId:s,optionalMethods:r,optionalEvents:e,chains:[n],optionalChains:i.length?i:void 0,rpcMap:Object.fromEntries(this.chains.map(u=>[u.id,u.rpcUrls.default.http[0]])),metadata:c,relayUrl:l}))}};Zv=new WeakSet;P5=function(){if(Rr(this,Uy,ik).call(this).includes(A5)||!this.options.isNewChainsStale)return!1;const e=Rr(this,By,rk).call(this),r=this.chains.map(({id:i})=>i),n=Rr(this,jy,nk).call(this);return n.length&&!n.some(i=>r.includes(i))?!1:!r.every(i=>e.includes(i))};T5=new WeakSet;yz=function(){We(this,or)&&(Rr(this,Fy,tk).call(this),We(this,or).on("accountsChanged",this.onAccountsChanged),We(this,or).on("chainChanged",this.onChainChanged),We(this,or).on("disconnect",this.onDisconnect),We(this,or).on("session_delete",this.onDisconnect),We(this,or).on("display_uri",this.onDisplayUri),We(this,or).on("connect",this.onConnect))};Fy=new WeakSet;tk=function(){We(this,or)&&(We(this,or).removeListener("accountsChanged",this.onAccountsChanged),We(this,or).removeListener("chainChanged",this.onChainChanged),We(this,or).removeListener("disconnect",this.onDisconnect),We(this,or).removeListener("session_delete",this.onDisconnect),We(this,or).removeListener("display_uri",this.onDisplayUri),We(this,or).removeListener("connect",this.onConnect))};Mu=new WeakSet;Eh=function(t){var e;(e=this.storage)==null||e.setItem(vz,t)};By=new WeakSet;rk=function(){var t;return((t=this.storage)==null?void 0:t.getItem(vz))??[]};jy=new WeakSet;nk=function(){var n,i,s;if(!We(this,or))return[];const t=(n=We(this,or).session)==null?void 0:n.namespaces;return t?((s=(i=dz(t)[pz])==null?void 0:i.chains)==null?void 0:s.map(o=>parseInt(o.split(":")[1]||"")))??[]:[]};Uy=new WeakSet;ik=function(){var n,i;if(!We(this,or))return[];const t=(n=We(this,or).session)==null?void 0:n.namespaces;return t?((i=dz(t)[pz])==null?void 0:i.methods)??[]:[]};function ke(){return ke=Object.assign?Object.assign.bind():function(t){for(var e=1;e({account:l[0]}),this.onDisconnect=()=>{this==null||this.emit("disconnect")};const o=(r==null||(n=r.connect)==null||(n=n.settings)==null?void 0:n.signInOptions)||[],a=r==null||(i=r.connect)==null||(i=i.settings)==null?void 0:i.signInWith;if(r==null||(s=r.connect)==null||(s=s.settings)==null?void 0:s.signInWithEmail)this.id="email",this.name="Email";else if(a)this.id=a,this.name=`${a[0].toUpperCase()}${a.slice(1)}`;else if(o.length>0){const l=o[0],u=`${l[0].toUpperCase()}${l.slice(1)}`;this.id=l,this.name=u}this.provider=NU.initWallet({defaultNetwork:r==null?void 0:r.defaultNetwork,transports:{walletAppURL:"https://sequence.app"},defaultEIP6492:!0}),this.provider.on("chainChanged",l=>{this==null||this.emit("change",{chain:{id:I5(l),unsupported:!1}})}),this.provider.on("accountsChanged",l=>{this==null||this.emit("accountsChanged",this.onAccountsChanged(l))}),this.provider.on("disconnect",()=>{this.onDisconnect()})}async connect(){if(!this.provider.isConnected()){var e,r,n;this==null||this.emit("message",{type:"connecting"});const s=(e=this.options)==null?void 0:e.connect,o=localStorage.getItem(gn.Theme),a=localStorage.getItem(gn.EthAuthSettings),c=a?JSON.parse(a):{},l=ke({authorize:!0},c,s,{settings:ke({theme:o||"dark"},s==null?void 0:s.settings)}),u=await this.provider.connect(l);if(u.error)throw new Pr(new Error(u.error));if(!u.connected)throw new Pr(new Error("Wallet connection rejected"));const f=(r=u.proof)==null?void 0:r.proofString,d=(n=u.proof)==null?void 0:n.typedData;if(f){const h=JSON.stringify({proofString:f,typedData:d});localStorage.setItem(gn.EthAuthProof,h)}}return{account:await this.getAccount(),chain:{id:this.provider.getChainId(),unsupported:this.isChainUnsupported(this.provider.getChainId())}}}async getWalletClient({chainId:e}={}){const r=this.chains.find(n=>n.id===e);return K1({chain:r,account:await this.getAccount(),transport:kb(this.provider)})}onChainChanged(e){this.provider.setDefaultChainId(I5(e))}async switchChain(e){if(this.isChainUnsupported(e))throw new Error("Unsupported chain");return this.provider.setDefaultChainId(e),this.chains.find(r=>r.id===e)}async disconnect(){localStorage.removeItem(gn.EthAuthProof),this.provider.disconnect()}getAccount(){return this.provider.getSigner().getAddress()}async getChainId(){return this.provider.getChainId()}async getProvider(){return this.provider}async getSigner(){return this.provider.getSigner()}async isAuthorized(){try{return!!await this.getAccount()}catch{return!1}}isChainUnsupported(e){return this.provider.networks.findIndex(r=>r.chainId===e)===-1}}const I5=t=>typeof t=="object"?I5(t.chainId):typeof t=="string"?Number.parseInt(t,t.trim().substring(0,2)==="0x"?16:10):typeof t=="bigint"?Number(t):t;function Xi(t){if(t==null)throw new TypeError("Cannot destructure "+t)}const S9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 34",fill:"none"},i),x.createElement("path",{d:"M27.702 11.5918C27.5049 11.7448 24.0243 13.7068 24.0243 18.0694C24.0243 23.1155 28.4532 24.9007 28.5858 24.9449C28.5654 25.0537 27.8822 27.3897 26.2506 29.77C24.7958 31.8646 23.2765 33.9558 20.9651 33.9558C18.6538 33.9558 18.0589 32.6127 15.3907 32.6127C12.7904 32.6127 11.8659 34 9.75169 34C7.63748 34 6.1623 32.0618 4.46618 29.6816C2.50154 26.8865 0.914185 22.5443 0.914185 18.423C0.914185 11.8128 5.21057 8.30703 9.43897 8.30703C11.6857 8.30703 13.5586 9.78278 14.9692 9.78278C16.3118 9.78278 18.4056 8.21862 20.9617 8.21862C21.9304 8.21862 25.4111 8.30703 27.702 11.5918ZM19.7483 5.42014C20.8054 4.16542 21.5532 2.42444 21.5532 0.683468C21.5532 0.442044 21.5328 0.19722 21.4886 0C19.7687 0.0646065 17.7224 1.14591 16.4886 2.57746C15.5199 3.67917 14.6157 5.42014 14.6157 7.18492C14.6157 7.45014 14.6599 7.71537 14.6803 7.80038C14.7891 7.82078 14.9658 7.84458 15.1426 7.84458C16.6857 7.84458 18.6266 6.81088 19.7483 5.42014Z",fill:e})))}},k9=({isDarkMode:t})=>{const e=t?"#FFFFFF":"#000000";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{d:"M27.166 20.8774C27.1338 17.335 30.0617 15.633 30.1936 15.5493C28.5463 13.1395 25.9852 12.8113 25.0714 12.7727C22.8932 12.5507 20.8179 14.0565 19.7111 14.0565C18.6043 14.0565 16.8991 12.8049 15.0909 12.8403C12.7131 12.8757 10.5221 14.2205 9.2962 16.3505C6.8284 20.6297 8.66557 26.9777 11.0722 30.4557C12.2498 32.1545 13.6494 34.0689 15.493 33.9981C17.2691 33.9273 17.9383 32.8495 20.0811 32.8495C22.224 32.8495 22.8289 33.9981 24.7014 33.9627C26.6094 33.9241 27.8191 32.2253 28.9871 30.5201C30.3352 28.5478 30.8918 26.6366 30.924 26.5369C30.8822 26.5208 27.2046 25.1116 27.166 20.8774Z",fill:e}),x.createElement("path",{d:"M23.6429 10.4722C24.621 9.28822 25.2806 7.64089 25.1004 6C23.6911 6.05791 21.9859 6.93949 20.9756 8.12351C20.0715 9.16917 19.2768 10.8455 19.4923 12.4542C21.0592 12.5764 22.6648 11.653 23.6429 10.4722Z",fill:e})))}},W2e=({chains:t,options:e={}})=>({id:"apple",isSequenceBased:!0,logoDark:S9({isDarkMode:!0}),logoLight:S9({isDarkMode:!1}),monochromeLogoDark:k9({isDarkMode:!0}),monochromeLogoLight:k9({isDarkMode:!1}),name:"Apple",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"apple"})})})})}}),A9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("rect",{width:"28",height:"28",fill:"#2C5FF6"}),x.createElement("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M14 23.8C19.4124 23.8 23.8 19.4124 23.8 14C23.8 8.58761 19.4124 4.2 14 4.2C8.58761 4.2 4.2 8.58761 4.2 14C4.2 19.4124 8.58761 23.8 14 23.8ZM11.55 10.8C11.1358 10.8 10.8 11.1358 10.8 11.55V16.45C10.8 16.8642 11.1358 17.2 11.55 17.2H16.45C16.8642 17.2 17.2 16.8642 17.2 16.45V11.55C17.2 11.1358 16.8642 10.8 16.45 10.8H11.55Z",fill:"white"})))},H2e=t=>({id:"coinbase-wallet",logoDark:A9,logoLight:A9,name:"Coinbase Wallet",createConnector:()=>new nge(ke({},t))}),_9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 35 34",fill:"none"},i),x.createElement("path",{d:"M17.0826 16.3805C17.1802 16.4598 17.32 16.4598 17.4176 16.3805L30.1401 6.04341C30.5283 5.72801 30.3053 5.09985 29.8051 5.09985H4.69499C4.19482 5.09985 3.9718 5.72801 4.35998 6.04341L17.0826 16.3805Z",fill:e}),x.createElement("path",{d:"M19.7626 19.2667L33.3838 8.19943C33.731 7.91735 34.2501 8.16441 34.2501 8.61174V24.2249C34.2501 26.5721 32.3473 28.4749 30.0001 28.4749H4.50006C2.15285 28.4749 0.250061 26.5721 0.250061 24.2249V8.61174C0.250061 8.16441 0.769134 7.91735 1.11631 8.19943L14.7375 19.2667C16.2014 20.4561 18.2987 20.4561 19.7626 19.2667Z",fill:e})))}},O5="@sequence.kit.connector.email",q2e=({chains:t,options:e={}})=>({id:"email",isSequenceBased:!0,logoDark:_9({isDarkMode:!0}),logoLight:_9({isDarkMode:!1}),name:"Email",createConnector:()=>{var r;const n=localStorage.getItem(O5);return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInOptions:["email"],signInWithEmail:n||""})})})})}}),P9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},e),x.createElement("path",{d:"M17.4214 36.9716C9.27855 35.5145 3.10712 28.4859 3.10712 20.0001C3.10712 10.5715 10.8214 2.85718 20.25 2.85718C29.6785 2.85718 37.3928 10.5715 37.3928 20.0001C37.3928 28.4859 31.2214 35.5145 23.0785 36.9716L22.1357 36.2002H18.3643L17.4214 36.9716Z",fill:"url(#paint0_linear_193_14528)"}),x.createElement("path",{d:"M26.9357 24.7999L27.7072 19.9999H23.1643V16.657C23.1643 15.2856 23.6786 14.257 25.7357 14.257H27.9643V9.88558C26.7643 9.71415 25.3929 9.54272 24.1929 9.54272C20.25 9.54272 17.5071 11.9427 17.5071 16.2285V19.9999H13.2214V24.7999H17.5071V36.8857C18.45 37.0571 19.3929 37.1429 20.3357 37.1429C21.2786 37.1429 22.2214 37.0571 23.1643 36.8857V24.7999H26.9357Z",fill:"white"}),x.createElement("defs",null,x.createElement("linearGradient",{id:"paint0_linear_193_14528",x1:"20.2508",y1:"35.9507",x2:"20.2508",y2:"2.85086",gradientUnits:"userSpaceOnUse"},x.createElement("stop",{"stop-color":"#0062E0"}),x.createElement("stop",{offset:"1","stop-color":"#19AFFF"})))))},T9=({isDarkMode:t})=>{const e=t?"#FFFFFF":"#000000";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{d:"M25.8582 10.4398C24.1222 10.4398 23.6288 11.2098 23.6288 12.9073V15.709H28.246L27.791 20.2476H23.6279V34H18.1024V20.2468H14.375V15.7081H18.1042V12.9851C18.1042 8.40625 19.9399 6 25.0891 6C26.1942 6 27.5163 6.0875 28.3055 6.19775V10.459",fill:e})))}},V2e=({chains:t,options:e={}})=>({id:"facebook",isSequenceBased:!0,logoDark:P9,logoLight:P9,monochromeLogoDark:T9({isDarkMode:!0}),monochromeLogoLight:T9({isDarkMode:!1}),name:"Facebook",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"facebook"})})})})}}),I9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({viewBox:"0 0 41 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("g",{id:"Frame 2114"},x.createElement("g",{id:"Group"},x.createElement("path",{id:"Vector",d:"M20.7497 16.8828V23.5218H29.9756C29.5705 25.6568 28.3548 27.4647 26.5314 28.6803L32.095 32.9972C35.3366 30.0051 37.2068 25.6102 37.2068 20.3895C37.2068 19.1739 37.0977 18.005 36.895 16.883L20.7497 16.8828Z",fill:"#4285F4"}),x.createElement("path",{id:"Vector_2",d:"M11.1424 23.2627L9.88756 24.2232L5.44592 27.6829C8.2667 33.2777 14.0481 37.1427 20.7493 37.1427C25.3778 37.1427 29.2583 35.6154 32.0947 32.9973L26.5311 28.6803C25.0038 29.7089 23.0557 30.3324 20.7493 30.3324C16.2922 30.3324 12.5053 27.3246 11.1494 23.2726L11.1424 23.2627Z",fill:"#34A853"}),x.createElement("path",{id:"Vector_3",d:"M5.44594 12.3169C4.27718 14.6233 3.60712 17.2259 3.60712 19.9999C3.60712 22.7739 4.27718 25.3765 5.44594 27.6829C5.44594 27.6984 11.1499 23.2569 11.1499 23.2569C10.8071 22.2284 10.6044 21.1375 10.6044 19.9997C10.6044 18.8619 10.8071 17.7711 11.1499 16.7425L5.44594 12.3169Z",fill:"#FBBC05"}),x.createElement("path",{id:"Vector_4",d:"M20.7497 9.6829C23.2744 9.6829 25.5185 10.5556 27.3107 12.2387L32.2198 7.32972C29.2431 4.55574 25.3783 2.85693 20.7497 2.85693C14.0484 2.85693 8.2667 6.70628 5.44592 12.3167L11.1497 16.7427C12.5055 12.6907 16.2926 9.6829 20.7497 9.6829Z",fill:"#EA4335"})))))},O9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M25.8355 14.7613C24.5584 13.5329 22.9441 12.9032 21.1356 12.9032C17.9377 12.9032 15.2302 15.0813 14.2595 18.0232L14.2593 18.023C14.0142 18.7662 13.8712 19.5609 13.8712 20.3866C13.8712 21.2124 14.004 22.0072 14.2594 22.7504L14.2587 22.751H14.2595C15.2302 25.6929 17.9377 27.871 21.1356 27.871C22.7907 27.871 24.1904 27.4168 25.2939 26.6736V26.6732C26.5812 25.7958 27.4497 24.5055 27.746 22.9777H21.1355V18.3223H32.6808C32.8034 19.0758 32.875 19.85 32.875 20.6655C32.875 24.4332 31.5467 27.6126 29.2377 29.77L29.2378 29.7703C27.2148 31.6594 24.446 32.7742 21.1356 32.7742C16.3438 32.7742 12.2059 29.9871 10.1931 25.9407V25.94L10.193 25.9401C9.35521 24.2678 8.875 22.3891 8.875 20.3866C8.875 18.384 9.35521 16.5053 10.193 14.833H10.1934C12.2063 10.7869 16.344 8 21.1356 8C24.446 8 27.2148 9.22839 29.3298 11.231L25.8355 14.7613Z",fill:e}))}},G2e=({chains:t,options:e={}})=>({id:"google",isSequenceBased:!0,logoDark:I9,logoLight:I9,monochromeLogoDark:O9({isDarkMode:!0}),monochromeLogoLight:O9({isDarkMode:!1}),name:"Google",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"google"})})})})}}),R9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("rect",{width:"28",height:"28"}),x.createElement("path",{d:"M24.0891 3.1199L15.3446 9.61456L16.9617 5.7828L24.0891 3.1199Z",fill:"#E2761B",stroke:"#E2761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M3.90207 3.1199L12.5763 9.67608L11.0383 5.7828L3.90207 3.1199Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M20.9429 18.1745L18.6139 21.7426L23.597 23.1136L25.0295 18.2536L20.9429 18.1745Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M2.97929 18.2536L4.40301 23.1136L9.38607 21.7426L7.05713 18.1745L2.97929 18.2536Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.10483 12.1456L7.71626 14.2461L12.6642 14.4658L12.4884 9.14877L9.10483 12.1456Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.8864 12.1456L15.4589 9.08725L15.3446 14.4658L20.2837 14.2461L18.8864 12.1456Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L12.3566 20.2925L9.79033 18.2888L9.38606 21.7426Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.6347 20.2925L18.6139 21.7426L18.2009 18.2888L15.6347 20.2925Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.6139 21.7426L15.6347 20.2925L15.8719 22.2348L15.8456 23.0521L18.6139 21.7426Z",fill:"#D7C1B3",stroke:"#D7C1B3",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L12.1544 23.0521L12.1368 22.2348L12.3566 20.2925L9.38606 21.7426Z",fill:"#D7C1B3",stroke:"#D7C1B3",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M12.1984 17.0056L9.72002 16.2762L11.4689 15.4765L12.1984 17.0056Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.7928 17.0056L16.5223 15.4765L18.28 16.2762L15.7928 17.0056Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L9.80791 18.1745L7.05712 18.2536L9.38606 21.7426Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.1921 18.1745L18.6139 21.7426L20.9429 18.2536L18.1921 18.1745Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M20.2837 14.2461L15.3446 14.4658L15.8016 17.0057L16.5311 15.4765L18.2888 16.2762L20.2837 14.2461Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.72002 16.2762L11.4777 15.4765L12.1984 17.0057L12.6642 14.4658L7.71626 14.2461L9.72002 16.2762Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M7.71626 14.2461L9.79033 18.2888L9.72002 16.2762L7.71626 14.2461Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.2888 16.2762L18.2009 18.2888L20.2837 14.2461L18.2888 16.2762Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M12.6642 14.4658L12.1984 17.0057L12.7784 20.0025L12.9102 16.0565L12.6642 14.4658Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.3446 14.4658L15.1073 16.0477L15.2128 20.0025L15.8016 17.0057L15.3446 14.4658Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.8016 17.0056L15.2128 20.0025L15.6347 20.2925L18.2009 18.2888L18.2888 16.2762L15.8016 17.0056Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.72002 16.2762L9.79033 18.2888L12.3566 20.2925L12.7784 20.0025L12.1984 17.0056L9.72002 16.2762Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.8456 23.0521L15.8719 22.2348L15.6522 22.0414H12.339L12.1368 22.2348L12.1544 23.0521L9.38606 21.7426L10.3528 22.5336L12.3126 23.8958H15.6786L17.6472 22.5336L18.6139 21.7426L15.8456 23.0521Z",fill:"#C0AD9E",stroke:"#C0AD9E",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.6347 20.2925L15.2128 20.0025H12.7784L12.3566 20.2925L12.1368 22.2348L12.339 22.0414H15.6522L15.8719 22.2348L15.6347 20.2925Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M24.4583 10.0364L25.2053 6.45072L24.0891 3.1199L15.6347 9.39485L18.8864 12.1456L23.4827 13.4903L24.5022 12.3038L24.0628 11.9874L24.7658 11.3459L24.221 10.924L24.924 10.3879L24.4583 10.0364Z",fill:"#763D16",stroke:"#763D16",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M2.79472 6.45072L3.54174 10.0364L3.06717 10.3879L3.77024 10.924L3.23415 11.3459L3.93722 11.9874L3.4978 12.3038L4.50847 13.4903L9.10483 12.1456L12.3566 9.39485L3.90207 3.1199L2.79472 6.45072Z",fill:"#763D16",stroke:"#763D16",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M23.4827 13.4903L18.8864 12.1456L20.2837 14.2461L18.2009 18.2888L20.9429 18.2536H25.0295L23.4827 13.4903Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.10484 12.1456L4.50848 13.4903L2.97929 18.2536H7.05713L9.79033 18.2888L7.71626 14.2461L9.10484 12.1456Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.3446 14.4658L15.6347 9.39485L16.9705 5.7828H11.0383L12.3566 9.39485L12.6642 14.4658L12.7696 16.0653L12.7784 20.0025H15.2128L15.2304 16.0653L15.3446 14.4658Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"})))},zy=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",style:{fill:"none"},id:"svg1316",version:"1.1",viewBox:"0 0 396 396"},e),x.createElement("g",{transform:"translate(0,38)",id:"g1256",clipPath:"url(#clip0_5_131)"},x.createElement("g",{id:"g1254",clipPath:"url(#clip1_5_131)"},x.createElement("path",{style:{fill:"#111111"},id:"path1232",d:"M 0,67.5049 V 250.165 c 0,37.282 30.1402,67.505 67.32,67.505 h 261.36 c 37.18,0 67.32,-30.223 67.32,-67.505 V 67.5049 C 396,30.223 365.86,0 328.68,0 H 67.32 C 30.1402,0 0,30.223 0,67.5049 Z"}),x.createElement("path",{style:{fill:"url(#paint0_linear_5_13"},id:"path1234",d:"M 0,67.5049 V 250.165 c 0,37.282 30.1402,67.505 67.32,67.505 h 261.36 c 37.18,0 67.32,-30.223 67.32,-67.505 V 67.5049 C 396,30.223 365.86,0 328.68,0 H 67.32 C 30.1402,0 0,30.223 0,67.5049 Z"}),x.createElement("path",{style:{fill:"url(#paint1_linear_5_131"},id:"path1236",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint2_linear_5_131)"},id:"path1238",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint3_linear_5_131)"},id:"path1240",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint4_linear_5_131)"},id:"path1242",d:"m 98.9999,238.126 c 0,-10.965 -8.8648,-19.854 -19.8,-19.854 -10.9352,0 -19.8,8.889 -19.8,19.854 0,10.966 8.8648,19.855 19.8,19.855 10.9352,0 19.8,-8.889 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint5_linear_5_131)"},id:"path1244",d:"m 336.6,158.835 c 0,-10.965 -8.865,-19.854 -19.8,-19.854 -10.935,0 -19.8,8.889 -19.8,19.854 0,10.965 8.865,19.855 19.8,19.855 10.935,0 19.8,-8.89 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint6_linear_5_131)"},id:"path1246",d:"m 336.6,158.835 c 0,-10.965 -8.865,-19.854 -19.8,-19.854 -10.935,0 -19.8,8.889 -19.8,19.854 0,10.965 8.865,19.855 19.8,19.855 10.935,0 19.8,-8.89 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint7_linear_5_131)"},id:"path1248",d:"M 316.8,59.5632 H 158.4 c -10.935,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.865,19.8544 19.8,19.8544 h 158.4 c 10.935,0 19.8,-8.8892 19.8,-19.8544 0,-10.9653 -8.865,-19.8544 -19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint8_linear_5_131)"},id:"path1250",d:"M 316.8,218.272 H 158.4 c -10.935,0 -19.8,8.889 -19.8,19.854 0,10.966 8.865,19.855 19.8,19.855 h 158.4 c 10.935,0 19.8,-8.889 19.8,-19.855 0,-10.965 -8.865,-19.854 -19.8,-19.854 z"}),x.createElement("path",{style:{fill:"url(#paint9_linear_5_131)"},id:"path1252",d:"M 237.6,138.981 H 79.2 c -10.9352,0 -19.8,8.889 -19.8,19.854 0,10.965 8.8648,19.855 19.8,19.855 h 158.4 c 10.935,0 19.8,-8.89 19.8,-19.855 0,-10.965 -8.865,-19.854 -19.8,-19.854 z"}))),x.createElement("defs",{id:"defs1314"},x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"318",x2:"198",y1:"4.0585401e-05",x1:"198",id:"paint0_linear_5_131"},x.createElement("stop",{id:"stop1258",stopColor:"#1D273D"}),x.createElement("stop",{id:"stop1260",stopColor:"#0D0F13",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"63",x2:"92.5",y1:"99",x1:"65.5",id:"paint1_linear_5_131"},x.createElement("stop",{id:"stop1263",stopColor:"#4462FE"}),x.createElement("stop",{id:"stop1265",stopColor:"#7D69FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"97.591103",x2:"96.137703",y1:"99.291199",x1:"62.879902",id:"paint2_linear_5_131"},x.createElement("stop",{id:"stop1268",stopColor:"#3757FD"}),x.createElement("stop",{id:"stop1270",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"97.591103",x2:"96.137703",y1:"99.291199",x1:"62.879902",id:"paint3_linear_5_131"},x.createElement("stop",{id:"stop1273",stopColor:"#2447FF"}),x.createElement("stop",{id:"stop1275",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"223.5",x2:"91.5",y1:"251.5",x1:"65",id:"paint4_linear_5_131"},x.createElement("stop",{id:"stop1278",stopColor:"#BC3EE6"}),x.createElement("stop",{id:"stop1280",stopColor:"#D972F1",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"146",x2:"329.5",y1:"172",x1:"305",id:"paint5_linear_5_131"},x.createElement("stop",{id:"stop1283",stopColor:"#29BDFF"}),x.createElement("stop",{id:"stop1285",stopColor:"#96E7FB",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"176.772",x2:"334.56699",y1:"178.418",x1:"300.17999",id:"paint6_linear_5_131"},x.createElement("stop",{id:"stop1288",stopColor:"#23BBFF"}),x.createElement("stop",{id:"stop1290",stopColor:"#85E7FF",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"60",x2:"317.5",y1:"99",x1:"154.5",id:"paint7_linear_5_131"},x.createElement("stop",{id:"stop1293",stopColor:"#23BBFF"}),x.createElement("stop",{id:"stop1295",stopColor:"#85E7FF",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"218",x2:"312.5",y1:"258",x1:"156",id:"paint8_linear_5_131"},x.createElement("stop",{id:"stop1298",stopColor:"#2447FF"}),x.createElement("stop",{id:"stop1300",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"139",x2:"235.5",y1:"179",x1:"86.000099",id:"paint9_linear_5_131"},x.createElement("stop",{id:"stop1303",stopColor:"#6634FF"}),x.createElement("stop",{id:"stop1305",stopColor:"#9C6DFF",offset:"1"})),x.createElement("clipPath",{id:"clip0_5_131"},x.createElement("rect",{style:{fill:"#ffffff"},y:"0",x:"0",id:"rect1308",height:"317.67001",width:"396"})),x.createElement("clipPath",{id:"clip1_5_131"},x.createElement("rect",{style:{fill:"#ffffff"},y:"0",x:"0",id:"rect1311",height:"317.67001",width:"396"})))))};window.ethereum=window.ethereum||{};const K2e=({chains:t})=>({id:"metamask",logoDark:R9,logoLight:R9,name:"Metamask",createConnector:()=>new ige({chains:t,options:{shimDisconnect:!0}})}),Q2e=({chains:t,options:e})=>({id:"mock",isSequenceBased:!0,logoDark:zy,logoLight:zy,name:"Mock",createConnector:()=>{var r;return new oge({chains:t,options:ke({chainId:(e==null||(r=e.chain)==null?void 0:r.id)||137,walletClient:K1({account:e.account,chain:(e==null?void 0:e.chain)||vfe,transport:e.transport})},e)})}}),Y2e=({chains:t,options:e})=>({id:"sequence",isSequenceBased:!0,logoDark:zy,logoLight:zy,name:"Sequence",createConnector:()=>new Od({chains:t,options:e})}),iv=({isDarkMode:t})=>{let e;return t===void 0?e="#9146FF":e=t?"white":"black",n=>(ke({},(Xi(n),n)),x.createElement(x.Fragment,null,x.createElement("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 2400 2800",transform:"scale(0.80)"},x.createElement("g",null,x.createElement("g",{id:"Layer_1-2"},x.createElement("path",{fill:e,d:"M500,0L0,500v1800h600v500l500-500h400l900-900V0H500z M2200,1300l-400,400h-400l-350,350v-350H600V200h1600 V1300z"}),x.createElement("rect",{x:"1700",y:"550",fill:e,width:"200",height:"600"}),x.createElement("rect",{x:"1150",y:"550",fill:e,width:"200",height:"600"}))))))},J2e=({chains:t,options:e={}})=>({id:"twitch",isSequenceBased:!0,logoDark:iv({}),logoLight:iv({}),monochromeLogoDark:iv({isDarkMode:!0}),monochromeLogoLight:iv({isDarkMode:!1}),name:"Twitch",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"twitch"})})})})}}),$9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({fill:"none",viewBox:"0 0 480 332",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("path",{d:"m126.613 93.9842c62.622-61.3123 164.152-61.3123 226.775 0l7.536 7.3788c3.131 3.066 3.131 8.036 0 11.102l-25.781 25.242c-1.566 1.533-4.104 1.533-5.67 0l-10.371-10.154c-43.687-42.7734-114.517-42.7734-158.204 0l-11.107 10.874c-1.565 1.533-4.103 1.533-5.669 0l-25.781-25.242c-3.132-3.066-3.132-8.036 0-11.102zm280.093 52.2038 22.946 22.465c3.131 3.066 3.131 8.036 0 11.102l-103.463 101.301c-3.131 3.065-8.208 3.065-11.339 0l-73.432-71.896c-.783-.767-2.052-.767-2.835 0l-73.43 71.896c-3.131 3.065-8.208 3.065-11.339 0l-103.4657-101.302c-3.1311-3.066-3.1311-8.036 0-11.102l22.9456-22.466c3.1311-3.065 8.2077-3.065 11.3388 0l73.4333 71.897c.782.767 2.051.767 2.834 0l73.429-71.897c3.131-3.065 8.208-3.065 11.339 0l73.433 71.897c.783.767 2.052.767 2.835 0l73.431-71.895c3.132-3.066 8.208-3.066 11.339 0z",fill:"#3396ff"})))},X2e=({chains:t,options:e})=>({id:"wallet-connect",logoDark:$9,logoLight:$9,name:"Walletconnect",createConnector:()=>new z2e({chains:t,options:e})}),Z2e=({chains:t,walletConnectProjectId:e,defaultChainId:r})=>{let n=t[0].id;if(r){const s=t.find(o=>o.id===r);s&&(n=s.id)}return Dz([H2e({chains:t,options:{appName:"app"}}),q2e({chains:t,options:{defaultNetwork:n}}),G2e({chains:t,options:{defaultNetwork:n}}),V2e({chains:t,options:{defaultNetwork:n}}),J2e({chains:t,options:{defaultNetwork:n}}),W2e({chains:t,options:{defaultNetwork:n}}),K2e({chains:t}),X2e({chains:t,options:{projectId:e}}),Y2e({chains:t,options:{defaultNetwork:n}})])};function sk(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function sv(){}function M9(){return typeof WeakMap<"u"?new WeakMap:eEe()}function eEe(){return{add:sv,delete:sv,get:sv,set:sv,has:function(t){return!1}}}var tEe=Object.prototype.hasOwnProperty,R5=function(t,e){return tEe.call(t,e)};function cE(t,e){for(var r in e)R5(e,r)&&(t[r]=e[r]);return t}var rEe=/^[ \t]*(?:\r\n|\r|\n)/,nEe=/(?:\r\n|\r|\n)[ \t]*$/,iEe=/^(?:[\r\n]|$)/,sEe=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,oEe=/^[ \t]*[\r\n][ \t\r\n]*$/;function N9(t,e,r){var n=0,i=t[0].match(sEe);i&&(n=i[1].length);var s="(\\r\\n|\\r|\\n).{0,"+n+"}",o=new RegExp(s,"g");e&&(t=t.slice(1));var a=r.newline,c=r.trimLeadingNewline,l=r.trimTrailingNewline,u=typeof a=="string",f=t.length,d=t.map(function(h,p){return h=h.replace(o,"$1"),p===0&&c&&(h=h.replace(rEe,"")),p===f-1&&l&&(h=h.replace(nEe,"")),u&&(h=h.replace(/\r\n|\n|\r/g,function(v){return a})),h});return d}function aEe(t,e){for(var r="",n=0,i=t.length;n{},registerClassName:()=>{},onEndFileScope:()=>{},registerComposition:()=>{},markCompositionUsed:()=>{},getIdentOption:()=>"short"},em=[lEe],au=()=>{if(em.length<1)throw new Error("No adapter configured");return em[em.length-1]},bz=!1,uEe=t=>{bz||fEe(t)},fEe=t=>{if(!t)throw new Error('No adapter provided when calling "setAdapter"');bz=!0,em.push(t)},Zb=function(){return au().appendCss(...arguments)},wz=function(){return au().registerClassName(...arguments)},dEe=function(){return au().registerComposition(...arguments)},Ez=function(){return au().markCompositionUsed(...arguments)},hEe=function(){for(var e,r,n=arguments.length,i=new Array(n),s=0;s{n||(yl(i[f].methods,s[f].methods)?yl(i[f].events,s[f].events)||(n=Fa("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${f}`)):n=Fa("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${f}`))}),n}function B2e(t){const e={};return Object.keys(t).forEach(r=>{var n;r.includes(":")?e[r]=t[r]:(n=t[r].chains)==null||n.forEach(i=>{e[i]={methods:t[r].methods,events:t[r].events}})}),e}function C9(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function j2e(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const n=Id(t[r].accounts);n==null||n.forEach(i=>{e[i]={accounts:t[r].accounts.filter(s=>s.includes(`${i}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function h9e(t,e){return Z8(t,!1)&&t<=e.max&&t>=e.min}var pz="eip155",U2e="store",vz="requestedChains",A5="wallet_addEthereumChain",or,t0,Xv,_5,ek,mz,Zv,P5,T5,yz,Fy,tk,Mu,Eh,By,rk,jy,nk,Uy,ik,z2e=class extends j1{constructor(t){super({...t,options:{isNewChainsStale:!0,...t.options}}),Mr(this,Xv),Mr(this,ek),Mr(this,Zv),Mr(this,T5),Mr(this,Fy),Mr(this,Mu),Mr(this,By),Mr(this,jy),Mr(this,Uy),Ke(this,"id","walletConnect"),Ke(this,"name","WalletConnect"),Ke(this,"ready",!0),Mr(this,or,void 0),Mr(this,t0,void 0),Ke(this,"onAccountsChanged",e=>{e.length===0?this.emit("disconnect"):this.emit("change",{account:Dn(e[0])})}),Ke(this,"onChainChanged",e=>{const r=Number(e),n=this.isChainUnsupported(r);this.emit("change",{chain:{id:r,unsupported:n}})}),Ke(this,"onDisconnect",()=>{Rr(this,Mu,Eh).call(this,[]),this.emit("disconnect")}),Ke(this,"onDisplayUri",e=>{this.emit("message",{type:"display_uri",data:e})}),Ke(this,"onConnect",()=>{this.emit("connect",{})}),Rr(this,Xv,_5).call(this)}async connect({chainId:t,pairingTopic:e}={}){var r,n,i,s,o;try{let a=t;if(!a){const p=(r=this.storage)==null?void 0:r.getItem(U2e),v=(s=(i=(n=p==null?void 0:p.state)==null?void 0:n.data)==null?void 0:i.chain)==null?void 0:s.id;v&&!this.isChainUnsupported(v)?a=v:a=(o=this.chains[0])==null?void 0:o.id}if(!a)throw new Error("No chains found on connector.");const c=await this.getProvider();Rr(this,T5,yz).call(this);const l=Rr(this,Zv,P5).call(this);if(c.session&&l&&await c.disconnect(),!c.session||l){const p=this.chains.filter(v=>v.id!==a).map(v=>v.id);this.emit("message",{type:"connecting"}),await c.connect({pairingTopic:e,chains:[a],optionalChains:p.length?p:void 0}),Rr(this,Mu,Eh).call(this,this.chains.map(({id:v})=>v))}const u=await c.enable(),f=Dn(u[0]),d=await this.getChainId(),h=this.isChainUnsupported(d);return{account:f,chain:{id:d,unsupported:h}}}catch(a){throw/user rejected/i.test(a==null?void 0:a.message)?new Pr(a):a}}async disconnect(){const t=await this.getProvider();try{await t.disconnect()}catch(e){if(!/No matching key/i.test(e.message))throw e}finally{Rr(this,Fy,tk).call(this),Rr(this,Mu,Eh).call(this,[])}}async getAccount(){const{accounts:t}=await this.getProvider();return Dn(t[0])}async getChainId(){const{chainId:t}=await this.getProvider();return t}async getProvider({chainId:t}={}){return We(this,or)||await Rr(this,Xv,_5).call(this),t&&await this.switchChain(t),We(this,or)}async getWalletClient({chainId:t}={}){const[e,r]=await Promise.all([this.getProvider({chainId:t}),this.getAccount()]),n=this.chains.find(i=>i.id===t);if(!e)throw new Error("provider is required.");return K1({account:r,chain:n,transport:kb(e)})}async isAuthorized(){try{const[t,e]=await Promise.all([this.getAccount(),this.getProvider()]),r=Rr(this,Zv,P5).call(this);if(!t)return!1;if(r&&e.session){try{await e.disconnect()}catch{}return!1}return!0}catch{return!1}}async switchChain(t){var r,n;const e=this.chains.find(i=>i.id===t);if(!e)throw new ea(new Error("chain not found on connector."));try{const i=await this.getProvider(),s=Rr(this,jy,nk).call(this),o=Rr(this,Uy,ik).call(this);if(!s.includes(t)&&o.includes(A5)){await i.request({method:A5,params:[{chainId:Ue(e.id),blockExplorerUrls:[(n=(r=e.blockExplorers)==null?void 0:r.default)==null?void 0:n.url],chainName:e.name,nativeCurrency:e.nativeCurrency,rpcUrls:[...e.rpcUrls.default.http]}]});const c=Rr(this,By,rk).call(this);c.push(t),Rr(this,Mu,Eh).call(this,c)}return await i.request({method:"wallet_switchEthereumChain",params:[{chainId:Ue(t)}]}),e}catch(i){const s=typeof i=="string"?i:i==null?void 0:i.message;throw/user rejected request/i.test(s)?new Pr(i):new ea(i)}}};or=new WeakMap;t0=new WeakMap;Xv=new WeakSet;_5=async function(){return!We(this,t0)&&typeof window<"u"&&ys(this,t0,Rr(this,ek,mz).call(this)),We(this,t0)};ek=new WeakSet;mz=async function(){const{EthereumProvider:t,OPTIONAL_EVENTS:e,OPTIONAL_METHODS:r}=await HS(()=>import("./index.es-5337afc7.js"),["./index.es-5337afc7.js","./events-90d6e183.js"],import.meta.url),[n,...i]=this.chains.map(({id:s})=>s);if(n){const{projectId:s,showQrModal:o=!0,qrModalOptions:a,metadata:c,relayUrl:l}=this.options;ys(this,or,await t.init({showQrModal:o,qrModalOptions:a,projectId:s,optionalMethods:r,optionalEvents:e,chains:[n],optionalChains:i.length?i:void 0,rpcMap:Object.fromEntries(this.chains.map(u=>[u.id,u.rpcUrls.default.http[0]])),metadata:c,relayUrl:l}))}};Zv=new WeakSet;P5=function(){if(Rr(this,Uy,ik).call(this).includes(A5)||!this.options.isNewChainsStale)return!1;const e=Rr(this,By,rk).call(this),r=this.chains.map(({id:i})=>i),n=Rr(this,jy,nk).call(this);return n.length&&!n.some(i=>r.includes(i))?!1:!r.every(i=>e.includes(i))};T5=new WeakSet;yz=function(){We(this,or)&&(Rr(this,Fy,tk).call(this),We(this,or).on("accountsChanged",this.onAccountsChanged),We(this,or).on("chainChanged",this.onChainChanged),We(this,or).on("disconnect",this.onDisconnect),We(this,or).on("session_delete",this.onDisconnect),We(this,or).on("display_uri",this.onDisplayUri),We(this,or).on("connect",this.onConnect))};Fy=new WeakSet;tk=function(){We(this,or)&&(We(this,or).removeListener("accountsChanged",this.onAccountsChanged),We(this,or).removeListener("chainChanged",this.onChainChanged),We(this,or).removeListener("disconnect",this.onDisconnect),We(this,or).removeListener("session_delete",this.onDisconnect),We(this,or).removeListener("display_uri",this.onDisplayUri),We(this,or).removeListener("connect",this.onConnect))};Mu=new WeakSet;Eh=function(t){var e;(e=this.storage)==null||e.setItem(vz,t)};By=new WeakSet;rk=function(){var t;return((t=this.storage)==null?void 0:t.getItem(vz))??[]};jy=new WeakSet;nk=function(){var n,i,s;if(!We(this,or))return[];const t=(n=We(this,or).session)==null?void 0:n.namespaces;return t?((s=(i=dz(t)[pz])==null?void 0:i.chains)==null?void 0:s.map(o=>parseInt(o.split(":")[1]||"")))??[]:[]};Uy=new WeakSet;ik=function(){var n,i;if(!We(this,or))return[];const t=(n=We(this,or).session)==null?void 0:n.namespaces;return t?((i=dz(t)[pz])==null?void 0:i.methods)??[]:[]};function ke(){return ke=Object.assign?Object.assign.bind():function(t){for(var e=1;e({account:l[0]}),this.onDisconnect=()=>{this==null||this.emit("disconnect")};const o=(r==null||(n=r.connect)==null||(n=n.settings)==null?void 0:n.signInOptions)||[],a=r==null||(i=r.connect)==null||(i=i.settings)==null?void 0:i.signInWith;if(r==null||(s=r.connect)==null||(s=s.settings)==null?void 0:s.signInWithEmail)this.id="email",this.name="Email";else if(a)this.id=a,this.name=`${a[0].toUpperCase()}${a.slice(1)}`;else if(o.length>0){const l=o[0],u=`${l[0].toUpperCase()}${l.slice(1)}`;this.id=l,this.name=u}this.provider=NU.initWallet({defaultNetwork:r==null?void 0:r.defaultNetwork,transports:{walletAppURL:"https://sequence.app"},defaultEIP6492:!0}),this.provider.on("chainChanged",l=>{this==null||this.emit("change",{chain:{id:I5(l),unsupported:!1}})}),this.provider.on("accountsChanged",l=>{this==null||this.emit("accountsChanged",this.onAccountsChanged(l))}),this.provider.on("disconnect",()=>{this.onDisconnect()})}async connect(){if(!this.provider.isConnected()){var e,r,n;this==null||this.emit("message",{type:"connecting"});const s=(e=this.options)==null?void 0:e.connect,o=localStorage.getItem(gn.Theme),a=localStorage.getItem(gn.EthAuthSettings),c=a?JSON.parse(a):{},l=ke({authorize:!0},c,s,{settings:ke({theme:o||"dark"},s==null?void 0:s.settings)}),u=await this.provider.connect(l);if(u.error)throw new Pr(new Error(u.error));if(!u.connected)throw new Pr(new Error("Wallet connection rejected"));const f=(r=u.proof)==null?void 0:r.proofString,d=(n=u.proof)==null?void 0:n.typedData;if(f){const h=JSON.stringify({proofString:f,typedData:d});localStorage.setItem(gn.EthAuthProof,h)}}return{account:await this.getAccount(),chain:{id:this.provider.getChainId(),unsupported:this.isChainUnsupported(this.provider.getChainId())}}}async getWalletClient({chainId:e}={}){const r=this.chains.find(n=>n.id===e);return K1({chain:r,account:await this.getAccount(),transport:kb(this.provider)})}onChainChanged(e){this.provider.setDefaultChainId(I5(e))}async switchChain(e){if(this.isChainUnsupported(e))throw new Error("Unsupported chain");return this.provider.setDefaultChainId(e),this.chains.find(r=>r.id===e)}async disconnect(){localStorage.removeItem(gn.EthAuthProof),this.provider.disconnect()}getAccount(){return this.provider.getSigner().getAddress()}async getChainId(){return this.provider.getChainId()}async getProvider(){return this.provider}async getSigner(){return this.provider.getSigner()}async isAuthorized(){try{return!!await this.getAccount()}catch{return!1}}isChainUnsupported(e){return this.provider.networks.findIndex(r=>r.chainId===e)===-1}}const I5=t=>typeof t=="object"?I5(t.chainId):typeof t=="string"?Number.parseInt(t,t.trim().substring(0,2)==="0x"?16:10):typeof t=="bigint"?Number(t):t;function Xi(t){if(t==null)throw new TypeError("Cannot destructure "+t)}const S9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 34",fill:"none"},i),x.createElement("path",{d:"M27.702 11.5918C27.5049 11.7448 24.0243 13.7068 24.0243 18.0694C24.0243 23.1155 28.4532 24.9007 28.5858 24.9449C28.5654 25.0537 27.8822 27.3897 26.2506 29.77C24.7958 31.8646 23.2765 33.9558 20.9651 33.9558C18.6538 33.9558 18.0589 32.6127 15.3907 32.6127C12.7904 32.6127 11.8659 34 9.75169 34C7.63748 34 6.1623 32.0618 4.46618 29.6816C2.50154 26.8865 0.914185 22.5443 0.914185 18.423C0.914185 11.8128 5.21057 8.30703 9.43897 8.30703C11.6857 8.30703 13.5586 9.78278 14.9692 9.78278C16.3118 9.78278 18.4056 8.21862 20.9617 8.21862C21.9304 8.21862 25.4111 8.30703 27.702 11.5918ZM19.7483 5.42014C20.8054 4.16542 21.5532 2.42444 21.5532 0.683468C21.5532 0.442044 21.5328 0.19722 21.4886 0C19.7687 0.0646065 17.7224 1.14591 16.4886 2.57746C15.5199 3.67917 14.6157 5.42014 14.6157 7.18492C14.6157 7.45014 14.6599 7.71537 14.6803 7.80038C14.7891 7.82078 14.9658 7.84458 15.1426 7.84458C16.6857 7.84458 18.6266 6.81088 19.7483 5.42014Z",fill:e})))}},k9=({isDarkMode:t})=>{const e=t?"#FFFFFF":"#000000";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{d:"M27.166 20.8774C27.1338 17.335 30.0617 15.633 30.1936 15.5493C28.5463 13.1395 25.9852 12.8113 25.0714 12.7727C22.8932 12.5507 20.8179 14.0565 19.7111 14.0565C18.6043 14.0565 16.8991 12.8049 15.0909 12.8403C12.7131 12.8757 10.5221 14.2205 9.2962 16.3505C6.8284 20.6297 8.66557 26.9777 11.0722 30.4557C12.2498 32.1545 13.6494 34.0689 15.493 33.9981C17.2691 33.9273 17.9383 32.8495 20.0811 32.8495C22.224 32.8495 22.8289 33.9981 24.7014 33.9627C26.6094 33.9241 27.8191 32.2253 28.9871 30.5201C30.3352 28.5478 30.8918 26.6366 30.924 26.5369C30.8822 26.5208 27.2046 25.1116 27.166 20.8774Z",fill:e}),x.createElement("path",{d:"M23.6429 10.4722C24.621 9.28822 25.2806 7.64089 25.1004 6C23.6911 6.05791 21.9859 6.93949 20.9756 8.12351C20.0715 9.16917 19.2768 10.8455 19.4923 12.4542C21.0592 12.5764 22.6648 11.653 23.6429 10.4722Z",fill:e})))}},W2e=({chains:t,options:e={}})=>({id:"apple",isSequenceBased:!0,logoDark:S9({isDarkMode:!0}),logoLight:S9({isDarkMode:!1}),monochromeLogoDark:k9({isDarkMode:!0}),monochromeLogoLight:k9({isDarkMode:!1}),name:"Apple",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"apple"})})})})}}),A9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("rect",{width:"28",height:"28",fill:"#2C5FF6"}),x.createElement("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M14 23.8C19.4124 23.8 23.8 19.4124 23.8 14C23.8 8.58761 19.4124 4.2 14 4.2C8.58761 4.2 4.2 8.58761 4.2 14C4.2 19.4124 8.58761 23.8 14 23.8ZM11.55 10.8C11.1358 10.8 10.8 11.1358 10.8 11.55V16.45C10.8 16.8642 11.1358 17.2 11.55 17.2H16.45C16.8642 17.2 17.2 16.8642 17.2 16.45V11.55C17.2 11.1358 16.8642 10.8 16.45 10.8H11.55Z",fill:"white"})))},H2e=t=>({id:"coinbase-wallet",logoDark:A9,logoLight:A9,name:"Coinbase Wallet",createConnector:()=>new nge(ke({},t))}),_9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 35 34",fill:"none"},i),x.createElement("path",{d:"M17.0826 16.3805C17.1802 16.4598 17.32 16.4598 17.4176 16.3805L30.1401 6.04341C30.5283 5.72801 30.3053 5.09985 29.8051 5.09985H4.69499C4.19482 5.09985 3.9718 5.72801 4.35998 6.04341L17.0826 16.3805Z",fill:e}),x.createElement("path",{d:"M19.7626 19.2667L33.3838 8.19943C33.731 7.91735 34.2501 8.16441 34.2501 8.61174V24.2249C34.2501 26.5721 32.3473 28.4749 30.0001 28.4749H4.50006C2.15285 28.4749 0.250061 26.5721 0.250061 24.2249V8.61174C0.250061 8.16441 0.769134 7.91735 1.11631 8.19943L14.7375 19.2667C16.2014 20.4561 18.2987 20.4561 19.7626 19.2667Z",fill:e})))}},O5="@sequence.kit.connector.email",q2e=({chains:t,options:e={}})=>({id:"email",isSequenceBased:!0,logoDark:_9({isDarkMode:!0}),logoLight:_9({isDarkMode:!1}),name:"Email",createConnector:()=>{var r;const n=localStorage.getItem(O5);return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInOptions:["email"],signInWithEmail:n||""})})})})}}),P9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},e),x.createElement("path",{d:"M17.4214 36.9716C9.27855 35.5145 3.10712 28.4859 3.10712 20.0001C3.10712 10.5715 10.8214 2.85718 20.25 2.85718C29.6785 2.85718 37.3928 10.5715 37.3928 20.0001C37.3928 28.4859 31.2214 35.5145 23.0785 36.9716L22.1357 36.2002H18.3643L17.4214 36.9716Z",fill:"url(#paint0_linear_193_14528)"}),x.createElement("path",{d:"M26.9357 24.7999L27.7072 19.9999H23.1643V16.657C23.1643 15.2856 23.6786 14.257 25.7357 14.257H27.9643V9.88558C26.7643 9.71415 25.3929 9.54272 24.1929 9.54272C20.25 9.54272 17.5071 11.9427 17.5071 16.2285V19.9999H13.2214V24.7999H17.5071V36.8857C18.45 37.0571 19.3929 37.1429 20.3357 37.1429C21.2786 37.1429 22.2214 37.0571 23.1643 36.8857V24.7999H26.9357Z",fill:"white"}),x.createElement("defs",null,x.createElement("linearGradient",{id:"paint0_linear_193_14528",x1:"20.2508",y1:"35.9507",x2:"20.2508",y2:"2.85086",gradientUnits:"userSpaceOnUse"},x.createElement("stop",{"stop-color":"#0062E0"}),x.createElement("stop",{offset:"1","stop-color":"#19AFFF"})))))},T9=({isDarkMode:t})=>{const e=t?"#FFFFFF":"#000000";return n=>{let i=ke({},(Xi(n),n));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{d:"M25.8582 10.4398C24.1222 10.4398 23.6288 11.2098 23.6288 12.9073V15.709H28.246L27.791 20.2476H23.6279V34H18.1024V20.2468H14.375V15.7081H18.1042V12.9851C18.1042 8.40625 19.9399 6 25.0891 6C26.1942 6 27.5163 6.0875 28.3055 6.19775V10.459",fill:e})))}},V2e=({chains:t,options:e={}})=>({id:"facebook",isSequenceBased:!0,logoDark:P9,logoLight:P9,monochromeLogoDark:T9({isDarkMode:!0}),monochromeLogoLight:T9({isDarkMode:!1}),name:"Facebook",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"facebook"})})})})}}),I9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({viewBox:"0 0 41 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("g",{id:"Frame 2114"},x.createElement("g",{id:"Group"},x.createElement("path",{id:"Vector",d:"M20.7497 16.8828V23.5218H29.9756C29.5705 25.6568 28.3548 27.4647 26.5314 28.6803L32.095 32.9972C35.3366 30.0051 37.2068 25.6102 37.2068 20.3895C37.2068 19.1739 37.0977 18.005 36.895 16.883L20.7497 16.8828Z",fill:"#4285F4"}),x.createElement("path",{id:"Vector_2",d:"M11.1424 23.2627L9.88756 24.2232L5.44592 27.6829C8.2667 33.2777 14.0481 37.1427 20.7493 37.1427C25.3778 37.1427 29.2583 35.6154 32.0947 32.9973L26.5311 28.6803C25.0038 29.7089 23.0557 30.3324 20.7493 30.3324C16.2922 30.3324 12.5053 27.3246 11.1494 23.2726L11.1424 23.2627Z",fill:"#34A853"}),x.createElement("path",{id:"Vector_3",d:"M5.44594 12.3169C4.27718 14.6233 3.60712 17.2259 3.60712 19.9999C3.60712 22.7739 4.27718 25.3765 5.44594 27.6829C5.44594 27.6984 11.1499 23.2569 11.1499 23.2569C10.8071 22.2284 10.6044 21.1375 10.6044 19.9997C10.6044 18.8619 10.8071 17.7711 11.1499 16.7425L5.44594 12.3169Z",fill:"#FBBC05"}),x.createElement("path",{id:"Vector_4",d:"M20.7497 9.6829C23.2744 9.6829 25.5185 10.5556 27.3107 12.2387L32.2198 7.32972C29.2431 4.55574 25.3783 2.85693 20.7497 2.85693C14.0484 2.85693 8.2667 6.70628 5.44592 12.3167L11.1497 16.7427C12.5055 12.6907 16.2926 9.6829 20.7497 9.6829Z",fill:"#EA4335"})))))},O9=({isDarkMode:t})=>{const e=t?"white":"black";return n=>{let i=ke({},(Xi(n),n));return x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 40",fill:"none"},i),x.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M25.8355 14.7613C24.5584 13.5329 22.9441 12.9032 21.1356 12.9032C17.9377 12.9032 15.2302 15.0813 14.2595 18.0232L14.2593 18.023C14.0142 18.7662 13.8712 19.5609 13.8712 20.3866C13.8712 21.2124 14.004 22.0072 14.2594 22.7504L14.2587 22.751H14.2595C15.2302 25.6929 17.9377 27.871 21.1356 27.871C22.7907 27.871 24.1904 27.4168 25.2939 26.6736V26.6732C26.5812 25.7958 27.4497 24.5055 27.746 22.9777H21.1355V18.3223H32.6808C32.8034 19.0758 32.875 19.85 32.875 20.6655C32.875 24.4332 31.5467 27.6126 29.2377 29.77L29.2378 29.7703C27.2148 31.6594 24.446 32.7742 21.1356 32.7742C16.3438 32.7742 12.2059 29.9871 10.1931 25.9407V25.94L10.193 25.9401C9.35521 24.2678 8.875 22.3891 8.875 20.3866C8.875 18.384 9.35521 16.5053 10.193 14.833H10.1934C12.2063 10.7869 16.344 8 21.1356 8C24.446 8 27.2148 9.22839 29.3298 11.231L25.8355 14.7613Z",fill:e}))}},G2e=({chains:t,options:e={}})=>({id:"google",isSequenceBased:!0,logoDark:I9,logoLight:I9,monochromeLogoDark:O9({isDarkMode:!0}),monochromeLogoLight:O9({isDarkMode:!1}),name:"Google",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"google"})})})})}}),R9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("rect",{width:"28",height:"28"}),x.createElement("path",{d:"M24.0891 3.1199L15.3446 9.61456L16.9617 5.7828L24.0891 3.1199Z",fill:"#E2761B",stroke:"#E2761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M3.90207 3.1199L12.5763 9.67608L11.0383 5.7828L3.90207 3.1199Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M20.9429 18.1745L18.6139 21.7426L23.597 23.1136L25.0295 18.2536L20.9429 18.1745Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M2.97929 18.2536L4.40301 23.1136L9.38607 21.7426L7.05713 18.1745L2.97929 18.2536Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.10483 12.1456L7.71626 14.2461L12.6642 14.4658L12.4884 9.14877L9.10483 12.1456Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.8864 12.1456L15.4589 9.08725L15.3446 14.4658L20.2837 14.2461L18.8864 12.1456Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L12.3566 20.2925L9.79033 18.2888L9.38606 21.7426Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.6347 20.2925L18.6139 21.7426L18.2009 18.2888L15.6347 20.2925Z",fill:"#E4761B",stroke:"#E4761B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.6139 21.7426L15.6347 20.2925L15.8719 22.2348L15.8456 23.0521L18.6139 21.7426Z",fill:"#D7C1B3",stroke:"#D7C1B3",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L12.1544 23.0521L12.1368 22.2348L12.3566 20.2925L9.38606 21.7426Z",fill:"#D7C1B3",stroke:"#D7C1B3",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M12.1984 17.0056L9.72002 16.2762L11.4689 15.4765L12.1984 17.0056Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.7928 17.0056L16.5223 15.4765L18.28 16.2762L15.7928 17.0056Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.38606 21.7426L9.80791 18.1745L7.05712 18.2536L9.38606 21.7426Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.1921 18.1745L18.6139 21.7426L20.9429 18.2536L18.1921 18.1745Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M20.2837 14.2461L15.3446 14.4658L15.8016 17.0057L16.5311 15.4765L18.2888 16.2762L20.2837 14.2461Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.72002 16.2762L11.4777 15.4765L12.1984 17.0057L12.6642 14.4658L7.71626 14.2461L9.72002 16.2762Z",fill:"#CD6116",stroke:"#CD6116",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M7.71626 14.2461L9.79033 18.2888L9.72002 16.2762L7.71626 14.2461Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M18.2888 16.2762L18.2009 18.2888L20.2837 14.2461L18.2888 16.2762Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M12.6642 14.4658L12.1984 17.0057L12.7784 20.0025L12.9102 16.0565L12.6642 14.4658Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.3446 14.4658L15.1073 16.0477L15.2128 20.0025L15.8016 17.0057L15.3446 14.4658Z",fill:"#E4751F",stroke:"#E4751F",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.8016 17.0056L15.2128 20.0025L15.6347 20.2925L18.2009 18.2888L18.2888 16.2762L15.8016 17.0056Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.72002 16.2762L9.79033 18.2888L12.3566 20.2925L12.7784 20.0025L12.1984 17.0056L9.72002 16.2762Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.8456 23.0521L15.8719 22.2348L15.6522 22.0414H12.339L12.1368 22.2348L12.1544 23.0521L9.38606 21.7426L10.3528 22.5336L12.3126 23.8958H15.6786L17.6472 22.5336L18.6139 21.7426L15.8456 23.0521Z",fill:"#C0AD9E",stroke:"#C0AD9E",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.6347 20.2925L15.2128 20.0025H12.7784L12.3566 20.2925L12.1368 22.2348L12.339 22.0414H15.6522L15.8719 22.2348L15.6347 20.2925Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M24.4583 10.0364L25.2053 6.45072L24.0891 3.1199L15.6347 9.39485L18.8864 12.1456L23.4827 13.4903L24.5022 12.3038L24.0628 11.9874L24.7658 11.3459L24.221 10.924L24.924 10.3879L24.4583 10.0364Z",fill:"#763D16",stroke:"#763D16",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M2.79472 6.45072L3.54174 10.0364L3.06717 10.3879L3.77024 10.924L3.23415 11.3459L3.93722 11.9874L3.4978 12.3038L4.50847 13.4903L9.10483 12.1456L12.3566 9.39485L3.90207 3.1199L2.79472 6.45072Z",fill:"#763D16",stroke:"#763D16",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M23.4827 13.4903L18.8864 12.1456L20.2837 14.2461L18.2009 18.2888L20.9429 18.2536H25.0295L23.4827 13.4903Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M9.10484 12.1456L4.50848 13.4903L2.97929 18.2536H7.05713L9.79033 18.2888L7.71626 14.2461L9.10484 12.1456Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M15.3446 14.4658L15.6347 9.39485L16.9705 5.7828H11.0383L12.3566 9.39485L12.6642 14.4658L12.7696 16.0653L12.7784 20.0025H15.2128L15.2304 16.0653L15.3446 14.4658Z",fill:"#F6851B",stroke:"#F6851B",strokeWidth:"0.0878845",strokeLinecap:"round",strokeLinejoin:"round"})))},zy=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({xmlns:"http://www.w3.org/2000/svg",style:{fill:"none"},id:"svg1316",version:"1.1",viewBox:"0 0 396 396"},e),x.createElement("g",{transform:"translate(0,38)",id:"g1256",clipPath:"url(#clip0_5_131)"},x.createElement("g",{id:"g1254",clipPath:"url(#clip1_5_131)"},x.createElement("path",{style:{fill:"#111111"},id:"path1232",d:"M 0,67.5049 V 250.165 c 0,37.282 30.1402,67.505 67.32,67.505 h 261.36 c 37.18,0 67.32,-30.223 67.32,-67.505 V 67.5049 C 396,30.223 365.86,0 328.68,0 H 67.32 C 30.1402,0 0,30.223 0,67.5049 Z"}),x.createElement("path",{style:{fill:"url(#paint0_linear_5_13"},id:"path1234",d:"M 0,67.5049 V 250.165 c 0,37.282 30.1402,67.505 67.32,67.505 h 261.36 c 37.18,0 67.32,-30.223 67.32,-67.505 V 67.5049 C 396,30.223 365.86,0 328.68,0 H 67.32 C 30.1402,0 0,30.223 0,67.5049 Z"}),x.createElement("path",{style:{fill:"url(#paint1_linear_5_131"},id:"path1236",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint2_linear_5_131)"},id:"path1238",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint3_linear_5_131)"},id:"path1240",d:"m 98.9999,79.4176 c 0,-10.9653 -8.8648,-19.8544 -19.8,-19.8544 -10.9352,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.8648,19.8544 19.8,19.8544 10.9352,0 19.8,-8.8892 19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint4_linear_5_131)"},id:"path1242",d:"m 98.9999,238.126 c 0,-10.965 -8.8648,-19.854 -19.8,-19.854 -10.9352,0 -19.8,8.889 -19.8,19.854 0,10.966 8.8648,19.855 19.8,19.855 10.9352,0 19.8,-8.889 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint5_linear_5_131)"},id:"path1244",d:"m 336.6,158.835 c 0,-10.965 -8.865,-19.854 -19.8,-19.854 -10.935,0 -19.8,8.889 -19.8,19.854 0,10.965 8.865,19.855 19.8,19.855 10.935,0 19.8,-8.89 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint6_linear_5_131)"},id:"path1246",d:"m 336.6,158.835 c 0,-10.965 -8.865,-19.854 -19.8,-19.854 -10.935,0 -19.8,8.889 -19.8,19.854 0,10.965 8.865,19.855 19.8,19.855 10.935,0 19.8,-8.89 19.8,-19.855 z"}),x.createElement("path",{style:{fill:"url(#paint7_linear_5_131)"},id:"path1248",d:"M 316.8,59.5632 H 158.4 c -10.935,0 -19.8,8.8891 -19.8,19.8544 0,10.9652 8.865,19.8544 19.8,19.8544 h 158.4 c 10.935,0 19.8,-8.8892 19.8,-19.8544 0,-10.9653 -8.865,-19.8544 -19.8,-19.8544 z"}),x.createElement("path",{style:{fill:"url(#paint8_linear_5_131)"},id:"path1250",d:"M 316.8,218.272 H 158.4 c -10.935,0 -19.8,8.889 -19.8,19.854 0,10.966 8.865,19.855 19.8,19.855 h 158.4 c 10.935,0 19.8,-8.889 19.8,-19.855 0,-10.965 -8.865,-19.854 -19.8,-19.854 z"}),x.createElement("path",{style:{fill:"url(#paint9_linear_5_131)"},id:"path1252",d:"M 237.6,138.981 H 79.2 c -10.9352,0 -19.8,8.889 -19.8,19.854 0,10.965 8.8648,19.855 19.8,19.855 h 158.4 c 10.935,0 19.8,-8.89 19.8,-19.855 0,-10.965 -8.865,-19.854 -19.8,-19.854 z"}))),x.createElement("defs",{id:"defs1314"},x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"318",x2:"198",y1:"4.0585401e-05",x1:"198",id:"paint0_linear_5_131"},x.createElement("stop",{id:"stop1258",stopColor:"#1D273D"}),x.createElement("stop",{id:"stop1260",stopColor:"#0D0F13",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"63",x2:"92.5",y1:"99",x1:"65.5",id:"paint1_linear_5_131"},x.createElement("stop",{id:"stop1263",stopColor:"#4462FE"}),x.createElement("stop",{id:"stop1265",stopColor:"#7D69FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"97.591103",x2:"96.137703",y1:"99.291199",x1:"62.879902",id:"paint2_linear_5_131"},x.createElement("stop",{id:"stop1268",stopColor:"#3757FD"}),x.createElement("stop",{id:"stop1270",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"97.591103",x2:"96.137703",y1:"99.291199",x1:"62.879902",id:"paint3_linear_5_131"},x.createElement("stop",{id:"stop1273",stopColor:"#2447FF"}),x.createElement("stop",{id:"stop1275",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"223.5",x2:"91.5",y1:"251.5",x1:"65",id:"paint4_linear_5_131"},x.createElement("stop",{id:"stop1278",stopColor:"#BC3EE6"}),x.createElement("stop",{id:"stop1280",stopColor:"#D972F1",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"146",x2:"329.5",y1:"172",x1:"305",id:"paint5_linear_5_131"},x.createElement("stop",{id:"stop1283",stopColor:"#29BDFF"}),x.createElement("stop",{id:"stop1285",stopColor:"#96E7FB",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"176.772",x2:"334.56699",y1:"178.418",x1:"300.17999",id:"paint6_linear_5_131"},x.createElement("stop",{id:"stop1288",stopColor:"#23BBFF"}),x.createElement("stop",{id:"stop1290",stopColor:"#85E7FF",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"60",x2:"317.5",y1:"99",x1:"154.5",id:"paint7_linear_5_131"},x.createElement("stop",{id:"stop1293",stopColor:"#23BBFF"}),x.createElement("stop",{id:"stop1295",stopColor:"#85E7FF",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"218",x2:"312.5",y1:"258",x1:"156",id:"paint8_linear_5_131"},x.createElement("stop",{id:"stop1298",stopColor:"#2447FF"}),x.createElement("stop",{id:"stop1300",stopColor:"#6980FA",offset:"1"})),x.createElement("linearGradient",{gradientUnits:"userSpaceOnUse",y2:"139",x2:"235.5",y1:"179",x1:"86.000099",id:"paint9_linear_5_131"},x.createElement("stop",{id:"stop1303",stopColor:"#6634FF"}),x.createElement("stop",{id:"stop1305",stopColor:"#9C6DFF",offset:"1"})),x.createElement("clipPath",{id:"clip0_5_131"},x.createElement("rect",{style:{fill:"#ffffff"},y:"0",x:"0",id:"rect1308",height:"317.67001",width:"396"})),x.createElement("clipPath",{id:"clip1_5_131"},x.createElement("rect",{style:{fill:"#ffffff"},y:"0",x:"0",id:"rect1311",height:"317.67001",width:"396"})))))};window.ethereum=window.ethereum||{};const K2e=({chains:t})=>({id:"metamask",logoDark:R9,logoLight:R9,name:"Metamask",createConnector:()=>new ige({chains:t,options:{shimDisconnect:!0}})}),Q2e=({chains:t,options:e})=>({id:"mock",isSequenceBased:!0,logoDark:zy,logoLight:zy,name:"Mock",createConnector:()=>{var r;return new oge({chains:t,options:ke({chainId:(e==null||(r=e.chain)==null?void 0:r.id)||137,walletClient:K1({account:e.account,chain:(e==null?void 0:e.chain)||vfe,transport:e.transport})},e)})}}),Y2e=({chains:t,options:e})=>({id:"sequence",isSequenceBased:!0,logoDark:zy,logoLight:zy,name:"Sequence",createConnector:()=>new Od({chains:t,options:e})}),iv=({isDarkMode:t})=>{let e;return t===void 0?e="#9146FF":e=t?"white":"black",n=>(ke({},(Xi(n),n)),x.createElement(x.Fragment,null,x.createElement("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 2400 2800",transform:"scale(0.80)"},x.createElement("g",null,x.createElement("g",{id:"Layer_1-2"},x.createElement("path",{fill:e,d:"M500,0L0,500v1800h600v500l500-500h400l900-900V0H500z M2200,1300l-400,400h-400l-350,350v-350H600V200h1600 V1300z"}),x.createElement("rect",{x:"1700",y:"550",fill:e,width:"200",height:"600"}),x.createElement("rect",{x:"1150",y:"550",fill:e,width:"200",height:"600"}))))))},J2e=({chains:t,options:e={}})=>({id:"twitch",isSequenceBased:!0,logoDark:iv({}),logoLight:iv({}),monochromeLogoDark:iv({isDarkMode:!0}),monochromeLogoLight:iv({isDarkMode:!1}),name:"Twitch",createConnector:()=>{var r;return new Od({chains:t,options:ke({},e,{connect:ke({},e==null?void 0:e.connect,{settings:ke({},e==null||(r=e.connect)==null?void 0:r.settings,{signInWith:"twitch"})})})})}}),$9=t=>{let e=ke({},(Xi(t),t));return x.createElement(x.Fragment,null,x.createElement("svg",ke({fill:"none",viewBox:"0 0 480 332",xmlns:"http://www.w3.org/2000/svg"},e),x.createElement("path",{d:"m126.613 93.9842c62.622-61.3123 164.152-61.3123 226.775 0l7.536 7.3788c3.131 3.066 3.131 8.036 0 11.102l-25.781 25.242c-1.566 1.533-4.104 1.533-5.67 0l-10.371-10.154c-43.687-42.7734-114.517-42.7734-158.204 0l-11.107 10.874c-1.565 1.533-4.103 1.533-5.669 0l-25.781-25.242c-3.132-3.066-3.132-8.036 0-11.102zm280.093 52.2038 22.946 22.465c3.131 3.066 3.131 8.036 0 11.102l-103.463 101.301c-3.131 3.065-8.208 3.065-11.339 0l-73.432-71.896c-.783-.767-2.052-.767-2.835 0l-73.43 71.896c-3.131 3.065-8.208 3.065-11.339 0l-103.4657-101.302c-3.1311-3.066-3.1311-8.036 0-11.102l22.9456-22.466c3.1311-3.065 8.2077-3.065 11.3388 0l73.4333 71.897c.782.767 2.051.767 2.834 0l73.429-71.897c3.131-3.065 8.208-3.065 11.339 0l73.433 71.897c.783.767 2.052.767 2.835 0l73.431-71.895c3.132-3.066 8.208-3.066 11.339 0z",fill:"#3396ff"})))},X2e=({chains:t,options:e})=>({id:"wallet-connect",logoDark:$9,logoLight:$9,name:"Walletconnect",createConnector:()=>new z2e({chains:t,options:e})}),Z2e=({chains:t,walletConnectProjectId:e,defaultChainId:r})=>{let n=t[0].id;if(r){const s=t.find(o=>o.id===r);s&&(n=s.id)}return Dz([H2e({chains:t,options:{appName:"app"}}),q2e({chains:t,options:{defaultNetwork:n}}),G2e({chains:t,options:{defaultNetwork:n}}),V2e({chains:t,options:{defaultNetwork:n}}),J2e({chains:t,options:{defaultNetwork:n}}),W2e({chains:t,options:{defaultNetwork:n}}),K2e({chains:t}),X2e({chains:t,options:{projectId:e}}),Y2e({chains:t,options:{defaultNetwork:n}})])};function sk(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function sv(){}function M9(){return typeof WeakMap<"u"?new WeakMap:eEe()}function eEe(){return{add:sv,delete:sv,get:sv,set:sv,has:function(t){return!1}}}var tEe=Object.prototype.hasOwnProperty,R5=function(t,e){return tEe.call(t,e)};function cE(t,e){for(var r in e)R5(e,r)&&(t[r]=e[r]);return t}var rEe=/^[ \t]*(?:\r\n|\r|\n)/,nEe=/(?:\r\n|\r|\n)[ \t]*$/,iEe=/^(?:[\r\n]|$)/,sEe=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,oEe=/^[ \t]*[\r\n][ \t\r\n]*$/;function N9(t,e,r){var n=0,i=t[0].match(sEe);i&&(n=i[1].length);var s="(\\r\\n|\\r|\\n).{0,"+n+"}",o=new RegExp(s,"g");e&&(t=t.slice(1));var a=r.newline,c=r.trimLeadingNewline,l=r.trimTrailingNewline,u=typeof a=="string",f=t.length,d=t.map(function(h,p){return h=h.replace(o,"$1"),p===0&&c&&(h=h.replace(rEe,"")),p===f-1&&l&&(h=h.replace(nEe,"")),u&&(h=h.replace(/\r\n|\n|\r/g,function(v){return a})),h});return d}function aEe(t,e){for(var r="",n=0,i=t.length;n{},registerClassName:()=>{},onEndFileScope:()=>{},registerComposition:()=>{},markCompositionUsed:()=>{},getIdentOption:()=>"short"},em=[lEe],au=()=>{if(em.length<1)throw new Error("No adapter configured");return em[em.length-1]},bz=!1,uEe=t=>{bz||fEe(t)},fEe=t=>{if(!t)throw new Error('No adapter provided when calling "setAdapter"');bz=!0,em.push(t)},Zb=function(){return au().appendCss(...arguments)},wz=function(){return au().registerClassName(...arguments)},dEe=function(){return au().registerComposition(...arguments)},Ez=function(){return au().markCompositionUsed(...arguments)},hEe=function(){for(var e,r,n=arguments.length,i=new Array(n),s=0;sMath.min(Math.max(r,e),t),H={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},he=e=>typeof e=="number",Et=e=>Array.isArray(e)&&!he(e[0]),jo=(e,t,r)=>{const n=t-e;return((r-e)%n+n)%n+e};function Wo(e,t){return Et(e)?e[jo(0,e.length,t)]:e}const no=(e,t,r)=>-r*e+r*t+e,io=()=>{},it=e=>e,pr=(e,t,r)=>t-e===0?1:(r-e)/(t-e);function so(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const o=pr(0,t,n);e.push(no(r,1,o))}}function Ho(e){const t=[0];return so(t,e-1),t}function zo(e,t=Ho(e.length),r=it){const n=e.length,o=n-t.length;return o>0&&so(t,o),i=>{let s=0;for(;sArray.isArray(e)&&he(e[0]),sr=e=>typeof e=="object"&&!!e.createAnimation,Ot=e=>typeof e=="function",Fo=e=>typeof e=="string",zt={ms:e=>e*1e3,s:e=>e/1e3},lo=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,Zo=1e-7,Vo=12;function Ko(e,t,r,n,o){let i,s,a=0;do s=t+(r-t)/2,i=lo(s,n,o)-e,i>0?r=s:t=s;while(Math.abs(i)>Zo&&++aKo(i,0,1,e,r);return i=>i===0||i===1?i:lo(o(i),t,n)}const qo=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);const n=r*e,o=t==="end"?Math.floor(n):Math.ceil(n);return oo(0,1,o/e)},Ar={ease:Ht(.25,.1,.25,1),"ease-in":Ht(.42,0,1,1),"ease-in-out":Ht(.42,0,.58,1),"ease-out":Ht(0,0,.58,1)},Yo=/\((.*?)\)/;function _r(e){if(Ot(e))return e;if(ao(e))return Ht(...e);if(Ar[e])return Ar[e];if(e.startsWith("steps")){const t=Yo.exec(e);if(t){const r=t[1].split(",");return qo(parseFloat(r[0]),r[1].trim())}}return it}class co{constructor(t,r=[0,1],{easing:n,duration:o=H.duration,delay:i=H.delay,endDelay:s=H.endDelay,repeat:a=H.repeat,offset:l,direction:c="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=it,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((b,h)=>{this.resolve=b,this.reject=h}),n=n||H.easing,sr(n)){const b=n.createAnimation(r);n=b.easing,r=b.keyframes||r,o=b.duration||o}this.repeat=a,this.easing=Et(n)?it:_r(n),this.updateDuration(o);const d=zo(r,l,Et(n)?n.map(_r):it);this.tick=b=>{var h;i=i;let u=0;this.pauseTime!==void 0?u=this.pauseTime:u=(b-this.startTime)*this.rate,this.t=u,u/=1e3,u=Math.max(u-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(u=this.totalDuration);const p=u/this.duration;let g=Math.floor(p),$=p%1;!$&&p>=1&&($=1),$===1&&g--;const f=g%2;(c==="reverse"||c==="alternate"&&f||c==="alternate-reverse"&&!f)&&($=1-$);const y=u>=this.totalDuration?1:Math.min($,1),v=d(this.easing(y));t(v),this.pauseTime===void 0&&(this.playState==="finished"||u>=this.totalDuration+s)?(this.playState="finished",(h=this.resolve)===null||h===void 0||h.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}class Go{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}const Ce=new WeakMap;function ho(e){return Ce.has(e)||Ce.set(e,{transforms:[],values:new Map}),Ce.get(e)}function Qo(e,t){return e.has(t)||e.set(t,new Go),e.get(t)}const Jo=["","X","Y","Z"],Xo=["translate","scale","rotate","skew"],ue={x:"translateX",y:"translateY",z:"translateZ"},Or={syntax:"",initialValue:"0deg",toDefaultUnit:e=>e+"deg"},tn={translate:{syntax:"",initialValue:"0px",toDefaultUnit:e=>e+"px"},rotate:Or,scale:{syntax:"",initialValue:1,toDefaultUnit:it},skew:Or},Zt=new Map,wr=e=>`--motion-${e}`,me=["x","y","z"];Xo.forEach(e=>{Jo.forEach(t=>{me.push(e+t),Zt.set(wr(e+t),tn[e])})});const en=(e,t)=>me.indexOf(e)-me.indexOf(t),rn=new Set(me),uo=e=>rn.has(e),on=(e,t)=>{ue[t]&&(t=ue[t]);const{transforms:r}=ho(e);Uo(r,t),e.style.transform=nn(r)},nn=e=>e.sort(en).reduce(sn,"").trim(),sn=(e,t)=>`${e} ${t}(var(${wr(t)}))`,ar=e=>e.startsWith("--"),kr=new Set;function an(e){if(!kr.has(e)){kr.add(e);try{const{syntax:t,initialValue:r}=Zt.has(e)?Zt.get(e):{};CSS.registerProperty({name:e,inherits:!1,syntax:t,initialValue:r})}catch{}}}const Ee=(e,t)=>document.createElement("div").animate(e,t),Ir={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{Ee({opacity:[1]})}catch{return!1}return!0},finished:()=>!!Ee({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{Ee({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},Ae={},Ct={};for(const e in Ir)Ct[e]=()=>(Ae[e]===void 0&&(Ae[e]=Ir[e]()),Ae[e]);const ln=.015,cn=(e,t)=>{let r="";const n=Math.round(t/ln);for(let o=0;oOt(e)?Ct.linearEasing()?`linear(${cn(e,t)})`:H.easing:ao(e)?dn(e):e,dn=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`;function hn(e,t){for(let r=0;rArray.isArray(e)?e:[e];function lr(e){return ue[e]&&(e=ue[e]),uo(e)?wr(e):e}const Xt={get:(e,t)=>{t=lr(t);let r=ar(t)?e.style.getPropertyValue(t):getComputedStyle(e)[t];if(!r&&r!==0){const n=Zt.get(t);n&&(r=n.initialValue)}return r},set:(e,t,r)=>{t=lr(t),ar(t)?e.style.setProperty(t,r):e.style[t]=r}};function mo(e,t=!0){if(!(!e||e.playState==="finished"))try{e.stop?e.stop():(t&&e.commitStyles(),e.cancel())}catch{}}function mn(e,t){var r;let n=(t==null?void 0:t.toDefaultUnit)||it;const o=e[e.length-1];if(Fo(o)){const i=((r=o.match(/(-?[\d.]+)([a-z%]*)/))===null||r===void 0?void 0:r[2])||"";i&&(n=s=>s+i)}return n}function gn(){return window.__MOTION_DEV_TOOLS_RECORD}function fn(e,t,r,n={},o){const i=gn(),s=n.record!==!1&&i;let a,{duration:l=H.duration,delay:c=H.delay,endDelay:d=H.endDelay,repeat:b=H.repeat,easing:h=H.easing,persist:u=!1,direction:p,offset:g,allowWebkitAcceleration:$=!1}=n;const f=ho(e),y=uo(t);let v=Ct.waapi();y&&on(e,t);const w=lr(t),k=Qo(f.values,w),I=Zt.get(w);return mo(k.animation,!(sr(h)&&k.generator)&&n.record!==!1),()=>{const R=()=>{var P,F;return(F=(P=Xt.get(e,w))!==null&&P!==void 0?P:I==null?void 0:I.initialValue)!==null&&F!==void 0?F:0};let T=hn(un(r),R);const z=mn(T,I);if(sr(h)){const P=h.createAnimation(T,t!=="opacity",R,w,k);h=P.easing,T=P.keyframes||T,l=P.duration||l}if(ar(w)&&(Ct.cssRegisterProperty()?an(w):v=!1),y&&!Ct.linearEasing()&&(Ot(h)||Et(h)&&h.some(Ot))&&(v=!1),v){I&&(T=T.map(Z=>he(Z)?I.toDefaultUnit(Z):Z)),T.length===1&&(!Ct.partialKeyframes()||s)&&T.unshift(R());const P={delay:zt.ms(c),duration:zt.ms(l),endDelay:zt.ms(d),easing:Et(h)?void 0:Tr(h,l),direction:p,iterations:b+1,fill:"both"};a=e.animate({[w]:T,offset:g,easing:Et(h)?h.map(Z=>Tr(Z,l)):void 0},P),a.finished||(a.finished=new Promise((Z,V)=>{a.onfinish=Z,a.oncancel=V}));const F=T[T.length-1];a.finished.then(()=>{u||(Xt.set(e,w,F),a.cancel())}).catch(io),$||(a.playbackRate=1.000001)}else if(o&&y)T=T.map(P=>typeof P=="string"?parseFloat(P):P),T.length===1&&T.unshift(parseFloat(R())),a=new o(P=>{Xt.set(e,w,z?z(P):P)},T,Object.assign(Object.assign({},n),{duration:l,easing:h}));else{const P=T[T.length-1];Xt.set(e,w,I&&he(P)?I.toDefaultUnit(P):P)}return s&&i(e,t,T,{duration:l,delay:c,easing:h,repeat:b,offset:g},"motion-one"),k.setAnimation(a),a}}const pn=(e,t)=>e[t]?Object.assign(Object.assign({},e),e[t]):Object.assign({},e);function wn(e,t){var r;return typeof e=="string"?t?((r=t[e])!==null&&r!==void 0||(t[e]=document.querySelectorAll(e)),e=t[e]):e=document.querySelectorAll(e):e instanceof Element&&(e=[e]),Array.from(e||[])}const vn=e=>e(),go=(e,t,r=H.duration)=>new Proxy({animations:e.map(vn).filter(Boolean),duration:r,options:t},yn),bn=e=>e.animations[0],yn={get:(e,t)=>{const r=bn(e);switch(t){case"duration":return e.duration;case"currentTime":return zt.s((r==null?void 0:r[t])||0);case"playbackRate":case"playState":return r==null?void 0:r[t];case"finished":return e.finished||(e.finished=Promise.all(e.animations.map(xn)).catch(io)),e.finished;case"stop":return()=>{e.animations.forEach(n=>mo(n))};case"forEachNative":return n=>{e.animations.forEach(o=>n(o,e))};default:return typeof(r==null?void 0:r[t])>"u"?void 0:()=>e.animations.forEach(n=>n[t]())}},set:(e,t,r)=>{switch(t){case"currentTime":r=zt.ms(r);case"playbackRate":for(let n=0;ne.finished;function $n(e,t,r){return Ot(e)?e(t,r):e}function Cn(e){return function(r,n,o={}){r=wn(r);const i=r.length,s=[];for(let a=0;aMath.min(Math.max(r,e),t),H={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},he=e=>typeof e=="number",Et=e=>Array.isArray(e)&&!he(e[0]),jo=(e,t,r)=>{const n=t-e;return((r-e)%n+n)%n+e};function Wo(e,t){return Et(e)?e[jo(0,e.length,t)]:e}const no=(e,t,r)=>-r*e+r*t+e,io=()=>{},it=e=>e,pr=(e,t,r)=>t-e===0?1:(r-e)/(t-e);function so(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const o=pr(0,t,n);e.push(no(r,1,o))}}function Ho(e){const t=[0];return so(t,e-1),t}function zo(e,t=Ho(e.length),r=it){const n=e.length,o=n-t.length;return o>0&&so(t,o),i=>{let s=0;for(;sArray.isArray(e)&&he(e[0]),sr=e=>typeof e=="object"&&!!e.createAnimation,Ot=e=>typeof e=="function",Fo=e=>typeof e=="string",zt={ms:e=>e*1e3,s:e=>e/1e3},lo=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,Zo=1e-7,Vo=12;function Ko(e,t,r,n,o){let i,s,a=0;do s=t+(r-t)/2,i=lo(s,n,o)-e,i>0?r=s:t=s;while(Math.abs(i)>Zo&&++aKo(i,0,1,e,r);return i=>i===0||i===1?i:lo(o(i),t,n)}const qo=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);const n=r*e,o=t==="end"?Math.floor(n):Math.ceil(n);return oo(0,1,o/e)},Ar={ease:Ht(.25,.1,.25,1),"ease-in":Ht(.42,0,1,1),"ease-in-out":Ht(.42,0,.58,1),"ease-out":Ht(0,0,.58,1)},Yo=/\((.*?)\)/;function _r(e){if(Ot(e))return e;if(ao(e))return Ht(...e);if(Ar[e])return Ar[e];if(e.startsWith("steps")){const t=Yo.exec(e);if(t){const r=t[1].split(",");return qo(parseFloat(r[0]),r[1].trim())}}return it}class co{constructor(t,r=[0,1],{easing:n,duration:o=H.duration,delay:i=H.delay,endDelay:s=H.endDelay,repeat:a=H.repeat,offset:l,direction:c="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=it,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((b,h)=>{this.resolve=b,this.reject=h}),n=n||H.easing,sr(n)){const b=n.createAnimation(r);n=b.easing,r=b.keyframes||r,o=b.duration||o}this.repeat=a,this.easing=Et(n)?it:_r(n),this.updateDuration(o);const d=zo(r,l,Et(n)?n.map(_r):it);this.tick=b=>{var h;i=i;let u=0;this.pauseTime!==void 0?u=this.pauseTime:u=(b-this.startTime)*this.rate,this.t=u,u/=1e3,u=Math.max(u-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(u=this.totalDuration);const p=u/this.duration;let g=Math.floor(p),$=p%1;!$&&p>=1&&($=1),$===1&&g--;const f=g%2;(c==="reverse"||c==="alternate"&&f||c==="alternate-reverse"&&!f)&&($=1-$);const y=u>=this.totalDuration?1:Math.min($,1),v=d(this.easing(y));t(v),this.pauseTime===void 0&&(this.playState==="finished"||u>=this.totalDuration+s)?(this.playState="finished",(h=this.resolve)===null||h===void 0||h.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}class Go{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}const Ce=new WeakMap;function ho(e){return Ce.has(e)||Ce.set(e,{transforms:[],values:new Map}),Ce.get(e)}function Qo(e,t){return e.has(t)||e.set(t,new Go),e.get(t)}const Jo=["","X","Y","Z"],Xo=["translate","scale","rotate","skew"],ue={x:"translateX",y:"translateY",z:"translateZ"},Or={syntax:"",initialValue:"0deg",toDefaultUnit:e=>e+"deg"},tn={translate:{syntax:"",initialValue:"0px",toDefaultUnit:e=>e+"px"},rotate:Or,scale:{syntax:"",initialValue:1,toDefaultUnit:it},skew:Or},Zt=new Map,wr=e=>`--motion-${e}`,me=["x","y","z"];Xo.forEach(e=>{Jo.forEach(t=>{me.push(e+t),Zt.set(wr(e+t),tn[e])})});const en=(e,t)=>me.indexOf(e)-me.indexOf(t),rn=new Set(me),uo=e=>rn.has(e),on=(e,t)=>{ue[t]&&(t=ue[t]);const{transforms:r}=ho(e);Uo(r,t),e.style.transform=nn(r)},nn=e=>e.sort(en).reduce(sn,"").trim(),sn=(e,t)=>`${e} ${t}(var(${wr(t)}))`,ar=e=>e.startsWith("--"),kr=new Set;function an(e){if(!kr.has(e)){kr.add(e);try{const{syntax:t,initialValue:r}=Zt.has(e)?Zt.get(e):{};CSS.registerProperty({name:e,inherits:!1,syntax:t,initialValue:r})}catch{}}}const Ee=(e,t)=>document.createElement("div").animate(e,t),Ir={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{Ee({opacity:[1]})}catch{return!1}return!0},finished:()=>!!Ee({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{Ee({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},Ae={},Ct={};for(const e in Ir)Ct[e]=()=>(Ae[e]===void 0&&(Ae[e]=Ir[e]()),Ae[e]);const ln=.015,cn=(e,t)=>{let r="";const n=Math.round(t/ln);for(let o=0;oOt(e)?Ct.linearEasing()?`linear(${cn(e,t)})`:H.easing:ao(e)?dn(e):e,dn=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`;function hn(e,t){for(let r=0;rArray.isArray(e)?e:[e];function lr(e){return ue[e]&&(e=ue[e]),uo(e)?wr(e):e}const Xt={get:(e,t)=>{t=lr(t);let r=ar(t)?e.style.getPropertyValue(t):getComputedStyle(e)[t];if(!r&&r!==0){const n=Zt.get(t);n&&(r=n.initialValue)}return r},set:(e,t,r)=>{t=lr(t),ar(t)?e.style.setProperty(t,r):e.style[t]=r}};function mo(e,t=!0){if(!(!e||e.playState==="finished"))try{e.stop?e.stop():(t&&e.commitStyles(),e.cancel())}catch{}}function mn(e,t){var r;let n=(t==null?void 0:t.toDefaultUnit)||it;const o=e[e.length-1];if(Fo(o)){const i=((r=o.match(/(-?[\d.]+)([a-z%]*)/))===null||r===void 0?void 0:r[2])||"";i&&(n=s=>s+i)}return n}function gn(){return window.__MOTION_DEV_TOOLS_RECORD}function fn(e,t,r,n={},o){const i=gn(),s=n.record!==!1&&i;let a,{duration:l=H.duration,delay:c=H.delay,endDelay:d=H.endDelay,repeat:b=H.repeat,easing:h=H.easing,persist:u=!1,direction:p,offset:g,allowWebkitAcceleration:$=!1}=n;const f=ho(e),y=uo(t);let v=Ct.waapi();y&&on(e,t);const w=lr(t),k=Qo(f.values,w),I=Zt.get(w);return mo(k.animation,!(sr(h)&&k.generator)&&n.record!==!1),()=>{const R=()=>{var P,F;return(F=(P=Xt.get(e,w))!==null&&P!==void 0?P:I==null?void 0:I.initialValue)!==null&&F!==void 0?F:0};let T=hn(un(r),R);const z=mn(T,I);if(sr(h)){const P=h.createAnimation(T,t!=="opacity",R,w,k);h=P.easing,T=P.keyframes||T,l=P.duration||l}if(ar(w)&&(Ct.cssRegisterProperty()?an(w):v=!1),y&&!Ct.linearEasing()&&(Ot(h)||Et(h)&&h.some(Ot))&&(v=!1),v){I&&(T=T.map(Z=>he(Z)?I.toDefaultUnit(Z):Z)),T.length===1&&(!Ct.partialKeyframes()||s)&&T.unshift(R());const P={delay:zt.ms(c),duration:zt.ms(l),endDelay:zt.ms(d),easing:Et(h)?void 0:Tr(h,l),direction:p,iterations:b+1,fill:"both"};a=e.animate({[w]:T,offset:g,easing:Et(h)?h.map(Z=>Tr(Z,l)):void 0},P),a.finished||(a.finished=new Promise((Z,V)=>{a.onfinish=Z,a.oncancel=V}));const F=T[T.length-1];a.finished.then(()=>{u||(Xt.set(e,w,F),a.cancel())}).catch(io),$||(a.playbackRate=1.000001)}else if(o&&y)T=T.map(P=>typeof P=="string"?parseFloat(P):P),T.length===1&&T.unshift(parseFloat(R())),a=new o(P=>{Xt.set(e,w,z?z(P):P)},T,Object.assign(Object.assign({},n),{duration:l,easing:h}));else{const P=T[T.length-1];Xt.set(e,w,I&&he(P)?I.toDefaultUnit(P):P)}return s&&i(e,t,T,{duration:l,delay:c,easing:h,repeat:b,offset:g},"motion-one"),k.setAnimation(a),a}}const pn=(e,t)=>e[t]?Object.assign(Object.assign({},e),e[t]):Object.assign({},e);function wn(e,t){var r;return typeof e=="string"?t?((r=t[e])!==null&&r!==void 0||(t[e]=document.querySelectorAll(e)),e=t[e]):e=document.querySelectorAll(e):e instanceof Element&&(e=[e]),Array.from(e||[])}const vn=e=>e(),go=(e,t,r=H.duration)=>new Proxy({animations:e.map(vn).filter(Boolean),duration:r,options:t},yn),bn=e=>e.animations[0],yn={get:(e,t)=>{const r=bn(e);switch(t){case"duration":return e.duration;case"currentTime":return zt.s((r==null?void 0:r[t])||0);case"playbackRate":case"playState":return r==null?void 0:r[t];case"finished":return e.finished||(e.finished=Promise.all(e.animations.map(xn)).catch(io)),e.finished;case"stop":return()=>{e.animations.forEach(n=>mo(n))};case"forEachNative":return n=>{e.animations.forEach(o=>n(o,e))};default:return typeof(r==null?void 0:r[t])>"u"?void 0:()=>e.animations.forEach(n=>n[t]())}},set:(e,t,r)=>{switch(t){case"currentTime":r=zt.ms(r);case"playbackRate":for(let n=0;ne.finished;function $n(e,t,r){return Ot(e)?e(t,r):e}function Cn(e){return function(r,n,o={}){r=wn(r);const i=r.length,s=[];for(let a=0;an[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Lc={},Qn={},bs={};Object.defineProperty(bs,"__esModule",{value:!0});bs.walletLogo=void 0;const F0=(t,e)=>{let r;switch(t){case"standard":return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};bs.walletLogo=F0;var gs={};Object.defineProperty(gs,"__esModule",{value:!0});gs.LINK_API_URL=void 0;gs.LINK_API_URL="https://www.walletlink.org";var ys={};Object.defineProperty(ys,"__esModule",{value:!0});ys.ScopedLocalStorage=void 0;class W0{constructor(e){this.scope=e}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`${this.scope}:${e}`}}ys.ScopedLocalStorage=W0;var tn={},Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});const H0=Nc;function qu(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function V0(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([o]=r),o instanceof Error)throw o;const a=new Error(`Unhandled error.${o?` (${o.message})`:""}`);throw a.context=o,a}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")qu(s,this,r);else{const o=s.length,a=V0(s);for(let c=0;c"u"&&(n=wh()),nc(t,"",0,[],void 0,0,n);var i;try{br.length===0?i=JSON.stringify(t,e,r):i=JSON.stringify(t,Eh(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;_r.length!==0;){var s=_r.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Qr(t,e,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:t}),_r.push([n,r,e,i])):br.push([e,r,t]):(n[r]=t,_r.push([n,r,e]))}function nc(t,e,r,n,i,s,o){s+=1;var a;if(typeof t=="object"&&t!==null){for(a=0;ao.depthLimit){Qr(Xi,t,e,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Qr(Xi,t,e,i);return}if(n.push(t),Array.isArray(t))for(a=0;ae?1:0}function Sh(t,e,r,n){typeof n>"u"&&(n=wh());var i=ic(t,"",0,[],void 0,0,n)||t,s;try{br.length===0?s=JSON.stringify(i,e,r):s=JSON.stringify(i,Eh(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;_r.length!==0;){var o=_r.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function ic(t,e,r,n,i,s,o){s+=1;var a;if(typeof t=="object"&&t!==null){for(a=0;ao.depthLimit){Qr(Xi,t,e,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Qr(Xi,t,e,i);return}if(n.push(t),Array.isArray(t))for(a=0;a0)for(var n=0;n=1e3&&t<=4999}function Z0(t,e){if(e!=="[Circular]")return e}var $c={},er={};Object.defineProperty(er,"__esModule",{value:!0});er.errorValues=er.errorCodes=void 0;er.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};er.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=er,r=Xt,n=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:o(n)};t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function o(h,p=i){if(Number.isInteger(h)){const v=h.toString();if(f(e.errorValues,v))return e.errorValues[v].message;if(u(h))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return p}t.getMessageFromCode=o;function a(h){if(!Number.isInteger(h))return!1;const p=h.toString();return!!(e.errorValues[p]||u(h))}t.isValidCode=a;function c(h,{fallbackError:p=s,shouldIncludeStack:v=!1}={}){var E,_;if(!p||!Number.isInteger(p.code)||typeof p.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(h instanceof r.EthereumRpcError)return h.serialize();const d={};if(h&&typeof h=="object"&&!Array.isArray(h)&&f(h,"code")&&a(h.code)){const m=h;d.code=m.code,m.message&&typeof m.message=="string"?(d.message=m.message,f(m,"data")&&(d.data=m.data)):(d.message=o(d.code),d.data={originalError:l(h)})}else{d.code=p.code;const m=(E=h)===null||E===void 0?void 0:E.message;d.message=m&&typeof m=="string"?m:p.message,d.data={originalError:l(h)}}const y=(_=h)===null||_===void 0?void 0:_.stack;return v&&h&&y&&typeof y=="string"&&(d.stack=y),d}t.serializeError=c;function u(h){return h>=-32099&&h<=-32e3}function l(h){return h&&typeof h=="object"&&!Array.isArray(h)?Object.assign({},h):h}function f(h,p){return Object.prototype.hasOwnProperty.call(h,p)}})($c);var vs={};Object.defineProperty(vs,"__esModule",{value:!0});vs.ethErrors=void 0;const Dc=Xt,xh=$c,De=er;vs.ethErrors={rpc:{parse:t=>Xe(De.errorCodes.rpc.parse,t),invalidRequest:t=>Xe(De.errorCodes.rpc.invalidRequest,t),invalidParams:t=>Xe(De.errorCodes.rpc.invalidParams,t),methodNotFound:t=>Xe(De.errorCodes.rpc.methodNotFound,t),internal:t=>Xe(De.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return Xe(e,t)},invalidInput:t=>Xe(De.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>Xe(De.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>Xe(De.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>Xe(De.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>Xe(De.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>Xe(De.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Nn(De.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>Nn(De.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>Nn(De.errorCodes.provider.unsupportedMethod,t),disconnected:t=>Nn(De.errorCodes.provider.disconnected,t),chainDisconnected:t=>Nn(De.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new Dc.EthereumProviderError(e,r,n)}}};function Xe(t,e){const[r,n]=Ih(e);return new Dc.EthereumRpcError(t,r||xh.getMessageFromCode(t),n)}function Nn(t,e){const[r,n]=Ih(e);return new Dc.EthereumProviderError(t,r||xh.getMessageFromCode(t),n)}function Ih(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=Xt;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const r=$c;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=vs;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=er;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(Pc);var be={},ms={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Web3Method=void 0,function(e){e.requestEthereumAccounts="requestEthereumAccounts",e.signEthereumMessage="signEthereumMessage",e.signEthereumTransaction="signEthereumTransaction",e.submitEthereumTransaction="submitEthereumTransaction",e.ethereumAddressFromSignedMessage="ethereumAddressFromSignedMessage",e.scanQRCode="scanQRCode",e.generic="generic",e.childRequestEthereumAccounts="childRequestEthereumAccounts",e.addEthereumChain="addEthereumChain",e.switchEthereumChain="switchEthereumChain",e.makeEthereumJSONRPCRequest="makeEthereumJSONRPCRequest",e.watchAsset="watchAsset",e.selectProvider="selectProvider"}(t.Web3Method||(t.Web3Method={}))})(ms);Object.defineProperty(be,"__esModule",{value:!0});be.EthereumAddressFromSignedMessageResponse=be.SubmitEthereumTransactionResponse=be.SignEthereumTransactionResponse=be.SignEthereumMessageResponse=be.isRequestEthereumAccountsResponse=be.SelectProviderResponse=be.WatchAssetReponse=be.RequestEthereumAccountsResponse=be.SwitchEthereumChainResponse=be.AddEthereumChainResponse=be.isErrorResponse=void 0;const Tt=ms;function Y0(t){var e,r;return((e=t)===null||e===void 0?void 0:e.method)!==void 0&&((r=t)===null||r===void 0?void 0:r.errorMessage)!==void 0}be.isErrorResponse=Y0;function K0(t){return{method:Tt.Web3Method.addEthereumChain,result:t}}be.AddEthereumChainResponse=K0;function X0(t){return{method:Tt.Web3Method.switchEthereumChain,result:t}}be.SwitchEthereumChainResponse=X0;function eb(t){return{method:Tt.Web3Method.requestEthereumAccounts,result:t}}be.RequestEthereumAccountsResponse=eb;function tb(t){return{method:Tt.Web3Method.watchAsset,result:t}}be.WatchAssetReponse=tb;function rb(t){return{method:Tt.Web3Method.selectProvider,result:t}}be.SelectProviderResponse=rb;function nb(t){return t&&t.method===Tt.Web3Method.requestEthereumAccounts}be.isRequestEthereumAccountsResponse=nb;function ib(t){return{method:Tt.Web3Method.signEthereumMessage,result:t}}be.SignEthereumMessageResponse=ib;function sb(t){return{method:Tt.Web3Method.signEthereumTransaction,result:t}}be.SignEthereumTransactionResponse=sb;function ob(t){return{method:Tt.Web3Method.submitEthereumTransaction,result:t}}be.SubmitEthereumTransactionResponse=ob;function ab(t){return{method:Tt.Web3Method.ethereumAddressFromSignedMessage,result:t}}be.EthereumAddressFromSignedMessageResponse=ab;var mn={};Object.defineProperty(mn,"__esModule",{value:!0});mn.LIB_VERSION=void 0;mn.LIB_VERSION="3.7.2";(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCode=t.serializeError=t.standardErrors=t.standardErrorMessage=t.standardErrorCodes=void 0;const e=Pc,r=be,n=mn;t.standardErrorCodes=Object.freeze(Object.assign(Object.assign({},e.errorCodes),{provider:Object.freeze(Object.assign(Object.assign({},e.errorCodes.provider),{unsupportedChain:4902}))}));function i(l){return l!==void 0?(0,e.getMessageFromCode)(l):"Unknown error"}t.standardErrorMessage=i,t.standardErrors=Object.freeze(Object.assign(Object.assign({},e.ethErrors),{provider:Object.freeze(Object.assign(Object.assign({},e.ethErrors.provider),{unsupportedChain:(l="")=>e.ethErrors.provider.custom({code:t.standardErrorCodes.provider.unsupportedChain,message:`Unrecognized chain ID ${l}. Try adding the chain using wallet_addEthereumChain first.`})}))}));function s(l,f){const h=(0,e.serializeError)(o(l),{shouldIncludeStack:!0}),p=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");p.searchParams.set("version",n.LIB_VERSION),p.searchParams.set("code",h.code.toString());const v=a(h.data,f);return v&&p.searchParams.set("method",v),p.searchParams.set("message",h.message),Object.assign(Object.assign({},h),{docUrl:p.href})}t.serializeError=s;function o(l){return typeof l=="string"?{message:l,code:t.standardErrorCodes.rpc.internal}:(0,r.isErrorResponse)(l)?Object.assign(Object.assign({},l),{message:l.errorMessage,code:l.errorCode,data:{method:l.method,result:l.result}}):l}function a(l,f){var h;const p=(h=l)===null||h===void 0?void 0:h.method;if(p)return p;if(f!==void 0)return typeof f=="string"?f:Array.isArray(f)?f.length>0?f[0].method:void 0:f.method}function c(l){var f;if(typeof l=="number")return l;if(u(l))return(f=l.code)!==null&&f!==void 0?f:l.errorCode}t.getErrorCode=c;function u(l){return typeof l=="object"&&l!==null&&(typeof l.code=="number"||typeof l.errorCode=="number")}})(ni);var _n={},Rh={exports:{}},sc={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh */(function(t,e){var r=ps,n=r.Buffer;function i(o,a){for(var c in o)a[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=s);function s(o,a,c){return n(o,a,c)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,c)},s.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var u=n(o);return a!==void 0?typeof c=="string"?u.fill(a,c):u.fill(a):u.fill(0),u},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}})(sc,sc.exports);var ir=sc.exports,Ah=ir.Buffer;function _s(t,e){this._block=Ah.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}_s.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=Ah.from(t,e));for(var r=this._block,n=this._blockSize,i=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s};_s.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var wn=_s,cb=bt,Mh=wn,ub=ir.Buffer,lb=[1518500249,1859775393,-1894007588,-899497514],fb=new Array(80);function ii(){this.init(),this._w=fb,Mh.call(this,64,56)}cb(ii,Mh);ii.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function hb(t){return t<<5|t>>>27}function db(t){return t<<30|t>>>2}function pb(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}ii.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=e[a-3]^e[a-8]^e[a-14]^e[a-16];for(var c=0;c<80;++c){var u=~~(c/20),l=hb(r)+pb(u,n,i,s)+o+e[c]+lb[u]|0;o=s,s=i,i=db(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};ii.prototype._hash=function(){var t=ub.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var bb=ii,gb=bt,kh=wn,yb=ir.Buffer,vb=[1518500249,1859775393,-1894007588,-899497514],mb=new Array(80);function si(){this.init(),this._w=mb,kh.call(this,64,56)}gb(si,kh);si.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function _b(t){return t<<1|t>>>31}function wb(t){return t<<5|t>>>27}function Sb(t){return t<<30|t>>>2}function Eb(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}si.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=_b(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var c=0;c<80;++c){var u=~~(c/20),l=wb(r)+Eb(u,n,i,s)+o+e[c]+vb[u]|0;o=s,s=i,i=Sb(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};si.prototype._hash=function(){var t=yb.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var Cb=si,xb=bt,Th=wn,Ib=ir.Buffer,Rb=[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],Ab=new Array(64);function oi(){this.init(),this._w=Ab,Th.call(this,64,56)}xb(oi,Th);oi.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Mb(t,e,r){return r^t&(e^r)}function kb(t,e,r){return t&e|r&(t|e)}function Tb(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function Ob(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function Nb(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function Lb(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}oi.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._f|0,c=this._g|0,u=this._h|0,l=0;l<16;++l)e[l]=t.readInt32BE(l*4);for(;l<64;++l)e[l]=Lb(e[l-2])+e[l-7]+Nb(e[l-15])+e[l-16]|0;for(var f=0;f<64;++f){var h=u+Ob(o)+Mb(o,a,c)+Rb[f]+e[f]|0,p=Tb(r)+kb(r,n,i)|0;u=c,c=a,a=o,o=s+h|0,s=i,i=n,n=r,r=h+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=u+this._h|0};oi.prototype._hash=function(){var t=Ib.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};var Oh=oi,Pb=bt,$b=Oh,Db=wn,jb=ir.Buffer,Bb=new Array(64);function ws(){this.init(),this._w=Bb,Db.call(this,64,56)}Pb(ws,$b);ws.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};ws.prototype._hash=function(){var t=jb.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};var Fb=ws,Wb=bt,Nh=wn,Hb=ir.Buffer,Gu=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Vb=new Array(160);function ai(){this.init(),this._w=Vb,Nh.call(this,128,112)}Wb(ai,Nh);ai.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ju(t,e,r){return r^t&(e^r)}function Qu(t,e,r){return t&e|r&(t|e)}function Zu(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function Yu(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function Ub(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function zb(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function qb(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function Gb(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function Ae(t,e){return t>>>0>>0?1:0}ai.prototype._update=function(t){for(var e=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,o=this._eh|0,a=this._fh|0,c=this._gh|0,u=this._hh|0,l=this._al|0,f=this._bl|0,h=this._cl|0,p=this._dl|0,v=this._el|0,E=this._fl|0,_=this._gl|0,d=this._hl|0,y=0;y<32;y+=2)e[y]=t.readInt32BE(y*4),e[y+1]=t.readInt32BE(y*4+4);for(;y<160;y+=2){var m=e[y-30],x=e[y-15*2+1],C=Ub(m,x),T=zb(x,m);m=e[y-2*2],x=e[y-2*2+1];var j=qb(m,x),$=Gb(x,m),A=e[y-7*2],U=e[y-7*2+1],ce=e[y-16*2],Z=e[y-16*2+1],R=T+U|0,M=C+A+Ae(R,T)|0;R=R+$|0,M=M+j+Ae(R,$)|0,R=R+Z|0,M=M+ce+Ae(R,Z)|0,e[y]=M,e[y+1]=R}for(var N=0;N<160;N+=2){M=e[N],R=e[N+1];var L=Qu(r,n,i),B=Qu(l,f,h),D=Zu(r,l),H=Zu(l,r),Y=Yu(o,v),J=Yu(v,o),se=Gu[N],he=Gu[N+1],le=Ju(o,a,c),We=Ju(v,E,_),w=d+J|0,S=u+Y+Ae(w,d)|0;w=w+We|0,S=S+le+Ae(w,We)|0,w=w+he|0,S=S+se+Ae(w,he)|0,w=w+R|0,S=S+M+Ae(w,R)|0;var O=H+B|0,z=D+L+Ae(O,H)|0;u=c,d=_,c=a,_=E,a=o,E=v,v=p+w|0,o=s+S+Ae(v,p)|0,s=i,p=h,i=n,h=f,n=r,f=l,l=w+O|0,r=S+z+Ae(l,w)|0}this._al=this._al+l|0,this._bl=this._bl+f|0,this._cl=this._cl+h|0,this._dl=this._dl+p|0,this._el=this._el+v|0,this._fl=this._fl+E|0,this._gl=this._gl+_|0,this._hl=this._hl+d|0,this._ah=this._ah+r+Ae(this._al,l)|0,this._bh=this._bh+n+Ae(this._bl,f)|0,this._ch=this._ch+i+Ae(this._cl,h)|0,this._dh=this._dh+s+Ae(this._dl,p)|0,this._eh=this._eh+o+Ae(this._el,v)|0,this._fh=this._fh+a+Ae(this._fl,E)|0,this._gh=this._gh+c+Ae(this._gl,_)|0,this._hh=this._hh+u+Ae(this._hl,d)|0};ai.prototype._hash=function(){var t=Hb.allocUnsafe(64);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};var Lh=ai,Jb=bt,Qb=Lh,Zb=wn,Yb=ir.Buffer,Kb=new Array(160);function Ss(){this.init(),this._w=Kb,Zb.call(this,128,112)}Jb(Ss,Qb);Ss.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};Ss.prototype._hash=function(){var t=Yb.allocUnsafe(48);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};var Xb=Ss,Rr=Rh.exports=function(e){e=e.toLowerCase();var r=Rr[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};Rr.sha=bb;Rr.sha1=Cb;Rr.sha224=Fb;Rr.sha256=Oh;Rr.sha384=Xb;Rr.sha512=Lh;var eg=Rh.exports,W={},tg=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,r);if(o.value!==i||o.enumerable!==!0)return!1}return!0},Ku=typeof Symbol<"u"&&Symbol,rg=tg,ng=function(){return typeof Ku!="function"||typeof Symbol!="function"||typeof Ku("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:rg()},Xu={foo:{}},ig=Object,sg=function(){return{__proto__:Xu}.foo===Xu.foo&&!({__proto__:null}instanceof ig)},og="Function.prototype.bind called on incompatible ",ag=Object.prototype.toString,cg=Math.max,ug="[object Function]",el=function(e,r){for(var n=[],i=0;i"u"||!Te?ne:Te(Uint8Array),mr={"%AggregateError%":typeof AggregateError>"u"?ne:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?ne:ArrayBuffer,"%ArrayIteratorPrototype%":jr&&Te?Te([][Symbol.iterator]()):ne,"%AsyncFromSyncIteratorPrototype%":ne,"%AsyncFunction%":zr,"%AsyncGenerator%":zr,"%AsyncGeneratorFunction%":zr,"%AsyncIteratorPrototype%":zr,"%Atomics%":typeof Atomics>"u"?ne:Atomics,"%BigInt%":typeof BigInt>"u"?ne:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?ne:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?ne:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?ne:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?ne:Float32Array,"%Float64Array%":typeof Float64Array>"u"?ne:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?ne:FinalizationRegistry,"%Function%":Ph,"%GeneratorFunction%":zr,"%Int8Array%":typeof Int8Array>"u"?ne:Int8Array,"%Int16Array%":typeof Int16Array>"u"?ne:Int16Array,"%Int32Array%":typeof Int32Array>"u"?ne:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":jr&&Te?Te(Te([][Symbol.iterator]())):ne,"%JSON%":typeof JSON=="object"?JSON:ne,"%Map%":typeof Map>"u"?ne:Map,"%MapIteratorPrototype%":typeof Map>"u"||!jr||!Te?ne:Te(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?ne:Promise,"%Proxy%":typeof Proxy>"u"?ne:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?ne:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?ne:Set,"%SetIteratorPrototype%":typeof Set>"u"||!jr||!Te?ne:Te(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?ne:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":jr&&Te?Te(""[Symbol.iterator]()):ne,"%Symbol%":jr?Symbol:ne,"%SyntaxError%":rn,"%ThrowTypeError%":vg,"%TypedArray%":_g,"%TypeError%":Zr,"%Uint8Array%":typeof Uint8Array>"u"?ne:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?ne:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?ne:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?ne:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?ne:WeakMap,"%WeakRef%":typeof WeakRef>"u"?ne:WeakRef,"%WeakSet%":typeof WeakSet>"u"?ne:WeakSet};if(Te)try{null.error}catch(t){var wg=Te(Te(t));mr["%Error.prototype%"]=wg}var Sg=function t(e){var r;if(e==="%AsyncFunction%")r=pa("async function () {}");else if(e==="%GeneratorFunction%")r=pa("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=pa("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Te&&(r=Te(i.prototype))}return mr[e]=r,r},tl={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ci=jc,es=yg,Eg=ci.call(Function.call,Array.prototype.concat),Cg=ci.call(Function.apply,Array.prototype.splice),rl=ci.call(Function.call,String.prototype.replace),ts=ci.call(Function.call,String.prototype.slice),xg=ci.call(Function.call,RegExp.prototype.exec),Ig=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Rg=/\\(\\)?/g,Ag=function(e){var r=ts(e,0,1),n=ts(e,-1);if(r==="%"&&n!=="%")throw new rn("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new rn("invalid intrinsic syntax, expected opening `%`");var i=[];return rl(e,Ig,function(s,o,a,c){i[i.length]=a?rl(c,Rg,"$1"):o||s}),i},Mg=function(e,r){var n=e,i;if(es(tl,n)&&(i=tl[n],n="%"+i[0]+"%"),es(mr,n)){var s=mr[n];if(s===zr&&(s=Sg(n)),typeof s>"u"&&!r)throw new Zr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new rn("intrinsic "+e+" does not exist!")},Ar=function(e,r){if(typeof e!="string"||e.length===0)throw new Zr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Zr('"allowMissing" argument must be a boolean');if(xg(/^%?[^%]*%?$/,e)===null)throw new rn("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Ag(e),i=n.length>0?n[0]:"",s=Mg("%"+i+"%",r),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Cg(n,Eg([0,1],u)));for(var l=1,f=!0;l=n.length){var E=vr(a,h);f=!!E,f&&"get"in E&&!("originalValue"in E.get)?a=E.get:a=a[h]}else f=es(a,h),a=a[h];f&&!c&&(mr[o]=a)}}return a},$h={exports:{}},kg=Ar,oc=kg("%Object.defineProperty%",!0),ac=function(){if(oc)try{return oc({},"a",{value:1}),!0}catch{return!1}return!1};ac.hasArrayLengthDefineBug=function(){if(!ac())return null;try{return oc([],"length",{value:1}).length!==1}catch{return!0}};var Dh=ac,Tg=Ar,qi=Tg("%Object.getOwnPropertyDescriptor%",!0);if(qi)try{qi([],"length")}catch{qi=null}var jh=qi,Og=Dh(),Bc=Ar,Fn=Og&&Bc("%Object.defineProperty%",!0);if(Fn)try{Fn({},"a",{value:1})}catch{Fn=!1}var Ng=Bc("%SyntaxError%"),Br=Bc("%TypeError%"),nl=jh,Lg=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Br("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Br("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Br("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Br("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Br("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Br("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!nl&&nl(e,r);if(Fn)Fn(e,r,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[r]=n;else throw new Ng("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Bh=Ar,il=Lg,Pg=Dh(),sl=jh,ol=Bh("%TypeError%"),$g=Bh("%Math.floor%"),Dg=function(e,r){if(typeof e!="function")throw new ol("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||$g(r)!==r)throw new ol("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&sl){var o=sl(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(Pg?il(e,"length",r,!0,!0):il(e,"length",r)),e};(function(t){var e=jc,r=Ar,n=Dg,i=r("%TypeError%"),s=r("%Function.prototype.apply%"),o=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(o,s),c=r("%Object.defineProperty%",!0),u=r("%Math.max%");if(c)try{c({},"a",{value:1})}catch{c=null}t.exports=function(h){if(typeof h!="function")throw new i("a function is required");var p=a(e,o,arguments);return n(p,1+u(0,h.length-(arguments.length-1)),!0)};var l=function(){return a(e,s,arguments)};c?c(t.exports,"apply",{value:l}):t.exports.apply=l})($h);var jg=$h.exports,Fh=Ar,Wh=jg,Bg=Wh(Fh("String.prototype.indexOf")),Fg=function(e,r){var n=Fh(e,!!r);return typeof n=="function"&&Bg(e,".prototype.")>-1?Wh(n):n},Fc=typeof Map=="function"&&Map.prototype,ga=Object.getOwnPropertyDescriptor&&Fc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,rs=Fc&&ga&&typeof ga.get=="function"?ga.get:null,al=Fc&&Map.prototype.forEach,Wc=typeof Set=="function"&&Set.prototype,ya=Object.getOwnPropertyDescriptor&&Wc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ns=Wc&&ya&&typeof ya.get=="function"?ya.get:null,cl=Wc&&Set.prototype.forEach,Wg=typeof WeakMap=="function"&&WeakMap.prototype,Wn=Wg?WeakMap.prototype.has:null,Hg=typeof WeakSet=="function"&&WeakSet.prototype,Hn=Hg?WeakSet.prototype.has:null,Vg=typeof WeakRef=="function"&&WeakRef.prototype,ul=Vg?WeakRef.prototype.deref:null,Ug=Boolean.prototype.valueOf,zg=Object.prototype.toString,qg=Function.prototype.toString,Gg=String.prototype.match,Hc=String.prototype.slice,Yt=String.prototype.replace,Jg=String.prototype.toUpperCase,ll=String.prototype.toLowerCase,Hh=RegExp.prototype.test,fl=Array.prototype.concat,xt=Array.prototype.join,Qg=Array.prototype.slice,hl=Math.floor,cc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,va=Object.getOwnPropertySymbols,uc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,nn=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Fe=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===nn||"symbol")?Symbol.toStringTag:null,Vh=Object.prototype.propertyIsEnumerable,dl=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function pl(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Hh.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var n=t<0?-hl(-t):hl(t);if(n!==t){var i=String(n),s=Hc.call(e,i.length+1);return Yt.call(i,r,"$&_")+"."+Yt.call(Yt.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Yt.call(e,r,"$&_")}var lc=Oc,bl=lc.custom,gl=zh(bl)?bl:null,Zg=function t(e,r,n,i){var s=r||{};if(Jt(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Jt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Jt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Jt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Jt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Gh(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?pl(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?pl(e,u):u}var l=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=l&&l>0&&typeof e=="object")return fc(e)?"[Array]":"[Object]";var f=py(s,n);if(typeof i>"u")i=[];else if(qh(i,e)>=0)return"[Circular]";function h(R,M,N){if(M&&(i=Qg.call(i),i.push(M)),N){var L={depth:s.depth};return Jt(s,"quoteStyle")&&(L.quoteStyle=s.quoteStyle),t(R,L,n+1,i)}return t(R,s,n+1,i)}if(typeof e=="function"&&!yl(e)){var p=sy(e),v=ki(e,h);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(v.length>0?" { "+xt.call(v,", ")+" }":"")}if(zh(e)){var E=nn?Yt.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):uc.call(e);return typeof e=="object"&&!nn?Ln(E):E}if(fy(e)){for(var _="<"+ll.call(String(e.nodeName)),d=e.attributes||[],y=0;y",_}if(fc(e)){if(e.length===0)return"[]";var m=ki(e,h);return f&&!dy(m)?"["+hc(m,f)+"]":"[ "+xt.call(m,", ")+" ]"}if(Xg(e)){var x=ki(e,h);return!("cause"in Error.prototype)&&"cause"in e&&!Vh.call(e,"cause")?"{ ["+String(e)+"] "+xt.call(fl.call("[cause]: "+h(e.cause),x),", ")+" }":x.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+xt.call(x,", ")+" }"}if(typeof e=="object"&&o){if(gl&&typeof e[gl]=="function"&&lc)return lc(e,{depth:l-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(oy(e)){var C=[];return al&&al.call(e,function(R,M){C.push(h(M,e,!0)+" => "+h(R,e))}),vl("Map",rs.call(e),C,f)}if(uy(e)){var T=[];return cl&&cl.call(e,function(R){T.push(h(R,e))}),vl("Set",ns.call(e),T,f)}if(ay(e))return ma("WeakMap");if(ly(e))return ma("WeakSet");if(cy(e))return ma("WeakRef");if(ty(e))return Ln(h(Number(e)));if(ny(e))return Ln(h(cc.call(e)));if(ry(e))return Ln(Ug.call(e));if(ey(e))return Ln(h(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(e===F)return"{ [object globalThis] }";if(!Kg(e)&&!yl(e)){var j=ki(e,h),$=dl?dl(e)===Object.prototype:e instanceof Object||e.constructor===Object,A=e instanceof Object?"":"null prototype",U=!$&&Fe&&Object(e)===e&&Fe in e?Hc.call(sr(e),8,-1):A?"Object":"",ce=$||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Z=ce+(U||A?"["+xt.call(fl.call([],U||[],A||[]),": ")+"] ":"");return j.length===0?Z+"{}":f?Z+"{"+hc(j,f)+"}":Z+"{ "+xt.call(j,", ")+" }"}return String(e)};function Uh(t,e,r){var n=(r.quoteStyle||e)==="double"?'"':"'";return n+t+n}function Yg(t){return Yt.call(String(t),/"/g,""")}function fc(t){return sr(t)==="[object Array]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function Kg(t){return sr(t)==="[object Date]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function yl(t){return sr(t)==="[object RegExp]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function Xg(t){return sr(t)==="[object Error]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ey(t){return sr(t)==="[object String]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ty(t){return sr(t)==="[object Number]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ry(t){return sr(t)==="[object Boolean]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function zh(t){if(nn)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!uc)return!1;try{return uc.call(t),!0}catch{}return!1}function ny(t){if(!t||typeof t!="object"||!cc)return!1;try{return cc.call(t),!0}catch{}return!1}var iy=Object.prototype.hasOwnProperty||function(t){return t in this};function Jt(t,e){return iy.call(t,e)}function sr(t){return zg.call(t)}function sy(t){if(t.name)return t.name;var e=Gg.call(qg.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function qh(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Gh(Hc.call(t,0,e.maxStringLength),e)+n}var i=Yt.call(Yt.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,hy);return Uh(i,"single",e)}function hy(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+Jg.call(e.toString(16))}function Ln(t){return"Object("+t+")"}function ma(t){return t+" { ? }"}function vl(t,e,r,n){var i=n?hc(r,n):xt.call(r,", ");return t+" ("+e+") {"+i+"}"}function dy(t){for(var e=0;en[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Lc={},Qn={},bs={};Object.defineProperty(bs,"__esModule",{value:!0});bs.walletLogo=void 0;const F0=(t,e)=>{let r;switch(t){case"standard":return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=e,`data:image/svg+xml,%3Csvg width='${e}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};bs.walletLogo=F0;var gs={};Object.defineProperty(gs,"__esModule",{value:!0});gs.LINK_API_URL=void 0;gs.LINK_API_URL="https://www.walletlink.org";var ys={};Object.defineProperty(ys,"__esModule",{value:!0});ys.ScopedLocalStorage=void 0;class W0{constructor(e){this.scope=e}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`${this.scope}:${e}`}}ys.ScopedLocalStorage=W0;var tn={},Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});const H0=Nc;function qu(t,e,r){try{Reflect.apply(t,e,r)}catch(n){setTimeout(()=>{throw n})}}function V0(t){const e=t.length,r=new Array(e);for(let n=0;n0&&([o]=r),o instanceof Error)throw o;const a=new Error(`Unhandled error.${o?` (${o.message})`:""}`);throw a.context=o,a}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")qu(s,this,r);else{const o=s.length,a=V0(s);for(let c=0;c"u"&&(n=wh()),nc(t,"",0,[],void 0,0,n);var i;try{br.length===0?i=JSON.stringify(t,e,r):i=JSON.stringify(t,Eh(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;_r.length!==0;){var s=_r.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Qr(t,e,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:t}),_r.push([n,r,e,i])):br.push([e,r,t]):(n[r]=t,_r.push([n,r,e]))}function nc(t,e,r,n,i,s,o){s+=1;var a;if(typeof t=="object"&&t!==null){for(a=0;ao.depthLimit){Qr(Xi,t,e,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Qr(Xi,t,e,i);return}if(n.push(t),Array.isArray(t))for(a=0;ae?1:0}function Sh(t,e,r,n){typeof n>"u"&&(n=wh());var i=ic(t,"",0,[],void 0,0,n)||t,s;try{br.length===0?s=JSON.stringify(i,e,r):s=JSON.stringify(i,Eh(e),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;_r.length!==0;){var o=_r.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function ic(t,e,r,n,i,s,o){s+=1;var a;if(typeof t=="object"&&t!==null){for(a=0;ao.depthLimit){Qr(Xi,t,e,i);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Qr(Xi,t,e,i);return}if(n.push(t),Array.isArray(t))for(a=0;a0)for(var n=0;n=1e3&&t<=4999}function Z0(t,e){if(e!=="[Circular]")return e}var $c={},er={};Object.defineProperty(er,"__esModule",{value:!0});er.errorValues=er.errorCodes=void 0;er.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};er.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=er,r=Xt,n=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:o(n)};t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function o(h,p=i){if(Number.isInteger(h)){const v=h.toString();if(f(e.errorValues,v))return e.errorValues[v].message;if(u(h))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return p}t.getMessageFromCode=o;function a(h){if(!Number.isInteger(h))return!1;const p=h.toString();return!!(e.errorValues[p]||u(h))}t.isValidCode=a;function c(h,{fallbackError:p=s,shouldIncludeStack:v=!1}={}){var E,_;if(!p||!Number.isInteger(p.code)||typeof p.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(h instanceof r.EthereumRpcError)return h.serialize();const d={};if(h&&typeof h=="object"&&!Array.isArray(h)&&f(h,"code")&&a(h.code)){const m=h;d.code=m.code,m.message&&typeof m.message=="string"?(d.message=m.message,f(m,"data")&&(d.data=m.data)):(d.message=o(d.code),d.data={originalError:l(h)})}else{d.code=p.code;const m=(E=h)===null||E===void 0?void 0:E.message;d.message=m&&typeof m=="string"?m:p.message,d.data={originalError:l(h)}}const y=(_=h)===null||_===void 0?void 0:_.stack;return v&&h&&y&&typeof y=="string"&&(d.stack=y),d}t.serializeError=c;function u(h){return h>=-32099&&h<=-32e3}function l(h){return h&&typeof h=="object"&&!Array.isArray(h)?Object.assign({},h):h}function f(h,p){return Object.prototype.hasOwnProperty.call(h,p)}})($c);var vs={};Object.defineProperty(vs,"__esModule",{value:!0});vs.ethErrors=void 0;const Dc=Xt,xh=$c,De=er;vs.ethErrors={rpc:{parse:t=>Xe(De.errorCodes.rpc.parse,t),invalidRequest:t=>Xe(De.errorCodes.rpc.invalidRequest,t),invalidParams:t=>Xe(De.errorCodes.rpc.invalidParams,t),methodNotFound:t=>Xe(De.errorCodes.rpc.methodNotFound,t),internal:t=>Xe(De.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return Xe(e,t)},invalidInput:t=>Xe(De.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>Xe(De.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>Xe(De.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>Xe(De.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>Xe(De.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>Xe(De.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Nn(De.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>Nn(De.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>Nn(De.errorCodes.provider.unsupportedMethod,t),disconnected:t=>Nn(De.errorCodes.provider.disconnected,t),chainDisconnected:t=>Nn(De.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new Dc.EthereumProviderError(e,r,n)}}};function Xe(t,e){const[r,n]=Ih(e);return new Dc.EthereumRpcError(t,r||xh.getMessageFromCode(t),n)}function Nn(t,e){const[r,n]=Ih(e);return new Dc.EthereumProviderError(t,r||xh.getMessageFromCode(t),n)}function Ih(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=Xt;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const r=$c;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=vs;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=er;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(Pc);var be={},ms={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Web3Method=void 0,function(e){e.requestEthereumAccounts="requestEthereumAccounts",e.signEthereumMessage="signEthereumMessage",e.signEthereumTransaction="signEthereumTransaction",e.submitEthereumTransaction="submitEthereumTransaction",e.ethereumAddressFromSignedMessage="ethereumAddressFromSignedMessage",e.scanQRCode="scanQRCode",e.generic="generic",e.childRequestEthereumAccounts="childRequestEthereumAccounts",e.addEthereumChain="addEthereumChain",e.switchEthereumChain="switchEthereumChain",e.makeEthereumJSONRPCRequest="makeEthereumJSONRPCRequest",e.watchAsset="watchAsset",e.selectProvider="selectProvider"}(t.Web3Method||(t.Web3Method={}))})(ms);Object.defineProperty(be,"__esModule",{value:!0});be.EthereumAddressFromSignedMessageResponse=be.SubmitEthereumTransactionResponse=be.SignEthereumTransactionResponse=be.SignEthereumMessageResponse=be.isRequestEthereumAccountsResponse=be.SelectProviderResponse=be.WatchAssetReponse=be.RequestEthereumAccountsResponse=be.SwitchEthereumChainResponse=be.AddEthereumChainResponse=be.isErrorResponse=void 0;const Tt=ms;function Y0(t){var e,r;return((e=t)===null||e===void 0?void 0:e.method)!==void 0&&((r=t)===null||r===void 0?void 0:r.errorMessage)!==void 0}be.isErrorResponse=Y0;function K0(t){return{method:Tt.Web3Method.addEthereumChain,result:t}}be.AddEthereumChainResponse=K0;function X0(t){return{method:Tt.Web3Method.switchEthereumChain,result:t}}be.SwitchEthereumChainResponse=X0;function eb(t){return{method:Tt.Web3Method.requestEthereumAccounts,result:t}}be.RequestEthereumAccountsResponse=eb;function tb(t){return{method:Tt.Web3Method.watchAsset,result:t}}be.WatchAssetReponse=tb;function rb(t){return{method:Tt.Web3Method.selectProvider,result:t}}be.SelectProviderResponse=rb;function nb(t){return t&&t.method===Tt.Web3Method.requestEthereumAccounts}be.isRequestEthereumAccountsResponse=nb;function ib(t){return{method:Tt.Web3Method.signEthereumMessage,result:t}}be.SignEthereumMessageResponse=ib;function sb(t){return{method:Tt.Web3Method.signEthereumTransaction,result:t}}be.SignEthereumTransactionResponse=sb;function ob(t){return{method:Tt.Web3Method.submitEthereumTransaction,result:t}}be.SubmitEthereumTransactionResponse=ob;function ab(t){return{method:Tt.Web3Method.ethereumAddressFromSignedMessage,result:t}}be.EthereumAddressFromSignedMessageResponse=ab;var mn={};Object.defineProperty(mn,"__esModule",{value:!0});mn.LIB_VERSION=void 0;mn.LIB_VERSION="3.7.2";(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCode=t.serializeError=t.standardErrors=t.standardErrorMessage=t.standardErrorCodes=void 0;const e=Pc,r=be,n=mn;t.standardErrorCodes=Object.freeze(Object.assign(Object.assign({},e.errorCodes),{provider:Object.freeze(Object.assign(Object.assign({},e.errorCodes.provider),{unsupportedChain:4902}))}));function i(l){return l!==void 0?(0,e.getMessageFromCode)(l):"Unknown error"}t.standardErrorMessage=i,t.standardErrors=Object.freeze(Object.assign(Object.assign({},e.ethErrors),{provider:Object.freeze(Object.assign(Object.assign({},e.ethErrors.provider),{unsupportedChain:(l="")=>e.ethErrors.provider.custom({code:t.standardErrorCodes.provider.unsupportedChain,message:`Unrecognized chain ID ${l}. Try adding the chain using wallet_addEthereumChain first.`})}))}));function s(l,f){const h=(0,e.serializeError)(o(l),{shouldIncludeStack:!0}),p=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");p.searchParams.set("version",n.LIB_VERSION),p.searchParams.set("code",h.code.toString());const v=a(h.data,f);return v&&p.searchParams.set("method",v),p.searchParams.set("message",h.message),Object.assign(Object.assign({},h),{docUrl:p.href})}t.serializeError=s;function o(l){return typeof l=="string"?{message:l,code:t.standardErrorCodes.rpc.internal}:(0,r.isErrorResponse)(l)?Object.assign(Object.assign({},l),{message:l.errorMessage,code:l.errorCode,data:{method:l.method,result:l.result}}):l}function a(l,f){var h;const p=(h=l)===null||h===void 0?void 0:h.method;if(p)return p;if(f!==void 0)return typeof f=="string"?f:Array.isArray(f)?f.length>0?f[0].method:void 0:f.method}function c(l){var f;if(typeof l=="number")return l;if(u(l))return(f=l.code)!==null&&f!==void 0?f:l.errorCode}t.getErrorCode=c;function u(l){return typeof l=="object"&&l!==null&&(typeof l.code=="number"||typeof l.errorCode=="number")}})(ni);var _n={},Rh={exports:{}},sc={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh */(function(t,e){var r=ps,n=r.Buffer;function i(o,a){for(var c in o)a[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=s);function s(o,a,c){return n(o,a,c)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,c)},s.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var u=n(o);return a!==void 0?typeof c=="string"?u.fill(a,c):u.fill(a):u.fill(0),u},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}})(sc,sc.exports);var ir=sc.exports,Ah=ir.Buffer;function _s(t,e){this._block=Ah.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}_s.prototype.update=function(t,e){typeof t=="string"&&(e=e||"utf8",t=Ah.from(t,e));for(var r=this._block,n=this._blockSize,i=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s};_s.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var wn=_s,cb=bt,Mh=wn,ub=ir.Buffer,lb=[1518500249,1859775393,-1894007588,-899497514],fb=new Array(80);function ii(){this.init(),this._w=fb,Mh.call(this,64,56)}cb(ii,Mh);ii.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function hb(t){return t<<5|t>>>27}function db(t){return t<<30|t>>>2}function pb(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}ii.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=e[a-3]^e[a-8]^e[a-14]^e[a-16];for(var c=0;c<80;++c){var u=~~(c/20),l=hb(r)+pb(u,n,i,s)+o+e[c]+lb[u]|0;o=s,s=i,i=db(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};ii.prototype._hash=function(){var t=ub.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var bb=ii,gb=bt,kh=wn,yb=ir.Buffer,vb=[1518500249,1859775393,-1894007588,-899497514],mb=new Array(80);function si(){this.init(),this._w=mb,kh.call(this,64,56)}gb(si,kh);si.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function _b(t){return t<<1|t>>>31}function wb(t){return t<<5|t>>>27}function Sb(t){return t<<30|t>>>2}function Eb(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}si.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)e[a]=t.readInt32BE(a*4);for(;a<80;++a)e[a]=_b(e[a-3]^e[a-8]^e[a-14]^e[a-16]);for(var c=0;c<80;++c){var u=~~(c/20),l=wb(r)+Eb(u,n,i,s)+o+e[c]+vb[u]|0;o=s,s=i,i=Sb(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};si.prototype._hash=function(){var t=yb.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};var Cb=si,xb=bt,Th=wn,Ib=ir.Buffer,Rb=[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],Ab=new Array(64);function oi(){this.init(),this._w=Ab,Th.call(this,64,56)}xb(oi,Th);oi.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Mb(t,e,r){return r^t&(e^r)}function kb(t,e,r){return t&e|r&(t|e)}function Tb(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function Ob(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function Nb(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function Lb(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}oi.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._f|0,c=this._g|0,u=this._h|0,l=0;l<16;++l)e[l]=t.readInt32BE(l*4);for(;l<64;++l)e[l]=Lb(e[l-2])+e[l-7]+Nb(e[l-15])+e[l-16]|0;for(var f=0;f<64;++f){var h=u+Ob(o)+Mb(o,a,c)+Rb[f]+e[f]|0,p=Tb(r)+kb(r,n,i)|0;u=c,c=a,a=o,o=s+h|0,s=i,i=n,n=r,r=h+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=u+this._h|0};oi.prototype._hash=function(){var t=Ib.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};var Oh=oi,Pb=bt,$b=Oh,Db=wn,jb=ir.Buffer,Bb=new Array(64);function ws(){this.init(),this._w=Bb,Db.call(this,64,56)}Pb(ws,$b);ws.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};ws.prototype._hash=function(){var t=jb.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};var Fb=ws,Wb=bt,Nh=wn,Hb=ir.Buffer,Gu=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Vb=new Array(160);function ai(){this.init(),this._w=Vb,Nh.call(this,128,112)}Wb(ai,Nh);ai.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ju(t,e,r){return r^t&(e^r)}function Qu(t,e,r){return t&e|r&(t|e)}function Zu(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function Yu(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function Ub(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function zb(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function qb(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function Gb(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function Ae(t,e){return t>>>0>>0?1:0}ai.prototype._update=function(t){for(var e=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,o=this._eh|0,a=this._fh|0,c=this._gh|0,u=this._hh|0,l=this._al|0,f=this._bl|0,h=this._cl|0,p=this._dl|0,v=this._el|0,E=this._fl|0,_=this._gl|0,d=this._hl|0,y=0;y<32;y+=2)e[y]=t.readInt32BE(y*4),e[y+1]=t.readInt32BE(y*4+4);for(;y<160;y+=2){var m=e[y-30],x=e[y-15*2+1],C=Ub(m,x),T=zb(x,m);m=e[y-2*2],x=e[y-2*2+1];var j=qb(m,x),$=Gb(x,m),A=e[y-7*2],U=e[y-7*2+1],ce=e[y-16*2],Z=e[y-16*2+1],R=T+U|0,M=C+A+Ae(R,T)|0;R=R+$|0,M=M+j+Ae(R,$)|0,R=R+Z|0,M=M+ce+Ae(R,Z)|0,e[y]=M,e[y+1]=R}for(var N=0;N<160;N+=2){M=e[N],R=e[N+1];var L=Qu(r,n,i),B=Qu(l,f,h),D=Zu(r,l),H=Zu(l,r),Y=Yu(o,v),J=Yu(v,o),se=Gu[N],he=Gu[N+1],le=Ju(o,a,c),We=Ju(v,E,_),w=d+J|0,S=u+Y+Ae(w,d)|0;w=w+We|0,S=S+le+Ae(w,We)|0,w=w+he|0,S=S+se+Ae(w,he)|0,w=w+R|0,S=S+M+Ae(w,R)|0;var O=H+B|0,z=D+L+Ae(O,H)|0;u=c,d=_,c=a,_=E,a=o,E=v,v=p+w|0,o=s+S+Ae(v,p)|0,s=i,p=h,i=n,h=f,n=r,f=l,l=w+O|0,r=S+z+Ae(l,w)|0}this._al=this._al+l|0,this._bl=this._bl+f|0,this._cl=this._cl+h|0,this._dl=this._dl+p|0,this._el=this._el+v|0,this._fl=this._fl+E|0,this._gl=this._gl+_|0,this._hl=this._hl+d|0,this._ah=this._ah+r+Ae(this._al,l)|0,this._bh=this._bh+n+Ae(this._bl,f)|0,this._ch=this._ch+i+Ae(this._cl,h)|0,this._dh=this._dh+s+Ae(this._dl,p)|0,this._eh=this._eh+o+Ae(this._el,v)|0,this._fh=this._fh+a+Ae(this._fl,E)|0,this._gh=this._gh+c+Ae(this._gl,_)|0,this._hh=this._hh+u+Ae(this._hl,d)|0};ai.prototype._hash=function(){var t=Hb.allocUnsafe(64);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};var Lh=ai,Jb=bt,Qb=Lh,Zb=wn,Yb=ir.Buffer,Kb=new Array(160);function Ss(){this.init(),this._w=Kb,Zb.call(this,128,112)}Jb(Ss,Qb);Ss.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};Ss.prototype._hash=function(){var t=Yb.allocUnsafe(48);function e(r,n,i){t.writeInt32BE(r,i),t.writeInt32BE(n,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};var Xb=Ss,Rr=Rh.exports=function(e){e=e.toLowerCase();var r=Rr[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};Rr.sha=bb;Rr.sha1=Cb;Rr.sha224=Fb;Rr.sha256=Oh;Rr.sha384=Xb;Rr.sha512=Lh;var eg=Rh.exports,W={},tg=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,r);if(o.value!==i||o.enumerable!==!0)return!1}return!0},Ku=typeof Symbol<"u"&&Symbol,rg=tg,ng=function(){return typeof Ku!="function"||typeof Symbol!="function"||typeof Ku("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:rg()},Xu={foo:{}},ig=Object,sg=function(){return{__proto__:Xu}.foo===Xu.foo&&!({__proto__:null}instanceof ig)},og="Function.prototype.bind called on incompatible ",ag=Object.prototype.toString,cg=Math.max,ug="[object Function]",el=function(e,r){for(var n=[],i=0;i"u"||!Te?ne:Te(Uint8Array),mr={"%AggregateError%":typeof AggregateError>"u"?ne:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?ne:ArrayBuffer,"%ArrayIteratorPrototype%":jr&&Te?Te([][Symbol.iterator]()):ne,"%AsyncFromSyncIteratorPrototype%":ne,"%AsyncFunction%":zr,"%AsyncGenerator%":zr,"%AsyncGeneratorFunction%":zr,"%AsyncIteratorPrototype%":zr,"%Atomics%":typeof Atomics>"u"?ne:Atomics,"%BigInt%":typeof BigInt>"u"?ne:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?ne:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?ne:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?ne:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?ne:Float32Array,"%Float64Array%":typeof Float64Array>"u"?ne:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?ne:FinalizationRegistry,"%Function%":Ph,"%GeneratorFunction%":zr,"%Int8Array%":typeof Int8Array>"u"?ne:Int8Array,"%Int16Array%":typeof Int16Array>"u"?ne:Int16Array,"%Int32Array%":typeof Int32Array>"u"?ne:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":jr&&Te?Te(Te([][Symbol.iterator]())):ne,"%JSON%":typeof JSON=="object"?JSON:ne,"%Map%":typeof Map>"u"?ne:Map,"%MapIteratorPrototype%":typeof Map>"u"||!jr||!Te?ne:Te(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?ne:Promise,"%Proxy%":typeof Proxy>"u"?ne:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?ne:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?ne:Set,"%SetIteratorPrototype%":typeof Set>"u"||!jr||!Te?ne:Te(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?ne:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":jr&&Te?Te(""[Symbol.iterator]()):ne,"%Symbol%":jr?Symbol:ne,"%SyntaxError%":rn,"%ThrowTypeError%":vg,"%TypedArray%":_g,"%TypeError%":Zr,"%Uint8Array%":typeof Uint8Array>"u"?ne:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?ne:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?ne:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?ne:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?ne:WeakMap,"%WeakRef%":typeof WeakRef>"u"?ne:WeakRef,"%WeakSet%":typeof WeakSet>"u"?ne:WeakSet};if(Te)try{null.error}catch(t){var wg=Te(Te(t));mr["%Error.prototype%"]=wg}var Sg=function t(e){var r;if(e==="%AsyncFunction%")r=pa("async function () {}");else if(e==="%GeneratorFunction%")r=pa("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=pa("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&Te&&(r=Te(i.prototype))}return mr[e]=r,r},tl={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ci=jc,es=yg,Eg=ci.call(Function.call,Array.prototype.concat),Cg=ci.call(Function.apply,Array.prototype.splice),rl=ci.call(Function.call,String.prototype.replace),ts=ci.call(Function.call,String.prototype.slice),xg=ci.call(Function.call,RegExp.prototype.exec),Ig=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Rg=/\\(\\)?/g,Ag=function(e){var r=ts(e,0,1),n=ts(e,-1);if(r==="%"&&n!=="%")throw new rn("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new rn("invalid intrinsic syntax, expected opening `%`");var i=[];return rl(e,Ig,function(s,o,a,c){i[i.length]=a?rl(c,Rg,"$1"):o||s}),i},Mg=function(e,r){var n=e,i;if(es(tl,n)&&(i=tl[n],n="%"+i[0]+"%"),es(mr,n)){var s=mr[n];if(s===zr&&(s=Sg(n)),typeof s>"u"&&!r)throw new Zr("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new rn("intrinsic "+e+" does not exist!")},Ar=function(e,r){if(typeof e!="string"||e.length===0)throw new Zr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Zr('"allowMissing" argument must be a boolean');if(xg(/^%?[^%]*%?$/,e)===null)throw new rn("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Ag(e),i=n.length>0?n[0]:"",s=Mg("%"+i+"%",r),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],Cg(n,Eg([0,1],u)));for(var l=1,f=!0;l=n.length){var E=vr(a,h);f=!!E,f&&"get"in E&&!("originalValue"in E.get)?a=E.get:a=a[h]}else f=es(a,h),a=a[h];f&&!c&&(mr[o]=a)}}return a},$h={exports:{}},kg=Ar,oc=kg("%Object.defineProperty%",!0),ac=function(){if(oc)try{return oc({},"a",{value:1}),!0}catch{return!1}return!1};ac.hasArrayLengthDefineBug=function(){if(!ac())return null;try{return oc([],"length",{value:1}).length!==1}catch{return!0}};var Dh=ac,Tg=Ar,qi=Tg("%Object.getOwnPropertyDescriptor%",!0);if(qi)try{qi([],"length")}catch{qi=null}var jh=qi,Og=Dh(),Bc=Ar,Fn=Og&&Bc("%Object.defineProperty%",!0);if(Fn)try{Fn({},"a",{value:1})}catch{Fn=!1}var Ng=Bc("%SyntaxError%"),Br=Bc("%TypeError%"),nl=jh,Lg=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Br("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Br("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Br("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Br("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Br("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Br("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!nl&&nl(e,r);if(Fn)Fn(e,r,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)e[r]=n;else throw new Ng("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Bh=Ar,il=Lg,Pg=Dh(),sl=jh,ol=Bh("%TypeError%"),$g=Bh("%Math.floor%"),Dg=function(e,r){if(typeof e!="function")throw new ol("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||$g(r)!==r)throw new ol("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&sl){var o=sl(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!n)&&(Pg?il(e,"length",r,!0,!0):il(e,"length",r)),e};(function(t){var e=jc,r=Ar,n=Dg,i=r("%TypeError%"),s=r("%Function.prototype.apply%"),o=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(o,s),c=r("%Object.defineProperty%",!0),u=r("%Math.max%");if(c)try{c({},"a",{value:1})}catch{c=null}t.exports=function(h){if(typeof h!="function")throw new i("a function is required");var p=a(e,o,arguments);return n(p,1+u(0,h.length-(arguments.length-1)),!0)};var l=function(){return a(e,s,arguments)};c?c(t.exports,"apply",{value:l}):t.exports.apply=l})($h);var jg=$h.exports,Fh=Ar,Wh=jg,Bg=Wh(Fh("String.prototype.indexOf")),Fg=function(e,r){var n=Fh(e,!!r);return typeof n=="function"&&Bg(e,".prototype.")>-1?Wh(n):n},Fc=typeof Map=="function"&&Map.prototype,ga=Object.getOwnPropertyDescriptor&&Fc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,rs=Fc&&ga&&typeof ga.get=="function"?ga.get:null,al=Fc&&Map.prototype.forEach,Wc=typeof Set=="function"&&Set.prototype,ya=Object.getOwnPropertyDescriptor&&Wc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ns=Wc&&ya&&typeof ya.get=="function"?ya.get:null,cl=Wc&&Set.prototype.forEach,Wg=typeof WeakMap=="function"&&WeakMap.prototype,Wn=Wg?WeakMap.prototype.has:null,Hg=typeof WeakSet=="function"&&WeakSet.prototype,Hn=Hg?WeakSet.prototype.has:null,Vg=typeof WeakRef=="function"&&WeakRef.prototype,ul=Vg?WeakRef.prototype.deref:null,Ug=Boolean.prototype.valueOf,zg=Object.prototype.toString,qg=Function.prototype.toString,Gg=String.prototype.match,Hc=String.prototype.slice,Yt=String.prototype.replace,Jg=String.prototype.toUpperCase,ll=String.prototype.toLowerCase,Hh=RegExp.prototype.test,fl=Array.prototype.concat,xt=Array.prototype.join,Qg=Array.prototype.slice,hl=Math.floor,cc=typeof BigInt=="function"?BigInt.prototype.valueOf:null,va=Object.getOwnPropertySymbols,uc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,nn=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Fe=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===nn||"symbol")?Symbol.toStringTag:null,Vh=Object.prototype.propertyIsEnumerable,dl=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function pl(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||Hh.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var n=t<0?-hl(-t):hl(t);if(n!==t){var i=String(n),s=Hc.call(e,i.length+1);return Yt.call(i,r,"$&_")+"."+Yt.call(Yt.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Yt.call(e,r,"$&_")}var lc=Oc,bl=lc.custom,gl=zh(bl)?bl:null,Zg=function t(e,r,n,i){var s=r||{};if(Jt(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Jt(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Jt(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Jt(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Jt(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Gh(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return a?pl(e,c):c}if(typeof e=="bigint"){var u=String(e)+"n";return a?pl(e,u):u}var l=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=l&&l>0&&typeof e=="object")return fc(e)?"[Array]":"[Object]";var f=py(s,n);if(typeof i>"u")i=[];else if(qh(i,e)>=0)return"[Circular]";function h(R,M,N){if(M&&(i=Qg.call(i),i.push(M)),N){var L={depth:s.depth};return Jt(s,"quoteStyle")&&(L.quoteStyle=s.quoteStyle),t(R,L,n+1,i)}return t(R,s,n+1,i)}if(typeof e=="function"&&!yl(e)){var p=sy(e),v=ki(e,h);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(v.length>0?" { "+xt.call(v,", ")+" }":"")}if(zh(e)){var E=nn?Yt.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):uc.call(e);return typeof e=="object"&&!nn?Ln(E):E}if(fy(e)){for(var _="<"+ll.call(String(e.nodeName)),d=e.attributes||[],y=0;y",_}if(fc(e)){if(e.length===0)return"[]";var m=ki(e,h);return f&&!dy(m)?"["+hc(m,f)+"]":"[ "+xt.call(m,", ")+" ]"}if(Xg(e)){var x=ki(e,h);return!("cause"in Error.prototype)&&"cause"in e&&!Vh.call(e,"cause")?"{ ["+String(e)+"] "+xt.call(fl.call("[cause]: "+h(e.cause),x),", ")+" }":x.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+xt.call(x,", ")+" }"}if(typeof e=="object"&&o){if(gl&&typeof e[gl]=="function"&&lc)return lc(e,{depth:l-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(oy(e)){var C=[];return al&&al.call(e,function(R,M){C.push(h(M,e,!0)+" => "+h(R,e))}),vl("Map",rs.call(e),C,f)}if(uy(e)){var T=[];return cl&&cl.call(e,function(R){T.push(h(R,e))}),vl("Set",ns.call(e),T,f)}if(ay(e))return ma("WeakMap");if(ly(e))return ma("WeakSet");if(cy(e))return ma("WeakRef");if(ty(e))return Ln(h(Number(e)));if(ny(e))return Ln(h(cc.call(e)));if(ry(e))return Ln(Ug.call(e));if(ey(e))return Ln(h(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(e===F)return"{ [object globalThis] }";if(!Kg(e)&&!yl(e)){var j=ki(e,h),$=dl?dl(e)===Object.prototype:e instanceof Object||e.constructor===Object,A=e instanceof Object?"":"null prototype",U=!$&&Fe&&Object(e)===e&&Fe in e?Hc.call(sr(e),8,-1):A?"Object":"",ce=$||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",Z=ce+(U||A?"["+xt.call(fl.call([],U||[],A||[]),": ")+"] ":"");return j.length===0?Z+"{}":f?Z+"{"+hc(j,f)+"}":Z+"{ "+xt.call(j,", ")+" }"}return String(e)};function Uh(t,e,r){var n=(r.quoteStyle||e)==="double"?'"':"'";return n+t+n}function Yg(t){return Yt.call(String(t),/"/g,""")}function fc(t){return sr(t)==="[object Array]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function Kg(t){return sr(t)==="[object Date]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function yl(t){return sr(t)==="[object RegExp]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function Xg(t){return sr(t)==="[object Error]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ey(t){return sr(t)==="[object String]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ty(t){return sr(t)==="[object Number]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function ry(t){return sr(t)==="[object Boolean]"&&(!Fe||!(typeof t=="object"&&Fe in t))}function zh(t){if(nn)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!uc)return!1;try{return uc.call(t),!0}catch{}return!1}function ny(t){if(!t||typeof t!="object"||!cc)return!1;try{return cc.call(t),!0}catch{}return!1}var iy=Object.prototype.hasOwnProperty||function(t){return t in this};function Jt(t,e){return iy.call(t,e)}function sr(t){return zg.call(t)}function sy(t){if(t.name)return t.name;var e=Gg.call(qg.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function qh(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Gh(Hc.call(t,0,e.maxStringLength),e)+n}var i=Yt.call(Yt.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,hy);return Uh(i,"single",e)}function hy(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+Jg.call(e.toString(16))}function Ln(t){return"Object("+t+")"}function ma(t){return t+" { ? }"}function vl(t,e,r,n){var i=n?hc(r,n):xt.call(r,", ");return t+" ("+e+") {"+i+"}"}function dy(t){for(var e=0;e=0)return!1;return!0}function py(t,e){var r;if(t.indent===" ")r=" ";else if(typeof t.indent=="number"&&t.indent>0)r=xt.call(Array(t.indent+1)," ");else return null;return{base:r,prev:xt.call(Array(e+1),r)}}function hc(t,e){if(t.length===0)return"";var r=` `+e.prev+e.base;return r+xt.call(t,","+r)+` `+e.prev}function ki(t,e){var r=fc(t),n=[];if(r){n.length=t.length;for(var i=0;i1;){var r=e.pop(),n=r.obj[r.prop];if(lr(n)){for(var i=[],s=0;s=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===My.RFC1738&&(u===40||u===41)){a+=o.charAt(c);continue}if(u<128){a=a+mt[u];continue}if(u<2048){a=a+(mt[192|u>>6]+mt[128|u&63]);continue}if(u<55296||u>=57344){a=a+(mt[224|u>>12]+mt[128|u>>6&63]+mt[128|u&63]);continue}c+=1,u=65536+((u&1023)<<10|o.charCodeAt(c)&1023),a+=mt[240|u>>18]+mt[128|u>>12&63]+mt[128|u>>6&63]+mt[128|u&63]}return a},Py=function(e){for(var r=[{obj:{o:e},prop:"o"}],n=[],i=0;i"u"&&(m=0)}if(typeof c=="function"?d=c(r,d):d instanceof Date?d=f(d):n==="comma"&&$t(d)&&(d=Gi.maybeMap(d,function(L){return L instanceof Date?f(L):L})),d===null){if(s)return a&&!v?a(r,Be.encoder,E,"key",h):r;d=""}if(Vy(d)||Gi.isBuffer(d)){if(a){var T=v?r:a(r,Be.encoder,E,"key",h);return[p(T)+"="+p(a(d,Be.encoder,E,"value",h))]}return[p(r)+"="+p(String(d))]}var j=[];if(typeof d>"u")return j;var $;if(n==="comma"&&$t(d))v&&a&&(d=Gi.maybeMap(d,a)),$=[{value:d.length>0?d.join(",")||null:void 0}];else if($t(c))$=c;else{var A=Object.keys(d);$=u?A.sort(u):A}for(var U=i&&$t(d)&&d.length===1?r+"[]":r,ce=0;ce<$.length;++ce){var Z=$[ce],R=typeof Z=="object"&&typeof Z.value<"u"?Z.value:d[Z];if(!(o&&R===null)){var M=$t(d)?typeof n=="function"?n(U,Z):U:U+(l?"."+Z:"["+Z+"]");_.set(e,m);var N=Zh();N.set(Sa,_),Yh(j,t(R,M,n,i,s,o,n==="comma"&&v&&$t(d)?null:a,c,u,l,f,h,p,v,E,N))}}return j},zy=function(e){if(!e)return Be;if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var r=e.charset||Be.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Vn.default;if(typeof e.format<"u"){if(!Fy.call(Vn.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var i=Vn.formatters[n],s=Be.filter;return(typeof e.filter=="function"||$t(e.filter))&&(s=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:Be.addQueryPrefix,allowDots:typeof e.allowDots>"u"?Be.allowDots:!!e.allowDots,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Be.charsetSentinel,delimiter:typeof e.delimiter>"u"?Be.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Be.encode,encoder:typeof e.encoder=="function"?e.encoder:Be.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Be.encodeValuesOnly,filter:s,format:n,formatter:i,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Be.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Be.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Be.strictNullHandling}},qy=function(t,e){var r=t,n=zy(e),i,s;typeof n.filter=="function"?(s=n.filter,r=s("",r)):$t(n.filter)&&(s=n.filter,i=s);var o=[];if(typeof r!="object"||r===null)return"";var a;e&&e.arrayFormat in ml?a=e.arrayFormat:e&&"indices"in e?a=e.indices?"indices":"repeat":a="indices";var c=ml[a];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u=c==="comma"&&e&&e.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);for(var l=Zh(),f=0;f0?v+p:""},sn=Qh,dc=Object.prototype.hasOwnProperty,Gy=Array.isArray,Me={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:sn.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Jy=function(t){return t.replace(/&#(\d+);/g,function(e,r){return String.fromCharCode(parseInt(r,10))})},Kh=function(t,e){return t&&typeof t=="string"&&e.comma&&t.indexOf(",")>-1?t.split(","):t},Qy="utf8=%26%2310003%3B",Zy="utf8=%E2%9C%93",Yy=function(e,r){var n={__proto__:null},i=r.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=r.parameterLimit===1/0?void 0:r.parameterLimit,o=i.split(r.delimiter,s),a=-1,c,u=r.charset;if(r.charsetSentinel)for(c=0;c-1&&(v=Gy(v)?[v]:v),dc.call(n,p)?n[p]=sn.combine(n[p],v):n[p]=v}return n},Ky=function(t,e,r,n){for(var i=n?e:Kh(e,r),s=t.length-1;s>=0;--s){var o,a=t[s];if(a==="[]"&&r.parseArrays)o=[].concat(i);else{o=r.plainObjects?Object.create(null):{};var c=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,u=parseInt(c,10);!r.parseArrays&&c===""?o={0:i}:!isNaN(u)&&a!==c&&String(u)===c&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(o=[],o[u]=i):c!=="__proto__"&&(o[c]=i)}i=o}return i},Xy=function(e,r,n,i){if(e){var s=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,c=n.depth>0&&o.exec(s),u=c?s.slice(0,c.index):s,l=[];if(u){if(!n.plainObjects&&dc.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var f=0;n.depth>0&&(c=a.exec(s))!==null&&f"u"?Me.charset:e.charset;return{allowDots:typeof e.allowDots>"u"?Me.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:Me.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:Me.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:Me.arrayLimit,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Me.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:Me.comma,decoder:typeof e.decoder=="function"?e.decoder:Me.decoder,delimiter:typeof e.delimiter=="string"||sn.isRegExp(e.delimiter)?e.delimiter:Me.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:Me.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:Me.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:Me.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:Me.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Me.strictNullHandling}},tv=function(t,e){var r=ev(e);if(t===""||t===null||typeof t>"u")return r.plainObjects?Object.create(null):{};for(var n=typeof t=="string"?Yy(t,r):t,i=r.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;on}t.OpaqueType=e,t.HexString=e(),t.AddressString=e(),t.BigIntString=e();function r(n){return Math.floor(n)}t.IntNumber=r,t.RegExpString=e(),function(n){n.CoinbaseWallet="CoinbaseWallet",n.MetaMask="MetaMask",n.Unselected=""}(t.ProviderType||(t.ProviderType={}))})(ui);var ov=F&&F.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(W,"__esModule",{value:!0});W.isInIFrame=W.createQrUrl=W.getFavicon=W.range=W.isBigNumber=W.ensureParsedJSONObject=W.ensureBN=W.ensureRegExpString=W.ensureIntNumber=W.ensureBuffer=W.ensureAddressString=W.ensureEvenLengthHexString=W.ensureHexString=W.isHexString=W.prepend0x=W.strip0x=W.has0xPrefix=W.hexStringFromIntNumber=W.intNumberFromHexString=W.bigIntStringFromBN=W.hexStringFromBuffer=W.hexStringToUint8Array=W.uint8ArrayToHex=W.randomBytesHex=void 0;const Qt=ov(ds),av=sv,Mr=ni,st=ui,Xh=/^[0-9]*$/,ed=/^[a-f0-9]*$/;function cv(t){return td(crypto.getRandomValues(new Uint8Array(t)))}W.randomBytesHex=cv;function td(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}W.uint8ArrayToHex=td;function uv(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>parseInt(e,16)))}W.hexStringToUint8Array=uv;function lv(t,e=!1){const r=t.toString("hex");return(0,st.HexString)(e?"0x"+r:r)}W.hexStringFromBuffer=lv;function fv(t){return(0,st.BigIntString)(t.toString(10))}W.bigIntStringFromBN=fv;function hv(t){return(0,st.IntNumber)(new Qt.default(fi(t,!1),16).toNumber())}W.intNumberFromHexString=hv;function dv(t){return(0,st.HexString)("0x"+new Qt.default(t).toString(16))}W.hexStringFromIntNumber=dv;function qc(t){return t.startsWith("0x")||t.startsWith("0X")}W.has0xPrefix=qc;function Es(t){return qc(t)?t.slice(2):t}W.strip0x=Es;function rd(t){return qc(t)?"0x"+t.slice(2):"0x"+t}W.prepend0x=rd;function li(t){if(typeof t!="string")return!1;const e=Es(t).toLowerCase();return ed.test(e)}W.isHexString=li;function nd(t,e=!1){if(typeof t=="string"){const r=Es(t).toLowerCase();if(ed.test(r))return(0,st.HexString)(e?"0x"+r:r)}throw Mr.standardErrors.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}W.ensureHexString=nd;function fi(t,e=!1){let r=nd(t,!1);return r.length%2===1&&(r=(0,st.HexString)("0"+r)),e?(0,st.HexString)("0x"+r):r}W.ensureEvenLengthHexString=fi;function pv(t){if(typeof t=="string"){const e=Es(t).toLowerCase();if(li(e)&&e.length===40)return(0,st.AddressString)(rd(e))}throw Mr.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}W.ensureAddressString=pv;function bv(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string")if(li(t)){const e=fi(t,!1);return Buffer.from(e,"hex")}else return Buffer.from(t,"utf8");throw Mr.standardErrors.rpc.invalidParams(`Not binary data: ${String(t)}`)}W.ensureBuffer=bv;function id(t){if(typeof t=="number"&&Number.isInteger(t))return(0,st.IntNumber)(t);if(typeof t=="string"){if(Xh.test(t))return(0,st.IntNumber)(Number(t));if(li(t))return(0,st.IntNumber)(new Qt.default(fi(t,!1),16).toNumber())}throw Mr.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}W.ensureIntNumber=id;function gv(t){if(t instanceof RegExp)return(0,st.RegExpString)(t.toString());throw Mr.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(t)}`)}W.ensureRegExpString=gv;function yv(t){if(t!==null&&(Qt.default.isBN(t)||sd(t)))return new Qt.default(t.toString(10),10);if(typeof t=="number")return new Qt.default(id(t));if(typeof t=="string"){if(Xh.test(t))return new Qt.default(t,10);if(li(t))return new Qt.default(fi(t,!1),16)}throw Mr.standardErrors.rpc.invalidParams(`Not an integer: ${String(t)}`)}W.ensureBN=yv;function vv(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw Mr.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}W.ensureParsedJSONObject=vv;function sd(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}W.isBigNumber=sd;function mv(t,e){return Array.from({length:e-t},(r,n)=>t+n)}W.range=mv;function _v(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:r}=document.location,n=t?t.getAttribute("href"):null;return!n||n.startsWith("javascript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${r}${n}`}W.getFavicon=_v;function wv(t,e,r,n,i,s){const o=n?"parent-id":"id",a=(0,av.stringify)({[o]:t,secret:e,server:r,v:i,chainId:s});return`${r}/#/link?${a}`}W.createQrUrl=wv;function Sv(){try{return window.frameElement!==null}catch{return!1}}W.isInIFrame=Sv;Object.defineProperty(_n,"__esModule",{value:!0});_n.Session=void 0;const wl=eg,Sl=W,El="session:id",Cl="session:secret",xl="session:linked";class Gc{constructor(e,r,n,i){this._storage=e,this._id=r||(0,Sl.randomBytesHex)(16),this._secret=n||(0,Sl.randomBytesHex)(32),this._key=new wl.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!i}static load(e){const r=e.getItem(El),n=e.getItem(xl),i=e.getItem(Cl);return r&&i?new Gc(e,r,i,n==="1"):null}static hash(e){return new wl.sha256().update(e).digest("hex")}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(El,this._id),this._storage.setItem(Cl,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(xl,this._linked?"1":"0")}}_n.Session=Gc;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});pt.WalletSDKRelayAbstract=pt.APP_VERSION_KEY=pt.LOCAL_STORAGE_ADDRESSES_KEY=pt.WALLET_USER_NAME_KEY=void 0;const Il=ni;pt.WALLET_USER_NAME_KEY="walletUsername";pt.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";pt.APP_VERSION_KEY="AppVersion";class Ev{async makeEthereumJSONRPCRequest(e,r){if(!r)throw new Error("Error: No jsonRpcUrl provided");return window.fetch(r,{method:"POST",body:JSON.stringify(e),mode:"cors",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{if(!n)throw Il.standardErrors.rpc.parse({});const i=n,{error:s}=i;if(s)throw(0,Il.serializeError)(s,e.method);return i})}}pt.WalletSDKRelayAbstract=Ev;var pc={exports:{}},od=Nc.EventEmitter,Ea,Rl;function Cv(){if(Rl)return Ea;Rl=1;function t(v,E){var _=Object.keys(v);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(v);E&&(d=d.filter(function(y){return Object.getOwnPropertyDescriptor(v,y).enumerable})),_.push.apply(_,d)}return _}function e(v){for(var E=1;E0?this.tail.next=d:this.head=d,this.tail=d,++this.length}},{key:"unshift",value:function(_){var d={data:_,next:this.head};this.length===0&&(this.tail=d),this.head=d,++this.length}},{key:"shift",value:function(){if(this.length!==0){var _=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,_}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(_){if(this.length===0)return"";for(var d=this.head,y=""+d.data;d=d.next;)y+=_+d.data;return y}},{key:"concat",value:function(_){if(this.length===0)return u.alloc(0);for(var d=u.allocUnsafe(_>>>0),y=this.head,m=0;y;)p(y.data,d,m),m+=y.data.length,y=y.next;return d}},{key:"consume",value:function(_,d){var y;return _x.length?x.length:_;if(C===x.length?m+=x:m+=x.slice(0,_),_-=C,_===0){C===x.length?(++y,d.next?this.head=d.next:this.head=this.tail=null):(this.head=d,d.data=x.slice(C));break}++y}return this.length-=y,m}},{key:"_getBuffer",value:function(_){var d=u.allocUnsafe(_),y=this.head,m=1;for(y.data.copy(d),_-=y.data.length;y=y.next;){var x=y.data,C=_>x.length?x.length:_;if(x.copy(d,d.length-_,0,C),_-=C,_===0){C===x.length?(++m,y.next?this.head=y.next:this.head=this.tail=null):(this.head=y,y.data=x.slice(C));break}++m}return this.length-=m,d}},{key:h,value:function(_,d){return f(this,e(e({},d),{},{depth:0,customInspect:!1}))}}]),v}(),Ea}function xv(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(bc,this,t)):process.nextTick(bc,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(s){!e&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(Ji,r):(r._writableState.errorEmitted=!0,process.nextTick(Al,r,s)):process.nextTick(Al,r,s):e?(process.nextTick(Ji,r),e(s)):process.nextTick(Ji,r)}),this)}function Al(t,e){bc(t,e),Ji(t)}function Ji(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function Iv(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function bc(t,e){t.emit("error",e)}function Rv(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}var ad={destroy:xv,undestroy:Iv,errorOrDestroy:Rv},kr={};function Av(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var cd={};function at(t,e,r){r||(r=Error);function n(s,o,a){return typeof e=="string"?e:e(s,o,a)}var i=function(s){Av(o,s);function o(a,c,u){return s.call(this,n(a,c,u))||this}return o}(r);i.prototype.name=r.name,i.prototype.code=t,cd[t]=i}function Ml(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(n){return String(n)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:r===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}else return"of ".concat(e," ").concat(String(t))}function Mv(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function kv(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function Tv(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}at("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);at("ERR_INVALID_ARG_TYPE",function(t,e,r){var n;typeof e=="string"&&Mv(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";var i;if(kv(t," argument"))i="The ".concat(t," ").concat(n," ").concat(Ml(e,"type"));else{var s=Tv(t,".")?"property":"argument";i='The "'.concat(t,'" ').concat(s," ").concat(n," ").concat(Ml(e,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);at("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");at("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});at("ERR_STREAM_PREMATURE_CLOSE","Premature close");at("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});at("ERR_MULTIPLE_CALLBACK","Callback called multiple times");at("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");at("ERR_STREAM_WRITE_AFTER_END","write after end");at("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);at("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);at("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");kr.codes=cd;var Ov=kr.codes.ERR_INVALID_OPT_VALUE;function Nv(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Lv(t,e,r,n){var i=Nv(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var s=n?r:"highWaterMark";throw new Ov(s,i)}return Math.floor(i)}return t.objectMode?16:16*1024}var ud={getHighWaterMark:Lv},Pv=$v;function $v(t,e){if(Ca("noDeprecation"))return t;var r=!1;function n(){if(!r){if(Ca("throwDeprecation"))throw new Error(e);Ca("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function Ca(t){try{if(!F.localStorage)return!1}catch{return!1}var e=F.localStorage[t];return e==null?!1:String(e).toLowerCase()==="true"}var xa,kl;function ld(){if(kl)return xa;kl=1,xa=$;function t(w){var S=this;this.next=null,this.entry=null,this.finish=function(){We(S,w)}}var e;$.WritableState=T;var r={deprecate:Pv},n=od,i=ps.Buffer,s=(typeof F<"u"?F:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(w){return i.from(w)}function a(w){return i.isBuffer(w)||w instanceof s}var c=ad,u=ud,l=u.getHighWaterMark,f=kr.codes,h=f.ERR_INVALID_ARG_TYPE,p=f.ERR_METHOD_NOT_IMPLEMENTED,v=f.ERR_MULTIPLE_CALLBACK,E=f.ERR_STREAM_CANNOT_PIPE,_=f.ERR_STREAM_DESTROYED,d=f.ERR_STREAM_NULL_VALUES,y=f.ERR_STREAM_WRITE_AFTER_END,m=f.ERR_UNKNOWN_ENCODING,x=c.errorOrDestroy;bt($,n);function C(){}function T(w,S,O){e=e||on(),w=w||{},typeof O!="boolean"&&(O=S instanceof e),this.objectMode=!!w.objectMode,O&&(this.objectMode=this.objectMode||!!w.writableObjectMode),this.highWaterMark=l(this,w,"writableHighWaterMark",O),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var z=w.decodeStrings===!1;this.decodeStrings=!z,this.defaultEncoding=w.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(te){L(S,te)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=w.emitClose!==!1,this.autoDestroy=!!w.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}T.prototype.getBuffer=function(){for(var S=this.bufferedRequest,O=[];S;)O.push(S),S=S.next;return O},function(){try{Object.defineProperty(T.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var j;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(j=Function.prototype[Symbol.hasInstance],Object.defineProperty($,Symbol.hasInstance,{value:function(S){return j.call(this,S)?!0:this!==$?!1:S&&S._writableState instanceof T}})):j=function(S){return S instanceof this};function $(w){e=e||on();var S=this instanceof e;if(!S&&!j.call($,this))return new $(w);this._writableState=new T(w,this,S),this.writable=!0,w&&(typeof w.write=="function"&&(this._write=w.write),typeof w.writev=="function"&&(this._writev=w.writev),typeof w.destroy=="function"&&(this._destroy=w.destroy),typeof w.final=="function"&&(this._final=w.final)),n.call(this)}$.prototype.pipe=function(){x(this,new E)};function A(w,S){var O=new y;x(w,O),process.nextTick(S,O)}function U(w,S,O,z){var te;return O===null?te=new d:typeof O!="string"&&!S.objectMode&&(te=new h("chunk",["string","Buffer"],O)),te?(x(w,te),process.nextTick(z,te),!1):!0}$.prototype.write=function(w,S,O){var z=this._writableState,te=!1,b=!z.objectMode&&a(w);return b&&!i.isBuffer(w)&&(w=o(w)),typeof S=="function"&&(O=S,S=null),b?S="buffer":S||(S=z.defaultEncoding),typeof O!="function"&&(O=C),z.ending?A(this,O):(b||U(this,z,w,O))&&(z.pendingcb++,te=Z(this,z,b,w,S,O)),te},$.prototype.cork=function(){this._writableState.corked++},$.prototype.uncork=function(){var w=this._writableState;w.corked&&(w.corked--,!w.writing&&!w.corked&&!w.bufferProcessing&&w.bufferedRequest&&H(this,w))},$.prototype.setDefaultEncoding=function(S){if(typeof S=="string"&&(S=S.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((S+"").toLowerCase())>-1))throw new m(S);return this._writableState.defaultEncoding=S,this},Object.defineProperty($.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ce(w,S,O){return!w.objectMode&&w.decodeStrings!==!1&&typeof S=="string"&&(S=i.from(S,O)),S}Object.defineProperty($.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Z(w,S,O,z,te,b){if(!O){var g=ce(S,z,te);z!==g&&(O=!0,te="buffer",z=g)}var k=S.objectMode?1:z.length;S.length+=k;var P=S.length>5===6?2:d>>4===14?3:d>>3===30?4:d>>6===2?-1:-2}function o(d,y,m){var x=y.length-1;if(x=0?(C>0&&(d.lastNeed=C-1),C):--x=0?(C>0&&(d.lastNeed=C-2),C):--x=0?(C>0&&(C===2?C=0:d.lastNeed=C-3),C):0))}function a(d,y,m){if((y[0]&192)!==128)return d.lastNeed=0,"�";if(d.lastNeed>1&&y.length>1){if((y[1]&192)!==128)return d.lastNeed=1,"�";if(d.lastNeed>2&&y.length>2&&(y[2]&192)!==128)return d.lastNeed=2,"�"}}function c(d){var y=this.lastTotal-this.lastNeed,m=a(this,d);if(m!==void 0)return m;if(this.lastNeed<=d.length)return d.copy(this.lastChar,y,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);d.copy(this.lastChar,y,0,d.length),this.lastNeed-=d.length}function u(d,y){var m=o(this,d,y);if(!this.lastNeed)return d.toString("utf8",y);this.lastTotal=m;var x=d.length-(m-this.lastNeed);return d.copy(this.lastChar,0,x),d.toString("utf8",y,x)}function l(d){var y=d&&d.length?this.write(d):"";return this.lastNeed?y+"�":y}function f(d,y){if((d.length-y)%2===0){var m=d.toString("utf16le",y);if(m){var x=m.charCodeAt(m.length-1);if(x>=55296&&x<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=d[d.length-2],this.lastChar[1]=d[d.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=d[d.length-1],d.toString("utf16le",y,d.length-1)}function h(d){var y=d&&d.length?this.write(d):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return y+this.lastChar.toString("utf16le",0,m)}return y}function p(d,y){var m=(d.length-y)%3;return m===0?d.toString("base64",y):(this.lastNeed=3-m,this.lastTotal=3,m===1?this.lastChar[0]=d[d.length-1]:(this.lastChar[0]=d[d.length-2],this.lastChar[1]=d[d.length-1]),d.toString("base64",y,d.length-m))}function v(d){var y=d&&d.length?this.write(d):"";return this.lastNeed?y+this.lastChar.toString("base64",0,3-this.lastNeed):y}function E(d){return d.toString(this.encoding)}function _(d){return d&&d.length?this.write(d):""}return Ra}var Ll=kr.codes.ERR_STREAM_PREMATURE_CLOSE;function Dv(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i0)if(typeof g!="string"&&!K.objectMode&&Object.getPrototypeOf(g)!==n.prototype&&(g=s(g)),P)K.endEmitted?C(b,new d):ce(b,K,g,!0);else if(K.ended)C(b,new E);else{if(K.destroyed)return!1;K.reading=!1,K.decoder&&!k?(g=K.decoder.write(g),K.objectMode||g.length!==0?ce(b,K,g,!1):H(b,K)):ce(b,K,g,!1)}else P||(K.reading=!1,H(b,K))}return!K.ended&&(K.length=R?b=R:(b--,b|=b>>>1,b|=b>>>2,b|=b>>>4,b|=b>>>8,b|=b>>>16,b++),b}function N(b,g){return b<=0||g.length===0&&g.ended?0:g.objectMode?1:b!==b?g.flowing&&g.length?g.buffer.head.data.length:g.length:(b>g.highWaterMark&&(g.highWaterMark=M(b)),b<=g.length?b:g.ended?g.length:(g.needReadable=!0,0))}A.prototype.read=function(b){c("read",b),b=parseInt(b,10);var g=this._readableState,k=b;if(b!==0&&(g.emittedReadable=!1),b===0&&g.needReadable&&((g.highWaterMark!==0?g.length>=g.highWaterMark:g.length>0)||g.ended))return c("read: emitReadable",g.length,g.ended),g.length===0&&g.ended?O(this):B(this),null;if(b=N(b,g),b===0&&g.ended)return g.length===0&&O(this),null;var P=g.needReadable;c("need readable",P),(g.length===0||g.length-b0?ge=S(b,g):ge=null,ge===null?(g.needReadable=g.length<=g.highWaterMark,b=0):(g.length-=b,g.awaitDrain=0),g.length===0&&(g.ended||(g.needReadable=!0),k!==b&&g.ended&&O(this)),ge!==null&&this.emit("data",ge),ge};function L(b,g){if(c("onEofChunk"),!g.ended){if(g.decoder){var k=g.decoder.end();k&&k.length&&(g.buffer.push(k),g.length+=g.objectMode?1:k.length)}g.ended=!0,g.sync?B(b):(g.needReadable=!1,g.emittedReadable||(g.emittedReadable=!0,D(b)))}}function B(b){var g=b._readableState;c("emitReadable",g.needReadable,g.emittedReadable),g.needReadable=!1,g.emittedReadable||(c("emitReadable",g.flowing),g.emittedReadable=!0,process.nextTick(D,b))}function D(b){var g=b._readableState;c("emitReadable_",g.destroyed,g.length,g.ended),!g.destroyed&&(g.length||g.ended)&&(b.emit("readable"),g.emittedReadable=!1),g.needReadable=!g.flowing&&!g.ended&&g.length<=g.highWaterMark,w(b)}function H(b,g){g.readingMore||(g.readingMore=!0,process.nextTick(Y,b,g))}function Y(b,g){for(;!g.reading&&!g.ended&&(g.length1&&te(P.pipes,b)!==-1)&&!Tn&&(c("false write response, pause",P.awaitDrain),P.awaitDrain++),k.pause())}function Pr(Nt){c("onerror",Nt),Ut(),b.removeListener("error",Pr),e(b,"error")===0&&C(b,Nt)}j(b,"error",Pr);function $r(){b.removeListener("finish",Dr),Ut()}b.once("close",$r);function Dr(){c("onfinish"),b.removeListener("close",$r),Ut()}b.once("finish",Dr);function Ut(){c("unpipe"),k.unpipe(b)}return b.emit("pipe",k),P.flowing||(c("pipe resume"),k.resume()),b};function J(b){return function(){var k=b._readableState;c("pipeOnDrain",k.awaitDrain),k.awaitDrain&&k.awaitDrain--,k.awaitDrain===0&&e(b,"data")&&(k.flowing=!0,w(b))}}A.prototype.unpipe=function(b){var g=this._readableState,k={hasUnpiped:!1};if(g.pipesCount===0)return this;if(g.pipesCount===1)return b&&b!==g.pipes?this:(b||(b=g.pipes),g.pipes=null,g.pipesCount=0,g.flowing=!1,b&&b.emit("unpipe",this,k),this);if(!b){var P=g.pipes,ge=g.pipesCount;g.pipes=null,g.pipesCount=0,g.flowing=!1;for(var K=0;K0,P.flowing!==!1&&this.resume()):b==="readable"&&!P.endEmitted&&!P.readableListening&&(P.readableListening=P.needReadable=!0,P.flowing=!1,P.emittedReadable=!1,c("on readable",P.length,P.reading),P.length?B(this):P.reading||process.nextTick(he,this)),k},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(b,g){var k=r.prototype.removeListener.call(this,b,g);return b==="readable"&&process.nextTick(se,this),k},A.prototype.removeAllListeners=function(b){var g=r.prototype.removeAllListeners.apply(this,arguments);return(b==="readable"||b===void 0)&&process.nextTick(se,this),g};function se(b){var g=b._readableState;g.readableListening=b.listenerCount("readable")>0,g.resumeScheduled&&!g.paused?g.flowing=!0:b.listenerCount("data")>0&&b.resume()}function he(b){c("readable nexttick read 0"),b.read(0)}A.prototype.resume=function(){var b=this._readableState;return b.flowing||(c("resume"),b.flowing=!b.readableListening,le(this,b)),b.paused=!1,this};function le(b,g){g.resumeScheduled||(g.resumeScheduled=!0,process.nextTick(We,b,g))}function We(b,g){c("resume",g.reading),g.reading||b.read(0),g.resumeScheduled=!1,b.emit("resume"),w(b),g.flowing&&!g.reading&&b.read(0)}A.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function w(b){var g=b._readableState;for(c("flow",g.flowing);g.flowing&&b.read()!==null;);}A.prototype.wrap=function(b){var g=this,k=this._readableState,P=!1;b.on("end",function(){if(c("wrapped end"),k.decoder&&!k.ended){var fe=k.decoder.end();fe&&fe.length&&g.push(fe)}g.push(null)}),b.on("data",function(fe){if(c("wrapped data"),k.decoder&&(fe=k.decoder.write(fe)),!(k.objectMode&&fe==null)&&!(!k.objectMode&&(!fe||!fe.length))){var Ot=g.push(fe);Ot||(P=!0,b.pause())}});for(var ge in b)this[ge]===void 0&&typeof b[ge]=="function"&&(this[ge]=function(Ot){return function(){return b[Ot].apply(b,arguments)}}(ge));for(var K=0;K=g.length?(g.decoder?k=g.buffer.join(""):g.buffer.length===1?k=g.buffer.first():k=g.buffer.concat(g.length),g.buffer.clear()):k=g.buffer.consume(b,g.decoder),k}function O(b){var g=b._readableState;c("endReadable",g.endEmitted),g.endEmitted||(g.ended=!0,process.nextTick(z,g,b))}function z(b,g){if(c("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,g.readable=!1,g.emit("end"),b.autoDestroy)){var k=g._writableState;(!k||k.autoDestroy&&k.finished)&&g.destroy()}}typeof Symbol=="function"&&(A.from=function(b,g){return x===void 0&&(x=Wv()),x(A,b,g)});function te(b,g){for(var k=0,P=b.length;k0;return Xv(o,c,u,function(l){i||(i=l),l&&s.forEach(Fl),!c&&(s.forEach(Fl),n(i))})});return e.reduce(em)}var nm=rm;(function(t,e){e=t.exports=hd(),e.Stream=e,e.Readable=e,e.Writable=ld(),e.Duplex=on(),e.Transform=dd,e.PassThrough=Jv,e.finished=Jc,e.pipeline=nm})(pc,pc.exports);var gd=pc.exports;const{Transform:im}=gd;var sm=t=>class yd extends im{constructor(r,n,i,s,o){super(o),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._hashBitLength=s,this._options=o,this._state=new t,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let s=null;try{this.update(r,n)}catch(o){s=o}i(s)}_flush(r){let n=null;try{this.push(this.digest())}catch(i){n=i}r(n)}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}digest(r){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let n=this._state.squeeze(this._hashBitLength/8);return r!==void 0&&(n=n.toString(r)),this._resetState(),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new yd(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const{Transform:om}=gd;var am=t=>class vd extends om{constructor(r,n,i,s){super(s),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._options=s,this._state=new t,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let s=null;try{this.update(r,n)}catch(o){s=o}i(s)}_flush(){}_read(r){this.push(this.squeeze(r))}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}squeeze(r,n){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let i=this._state.squeeze(r);return n!==void 0&&(i=i.toString(n)),i}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new vd(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const cm=sm,um=am;var lm=function(t){const e=cm(t),r=um(t);return function(n,i){switch(typeof n=="string"?n.toLowerCase():n){case"keccak224":return new e(1152,448,null,224,i);case"keccak256":return new e(1088,512,null,256,i);case"keccak384":return new e(832,768,null,384,i);case"keccak512":return new e(576,1024,null,512,i);case"sha3-224":return new e(1152,448,6,224,i);case"sha3-256":return new e(1088,512,6,256,i);case"sha3-384":return new e(832,768,6,384,i);case"sha3-512":return new e(576,1024,6,512,i);case"shake128":return new r(1344,256,31,i);case"shake256":return new r(1088,512,31,i);default:throw new Error("Invald algorithm: "+n)}}},md={};const Wl=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];md.p1600=function(t){for(let e=0;e<24;++e){const r=t[0]^t[10]^t[20]^t[30]^t[40],n=t[1]^t[11]^t[21]^t[31]^t[41],i=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],o=t[4]^t[14]^t[24]^t[34]^t[44],a=t[5]^t[15]^t[25]^t[35]^t[45],c=t[6]^t[16]^t[26]^t[36]^t[46],u=t[7]^t[17]^t[27]^t[37]^t[47],l=t[8]^t[18]^t[28]^t[38]^t[48],f=t[9]^t[19]^t[29]^t[39]^t[49];let h=l^(i<<1|s>>>31),p=f^(s<<1|i>>>31);const v=t[0]^h,E=t[1]^p,_=t[10]^h,d=t[11]^p,y=t[20]^h,m=t[21]^p,x=t[30]^h,C=t[31]^p,T=t[40]^h,j=t[41]^p;h=r^(o<<1|a>>>31),p=n^(a<<1|o>>>31);const $=t[2]^h,A=t[3]^p,U=t[12]^h,ce=t[13]^p,Z=t[22]^h,R=t[23]^p,M=t[32]^h,N=t[33]^p,L=t[42]^h,B=t[43]^p;h=i^(c<<1|u>>>31),p=s^(u<<1|c>>>31);const D=t[4]^h,H=t[5]^p,Y=t[14]^h,J=t[15]^p,se=t[24]^h,he=t[25]^p,le=t[34]^h,We=t[35]^p,w=t[44]^h,S=t[45]^p;h=o^(l<<1|f>>>31),p=a^(f<<1|l>>>31);const O=t[6]^h,z=t[7]^p,te=t[16]^h,b=t[17]^p,g=t[26]^h,k=t[27]^p,P=t[36]^h,ge=t[37]^p,K=t[46]^h,fe=t[47]^p;h=c^(r<<1|n>>>31),p=u^(n<<1|r>>>31);const Ot=t[8]^h,or=t[9]^p,Tn=t[18]^h,Mi=t[19]^p,On=t[28]^h,Pr=t[29]^p,$r=t[38]^h,Dr=t[39]^p,Ut=t[48]^h,Nt=t[49]^p,vt=v,mo=E,_o=d<<4|_>>>28,wo=_<<4|d>>>28,So=y<<3|m>>>29,Eo=m<<3|y>>>29,Co=C<<9|x>>>23,xo=x<<9|C>>>23,Io=T<<18|j>>>14,Ro=j<<18|T>>>14,Ao=$<<1|A>>>31,Mo=A<<1|$>>>31,ko=ce<<12|U>>>20,To=U<<12|ce>>>20,Oo=Z<<10|R>>>22,No=R<<10|Z>>>22,Lo=N<<13|M>>>19,Po=M<<13|N>>>19,$o=L<<2|B>>>30,Do=B<<2|L>>>30,jo=H<<30|D>>>2,Bo=D<<30|H>>>2,Fo=Y<<6|J>>>26,Wo=J<<6|Y>>>26,Ho=he<<11|se>>>21,Vo=se<<11|he>>>21,Uo=le<<15|We>>>17,zo=We<<15|le>>>17,qo=S<<29|w>>>3,Go=w<<29|S>>>3,Jo=O<<28|z>>>4,Qo=z<<28|O>>>4,Zo=b<<23|te>>>9,Yo=te<<23|b>>>9,Ko=g<<25|k>>>7,Xo=k<<25|g>>>7,ea=P<<21|ge>>>11,ta=ge<<21|P>>>11,ra=fe<<24|K>>>8,na=K<<24|fe>>>8,ia=Ot<<27|or>>>5,sa=or<<27|Ot>>>5,oa=Tn<<20|Mi>>>12,aa=Mi<<20|Tn>>>12,ca=Pr<<7|On>>>25,ua=On<<7|Pr>>>25,la=$r<<8|Dr>>>24,fa=Dr<<8|$r>>>24,ha=Ut<<14|Nt>>>18,da=Nt<<14|Ut>>>18;t[0]=vt^~ko&Ho,t[1]=mo^~To&Vo,t[10]=Jo^~oa&So,t[11]=Qo^~aa&Eo,t[20]=Ao^~Fo&Ko,t[21]=Mo^~Wo&Xo,t[30]=ia^~_o&Oo,t[31]=sa^~wo&No,t[40]=jo^~Zo&ca,t[41]=Bo^~Yo&ua,t[2]=ko^~Ho&ea,t[3]=To^~Vo&ta,t[12]=oa^~So&Lo,t[13]=aa^~Eo&Po,t[22]=Fo^~Ko&la,t[23]=Wo^~Xo&fa,t[32]=_o^~Oo&Uo,t[33]=wo^~No&zo,t[42]=Zo^~ca&Co,t[43]=Yo^~ua&xo,t[4]=Ho^~ea&ha,t[5]=Vo^~ta&da,t[14]=So^~Lo&qo,t[15]=Eo^~Po&Go,t[24]=Ko^~la&Io,t[25]=Xo^~fa&Ro,t[34]=Oo^~Uo&ra,t[35]=No^~zo&na,t[44]=ca^~Co&$o,t[45]=ua^~xo&Do,t[6]=ea^~ha&vt,t[7]=ta^~da&mo,t[16]=Lo^~qo&Jo,t[17]=Po^~Go&Qo,t[26]=la^~Io&Ao,t[27]=fa^~Ro&Mo,t[36]=Uo^~ra&ia,t[37]=zo^~na&sa,t[46]=Co^~$o&jo,t[47]=xo^~Do&Bo,t[8]=ha^~vt&ko,t[9]=da^~mo&To,t[18]=qo^~Jo&oa,t[19]=Go^~Qo&aa,t[28]=Io^~Ao&Fo,t[29]=Ro^~Mo&Wo,t[38]=ra^~ia&_o,t[39]=na^~sa&wo,t[48]=$o^~jo&Zo,t[49]=Do^~Bo&Yo,t[0]^=Wl[e*2],t[1]^=Wl[e*2+1]}};const is=md;function En(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}En.prototype.initialize=function(t,e){for(let r=0;r<50;++r)this.state[r]=0;this.blockSize=t/8,this.count=0,this.squeezing=!1};En.prototype.absorb=function(t){for(let e=0;e>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(is.p1600(this.state),this.count=0);return e};En.prototype.copy=function(t){for(let e=0;e<50;++e)t.state[e]=this.state[e];t.blockSize=this.blockSize,t.count=this.count,t.squeezing=this.squeezing};var fm=En,hm=lm(fm);const dm=hm,pm=ds;function _d(t){return Buffer.allocUnsafe(t).fill(0)}function wd(t,e,r){const n=_d(e);return t=Is(t),r?t.length"u")throw new Error("Not an array?");if(r=Id(t),r!=="dynamic"&&r!==0&&e.length>r)throw new Error("Elements exceed array size: "+r);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(s in e)i.push(Et(t,e[s]));if(r==="dynamic"){var o=Et("uint256",e.length);i.unshift(o)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([Et("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,wr.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(r=Yr(t),r<1||r>32)throw new Error("Invalid bytes width: "+r);return wr.setLengthRight(e,32)}else if(t.startsWith("uint")){if(r=Yr(t),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=fr(e),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());if(n<0)throw new Error("Supplied uint is negative");return n.toArrayLike(Buffer,"be",32)}else if(t.startsWith("int")){if(r=Yr(t),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=fr(e),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());return n.toTwos(256).toArrayLike(Buffer,"be",32)}else if(t.startsWith("ufixed")){if(r=Hl(t),n=fr(e),n<0)throw new Error("Supplied ufixed is negative");return Et("uint256",n.mul(new gr(2).pow(new gr(r[1]))))}else if(t.startsWith("fixed"))return r=Hl(t),Et("int256",fr(e).mul(new gr(2).pow(new gr(r[1]))))}throw new Error("Unsupported or invalid type: "+t)}function mm(t){return t==="string"||t==="bytes"||Id(t)==="dynamic"}function _m(t){return t.lastIndexOf("]")===t.length-1}function wm(t,e){var r=[],n=[],i=32*t.length;for(var s in t){var o=xd(t[s]),a=e[s],c=Et(o,a);mm(o)?(r.push(Et("uint256",i)),n.push(c),i+=c.length):r.push(c)}return Buffer.concat(r.concat(n))}function Rd(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var r,n,i=[],s=0;s32)throw new Error("Invalid bytes width: "+r);i.push(wr.setLengthRight(a,r))}else if(o.startsWith("uint")){if(r=Yr(o),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=fr(a),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());i.push(n.toArrayLike(Buffer,"be",r/8))}else if(o.startsWith("int")){if(r=Yr(o),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=fr(a),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());i.push(n.toTwos(r).toArrayLike(Buffer,"be",r/8))}else throw new Error("Unsupported or invalid type: "+o)}return Buffer.concat(i)}function Sm(t,e){return wr.keccak(Rd(t,e))}var Em={rawEncode:wm,solidityPack:Rd,soliditySHA3:Sm};const ft=Cd,Un=Em,Ad={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Oa={encodeData(t,e,r,n=!0){const i=["bytes32"],s=[this.hashType(t,r)];if(n){const o=(a,c,u)=>{if(r[c]!==void 0)return["bytes32",u==null?"0x0000000000000000000000000000000000000000000000000000000000000000":ft.keccak(this.encodeData(c,u,r,n))];if(u===void 0)throw new Error(`missing value for field ${a} of type ${c}`);if(c==="bytes")return["bytes32",ft.keccak(u)];if(c==="string")return typeof u=="string"&&(u=Buffer.from(u,"utf8")),["bytes32",ft.keccak(u)];if(c.lastIndexOf("]")===c.length-1){const l=c.slice(0,c.lastIndexOf("[")),f=u.map(h=>o(a,l,h));return["bytes32",ft.keccak(Un.rawEncode(f.map(([h])=>h),f.map(([,h])=>h)))]}return[c,u]};for(const a of r[t]){const[c,u]=o(a.name,a.type,e[a.name]);i.push(c),s.push(u)}}else for(const o of r[t]){let a=e[o.name];if(a!==void 0)if(o.type==="bytes")i.push("bytes32"),a=ft.keccak(a),s.push(a);else if(o.type==="string")i.push("bytes32"),typeof a=="string"&&(a=Buffer.from(a,"utf8")),a=ft.keccak(a),s.push(a);else if(r[o.type]!==void 0)i.push("bytes32"),a=ft.keccak(this.encodeData(o.type,a,r,n)),s.push(a);else{if(o.type.lastIndexOf("]")===o.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(o.type),s.push(a)}}return Un.rawEncode(i,s)},encodeType(t,e){let r="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);r+=i+"("+e[i].map(({name:o,type:a})=>a+" "+o).join(",")+")"}return r},findTypeDependencies(t,e,r=[]){if(t=t.match(/^\w*/)[0],r.includes(t)||e[t]===void 0)return r;r.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,r))!r.includes(i)&&r.push(i);return r},hashStruct(t,e,r,n=!0){return ft.keccak(this.encodeData(t,e,r,n))},hashType(t,e){return ft.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const r in Ad.properties)t[r]&&(e[r]=t[r]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const r=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",r.domain,r.types,e)),r.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(r.primaryType,r.message,r.types,e)),ft.keccak(Buffer.concat(n))}};var Cm={TYPED_MESSAGE_SCHEMA:Ad,TypedDataUtils:Oa,hashForSignTypedDataLegacy:function(t){return xm(t.data)},hashForSignTypedData_v3:function(t){return Oa.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return Oa.hash(t.data)}};function xm(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const r=t.map(function(s){return s.type==="bytes"?ft.toBuffer(s.value):s.value}),n=t.map(function(s){return s.type}),i=t.map(function(s){if(!s.name)throw e;return s.type+" "+s.name});return Un.soliditySHA3(["bytes32","bytes32"],[Un.soliditySHA3(new Array(t.length).fill("string"),i),Un.soliditySHA3(n,r)])}var an={};Object.defineProperty(an,"__esModule",{value:!0});an.filterFromParam=an.FilterPolyfill=void 0;const qr=ui,He=W,Im=5*60*1e3,hr={jsonrpc:"2.0",id:0};class Rm{constructor(e){this.logFilters=new Map,this.blockFilters=new Set,this.pendingTransactionFilters=new Set,this.cursors=new Map,this.timeouts=new Map,this.nextFilterId=(0,qr.IntNumber)(1),this.provider=e}async newFilter(e){const r=Md(e),n=this.makeFilterId(),i=await this.setInitialCursorPosition(n,r.fromBlock);return console.log(`Installing new log filter(${n}):`,r,"initial cursor position:",i),this.logFilters.set(n,r),this.setFilterTimeout(n),(0,He.hexStringFromIntNumber)(n)}async newBlockFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.log(`Installing new block filter (${e}) with initial cursor position:`,r),this.blockFilters.add(e),this.setFilterTimeout(e),(0,He.hexStringFromIntNumber)(e)}async newPendingTransactionFilter(){const e=this.makeFilterId(),r=await this.setInitialCursorPosition(e,"latest");return console.log(`Installing new block filter (${e}) with initial cursor position:`,r),this.pendingTransactionFilters.add(e),this.setFilterTimeout(e),(0,He.hexStringFromIntNumber)(e)}uninstallFilter(e){const r=(0,He.intNumberFromHexString)(e);return console.log(`Uninstalling filter (${r})`),this.deleteFilter(r),!0}getFilterChanges(e){const r=(0,He.intNumberFromHexString)(e);return this.timeouts.has(r)&&this.setFilterTimeout(r),this.logFilters.has(r)?this.getLogFilterChanges(r):this.blockFilters.has(r)?this.getBlockFilterChanges(r):this.pendingTransactionFilters.has(r)?this.getPendingTransactionFilterChanges(r):Promise.resolve(Ni())}async getFilterLogs(e){const r=(0,He.intNumberFromHexString)(e),n=this.logFilters.get(r);return n?this.sendAsyncPromise(Object.assign(Object.assign({},hr),{method:"eth_getLogs",params:[Vl(n)]})):Ni()}makeFilterId(){return(0,qr.IntNumber)(++this.nextFilterId)}sendAsyncPromise(e){return new Promise((r,n)=>{this.provider.sendAsync(e,(i,s)=>{if(i)return n(i);if(Array.isArray(s)||s==null)return n(new Error(`unexpected response received: ${JSON.stringify(s)}`));r(s)})})}deleteFilter(e){console.log(`Deleting filter (${e})`),this.logFilters.delete(e),this.blockFilters.delete(e),this.pendingTransactionFilters.delete(e),this.cursors.delete(e),this.timeouts.delete(e)}async getLogFilterChanges(e){const r=this.logFilters.get(e),n=this.cursors.get(e);if(!n||!r)return Ni();const i=await this.getCurrentBlockHeight(),s=r.toBlock==="latest"?i:r.toBlock;if(n>i||n>r.toBlock)return Li();console.log(`Fetching logs from ${n} to ${s} for filter ${e}`);const o=await this.sendAsyncPromise(Object.assign(Object.assign({},hr),{method:"eth_getLogs",params:[Vl(Object.assign(Object.assign({},r),{fromBlock:n,toBlock:s}))]}));if(Array.isArray(o.result)){const a=o.result.map(u=>(0,He.intNumberFromHexString)(u.blockNumber||"0x0")),c=Math.max(...a);if(c&&c>n){const u=(0,qr.IntNumber)(c+1);console.log(`Moving cursor position for filter (${e}) from ${n} to ${u}`),this.cursors.set(e,u)}}return o}async getBlockFilterChanges(e){const r=this.cursors.get(e);if(!r)return Ni();const n=await this.getCurrentBlockHeight();if(r>n)return Li();console.log(`Fetching blocks from ${r} to ${n} for filter (${e})`);const i=(await Promise.all((0,He.range)(r,n+1).map(o=>this.getBlockHashByNumber((0,qr.IntNumber)(o))))).filter(o=>!!o),s=(0,qr.IntNumber)(r+i.length);return console.log(`Moving cursor position for filter (${e}) from ${r} to ${s}`),this.cursors.set(e,s),Object.assign(Object.assign({},hr),{result:i})}async getPendingTransactionFilterChanges(e){return Promise.resolve(Li())}async setInitialCursorPosition(e,r){const n=await this.getCurrentBlockHeight(),i=typeof r=="number"&&r>n?r:n;return this.cursors.set(e,i),i}setFilterTimeout(e){const r=this.timeouts.get(e);r&&window.clearTimeout(r);const n=window.setTimeout(()=>{console.log(`Filter (${e}) timed out`),this.deleteFilter(e)},Im);this.timeouts.set(e,n)}async getCurrentBlockHeight(){const{result:e}=await this.sendAsyncPromise(Object.assign(Object.assign({},hr),{method:"eth_blockNumber",params:[]}));return(0,He.intNumberFromHexString)((0,He.ensureHexString)(e))}async getBlockHashByNumber(e){const r=await this.sendAsyncPromise(Object.assign(Object.assign({},hr),{method:"eth_getBlockByNumber",params:[(0,He.hexStringFromIntNumber)(e),!1]}));return r.result&&typeof r.result.hash=="string"?(0,He.ensureHexString)(r.result.hash):null}}an.FilterPolyfill=Rm;function Md(t){return{fromBlock:Ul(t.fromBlock),toBlock:Ul(t.toBlock),addresses:t.address===void 0?null:Array.isArray(t.address)?t.address:[t.address],topics:t.topics||[]}}an.filterFromParam=Md;function Vl(t){const e={fromBlock:zl(t.fromBlock),toBlock:zl(t.toBlock),topics:t.topics};return t.addresses!==null&&(e.address=t.addresses),e}function Ul(t){if(t===void 0||t==="latest"||t==="pending")return"latest";if(t==="earliest")return(0,qr.IntNumber)(0);if((0,He.isHexString)(t))return(0,He.intNumberFromHexString)(t);throw new Error(`Invalid block option: ${String(t)}`)}function zl(t){return t==="latest"?t:(0,He.hexStringFromIntNumber)(t)}function Ni(){return Object.assign(Object.assign({},hr),{error:{code:-32e3,message:"filter not found"}})}function Li(){return Object.assign(Object.assign({},hr),{result:[]})}var kd={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.JSONRPCMethod=void 0,function(e){e.eth_accounts="eth_accounts",e.eth_coinbase="eth_coinbase",e.net_version="net_version",e.eth_chainId="eth_chainId",e.eth_uninstallFilter="eth_uninstallFilter",e.eth_requestAccounts="eth_requestAccounts",e.eth_sign="eth_sign",e.eth_ecRecover="eth_ecRecover",e.personal_sign="personal_sign",e.personal_ecRecover="personal_ecRecover",e.eth_signTransaction="eth_signTransaction",e.eth_sendRawTransaction="eth_sendRawTransaction",e.eth_sendTransaction="eth_sendTransaction",e.eth_signTypedData_v1="eth_signTypedData_v1",e.eth_signTypedData_v2="eth_signTypedData_v2",e.eth_signTypedData_v3="eth_signTypedData_v3",e.eth_signTypedData_v4="eth_signTypedData_v4",e.eth_signTypedData="eth_signTypedData",e.cbWallet_arbitrary="walletlink_arbitrary",e.wallet_addEthereumChain="wallet_addEthereumChain",e.wallet_switchEthereumChain="wallet_switchEthereumChain",e.wallet_watchAsset="wallet_watchAsset",e.eth_subscribe="eth_subscribe",e.eth_unsubscribe="eth_unsubscribe",e.eth_newFilter="eth_newFilter",e.eth_newBlockFilter="eth_newBlockFilter",e.eth_newPendingTransactionFilter="eth_newPendingTransactionFilter",e.eth_getFilterChanges="eth_getFilterChanges",e.eth_getFilterLogs="eth_getFilterLogs"}(t.JSONRPCMethod||(t.JSONRPCMethod={}))})(kd);var Rs={},Td={},As={},Qc=Am;function Am(t){t=t||{};var e=t.max||Number.MAX_SAFE_INTEGER,r=typeof t.start<"u"?t.start:Math.floor(Math.random()*e);return function(){return r=r%e,r++}}const ql=(t,e)=>function(){const r=e.promiseModule,n=new Array(arguments.length);for(let i=0;i{e.errorFirst?n.push(function(o,a){if(e.multiArgs){const c=new Array(arguments.length-1);for(let u=1;u{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);const r=i=>{const s=o=>typeof o=="string"?i===o:o.test(i);return e.include?e.include.some(s):!e.exclude.some(s)};let n;typeof t=="function"?n=function(){return e.excludeMain?t.apply(this,arguments):ql(t,e).apply(this,arguments)}:n=Object.create(Object.getPrototypeOf(t));for(const i in t){const s=t[i];n[i]=typeof s=="function"&&r(i)?ql(s,e):s}return n},hi={},km=F&&F.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(hi,"__esModule",{value:!0});hi.BaseBlockTracker=void 0;const Tm=km(Ir),Om=1e3,Nm=(t,e)=>t+e,Gl=["sync","latest"];class Lm extends Tm.default{constructor(e){super(),this._blockResetDuration=e.blockResetDuration||20*Om,this._currentBlock=null,this._isRunning=!1,this._onNewListener=this._onNewListener.bind(this),this._onRemoveListener=this._onRemoveListener.bind(this),this._resetCurrentBlock=this._resetCurrentBlock.bind(this),this._setupInternalEvents()}async destroy(){this._cancelBlockResetTimeout(),await this._maybeEnd(),super.removeAllListeners()}isRunning(){return this._isRunning}getCurrentBlock(){return this._currentBlock}async getLatestBlock(){return this._currentBlock?this._currentBlock:await new Promise(r=>this.once("latest",r))}removeAllListeners(e){return e?super.removeAllListeners(e):super.removeAllListeners(),this._setupInternalEvents(),this._onRemoveListener(),this}_setupInternalEvents(){this.removeListener("newListener",this._onNewListener),this.removeListener("removeListener",this._onRemoveListener),this.on("newListener",this._onNewListener),this.on("removeListener",this._onRemoveListener)}_onNewListener(e){Gl.includes(e)&&this._maybeStart()}_onRemoveListener(){this._getBlockTrackerEventCount()>0||this._maybeEnd()}async _maybeStart(){this._isRunning||(this._isRunning=!0,this._cancelBlockResetTimeout(),await this._start(),this.emit("_started"))}async _maybeEnd(){this._isRunning&&(this._isRunning=!1,this._setupBlockResetTimeout(),await this._end(),this.emit("_ended"))}_getBlockTrackerEventCount(){return Gl.map(e=>this.listenerCount(e)).reduce(Nm)}_newPotentialLatest(e){const r=this._currentBlock;r&&Jl(e)<=Jl(r)||this._setCurrentBlock(e)}_setCurrentBlock(e){const r=this._currentBlock;this._currentBlock=e,this.emit("latest",e),this.emit("sync",{oldBlock:r,newBlock:e})}_setupBlockResetTimeout(){this._cancelBlockResetTimeout(),this._blockResetTimeout=setTimeout(this._resetCurrentBlock,this._blockResetDuration),this._blockResetTimeout.unref&&this._blockResetTimeout.unref()}_cancelBlockResetTimeout(){this._blockResetTimeout&&clearTimeout(this._blockResetTimeout)}_resetCurrentBlock(){this._currentBlock=null}}hi.BaseBlockTracker=Lm;function Jl(t){return Number.parseInt(t,16)}var Od={},Nd={},$e={};class Ld extends TypeError{constructor(e,r){let n;const{message:i,explanation:s,...o}=e,{path:a}=e,c=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??c),s!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Pm(t){return ot(t)&&typeof t[Symbol.iterator]=="function"}function ot(t){return typeof t=="object"&&t!=null}function Ql(t){if(Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Re(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function $m(t){const{done:e,value:r}=t.next();return e?void 0:r}function Dm(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:o}=r,{refinement:a,message:c=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Re(n)}\``}=t;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:c}}function*gc(t,e,r,n){Pm(t)||(t=[t]);for(const i of t){const s=Dm(i,e,r,n);s&&(yield s)}}function*Zc(t,e,r={}){const{path:n=[],branch:i=[t],coerce:s=!1,mask:o=!1}=r,a={path:n,branch:i};if(s&&(t=e.coercer(t,a),o&&e.type!=="type"&&ot(e.schema)&&ot(t)&&!Array.isArray(t)))for(const u in t)e.schema[u]===void 0&&delete t[u];let c="valid";for(const u of e.validator(t,a))u.explanation=r.message,c="not_valid",yield[u,void 0];for(let[u,l,f]of e.entries(t,a)){const h=Zc(l,f,{path:u===void 0?n:[...n,u],branch:u===void 0?i:[...i,l],coerce:s,mask:o,message:r.message});for(const p of h)p[0]?(c=p[0].refinement!=null?"not_refined":"not_valid",yield[p[0],void 0]):s&&(l=p[1],u===void 0?t=l:t instanceof Map?t.set(u,l):t instanceof Set?t.add(l):ot(t)&&(l!==void 0||u in t)&&(t[u]=l))}if(c!=="not_valid")for(const u of e.refiner(t,a))u.explanation=r.message,c="not_refined",yield[u,void 0];c==="valid"&&(yield[void 0,t])}class Ce{constructor(e){const{type:r,schema:n,validator:i,refiner:s,coercer:o=c=>c,entries:a=function*(){}}=e;this.type=r,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(c,u)=>{const l=i(c,u);return gc(l,u,this,c)}:this.validator=()=>[],s?this.refiner=(c,u)=>{const l=s(c,u);return gc(l,u,this,c)}:this.refiner=()=>[]}assert(e,r){return Pd(e,this,r)}create(e,r){return $d(e,this,r)}is(e){return Yc(e,this)}mask(e,r){return Dd(e,this,r)}validate(e,r={}){return Cn(e,this,r)}}function Pd(t,e,r){const n=Cn(t,e,{message:r});if(n[0])throw n[0]}function $d(t,e,r){const n=Cn(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Dd(t,e,r){const n=Cn(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function Yc(t,e){return!Cn(t,e)[0]}function Cn(t,e,r={}){const n=Zc(t,e,r),i=$m(n);return i[0]?[new Ld(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function jm(...t){const e=t[0].type==="type",r=t.map(i=>i.schema),n=Object.assign({},...r);return e?Xc(n):di(n)}function Je(t,e){return new Ce({type:t,schema:null,validator:e})}function Bm(t,e){return new Ce({...t,refiner:(r,n)=>r===void 0||t.refiner(r,n),validator(r,n){return r===void 0?!0:(e(r,n),t.validator(r,n))}})}function Fm(t){return new Ce({type:"dynamic",schema:null,*entries(e,r){yield*t(e,r).entries(e,r)},validator(e,r){return t(e,r).validator(e,r)},coercer(e,r){return t(e,r).coercer(e,r)},refiner(e,r){return t(e,r).refiner(e,r)}})}function Wm(t){let e;return new Ce({type:"lazy",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator(r,n){return e??(e=t()),e.validator(r,n)},coercer(r,n){return e??(e=t()),e.coercer(r,n)},refiner(r,n){return e??(e=t()),e.refiner(r,n)}})}function Hm(t,e){const{schema:r}=t,n={...r};for(const i of e)delete n[i];switch(t.type){case"type":return Xc(n);default:return di(n)}}function Vm(t){const e=t instanceof Ce?{...t.schema}:{...t};for(const r in e)e[r]=jd(e[r]);return di(e)}function Um(t,e){const{schema:r}=t,n={};for(const i of e)n[i]=r[i];return di(n)}function zm(t,e){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),Je(t,e)}function qm(){return Je("any",()=>!0)}function Gm(t){return new Ce({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Re(e)}`}})}function Jm(){return Je("bigint",t=>typeof t=="bigint")}function Qm(){return Je("boolean",t=>typeof t=="boolean")}function Zm(){return Je("date",t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \`Date\` object, but received: ${Re(t)}`)}function Ym(t){const e={},r=t.map(n=>Re(n)).join();for(const n of t)e[n]=n;return new Ce({type:"enums",schema:e,validator(n){return t.includes(n)||`Expected one of \`${r}\`, but received: ${Re(n)}`}})}function Km(){return Je("func",t=>typeof t=="function"||`Expected a function, but received: ${Re(t)}`)}function Xm(t){return Je("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${Re(e)}`)}function e1(){return Je("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${Re(t)}`)}function t1(t){return new Ce({type:"intersection",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function r1(t){const e=Re(t),r=typeof t;return new Ce({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${Re(n)}`}})}function n1(t,e){return new Ce({type:"map",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer(r){return r instanceof Map?new Map(r):r},validator(r){return r instanceof Map||`Expected a \`Map\` object, but received: ${Re(r)}`}})}function Kc(){return Je("never",()=>!1)}function i1(t){return new Ce({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function s1(){return Je("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${Re(t)}`)}function di(t){const e=t?Object.keys(t):[],r=Kc();return new Ce({type:"object",schema:t||null,*entries(n){if(t&&ot(n)){const i=new Set(Object.keys(n));for(const s of e)i.delete(s),yield[s,n[s],t[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return ot(n)||`Expected an object, but received: ${Re(n)}`},coercer(n){return ot(n)?{...n}:n}})}function jd(t){return new Ce({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function o1(t,e){return new Ce({type:"record",schema:null,*entries(r){if(ot(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator(r){return ot(r)||`Expected an object, but received: ${Re(r)}`}})}function a1(){return Je("regexp",t=>t instanceof RegExp)}function c1(t){return new Ce({type:"set",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||`Expected a \`Set\` object, but received: ${Re(e)}`}})}function Bd(){return Je("string",t=>typeof t=="string"||`Expected a string, but received: ${Re(t)}`)}function u1(t){const e=Kc();return new Ce({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;ir.type).join(" | ");return new Ce({type:"union",schema:null,coercer(r){for(const n of t){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of t){const[...o]=Zc(r,s,n),[a]=o;if(a[0])for(const[c]of o)c&&i.push(c);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Re(r)}`,...i]}})}function Fd(){return Je("unknown",()=>!0)}function eu(t,e,r){return new Ce({...t,coercer:(n,i)=>Yc(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function f1(t,e,r={}){return eu(t,Fd(),n=>{const i=typeof e=="function"?e():e;if(n===void 0)return i;if(!r.strict&&Ql(n)&&Ql(i)){const s={...n};let o=!1;for(const a in i)s[a]===void 0&&(s[a]=i[a],o=!0);if(o)return s}return n})}function h1(t){return eu(t,Bd(),e=>e.trim())}function d1(t){return Tr(t,"empty",e=>{const r=Wd(e);return r===0||`Expected an empty ${t.type} but received one with a size of \`${r}\``})}function Wd(t){return t instanceof Map||t instanceof Set?t.size:t.length}function p1(t,e,r={}){const{exclusive:n}=r;return Tr(t,"max",i=>n?in?i>e:i>=e||`Expected a ${t.type} greater than ${n?"":"or equal to "}${e} but received \`${i}\``)}function g1(t){return Tr(t,"nonempty",e=>Wd(e)>0||`Expected a nonempty ${t.type} but received an empty one`)}function y1(t,e){return Tr(t,"pattern",r=>e.test(r)||`Expected a ${t.type} matching \`/${e.source}/\` but received "${r}"`)}function v1(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \`${e}\``:`between \`${e}\` and \`${r}\``;return Tr(t,"size",s=>{if(typeof s=="number"||s instanceof Date)return e<=s&&s<=r||`${n} ${i} but received \`${s}\``;if(s instanceof Map||s instanceof Set){const{size:o}=s;return e<=o&&o<=r||`${n} with a size ${i} but received one with a size of \`${o}\``}else{const{length:o}=s;return e<=o&&o<=r||`${n} with a length ${i} but received one with a length of \`${o}\``}})}function Tr(t,e,r){return new Ce({...t,*refiner(n,i){yield*t.refiner(n,i);const s=r(n,i),o=gc(s,i,t,n);for(const a of o)yield{...a,refinement:e}}})}const m1=Object.freeze(Object.defineProperty({__proto__:null,Struct:Ce,StructError:Ld,any:qm,array:Gm,assert:Pd,assign:jm,bigint:Jm,boolean:Qm,coerce:eu,create:$d,date:Zm,defaulted:f1,define:Je,deprecated:Bm,dynamic:Fm,empty:d1,enums:Ym,func:Km,instance:Xm,integer:e1,intersection:t1,is:Yc,lazy:Wm,literal:r1,map:n1,mask:Dd,max:p1,min:b1,never:Kc,nonempty:g1,nullable:i1,number:s1,object:di,omit:Hm,optional:jd,partial:Vm,pattern:y1,pick:Um,record:o1,refine:Tr,regexp:a1,set:c1,size:v1,string:Bd,struct:zm,trimmed:h1,tuple:u1,type:Xc,union:l1,unknown:Fd,validate:Cn},Symbol.toStringTag,{value:"Module"})),Or=xr(m1);Object.defineProperty($e,"__esModule",{value:!0});$e.assertExhaustive=$e.assertStruct=$e.assert=$e.AssertionError=void 0;const _1=Or;function w1(t){return typeof t=="object"&&t!==null&&"message"in t}function S1(t){var e,r;return typeof((r=(e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.name)=="string"}function E1(t){const e=w1(t)?t.message:String(t);return e.endsWith(".")?e.slice(0,-1):e}function Hd(t,e){return S1(t)?new t({message:e}):t({message:e})}class tu extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}$e.AssertionError=tu;function C1(t,e="Assertion failed.",r=tu){if(!t)throw e instanceof Error?e:Hd(r,e)}$e.assert=C1;function x1(t,e,r="Assertion failed",n=tu){try{(0,_1.assert)(t,e)}catch(i){throw Hd(n,`${r}: ${E1(i)}.`)}}$e.assertStruct=x1;function I1(t){throw new Error("Invalid branch reached. Should be detected during compilation.")}$e.assertExhaustive=I1;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});pi.base64=void 0;const R1=Or,A1=$e,M1=(t,e={})=>{var r,n;const i=(r=e.paddingRequired)!==null&&r!==void 0?r:!1,s=(n=e.characterSet)!==null&&n!==void 0?n:"base64";let o;s==="base64"?o=String.raw`[A-Za-z0-9+\/]`:((0,A1.assert)(s==="base64url"),o=String.raw`[-_A-Za-z0-9]`);let a;return i?a=new RegExp(`^(?:${o}{4})*(?:${o}{3}=|${o}{2}==)?$`,"u"):a=new RegExp(`^(?:${o}{4})*(?:${o}{2,3}|${o}{3}=|${o}{2}==)?$`,"u"),(0,R1.pattern)(t,a)};pi.base64=M1;var oe={},bi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.remove0x=t.add0x=t.assertIsStrictHexString=t.assertIsHexString=t.isStrictHexString=t.isHexString=t.StrictHexStruct=t.HexStruct=void 0;const e=Or,r=$e;t.HexStruct=(0,e.pattern)((0,e.string)(),/^(?:0x)?[0-9a-f]+$/iu),t.StrictHexStruct=(0,e.pattern)((0,e.string)(),/^0x[0-9a-f]+$/iu);function n(u){return(0,e.is)(u,t.HexStruct)}t.isHexString=n;function i(u){return(0,e.is)(u,t.StrictHexStruct)}t.isStrictHexString=i;function s(u){(0,r.assert)(n(u),"Value must be a hexadecimal string.")}t.assertIsHexString=s;function o(u){(0,r.assert)(i(u),'Value must be a hexadecimal string, starting with "0x".')}t.assertIsStrictHexString=o;function a(u){return u.startsWith("0x")?u:u.startsWith("0X")?`0x${u.substring(2)}`:`0x${u}`}t.add0x=a;function c(u){return u.startsWith("0x")||u.startsWith("0X")?u.substring(2):u}t.remove0x=c})(bi);Object.defineProperty(oe,"__esModule",{value:!0});oe.createDataView=oe.concatBytes=oe.valueToBytes=oe.stringToBytes=oe.numberToBytes=oe.signedBigIntToBytes=oe.bigIntToBytes=oe.hexToBytes=oe.bytesToString=oe.bytesToNumber=oe.bytesToSignedBigInt=oe.bytesToBigInt=oe.bytesToHex=oe.assertIsBytes=oe.isBytes=void 0;const Ze=$e,yc=bi,Zl=48,Yl=58,Kl=87;function k1(){const t=[];return()=>{if(t.length===0)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,"0"));return t}}const T1=k1();function ru(t){return t instanceof Uint8Array}oe.isBytes=ru;function xn(t){(0,Ze.assert)(ru(t),"Value must be a Uint8Array.")}oe.assertIsBytes=xn;function Vd(t){if(xn(t),t.length===0)return"0x";const e=T1(),r=new Array(t.length);for(let n=0;n=BigInt(0),"Value must be a non-negative bigint.");const e=t.toString(16);return Ms(e)}oe.bigIntToBytes=zd;function P1(t,e){(0,Ze.assert)(e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(e*8+-1))}function $1(t,e){(0,Ze.assert)(typeof t=="bigint","Value must be a bigint."),(0,Ze.assert)(typeof e=="number","Byte length must be a number."),(0,Ze.assert)(e>0,"Byte length must be greater than 0."),(0,Ze.assert)(P1(t,e),"Byte length is too small to represent the given value.");let r=t;const n=new Uint8Array(e);for(let i=0;i>=BigInt(8);return n.reverse()}oe.signedBigIntToBytes=$1;function qd(t){(0,Ze.assert)(typeof t=="number","Value must be a number."),(0,Ze.assert)(t>=0,"Value must be a non-negative number."),(0,Ze.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToBytes` instead.");const e=t.toString(16);return Ms(e)}oe.numberToBytes=qd;function Gd(t){return(0,Ze.assert)(typeof t=="string","Value must be a string."),new TextEncoder().encode(t)}oe.stringToBytes=Gd;function Jd(t){if(typeof t=="bigint")return zd(t);if(typeof t=="number")return qd(t);if(typeof t=="string")return t.startsWith("0x")?Ms(t):Gd(t);if(ru(t))return t;throw new TypeError(`Unsupported value type: "${typeof t}".`)}oe.valueToBytes=Jd;function D1(t){const e=new Array(t.length);let r=0;for(let i=0;ie.call(r,n,i,this))}get(e){return Ve(this,ut,"f").get(e)}has(e){return Ve(this,ut,"f").has(e)}keys(){return Ve(this,ut,"f").keys()}values(){return Ve(this,ut,"f").values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map(([e,r])=>`${String(e)} => ${String(r)}`).join(", ")} `:""}}`}}cn.FrozenMap=nu;class iu{constructor(e){_t.set(this,void 0),Yd(this,_t,new Set(e),"f"),Object.freeze(this)}get size(){return Ve(this,_t,"f").size}[(_t=new WeakMap,Symbol.iterator)](){return Ve(this,_t,"f")[Symbol.iterator]()}entries(){return Ve(this,_t,"f").entries()}forEach(e,r){return Ve(this,_t,"f").forEach((n,i,s)=>e.call(r,n,i,this))}has(e){return Ve(this,_t,"f").has(e)}keys(){return Ve(this,_t,"f").keys()}values(){return Ve(this,_t,"f").values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map(e=>String(e)).join(", ")} `:""}}`}}cn.FrozenSet=iu;Object.freeze(nu);Object.freeze(nu.prototype);Object.freeze(iu);Object.freeze(iu.prototype);var Kd={},su={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateNumberSize=t.calculateStringSize=t.isASCII=t.isPlainObject=t.ESCAPE_CHARACTERS_REGEXP=t.JsonSize=t.hasProperty=t.isObject=t.isNullOrUndefined=t.isNonEmptyArray=void 0;function e(u){return Array.isArray(u)&&u.length>0}t.isNonEmptyArray=e;function r(u){return u==null}t.isNullOrUndefined=r;function n(u){return!!u&&typeof u=="object"&&!Array.isArray(u)}t.isObject=n;const i=(u,l)=>Object.hasOwnProperty.call(u,l);t.hasProperty=i,function(u){u[u.Null=4]="Null",u[u.Comma=1]="Comma",u[u.Wrapper=1]="Wrapper",u[u.True=4]="True",u[u.False=5]="False",u[u.Quote=1]="Quote",u[u.Colon=1]="Colon",u[u.Date=24]="Date"}(t.JsonSize||(t.JsonSize={})),t.ESCAPE_CHARACTERS_REGEXP=/"|\\|\n|\r|\t/gu;function s(u){if(typeof u!="object"||u===null)return!1;try{let l=u;for(;Object.getPrototypeOf(l)!==null;)l=Object.getPrototypeOf(l);return Object.getPrototypeOf(u)===l}catch{return!1}}t.isPlainObject=s;function o(u){return u.charCodeAt(0)<=127}t.isASCII=o;function a(u){var l;return u.split("").reduce((h,p)=>o(p)?h+1:h+2,0)+((l=u.match(t.ESCAPE_CHARACTERS_REGEXP))!==null&&l!==void 0?l:[]).length}t.calculateStringSize=a;function c(u){return u.toString().length}t.calculateNumberSize=c})(su);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateJsonAndGetSize=t.getJsonRpcIdValidator=t.assertIsJsonRpcError=t.isJsonRpcError=t.assertIsJsonRpcFailure=t.isJsonRpcFailure=t.assertIsJsonRpcSuccess=t.isJsonRpcSuccess=t.assertIsJsonRpcResponse=t.isJsonRpcResponse=t.assertIsPendingJsonRpcResponse=t.isPendingJsonRpcResponse=t.JsonRpcResponseStruct=t.JsonRpcFailureStruct=t.JsonRpcSuccessStruct=t.PendingJsonRpcResponseStruct=t.assertIsJsonRpcRequest=t.isJsonRpcRequest=t.assertIsJsonRpcNotification=t.isJsonRpcNotification=t.JsonRpcNotificationStruct=t.JsonRpcRequestStruct=t.JsonRpcParamsStruct=t.JsonRpcErrorStruct=t.JsonRpcIdStruct=t.JsonRpcVersionStruct=t.jsonrpc2=t.isValidJson=t.JsonStruct=void 0;const e=Or,r=$e,n=su;t.JsonStruct=(0,e.define)("Json",C=>{const[T]=x(C,!0);return T?!0:"Expected a valid JSON-serializable value"});function i(C){return(0,e.is)(C,t.JsonStruct)}t.isValidJson=i,t.jsonrpc2="2.0",t.JsonRpcVersionStruct=(0,e.literal)(t.jsonrpc2),t.JsonRpcIdStruct=(0,e.nullable)((0,e.union)([(0,e.number)(),(0,e.string)()])),t.JsonRpcErrorStruct=(0,e.object)({code:(0,e.integer)(),message:(0,e.string)(),data:(0,e.optional)(t.JsonStruct),stack:(0,e.optional)((0,e.string)())}),t.JsonRpcParamsStruct=(0,e.optional)((0,e.union)([(0,e.record)((0,e.string)(),t.JsonStruct),(0,e.array)(t.JsonStruct)])),t.JsonRpcRequestStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,method:(0,e.string)(),params:t.JsonRpcParamsStruct}),t.JsonRpcNotificationStruct=(0,e.omit)(t.JsonRpcRequestStruct,["id"]);function s(C){return(0,e.is)(C,t.JsonRpcNotificationStruct)}t.isJsonRpcNotification=s;function o(C,T){(0,r.assertStruct)(C,t.JsonRpcNotificationStruct,"Invalid JSON-RPC notification",T)}t.assertIsJsonRpcNotification=o;function a(C){return(0,e.is)(C,t.JsonRpcRequestStruct)}t.isJsonRpcRequest=a;function c(C,T){(0,r.assertStruct)(C,t.JsonRpcRequestStruct,"Invalid JSON-RPC request",T)}t.assertIsJsonRpcRequest=c,t.PendingJsonRpcResponseStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:(0,e.optional)((0,e.unknown)()),error:(0,e.optional)(t.JsonRpcErrorStruct)}),t.JsonRpcSuccessStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,result:t.JsonStruct}),t.JsonRpcFailureStruct=(0,e.object)({id:t.JsonRpcIdStruct,jsonrpc:t.JsonRpcVersionStruct,error:t.JsonRpcErrorStruct}),t.JsonRpcResponseStruct=(0,e.union)([t.JsonRpcSuccessStruct,t.JsonRpcFailureStruct]);function u(C){return(0,e.is)(C,t.PendingJsonRpcResponseStruct)}t.isPendingJsonRpcResponse=u;function l(C,T){(0,r.assertStruct)(C,t.PendingJsonRpcResponseStruct,"Invalid pending JSON-RPC response",T)}t.assertIsPendingJsonRpcResponse=l;function f(C){return(0,e.is)(C,t.JsonRpcResponseStruct)}t.isJsonRpcResponse=f;function h(C,T){(0,r.assertStruct)(C,t.JsonRpcResponseStruct,"Invalid JSON-RPC response",T)}t.assertIsJsonRpcResponse=h;function p(C){return(0,e.is)(C,t.JsonRpcSuccessStruct)}t.isJsonRpcSuccess=p;function v(C,T){(0,r.assertStruct)(C,t.JsonRpcSuccessStruct,"Invalid JSON-RPC success response",T)}t.assertIsJsonRpcSuccess=v;function E(C){return(0,e.is)(C,t.JsonRpcFailureStruct)}t.isJsonRpcFailure=E;function _(C,T){(0,r.assertStruct)(C,t.JsonRpcFailureStruct,"Invalid JSON-RPC failure response",T)}t.assertIsJsonRpcFailure=_;function d(C){return(0,e.is)(C,t.JsonRpcErrorStruct)}t.isJsonRpcError=d;function y(C,T){(0,r.assertStruct)(C,t.JsonRpcErrorStruct,"Invalid JSON-RPC error",T)}t.assertIsJsonRpcError=y;function m(C){const{permitEmptyString:T,permitFractions:j,permitNull:$}=Object.assign({permitEmptyString:!0,permitFractions:!1,permitNull:!0},C);return U=>!!(typeof U=="number"&&(j||Number.isInteger(U))||typeof U=="string"&&(T||U.length>0)||$&&U===null)}t.getJsonRpcIdValidator=m;function x(C,T=!1){const j=new Set;function $(A,U){if(A===void 0)return[!1,0];if(A===null)return[!0,U?0:n.JsonSize.Null];const ce=typeof A;try{if(ce==="function")return[!1,0];if(ce==="string"||A instanceof String)return[!0,U?0:(0,n.calculateStringSize)(A)+n.JsonSize.Quote*2];if(ce==="boolean"||A instanceof Boolean)return U?[!0,0]:[!0,A==!0?n.JsonSize.True:n.JsonSize.False];if(ce==="number"||A instanceof Number)return U?[!0,0]:[!0,(0,n.calculateNumberSize)(A)];if(A instanceof Date)return U?[!0,0]:[!0,isNaN(A.getDate())?n.JsonSize.Null:n.JsonSize.Date+n.JsonSize.Quote*2]}catch{return[!1,0]}if(!(0,n.isPlainObject)(A)&&!Array.isArray(A))return[!1,0];if(j.has(A))return[!1,0];j.add(A);try{return[!0,Object.entries(A).reduce((Z,[R,M],N,L)=>{let[B,D]=$(M,U);if(!B)throw new Error("JSON validation did not pass. Validation process stopped.");if(j.delete(A),U)return 0;const H=Array.isArray(A)?0:R.length+n.JsonSize.Comma+n.JsonSize.Colon*2,Y=N0)return o(l);if(h==="number"&&isFinite(l))return f.long?c(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function o(l){if(l=String(l),!(l.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(f){var h=parseFloat(f[1]),p=(f[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return h*s;case"weeks":case"week":case"w":return h*i;case"days":case"day":case"d":return h*n;case"hours":case"hour":case"hrs":case"hr":case"h":return h*r;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function a(l){var f=Math.abs(l);return f>=n?Math.round(l/n)+"d":f>=r?Math.round(l/r)+"h":f>=e?Math.round(l/e)+"m":f>=t?Math.round(l/t)+"s":l+"ms"}function c(l){var f=Math.abs(l);return f>=n?u(l,f,n,"day"):f>=r?u(l,f,r,"hour"):f>=e?u(l,f,e,"minute"):f>=t?u(l,f,t,"second"):l+" ms"}function u(l,f,h,p){var v=f>=h*1.5;return Math.round(l/h)+" "+p+(v?"s":"")}return Na}function Z1(t){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=i,r.enabled=o,r.humanize=Q1(),r.destroy=u,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let f=0;for(let h=0;h{if(T==="%%")return"%";x++;const $=r.formatters[j];if(typeof $=="function"){const A=_[x];T=$.call(d,A),_.splice(x,1),x--}return T}),r.formatArgs.call(d,_),(d.log||r.log).apply(d,_)}return E.namespace=l,E.useColors=r.useColors(),E.color=r.selectColor(l),E.extend=n,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(p!==r.namespaces&&(p=r.namespaces,v=r.enabled(l)),v),set:_=>{h=_}}),typeof r.init=="function"&&r.init(E),E}function n(l,f){const h=r(this.namespace+(typeof f>"u"?":":f)+l);return h.log=this.log,h}function i(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let f;const h=(typeof l=="string"?l:"").split(/[\s,]+/),p=h.length;for(f=0;f"-"+f)].join(",");return r.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;c.splice(1,0,u,"color: inherit");let l=0,f=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(l++,h==="%c"&&(f=l))}),c.splice(f,0,u)}e.log=console.debug||console.log||(()=>{});function i(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function s(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c={}.DEBUG),c}function o(){try{return localStorage}catch{}}t.exports=Y1(e);const{formatters:a}=t.exports;a.j=function(c){try{return JSON.stringify(c)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(vc,vc.exports);var K1=vc.exports,X1=F&&F.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(un,"__esModule",{value:!0});un.createModuleLogger=un.createProjectLogger=void 0;const e_=X1(K1),t_=(0,e_.default)("metamask");function r_(t){return t_.extend(t)}un.createProjectLogger=r_;function n_(t,e){return t.extend(e)}un.createModuleLogger=n_;var At={};Object.defineProperty(At,"__esModule",{value:!0});At.hexToBigInt=At.hexToNumber=At.bigIntToHex=At.numberToHex=void 0;const Kr=$e,Kn=bi,i_=t=>((0,Kr.assert)(typeof t=="number","Value must be a number."),(0,Kr.assert)(t>=0,"Value must be a non-negative number."),(0,Kr.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToHex` instead."),(0,Kn.add0x)(t.toString(16)));At.numberToHex=i_;const s_=t=>((0,Kr.assert)(typeof t=="bigint","Value must be a bigint."),(0,Kr.assert)(t>=0,"Value must be a non-negative bigint."),(0,Kn.add0x)(t.toString(16)));At.bigIntToHex=s_;const o_=t=>{(0,Kn.assertIsHexString)(t);const e=parseInt(t,16);return(0,Kr.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `hexToBigInt` instead."),e};At.hexToNumber=o_;const a_=t=>((0,Kn.assertIsHexString)(t),BigInt((0,Kn.add0x)(t)));At.hexToBigInt=a_;var Xd={};Object.defineProperty(Xd,"__esModule",{value:!0});var ep={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.timeSince=t.inMilliseconds=t.Duration=void 0,function(s){s[s.Millisecond=1]="Millisecond",s[s.Second=1e3]="Second",s[s.Minute=6e4]="Minute",s[s.Hour=36e5]="Hour",s[s.Day=864e5]="Day",s[s.Week=6048e5]="Week",s[s.Year=31536e6]="Year"}(t.Duration||(t.Duration={}));const e=s=>Number.isInteger(s)&&s>=0,r=(s,o)=>{if(!e(s))throw new Error(`"${o}" must be a non-negative integer. Received: "${s}".`)};function n(s,o){return r(s,"count"),s*o}t.inMilliseconds=n;function i(s){return r(s,"timestamp"),Date.now()-s}t.timeSince=i})(ep);var tp={},mc={exports:{}};const c_="2.0.0",rp=256,u_=Number.MAX_SAFE_INTEGER||9007199254740991,l_=16,f_=rp-6,h_=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Os={MAX_LENGTH:rp,MAX_SAFE_COMPONENT_LENGTH:l_,MAX_SAFE_BUILD_LENGTH:f_,MAX_SAFE_INTEGER:u_,RELEASE_TYPES:h_,SEMVER_SPEC_VERSION:c_,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const d_=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};var Ns=d_;(function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Os,s=Ns;e=t.exports={};const o=e.re=[],a=e.safeRe=[],c=e.src=[],u=e.t={};let l=0;const f="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[f,n]],p=E=>{for(const[_,d]of h)E=E.split(`${_}*`).join(`${_}{0,${d}}`).split(`${_}+`).join(`${_}{1,${d}}`);return E},v=(E,_,d)=>{const y=p(_),m=l++;s(E,m,_),u[E]=m,c[m]=_,o[m]=new RegExp(_,d?"g":void 0),a[m]=new RegExp(y,d?"g":void 0)};v("NUMERICIDENTIFIER","0|[1-9]\\d*"),v("NUMERICIDENTIFIERLOOSE","\\d+"),v("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),v("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),v("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),v("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),v("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),v("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),v("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),v("BUILDIDENTIFIER",`${f}+`),v("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),v("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),v("FULL",`^${c[u.FULLPLAIN]}$`),v("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),v("LOOSE",`^${c[u.LOOSEPLAIN]}$`),v("GTLT","((?:<|>)?=?)"),v("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),v("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),v("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),v("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),v("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),v("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),v("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),v("COERCERTL",c[u.COERCE],!0),v("LONETILDE","(?:~>?)"),v("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",v("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),v("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),v("LONECARET","(?:\\^)"),v("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",v("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),v("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),v("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),v("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),v("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",v("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),v("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),v("STAR","(<|>)?=?\\s*\\*"),v("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),v("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(mc,mc.exports);var gi=mc.exports;const p_=Object.freeze({loose:!0}),b_=Object.freeze({}),g_=t=>t?typeof t!="object"?p_:t:b_;var ou=g_;const tf=/^[0-9]+$/,np=(t,e)=>{const r=tf.test(t),n=tf.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:tnp(e,t);var ip={compareIdentifiers:np,rcompareIdentifiers:y_};const Pi=Ns,{MAX_LENGTH:rf,MAX_SAFE_INTEGER:$i}=Os,{safeRe:nf,t:sf}=gi,v_=ou,{compareIdentifiers:Fr}=ip;let m_=class St{constructor(e,r){if(r=v_(r),e instanceof St){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>rf)throw new TypeError(`version is longer than ${rf} characters`);Pi("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const n=e.trim().match(r.loose?nf[sf.LOOSE]:nf[sf.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>$i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>$i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>$i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s<$i)return s}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(Pi("SemVer.compare",this.version,this.options,e),!(e instanceof St)){if(typeof e=="string"&&e===this.version)return 0;e=new St(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof St||(e=new St(e,this.options)),Fr(this.major,e.major)||Fr(this.minor,e.minor)||Fr(this.patch,e.patch)}comparePre(e){if(e instanceof St||(e=new St(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=e.prerelease[r];if(Pi("prerelease compare",r,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return Fr(n,i)}while(++r)}compareBuild(e){e instanceof St||(e=new St(e,this.options));let r=0;do{const n=this.build[r],i=e.build[r];if(Pi("prerelease compare",r,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return Fr(n,i)}while(++r)}inc(e,r,n){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,n),this.inc("pre",r,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,n),this.inc("pre",r,n);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const i=Number(n)?1:0;if(!r&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(this.prerelease.length===0)this.prerelease=[i];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let s=[r,i];n===!1&&(s=[r]),Fr(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var qe=m_;const of=qe,__=(t,e,r=!1)=>{if(t instanceof of)return t;try{return new of(t,e)}catch(n){if(!r)return null;throw n}};var In=__;const w_=In,S_=(t,e)=>{const r=w_(t,e);return r?r.version:null};var E_=S_;const C_=In,x_=(t,e)=>{const r=C_(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};var I_=x_;const af=qe,R_=(t,e,r,n,i)=>{typeof r=="string"&&(i=n,n=r,r=void 0);try{return new af(t instanceof af?t.version:t,r).inc(e,n,i).version}catch{return null}};var A_=R_;const cf=In,M_=(t,e)=>{const r=cf(t,null,!0),n=cf(e,null,!0),i=r.compare(n);if(i===0)return null;const s=i>0,o=s?r:n,a=s?n:r,c=!!o.prerelease.length;if(!!a.prerelease.length&&!c)return!a.patch&&!a.minor?"major":o.patch?"patch":o.minor?"minor":"major";const l=c?"pre":"";return r.major!==n.major?l+"major":r.minor!==n.minor?l+"minor":r.patch!==n.patch?l+"patch":"prerelease"};var k_=M_;const T_=qe,O_=(t,e)=>new T_(t,e).major;var N_=O_;const L_=qe,P_=(t,e)=>new L_(t,e).minor;var $_=P_;const D_=qe,j_=(t,e)=>new D_(t,e).patch;var B_=j_;const F_=In,W_=(t,e)=>{const r=F_(t,e);return r&&r.prerelease.length?r.prerelease:null};var H_=W_;const uf=qe,V_=(t,e,r)=>new uf(t,r).compare(new uf(e,r));var gt=V_;const U_=gt,z_=(t,e,r)=>U_(e,t,r);var q_=z_;const G_=gt,J_=(t,e)=>G_(t,e,!0);var Q_=J_;const lf=qe,Z_=(t,e,r)=>{const n=new lf(t,r),i=new lf(e,r);return n.compare(i)||n.compareBuild(i)};var au=Z_;const Y_=au,K_=(t,e)=>t.sort((r,n)=>Y_(r,n,e));var X_=K_;const ew=au,tw=(t,e)=>t.sort((r,n)=>ew(n,r,e));var rw=tw;const nw=gt,iw=(t,e,r)=>nw(t,e,r)>0;var Ls=iw;const sw=gt,ow=(t,e,r)=>sw(t,e,r)<0;var cu=ow;const aw=gt,cw=(t,e,r)=>aw(t,e,r)===0;var sp=cw;const uw=gt,lw=(t,e,r)=>uw(t,e,r)!==0;var op=lw;const fw=gt,hw=(t,e,r)=>fw(t,e,r)>=0;var uu=hw;const dw=gt,pw=(t,e,r)=>dw(t,e,r)<=0;var lu=pw;const bw=sp,gw=op,yw=Ls,vw=uu,mw=cu,_w=lu,ww=(t,e,r,n)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return bw(t,r,n);case"!=":return gw(t,r,n);case">":return yw(t,r,n);case">=":return vw(t,r,n);case"<":return mw(t,r,n);case"<=":return _w(t,r,n);default:throw new TypeError(`Invalid operator: ${e}`)}};var ap=ww;const Sw=qe,Ew=In,{safeRe:Di,t:ji}=gi,Cw=(t,e)=>{if(t instanceof Sw)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(Di[ji.COERCE]);else{let n;for(;(n=Di[ji.COERCERTL].exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||n.index+n[0].length!==r.index+r[0].length)&&(r=n),Di[ji.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;Di[ji.COERCERTL].lastIndex=-1}return r===null?null:Ew(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,e)};var xw=Cw,La,ff;function Iw(){return ff||(ff=1,La=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),La}var Rw=ae;ae.Node=Sr;ae.create=ae;function ae(t){var e=this;if(e instanceof ae||(e=new ae),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(i){e.push(i)});else if(arguments.length>0)for(var r=0,n=arguments.length;r1)r=e;else if(this.head)n=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=0;n!==null;i++)r=t(r,n.value,i),n=n.next;return r};ae.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else if(this.tail)n=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=this.length-1;n!==null;i--)r=t(r,n.value,i),n=n.prev;return r};ae.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};ae.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};ae.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new ae;if(ethis.length&&(e=this.length);for(var n=0,i=this.head;i!==null&&nthis.length&&(e=this.length);for(var n=this.length,i=this.tail;i!==null&&n>e;n--)i=i.prev;for(;i!==null&&n>t;n--,i=i.prev)r.push(i.value);return r};ae.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,i=this.head;i!==null&&n1;class Ow{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[dr]=e.max||1/0;const r=e.length||Pa;if(this[Wr]=typeof r!="function"?Pa:r,this[zn]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[yr]=e.maxAge||0,this[Lt]=e.dispose,this[hf]=e.noDisposeOnSet||!1,this[cp]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[dr]=e||1/0,Pn(this)}get max(){return this[dr]}set allowStale(e){this[zn]=!!e}get allowStale(){return this[zn]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[yr]=e,Pn(this)}get maxAge(){return this[yr]}set lengthCalculator(e){typeof e!="function"&&(e=Pa),e!==this[Wr]&&(this[Wr]=e,this[Dt]=0,this[ke].forEach(r=>{r.length=this[Wr](r.value,r.key),this[Dt]+=r.length})),Pn(this)}get lengthCalculator(){return this[Wr]}get length(){return this[Dt]}get itemCount(){return this[ke].length}rforEach(e,r){r=r||this;for(let n=this[ke].tail;n!==null;){const i=n.prev;df(this,e,n,r),n=i}}forEach(e,r){r=r||this;for(let n=this[ke].head;n!==null;){const i=n.next;df(this,e,n,r),n=i}}keys(){return this[ke].toArray().map(e=>e.key)}values(){return this[ke].toArray().map(e=>e.value)}reset(){this[Lt]&&this[ke]&&this[ke].length&&this[ke].forEach(e=>this[Lt](e.key,e.value)),this[ht]=new Map,this[ke]=new Tw,this[Dt]=0}dump(){return this[ke].map(e=>ss(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[ke]}set(e,r,n){if(n=n||this[yr],n&&typeof n!="number")throw new TypeError("maxAge must be a number");const i=n?Date.now():0,s=this[Wr](r,e);if(this[ht].has(e)){if(s>this[dr])return Xr(this,this[ht].get(e)),!1;const c=this[ht].get(e).value;return this[Lt]&&(this[hf]||this[Lt](e,c.value)),c.now=i,c.maxAge=n,c.value=r,this[Dt]+=s-c.length,c.length=s,this.get(e),Pn(this),!0}const o=new Nw(e,r,s,i,n);return o.length>this[dr]?(this[Lt]&&this[Lt](e,r),!1):(this[Dt]+=o.length,this[ke].unshift(o),this[ht].set(e,this[ke].head),Pn(this),!0)}has(e){if(!this[ht].has(e))return!1;const r=this[ht].get(e).value;return!ss(this,r)}get(e){return $a(this,e,!0)}peek(e){return $a(this,e,!1)}pop(){const e=this[ke].tail;return e?(Xr(this,e),e.value):null}del(e){Xr(this,this[ht].get(e))}load(e){this.reset();const r=Date.now();for(let n=e.length-1;n>=0;n--){const i=e[n],s=i.e||0;if(s===0)this.set(i.k,i.v);else{const o=s-r;o>0&&this.set(i.k,i.v,o)}}}prune(){this[ht].forEach((e,r)=>$a(this,r,!1))}}const $a=(t,e,r)=>{const n=t[ht].get(e);if(n){const i=n.value;if(ss(t,i)){if(Xr(t,n),!t[zn])return}else r&&(t[cp]&&(n.value.now=Date.now()),t[ke].unshiftNode(n));return i.value}},ss=(t,e)=>{if(!e||!e.maxAge&&!t[yr])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[yr]&&r>t[yr]},Pn=t=>{if(t[Dt]>t[dr])for(let e=t[ke].tail;t[Dt]>t[dr]&&e!==null;){const r=e.prev;Xr(t,e),e=r}},Xr=(t,e)=>{if(e){const r=e.value;t[Lt]&&t[Lt](r.key,r.value),t[Dt]-=r.length,t[ht].delete(r.key),t[ke].removeNode(e)}};class Nw{constructor(e,r,n,i,s){this.key=e,this.value=r,this.length=n,this.now=i,this.maxAge=s||0}}const df=(t,e,r,n)=>{let i=r.value;ss(t,i)&&(Xr(t,r),t[zn]||(i=void 0)),i&&e.call(n,i.value,i.key,t)};var Lw=Ow,Da,pf;function yt(){if(pf)return Da;pf=1;class t{constructor(M,N){if(N=n(N),M instanceof t)return M.loose===!!N.loose&&M.includePrerelease===!!N.includePrerelease?M:new t(M.raw,N);if(M instanceof i)return this.raw=M.value,this.set=[[M]],this.format(),this;if(this.options=N,this.loose=!!N.loose,this.includePrerelease=!!N.includePrerelease,this.raw=M.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(L=>this.parseRange(L.trim())).filter(L=>L.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const L=this.set[0];if(this.set=this.set.filter(B=>!v(B[0])),this.set.length===0)this.set=[L];else if(this.set.length>1){for(const B of this.set)if(B.length===1&&E(B[0])){this.set=[B];break}}}this.format()}format(){return this.range=this.set.map(M=>M.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(M){const L=((this.options.includePrerelease&&h)|(this.options.loose&&p))+":"+M,B=r.get(L);if(B)return B;const D=this.options.loose,H=D?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];M=M.replace(H,ce(this.options.includePrerelease)),s("hyphen replace",M),M=M.replace(a[c.COMPARATORTRIM],u),s("comparator trim",M),M=M.replace(a[c.TILDETRIM],l),s("tilde trim",M),M=M.replace(a[c.CARETTRIM],f),s("caret trim",M);let Y=M.split(" ").map(le=>d(le,this.options)).join(" ").split(/\s+/).map(le=>U(le,this.options));D&&(Y=Y.filter(le=>(s("loose invalid filter",le,this.options),!!le.match(a[c.COMPARATORLOOSE])))),s("range list",Y);const J=new Map,se=Y.map(le=>new i(le,this.options));for(const le of se){if(v(le))return[le];J.set(le.value,le)}J.size>1&&J.has("")&&J.delete("");const he=[...J.values()];return r.set(L,he),he}intersects(M,N){if(!(M instanceof t))throw new TypeError("a Range is required");return this.set.some(L=>_(L,N)&&M.set.some(B=>_(B,N)&&L.every(D=>B.every(H=>D.intersects(H,N)))))}test(M){if(!M)return!1;if(typeof M=="string")try{M=new o(M,this.options)}catch{return!1}for(let N=0;NR.value==="<0.0.0-0",E=R=>R.value==="",_=(R,M)=>{let N=!0;const L=R.slice();let B=L.pop();for(;N&&L.length;)N=L.every(D=>B.intersects(D,M)),B=L.pop();return N},d=(R,M)=>(s("comp",R,M),R=C(R,M),s("caret",R),R=m(R,M),s("tildes",R),R=j(R,M),s("xrange",R),R=A(R,M),s("stars",R),R),y=R=>!R||R.toLowerCase()==="x"||R==="*",m=(R,M)=>R.trim().split(/\s+/).map(N=>x(N,M)).join(" "),x=(R,M)=>{const N=M.loose?a[c.TILDELOOSE]:a[c.TILDE];return R.replace(N,(L,B,D,H,Y)=>{s("tilde",R,L,B,D,H,Y);let J;return y(B)?J="":y(D)?J=`>=${B}.0.0 <${+B+1}.0.0-0`:y(H)?J=`>=${B}.${D}.0 <${B}.${+D+1}.0-0`:Y?(s("replaceTilde pr",Y),J=`>=${B}.${D}.${H}-${Y} <${B}.${+D+1}.0-0`):J=`>=${B}.${D}.${H} <${B}.${+D+1}.0-0`,s("tilde return",J),J})},C=(R,M)=>R.trim().split(/\s+/).map(N=>T(N,M)).join(" "),T=(R,M)=>{s("caret",R,M);const N=M.loose?a[c.CARETLOOSE]:a[c.CARET],L=M.includePrerelease?"-0":"";return R.replace(N,(B,D,H,Y,J)=>{s("caret",R,B,D,H,Y,J);let se;return y(D)?se="":y(H)?se=`>=${D}.0.0${L} <${+D+1}.0.0-0`:y(Y)?D==="0"?se=`>=${D}.${H}.0${L} <${D}.${+H+1}.0-0`:se=`>=${D}.${H}.0${L} <${+D+1}.0.0-0`:J?(s("replaceCaret pr",J),D==="0"?H==="0"?se=`>=${D}.${H}.${Y}-${J} <${D}.${H}.${+Y+1}-0`:se=`>=${D}.${H}.${Y}-${J} <${D}.${+H+1}.0-0`:se=`>=${D}.${H}.${Y}-${J} <${+D+1}.0.0-0`):(s("no pr"),D==="0"?H==="0"?se=`>=${D}.${H}.${Y}${L} <${D}.${H}.${+Y+1}-0`:se=`>=${D}.${H}.${Y}${L} <${D}.${+H+1}.0-0`:se=`>=${D}.${H}.${Y} <${+D+1}.0.0-0`),s("caret return",se),se})},j=(R,M)=>(s("replaceXRanges",R,M),R.split(/\s+/).map(N=>$(N,M)).join(" ")),$=(R,M)=>{R=R.trim();const N=M.loose?a[c.XRANGELOOSE]:a[c.XRANGE];return R.replace(N,(L,B,D,H,Y,J)=>{s("xRange",R,L,B,D,H,Y,J);const se=y(D),he=se||y(H),le=he||y(Y),We=le;return B==="="&&We&&(B=""),J=M.includePrerelease?"-0":"",se?B===">"||B==="<"?L="<0.0.0-0":L="*":B&&We?(he&&(H=0),Y=0,B===">"?(B=">=",he?(D=+D+1,H=0,Y=0):(H=+H+1,Y=0)):B==="<="&&(B="<",he?D=+D+1:H=+H+1),B==="<"&&(J="-0"),L=`${B+D}.${H}.${Y}${J}`):he?L=`>=${D}.0.0${J} <${+D+1}.0.0-0`:le&&(L=`>=${D}.${H}.0${J} <${D}.${+H+1}.0-0`),s("xRange return",L),L})},A=(R,M)=>(s("replaceStars",R,M),R.trim().replace(a[c.STAR],"")),U=(R,M)=>(s("replaceGTE0",R,M),R.trim().replace(a[M.includePrerelease?c.GTE0PRE:c.GTE0],"")),ce=R=>(M,N,L,B,D,H,Y,J,se,he,le,We,w)=>(y(L)?N="":y(B)?N=`>=${L}.0.0${R?"-0":""}`:y(D)?N=`>=${L}.${B}.0${R?"-0":""}`:H?N=`>=${N}`:N=`>=${N}${R?"-0":""}`,y(se)?J="":y(he)?J=`<${+se+1}.0.0-0`:y(le)?J=`<${se}.${+he+1}.0-0`:We?J=`<=${se}.${he}.${le}-${We}`:R?J=`<${se}.${he}.${+le+1}-0`:J=`<=${J}`,`${N} ${J}`.trim()),Z=(R,M,N)=>{for(let L=0;L0){const B=R[L].semver;if(B.major===M.major&&B.minor===M.minor&&B.patch===M.patch)return!0}return!1}return!0};return Da}var ja,bf;function Ps(){if(bf)return ja;bf=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(l,f){if(f=r(f),l instanceof e){if(l.loose===!!f.loose)return l;l=l.value}l=l.trim().split(/\s+/).join(" "),o("comparator",l,f),this.options=f,this.loose=!!f.loose,this.parse(l),this.semver===t?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(l){const f=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],h=l.match(f);if(!h)throw new TypeError(`Invalid comparator: ${l}`);this.operator=h[1]!==void 0?h[1]:"",this.operator==="="&&(this.operator=""),h[2]?this.semver=new a(h[2],this.options.loose):this.semver=t}toString(){return this.value}test(l){if(o("Comparator.test",l,this.options.loose),this.semver===t||l===t)return!0;if(typeof l=="string")try{l=new a(l,this.options)}catch{return!1}return s(l,this.operator,this.semver,this.options)}intersects(l,f){if(!(l instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(l.value,f).test(this.value):l.operator===""?l.value===""?!0:new c(this.value,f).test(l.semver):(f=r(f),f.includePrerelease&&(this.value==="<0.0.0-0"||l.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||l.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&l.operator.startsWith(">")||this.operator.startsWith("<")&&l.operator.startsWith("<")||this.semver.version===l.semver.version&&this.operator.includes("=")&&l.operator.includes("=")||s(this.semver,"<",l.semver,f)&&this.operator.startsWith(">")&&l.operator.startsWith("<")||s(this.semver,">",l.semver,f)&&this.operator.startsWith("<")&&l.operator.startsWith(">")))}}ja=e;const r=ou,{safeRe:n,t:i}=gi,s=ap,o=Ns,a=qe,c=yt();return ja}const Pw=yt(),$w=(t,e,r)=>{try{e=new Pw(e,r)}catch{return!1}return e.test(t)};var $s=$w;const Dw=yt(),jw=(t,e)=>new Dw(t,e).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));var Bw=jw;const Fw=qe,Ww=yt(),Hw=(t,e,r)=>{let n=null,i=null,s=null;try{s=new Ww(e,r)}catch{return null}return t.forEach(o=>{s.test(o)&&(!n||i.compare(o)===-1)&&(n=o,i=new Fw(n,r))}),n};var Vw=Hw;const Uw=qe,zw=yt(),qw=(t,e,r)=>{let n=null,i=null,s=null;try{s=new zw(e,r)}catch{return null}return t.forEach(o=>{s.test(o)&&(!n||i.compare(o)===1)&&(n=o,i=new Uw(n,r))}),n};var Gw=qw;const Ba=qe,Jw=yt(),gf=Ls,Qw=(t,e)=>{t=new Jw(t,e);let r=new Ba("0.0.0");if(t.test(r)||(r=new Ba("0.0.0-0"),t.test(r)))return r;r=null;for(let n=0;n{const a=new Ba(o.semver.version);switch(o.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!s||gf(a,s))&&(s=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),s&&(!r||gf(r,s))&&(r=s)}return r&&t.test(r)?r:null};var Zw=Qw;const Yw=yt(),Kw=(t,e)=>{try{return new Yw(t,e).range||"*"}catch{return null}};var Xw=Kw;const eS=qe,up=Ps(),{ANY:tS}=up,rS=yt(),nS=$s,yf=Ls,vf=cu,iS=lu,sS=uu,oS=(t,e,r,n)=>{t=new eS(t,n),e=new rS(e,n);let i,s,o,a,c;switch(r){case">":i=yf,s=iS,o=vf,a=">",c=">=";break;case"<":i=vf,s=sS,o=yf,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(nS(t,e,n))return!1;for(let u=0;u{p.semver===tS&&(p=new up(">=0.0.0")),f=f||p,h=h||p,i(p.semver,f.semver,n)?f=p:o(p.semver,h.semver,n)&&(h=p)}),f.operator===a||f.operator===c||(!h.operator||h.operator===a)&&s(t,h.semver))return!1;if(h.operator===c&&o(t,h.semver))return!1}return!0};var fu=oS;const aS=fu,cS=(t,e,r)=>aS(t,e,">",r);var uS=cS;const lS=fu,fS=(t,e,r)=>lS(t,e,"<",r);var hS=fS;const mf=yt(),dS=(t,e,r)=>(t=new mf(t,r),e=new mf(e,r),t.intersects(e,r));var pS=dS;const bS=$s,gS=gt;var yS=(t,e,r)=>{const n=[];let i=null,s=null;const o=t.sort((l,f)=>gS(l,f,r));for(const l of o)bS(l,e,r)?(s=l,i||(i=l)):(s&&n.push([i,s]),s=null,i=null);i&&n.push([i,null]);const a=[];for(const[l,f]of n)l===f?a.push(l):!f&&l===o[0]?a.push("*"):f?l===o[0]?a.push(`<=${f}`):a.push(`${l} - ${f}`):a.push(`>=${l}`);const c=a.join(" || "),u=typeof e.raw=="string"?e.raw:String(e);return c.length{if(t===e)return!0;t=new _f(t,r),e=new _f(e,r);let n=!1;e:for(const i of t.set){for(const s of e.set){const o=_S(i,s,r);if(n=n||o!==null,o)continue e}if(n)return!1}return!0},mS=[new hu(">=0.0.0-0")],wf=[new hu(">=0.0.0")],_S=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===Fa){if(e.length===1&&e[0].semver===Fa)return!0;r.includePrerelease?t=mS:t=wf}if(e.length===1&&e[0].semver===Fa){if(r.includePrerelease)return!0;e=wf}const n=new Set;let i,s;for(const p of t)p.operator===">"||p.operator===">="?i=Sf(i,p,r):p.operator==="<"||p.operator==="<="?s=Ef(s,p,r):n.add(p.semver);if(n.size>1)return null;let o;if(i&&s){if(o=du(i.semver,s.semver,r),o>0)return null;if(o===0&&(i.operator!==">="||s.operator!=="<="))return null}for(const p of n){if(i&&!$n(p,String(i),r)||s&&!$n(p,String(s),r))return null;for(const v of e)if(!$n(p,String(v),r))return!1;return!0}let a,c,u,l,f=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1,h=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;f&&f.prerelease.length===1&&s.operator==="<"&&f.prerelease[0]===0&&(f=!1);for(const p of e){if(l=l||p.operator===">"||p.operator===">=",u=u||p.operator==="<"||p.operator==="<=",i){if(h&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===h.major&&p.semver.minor===h.minor&&p.semver.patch===h.patch&&(h=!1),p.operator===">"||p.operator===">="){if(a=Sf(i,p,r),a===p&&a!==i)return!1}else if(i.operator===">="&&!$n(i.semver,String(p),r))return!1}if(s){if(f&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch&&(f=!1),p.operator==="<"||p.operator==="<="){if(c=Ef(s,p,r),c===p&&c!==s)return!1}else if(s.operator==="<="&&!$n(s.semver,String(p),r))return!1}if(!p.operator&&(s||i)&&o!==0)return!1}return!(i&&u&&!s&&o!==0||s&&l&&!i&&o!==0||h||f)},Sf=(t,e,r)=>{if(!t)return e;const n=du(t.semver,e.semver,r);return n>0?t:n<0||e.operator===">"&&t.operator===">="?e:t},Ef=(t,e,r)=>{if(!t)return e;const n=du(t.semver,e.semver,r);return n<0?t:n>0||e.operator==="<"&&t.operator==="<="?e:t};var wS=vS;const Wa=gi,Cf=Os,SS=qe,xf=ip,ES=In,CS=E_,xS=I_,IS=A_,RS=k_,AS=N_,MS=$_,kS=B_,TS=H_,OS=gt,NS=q_,LS=Q_,PS=au,$S=X_,DS=rw,jS=Ls,BS=cu,FS=sp,WS=op,HS=uu,VS=lu,US=ap,zS=xw,qS=Ps(),GS=yt(),JS=$s,QS=Bw,ZS=Vw,YS=Gw,KS=Zw,XS=Xw,e2=fu,t2=uS,r2=hS,n2=pS,i2=yS,s2=wS;var o2={parse:ES,valid:CS,clean:xS,inc:IS,diff:RS,major:AS,minor:MS,patch:kS,prerelease:TS,compare:OS,rcompare:NS,compareLoose:LS,compareBuild:PS,sort:$S,rsort:DS,gt:jS,lt:BS,eq:FS,neq:WS,gte:HS,lte:VS,cmp:US,coerce:zS,Comparator:qS,Range:GS,satisfies:JS,toComparators:QS,maxSatisfying:ZS,minSatisfying:YS,minVersion:KS,validRange:XS,outside:e2,gtr:t2,ltr:r2,intersects:n2,simplifyRange:i2,subset:s2,SemVer:SS,re:Wa.re,src:Wa.src,tokens:Wa.t,SEMVER_SPEC_VERSION:Cf.SEMVER_SPEC_VERSION,RELEASE_TYPES:Cf.RELEASE_TYPES,compareIdentifiers:xf.compareIdentifiers,rcompareIdentifiers:xf.rcompareIdentifiers};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.satisfiesVersionRange=t.gtRange=t.gtVersion=t.assertIsSemVerRange=t.assertIsSemVerVersion=t.isValidSemVerRange=t.isValidSemVerVersion=t.VersionRangeStruct=t.VersionStruct=void 0;const e=o2,r=Or,n=$e;t.VersionStruct=(0,r.refine)((0,r.string)(),"Version",f=>(0,e.valid)(f)===null?`Expected SemVer version, got "${f}"`:!0),t.VersionRangeStruct=(0,r.refine)((0,r.string)(),"Version range",f=>(0,e.validRange)(f)===null?`Expected SemVer range, got "${f}"`:!0);function i(f){return(0,r.is)(f,t.VersionStruct)}t.isValidSemVerVersion=i;function s(f){return(0,r.is)(f,t.VersionRangeStruct)}t.isValidSemVerRange=s;function o(f){(0,n.assertStruct)(f,t.VersionStruct)}t.assertIsSemVerVersion=o;function a(f){(0,n.assertStruct)(f,t.VersionRangeStruct)}t.assertIsSemVerRange=a;function c(f,h){return(0,e.gt)(f,h)}t.gtVersion=c;function u(f,h){return(0,e.gtr)(f,h)}t.gtRange=u;function l(f,h){return(0,e.satisfies)(f,h,{includePrerelease:!0})}t.satisfiesVersionRange=l})(tp);(function(t){var e=F&&F.__createBinding||(Object.create?function(n,i,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(i,s);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,o,a)}:function(n,i,s,o){o===void 0&&(o=s),n[o]=i[s]}),r=F&&F.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r($e,t),r(pi,t),r(oe,t),r(ks,t),r(Rt,t),r(cn,t),r(bi,t),r(Kd,t),r(un,t),r(su,t),r(At,t),r(Xd,t),r(ep,t),r(tp,t)})(Nd);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createModuleLogger=t.projectLogger=void 0;const e=Nd;Object.defineProperty(t,"createModuleLogger",{enumerable:!0,get:function(){return e.createModuleLogger}}),t.projectLogger=(0,e.createProjectLogger)("eth-block-tracker")})(Od);var lp=F&&F.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(As,"__esModule",{value:!0});As.PollingBlockTracker=void 0;const a2=lp(Qc),c2=lp(Mm),u2=hi,If=Od,Rf=(0,If.createModuleLogger)(If.projectLogger,"polling-block-tracker"),l2=(0,a2.default)(),f2=1e3;class h2 extends u2.BaseBlockTracker{constructor(e={}){var r;if(!e.provider)throw new Error("PollingBlockTracker - no provider specified.");super({blockResetDuration:(r=e.blockResetDuration)!==null&&r!==void 0?r:e.pollingInterval}),this._provider=e.provider,this._pollingInterval=e.pollingInterval||20*f2,this._retryTimeout=e.retryTimeout||this._pollingInterval/10,this._keepEventLoopActive=e.keepEventLoopActive===void 0?!0:e.keepEventLoopActive,this._setSkipCacheFlag=e.setSkipCacheFlag||!1}async checkForLatestBlock(){return await this._updateLatestBlock(),await this.getLatestBlock()}async _start(){this._synchronize()}async _end(){}async _synchronize(){for(var e;this._isRunning;)try{await this._updateLatestBlock();const r=Af(this._pollingInterval,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await r}catch(r){const n=new Error(`PollingBlockTracker - encountered an error while attempting to update latest block: diff --git a/assets/index-e4b650d6.js b/assets/index-f6657797.js similarity index 98% rename from assets/index-e4b650d6.js rename to assets/index-f6657797.js index b14e04be..8e416c01 100644 --- a/assets/index-e4b650d6.js +++ b/assets/index-f6657797.js @@ -1 +1 @@ -import{ar as le}from"./index-da732aeb.js";import{b as ce}from"./index-cc134824.js";const de=Symbol(),X=Object.getPrototypeOf,F=new WeakMap,ue=e=>e&&(F.has(e)?F.get(e):X(e)===Object.prototype||X(e)===Array.prototype),fe=e=>ue(e)&&e[de]||null,Y=(e,t=!0)=>{F.set(e,t)},J=e=>typeof e=="object"&&e!==null,C=new WeakMap,B=new WeakSet,pe=(e=Object.is,t=(o,h)=>new Proxy(o,h),s=o=>J(o)&&!B.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),r=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,h,I=r)=>{const w=l.get(o);if((w==null?void 0:w[0])===h)return w[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return Y(b,!0),l.set(o,[h,b]),Reflect.ownKeys(o).forEach(P=>{if(Object.getOwnPropertyDescriptor(b,P))return;const O=Reflect.get(o,P),D={value:O,enumerable:!0,configurable:!0};if(B.has(O))Y(O,!1);else if(O instanceof Promise)delete D.value,D.get=()=>I(O);else if(C.has(O)){const[y,z]=C.get(O);D.value=c(y,z(),I)}Object.defineProperty(b,P,D)}),b},m=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const h=m.get(o);if(h)return h;let I=f[0];const w=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,w.forEach(n=>n(i,a)))};let P=f[1];const O=(i=++f[1])=>(P!==i&&!w.size&&(P=i,y.forEach(([a])=>{const n=a[1](i);n>I&&(I=n)})),I),D=i=>(a,n)=>{const g=[...a];g[1]=[i,...g[1]],b(g,n)},y=new Map,z=(i,a)=>{if(w.size){const n=a[3](D(i));y.set(i,[a,n])}else y.set(i,[a])},Q=i=>{var a;const n=y.get(i);n&&(y.delete(i),(a=n[1])==null||a.call(n))},ae=i=>(w.add(i),w.size===1&&y.forEach(([n,g],R)=>{const k=n[3](D(R));y.set(R,[n,k])}),()=>{w.delete(i),w.size===0&&y.forEach(([n,g],R)=>{g&&(g(),y.set(R,[n]))})}),H=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),V=t(H,{deleteProperty(i,a){const n=Reflect.get(i,a);Q(a);const g=Reflect.deleteProperty(i,a);return g&&b(["delete",[a],n]),g},set(i,a,n,g){const R=Reflect.has(i,a),k=Reflect.get(i,a,g);if(R&&(e(k,n)||m.has(n)&&e(k,m.get(n))))return!0;Q(a),J(n)&&(n=fe(n)||n);let $=n;if(n instanceof Promise)n.then(A=>{n.status="fulfilled",n.value=A,b(["resolve",[a],A])}).catch(A=>{n.status="rejected",n.reason=A,b(["reject",[a],A])});else{!C.has(n)&&s(n)&&($=W(n));const A=!B.has($)&&C.get($);A&&z(a,A)}return Reflect.set(i,a,$,g),b(["set",[a],n,k]),!0}});m.set(o,V);const ie=[H,O,c,ae];return C.set(V,ie),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(V[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(H,i,a)}),V})=>[W,C,B,e,t,s,r,l,c,m,f],[me]=pe();function S(e={}){return me(e)}function j(e,t,s){const r=C.get(e);let l;const c=[],m=r[3];let f=!1;const o=m(h=>{if(c.push(h),s){t(c.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function ge(e,t){const s=C.get(e),[r,l,c]=s;return c(r,l(),t)}const d=S({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),re={state:d,subscribe(e){return j(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},p={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return p.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return p.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(p.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!p.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(p.WCM_VERSION,"2.5.9")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=re.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},he=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),u=S({enabled:he,userSessionId:"",events:[],connectedWalletId:void 0}),we={state:u,subscribe(e){return j(u.events,()=>e(ge(u.events[u.events.length-1])))},initialize(){u.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(u.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){u.connectedWalletId=e},click(e){if(u.enabled){const t={type:"CLICK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},track(e){if(u.enabled){const t={type:"TRACK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},view(e){if(u.enabled){const t={type:"VIEW",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}}},E=S({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),v={state:E,subscribe(e){return j(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},x=S({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),N={state:x,subscribe(e){return j(x,()=>e(x))},setConfig(e){var t,s;we.initialize(),v.setChains(e.chains),v.setIsAuth(!!e.enableAuthMode),v.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),v.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),p.setModalVersionInStorage(),Object.assign(x,e)}},G="https://explorer-api.walletconnect.com";async function K(e,t){const s=new URL(e,G);return s.searchParams.append("projectId",N.state.projectId),Object.entries(t).forEach(([r,l])=>{l&&s.searchParams.append(r,String(l))}),(await fetch(s)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}`}};var be=Object.defineProperty,Z=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,ee=(e,t,s)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ie=(e,t)=>{for(var s in t||(t={}))ye.call(t,s)&&ee(e,s,t[s]);if(Z)for(var s of Z(t))ve.call(t,s)&&ee(e,s,t[s]);return e};const te=p.isMobile(),L=S({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ue={state:L,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=N.state;if(e==="NONE"||t==="ALL"&&!e)return L.recomendedWallets;if(p.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await M.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),L.recomendedWallets=l}else{const{chains:s,isAuth:r}=v.state,l=s==null?void 0:s.join(","),c=p.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:p.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=te?await M.getMobileListings(m):await M.getDesktopListings(m);L.recomendedWallets=Object.values(f)}return L.recomendedWallets},async getWallets(e){const t=Ie({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=N.state,{recomendedWallets:l}=L;if(r==="ALL")return L.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):p.isArray(s)&&(t.excludedIds=s.join(",")),p.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),v.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=te?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),h=m?"search":"wallets";return L[h]={listings:[...L[h].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){L.search={listings:[],total:0,page:1}}},_=S({open:!1}),q={state:_,subscribe(e){return j(_,()=>e(_))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=v.state;if(v.setWalletConnectUri(e==null?void 0:e.uri),v.setChains(e==null?void 0:e.chains),re.reset("ConnectWallet"),s&&r)_.open=!0,t();else{const l=setInterval(()=>{const c=v.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),_.open=!0,t())},200)}})},close(){_.open=!1}};var Ee=Object.defineProperty,se=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,oe=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&oe(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&oe(e,s,t[s]);return e};function Ae(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const T=S({themeMode:Ae()?"dark":"light"}),ne={state:T,subscribe(e){return j(T,()=>e(T))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(T.themeMode=t),s&&(T.themeVariables=We({},s))}},U=S({open:!1,message:"",variant:"success"}),je={state:U,subscribe(e){return j(U,()=>e(U))},openToast(e,t){U.open=!0,U.message=e,U.variant=t},closeToast(){U.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=ce.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}),window.global||(window.global=window));class Ce{constructor(t){this.openModal=q.open,this.closeModal=q.close,this.subscribeModal=q.subscribe,this.setTheme=ne.setThemeConfig,ne.setThemeConfig(t),N.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await le(()=>import("./index-3a237630.js"),["./index-3a237630.js","./index-da732aeb.js","./index-f4824932.css","./index-cc134824.js"],import.meta.url);const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),v.setIsUiLoaded(!0)}}}const Pe=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ce},Symbol.toStringTag,{value:"Module"}));export{we as $,N as C,Ue as G,re as N,q as Q,ne as X,je as Y,Pe as a,v as c,p as i}; +import{ar as le}from"./index-1b4dc470.js";import{b as ce}from"./index-cc134824.js";const de=Symbol(),X=Object.getPrototypeOf,F=new WeakMap,ue=e=>e&&(F.has(e)?F.get(e):X(e)===Object.prototype||X(e)===Array.prototype),fe=e=>ue(e)&&e[de]||null,Y=(e,t=!0)=>{F.set(e,t)},J=e=>typeof e=="object"&&e!==null,C=new WeakMap,B=new WeakSet,pe=(e=Object.is,t=(o,h)=>new Proxy(o,h),s=o=>J(o)&&!B.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),r=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,h,I=r)=>{const w=l.get(o);if((w==null?void 0:w[0])===h)return w[1];const b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return Y(b,!0),l.set(o,[h,b]),Reflect.ownKeys(o).forEach(P=>{if(Object.getOwnPropertyDescriptor(b,P))return;const O=Reflect.get(o,P),D={value:O,enumerable:!0,configurable:!0};if(B.has(O))Y(O,!1);else if(O instanceof Promise)delete D.value,D.get=()=>I(O);else if(C.has(O)){const[y,z]=C.get(O);D.value=c(y,z(),I)}Object.defineProperty(b,P,D)}),b},m=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const h=m.get(o);if(h)return h;let I=f[0];const w=new Set,b=(i,a=++f[0])=>{I!==a&&(I=a,w.forEach(n=>n(i,a)))};let P=f[1];const O=(i=++f[1])=>(P!==i&&!w.size&&(P=i,y.forEach(([a])=>{const n=a[1](i);n>I&&(I=n)})),I),D=i=>(a,n)=>{const g=[...a];g[1]=[i,...g[1]],b(g,n)},y=new Map,z=(i,a)=>{if(w.size){const n=a[3](D(i));y.set(i,[a,n])}else y.set(i,[a])},Q=i=>{var a;const n=y.get(i);n&&(y.delete(i),(a=n[1])==null||a.call(n))},ae=i=>(w.add(i),w.size===1&&y.forEach(([n,g],R)=>{const k=n[3](D(R));y.set(R,[n,k])}),()=>{w.delete(i),w.size===0&&y.forEach(([n,g],R)=>{g&&(g(),y.set(R,[n]))})}),H=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),V=t(H,{deleteProperty(i,a){const n=Reflect.get(i,a);Q(a);const g=Reflect.deleteProperty(i,a);return g&&b(["delete",[a],n]),g},set(i,a,n,g){const R=Reflect.has(i,a),k=Reflect.get(i,a,g);if(R&&(e(k,n)||m.has(n)&&e(k,m.get(n))))return!0;Q(a),J(n)&&(n=fe(n)||n);let $=n;if(n instanceof Promise)n.then(A=>{n.status="fulfilled",n.value=A,b(["resolve",[a],A])}).catch(A=>{n.status="rejected",n.reason=A,b(["reject",[a],A])});else{!C.has(n)&&s(n)&&($=W(n));const A=!B.has($)&&C.get($);A&&z(a,A)}return Reflect.set(i,a,$,g),b(["set",[a],n,k]),!0}});m.set(o,V);const ie=[H,O,c,ae];return C.set(V,ie),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(V[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(H,i,a)}),V})=>[W,C,B,e,t,s,r,l,c,m,f],[me]=pe();function S(e={}){return me(e)}function j(e,t,s){const r=C.get(e);let l;const c=[],m=r[3];let f=!1;const o=m(h=>{if(c.push(h),s){t(c.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function ge(e,t){const s=C.get(e),[r,l,c]=s;return c(r,l(),t)}const d=S({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),re={state:d,subscribe(e){return j(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},p={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return p.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return p.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(p.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!p.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(p.WCM_VERSION,"2.5.9")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=re.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},he=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),u=S({enabled:he,userSessionId:"",events:[],connectedWalletId:void 0}),we={state:u,subscribe(e){return j(u.events,()=>e(ge(u.events[u.events.length-1])))},initialize(){u.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(u.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){u.connectedWalletId=e},click(e){if(u.enabled){const t={type:"CLICK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},track(e){if(u.enabled){const t={type:"TRACK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},view(e){if(u.enabled){const t={type:"VIEW",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}}},E=S({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),v={state:E,subscribe(e){return j(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},x=S({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),N={state:x,subscribe(e){return j(x,()=>e(x))},setConfig(e){var t,s;we.initialize(),v.setChains(e.chains),v.setIsAuth(!!e.enableAuthMode),v.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),v.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),p.setModalVersionInStorage(),Object.assign(x,e)}},G="https://explorer-api.walletconnect.com";async function K(e,t){const s=new URL(e,G);return s.searchParams.append("projectId",N.state.projectId),Object.entries(t).forEach(([r,l])=>{l&&s.searchParams.append(r,String(l))}),(await fetch(s)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}`}};var be=Object.defineProperty,Z=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,ee=(e,t,s)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ie=(e,t)=>{for(var s in t||(t={}))ye.call(t,s)&&ee(e,s,t[s]);if(Z)for(var s of Z(t))ve.call(t,s)&&ee(e,s,t[s]);return e};const te=p.isMobile(),L=S({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ue={state:L,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=N.state;if(e==="NONE"||t==="ALL"&&!e)return L.recomendedWallets;if(p.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await M.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),L.recomendedWallets=l}else{const{chains:s,isAuth:r}=v.state,l=s==null?void 0:s.join(","),c=p.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:p.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=te?await M.getMobileListings(m):await M.getDesktopListings(m);L.recomendedWallets=Object.values(f)}return L.recomendedWallets},async getWallets(e){const t=Ie({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=N.state,{recomendedWallets:l}=L;if(r==="ALL")return L.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):p.isArray(s)&&(t.excludedIds=s.join(",")),p.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),v.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=te?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),h=m?"search":"wallets";return L[h]={listings:[...L[h].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){L.search={listings:[],total:0,page:1}}},_=S({open:!1}),q={state:_,subscribe(e){return j(_,()=>e(_))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=v.state;if(v.setWalletConnectUri(e==null?void 0:e.uri),v.setChains(e==null?void 0:e.chains),re.reset("ConnectWallet"),s&&r)_.open=!0,t();else{const l=setInterval(()=>{const c=v.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),_.open=!0,t())},200)}})},close(){_.open=!1}};var Ee=Object.defineProperty,se=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,oe=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&oe(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&oe(e,s,t[s]);return e};function Ae(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const T=S({themeMode:Ae()?"dark":"light"}),ne={state:T,subscribe(e){return j(T,()=>e(T))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(T.themeMode=t),s&&(T.themeVariables=We({},s))}},U=S({open:!1,message:"",variant:"success"}),je={state:U,subscribe(e){return j(U,()=>e(U))},openToast(e,t){U.open=!0,U.message=e,U.variant=t},closeToast(){U.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=ce.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}),window.global||(window.global=window));class Ce{constructor(t){this.openModal=q.open,this.closeModal=q.close,this.subscribeModal=q.subscribe,this.setTheme=ne.setThemeConfig,ne.setThemeConfig(t),N.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await le(()=>import("./index-73787080.js"),["./index-73787080.js","./index-1b4dc470.js","./index-f4824932.css","./index-cc134824.js"],import.meta.url);const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),v.setIsUiLoaded(!0)}}}const Pe=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ce},Symbol.toStringTag,{value:"Module"}));export{we as $,N as C,Ue as G,re as N,q as Q,ne as X,je as Y,Pe as a,v as c,p as i}; diff --git a/assets/index.es-69483be7.js b/assets/index.es-5337afc7.js similarity index 99% rename from assets/index.es-69483be7.js rename to assets/index.es-5337afc7.js index 65332ed5..01580750 100644 --- a/assets/index.es-69483be7.js +++ b/assets/index.es-5337afc7.js @@ -1,4 +1,4 @@ -import{g as im,d as ds,e as ne,f as sm,w as Dl,h as Fl,j as yc,k as fo,l as nm,c as Mr,a as Ll,I as _i,A as om,U as am,m as Q,n as cm,o as oc,p as um,q as hm,P as lm,V as Ah,s as fm,D as pm,C as dm,Z as Ch,$ as gm,u as ym,v as co,x as vm,y as $l,z as Lr,B as mm,E as wm,X as hs,F as Ft,G as tr,H as wi,J as ur,K as _m,L as ls,M as Ml,N as bm,O as Em,Q as Im,R as jl,S as xm,T as zl,Y as Ul,W as fs,a0 as ac,a1 as io,a2 as ps,a3 as Sm,a4 as so,a5 as Pm,a6 as Am,a7 as Cm,a8 as Om,a9 as Rm,aa as Ha,ab as Oh,ac as Tm,ad as Nm,ae as Dm,af as Rh,ag as Fm,ah as Lm,ai as $m,aj as Mm,ak as jm,al as zm,am as Um,an as no,ao as ql,ap as ka,aq as qm,ar as Bm}from"./index-da732aeb.js";import{e as Cr,N as vc}from"./events-d5745873.js";const Hm=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,km=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Km=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Vm(c,r){if(c==="__proto__"||c==="constructor"&&r&&typeof r=="object"&&"prototype"in r){Gm(c);return}return r}function Gm(c){console.warn(`[destr] Dropping "${c}" key to prevent prototype pollution.`)}function Zn(c,r={}){if(typeof c!="string")return c;const i=c.trim();if(c[0]==='"'&&c.at(-1)==='"'&&!c.includes("\\"))return i.slice(1,-1);if(i.length<=9){const n=i.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!Km.test(c)){if(r.strict)throw new SyntaxError("[destr] Invalid JSON");return c}try{if(Hm.test(c)||km.test(c)){if(r.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(c,Vm)}return JSON.parse(c)}catch(n){if(r.strict)throw n;return c}}function Wm(c){return!c||typeof c.then!="function"?Promise.resolve(c):c}function qt(c,...r){try{return Wm(c(...r))}catch(i){return Promise.reject(i)}}function Jm(c){const r=typeof c;return c===null||r!=="object"&&r!=="function"}function Ym(c){const r=Object.getPrototypeOf(c);return!r||r.isPrototypeOf(Object)}function oo(c){if(Jm(c))return String(c);if(Ym(c)||Array.isArray(c))return JSON.stringify(c);if(typeof c.toJSON=="function")return oo(c.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Bl(){if(typeof Buffer===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const cc="base64:";function Xm(c){if(typeof c=="string")return c;Bl();const r=Buffer.from(c).toString("base64");return cc+r}function Zm(c){return typeof c!="string"||!c.startsWith(cc)?c:(Bl(),Buffer.from(c.slice(cc.length),"base64"))}function cr(c){return c?c.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Qm(...c){return cr(c.join(":"))}function Qn(c){return c=cr(c),c?c+":":""}const e1="memory",t1=()=>{const c=new Map;return{name:e1,options:{},hasItem(r){return c.has(r)},getItem(r){return c.get(r)??null},getItemRaw(r){return c.get(r)??null},setItem(r,i){c.set(r,i)},setItemRaw(r,i){c.set(r,i)},removeItem(r){c.delete(r)},getKeys(){return Array.from(c.keys())},clear(){c.clear()},dispose(){c.clear()}}};function r1(c={}){const r={mounts:{"":c.driver||t1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},i=m=>{for(const S of r.mountpoints)if(m.startsWith(S))return{base:S,relativeKey:m.slice(S.length),driver:r.mounts[S]};return{base:"",relativeKey:m,driver:r.mounts[""]}},n=(m,S)=>r.mountpoints.filter(O=>O.startsWith(m)||S&&m.startsWith(O)).map(O=>({relativeBase:m.length>O.length?m.slice(O.length):void 0,mountpoint:O,driver:r.mounts[O]})),o=(m,S)=>{if(r.watching){S=cr(S);for(const O of r.watchListeners)O(m,S)}},l=async()=>{if(!r.watching){r.watching=!0;for(const m in r.mounts)r.unwatch[m]=await Th(r.mounts[m],o,m)}},d=async()=>{if(r.watching){for(const m in r.unwatch)await r.unwatch[m]();r.unwatch={},r.watching=!1}},v=(m,S,O)=>{const F=new Map,z=R=>{let K=F.get(R.base);return K||(K={driver:R.driver,base:R.base,items:[]},F.set(R.base,K)),K};for(const R of m){const K=typeof R=="string",re=cr(K?R:R.key),he=K?void 0:R.value,le=K||!R.options?S:{...S,...R.options},fe=i(re);z(fe).items.push({key:re,value:he,relativeKey:fe.relativeKey,options:le})}return Promise.all([...F.values()].map(R=>O(R))).then(R=>R.flat())},b={hasItem(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return qt(F.hasItem,O,S)},getItem(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return qt(F.getItem,O,S).then(z=>Zn(z))},getItems(m,S){return v(m,S,O=>O.driver.getItems?qt(O.driver.getItems,O.items.map(F=>({key:F.relativeKey,options:F.options})),S).then(F=>F.map(z=>({key:Qm(O.base,z.key),value:Zn(z.value)}))):Promise.all(O.items.map(F=>qt(O.driver.getItem,F.relativeKey,F.options).then(z=>({key:F.key,value:Zn(z)})))))},getItemRaw(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return F.getItemRaw?qt(F.getItemRaw,O,S):qt(F.getItem,O,S).then(z=>Zm(z))},async setItem(m,S,O={}){if(S===void 0)return b.removeItem(m);m=cr(m);const{relativeKey:F,driver:z}=i(m);z.setItem&&(await qt(z.setItem,F,oo(S),O),z.watch||o("update",m))},async setItems(m,S){await v(m,S,async O=>{O.driver.setItems&&await qt(O.driver.setItems,O.items.map(F=>({key:F.relativeKey,value:oo(F.value),options:F.options})),S),O.driver.setItem&&await Promise.all(O.items.map(F=>qt(O.driver.setItem,F.relativeKey,oo(F.value),F.options)))})},async setItemRaw(m,S,O={}){if(S===void 0)return b.removeItem(m,O);m=cr(m);const{relativeKey:F,driver:z}=i(m);if(z.setItemRaw)await qt(z.setItemRaw,F,S,O);else if(z.setItem)await qt(z.setItem,F,Xm(S),O);else return;z.watch||o("update",m)},async removeItem(m,S={}){typeof S=="boolean"&&(S={removeMeta:S}),m=cr(m);const{relativeKey:O,driver:F}=i(m);F.removeItem&&(await qt(F.removeItem,O,S),(S.removeMeta||S.removeMata)&&await qt(F.removeItem,O+"$",S),F.watch||o("remove",m))},async getMeta(m,S={}){typeof S=="boolean"&&(S={nativeOnly:S}),m=cr(m);const{relativeKey:O,driver:F}=i(m),z=Object.create(null);if(F.getMeta&&Object.assign(z,await qt(F.getMeta,O,S)),!S.nativeOnly){const R=await qt(F.getItem,O+"$",S).then(K=>Zn(K));R&&typeof R=="object"&&(typeof R.atime=="string"&&(R.atime=new Date(R.atime)),typeof R.mtime=="string"&&(R.mtime=new Date(R.mtime)),Object.assign(z,R))}return z},setMeta(m,S,O={}){return this.setItem(m+"$",S,O)},removeMeta(m,S={}){return this.removeItem(m+"$",S)},async getKeys(m,S={}){m=Qn(m);const O=n(m,!0);let F=[];const z=[];for(const R of O){const re=(await qt(R.driver.getKeys,R.relativeBase,S)).map(he=>R.mountpoint+cr(he)).filter(he=>!F.some(le=>he.startsWith(le)));z.push(...re),F=[R.mountpoint,...F.filter(he=>!he.startsWith(R.mountpoint))]}return m?z.filter(R=>R.startsWith(m)&&!R.endsWith("$")):z.filter(R=>!R.endsWith("$"))},async clear(m,S={}){m=Qn(m),await Promise.all(n(m,!1).map(async O=>{if(O.driver.clear)return qt(O.driver.clear,O.relativeBase,S);if(O.driver.removeItem){const F=await O.driver.getKeys(O.relativeBase||"",S);return Promise.all(F.map(z=>O.driver.removeItem(z,S)))}}))},async dispose(){await Promise.all(Object.values(r.mounts).map(m=>Nh(m)))},async watch(m){return await l(),r.watchListeners.push(m),async()=>{r.watchListeners=r.watchListeners.filter(S=>S!==m),r.watchListeners.length===0&&await d()}},async unwatch(){r.watchListeners=[],await d()},mount(m,S){if(m=Qn(m),m&&r.mounts[m])throw new Error(`already mounted at ${m}`);return m&&(r.mountpoints.push(m),r.mountpoints.sort((O,F)=>F.length-O.length)),r.mounts[m]=S,r.watching&&Promise.resolve(Th(S,o,m)).then(O=>{r.unwatch[m]=O}).catch(console.error),b},async unmount(m,S=!0){m=Qn(m),!(!m||!r.mounts[m])&&(r.watching&&m in r.unwatch&&(r.unwatch[m](),delete r.unwatch[m]),S&&await Nh(r.mounts[m]),r.mountpoints=r.mountpoints.filter(O=>O!==m),delete r.mounts[m])},getMount(m=""){m=cr(m)+":";const S=i(m);return{driver:S.driver,base:S.base}},getMounts(m="",S={}){return m=cr(m),n(m,S.parents).map(F=>({driver:F.driver,base:F.mountpoint}))}};return b}function Th(c,r,i){return c.watch?c.watch((n,o)=>r(n,i+o)):()=>{}}async function Nh(c){typeof c.dispose=="function"&&await qt(c.dispose)}function qi(c){return new Promise((r,i)=>{c.oncomplete=c.onsuccess=()=>r(c.result),c.onabort=c.onerror=()=>i(c.error)})}function Hl(c,r){const i=indexedDB.open(c);i.onupgradeneeded=()=>i.result.createObjectStore(r);const n=qi(i);return(o,l)=>n.then(d=>l(d.transaction(r,o).objectStore(r)))}let Ka;function ks(){return Ka||(Ka=Hl("keyval-store","keyval")),Ka}function Dh(c,r=ks()){return r("readonly",i=>qi(i.get(c)))}function i1(c,r,i=ks()){return i("readwrite",n=>(n.put(r,c),qi(n.transaction)))}function s1(c,r=ks()){return r("readwrite",i=>(i.delete(c),qi(i.transaction)))}function n1(c=ks()){return c("readwrite",r=>(r.clear(),qi(r.transaction)))}function o1(c,r){return c.openCursor().onsuccess=function(){this.result&&(r(this.result),this.result.continue())},qi(c.transaction)}function a1(c=ks()){return c("readonly",r=>{if(r.getAllKeys)return qi(r.getAllKeys());const i=[];return o1(r,n=>i.push(n.key)).then(()=>i)})}const c1=c=>JSON.stringify(c,(r,i)=>typeof i=="bigint"?i.toString()+"n":i),u1=c=>{const r=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=c.replace(r,'$1"$2n"$3');return JSON.parse(i,(n,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function Ks(c){if(typeof c!="string")throw new Error(`Cannot safe json parse value of type ${typeof c}`);try{return u1(c)}catch{return c}}function Ui(c){return typeof c=="string"?c:c1(c)||""}const h1="idb-keyval";var l1=(c={})=>{const r=c.base&&c.base.length>0?`${c.base}:`:"",i=o=>r+o;let n;return c.dbName&&c.storeName&&(n=Hl(c.dbName,c.storeName)),{name:h1,options:c,async hasItem(o){return!(typeof await Dh(i(o),n)>"u")},async getItem(o){return await Dh(i(o),n)??null},setItem(o,l){return i1(i(o),l,n)},removeItem(o){return s1(i(o),n)},getKeys(){return a1(n)},clear(){return n1(n)}}};const f1="WALLET_CONNECT_V2_INDEXED_DB",p1="keyvaluestorage";let d1=class{constructor(){this.indexedDb=r1({driver:l1({dbName:f1,storeName:p1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(r=>[r.key,r.value])}async getItem(r){const i=await this.indexedDb.getItem(r);if(i!==null)return i}async setItem(r,i){await this.indexedDb.setItem(r,Ui(i))}async removeItem(r){await this.indexedDb.removeItem(r)}};var Va=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ao={exports:{}};(function(){let c;function r(){}c=r,c.prototype.getItem=function(i){return this.hasOwnProperty(i)?String(this[i]):null},c.prototype.setItem=function(i,n){this[i]=String(n)},c.prototype.removeItem=function(i){delete this[i]},c.prototype.clear=function(){const i=this;Object.keys(i).forEach(function(n){i[n]=void 0,delete i[n]})},c.prototype.key=function(i){return i=i||0,Object.keys(this)[i]},c.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Va<"u"&&Va.localStorage?ao.exports=Va.localStorage:typeof window<"u"&&window.localStorage?ao.exports=window.localStorage:ao.exports=new r})();function g1(c){var r;return[c[0],Ks((r=c[1])!=null?r:"")]}let y1=class{constructor(){this.localStorage=ao.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(g1)}async getItem(r){const i=this.localStorage.getItem(r);if(i!==null)return Ks(i)}async setItem(r,i){this.localStorage.setItem(r,Ui(i))}async removeItem(r){this.localStorage.removeItem(r)}};const v1="wc_storage_version",Fh=1,m1=async(c,r,i)=>{const n=v1,o=await r.getItem(n);if(o&&o>=Fh){i(r);return}const l=await c.getKeys();if(!l.length){i(r);return}const d=[];for(;l.length;){const v=l.shift();if(!v)continue;const b=v.toLowerCase();if(b.includes("wc@")||b.includes("walletconnect")||b.includes("wc_")||b.includes("wallet_connect")){const m=await c.getItem(v);await r.setItem(v,m),d.push(v)}}await r.setItem(n,Fh),i(r),w1(c,d)},w1=async(c,r)=>{r.length&&r.forEach(async i=>{await c.removeItem(i)})};let _1=class{constructor(){this.initialized=!1,this.setInitialized=i=>{this.storage=i,this.initialized=!0};const r=new y1;this.storage=r;try{const i=new d1;m1(r,i,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(r){return await this.initialize(),this.storage.getItem(r)}async setItem(r,i){return await this.initialize(),this.storage.setItem(r,i)}async removeItem(r){return await this.initialize(),this.storage.removeItem(r)}async initialize(){this.initialized||await new Promise(r=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),r())},20)})}};var gs={},Ls={},Ga={},$s={};let Bi=class{};const b1=Object.freeze(Object.defineProperty({__proto__:null,IEvents:Bi},Symbol.toStringTag,{value:"Module"})),E1=im(b1);var Lh;function I1(){if(Lh)return $s;Lh=1,Object.defineProperty($s,"__esModule",{value:!0}),$s.IHeartBeat=void 0;const c=E1;class r extends c.IEvents{constructor(n){super()}}return $s.IHeartBeat=r,$s}var $h;function kl(){return $h||($h=1,function(c){Object.defineProperty(c,"__esModule",{value:!0}),ds.__exportStar(I1(),c)}(Ga)),Ga}var Wa={},ji={},Mh;function x1(){if(Mh)return ji;Mh=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.HEARTBEAT_EVENTS=ji.HEARTBEAT_INTERVAL=void 0;const c=ne;return ji.HEARTBEAT_INTERVAL=c.FIVE_SECONDS,ji.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},ji}var jh;function Kl(){return jh||(jh=1,function(c){Object.defineProperty(c,"__esModule",{value:!0}),ds.__exportStar(x1(),c)}(Wa)),Wa}var zh;function S1(){if(zh)return Ls;zh=1,Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.HeartBeat=void 0;const c=ds,r=Cr,i=ne,n=kl(),o=Kl();class l extends n.IHeartBeat{constructor(v){super(v),this.events=new r.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(v==null?void 0:v.interval)||o.HEARTBEAT_INTERVAL}static init(v){return c.__awaiter(this,void 0,void 0,function*(){const b=new l(v);return yield b.init(),b})}init(){return c.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(v,b){this.events.on(v,b)}once(v,b){this.events.once(v,b)}off(v,b){this.events.off(v,b)}removeListener(v,b){this.events.removeListener(v,b)}initialize(){return c.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),i.toMiliseconds(this.interval))})}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return Ls.HeartBeat=l,Ls}(function(c){Object.defineProperty(c,"__esModule",{value:!0});const r=ds;r.__exportStar(S1(),c),r.__exportStar(kl(),c),r.__exportStar(Kl(),c)})(gs);var Re={},Ja,Uh;function P1(){if(Uh)return Ja;Uh=1;function c(i){try{return JSON.stringify(i)}catch{return'"[Circular]"'}}Ja=r;function r(i,n,o){var l=o&&o.stringify||c,d=1;if(typeof i=="object"&&i!==null){var v=n.length+d;if(v===1)return i;var b=new Array(v);b[0]=l(i);for(var m=1;m-1?z:0,i.charCodeAt(K+1)){case 100:case 102:if(F>=S||n[F]==null)break;z=S||n[F]==null)break;z=S||n[F]===void 0)break;z",z=K+2,K++;break}O+=l(n[F]),z=K+2,K++;break;case 115:if(F>=S)break;z-1&&(ue=!1);const Te=["error","fatal","warn","info","debug","trace"];typeof W=="function"&&(W.error=W.fatal=W.warn=W.info=W.debug=W.trace=W),L.enabled===!1&&(L.level="silent");const Ue=L.level||"info",y=Object.create(W);y.log||(y.log=re),Object.defineProperty(y,"levelVal",{get:X}),Object.defineProperty(y,"level",{get:ce,set:V});const I={transmit:q,serialize:ie,asObject:L.browser.asObject,levels:Te,timestamp:z(L)};y.levels=o.levels,y.level=Ue,y.setMaxListeners=y.getMaxListeners=y.emit=y.addListener=y.on=y.prependListener=y.once=y.prependOnceListener=y.removeListener=y.removeAllListeners=y.listeners=y.listenerCount=y.eventNames=y.write=y.flush=re,y.serializers=ve,y._serialize=ie,y._stdErrSerialize=ue,y.child=B,q&&(y._logEvent=O());function X(){return this.level==="silent"?1/0:this.levels.values[this.level]}function ce(){return this._level}function V(k){if(k!=="silent"&&!this.levels.values[k])throw Error("unknown level "+k);this._level=k,l(I,y,"error","log"),l(I,y,"fatal","error"),l(I,y,"warn","error"),l(I,y,"info","log"),l(I,y,"debug","log"),l(I,y,"trace","log")}function B(k,G){if(!k)throw new Error("missing bindings for child Pino");G=G||{},ie&&k.serializers&&(G.serializers=k.serializers);const Je=G.serializers;if(ie&&Je){var He=Object.assign({},ve,Je),jr=L.browser.serialize===!0?Object.keys(He):ie;delete k.serializers,b([k],jr,He,this._stdErrSerialize)}function Ie(xt){this._childLevel=(xt._childLevel|0)+1,this.error=m(xt,k,"error"),this.fatal=m(xt,k,"fatal"),this.warn=m(xt,k,"warn"),this.info=m(xt,k,"info"),this.debug=m(xt,k,"debug"),this.trace=m(xt,k,"trace"),He&&(this.serializers=He,this._serialize=jr),q&&(this._logEvent=O([].concat(xt._logEvent.bindings,k)))}return Ie.prototype=this,new Ie(this)}return y}o.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},o.stdSerializers=i,o.stdTimeFunctions=Object.assign({},{nullTime:he,epochTime:le,unixTime:fe,isoTime:pe});function l(L,q,W,ve){const ie=Object.getPrototypeOf(q);q[W]=q.levelVal>q.levels.values[W]?re:ie[W]?ie[W]:r[W]||r[ve]||re,d(L,q,W)}function d(L,q,W){!L.transmit&&q[W]===re||(q[W]=function(ve){return function(){const ue=L.timestamp(),Te=new Array(arguments.length),Ue=Object.getPrototypeOf&&Object.getPrototypeOf(this)===r?r:this;for(var y=0;y-1&&ue in W&&(L[ie][ue]=W[ue](L[ie][ue]))}function m(L,q,W){return function(){const ve=new Array(1+arguments.length);ve[0]=q;for(var ie=1;ie"u"?m=i(v,b):m=v.bindings().context||"",m}er.getLoggerContext=o;function l(v,b,m=c.PINO_CUSTOM_CONTEXT_KEY){const S=o(v,m);return S.trim()?`${S}/${b}`:b}er.formatChildLoggerContext=l;function d(v,b,m=c.PINO_CUSTOM_CONTEXT_KEY){const S=l(v,b,m),O=v.child({context:S});return n(O,S,m)}return er.generateChildLogger=d,er}(function(c){Object.defineProperty(c,"__esModule",{value:!0}),c.pino=void 0;const r=ds,i=r.__importDefault(A1());Object.defineProperty(c,"pino",{enumerable:!0,get:function(){return i.default}}),r.__exportStar(Vl(),c),r.__exportStar(C1(),c)})(Re);class O1 extends Bi{constructor(r){super(),this.opts=r,this.protocol="wc",this.version=2}}class R1 extends Bi{constructor(r,i){super(),this.core=r,this.logger=i,this.records=new Map}}class T1{constructor(r,i){this.logger=r,this.core=i}}let N1=class extends Bi{constructor(r,i){super(),this.relayer=r,this.logger=i}},D1=class extends Bi{constructor(r){super()}},F1=class{constructor(r,i,n,o){this.core=r,this.logger=i,this.name=n}};class L1 extends Bi{constructor(r,i){super(),this.relayer=r,this.logger=i}}let $1=class extends Bi{constructor(r,i){super(),this.core=r,this.logger=i}},M1=class{constructor(r,i){this.projectId=r,this.logger=i}},j1=class{constructor(r){this.opts=r,this.protocol="wc",this.version=2}},z1=class{constructor(r){this.client=r}};var mc={},Gl={};(function(c){Object.defineProperty(c,"__esModule",{value:!0});var r=sm,i=Dl;c.DIGEST_LENGTH=64,c.BLOCK_SIZE=128;var n=function(){function v(){this.digestLength=c.DIGEST_LENGTH,this.blockSize=c.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return v.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},v.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},v.prototype.clean=function(){i.wipe(this._buffer),i.wipe(this._tempHi),i.wipe(this._tempLo),this.reset()},v.prototype.update=function(b,m){if(m===void 0&&(m=b.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var S=0;if(this._bytesHashed+=m,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[S++],m--;this._bufferLength===this.blockSize&&(l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(m>=this.blockSize&&(S=l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,b,S,m),m%=this.blockSize);m>0;)this._buffer[this._bufferLength++]=b[S++],m--;return this},v.prototype.finish=function(b){if(!this._finished){var m=this._bytesHashed,S=this._bufferLength,O=m/536870912|0,F=m<<3,z=m%128<112?128:256;this._buffer[S]=128;for(var R=S+1;R0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},v.prototype.restoreState=function(b){return this._stateHi.set(b.stateHi),this._stateLo.set(b.stateLo),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},v.prototype.cleanSavedState=function(b){i.wipe(b.stateHi),i.wipe(b.stateLo),b.buffer&&i.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},v}();c.SHA512=n;var o=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function l(v,b,m,S,O,F,z){for(var R=m[0],K=m[1],re=m[2],he=m[3],le=m[4],fe=m[5],pe=m[6],de=m[7],L=S[0],q=S[1],W=S[2],ve=S[3],ie=S[4],ue=S[5],Te=S[6],Ue=S[7],y,I,X,ce,V,B,k,G;z>=128;){for(var Je=0;Je<16;Je++){var He=8*Je+F;v[Je]=r.readUint32BE(O,He),b[Je]=r.readUint32BE(O,He+4)}for(var Je=0;Je<80;Je++){var jr=R,Ie=K,xt=re,D=he,N=le,C=fe,u=pe,E=de,ee=L,ge=q,be=W,Ne=ve,Fe=ie,Pe=ue,St=Te,mt=Ue;if(y=de,I=Ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=(le>>>14|ie<<32-14)^(le>>>18|ie<<32-18)^(ie>>>41-32|le<<32-(41-32)),I=(ie>>>14|le<<32-14)^(ie>>>18|le<<32-18)^(le>>>41-32|ie<<32-(41-32)),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=le&fe^~le&pe,I=ie&ue^~ie&Te,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=o[Je*2],I=o[Je*2+1],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=v[Je%16],I=b[Je%16],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,X=k&65535|G<<16,ce=V&65535|B<<16,y=X,I=ce,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=(R>>>28|L<<32-28)^(L>>>34-32|R<<32-(34-32))^(L>>>39-32|R<<32-(39-32)),I=(L>>>28|R<<32-28)^(R>>>34-32|L<<32-(34-32))^(R>>>39-32|L<<32-(39-32)),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=R&K^R&re^K&re,I=L&q^L&W^q&W,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,E=k&65535|G<<16,mt=V&65535|B<<16,y=D,I=Ne,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=X,I=ce,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,D=k&65535|G<<16,Ne=V&65535|B<<16,K=jr,re=Ie,he=xt,le=D,fe=N,pe=C,de=u,R=E,q=ee,W=ge,ve=be,ie=Ne,ue=Fe,Te=Pe,Ue=St,L=mt,Je%16===15)for(var He=0;He<16;He++)y=v[He],I=b[He],V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=v[(He+9)%16],I=b[(He+9)%16],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,X=v[(He+1)%16],ce=b[(He+1)%16],y=(X>>>1|ce<<32-1)^(X>>>8|ce<<32-8)^X>>>7,I=(ce>>>1|X<<32-1)^(ce>>>8|X<<32-8)^(ce>>>7|X<<32-7),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,X=v[(He+14)%16],ce=b[(He+14)%16],y=(X>>>19|ce<<32-19)^(ce>>>61-32|X<<32-(61-32))^X>>>6,I=(ce>>>19|X<<32-19)^(X>>>61-32|ce<<32-(61-32))^(ce>>>6|X<<32-6),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,v[He]=k&65535|G<<16,b[He]=V&65535|B<<16}y=R,I=L,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[0],I=S[0],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[0]=R=k&65535|G<<16,S[0]=L=V&65535|B<<16,y=K,I=q,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[1],I=S[1],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[1]=K=k&65535|G<<16,S[1]=q=V&65535|B<<16,y=re,I=W,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[2],I=S[2],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[2]=re=k&65535|G<<16,S[2]=W=V&65535|B<<16,y=he,I=ve,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[3],I=S[3],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[3]=he=k&65535|G<<16,S[3]=ve=V&65535|B<<16,y=le,I=ie,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[4],I=S[4],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[4]=le=k&65535|G<<16,S[4]=ie=V&65535|B<<16,y=fe,I=ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[5],I=S[5],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[5]=fe=k&65535|G<<16,S[5]=ue=V&65535|B<<16,y=pe,I=Te,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[6],I=S[6],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[6]=pe=k&65535|G<<16,S[6]=Te=V&65535|B<<16,y=de,I=Ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[7],I=S[7],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[7]=de=k&65535|G<<16,S[7]=Ue=V&65535|B<<16,F+=128,z-=128}return F}function d(v){var b=new n;b.update(v);var m=b.digest();return b.clean(),m}c.hash=d})(Gl);(function(c){Object.defineProperty(c,"__esModule",{value:!0}),c.convertSecretKeyToX25519=c.convertPublicKeyToX25519=c.verify=c.sign=c.extractPublicKeyFromSecretKey=c.generateKeyPair=c.generateKeyPairFromSeed=c.SEED_LENGTH=c.SECRET_KEY_LENGTH=c.PUBLIC_KEY_LENGTH=c.SIGNATURE_LENGTH=void 0;const r=Fl,i=Gl,n=Dl;c.SIGNATURE_LENGTH=64,c.PUBLIC_KEY_LENGTH=32,c.SECRET_KEY_LENGTH=64,c.SEED_LENGTH=32;function o(D){const N=new Float64Array(16);if(D)for(let C=0;C>16&1),C[ge-1]&=65535;C[15]=u[15]-32767-(C[14]>>16&1);const ee=C[15]>>16&1;C[14]&=65535,K(u,C,1-ee)}for(let E=0;E<16;E++)D[2*E]=u[E]&255,D[2*E+1]=u[E]>>8}function he(D,N){let C=0;for(let u=0;u<32;u++)C|=D[u]^N[u];return(1&C-1>>>8)-1}function le(D,N){const C=new Uint8Array(32),u=new Uint8Array(32);return re(C,D),re(u,N),he(C,u)}function fe(D){const N=new Uint8Array(32);return re(N,D),N[0]&1}function pe(D,N){for(let C=0;C<16;C++)D[C]=N[2*C]+(N[2*C+1]<<8);D[15]&=32767}function de(D,N,C){for(let u=0;u<16;u++)D[u]=N[u]+C[u]}function L(D,N,C){for(let u=0;u<16;u++)D[u]=N[u]-C[u]}function q(D,N,C){let u,E,ee=0,ge=0,be=0,Ne=0,Fe=0,Pe=0,St=0,mt=0,nt=0,$e=0,Xe=0,Ze=0,ot=0,qe=0,Qe=0,De=0,ke=0,ut=0,je=0,Pt=0,Lt=0,Bt=0,Ht=0,jt=0,Wt=0,rr=0,zr=0,Jt=0,Gr=0,ci=0,xi=0,ht=C[0],rt=C[1],lt=C[2],ft=C[3],at=C[4],it=C[5],At=C[6],Ct=C[7],pt=C[8],Ot=C[9],dt=C[10],wt=C[11],gt=C[12],Ye=C[13],Rt=C[14],Tt=C[15];u=N[0],ee+=u*ht,ge+=u*rt,be+=u*lt,Ne+=u*ft,Fe+=u*at,Pe+=u*it,St+=u*At,mt+=u*Ct,nt+=u*pt,$e+=u*Ot,Xe+=u*dt,Ze+=u*wt,ot+=u*gt,qe+=u*Ye,Qe+=u*Rt,De+=u*Tt,u=N[1],ge+=u*ht,be+=u*rt,Ne+=u*lt,Fe+=u*ft,Pe+=u*at,St+=u*it,mt+=u*At,nt+=u*Ct,$e+=u*pt,Xe+=u*Ot,Ze+=u*dt,ot+=u*wt,qe+=u*gt,Qe+=u*Ye,De+=u*Rt,ke+=u*Tt,u=N[2],be+=u*ht,Ne+=u*rt,Fe+=u*lt,Pe+=u*ft,St+=u*at,mt+=u*it,nt+=u*At,$e+=u*Ct,Xe+=u*pt,Ze+=u*Ot,ot+=u*dt,qe+=u*wt,Qe+=u*gt,De+=u*Ye,ke+=u*Rt,ut+=u*Tt,u=N[3],Ne+=u*ht,Fe+=u*rt,Pe+=u*lt,St+=u*ft,mt+=u*at,nt+=u*it,$e+=u*At,Xe+=u*Ct,Ze+=u*pt,ot+=u*Ot,qe+=u*dt,Qe+=u*wt,De+=u*gt,ke+=u*Ye,ut+=u*Rt,je+=u*Tt,u=N[4],Fe+=u*ht,Pe+=u*rt,St+=u*lt,mt+=u*ft,nt+=u*at,$e+=u*it,Xe+=u*At,Ze+=u*Ct,ot+=u*pt,qe+=u*Ot,Qe+=u*dt,De+=u*wt,ke+=u*gt,ut+=u*Ye,je+=u*Rt,Pt+=u*Tt,u=N[5],Pe+=u*ht,St+=u*rt,mt+=u*lt,nt+=u*ft,$e+=u*at,Xe+=u*it,Ze+=u*At,ot+=u*Ct,qe+=u*pt,Qe+=u*Ot,De+=u*dt,ke+=u*wt,ut+=u*gt,je+=u*Ye,Pt+=u*Rt,Lt+=u*Tt,u=N[6],St+=u*ht,mt+=u*rt,nt+=u*lt,$e+=u*ft,Xe+=u*at,Ze+=u*it,ot+=u*At,qe+=u*Ct,Qe+=u*pt,De+=u*Ot,ke+=u*dt,ut+=u*wt,je+=u*gt,Pt+=u*Ye,Lt+=u*Rt,Bt+=u*Tt,u=N[7],mt+=u*ht,nt+=u*rt,$e+=u*lt,Xe+=u*ft,Ze+=u*at,ot+=u*it,qe+=u*At,Qe+=u*Ct,De+=u*pt,ke+=u*Ot,ut+=u*dt,je+=u*wt,Pt+=u*gt,Lt+=u*Ye,Bt+=u*Rt,Ht+=u*Tt,u=N[8],nt+=u*ht,$e+=u*rt,Xe+=u*lt,Ze+=u*ft,ot+=u*at,qe+=u*it,Qe+=u*At,De+=u*Ct,ke+=u*pt,ut+=u*Ot,je+=u*dt,Pt+=u*wt,Lt+=u*gt,Bt+=u*Ye,Ht+=u*Rt,jt+=u*Tt,u=N[9],$e+=u*ht,Xe+=u*rt,Ze+=u*lt,ot+=u*ft,qe+=u*at,Qe+=u*it,De+=u*At,ke+=u*Ct,ut+=u*pt,je+=u*Ot,Pt+=u*dt,Lt+=u*wt,Bt+=u*gt,Ht+=u*Ye,jt+=u*Rt,Wt+=u*Tt,u=N[10],Xe+=u*ht,Ze+=u*rt,ot+=u*lt,qe+=u*ft,Qe+=u*at,De+=u*it,ke+=u*At,ut+=u*Ct,je+=u*pt,Pt+=u*Ot,Lt+=u*dt,Bt+=u*wt,Ht+=u*gt,jt+=u*Ye,Wt+=u*Rt,rr+=u*Tt,u=N[11],Ze+=u*ht,ot+=u*rt,qe+=u*lt,Qe+=u*ft,De+=u*at,ke+=u*it,ut+=u*At,je+=u*Ct,Pt+=u*pt,Lt+=u*Ot,Bt+=u*dt,Ht+=u*wt,jt+=u*gt,Wt+=u*Ye,rr+=u*Rt,zr+=u*Tt,u=N[12],ot+=u*ht,qe+=u*rt,Qe+=u*lt,De+=u*ft,ke+=u*at,ut+=u*it,je+=u*At,Pt+=u*Ct,Lt+=u*pt,Bt+=u*Ot,Ht+=u*dt,jt+=u*wt,Wt+=u*gt,rr+=u*Ye,zr+=u*Rt,Jt+=u*Tt,u=N[13],qe+=u*ht,Qe+=u*rt,De+=u*lt,ke+=u*ft,ut+=u*at,je+=u*it,Pt+=u*At,Lt+=u*Ct,Bt+=u*pt,Ht+=u*Ot,jt+=u*dt,Wt+=u*wt,rr+=u*gt,zr+=u*Ye,Jt+=u*Rt,Gr+=u*Tt,u=N[14],Qe+=u*ht,De+=u*rt,ke+=u*lt,ut+=u*ft,je+=u*at,Pt+=u*it,Lt+=u*At,Bt+=u*Ct,Ht+=u*pt,jt+=u*Ot,Wt+=u*dt,rr+=u*wt,zr+=u*gt,Jt+=u*Ye,Gr+=u*Rt,ci+=u*Tt,u=N[15],De+=u*ht,ke+=u*rt,ut+=u*lt,je+=u*ft,Pt+=u*at,Lt+=u*it,Bt+=u*At,Ht+=u*Ct,jt+=u*pt,Wt+=u*Ot,rr+=u*dt,zr+=u*wt,Jt+=u*gt,Gr+=u*Ye,ci+=u*Rt,xi+=u*Tt,ee+=38*ke,ge+=38*ut,be+=38*je,Ne+=38*Pt,Fe+=38*Lt,Pe+=38*Bt,St+=38*Ht,mt+=38*jt,nt+=38*Wt,$e+=38*rr,Xe+=38*zr,Ze+=38*Jt,ot+=38*Gr,qe+=38*ci,Qe+=38*xi,E=1,u=ee+E+65535,E=Math.floor(u/65536),ee=u-E*65536,u=ge+E+65535,E=Math.floor(u/65536),ge=u-E*65536,u=be+E+65535,E=Math.floor(u/65536),be=u-E*65536,u=Ne+E+65535,E=Math.floor(u/65536),Ne=u-E*65536,u=Fe+E+65535,E=Math.floor(u/65536),Fe=u-E*65536,u=Pe+E+65535,E=Math.floor(u/65536),Pe=u-E*65536,u=St+E+65535,E=Math.floor(u/65536),St=u-E*65536,u=mt+E+65535,E=Math.floor(u/65536),mt=u-E*65536,u=nt+E+65535,E=Math.floor(u/65536),nt=u-E*65536,u=$e+E+65535,E=Math.floor(u/65536),$e=u-E*65536,u=Xe+E+65535,E=Math.floor(u/65536),Xe=u-E*65536,u=Ze+E+65535,E=Math.floor(u/65536),Ze=u-E*65536,u=ot+E+65535,E=Math.floor(u/65536),ot=u-E*65536,u=qe+E+65535,E=Math.floor(u/65536),qe=u-E*65536,u=Qe+E+65535,E=Math.floor(u/65536),Qe=u-E*65536,u=De+E+65535,E=Math.floor(u/65536),De=u-E*65536,ee+=E-1+37*(E-1),E=1,u=ee+E+65535,E=Math.floor(u/65536),ee=u-E*65536,u=ge+E+65535,E=Math.floor(u/65536),ge=u-E*65536,u=be+E+65535,E=Math.floor(u/65536),be=u-E*65536,u=Ne+E+65535,E=Math.floor(u/65536),Ne=u-E*65536,u=Fe+E+65535,E=Math.floor(u/65536),Fe=u-E*65536,u=Pe+E+65535,E=Math.floor(u/65536),Pe=u-E*65536,u=St+E+65535,E=Math.floor(u/65536),St=u-E*65536,u=mt+E+65535,E=Math.floor(u/65536),mt=u-E*65536,u=nt+E+65535,E=Math.floor(u/65536),nt=u-E*65536,u=$e+E+65535,E=Math.floor(u/65536),$e=u-E*65536,u=Xe+E+65535,E=Math.floor(u/65536),Xe=u-E*65536,u=Ze+E+65535,E=Math.floor(u/65536),Ze=u-E*65536,u=ot+E+65535,E=Math.floor(u/65536),ot=u-E*65536,u=qe+E+65535,E=Math.floor(u/65536),qe=u-E*65536,u=Qe+E+65535,E=Math.floor(u/65536),Qe=u-E*65536,u=De+E+65535,E=Math.floor(u/65536),De=u-E*65536,ee+=E-1+37*(E-1),D[0]=ee,D[1]=ge,D[2]=be,D[3]=Ne,D[4]=Fe,D[5]=Pe,D[6]=St,D[7]=mt,D[8]=nt,D[9]=$e,D[10]=Xe,D[11]=Ze,D[12]=ot,D[13]=qe,D[14]=Qe,D[15]=De}function W(D,N){q(D,N,N)}function ve(D,N){const C=o();let u;for(u=0;u<16;u++)C[u]=N[u];for(u=253;u>=0;u--)W(C,C),u!==2&&u!==4&&q(C,C,N);for(u=0;u<16;u++)D[u]=C[u]}function ie(D,N){const C=o();let u;for(u=0;u<16;u++)C[u]=N[u];for(u=250;u>=0;u--)W(C,C),u!==1&&q(C,C,N);for(u=0;u<16;u++)D[u]=C[u]}function ue(D,N){const C=o(),u=o(),E=o(),ee=o(),ge=o(),be=o(),Ne=o(),Fe=o(),Pe=o();L(C,D[1],D[0]),L(Pe,N[1],N[0]),q(C,C,Pe),de(u,D[0],D[1]),de(Pe,N[0],N[1]),q(u,u,Pe),q(E,D[3],N[3]),q(E,E,m),q(ee,D[2],N[2]),de(ee,ee,ee),L(ge,u,C),L(be,ee,E),de(Ne,ee,E),de(Fe,u,C),q(D[0],ge,be),q(D[1],Fe,Ne),q(D[2],Ne,be),q(D[3],ge,Fe)}function Te(D,N,C){for(let u=0;u<4;u++)K(D[u],N[u],C)}function Ue(D,N){const C=o(),u=o(),E=o();ve(E,N[2]),q(C,N[0],E),q(u,N[1],E),re(D,u),D[31]^=fe(C)<<7}function y(D,N,C){z(D[0],d),z(D[1],v),z(D[2],v),z(D[3],d);for(let u=255;u>=0;--u){const E=C[u/8|0]>>(u&7)&1;Te(D,N,E),ue(N,D),ue(D,D),Te(D,N,E)}}function I(D,N){const C=[o(),o(),o(),o()];z(C[0],S),z(C[1],O),z(C[2],v),q(C[3],S,O),y(D,C,N)}function X(D){if(D.length!==c.SEED_LENGTH)throw new Error(`ed25519: seed must be ${c.SEED_LENGTH} bytes`);const N=(0,i.hash)(D);N[0]&=248,N[31]&=127,N[31]|=64;const C=new Uint8Array(32),u=[o(),o(),o(),o()];I(u,N),Ue(C,u);const E=new Uint8Array(64);return E.set(D),E.set(C,32),{publicKey:C,secretKey:E}}c.generateKeyPairFromSeed=X;function ce(D){const N=(0,r.randomBytes)(32,D),C=X(N);return(0,n.wipe)(N),C}c.generateKeyPair=ce;function V(D){if(D.length!==c.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${c.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(D.subarray(32))}c.extractPublicKeyFromSecretKey=V;const B=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function k(D,N){let C,u,E,ee;for(u=63;u>=32;--u){for(C=0,E=u-32,ee=u-12;E>4)*B[E],C=N[E]>>8,N[E]&=255;for(E=0;E<32;E++)N[E]-=C*B[E];for(u=0;u<32;u++)N[u+1]+=N[u]>>8,D[u]=N[u]&255}function G(D){const N=new Float64Array(64);for(let C=0;C<64;C++)N[C]=D[C];for(let C=0;C<64;C++)D[C]=0;k(D,N)}function Je(D,N){const C=new Float64Array(64),u=[o(),o(),o(),o()],E=(0,i.hash)(D.subarray(0,32));E[0]&=248,E[31]&=127,E[31]|=64;const ee=new Uint8Array(64);ee.set(E.subarray(32),32);const ge=new i.SHA512;ge.update(ee.subarray(32)),ge.update(N);const be=ge.digest();ge.clean(),G(be),I(u,be),Ue(ee,u),ge.reset(),ge.update(ee.subarray(0,32)),ge.update(D.subarray(32)),ge.update(N);const Ne=ge.digest();G(Ne);for(let Fe=0;Fe<32;Fe++)C[Fe]=be[Fe];for(let Fe=0;Fe<32;Fe++)for(let Pe=0;Pe<32;Pe++)C[Fe+Pe]+=Ne[Fe]*E[Pe];return k(ee.subarray(32),C),ee}c.sign=Je;function He(D,N){const C=o(),u=o(),E=o(),ee=o(),ge=o(),be=o(),Ne=o();return z(D[2],v),pe(D[1],N),W(E,D[1]),q(ee,E,b),L(E,E,D[2]),de(ee,D[2],ee),W(ge,ee),W(be,ge),q(Ne,be,ge),q(C,Ne,E),q(C,C,ee),ie(C,C),q(C,C,E),q(C,C,ee),q(C,C,ee),q(D[0],C,ee),W(u,D[0]),q(u,u,ee),le(u,E)&&q(D[0],D[0],F),W(u,D[0]),q(u,u,ee),le(u,E)?-1:(fe(D[0])===N[31]>>7&&L(D[0],d,D[0]),q(D[3],D[0],D[1]),0)}function jr(D,N,C){const u=new Uint8Array(32),E=[o(),o(),o(),o()],ee=[o(),o(),o(),o()];if(C.length!==c.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${c.SIGNATURE_LENGTH} bytes`);if(He(ee,D))return!1;const ge=new i.SHA512;ge.update(C.subarray(0,32)),ge.update(D),ge.update(N);const be=ge.digest();return G(be),y(E,ee,be),I(ee,C.subarray(32)),ue(E,ee),Ue(u,E),!he(C,u)}c.verify=jr;function Ie(D){let N=[o(),o(),o(),o()];if(He(N,D))throw new Error("Ed25519: invalid public key");let C=o(),u=o(),E=N[1];de(C,v,E),L(u,v,E),ve(u,u),q(C,C,u);let ee=new Uint8Array(32);return re(ee,C),ee}c.convertPublicKeyToX25519=Ie;function xt(D){const N=(0,i.hash)(D.subarray(0,32));N[0]&=248,N[31]&=127,N[31]|=64;const C=new Uint8Array(N.subarray(0,32));return(0,n.wipe)(N),C}c.convertSecretKeyToX25519=xt})(mc);const U1="EdDSA",q1="JWT",Wl=".",Jl="base64url",B1="utf8",H1="utf8",k1=":",K1="did",V1="key",kh="base58btc",G1="z",W1="K36",J1=32;function uo(c){return fo(yc(Ui(c),B1),Jl)}function Yl(c){const r=yc(W1,kh),i=G1+fo(nm([r,c]),kh);return[K1,V1,i].join(k1)}function Y1(c){return fo(c,Jl)}function X1(c){return yc([uo(c.header),uo(c.payload)].join(Wl),H1)}function Z1(c){return[uo(c.header),uo(c.payload),Y1(c.signature)].join(Wl)}function Kh(c=Fl.randomBytes(J1)){return mc.generateKeyPairFromSeed(c)}async function Q1(c,r,i,n,o=ne.fromMiliseconds(Date.now())){const l={alg:U1,typ:q1},d=Yl(n.publicKey),v=o+i,b={iss:d,sub:c,aud:r,iat:o,exp:v},m=X1({header:l,payload:b}),S=mc.sign(n.secretKey,m);return Z1({header:l,payload:b,signature:S})}const ew="PARSE_ERROR",tw="INVALID_REQUEST",rw="METHOD_NOT_FOUND",iw="INVALID_PARAMS",Xl="INTERNAL_ERROR",wc="SERVER_ERROR",sw=[-32700,-32600,-32601,-32602,-32603],Hs={[ew]:{code:-32700,message:"Parse error"},[tw]:{code:-32600,message:"Invalid Request"},[rw]:{code:-32601,message:"Method not found"},[iw]:{code:-32602,message:"Invalid params"},[Xl]:{code:-32603,message:"Internal error"},[wc]:{code:-32e3,message:"Server error"}},Zl=wc;function nw(c){return sw.includes(c)}function Vh(c){return Object.keys(Hs).includes(c)?Hs[c]:Hs[Zl]}function ow(c){const r=Object.values(Hs).find(i=>i.code===c);return r||Hs[Zl]}function Ql(c,r,i){return c.message.includes("getaddrinfo ENOTFOUND")||c.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${i} RPC url at ${r}`):c}var ef={},ni={},Gh;function aw(){if(Gh)return ni;Gh=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.isBrowserCryptoAvailable=ni.getSubtleCrypto=ni.getBrowerCrypto=void 0;function c(){return(Mr===null||Mr===void 0?void 0:Mr.crypto)||(Mr===null||Mr===void 0?void 0:Mr.msCrypto)||{}}ni.getBrowerCrypto=c;function r(){const n=c();return n.subtle||n.webkitSubtle}ni.getSubtleCrypto=r;function i(){return!!c()&&!!r()}return ni.isBrowserCryptoAvailable=i,ni}var oi={},Wh;function cw(){if(Wh)return oi;Wh=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowser=oi.isNode=oi.isReactNative=void 0;function c(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}oi.isReactNative=c;function r(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}oi.isNode=r;function i(){return!c()&&!r()}return oi.isBrowser=i,oi}(function(c){Object.defineProperty(c,"__esModule",{value:!0});const r=ds;r.__exportStar(aw(),c),r.__exportStar(cw(),c)})(ef);function tf(c=3){const r=Date.now()*Math.pow(10,c),i=Math.floor(Math.random()*Math.pow(10,c));return r+i}function _c(c=6){return BigInt(tf(c))}function po(c,r,i){return{id:i||tf(),jsonrpc:"2.0",method:c,params:r}}function bc(c,r){return{id:c,jsonrpc:"2.0",result:r}}function go(c,r,i){return{id:c,jsonrpc:"2.0",error:uw(r,i)}}function uw(c,r){return typeof c>"u"?Vh(Xl):(typeof c=="string"&&(c=Object.assign(Object.assign({},Vh(wc)),{message:c})),typeof r<"u"&&(c.data=r),nw(c.code)&&(c=ow(c.code)),c)}class hw{}class lw extends hw{constructor(){super()}}class fw extends lw{constructor(r){super()}}const pw="^https?:",dw="^wss?:";function gw(c){const r=c.match(new RegExp(/^\w+:/,"gi"));if(!(!r||!r.length))return r[0]}function rf(c,r){const i=gw(c);return typeof i>"u"?!1:new RegExp(r).test(i)}function Jh(c){return rf(c,pw)}function Yh(c){return rf(c,dw)}function yw(c){return new RegExp("wss?://localhost(:d{2,5})?").test(c)}function sf(c){return typeof c=="object"&&"id"in c&&"jsonrpc"in c&&c.jsonrpc==="2.0"}function Ec(c){return sf(c)&&"method"in c}function yo(c){return sf(c)&&(ai(c)||$r(c))}function ai(c){return"result"in c}function $r(c){return"error"in c}class Ei extends fw{constructor(r){super(r),this.events=new Cr.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(r),this.connection.connected&&this.registerEventListeners()}async connect(r=this.connection){await this.open(r)}async disconnect(){await this.close()}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async request(r,i){return this.requestStrict(po(r.method,r.params||[],r.id||_c().toString()),i)}async requestStrict(r,i){return new Promise(async(n,o)=>{if(!this.connection.connected)try{await this.open()}catch(l){o(l)}this.events.on(`${r.id}`,l=>{$r(l)?o(l.error):n(l.result)});try{await this.connection.send(r,i)}catch(l){o(l)}})}setConnection(r=this.connection){return r}onPayload(r){this.events.emit("payload",r),yo(r)?this.events.emit(`${r.id}`,r):this.events.emit("message",{type:r.method,data:r.params})}onClose(r){r&&r.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${r.code} ${r.reason?`(${r.reason})`:""}`)),this.events.emit("disconnect")}async open(r=this.connection){this.connection===r&&this.connection.connected||(this.connection.connected&&this.close(),typeof r=="string"&&(await this.connection.open(r),r=this.connection),this.connection=this.setConnection(r),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",r=>this.onPayload(r)),this.connection.on("close",r=>this.onClose(r)),this.connection.on("error",r=>this.events.emit("error",r)),this.connection.on("register_error",r=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const vw=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),mw=()=>typeof window<"u",Xh=c=>c.split("?")[0],Zh=10,ww=vw();class _w{constructor(r){if(this.url=r,this.events=new Cr.EventEmitter,this.registering=!1,!Yh(r))throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);this.url=r}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async open(r=this.url){await this.register(r)}async close(){return new Promise((r,i)=>{if(typeof this.socket>"u"){i(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),r()},this.socket.close()})}async send(r,i){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ui(r))}catch(n){this.onError(r.id,n)}}register(r=this.url){if(!Yh(r))throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((n,o)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),o(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=r,this.registering=!0,new Promise((i,n)=>{const o=ef.isReactNative()?void 0:{rejectUnauthorized:!yw(r)},l=new ww(r,[],o);mw()?l.onerror=d=>{const v=d;n(this.emitError(v.error))}:l.on("error",d=>{n(this.emitError(d))}),l.onopen=()=>{this.onOpen(l),i(l)}})}onOpen(r){r.onmessage=i=>this.onPayload(i),r.onclose=i=>this.onClose(i),this.socket=r,this.registering=!1,this.events.emit("open")}onClose(r){this.socket=void 0,this.registering=!1,this.events.emit("close",r)}onPayload(r){if(typeof r.data>"u")return;const i=typeof r.data=="string"?Ks(r.data):r.data;this.events.emit("payload",i)}onError(r,i){const n=this.parseError(i),o=n.message||n.toString(),l=go(r,o);this.events.emit("payload",l)}parseError(r,i=this.url){return Ql(r,Xh(i),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Zh&&this.events.setMaxListeners(Zh)}emitError(r){const i=this.parseError(new Error((r==null?void 0:r.message)||`WebSocket connection failed for host: ${Xh(this.url)}`));return this.events.emit("register_error",i),i}}var ho={exports:{}};ho.exports;(function(c,r){var i=200,n="__lodash_hash_undefined__",o=1,l=2,d=9007199254740991,v="[object Arguments]",b="[object Array]",m="[object AsyncFunction]",S="[object Boolean]",O="[object Date]",F="[object Error]",z="[object Function]",R="[object GeneratorFunction]",K="[object Map]",re="[object Number]",he="[object Null]",le="[object Object]",fe="[object Promise]",pe="[object Proxy]",de="[object RegExp]",L="[object Set]",q="[object String]",W="[object Symbol]",ve="[object Undefined]",ie="[object WeakMap]",ue="[object ArrayBuffer]",Te="[object DataView]",Ue="[object Float32Array]",y="[object Float64Array]",I="[object Int8Array]",X="[object Int16Array]",ce="[object Int32Array]",V="[object Uint8Array]",B="[object Uint8ClampedArray]",k="[object Uint16Array]",G="[object Uint32Array]",Je=/[\\^$.*+?()[\]{}|]/g,He=/^\[object .+?Constructor\]$/,jr=/^(?:0|[1-9]\d*)$/,Ie={};Ie[Ue]=Ie[y]=Ie[I]=Ie[X]=Ie[ce]=Ie[V]=Ie[B]=Ie[k]=Ie[G]=!0,Ie[v]=Ie[b]=Ie[ue]=Ie[S]=Ie[Te]=Ie[O]=Ie[F]=Ie[z]=Ie[K]=Ie[re]=Ie[le]=Ie[de]=Ie[L]=Ie[q]=Ie[ie]=!1;var xt=typeof Mr=="object"&&Mr&&Mr.Object===Object&&Mr,D=typeof self=="object"&&self&&self.Object===Object&&self,N=xt||D||Function("return this")(),C=r&&!r.nodeType&&r,u=C&&!0&&c&&!c.nodeType&&c,E=u&&u.exports===C,ee=E&&xt.process,ge=function(){try{return ee&&ee.binding&&ee.binding("util")}catch{}}(),be=ge&&ge.isTypedArray;function Ne(g,x){for(var U=-1,Y=g==null?0:g.length,Ve=0,me=[];++U-1}function Po(g,x){var U=this.__data__,Y=Si(U,g);return Y<0?(++this.size,U.push([g,x])):U[Y][1]=x,this}yr.prototype.clear=Eo,yr.prototype.delete=Io,yr.prototype.get=xo,yr.prototype.has=So,yr.prototype.set=Po;function Wr(g){var x=-1,U=g==null?0:g.length;for(this.clear();++xNt))return!1;var Ge=me.get(g);if(Ge&&me.get(x))return Ge==x;var _t=-1,ir=!0,Dt=U&l?new Vi:void 0;for(me.set(g,x),me.set(x,g);++_t-1&&g%1==0&&g-1&&g%1==0&&g<=d}function ln(g){var x=typeof g;return g!=null&&(x=="object"||x=="function")}function Ci(g){return g!=null&&typeof g=="object"}var fn=be?mt(be):Zs;function zo(g){return Mo(g)?Ys(g):Qs(g)}function Ke(){return[]}function Be(){return!1}c.exports=jo})(ho,ho.exports);var bw=ho.exports;const Ew=Ll(bw);function Iw(c,r){if(c.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),n=0;n>>0,pe=new Uint8Array(fe);he!==le;){for(var de=R[he],L=0,q=fe-1;(de!==0||L>>0,pe[q]=de%v>>>0,de=de/v>>>0;if(de!==0)throw new Error("Non-zero carry");re=L,he++}for(var W=fe-re;W!==fe&&pe[W]===0;)W++;for(var ve=b.repeat(K);W>>0,fe=new Uint8Array(le);R[K];){var pe=i[R.charCodeAt(K)];if(pe===255)return;for(var de=0,L=le-1;(pe!==0||de>>0,fe[L]=pe%256>>>0,pe=pe/256>>>0;if(pe!==0)throw new Error("Non-zero carry");he=de,K++}if(R[K]!==" "){for(var q=le-he;q!==le&&fe[q]===0;)q++;for(var W=new Uint8Array(re+(le-q)),ve=re;q!==le;)W[ve++]=fe[q++];return W}}}function z(R){var K=F(R);if(K)return K;throw new Error(`Non-${r} character`)}return{encode:O,decodeUnsafe:F,decode:z}}var xw=Iw,Sw=xw;const nf=c=>{if(c instanceof Uint8Array&&c.constructor.name==="Uint8Array")return c;if(c instanceof ArrayBuffer)return new Uint8Array(c);if(ArrayBuffer.isView(c))return new Uint8Array(c.buffer,c.byteOffset,c.byteLength);throw new Error("Unknown type, must be binary type")},Pw=c=>new TextEncoder().encode(c),Aw=c=>new TextDecoder().decode(c);class Cw{constructor(r,i,n){this.name=r,this.prefix=i,this.baseEncode=n}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}}class Ow{constructor(r,i,n){if(this.name=r,this.prefix=i,i.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i.codePointAt(0),this.baseDecode=n}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return of(this,r)}}class Rw{constructor(r){this.decoders=r}or(r){return of(this,r)}decode(r){const i=r[0],n=this.decoders[i];if(n)return n.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const of=(c,r)=>new Rw({...c.decoders||{[c.prefix]:c},...r.decoders||{[r.prefix]:r}});class Tw{constructor(r,i,n,o){this.name=r,this.prefix=i,this.baseEncode=n,this.baseDecode=o,this.encoder=new Cw(r,i,n),this.decoder=new Ow(r,i,o)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}}const vo=({name:c,prefix:r,encode:i,decode:n})=>new Tw(c,r,i,n),Vs=({prefix:c,name:r,alphabet:i})=>{const{encode:n,decode:o}=Sw(i,r);return vo({prefix:c,name:r,encode:n,decode:l=>nf(o(l))})},Nw=(c,r,i,n)=>{const o={};for(let S=0;S=8&&(v-=8,d[m++]=255&b>>v)}if(v>=i||255&b<<8-v)throw new SyntaxError("Unexpected end of data");return d},Dw=(c,r,i)=>{const n=r[r.length-1]==="=",o=(1<i;)d-=i,l+=r[o&v>>d];if(d&&(l+=r[o&v<vo({prefix:r,name:c,encode(o){return Dw(o,n,i)},decode(o){return Nw(o,n,i,c)}}),Fw=vo({prefix:"\0",name:"identity",encode:c=>Aw(c),decode:c=>Pw(c)});var Lw=Object.freeze({__proto__:null,identity:Fw});const $w=Kt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mw=Object.freeze({__proto__:null,base2:$w});const jw=Kt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zw=Object.freeze({__proto__:null,base8:jw});const Uw=Vs({prefix:"9",name:"base10",alphabet:"0123456789"});var qw=Object.freeze({__proto__:null,base10:Uw});const Bw=Kt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hw=Kt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var kw=Object.freeze({__proto__:null,base16:Bw,base16upper:Hw});const Kw=Kt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vw=Kt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gw=Kt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ww=Kt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jw=Kt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Yw=Kt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xw=Kt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zw=Kt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qw=Kt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var e_=Object.freeze({__proto__:null,base32:Kw,base32upper:Vw,base32pad:Gw,base32padupper:Ww,base32hex:Jw,base32hexupper:Yw,base32hexpad:Xw,base32hexpadupper:Zw,base32z:Qw});const t_=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),r_=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var i_=Object.freeze({__proto__:null,base36:t_,base36upper:r_});const s_=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),n_=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var o_=Object.freeze({__proto__:null,base58btc:s_,base58flickr:n_});const a_=Kt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c_=Kt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),u_=Kt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),h_=Kt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var l_=Object.freeze({__proto__:null,base64:a_,base64pad:c_,base64url:u_,base64urlpad:h_});const af=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),f_=af.reduce((c,r,i)=>(c[i]=r,c),[]),p_=af.reduce((c,r,i)=>(c[r.codePointAt(0)]=i,c),[]);function d_(c){return c.reduce((r,i)=>(r+=f_[i],r),"")}function g_(c){const r=[];for(const i of c){const n=p_[i.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${i}`);r.push(n)}return new Uint8Array(r)}const y_=vo({prefix:"🚀",name:"base256emoji",encode:d_,decode:g_});var v_=Object.freeze({__proto__:null,base256emoji:y_}),m_=cf,Qh=128,w_=127,__=~w_,b_=Math.pow(2,31);function cf(c,r,i){r=r||[],i=i||0;for(var n=i;c>=b_;)r[i++]=c&255|Qh,c/=128;for(;c&__;)r[i++]=c&255|Qh,c>>>=7;return r[i]=c|0,cf.bytes=i-n+1,r}var E_=uc,I_=128,el=127;function uc(c,n){var i=0,n=n||0,o=0,l=n,d,v=c.length;do{if(l>=v)throw uc.bytes=0,new RangeError("Could not decode varint");d=c[l++],i+=o<28?(d&el)<=I_);return uc.bytes=l-n,i}var x_=Math.pow(2,7),S_=Math.pow(2,14),P_=Math.pow(2,21),A_=Math.pow(2,28),C_=Math.pow(2,35),O_=Math.pow(2,42),R_=Math.pow(2,49),T_=Math.pow(2,56),N_=Math.pow(2,63),D_=function(c){return c(uf.encode(c,r,i),r),rl=c=>uf.encodingLength(c),hc=(c,r)=>{const i=r.byteLength,n=rl(c),o=n+rl(i),l=new Uint8Array(o+i);return tl(c,l,0),tl(i,l,n),l.set(r,o),new L_(c,i,r,l)};class L_{constructor(r,i,n,o){this.code=r,this.size=i,this.digest=n,this.bytes=o}}const hf=({name:c,code:r,encode:i})=>new $_(c,r,i);class $_{constructor(r,i,n){this.name=r,this.code=i,this.encode=n}digest(r){if(r instanceof Uint8Array){const i=this.encode(r);return i instanceof Uint8Array?hc(this.code,i):i.then(n=>hc(this.code,n))}else throw Error("Unknown type, must be binary type")}}const lf=c=>async r=>new Uint8Array(await crypto.subtle.digest(c,r)),M_=hf({name:"sha2-256",code:18,encode:lf("SHA-256")}),j_=hf({name:"sha2-512",code:19,encode:lf("SHA-512")});var z_=Object.freeze({__proto__:null,sha256:M_,sha512:j_});const ff=0,U_="identity",pf=nf,q_=c=>hc(ff,pf(c)),B_={code:ff,name:U_,encode:pf,digest:q_};var H_=Object.freeze({__proto__:null,identity:B_});new TextEncoder,new TextDecoder;const il={...Lw,...Mw,...zw,...qw,...kw,...e_,...i_,...o_,...l_,...v_};({...z_,...H_});function df(c){return globalThis.Buffer!=null?new Uint8Array(c.buffer,c.byteOffset,c.byteLength):c}function k_(c=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?df(globalThis.Buffer.allocUnsafe(c)):new Uint8Array(c)}function gf(c,r,i,n){return{name:c,prefix:r,encoder:{name:c,prefix:r,encode:i},decoder:{decode:n}}}const sl=gf("utf8","u",c=>"u"+new TextDecoder("utf8").decode(c),c=>new TextEncoder().encode(c.substring(1))),Xa=gf("ascii","a",c=>{let r="a";for(let i=0;i{c=c.substring(1);const r=k_(c.length);for(let i=0;i{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,o)=>{this.isInitialized(),this.keychain.set(n,o),await this.persist()},this.get=n=>{this.isInitialized();const o=this.keychain.get(n);if(typeof o>"u"){const{message:l}=Q("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(l)}return o},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=r,this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(r){await this.core.storage.setItem(this.storageKey,zl(r))}async getKeyChain(){const r=await this.core.storage.getItem(this.storageKey);return typeof r<"u"?Ul(r):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Eb{constructor(r,i,n){this.core=r,this.logger=i,this.name=Y_,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=o=>(this.isInitialized(),this.keychain.has(o)),this.getClientId=async()=>{this.isInitialized();const o=await this.getClientSeed(),l=Kh(o);return Yl(l.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const o=cm();return this.setPrivateKey(o.publicKey,o.privateKey)},this.signJWT=async o=>{this.isInitialized();const l=await this.getClientSeed(),d=Kh(l),v=oc();return await Q1(v,o,X_,d)},this.generateSharedKey=(o,l,d)=>{this.isInitialized();const v=this.getPrivateKey(o),b=um(v,l);return this.setSymKey(b,d)},this.setSymKey=async(o,l)=>{this.isInitialized();const d=l||hm(o);return await this.keychain.set(d,o),d},this.deleteKeyPair=async o=>{this.isInitialized(),await this.keychain.del(o)},this.deleteSymKey=async o=>{this.isInitialized(),await this.keychain.del(o)},this.encode=async(o,l,d)=>{this.isInitialized();const v=lm(d),b=Ui(l);if(Ah(v)){const F=v.senderPublicKey,z=v.receiverPublicKey;o=await this.generateSharedKey(F,z)}const m=this.getSymKey(o),{type:S,senderPublicKey:O}=v;return fm({type:S,symKey:m,message:b,senderPublicKey:O})},this.decode=async(o,l,d)=>{this.isInitialized();const v=pm(l,d);if(Ah(v)){const S=v.receiverPublicKey,O=v.senderPublicKey;o=await this.generateSharedKey(S,O)}const b=this.getSymKey(o),m=dm({symKey:b,encoded:l});return Ks(m)},this.getPayloadType=o=>{const l=Ch(o);return gm(l.type)},this.getPayloadSenderPublicKey=o=>{const l=Ch(o);return l.senderPublicKey?fo(l.senderPublicKey,ym):void 0},this.core=r,this.logger=Re.generateChildLogger(i,this.name),this.keychain=n||new bb(this.core,this.logger)}get context(){return Re.getLoggerContext(this.logger)}async setPrivateKey(r,i){return await this.keychain.set(r,i),r}getPrivateKey(r){return this.keychain.get(r)}async getClientSeed(){let r="";try{r=this.keychain.get(nl)}catch{r=oc(),await this.keychain.set(nl,r)}return V_(r,"base16")}getSymKey(r){return this.keychain.get(r)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Ib extends T1{constructor(r,i){super(r,i),this.logger=r,this.core=i,this.messages=new Map,this.name=eb,this.version=tb,this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,o)=>{this.isInitialized();const l=fs(o);let d=this.messages.get(n);return typeof d>"u"&&(d={}),typeof d[l]<"u"||(d[l]=o,this.messages.set(n,d),await this.persist()),l},this.get=n=>{this.isInitialized();let o=this.messages.get(n);return typeof o>"u"&&(o={}),o},this.has=(n,o)=>{this.isInitialized();const l=this.get(n),d=fs(o);return typeof l[d]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Re.generateChildLogger(r,this.name),this.core=i}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(r){await this.core.storage.setItem(this.storageKey,zl(r))}async getRelayerMessages(){const r=await this.core.storage.getItem(this.storageKey);return typeof r<"u"?Ul(r):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class xb extends N1{constructor(r,i){super(r,i),this.relayer=r,this.logger=i,this.events=new Cr.EventEmitter,this.name=ib,this.queue=new Map,this.publishTimeout=ne.toMiliseconds(ne.TEN_SECONDS),this.queueTimeout=ne.toMiliseconds(ne.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(n,o,l)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:o,opts:l}});try{const d=(l==null?void 0:l.ttl)||rb,v=ac(l),b=(l==null?void 0:l.prompt)||!1,m=(l==null?void 0:l.tag)||0,S=(l==null?void 0:l.id)||_c().toString(),O={topic:n,message:o,opts:{ttl:d,relay:v,prompt:b,tag:m,id:S}},F=setTimeout(()=>this.queue.set(S,O),this.queueTimeout);try{await await co(this.rpcPublish(n,o,d,v,b,m,S),this.publishTimeout),clearTimeout(F),this.relayer.events.emit(vt.publish,O)}catch{this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0;return}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:o,opts:l}})}catch(d){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(d),d}},this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.relayer=r,this.logger=Re.generateChildLogger(i,this.name),this.registerEventListeners()}get context(){return Re.getLoggerContext(this.logger)}rpcPublish(r,i,n,o,l,d,v){var b,m,S,O;const F={method:io(o.protocol).publish,params:{topic:r,message:i,ttl:n,prompt:l,tag:d},id:v};return _i((b=F.params)==null?void 0:b.prompt)&&((m=F.params)==null||delete m.prompt),_i((S=F.params)==null?void 0:S.tag)&&((O=F.params)==null||delete O.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:F}),this.relayer.request(F)}onPublish(r){this.queue.delete(r)}checkQueue(){this.queue.forEach(async r=>{const{topic:i,message:n,opts:o}=r;await this.publish(i,n,o)})}registerEventListeners(){this.relayer.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(vt.connection_stalled);return}this.checkQueue()}),this.relayer.on(vt.message_ack,r=>{this.onPublish(r.id.toString())})}}class Sb{constructor(){this.map=new Map,this.set=(r,i)=>{const n=this.get(r);this.exists(r,i)||this.map.set(r,[...n,i])},this.get=r=>this.map.get(r)||[],this.exists=(r,i)=>this.get(r).includes(i),this.delete=(r,i)=>{if(typeof i>"u"){this.map.delete(r);return}if(!this.map.has(r))return;const n=this.get(r);if(!this.exists(r,i))return;const o=n.filter(l=>l!==i);if(!o.length){this.map.delete(r);return}this.map.set(r,o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Pb=Object.defineProperty,Ab=Object.defineProperties,Cb=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,Ob=Object.prototype.hasOwnProperty,Rb=Object.prototype.propertyIsEnumerable,ul=(c,r,i)=>r in c?Pb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,zs=(c,r)=>{for(var i in r||(r={}))Ob.call(r,i)&&ul(c,i,r[i]);if(cl)for(var i of cl(r))Rb.call(r,i)&&ul(c,i,r[i]);return c},Qa=(c,r)=>Ab(c,Cb(r));class Tb extends L1{constructor(r,i){super(r,i),this.relayer=r,this.logger=i,this.subscriptions=new Map,this.topicMap=new Sb,this.events=new Cr.EventEmitter,this.name=fb,this.version=pb,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=bi,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(n,o)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:o}});try{const l=ac(o),d={topic:n,relay:l};this.pending.set(n,d);const v=await this.rpcSubscribe(n,l);return this.onSubscribe(v,d),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:o}}),v}catch(l){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(l),l}},this.unsubscribe=async(n,o)=>{await this.restartToComplete(),this.isInitialized(),typeof(o==null?void 0:o.id)<"u"?await this.unsubscribeById(n,o.id,o):await this.unsubscribeByTopic(n,o)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((o,l)=>{const d=new ne.Watch;d.start(this.pendingSubscriptionWatchLabel);const v=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(v),d.stop(this.pendingSubscriptionWatchLabel),o(!0)),d.elapsed(this.pendingSubscriptionWatchLabel)>=db&&(clearInterval(v),d.stop(this.pendingSubscriptionWatchLabel),l(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=r,this.logger=Re.generateChildLogger(i,this.name),this.clientId=""}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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}hasSubscription(r,i){let n=!1;try{n=this.getSubscription(r).topic===i}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(r,i){const n=this.topicMap.get(r);await Promise.all(n.map(async o=>await this.unsubscribeById(r,o,i)))}async unsubscribeById(r,i,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:r,id:i,opts:n}});try{const o=ac(n);await this.rpcUnsubscribe(r,i,o);const l=tr("USER_DISCONNECTED",`${this.name}, ${r}`);await this.onUnsubscribe(r,i,l),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:r,id:i,opts:n}})}catch(o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(o),o}}async rpcSubscribe(r,i){const n={method:io(i.protocol).subscribe,params:{topic:r}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await co(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(vt.connection_stalled)}return fs(r+this.clientId)}async rpcBatchSubscribe(r){if(!r.length)return;const i=r[0].relay,n={method:io(i.protocol).batchSubscribe,params:{topics:r.map(o=>o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await co(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(vt.connection_stalled)}}rpcUnsubscribe(r,i,n){const o={method:io(n.protocol).unsubscribe,params:{topic:r,id:i}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o}),this.relayer.request(o)}onSubscribe(r,i){this.setSubscription(r,Qa(zs({},i),{id:r})),this.pending.delete(i.topic)}onBatchSubscribe(r){r.length&&r.forEach(i=>{this.setSubscription(i.id,zs({},i)),this.pending.delete(i.topic)})}async onUnsubscribe(r,i,n){this.events.removeAllListeners(i),this.hasSubscription(i,r)&&this.deleteSubscription(i,n),await this.relayer.messages.del(r)}async setRelayerSubscriptions(r){await this.relayer.core.storage.setItem(this.storageKey,r)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(r,i){this.subscriptions.has(r)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:r,subscription:i}),this.addSubscription(r,i))}addSubscription(r,i){this.subscriptions.set(r,zs({},i)),this.topicMap.set(i.topic,r),this.events.emit(Vr.created,i)}getSubscription(r){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:r});const i=this.subscriptions.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}deleteSubscription(r,i){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:r,reason:i});const n=this.getSubscription(r);this.subscriptions.delete(r),this.topicMap.delete(n.topic,r),this.events.emit(Vr.deleted,Qa(zs({},n),{reason:i}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Vr.sync)}async reset(){if(this.cached.length){const r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i"u"||!r.length)return;if(this.subscriptions.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(r){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(r)}}async batchSubscribe(r){if(!r.length)return;const i=await this.rpcBatchSubscribe(r);ps(i)&&this.onBatchSubscribe(i.map((n,o)=>Qa(zs({},r[o]),{id:n})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}registerEventListeners(){this.relayer.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(vt.connect,async()=>{await this.onConnect()}),this.relayer.on(vt.disconnect,()=>{this.onDisconnect()}),this.events.on(Vr.created,async r=>{const i=Vr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(Vr.deleted,async r=>{const i=Vr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}async restartToComplete(){this.restartInProgress&&await new Promise(r=>{const i=setInterval(()=>{this.restartInProgress||(clearInterval(i),r())},this.pollingInterval)})}}var Nb=Object.defineProperty,hl=Object.getOwnPropertySymbols,Db=Object.prototype.hasOwnProperty,Fb=Object.prototype.propertyIsEnumerable,ll=(c,r,i)=>r in c?Nb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Lb=(c,r)=>{for(var i in r||(r={}))Db.call(r,i)&&ll(c,i,r[i]);if(hl)for(var i of hl(r))Fb.call(r,i)&&ll(c,i,r[i]);return c};class $b extends D1{constructor(r){super(r),this.protocol="wc",this.version=2,this.events=new Cr.EventEmitter,this.name=nb,this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async i=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(i)}catch(n){throw this.logger.debug("Failed to Publish Request"),this.logger.error(n),n}},this.core=r.core,this.logger=typeof r.logger<"u"&&typeof r.logger!="string"?Re.generateChildLogger(r.logger,this.name):Re.pino(Re.getDefaultLoggerOptions({level:r.logger||sb})),this.messages=new Ib(this.logger,r.core),this.subscriber=new Tb(this,this.logger),this.publisher=new xb(this,this.logger),this.relayUrl=(r==null?void 0:r.relayUrl)||mf,this.projectId=r.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${ol}...`),await this.restartTransport(ol)}this.registerEventListeners(),this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},ub)}get context(){return Re.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(r,i,n){this.isInitialized(),await this.publisher.publish(r,i,n),await this.recordMessageEvent({topic:r,message:i,publishedAt:Date.now()})}async subscribe(r,i){var n;this.isInitialized();let o=((n=this.subscriber.topicMap.get(r))==null?void 0:n[0])||"";return o||(await Promise.all([new Promise(l=>{this.subscriber.once(Vr.created,d=>{d.topic===r&&l()})}),new Promise(async l=>{o=await this.subscriber.subscribe(r,i),l()})]),o)}async unsubscribe(r,i){this.isInitialized(),await this.subscriber.unsubscribe(r,i)}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(vt.transport_closed))}async transportOpen(r){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=r||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise(i=>{this.initialized||i(),this.subscriber.once(Vr.resubscribed,()=>{i()})}),await Promise.race([new Promise(async(i,n)=>{await co(this.provider.connect(),5e3,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>n(o)).then(()=>i()).finally(()=>this.removeListener(vt.transport_closed,this.rejectTransportOpen))}),new Promise(i=>this.once(vt.transport_closed,this.rejectTransportOpen))])])}catch(i){this.logger.error(i);const n=i;if(!this.isConnectionStalled(n.message))throw i;this.events.emit(vt.transport_closed)}finally{this.reconnecting=!1}}}async restartTransport(r){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=r||this.relayUrl,this.connected&&await Promise.all([new Promise(i=>{this.provider.once(Ms.disconnect,()=>{i()})}),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(r){return this.staleConnectionErrors.some(i=>r.includes(i))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const r=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ei(new _w(vm({sdkVersion:cb,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:r,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(r){const{topic:i,message:n}=r;await this.messages.set(i,n)}async shouldIgnoreMessageEvent(r){const{topic:i,message:n}=r;return await this.subscriber.isSubscribed(i)?this.messages.has(i,n):!0}async onProviderPayload(r){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:r}),Ec(r)){if(!r.method.endsWith(ob))return;const i=r.params,{topic:n,message:o,publishedAt:l}=i.data,d={topic:n,message:o,publishedAt:l};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Lb({type:"event",event:i.id},d)),this.events.emit(i.id,d),await this.acknowledgePayload(r),await this.onMessageEvent(d)}else yo(r)&&this.events.emit(vt.message_ack,r)}async onMessageEvent(r){await this.shouldIgnoreMessageEvent(r)||(this.events.emit(vt.message,r),await this.recordMessageEvent(r))}async acknowledgePayload(r){const i=bc(r.id,!0);await this.provider.connection.send(i)}registerProviderListeners(){this.provider.on(Ms.payload,r=>this.onProviderPayload(r)),this.provider.on(Ms.connect,()=>{this.events.emit(vt.connect)}),this.provider.on(Ms.disconnect,()=>{this.onProviderDisconnect()}),this.provider.on(Ms.error,r=>{this.logger.error(r),this.events.emit(vt.error,r)})}registerEventListeners(){this.events.on(vt.connection_stalled,async()=>{await this.restartTransport()})}onProviderDisconnect(){this.events.emit(vt.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.restartTransport()},ne.toMiliseconds(ab))}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise(r=>{const i=setInterval(()=>{this.connected&&(clearInterval(i),r())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var Mb=Object.defineProperty,fl=Object.getOwnPropertySymbols,jb=Object.prototype.hasOwnProperty,zb=Object.prototype.propertyIsEnumerable,pl=(c,r,i)=>r in c?Mb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,dl=(c,r)=>{for(var i in r||(r={}))jb.call(r,i)&&pl(c,i,r[i]);if(fl)for(var i of fl(r))zb.call(r,i)&&pl(c,i,r[i]);return c};class mo extends F1{constructor(r,i,n,o=bi,l=void 0){super(r,i,n,o),this.core=r,this.logger=i,this.name=n,this.map=new Map,this.version=hb,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(d=>{this.getKey&&d!==null&&!_i(d)?this.map.set(this.getKey(d),d):om(d)?this.map.set(d.id,d):am(d)&&this.map.set(d.topic,d)}),this.cached=[],this.initialized=!0)},this.set=async(d,v)=>{this.isInitialized(),this.map.has(d)?await this.update(d,v):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:d,value:v}),this.map.set(d,v),await this.persist())},this.get=d=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:d}),this.getData(d)),this.getAll=d=>(this.isInitialized(),d?this.values.filter(v=>Object.keys(d).every(b=>Ew(v[b],d[b]))):this.values),this.update=async(d,v)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:d,update:v});const b=dl(dl({},this.getData(d)),v);this.map.set(d,b),await this.persist()},this.delete=async(d,v)=>{this.isInitialized(),this.map.has(d)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:d,reason:v}),this.map.delete(d),await this.persist())},this.logger=Re.generateChildLogger(i,this.name),this.storagePrefix=o,this.getKey=l}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(r){await this.core.storage.setItem(this.storageKey,r)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(r){const i=this.map.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw this.logger.error(n),new Error(n)}return i}async persist(){await this.setDataStore(this.values)}async restore(){try{const r=await this.getDataStore();if(typeof r>"u"||!r.length)return;if(this.map.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(r){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(r)}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Ub{constructor(r,i){this.core=r,this.logger=i,this.name=gb,this.version=yb,this.events=new vc,this.initialized=!1,this.storagePrefix=bi,this.ignoredPayloadTypes=[$l],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=oc(),o=await this.core.crypto.setSymKey(n),l=Lr(ne.FIVE_MINUTES),d={protocol:vf},v={topic:o,expiry:l,relay:d,active:!1},b=mm({protocol:this.core.protocol,version:this.core.version,topic:o,symKey:n,relay:d});return await this.pairings.set(o,v),await this.core.relayer.subscribe(o),this.core.expirer.set(o,l),{topic:o,uri:b}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:o,symKey:l,relay:d}=wm(n.uri);if(this.pairings.keys.includes(o))throw new Error(`Pairing already exists: ${o}`);if(this.core.crypto.hasKeys(o))throw new Error(`Keychain already exists: ${o}`);const v=Lr(ne.FIVE_MINUTES),b={topic:o,relay:d,expiry:v,active:!1};return await this.pairings.set(o,b),await this.core.crypto.setSymKey(l,o),await this.core.relayer.subscribe(o,{relay:d}),this.core.expirer.set(o,v),n.activatePairing&&await this.activate({topic:o}),b},this.activate=async({topic:n})=>{this.isInitialized();const o=Lr(ne.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:o}),this.core.expirer.set(n,o)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:o}=n;if(this.pairings.keys.includes(o)){const l=await this.sendRequest(o,"wc_pairingPing",{}),{done:d,resolve:v,reject:b}=hs();this.events.once(Ft("pairing_ping",l),({error:m})=>{m?b(m):v()}),await d()}},this.updateExpiry=async({topic:n,expiry:o})=>{this.isInitialized(),await this.pairings.update(n,{expiry:o})},this.updateMetadata=async({topic:n,metadata:o})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:o}=n;this.pairings.keys.includes(o)&&(await this.sendRequest(o,"wc_pairingDelete",tr("USER_DISCONNECTED")),await this.deletePairing(o))},this.sendRequest=async(n,o,l)=>{const d=po(o,l),v=await this.core.crypto.encode(n,d),b=js[o].req;return this.core.history.set(n,d),this.core.relayer.publish(n,v,b),d.id},this.sendResult=async(n,o,l)=>{const d=bc(n,l),v=await this.core.crypto.encode(o,d),b=await this.core.history.get(o,n),m=js[b.request.method].res;await this.core.relayer.publish(o,v,m),await this.core.history.resolve(d)},this.sendError=async(n,o,l)=>{const d=go(n,l),v=await this.core.crypto.encode(o,d),b=await this.core.history.get(o,n),m=js[b.request.method]?js[b.request.method].res:js.unregistered_method.res;await this.core.relayer.publish(o,v,m),await this.core.history.resolve(d)},this.deletePairing=async(n,o)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,tr("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),o?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(o=>wi(o.expiry));await Promise.all(n.map(o=>this.deletePairing(o.topic)))},this.onRelayEventRequest=n=>{const{topic:o,payload:l}=n,d=l.method;if(this.pairings.keys.includes(o))switch(d){case"wc_pairingPing":return this.onPairingPingRequest(o,l);case"wc_pairingDelete":return this.onPairingDeleteRequest(o,l);default:return this.onUnknownRpcMethodRequest(o,l)}},this.onRelayEventResponse=async n=>{const{topic:o,payload:l}=n,d=(await this.core.history.get(o,l.id)).request.method;if(this.pairings.keys.includes(o))switch(d){case"wc_pairingPing":return this.onPairingPingResponse(o,l);default:return this.onUnknownRpcMethodResponse(d)}},this.onPairingPingRequest=async(n,o)=>{const{id:l}=o;try{this.isValidPing({topic:n}),await this.sendResult(l,n,!0),this.events.emit("pairing_ping",{id:l,topic:n})}catch(d){await this.sendError(l,n,d),this.logger.error(d)}},this.onPairingPingResponse=(n,o)=>{const{id:l}=o;setTimeout(()=>{ai(o)?this.events.emit(Ft("pairing_ping",l),{}):$r(o)&&this.events.emit(Ft("pairing_ping",l),{error:o.error})},500)},this.onPairingDeleteRequest=async(n,o)=>{const{id:l}=o;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit("pairing_delete",{id:l,topic:n})}catch(d){await this.sendError(l,n,d),this.logger.error(d)}},this.onUnknownRpcMethodRequest=async(n,o)=>{const{id:l,method:d}=o;try{if(this.registeredMethods.includes(d))return;const v=tr("WC_METHOD_UNSUPPORTED",d);await this.sendError(l,n,v),this.logger.error(v)}catch(v){await this.sendError(l,n,v),this.logger.error(v)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(tr("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!ur(n)){const{message:o}=Q("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(o)}if(!_m(n.uri)){const{message:o}=Q("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(o)}},this.isValidPing=async n=>{if(!ur(n)){const{message:l}=Q("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(l)}const{topic:o}=n;await this.isValidPairingTopic(o)},this.isValidDisconnect=async n=>{if(!ur(n)){const{message:l}=Q("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(l)}const{topic:o}=n;await this.isValidPairingTopic(o)},this.isValidPairingTopic=async n=>{if(!ls(n,!1)){const{message:o}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(o)}if(!this.pairings.keys.includes(n)){const{message:o}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(o)}if(wi(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:o}=Q("EXPIRED",`pairing topic: ${n}`);throw new Error(o)}},this.core=r,this.logger=Re.generateChildLogger(i,this.name),this.pairings=new mo(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Re.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}registerRelayerEvents(){this.core.relayer.on(vt.message,async r=>{const{topic:i,message:n}=r;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const o=await this.core.crypto.decode(i,n);Ec(o)?(this.core.history.set(i,o),this.onRelayEventRequest({topic:i,payload:o})):yo(o)&&(await this.core.history.resolve(o),await this.onRelayEventResponse({topic:i,payload:o}),this.core.history.delete(i,o.id))})}registerExpirerEvents(){this.core.expirer.on(Pr.expired,async r=>{const{topic:i}=Ml(r.target);i&&this.pairings.keys.includes(i)&&(await this.deletePairing(i,!0),this.events.emit("pairing_expire",{topic:i}))})}}class qb extends R1{constructor(r,i){super(r,i),this.core=r,this.logger=i,this.records=new Map,this.events=new Cr.EventEmitter,this.name=vb,this.version=mb,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,o,l)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:o,chainId:l}),this.records.has(o.id))return;const d={id:o.id,topic:n,request:{method:o.method,params:o.params||null},chainId:l,expiry:Lr(ne.THIRTY_DAYS)};this.records.set(d.id,d),this.events.emit(Kr.created,d)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const o=await this.getRecord(n.id);typeof o.response>"u"&&(o.response=$r(n)?{error:n.error}:{result:n.result},this.records.set(o.id,o),this.events.emit(Kr.updated,o))},this.get=async(n,o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:o}),await this.getRecord(o)),this.delete=(n,o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:o}),this.values.forEach(l=>{if(l.topic===n){if(typeof o<"u"&&l.id!==o)return;this.records.delete(l.id),this.events.emit(Kr.deleted,l)}})},this.exists=async(n,o)=>(this.isInitialized(),this.records.has(o)?(await this.getRecord(o)).topic===n:!1),this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 r=[];return this.values.forEach(i=>{if(typeof i.response<"u")return;const n={topic:i.topic,request:po(i.request.method,i.request.params,i.id),chainId:i.chainId};return r.push(n)}),r}async setJsonRpcRecords(r){await this.core.storage.setItem(this.storageKey,r)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(r){this.isInitialized();const i=this.records.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Kr.sync)}async restore(){try{const r=await this.getJsonRpcRecords();if(typeof r>"u"||!r.length)return;if(this.records.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}}registerEventListeners(){this.events.on(Kr.created,r=>{const i=Kr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.events.on(Kr.updated,r=>{const i=Kr.updated;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.events.on(Kr.deleted,r=>{const i=Kr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(r=>{ne.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.delete(r.topic,r.id))})}catch(r){this.logger.warn(r)}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Bb extends $1{constructor(r,i){super(r,i),this.core=r,this.logger=i,this.expirations=new Map,this.events=new Cr.EventEmitter,this.name=wb,this.version=_b,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const o=this.formatTarget(n);return typeof this.getExpiration(o)<"u"}catch{return!1}},this.set=(n,o)=>{this.isInitialized();const l=this.formatTarget(n),d={target:l,expiry:o};this.expirations.set(l,d),this.checkExpiry(l,d),this.events.emit(Pr.created,{target:l,expiration:d})},this.get=n=>{this.isInitialized();const o=this.formatTarget(n);return this.getExpiration(o)},this.del=n=>{if(this.isInitialized(),this.has(n)){const o=this.formatTarget(n),l=this.getExpiration(o);this.expirations.delete(o),this.events.emit(Pr.deleted,{target:o,expiration:l})}},this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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(r){if(typeof r=="string")return bm(r);if(typeof r=="number")return Em(r);const{message:i}=Q("UNKNOWN_TYPE",`Target type: ${typeof r}`);throw new Error(i)}async setExpirations(r){await this.core.storage.setItem(this.storageKey,r)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Pr.sync)}async restore(){try{const r=await this.getExpirations();if(typeof r>"u"||!r.length)return;if(this.expirations.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(r){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(r)}}getExpiration(r){const i=this.expirations.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw this.logger.error(n),new Error(n)}return i}checkExpiry(r,i){const{expiry:n}=i;ne.toMiliseconds(n)-Date.now()<=0&&this.expire(r,i)}expire(r,i){this.expirations.delete(r),this.events.emit(Pr.expired,{target:r,expiration:i})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((r,i)=>this.checkExpiry(i,r))}registerEventListeners(){this.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Pr.created,r=>{const i=Pr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()}),this.events.on(Pr.expired,r=>{const i=Pr.expired;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()}),this.events.on(Pr.deleted,r=>{const i=Pr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()})}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Hb extends M1{constructor(r,i){super(r,i),this.projectId=r,this.logger=i,this.name=Za,this.initialized=!1,this.init=async n=>{Im()||!jl()||(this.verifyUrl=(n==null?void 0:n.verifyUrl)||al,await this.createIframe())},this.register=async n=>{var o;if(this.initialized||await this.init(),!!this.iframe)try{(o=this.iframe.contentWindow)==null||o.postMessage(n.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${n.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async n=>{var o;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${n.attestationId}`);const l=this.startAbortTimer(ne.FIVE_SECONDS),d=await fetch(`${this.verifyUrl}/attestation/${n.attestationId}`,{signal:this.abortController.signal});return clearTimeout(l),d.status===200?(o=await d.json())==null?void 0:o.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise((n,o)=>{if(document.getElementById(Za))return n();const l=document.createElement("iframe");l.setAttribute("id",Za),l.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),l.style.display="none",l.addEventListener("load",()=>{this.initialized=!0,n()}),l.addEventListener("error",d=>{o(d)}),document.body.append(l),this.iframe=l}),new Promise(n=>{setTimeout(()=>n("iframe load timeout"),ne.toMiliseconds(ne.ONE_SECOND/2))})])}catch(n){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(n)}},this.logger=Re.generateChildLogger(i,this.name),this.verifyUrl=al,this.abortController=new AbortController,this.isDevEnv=xm()&&{}.IS_VITEST}get context(){return Re.getLoggerContext(this.logger)}startAbortTimer(r){return setTimeout(()=>this.abortController.abort(),ne.toMiliseconds(r))}}var kb=Object.defineProperty,gl=Object.getOwnPropertySymbols,Kb=Object.prototype.hasOwnProperty,Vb=Object.prototype.propertyIsEnumerable,yl=(c,r,i)=>r in c?kb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,vl=(c,r)=>{for(var i in r||(r={}))Kb.call(r,i)&&yl(c,i,r[i]);if(gl)for(var i of gl(r))Vb.call(r,i)&&yl(c,i,r[i]);return c};class xc extends O1{constructor(r){super(r),this.protocol=yf,this.version=G_,this.name=Ic,this.events=new Cr.EventEmitter,this.initialized=!1,this.on=(n,o)=>this.events.on(n,o),this.once=(n,o)=>this.events.once(n,o),this.off=(n,o)=>this.events.off(n,o),this.removeListener=(n,o)=>this.events.removeListener(n,o),this.projectId=r==null?void 0:r.projectId,this.relayUrl=(r==null?void 0:r.relayUrl)||mf;const i=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||W_.logger}));this.logger=Re.generateChildLogger(i,this.name),this.heartbeat=new gs.HeartBeat,this.crypto=new Eb(this,this.logger,r==null?void 0:r.keychain),this.history=new qb(this,this.logger),this.expirer=new Bb(this,this.logger),this.storage=r!=null&&r.storage?r.storage:new _1(vl(vl({},J_),r==null?void 0:r.storageOptions)),this.relayer=new $b({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Ub(this,this.logger),this.verify=new Hb(this.projectId||"",this.logger)}static async init(r){const i=new xc(r);await i.initialize();const n=await i.crypto.getClientId();return await i.storage.setItem(lb,n),i}get context(){return Re.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(r){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,r),this.logger.error(r.message),r}}}const Gb=xc,wf="wc",_f=2,bf="client",Sc=`${wf}@${_f}:${bf}:`,ec={name:bf,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Wb="WALLETCONNECT_DEEPLINK_CHOICE",Jb="proposal",Ef="Proposal expired",Yb="session",eo=ne.SEVEN_DAYS,Xb="engine",Us={wc_sessionPropose:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1115}}},tc={min:ne.FIVE_MINUTES,max:ne.SEVEN_DAYS},Zb="request",Qb=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var eE=Object.defineProperty,tE=Object.defineProperties,rE=Object.getOwnPropertyDescriptors,ml=Object.getOwnPropertySymbols,iE=Object.prototype.hasOwnProperty,sE=Object.prototype.propertyIsEnumerable,wl=(c,r,i)=>r in c?eE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Sr=(c,r)=>{for(var i in r||(r={}))iE.call(r,i)&&wl(c,i,r[i]);if(ml)for(var i of ml(r))sE.call(r,i)&&wl(c,i,r[i]);return c},rc=(c,r)=>tE(c,rE(r));class nE extends z1{constructor(r){super(r),this.name=Xb,this.events=new vc,this.initialized=!1,this.ignoredPayloadTypes=[$l],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Us)}),this.initialized=!0)},this.connect=async i=>{this.isInitialized();const n=rc(Sr({},i),{requiredNamespaces:i.requiredNamespaces||{},optionalNamespaces:i.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:o,requiredNamespaces:l,optionalNamespaces:d,sessionProperties:v,relays:b}=n;let m=o,S,O=!1;if(m&&(O=this.client.core.pairing.pairings.get(m).active),!m||!O){const{topic:fe,uri:pe}=await this.client.core.pairing.create();m=fe,S=pe}const F=await this.client.core.crypto.generateKeyPair(),z=Sr({requiredNamespaces:l,optionalNamespaces:d,relays:b??[{protocol:vf}],proposer:{publicKey:F,metadata:this.client.metadata}},v&&{sessionProperties:v}),{reject:R,resolve:K,done:re}=hs(ne.FIVE_MINUTES,Ef);if(this.events.once(Ft("session_connect"),async({error:fe,session:pe})=>{if(fe)R(fe);else if(pe){pe.self.publicKey=F;const de=rc(Sr({},pe),{requiredNamespaces:pe.requiredNamespaces,optionalNamespaces:pe.optionalNamespaces});await this.client.session.set(pe.topic,de),await this.setExpiry(pe.topic,pe.expiry),m&&await this.client.core.pairing.updateMetadata({topic:m,metadata:pe.peer.metadata}),K(de)}}),!m){const{message:fe}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${m}`);throw new Error(fe)}const he=await this.sendRequest(m,"wc_sessionPropose",z),le=Lr(ne.FIVE_MINUTES);return await this.setProposal(he,Sr({id:he,expiry:le},z)),{uri:S,approval:re}},this.pair=async i=>(this.isInitialized(),await this.client.core.pairing.pair(i)),this.approve=async i=>{this.isInitialized(),await this.isValidApprove(i);const{id:n,relayProtocol:o,namespaces:l,sessionProperties:d}=i,v=this.client.proposal.get(n);let{pairingTopic:b,proposer:m,requiredNamespaces:S,optionalNamespaces:O}=v;b=b||"",so(S)||(S=Pm(l,"approve()"));const F=await this.client.core.crypto.generateKeyPair(),z=m.publicKey,R=await this.client.core.crypto.generateSharedKey(F,z);b&&n&&(await this.client.core.pairing.updateMetadata({topic:b,metadata:m.metadata}),await this.sendResult(n,b,{relay:{protocol:o??"irn"},responderPublicKey:F}),await this.client.proposal.delete(n,tr("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:b}));const K=Sr({relay:{protocol:o??"irn"},namespaces:l,requiredNamespaces:S,optionalNamespaces:O,pairingTopic:b,controller:{publicKey:F,metadata:this.client.metadata},expiry:Lr(eo)},d&&{sessionProperties:d});await this.client.core.relayer.subscribe(R),await this.sendRequest(R,"wc_sessionSettle",K);const re=rc(Sr({},K),{topic:R,pairingTopic:b,acknowledged:!1,self:K.controller,peer:{publicKey:m.publicKey,metadata:m.metadata},controller:F});return await this.client.session.set(R,re),await this.setExpiry(R,Lr(eo)),{topic:R,acknowledged:()=>new Promise(he=>setTimeout(()=>he(this.client.session.get(R)),500))}},this.reject=async i=>{this.isInitialized(),await this.isValidReject(i);const{id:n,reason:o}=i,{pairingTopic:l}=this.client.proposal.get(n);l&&(await this.sendError(n,l,o),await this.client.proposal.delete(n,tr("USER_DISCONNECTED")))},this.update=async i=>{this.isInitialized(),await this.isValidUpdate(i);const{topic:n,namespaces:o}=i,l=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:o}),{done:d,resolve:v,reject:b}=hs();return this.events.once(Ft("session_update",l),({error:m})=>{m?b(m):v()}),await this.client.session.update(n,{namespaces:o}),{acknowledged:d}},this.extend=async i=>{this.isInitialized(),await this.isValidExtend(i);const{topic:n}=i,o=await this.sendRequest(n,"wc_sessionExtend",{}),{done:l,resolve:d,reject:v}=hs();return this.events.once(Ft("session_extend",o),({error:b})=>{b?v(b):d()}),await this.setExpiry(n,Lr(eo)),{acknowledged:l}},this.request=async i=>{this.isInitialized(),await this.isValidRequest(i);const{chainId:n,request:o,topic:l,expiry:d}=i,v=await this.sendRequest(l,"wc_sessionRequest",{request:o,chainId:n},d),{done:b,resolve:m,reject:S}=hs(d);this.events.once(Ft("session_request",v),({error:F,result:z})=>{F?S(F):m(z)}),this.client.events.emit("session_request_sent",{topic:l,request:o,chainId:n,id:v});const O=await this.client.core.storage.getItem(Wb);return Am({id:v,topic:l,wcDeepLink:O}),await b()},this.respond=async i=>{this.isInitialized(),await this.isValidRespond(i);const{topic:n,response:o}=i,{id:l}=o;ai(o)?await this.sendResult(l,n,o.result):$r(o)&&await this.sendError(l,n,o.error),this.deletePendingSessionRequest(i.response.id,{message:"fulfilled",code:0})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.client.session.keys.includes(n)){const o=await this.sendRequest(n,"wc_sessionPing",{}),{done:l,resolve:d,reject:v}=hs();this.events.once(Ft("session_ping",o),({error:b})=>{b?v(b):d()}),await l()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async i=>{this.isInitialized(),await this.isValidEmit(i);const{topic:n,event:o,chainId:l}=i;await this.sendRequest(n,"wc_sessionEvent",{event:o,chainId:l})},this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;if(this.client.session.keys.includes(n)){const o=_c().toString();let l;const d=v=>{(v==null?void 0:v.id.toString())===o&&(this.client.core.relayer.events.removeListener(vt.message_ack,d),l())};await Promise.all([new Promise(v=>{l=v,this.client.core.relayer.on(vt.message_ack,d)}),this.sendRequest(n,"wc_sessionDelete",tr("USER_DISCONNECTED"),void 0,o)]),await this.deleteSession(n)}else await this.client.core.pairing.disconnect({topic:n})},this.find=i=>(this.isInitialized(),this.client.session.getAll().filter(n=>Cm(n,i))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async i=>{if(i.pairingTopic)try{const n=this.client.core.pairing.pairings.get(i.pairingTopic),o=this.client.core.pairing.pairings.getAll().filter(l=>{var d,v;return((d=l.peerMetadata)==null?void 0:d.url)&&((v=l.peerMetadata)==null?void 0:v.url)===i.peer.metadata.url&&l.topic&&l.topic!==n.topic});if(o.length===0)return;this.client.logger.info(`Cleaning up ${o.length} duplicate pairing(s)`),await Promise.all(o.map(l=>this.client.core.pairing.disconnect({topic:l.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async(i,n)=>{const{self:o}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),this.client.session.delete(i,tr("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),n||this.client.core.expirer.del(i)},this.deleteProposal=async(i,n)=>{await Promise.all([this.client.proposal.delete(i,tr("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(i)])},this.deletePendingSessionRequest=async(i,n,o=!1)=>{await Promise.all([this.client.pendingRequest.delete(i,n),o?Promise.resolve():this.client.core.expirer.del(i)])},this.setExpiry=async(i,n)=>{this.client.session.keys.includes(i)&&await this.client.session.update(i,{expiry:n}),this.client.core.expirer.set(i,n)},this.setProposal=async(i,n)=>{await this.client.proposal.set(i,n),this.client.core.expirer.set(i,n.expiry)},this.setPendingSessionRequest=async i=>{const n=Us.wc_sessionRequest.req.ttl,{id:o,topic:l,params:d}=i;await this.client.pendingRequest.set(o,{id:o,topic:l,params:d}),n&&this.client.core.expirer.set(o,Lr(n))},this.sendRequest=async(i,n,o,l,d)=>{const v=po(n,o);if(jl()&&Qb.includes(n)){const S=fs(JSON.stringify(v));await this.client.core.verify.register({attestationId:S})}const b=await this.client.core.crypto.encode(i,v),m=Us[n].req;return l&&(m.ttl=l),d&&(m.id=d),this.client.core.history.set(i,v),this.client.core.relayer.publish(i,b,m),v.id},this.sendResult=async(i,n,o)=>{const l=bc(i,o),d=await this.client.core.crypto.encode(n,l),v=await this.client.core.history.get(n,i),b=Us[v.request.method].res;this.client.core.relayer.publish(n,d,b),await this.client.core.history.resolve(l)},this.sendError=async(i,n,o)=>{const l=go(i,o),d=await this.client.core.crypto.encode(n,l),v=await this.client.core.history.get(n,i),b=Us[v.request.method].res;this.client.core.relayer.publish(n,d,b),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const i=[],n=[];this.client.session.getAll().forEach(o=>{wi(o.expiry)&&i.push(o.topic)}),this.client.proposal.getAll().forEach(o=>{wi(o.expiry)&&n.push(o.id)}),await Promise.all([...i.map(o=>this.deleteSession(o)),...n.map(o=>this.deleteProposal(o))])},this.onRelayEventRequest=i=>{const{topic:n,payload:o}=i,l=o.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeRequest(n,o);case"wc_sessionSettle":return this.onSessionSettleRequest(n,o);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,o);case"wc_sessionExtend":return this.onSessionExtendRequest(n,o);case"wc_sessionPing":return this.onSessionPingRequest(n,o);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,o);case"wc_sessionRequest":return this.onSessionRequest(n,o);case"wc_sessionEvent":return this.onSessionEventRequest(n,o);default:return this.client.logger.info(`Unsupported request method ${l}`)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:o}=i,l=(await this.client.core.history.get(n,o.id)).request.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeResponse(n,o);case"wc_sessionSettle":return this.onSessionSettleResponse(n,o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,o);case"wc_sessionExtend":return this.onSessionExtendResponse(n,o);case"wc_sessionPing":return this.onSessionPingResponse(n,o);case"wc_sessionRequest":return this.onSessionRequestResponse(n,o);default:return this.client.logger.info(`Unsupported response method ${l}`)}},this.onRelayEventUnknownPayload=i=>{const{topic:n}=i,{message:o}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(o)},this.onSessionProposeRequest=async(i,n)=>{const{params:o,id:l}=n;try{this.isValidConnect(Sr({},n.params));const d=Lr(ne.FIVE_MINUTES),v=Sr({id:l,pairingTopic:i,expiry:d},o);await this.setProposal(l,v);const b=fs(JSON.stringify(n)),m=await this.getVerifyContext(b,v.proposer.metadata);this.client.events.emit("session_proposal",{id:l,params:v,verifyContext:m})}catch(d){await this.sendError(l,i,d),this.client.logger.error(d)}},this.onSessionProposeResponse=async(i,n)=>{const{id:o}=n;if(ai(n)){const{result:l}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:l});const d=this.client.proposal.get(o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:d});const v=d.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:v});const b=l.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:b});const m=await this.client.core.crypto.generateSharedKey(v,b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:m});const S=await this.client.core.relayer.subscribe(m);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:S}),await this.client.core.pairing.activate({topic:i})}else $r(n)&&(await this.client.proposal.delete(o,tr("USER_DISCONNECTED")),this.events.emit(Ft("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidSessionSettleRequest(l);const{relay:d,controller:v,expiry:b,namespaces:m,requiredNamespaces:S,optionalNamespaces:O,sessionProperties:F,pairingTopic:z}=n.params,R=Sr({topic:i,relay:d,expiry:b,namespaces:m,acknowledged:!0,pairingTopic:z,requiredNamespaces:S,optionalNamespaces:O,controller:v.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:v.publicKey,metadata:v.metadata}},F&&{sessionProperties:F});await this.sendResult(n.id,i,!0),this.events.emit(Ft("session_connect"),{session:R}),this.cleanupDuplicatePairings(R)}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.onSessionSettleResponse=async(i,n)=>{const{id:o}=n;ai(n)?(await this.client.session.update(i,{acknowledged:!0}),this.events.emit(Ft("session_approve",o),{})):$r(n)&&(await this.client.session.delete(i,tr("USER_DISCONNECTED")),this.events.emit(Ft("session_approve",o),{error:n.error}))},this.onSessionUpdateRequest=async(i,n)=>{const{params:o,id:l}=n;try{this.isValidUpdate(Sr({topic:i},o)),await this.client.session.update(i,{namespaces:o.namespaces}),await this.sendResult(l,i,!0),this.client.events.emit("session_update",{id:l,topic:i,params:o})}catch(d){await this.sendError(l,i,d),this.client.logger.error(d)}},this.onSessionUpdateResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_update",o),{}):$r(n)&&this.events.emit(Ft("session_update",o),{error:n.error})},this.onSessionExtendRequest=async(i,n)=>{const{id:o}=n;try{this.isValidExtend({topic:i}),await this.setExpiry(i,Lr(eo)),await this.sendResult(o,i,!0),this.client.events.emit("session_extend",{id:o,topic:i})}catch(l){await this.sendError(o,i,l),this.client.logger.error(l)}},this.onSessionExtendResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_extend",o),{}):$r(n)&&this.events.emit(Ft("session_extend",o),{error:n.error})},this.onSessionPingRequest=async(i,n)=>{const{id:o}=n;try{this.isValidPing({topic:i}),await this.sendResult(o,i,!0),this.client.events.emit("session_ping",{id:o,topic:i})}catch(l){await this.sendError(o,i,l),this.client.logger.error(l)}},this.onSessionPingResponse=(i,n)=>{const{id:o}=n;setTimeout(()=>{ai(n)?this.events.emit(Ft("session_ping",o),{}):$r(n)&&this.events.emit(Ft("session_ping",o),{error:n.error})},500)},this.onSessionDeleteRequest=async(i,n)=>{const{id:o}=n;try{this.isValidDisconnect({topic:i,reason:n.params}),await Promise.all([new Promise(l=>{this.client.core.relayer.once(vt.publish,async()=>{l(await this.deleteSession(i))})}),this.sendResult(o,i,!0)]),this.client.events.emit("session_delete",{id:o,topic:i})}catch(l){this.client.logger.error(l)}},this.onSessionRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidRequest(Sr({topic:i},l)),await this.setPendingSessionRequest({id:o,topic:i,params:l});const d=fs(JSON.stringify(n)),v=this.client.session.get(i),b=await this.getVerifyContext(d,v.peer.metadata);this.client.events.emit("session_request",{id:o,topic:i,params:l,verifyContext:b})}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.onSessionRequestResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_request",o),{result:n.result}):$r(n)&&this.events.emit(Ft("session_request",o),{error:n.error})},this.onSessionEventRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidEmit(Sr({topic:i},l)),this.client.events.emit("session_event",{id:o,topic:i,params:l})}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.isValidConnect=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(i)}`);throw new Error(b)}const{pairingTopic:n,requiredNamespaces:o,optionalNamespaces:l,sessionProperties:d,relays:v}=i;if(_i(n)||await this.isValidPairingTopic(n),!Om(v,!0)){const{message:b}=Q("MISSING_OR_INVALID",`connect() relays: ${v}`);throw new Error(b)}!_i(o)&&so(o)!==0&&this.validateNamespaces(o,"requiredNamespaces"),!_i(l)&&so(l)!==0&&this.validateNamespaces(l,"optionalNamespaces"),_i(d)||this.validateSessionProps(d,"sessionProperties")},this.validateNamespaces=(i,n)=>{const o=Rm(i,"connect()",n);if(o)throw new Error(o.message)},this.isValidApprove=async i=>{if(!ur(i))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${i}`).message);const{id:n,namespaces:o,relayProtocol:l,sessionProperties:d}=i;await this.isValidProposalId(n);const v=this.client.proposal.get(n),b=Ha(o,"approve()");if(b)throw new Error(b.message);const m=Oh(v.requiredNamespaces,o,"approve()");if(m)throw new Error(m.message);if(!ls(l,!0)){const{message:S}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${l}`);throw new Error(S)}_i(d)||this.validateSessionProps(d,"sessionProperties")},this.isValidReject=async i=>{if(!ur(i)){const{message:l}=Q("MISSING_OR_INVALID",`reject() params: ${i}`);throw new Error(l)}const{id:n,reason:o}=i;if(await this.isValidProposalId(n),!Tm(o)){const{message:l}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(o)}`);throw new Error(l)}},this.isValidSessionSettleRequest=i=>{if(!ur(i)){const{message:m}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${i}`);throw new Error(m)}const{relay:n,controller:o,namespaces:l,expiry:d}=i;if(!Nm(n)){const{message:m}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(m)}const v=Dm(o,"onSessionSettleRequest()");if(v)throw new Error(v.message);const b=Ha(l,"onSessionSettleRequest()");if(b)throw new Error(b.message);if(wi(d)){const{message:m}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(m)}},this.isValidUpdate=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`update() params: ${i}`);throw new Error(b)}const{topic:n,namespaces:o}=i;await this.isValidSessionTopic(n);const l=this.client.session.get(n),d=Ha(o,"update()");if(d)throw new Error(d.message);const v=Oh(l.requiredNamespaces,o,"update()");if(v)throw new Error(v.message)},this.isValidExtend=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`extend() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionTopic(n)},this.isValidRequest=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`request() params: ${i}`);throw new Error(b)}const{topic:n,request:o,chainId:l,expiry:d}=i;await this.isValidSessionTopic(n);const{namespaces:v}=this.client.session.get(n);if(!Rh(v,l)){const{message:b}=Q("MISSING_OR_INVALID",`request() chainId: ${l}`);throw new Error(b)}if(!Fm(o)){const{message:b}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(o)}`);throw new Error(b)}if(!Lm(v,l,o.method)){const{message:b}=Q("MISSING_OR_INVALID",`request() method: ${o.method}`);throw new Error(b)}if(d&&!$m(d,tc)){const{message:b}=Q("MISSING_OR_INVALID",`request() expiry: ${d}. Expiry must be a number (in seconds) between ${tc.min} and ${tc.max}`);throw new Error(b)}},this.isValidRespond=async i=>{if(!ur(i)){const{message:l}=Q("MISSING_OR_INVALID",`respond() params: ${i}`);throw new Error(l)}const{topic:n,response:o}=i;if(await this.isValidSessionTopic(n),!Mm(o)){const{message:l}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(o)}`);throw new Error(l)}},this.isValidPing=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async i=>{if(!ur(i)){const{message:v}=Q("MISSING_OR_INVALID",`emit() params: ${i}`);throw new Error(v)}const{topic:n,event:o,chainId:l}=i;await this.isValidSessionTopic(n);const{namespaces:d}=this.client.session.get(n);if(!Rh(d,l)){const{message:v}=Q("MISSING_OR_INVALID",`emit() chainId: ${l}`);throw new Error(v)}if(!jm(o)){const{message:v}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(v)}if(!zm(d,l,o.name)){const{message:v}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(v)}},this.isValidDisconnect=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionOrPairingTopic(n)},this.getVerifyContext=async(i,n)=>{const o={verified:{verifyUrl:n.verifyUrl||"",validation:"UNKNOWN",origin:n.url||""}};try{const l=await this.client.core.verify.resolve({attestationId:i,verifyUrl:n.verifyUrl});l&&(o.verified.origin=l,o.verified.validation=l===n.url?"VALID":"INVALID")}catch(l){this.client.logger.error(l)}return this.client.logger.info(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(i,n)=>{Object.values(i).forEach(o=>{if(!ls(o,!1)){const{message:l}=Q("MISSING_OR_INVALID",`${n} must be in Record format. Received: ${JSON.stringify(o)}`);throw new Error(l)}})}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}registerRelayerEvents(){this.client.core.relayer.on(vt.message,async r=>{const{topic:i,message:n}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const o=await this.client.core.crypto.decode(i,n);Ec(o)?(this.client.core.history.set(i,o),this.onRelayEventRequest({topic:i,payload:o})):yo(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:i,payload:o}),this.client.core.history.delete(i,o.id)):this.onRelayEventUnknownPayload({topic:i,payload:o})})}registerExpirerEvents(){this.client.core.expirer.on(Pr.expired,async r=>{const{topic:i,id:n}=Ml(r.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,Q("EXPIRED"),!0);i?this.client.session.keys.includes(i)&&(await this.deleteSession(i,!0),this.client.events.emit("session_expire",{topic:i})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}isValidPairingTopic(r){if(!ls(r,!1)){const{message:i}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.core.pairing.pairings.get(r).expiry)){const{message:i}=Q("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}async isValidSessionTopic(r){if(!ls(r,!1)){const{message:i}=Q("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(i)}if(!this.client.session.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.session.get(r).expiry)){await this.deleteSession(r);const{message:i}=Q("EXPIRED",`session topic: ${r}`);throw new Error(i)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(ls(r,!1)){const{message:i}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(i)}else{const{message:i}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(i)}}async isValidProposalId(r){if(!Um(r)){const{message:i}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(i)}if(!this.client.proposal.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.proposal.get(r).expiry)){await this.deleteProposal(r);const{message:i}=Q("EXPIRED",`proposal id: ${r}`);throw new Error(i)}}}class oE extends mo{constructor(r,i){super(r,i,Jb,Sc),this.core=r,this.logger=i}}class aE extends mo{constructor(r,i){super(r,i,Yb,Sc),this.core=r,this.logger=i}}class cE extends mo{constructor(r,i){super(r,i,Zb,Sc,n=>n.id),this.core=r,this.logger=i}}let uE=class If extends j1{constructor(r){super(r),this.protocol=wf,this.version=_f,this.name=ec.name,this.events=new Cr.EventEmitter,this.on=(n,o)=>this.events.on(n,o),this.once=(n,o)=>this.events.once(n,o),this.off=(n,o)=>this.events.off(n,o),this.removeListener=(n,o)=>this.events.removeListener(n,o),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(o){throw this.logger.error(o.message),o}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(o){throw this.logger.error(o.message),o}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(o){throw this.logger.error(o.message),o}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(o){throw this.logger.error(o.message),o}},this.update=async n=>{try{return await this.engine.update(n)}catch(o){throw this.logger.error(o.message),o}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(o){throw this.logger.error(o.message),o}},this.request=async n=>{try{return await this.engine.request(n)}catch(o){throw this.logger.error(o.message),o}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(o){throw this.logger.error(o.message),o}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(o){throw this.logger.error(o.message),o}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(o){throw this.logger.error(o.message),o}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(o){throw this.logger.error(o.message),o}},this.find=n=>{try{return this.engine.find(n)}catch(o){throw this.logger.error(o.message),o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=(r==null?void 0:r.name)||ec.name,this.metadata=(r==null?void 0:r.metadata)||Sm();const i=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||ec.logger}));this.core=(r==null?void 0:r.core)||new Gb(r),this.logger=Re.generateChildLogger(i,this.name),this.session=new aE(this.core,this.logger),this.proposal=new oE(this.core,this.logger),this.pendingRequest=new cE(this.core,this.logger),this.engine=new nE(this)}static async init(r){const i=new If(r);return await i.initialize(),i}get context(){return Re.getLoggerContext(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.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};var lc={exports:{}};(function(c,r){var i=typeof self<"u"?self:Mr,n=function(){function l(){this.fetch=!1,this.DOMException=i.DOMException}return l.prototype=i,new l}();(function(l){(function(d){var v={searchParams:"URLSearchParams"in l,iterable:"Symbol"in l&&"iterator"in Symbol,blob:"FileReader"in l&&"Blob"in l&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in l,arrayBuffer:"ArrayBuffer"in l};function b(y){return y&&DataView.prototype.isPrototypeOf(y)}if(v.arrayBuffer)var m=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],S=ArrayBuffer.isView||function(y){return y&&m.indexOf(Object.prototype.toString.call(y))>-1};function O(y){if(typeof y!="string"&&(y=String(y)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(y))throw new TypeError("Invalid character in header field name");return y.toLowerCase()}function F(y){return typeof y!="string"&&(y=String(y)),y}function z(y){var I={next:function(){var X=y.shift();return{done:X===void 0,value:X}}};return v.iterable&&(I[Symbol.iterator]=function(){return I}),I}function R(y){this.map={},y instanceof R?y.forEach(function(I,X){this.append(X,I)},this):Array.isArray(y)?y.forEach(function(I){this.append(I[0],I[1])},this):y&&Object.getOwnPropertyNames(y).forEach(function(I){this.append(I,y[I])},this)}R.prototype.append=function(y,I){y=O(y),I=F(I);var X=this.map[y];this.map[y]=X?X+", "+I:I},R.prototype.delete=function(y){delete this.map[O(y)]},R.prototype.get=function(y){return y=O(y),this.has(y)?this.map[y]:null},R.prototype.has=function(y){return this.map.hasOwnProperty(O(y))},R.prototype.set=function(y,I){this.map[O(y)]=F(I)},R.prototype.forEach=function(y,I){for(var X in this.map)this.map.hasOwnProperty(X)&&y.call(I,this.map[X],X,this)},R.prototype.keys=function(){var y=[];return this.forEach(function(I,X){y.push(X)}),z(y)},R.prototype.values=function(){var y=[];return this.forEach(function(I){y.push(I)}),z(y)},R.prototype.entries=function(){var y=[];return this.forEach(function(I,X){y.push([X,I])}),z(y)},v.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function K(y){if(y.bodyUsed)return Promise.reject(new TypeError("Already read"));y.bodyUsed=!0}function re(y){return new Promise(function(I,X){y.onload=function(){I(y.result)},y.onerror=function(){X(y.error)}})}function he(y){var I=new FileReader,X=re(I);return I.readAsArrayBuffer(y),X}function le(y){var I=new FileReader,X=re(I);return I.readAsText(y),X}function fe(y){for(var I=new Uint8Array(y),X=new Array(I.length),ce=0;ce-1?I:y}function W(y,I){I=I||{};var X=I.body;if(y instanceof W){if(y.bodyUsed)throw new TypeError("Already read");this.url=y.url,this.credentials=y.credentials,I.headers||(this.headers=new R(y.headers)),this.method=y.method,this.mode=y.mode,this.signal=y.signal,!X&&y._bodyInit!=null&&(X=y._bodyInit,y.bodyUsed=!0)}else this.url=String(y);if(this.credentials=I.credentials||this.credentials||"same-origin",(I.headers||!this.headers)&&(this.headers=new R(I.headers)),this.method=q(I.method||this.method||"GET"),this.mode=I.mode||this.mode||null,this.signal=I.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&X)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(X)}W.prototype.clone=function(){return new W(this,{body:this._bodyInit})};function ve(y){var I=new FormData;return y.trim().split("&").forEach(function(X){if(X){var ce=X.split("="),V=ce.shift().replace(/\+/g," "),B=ce.join("=").replace(/\+/g," ");I.append(decodeURIComponent(V),decodeURIComponent(B))}}),I}function ie(y){var I=new R,X=y.replace(/\r?\n[\t ]+/g," ");return X.split(/\r?\n/).forEach(function(ce){var V=ce.split(":"),B=V.shift().trim();if(B){var k=V.join(":").trim();I.append(B,k)}}),I}de.call(W.prototype);function ue(y,I){I||(I={}),this.type="default",this.status=I.status===void 0?200:I.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in I?I.statusText:"OK",this.headers=new R(I.headers),this.url=I.url||"",this._initBody(y)}de.call(ue.prototype),ue.prototype.clone=function(){return new ue(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},ue.error=function(){var y=new ue(null,{status:0,statusText:""});return y.type="error",y};var Te=[301,302,303,307,308];ue.redirect=function(y,I){if(Te.indexOf(I)===-1)throw new RangeError("Invalid status code");return new ue(null,{status:I,headers:{location:y}})},d.DOMException=l.DOMException;try{new d.DOMException}catch{d.DOMException=function(I,X){this.message=I,this.name=X;var ce=Error(I);this.stack=ce.stack},d.DOMException.prototype=Object.create(Error.prototype),d.DOMException.prototype.constructor=d.DOMException}function Ue(y,I){return new Promise(function(X,ce){var V=new W(y,I);if(V.signal&&V.signal.aborted)return ce(new d.DOMException("Aborted","AbortError"));var B=new XMLHttpRequest;function k(){B.abort()}B.onload=function(){var G={status:B.status,statusText:B.statusText,headers:ie(B.getAllResponseHeaders()||"")};G.url="responseURL"in B?B.responseURL:G.headers.get("X-Request-URL");var Je="response"in B?B.response:B.responseText;X(new ue(Je,G))},B.onerror=function(){ce(new TypeError("Network request failed"))},B.ontimeout=function(){ce(new TypeError("Network request failed"))},B.onabort=function(){ce(new d.DOMException("Aborted","AbortError"))},B.open(V.method,V.url,!0),V.credentials==="include"?B.withCredentials=!0:V.credentials==="omit"&&(B.withCredentials=!1),"responseType"in B&&v.blob&&(B.responseType="blob"),V.headers.forEach(function(G,Je){B.setRequestHeader(Je,G)}),V.signal&&(V.signal.addEventListener("abort",k),B.onreadystatechange=function(){B.readyState===4&&V.signal.removeEventListener("abort",k)}),B.send(typeof V._bodyInit>"u"?null:V._bodyInit)})}return Ue.polyfill=!0,l.fetch||(l.fetch=Ue,l.Headers=R,l.Request=W,l.Response=ue),d.Headers=R,d.Request=W,d.Response=ue,d.fetch=Ue,Object.defineProperty(d,"__esModule",{value:!0}),d})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var o=n;r=o.fetch,r.default=o.fetch,r.fetch=o.fetch,r.Headers=o.Headers,r.Request=o.Request,r.Response=o.Response,c.exports=r})(lc,lc.exports);var hE=lc.exports;const _l=Ll(hE),lE={Accept:"application/json","Content-Type":"application/json"},fE="POST",bl={headers:lE,method:fE},El=10;class Hi{constructor(r,i=!1){if(this.url=r,this.disableProviderPing=i,this.events=new Cr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Jh(r))throw new Error(`Provided URL is not compatible with HTTP connection: ${r}`);this.url=r,this.disableProviderPing=i}get connected(){return this.isAvailable}get connecting(){return this.registering}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async open(r=this.url){await this.register(r)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(r,i){this.isAvailable||await this.register();try{const n=Ui(r),l=await(await _l(this.url,Object.assign(Object.assign({},bl),{body:n}))).json();this.onPayload({data:l})}catch(n){this.onError(r.id,n)}}async register(r=this.url){if(!Jh(r))throw new Error(`Provided URL is not compatible with HTTP connection: ${r}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((n,o)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),o(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return o(new Error("HTTP connection is missing or invalid"));n()})})}this.url=r,this.registering=!0;try{if(!this.disableProviderPing){const i=Ui({id:1,jsonrpc:"2.0",method:"test",params:[]});await _l(r,Object.assign(Object.assign({},bl),{body:i}))}this.onOpen()}catch(i){const n=this.parseError(i);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(r){if(typeof r.data>"u")return;const i=typeof r.data=="string"?Ks(r.data):r.data;this.events.emit("payload",i)}onError(r,i){const n=this.parseError(i),o=n.message||n.toString(),l=go(r,o);this.events.emit("payload",l)}parseError(r,i=this.url){return Ql(r,i,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>El&&this.events.setMaxListeners(El)}}const Il="error",pE="wss://relay.walletconnect.com",dE="wc",gE="universal_provider",xl=`${dE}@2:${gE}:`,yE="https://rpc.walletconnect.com/v1",Ii={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var qs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},fc={exports:{}};/** +import{g as im,d as ds,e as ne,f as sm,w as Dl,h as Fl,j as yc,k as fo,l as nm,c as Mr,a as Ll,I as _i,A as om,U as am,m as Q,n as cm,o as oc,p as um,q as hm,P as lm,V as Ah,s as fm,D as pm,C as dm,Z as Ch,$ as gm,u as ym,v as co,x as vm,y as $l,z as Lr,B as mm,E as wm,X as hs,F as Ft,G as tr,H as wi,J as ur,K as _m,L as ls,M as Ml,N as bm,O as Em,Q as Im,R as jl,S as xm,T as zl,Y as Ul,W as fs,a0 as ac,a1 as io,a2 as ps,a3 as Sm,a4 as so,a5 as Pm,a6 as Am,a7 as Cm,a8 as Om,a9 as Rm,aa as Ha,ab as Oh,ac as Tm,ad as Nm,ae as Dm,af as Rh,ag as Fm,ah as Lm,ai as $m,aj as Mm,ak as jm,al as zm,am as Um,an as no,ao as ql,ap as ka,aq as qm,ar as Bm}from"./index-1b4dc470.js";import{e as Cr,N as vc}from"./events-90d6e183.js";const Hm=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,km=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Km=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Vm(c,r){if(c==="__proto__"||c==="constructor"&&r&&typeof r=="object"&&"prototype"in r){Gm(c);return}return r}function Gm(c){console.warn(`[destr] Dropping "${c}" key to prevent prototype pollution.`)}function Zn(c,r={}){if(typeof c!="string")return c;const i=c.trim();if(c[0]==='"'&&c.at(-1)==='"'&&!c.includes("\\"))return i.slice(1,-1);if(i.length<=9){const n=i.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!Km.test(c)){if(r.strict)throw new SyntaxError("[destr] Invalid JSON");return c}try{if(Hm.test(c)||km.test(c)){if(r.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(c,Vm)}return JSON.parse(c)}catch(n){if(r.strict)throw n;return c}}function Wm(c){return!c||typeof c.then!="function"?Promise.resolve(c):c}function qt(c,...r){try{return Wm(c(...r))}catch(i){return Promise.reject(i)}}function Jm(c){const r=typeof c;return c===null||r!=="object"&&r!=="function"}function Ym(c){const r=Object.getPrototypeOf(c);return!r||r.isPrototypeOf(Object)}function oo(c){if(Jm(c))return String(c);if(Ym(c)||Array.isArray(c))return JSON.stringify(c);if(typeof c.toJSON=="function")return oo(c.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Bl(){if(typeof Buffer===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const cc="base64:";function Xm(c){if(typeof c=="string")return c;Bl();const r=Buffer.from(c).toString("base64");return cc+r}function Zm(c){return typeof c!="string"||!c.startsWith(cc)?c:(Bl(),Buffer.from(c.slice(cc.length),"base64"))}function cr(c){return c?c.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Qm(...c){return cr(c.join(":"))}function Qn(c){return c=cr(c),c?c+":":""}const e1="memory",t1=()=>{const c=new Map;return{name:e1,options:{},hasItem(r){return c.has(r)},getItem(r){return c.get(r)??null},getItemRaw(r){return c.get(r)??null},setItem(r,i){c.set(r,i)},setItemRaw(r,i){c.set(r,i)},removeItem(r){c.delete(r)},getKeys(){return Array.from(c.keys())},clear(){c.clear()},dispose(){c.clear()}}};function r1(c={}){const r={mounts:{"":c.driver||t1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},i=m=>{for(const S of r.mountpoints)if(m.startsWith(S))return{base:S,relativeKey:m.slice(S.length),driver:r.mounts[S]};return{base:"",relativeKey:m,driver:r.mounts[""]}},n=(m,S)=>r.mountpoints.filter(O=>O.startsWith(m)||S&&m.startsWith(O)).map(O=>({relativeBase:m.length>O.length?m.slice(O.length):void 0,mountpoint:O,driver:r.mounts[O]})),o=(m,S)=>{if(r.watching){S=cr(S);for(const O of r.watchListeners)O(m,S)}},l=async()=>{if(!r.watching){r.watching=!0;for(const m in r.mounts)r.unwatch[m]=await Th(r.mounts[m],o,m)}},d=async()=>{if(r.watching){for(const m in r.unwatch)await r.unwatch[m]();r.unwatch={},r.watching=!1}},v=(m,S,O)=>{const F=new Map,z=R=>{let K=F.get(R.base);return K||(K={driver:R.driver,base:R.base,items:[]},F.set(R.base,K)),K};for(const R of m){const K=typeof R=="string",re=cr(K?R:R.key),he=K?void 0:R.value,le=K||!R.options?S:{...S,...R.options},fe=i(re);z(fe).items.push({key:re,value:he,relativeKey:fe.relativeKey,options:le})}return Promise.all([...F.values()].map(R=>O(R))).then(R=>R.flat())},b={hasItem(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return qt(F.hasItem,O,S)},getItem(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return qt(F.getItem,O,S).then(z=>Zn(z))},getItems(m,S){return v(m,S,O=>O.driver.getItems?qt(O.driver.getItems,O.items.map(F=>({key:F.relativeKey,options:F.options})),S).then(F=>F.map(z=>({key:Qm(O.base,z.key),value:Zn(z.value)}))):Promise.all(O.items.map(F=>qt(O.driver.getItem,F.relativeKey,F.options).then(z=>({key:F.key,value:Zn(z)})))))},getItemRaw(m,S={}){m=cr(m);const{relativeKey:O,driver:F}=i(m);return F.getItemRaw?qt(F.getItemRaw,O,S):qt(F.getItem,O,S).then(z=>Zm(z))},async setItem(m,S,O={}){if(S===void 0)return b.removeItem(m);m=cr(m);const{relativeKey:F,driver:z}=i(m);z.setItem&&(await qt(z.setItem,F,oo(S),O),z.watch||o("update",m))},async setItems(m,S){await v(m,S,async O=>{O.driver.setItems&&await qt(O.driver.setItems,O.items.map(F=>({key:F.relativeKey,value:oo(F.value),options:F.options})),S),O.driver.setItem&&await Promise.all(O.items.map(F=>qt(O.driver.setItem,F.relativeKey,oo(F.value),F.options)))})},async setItemRaw(m,S,O={}){if(S===void 0)return b.removeItem(m,O);m=cr(m);const{relativeKey:F,driver:z}=i(m);if(z.setItemRaw)await qt(z.setItemRaw,F,S,O);else if(z.setItem)await qt(z.setItem,F,Xm(S),O);else return;z.watch||o("update",m)},async removeItem(m,S={}){typeof S=="boolean"&&(S={removeMeta:S}),m=cr(m);const{relativeKey:O,driver:F}=i(m);F.removeItem&&(await qt(F.removeItem,O,S),(S.removeMeta||S.removeMata)&&await qt(F.removeItem,O+"$",S),F.watch||o("remove",m))},async getMeta(m,S={}){typeof S=="boolean"&&(S={nativeOnly:S}),m=cr(m);const{relativeKey:O,driver:F}=i(m),z=Object.create(null);if(F.getMeta&&Object.assign(z,await qt(F.getMeta,O,S)),!S.nativeOnly){const R=await qt(F.getItem,O+"$",S).then(K=>Zn(K));R&&typeof R=="object"&&(typeof R.atime=="string"&&(R.atime=new Date(R.atime)),typeof R.mtime=="string"&&(R.mtime=new Date(R.mtime)),Object.assign(z,R))}return z},setMeta(m,S,O={}){return this.setItem(m+"$",S,O)},removeMeta(m,S={}){return this.removeItem(m+"$",S)},async getKeys(m,S={}){m=Qn(m);const O=n(m,!0);let F=[];const z=[];for(const R of O){const re=(await qt(R.driver.getKeys,R.relativeBase,S)).map(he=>R.mountpoint+cr(he)).filter(he=>!F.some(le=>he.startsWith(le)));z.push(...re),F=[R.mountpoint,...F.filter(he=>!he.startsWith(R.mountpoint))]}return m?z.filter(R=>R.startsWith(m)&&!R.endsWith("$")):z.filter(R=>!R.endsWith("$"))},async clear(m,S={}){m=Qn(m),await Promise.all(n(m,!1).map(async O=>{if(O.driver.clear)return qt(O.driver.clear,O.relativeBase,S);if(O.driver.removeItem){const F=await O.driver.getKeys(O.relativeBase||"",S);return Promise.all(F.map(z=>O.driver.removeItem(z,S)))}}))},async dispose(){await Promise.all(Object.values(r.mounts).map(m=>Nh(m)))},async watch(m){return await l(),r.watchListeners.push(m),async()=>{r.watchListeners=r.watchListeners.filter(S=>S!==m),r.watchListeners.length===0&&await d()}},async unwatch(){r.watchListeners=[],await d()},mount(m,S){if(m=Qn(m),m&&r.mounts[m])throw new Error(`already mounted at ${m}`);return m&&(r.mountpoints.push(m),r.mountpoints.sort((O,F)=>F.length-O.length)),r.mounts[m]=S,r.watching&&Promise.resolve(Th(S,o,m)).then(O=>{r.unwatch[m]=O}).catch(console.error),b},async unmount(m,S=!0){m=Qn(m),!(!m||!r.mounts[m])&&(r.watching&&m in r.unwatch&&(r.unwatch[m](),delete r.unwatch[m]),S&&await Nh(r.mounts[m]),r.mountpoints=r.mountpoints.filter(O=>O!==m),delete r.mounts[m])},getMount(m=""){m=cr(m)+":";const S=i(m);return{driver:S.driver,base:S.base}},getMounts(m="",S={}){return m=cr(m),n(m,S.parents).map(F=>({driver:F.driver,base:F.mountpoint}))}};return b}function Th(c,r,i){return c.watch?c.watch((n,o)=>r(n,i+o)):()=>{}}async function Nh(c){typeof c.dispose=="function"&&await qt(c.dispose)}function qi(c){return new Promise((r,i)=>{c.oncomplete=c.onsuccess=()=>r(c.result),c.onabort=c.onerror=()=>i(c.error)})}function Hl(c,r){const i=indexedDB.open(c);i.onupgradeneeded=()=>i.result.createObjectStore(r);const n=qi(i);return(o,l)=>n.then(d=>l(d.transaction(r,o).objectStore(r)))}let Ka;function ks(){return Ka||(Ka=Hl("keyval-store","keyval")),Ka}function Dh(c,r=ks()){return r("readonly",i=>qi(i.get(c)))}function i1(c,r,i=ks()){return i("readwrite",n=>(n.put(r,c),qi(n.transaction)))}function s1(c,r=ks()){return r("readwrite",i=>(i.delete(c),qi(i.transaction)))}function n1(c=ks()){return c("readwrite",r=>(r.clear(),qi(r.transaction)))}function o1(c,r){return c.openCursor().onsuccess=function(){this.result&&(r(this.result),this.result.continue())},qi(c.transaction)}function a1(c=ks()){return c("readonly",r=>{if(r.getAllKeys)return qi(r.getAllKeys());const i=[];return o1(r,n=>i.push(n.key)).then(()=>i)})}const c1=c=>JSON.stringify(c,(r,i)=>typeof i=="bigint"?i.toString()+"n":i),u1=c=>{const r=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=c.replace(r,'$1"$2n"$3');return JSON.parse(i,(n,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function Ks(c){if(typeof c!="string")throw new Error(`Cannot safe json parse value of type ${typeof c}`);try{return u1(c)}catch{return c}}function Ui(c){return typeof c=="string"?c:c1(c)||""}const h1="idb-keyval";var l1=(c={})=>{const r=c.base&&c.base.length>0?`${c.base}:`:"",i=o=>r+o;let n;return c.dbName&&c.storeName&&(n=Hl(c.dbName,c.storeName)),{name:h1,options:c,async hasItem(o){return!(typeof await Dh(i(o),n)>"u")},async getItem(o){return await Dh(i(o),n)??null},setItem(o,l){return i1(i(o),l,n)},removeItem(o){return s1(i(o),n)},getKeys(){return a1(n)},clear(){return n1(n)}}};const f1="WALLET_CONNECT_V2_INDEXED_DB",p1="keyvaluestorage";let d1=class{constructor(){this.indexedDb=r1({driver:l1({dbName:f1,storeName:p1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(r=>[r.key,r.value])}async getItem(r){const i=await this.indexedDb.getItem(r);if(i!==null)return i}async setItem(r,i){await this.indexedDb.setItem(r,Ui(i))}async removeItem(r){await this.indexedDb.removeItem(r)}};var Va=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ao={exports:{}};(function(){let c;function r(){}c=r,c.prototype.getItem=function(i){return this.hasOwnProperty(i)?String(this[i]):null},c.prototype.setItem=function(i,n){this[i]=String(n)},c.prototype.removeItem=function(i){delete this[i]},c.prototype.clear=function(){const i=this;Object.keys(i).forEach(function(n){i[n]=void 0,delete i[n]})},c.prototype.key=function(i){return i=i||0,Object.keys(this)[i]},c.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Va<"u"&&Va.localStorage?ao.exports=Va.localStorage:typeof window<"u"&&window.localStorage?ao.exports=window.localStorage:ao.exports=new r})();function g1(c){var r;return[c[0],Ks((r=c[1])!=null?r:"")]}let y1=class{constructor(){this.localStorage=ao.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(g1)}async getItem(r){const i=this.localStorage.getItem(r);if(i!==null)return Ks(i)}async setItem(r,i){this.localStorage.setItem(r,Ui(i))}async removeItem(r){this.localStorage.removeItem(r)}};const v1="wc_storage_version",Fh=1,m1=async(c,r,i)=>{const n=v1,o=await r.getItem(n);if(o&&o>=Fh){i(r);return}const l=await c.getKeys();if(!l.length){i(r);return}const d=[];for(;l.length;){const v=l.shift();if(!v)continue;const b=v.toLowerCase();if(b.includes("wc@")||b.includes("walletconnect")||b.includes("wc_")||b.includes("wallet_connect")){const m=await c.getItem(v);await r.setItem(v,m),d.push(v)}}await r.setItem(n,Fh),i(r),w1(c,d)},w1=async(c,r)=>{r.length&&r.forEach(async i=>{await c.removeItem(i)})};let _1=class{constructor(){this.initialized=!1,this.setInitialized=i=>{this.storage=i,this.initialized=!0};const r=new y1;this.storage=r;try{const i=new d1;m1(r,i,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(r){return await this.initialize(),this.storage.getItem(r)}async setItem(r,i){return await this.initialize(),this.storage.setItem(r,i)}async removeItem(r){return await this.initialize(),this.storage.removeItem(r)}async initialize(){this.initialized||await new Promise(r=>{const i=setInterval(()=>{this.initialized&&(clearInterval(i),r())},20)})}};var gs={},Ls={},Ga={},$s={};let Bi=class{};const b1=Object.freeze(Object.defineProperty({__proto__:null,IEvents:Bi},Symbol.toStringTag,{value:"Module"})),E1=im(b1);var Lh;function I1(){if(Lh)return $s;Lh=1,Object.defineProperty($s,"__esModule",{value:!0}),$s.IHeartBeat=void 0;const c=E1;class r extends c.IEvents{constructor(n){super()}}return $s.IHeartBeat=r,$s}var $h;function kl(){return $h||($h=1,function(c){Object.defineProperty(c,"__esModule",{value:!0}),ds.__exportStar(I1(),c)}(Ga)),Ga}var Wa={},ji={},Mh;function x1(){if(Mh)return ji;Mh=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.HEARTBEAT_EVENTS=ji.HEARTBEAT_INTERVAL=void 0;const c=ne;return ji.HEARTBEAT_INTERVAL=c.FIVE_SECONDS,ji.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},ji}var jh;function Kl(){return jh||(jh=1,function(c){Object.defineProperty(c,"__esModule",{value:!0}),ds.__exportStar(x1(),c)}(Wa)),Wa}var zh;function S1(){if(zh)return Ls;zh=1,Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.HeartBeat=void 0;const c=ds,r=Cr,i=ne,n=kl(),o=Kl();class l extends n.IHeartBeat{constructor(v){super(v),this.events=new r.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(v==null?void 0:v.interval)||o.HEARTBEAT_INTERVAL}static init(v){return c.__awaiter(this,void 0,void 0,function*(){const b=new l(v);return yield b.init(),b})}init(){return c.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(v,b){this.events.on(v,b)}once(v,b){this.events.once(v,b)}off(v,b){this.events.off(v,b)}removeListener(v,b){this.events.removeListener(v,b)}initialize(){return c.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),i.toMiliseconds(this.interval))})}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return Ls.HeartBeat=l,Ls}(function(c){Object.defineProperty(c,"__esModule",{value:!0});const r=ds;r.__exportStar(S1(),c),r.__exportStar(kl(),c),r.__exportStar(Kl(),c)})(gs);var Re={},Ja,Uh;function P1(){if(Uh)return Ja;Uh=1;function c(i){try{return JSON.stringify(i)}catch{return'"[Circular]"'}}Ja=r;function r(i,n,o){var l=o&&o.stringify||c,d=1;if(typeof i=="object"&&i!==null){var v=n.length+d;if(v===1)return i;var b=new Array(v);b[0]=l(i);for(var m=1;m-1?z:0,i.charCodeAt(K+1)){case 100:case 102:if(F>=S||n[F]==null)break;z=S||n[F]==null)break;z=S||n[F]===void 0)break;z",z=K+2,K++;break}O+=l(n[F]),z=K+2,K++;break;case 115:if(F>=S)break;z-1&&(ue=!1);const Te=["error","fatal","warn","info","debug","trace"];typeof W=="function"&&(W.error=W.fatal=W.warn=W.info=W.debug=W.trace=W),L.enabled===!1&&(L.level="silent");const Ue=L.level||"info",y=Object.create(W);y.log||(y.log=re),Object.defineProperty(y,"levelVal",{get:X}),Object.defineProperty(y,"level",{get:ce,set:V});const I={transmit:q,serialize:ie,asObject:L.browser.asObject,levels:Te,timestamp:z(L)};y.levels=o.levels,y.level=Ue,y.setMaxListeners=y.getMaxListeners=y.emit=y.addListener=y.on=y.prependListener=y.once=y.prependOnceListener=y.removeListener=y.removeAllListeners=y.listeners=y.listenerCount=y.eventNames=y.write=y.flush=re,y.serializers=ve,y._serialize=ie,y._stdErrSerialize=ue,y.child=B,q&&(y._logEvent=O());function X(){return this.level==="silent"?1/0:this.levels.values[this.level]}function ce(){return this._level}function V(k){if(k!=="silent"&&!this.levels.values[k])throw Error("unknown level "+k);this._level=k,l(I,y,"error","log"),l(I,y,"fatal","error"),l(I,y,"warn","error"),l(I,y,"info","log"),l(I,y,"debug","log"),l(I,y,"trace","log")}function B(k,G){if(!k)throw new Error("missing bindings for child Pino");G=G||{},ie&&k.serializers&&(G.serializers=k.serializers);const Je=G.serializers;if(ie&&Je){var He=Object.assign({},ve,Je),jr=L.browser.serialize===!0?Object.keys(He):ie;delete k.serializers,b([k],jr,He,this._stdErrSerialize)}function Ie(xt){this._childLevel=(xt._childLevel|0)+1,this.error=m(xt,k,"error"),this.fatal=m(xt,k,"fatal"),this.warn=m(xt,k,"warn"),this.info=m(xt,k,"info"),this.debug=m(xt,k,"debug"),this.trace=m(xt,k,"trace"),He&&(this.serializers=He,this._serialize=jr),q&&(this._logEvent=O([].concat(xt._logEvent.bindings,k)))}return Ie.prototype=this,new Ie(this)}return y}o.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},o.stdSerializers=i,o.stdTimeFunctions=Object.assign({},{nullTime:he,epochTime:le,unixTime:fe,isoTime:pe});function l(L,q,W,ve){const ie=Object.getPrototypeOf(q);q[W]=q.levelVal>q.levels.values[W]?re:ie[W]?ie[W]:r[W]||r[ve]||re,d(L,q,W)}function d(L,q,W){!L.transmit&&q[W]===re||(q[W]=function(ve){return function(){const ue=L.timestamp(),Te=new Array(arguments.length),Ue=Object.getPrototypeOf&&Object.getPrototypeOf(this)===r?r:this;for(var y=0;y-1&&ue in W&&(L[ie][ue]=W[ue](L[ie][ue]))}function m(L,q,W){return function(){const ve=new Array(1+arguments.length);ve[0]=q;for(var ie=1;ie"u"?m=i(v,b):m=v.bindings().context||"",m}er.getLoggerContext=o;function l(v,b,m=c.PINO_CUSTOM_CONTEXT_KEY){const S=o(v,m);return S.trim()?`${S}/${b}`:b}er.formatChildLoggerContext=l;function d(v,b,m=c.PINO_CUSTOM_CONTEXT_KEY){const S=l(v,b,m),O=v.child({context:S});return n(O,S,m)}return er.generateChildLogger=d,er}(function(c){Object.defineProperty(c,"__esModule",{value:!0}),c.pino=void 0;const r=ds,i=r.__importDefault(A1());Object.defineProperty(c,"pino",{enumerable:!0,get:function(){return i.default}}),r.__exportStar(Vl(),c),r.__exportStar(C1(),c)})(Re);class O1 extends Bi{constructor(r){super(),this.opts=r,this.protocol="wc",this.version=2}}class R1 extends Bi{constructor(r,i){super(),this.core=r,this.logger=i,this.records=new Map}}class T1{constructor(r,i){this.logger=r,this.core=i}}let N1=class extends Bi{constructor(r,i){super(),this.relayer=r,this.logger=i}},D1=class extends Bi{constructor(r){super()}},F1=class{constructor(r,i,n,o){this.core=r,this.logger=i,this.name=n}};class L1 extends Bi{constructor(r,i){super(),this.relayer=r,this.logger=i}}let $1=class extends Bi{constructor(r,i){super(),this.core=r,this.logger=i}},M1=class{constructor(r,i){this.projectId=r,this.logger=i}},j1=class{constructor(r){this.opts=r,this.protocol="wc",this.version=2}},z1=class{constructor(r){this.client=r}};var mc={},Gl={};(function(c){Object.defineProperty(c,"__esModule",{value:!0});var r=sm,i=Dl;c.DIGEST_LENGTH=64,c.BLOCK_SIZE=128;var n=function(){function v(){this.digestLength=c.DIGEST_LENGTH,this.blockSize=c.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return v.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},v.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},v.prototype.clean=function(){i.wipe(this._buffer),i.wipe(this._tempHi),i.wipe(this._tempLo),this.reset()},v.prototype.update=function(b,m){if(m===void 0&&(m=b.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var S=0;if(this._bytesHashed+=m,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=b[S++],m--;this._bufferLength===this.blockSize&&(l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(m>=this.blockSize&&(S=l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,b,S,m),m%=this.blockSize);m>0;)this._buffer[this._bufferLength++]=b[S++],m--;return this},v.prototype.finish=function(b){if(!this._finished){var m=this._bytesHashed,S=this._bufferLength,O=m/536870912|0,F=m<<3,z=m%128<112?128:256;this._buffer[S]=128;for(var R=S+1;R0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},v.prototype.restoreState=function(b){return this._stateHi.set(b.stateHi),this._stateLo.set(b.stateLo),this._bufferLength=b.bufferLength,b.buffer&&this._buffer.set(b.buffer),this._bytesHashed=b.bytesHashed,this._finished=!1,this},v.prototype.cleanSavedState=function(b){i.wipe(b.stateHi),i.wipe(b.stateLo),b.buffer&&i.wipe(b.buffer),b.bufferLength=0,b.bytesHashed=0},v}();c.SHA512=n;var o=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function l(v,b,m,S,O,F,z){for(var R=m[0],K=m[1],re=m[2],he=m[3],le=m[4],fe=m[5],pe=m[6],de=m[7],L=S[0],q=S[1],W=S[2],ve=S[3],ie=S[4],ue=S[5],Te=S[6],Ue=S[7],y,I,X,ce,V,B,k,G;z>=128;){for(var Je=0;Je<16;Je++){var He=8*Je+F;v[Je]=r.readUint32BE(O,He),b[Je]=r.readUint32BE(O,He+4)}for(var Je=0;Je<80;Je++){var jr=R,Ie=K,xt=re,D=he,N=le,C=fe,u=pe,E=de,ee=L,ge=q,be=W,Ne=ve,Fe=ie,Pe=ue,St=Te,mt=Ue;if(y=de,I=Ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=(le>>>14|ie<<32-14)^(le>>>18|ie<<32-18)^(ie>>>41-32|le<<32-(41-32)),I=(ie>>>14|le<<32-14)^(ie>>>18|le<<32-18)^(le>>>41-32|ie<<32-(41-32)),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=le&fe^~le&pe,I=ie&ue^~ie&Te,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=o[Je*2],I=o[Je*2+1],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=v[Je%16],I=b[Je%16],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,X=k&65535|G<<16,ce=V&65535|B<<16,y=X,I=ce,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=(R>>>28|L<<32-28)^(L>>>34-32|R<<32-(34-32))^(L>>>39-32|R<<32-(39-32)),I=(L>>>28|R<<32-28)^(R>>>34-32|L<<32-(34-32))^(R>>>39-32|L<<32-(39-32)),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,y=R&K^R&re^K&re,I=L&q^L&W^q&W,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,E=k&65535|G<<16,mt=V&65535|B<<16,y=D,I=Ne,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=X,I=ce,V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,D=k&65535|G<<16,Ne=V&65535|B<<16,K=jr,re=Ie,he=xt,le=D,fe=N,pe=C,de=u,R=E,q=ee,W=ge,ve=be,ie=Ne,ue=Fe,Te=Pe,Ue=St,L=mt,Je%16===15)for(var He=0;He<16;He++)y=v[He],I=b[He],V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=v[(He+9)%16],I=b[(He+9)%16],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,X=v[(He+1)%16],ce=b[(He+1)%16],y=(X>>>1|ce<<32-1)^(X>>>8|ce<<32-8)^X>>>7,I=(ce>>>1|X<<32-1)^(ce>>>8|X<<32-8)^(ce>>>7|X<<32-7),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,X=v[(He+14)%16],ce=b[(He+14)%16],y=(X>>>19|ce<<32-19)^(ce>>>61-32|X<<32-(61-32))^X>>>6,I=(ce>>>19|X<<32-19)^(X>>>61-32|ce<<32-(61-32))^(ce>>>6|X<<32-6),V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,v[He]=k&65535|G<<16,b[He]=V&65535|B<<16}y=R,I=L,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[0],I=S[0],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[0]=R=k&65535|G<<16,S[0]=L=V&65535|B<<16,y=K,I=q,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[1],I=S[1],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[1]=K=k&65535|G<<16,S[1]=q=V&65535|B<<16,y=re,I=W,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[2],I=S[2],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[2]=re=k&65535|G<<16,S[2]=W=V&65535|B<<16,y=he,I=ve,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[3],I=S[3],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[3]=he=k&65535|G<<16,S[3]=ve=V&65535|B<<16,y=le,I=ie,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[4],I=S[4],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[4]=le=k&65535|G<<16,S[4]=ie=V&65535|B<<16,y=fe,I=ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[5],I=S[5],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[5]=fe=k&65535|G<<16,S[5]=ue=V&65535|B<<16,y=pe,I=Te,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[6],I=S[6],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[6]=pe=k&65535|G<<16,S[6]=Te=V&65535|B<<16,y=de,I=Ue,V=I&65535,B=I>>>16,k=y&65535,G=y>>>16,y=m[7],I=S[7],V+=I&65535,B+=I>>>16,k+=y&65535,G+=y>>>16,B+=V>>>16,k+=B>>>16,G+=k>>>16,m[7]=de=k&65535|G<<16,S[7]=Ue=V&65535|B<<16,F+=128,z-=128}return F}function d(v){var b=new n;b.update(v);var m=b.digest();return b.clean(),m}c.hash=d})(Gl);(function(c){Object.defineProperty(c,"__esModule",{value:!0}),c.convertSecretKeyToX25519=c.convertPublicKeyToX25519=c.verify=c.sign=c.extractPublicKeyFromSecretKey=c.generateKeyPair=c.generateKeyPairFromSeed=c.SEED_LENGTH=c.SECRET_KEY_LENGTH=c.PUBLIC_KEY_LENGTH=c.SIGNATURE_LENGTH=void 0;const r=Fl,i=Gl,n=Dl;c.SIGNATURE_LENGTH=64,c.PUBLIC_KEY_LENGTH=32,c.SECRET_KEY_LENGTH=64,c.SEED_LENGTH=32;function o(D){const N=new Float64Array(16);if(D)for(let C=0;C>16&1),C[ge-1]&=65535;C[15]=u[15]-32767-(C[14]>>16&1);const ee=C[15]>>16&1;C[14]&=65535,K(u,C,1-ee)}for(let E=0;E<16;E++)D[2*E]=u[E]&255,D[2*E+1]=u[E]>>8}function he(D,N){let C=0;for(let u=0;u<32;u++)C|=D[u]^N[u];return(1&C-1>>>8)-1}function le(D,N){const C=new Uint8Array(32),u=new Uint8Array(32);return re(C,D),re(u,N),he(C,u)}function fe(D){const N=new Uint8Array(32);return re(N,D),N[0]&1}function pe(D,N){for(let C=0;C<16;C++)D[C]=N[2*C]+(N[2*C+1]<<8);D[15]&=32767}function de(D,N,C){for(let u=0;u<16;u++)D[u]=N[u]+C[u]}function L(D,N,C){for(let u=0;u<16;u++)D[u]=N[u]-C[u]}function q(D,N,C){let u,E,ee=0,ge=0,be=0,Ne=0,Fe=0,Pe=0,St=0,mt=0,nt=0,$e=0,Xe=0,Ze=0,ot=0,qe=0,Qe=0,De=0,ke=0,ut=0,je=0,Pt=0,Lt=0,Bt=0,Ht=0,jt=0,Wt=0,rr=0,zr=0,Jt=0,Gr=0,ci=0,xi=0,ht=C[0],rt=C[1],lt=C[2],ft=C[3],at=C[4],it=C[5],At=C[6],Ct=C[7],pt=C[8],Ot=C[9],dt=C[10],wt=C[11],gt=C[12],Ye=C[13],Rt=C[14],Tt=C[15];u=N[0],ee+=u*ht,ge+=u*rt,be+=u*lt,Ne+=u*ft,Fe+=u*at,Pe+=u*it,St+=u*At,mt+=u*Ct,nt+=u*pt,$e+=u*Ot,Xe+=u*dt,Ze+=u*wt,ot+=u*gt,qe+=u*Ye,Qe+=u*Rt,De+=u*Tt,u=N[1],ge+=u*ht,be+=u*rt,Ne+=u*lt,Fe+=u*ft,Pe+=u*at,St+=u*it,mt+=u*At,nt+=u*Ct,$e+=u*pt,Xe+=u*Ot,Ze+=u*dt,ot+=u*wt,qe+=u*gt,Qe+=u*Ye,De+=u*Rt,ke+=u*Tt,u=N[2],be+=u*ht,Ne+=u*rt,Fe+=u*lt,Pe+=u*ft,St+=u*at,mt+=u*it,nt+=u*At,$e+=u*Ct,Xe+=u*pt,Ze+=u*Ot,ot+=u*dt,qe+=u*wt,Qe+=u*gt,De+=u*Ye,ke+=u*Rt,ut+=u*Tt,u=N[3],Ne+=u*ht,Fe+=u*rt,Pe+=u*lt,St+=u*ft,mt+=u*at,nt+=u*it,$e+=u*At,Xe+=u*Ct,Ze+=u*pt,ot+=u*Ot,qe+=u*dt,Qe+=u*wt,De+=u*gt,ke+=u*Ye,ut+=u*Rt,je+=u*Tt,u=N[4],Fe+=u*ht,Pe+=u*rt,St+=u*lt,mt+=u*ft,nt+=u*at,$e+=u*it,Xe+=u*At,Ze+=u*Ct,ot+=u*pt,qe+=u*Ot,Qe+=u*dt,De+=u*wt,ke+=u*gt,ut+=u*Ye,je+=u*Rt,Pt+=u*Tt,u=N[5],Pe+=u*ht,St+=u*rt,mt+=u*lt,nt+=u*ft,$e+=u*at,Xe+=u*it,Ze+=u*At,ot+=u*Ct,qe+=u*pt,Qe+=u*Ot,De+=u*dt,ke+=u*wt,ut+=u*gt,je+=u*Ye,Pt+=u*Rt,Lt+=u*Tt,u=N[6],St+=u*ht,mt+=u*rt,nt+=u*lt,$e+=u*ft,Xe+=u*at,Ze+=u*it,ot+=u*At,qe+=u*Ct,Qe+=u*pt,De+=u*Ot,ke+=u*dt,ut+=u*wt,je+=u*gt,Pt+=u*Ye,Lt+=u*Rt,Bt+=u*Tt,u=N[7],mt+=u*ht,nt+=u*rt,$e+=u*lt,Xe+=u*ft,Ze+=u*at,ot+=u*it,qe+=u*At,Qe+=u*Ct,De+=u*pt,ke+=u*Ot,ut+=u*dt,je+=u*wt,Pt+=u*gt,Lt+=u*Ye,Bt+=u*Rt,Ht+=u*Tt,u=N[8],nt+=u*ht,$e+=u*rt,Xe+=u*lt,Ze+=u*ft,ot+=u*at,qe+=u*it,Qe+=u*At,De+=u*Ct,ke+=u*pt,ut+=u*Ot,je+=u*dt,Pt+=u*wt,Lt+=u*gt,Bt+=u*Ye,Ht+=u*Rt,jt+=u*Tt,u=N[9],$e+=u*ht,Xe+=u*rt,Ze+=u*lt,ot+=u*ft,qe+=u*at,Qe+=u*it,De+=u*At,ke+=u*Ct,ut+=u*pt,je+=u*Ot,Pt+=u*dt,Lt+=u*wt,Bt+=u*gt,Ht+=u*Ye,jt+=u*Rt,Wt+=u*Tt,u=N[10],Xe+=u*ht,Ze+=u*rt,ot+=u*lt,qe+=u*ft,Qe+=u*at,De+=u*it,ke+=u*At,ut+=u*Ct,je+=u*pt,Pt+=u*Ot,Lt+=u*dt,Bt+=u*wt,Ht+=u*gt,jt+=u*Ye,Wt+=u*Rt,rr+=u*Tt,u=N[11],Ze+=u*ht,ot+=u*rt,qe+=u*lt,Qe+=u*ft,De+=u*at,ke+=u*it,ut+=u*At,je+=u*Ct,Pt+=u*pt,Lt+=u*Ot,Bt+=u*dt,Ht+=u*wt,jt+=u*gt,Wt+=u*Ye,rr+=u*Rt,zr+=u*Tt,u=N[12],ot+=u*ht,qe+=u*rt,Qe+=u*lt,De+=u*ft,ke+=u*at,ut+=u*it,je+=u*At,Pt+=u*Ct,Lt+=u*pt,Bt+=u*Ot,Ht+=u*dt,jt+=u*wt,Wt+=u*gt,rr+=u*Ye,zr+=u*Rt,Jt+=u*Tt,u=N[13],qe+=u*ht,Qe+=u*rt,De+=u*lt,ke+=u*ft,ut+=u*at,je+=u*it,Pt+=u*At,Lt+=u*Ct,Bt+=u*pt,Ht+=u*Ot,jt+=u*dt,Wt+=u*wt,rr+=u*gt,zr+=u*Ye,Jt+=u*Rt,Gr+=u*Tt,u=N[14],Qe+=u*ht,De+=u*rt,ke+=u*lt,ut+=u*ft,je+=u*at,Pt+=u*it,Lt+=u*At,Bt+=u*Ct,Ht+=u*pt,jt+=u*Ot,Wt+=u*dt,rr+=u*wt,zr+=u*gt,Jt+=u*Ye,Gr+=u*Rt,ci+=u*Tt,u=N[15],De+=u*ht,ke+=u*rt,ut+=u*lt,je+=u*ft,Pt+=u*at,Lt+=u*it,Bt+=u*At,Ht+=u*Ct,jt+=u*pt,Wt+=u*Ot,rr+=u*dt,zr+=u*wt,Jt+=u*gt,Gr+=u*Ye,ci+=u*Rt,xi+=u*Tt,ee+=38*ke,ge+=38*ut,be+=38*je,Ne+=38*Pt,Fe+=38*Lt,Pe+=38*Bt,St+=38*Ht,mt+=38*jt,nt+=38*Wt,$e+=38*rr,Xe+=38*zr,Ze+=38*Jt,ot+=38*Gr,qe+=38*ci,Qe+=38*xi,E=1,u=ee+E+65535,E=Math.floor(u/65536),ee=u-E*65536,u=ge+E+65535,E=Math.floor(u/65536),ge=u-E*65536,u=be+E+65535,E=Math.floor(u/65536),be=u-E*65536,u=Ne+E+65535,E=Math.floor(u/65536),Ne=u-E*65536,u=Fe+E+65535,E=Math.floor(u/65536),Fe=u-E*65536,u=Pe+E+65535,E=Math.floor(u/65536),Pe=u-E*65536,u=St+E+65535,E=Math.floor(u/65536),St=u-E*65536,u=mt+E+65535,E=Math.floor(u/65536),mt=u-E*65536,u=nt+E+65535,E=Math.floor(u/65536),nt=u-E*65536,u=$e+E+65535,E=Math.floor(u/65536),$e=u-E*65536,u=Xe+E+65535,E=Math.floor(u/65536),Xe=u-E*65536,u=Ze+E+65535,E=Math.floor(u/65536),Ze=u-E*65536,u=ot+E+65535,E=Math.floor(u/65536),ot=u-E*65536,u=qe+E+65535,E=Math.floor(u/65536),qe=u-E*65536,u=Qe+E+65535,E=Math.floor(u/65536),Qe=u-E*65536,u=De+E+65535,E=Math.floor(u/65536),De=u-E*65536,ee+=E-1+37*(E-1),E=1,u=ee+E+65535,E=Math.floor(u/65536),ee=u-E*65536,u=ge+E+65535,E=Math.floor(u/65536),ge=u-E*65536,u=be+E+65535,E=Math.floor(u/65536),be=u-E*65536,u=Ne+E+65535,E=Math.floor(u/65536),Ne=u-E*65536,u=Fe+E+65535,E=Math.floor(u/65536),Fe=u-E*65536,u=Pe+E+65535,E=Math.floor(u/65536),Pe=u-E*65536,u=St+E+65535,E=Math.floor(u/65536),St=u-E*65536,u=mt+E+65535,E=Math.floor(u/65536),mt=u-E*65536,u=nt+E+65535,E=Math.floor(u/65536),nt=u-E*65536,u=$e+E+65535,E=Math.floor(u/65536),$e=u-E*65536,u=Xe+E+65535,E=Math.floor(u/65536),Xe=u-E*65536,u=Ze+E+65535,E=Math.floor(u/65536),Ze=u-E*65536,u=ot+E+65535,E=Math.floor(u/65536),ot=u-E*65536,u=qe+E+65535,E=Math.floor(u/65536),qe=u-E*65536,u=Qe+E+65535,E=Math.floor(u/65536),Qe=u-E*65536,u=De+E+65535,E=Math.floor(u/65536),De=u-E*65536,ee+=E-1+37*(E-1),D[0]=ee,D[1]=ge,D[2]=be,D[3]=Ne,D[4]=Fe,D[5]=Pe,D[6]=St,D[7]=mt,D[8]=nt,D[9]=$e,D[10]=Xe,D[11]=Ze,D[12]=ot,D[13]=qe,D[14]=Qe,D[15]=De}function W(D,N){q(D,N,N)}function ve(D,N){const C=o();let u;for(u=0;u<16;u++)C[u]=N[u];for(u=253;u>=0;u--)W(C,C),u!==2&&u!==4&&q(C,C,N);for(u=0;u<16;u++)D[u]=C[u]}function ie(D,N){const C=o();let u;for(u=0;u<16;u++)C[u]=N[u];for(u=250;u>=0;u--)W(C,C),u!==1&&q(C,C,N);for(u=0;u<16;u++)D[u]=C[u]}function ue(D,N){const C=o(),u=o(),E=o(),ee=o(),ge=o(),be=o(),Ne=o(),Fe=o(),Pe=o();L(C,D[1],D[0]),L(Pe,N[1],N[0]),q(C,C,Pe),de(u,D[0],D[1]),de(Pe,N[0],N[1]),q(u,u,Pe),q(E,D[3],N[3]),q(E,E,m),q(ee,D[2],N[2]),de(ee,ee,ee),L(ge,u,C),L(be,ee,E),de(Ne,ee,E),de(Fe,u,C),q(D[0],ge,be),q(D[1],Fe,Ne),q(D[2],Ne,be),q(D[3],ge,Fe)}function Te(D,N,C){for(let u=0;u<4;u++)K(D[u],N[u],C)}function Ue(D,N){const C=o(),u=o(),E=o();ve(E,N[2]),q(C,N[0],E),q(u,N[1],E),re(D,u),D[31]^=fe(C)<<7}function y(D,N,C){z(D[0],d),z(D[1],v),z(D[2],v),z(D[3],d);for(let u=255;u>=0;--u){const E=C[u/8|0]>>(u&7)&1;Te(D,N,E),ue(N,D),ue(D,D),Te(D,N,E)}}function I(D,N){const C=[o(),o(),o(),o()];z(C[0],S),z(C[1],O),z(C[2],v),q(C[3],S,O),y(D,C,N)}function X(D){if(D.length!==c.SEED_LENGTH)throw new Error(`ed25519: seed must be ${c.SEED_LENGTH} bytes`);const N=(0,i.hash)(D);N[0]&=248,N[31]&=127,N[31]|=64;const C=new Uint8Array(32),u=[o(),o(),o(),o()];I(u,N),Ue(C,u);const E=new Uint8Array(64);return E.set(D),E.set(C,32),{publicKey:C,secretKey:E}}c.generateKeyPairFromSeed=X;function ce(D){const N=(0,r.randomBytes)(32,D),C=X(N);return(0,n.wipe)(N),C}c.generateKeyPair=ce;function V(D){if(D.length!==c.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${c.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(D.subarray(32))}c.extractPublicKeyFromSecretKey=V;const B=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function k(D,N){let C,u,E,ee;for(u=63;u>=32;--u){for(C=0,E=u-32,ee=u-12;E>4)*B[E],C=N[E]>>8,N[E]&=255;for(E=0;E<32;E++)N[E]-=C*B[E];for(u=0;u<32;u++)N[u+1]+=N[u]>>8,D[u]=N[u]&255}function G(D){const N=new Float64Array(64);for(let C=0;C<64;C++)N[C]=D[C];for(let C=0;C<64;C++)D[C]=0;k(D,N)}function Je(D,N){const C=new Float64Array(64),u=[o(),o(),o(),o()],E=(0,i.hash)(D.subarray(0,32));E[0]&=248,E[31]&=127,E[31]|=64;const ee=new Uint8Array(64);ee.set(E.subarray(32),32);const ge=new i.SHA512;ge.update(ee.subarray(32)),ge.update(N);const be=ge.digest();ge.clean(),G(be),I(u,be),Ue(ee,u),ge.reset(),ge.update(ee.subarray(0,32)),ge.update(D.subarray(32)),ge.update(N);const Ne=ge.digest();G(Ne);for(let Fe=0;Fe<32;Fe++)C[Fe]=be[Fe];for(let Fe=0;Fe<32;Fe++)for(let Pe=0;Pe<32;Pe++)C[Fe+Pe]+=Ne[Fe]*E[Pe];return k(ee.subarray(32),C),ee}c.sign=Je;function He(D,N){const C=o(),u=o(),E=o(),ee=o(),ge=o(),be=o(),Ne=o();return z(D[2],v),pe(D[1],N),W(E,D[1]),q(ee,E,b),L(E,E,D[2]),de(ee,D[2],ee),W(ge,ee),W(be,ge),q(Ne,be,ge),q(C,Ne,E),q(C,C,ee),ie(C,C),q(C,C,E),q(C,C,ee),q(C,C,ee),q(D[0],C,ee),W(u,D[0]),q(u,u,ee),le(u,E)&&q(D[0],D[0],F),W(u,D[0]),q(u,u,ee),le(u,E)?-1:(fe(D[0])===N[31]>>7&&L(D[0],d,D[0]),q(D[3],D[0],D[1]),0)}function jr(D,N,C){const u=new Uint8Array(32),E=[o(),o(),o(),o()],ee=[o(),o(),o(),o()];if(C.length!==c.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${c.SIGNATURE_LENGTH} bytes`);if(He(ee,D))return!1;const ge=new i.SHA512;ge.update(C.subarray(0,32)),ge.update(D),ge.update(N);const be=ge.digest();return G(be),y(E,ee,be),I(ee,C.subarray(32)),ue(E,ee),Ue(u,E),!he(C,u)}c.verify=jr;function Ie(D){let N=[o(),o(),o(),o()];if(He(N,D))throw new Error("Ed25519: invalid public key");let C=o(),u=o(),E=N[1];de(C,v,E),L(u,v,E),ve(u,u),q(C,C,u);let ee=new Uint8Array(32);return re(ee,C),ee}c.convertPublicKeyToX25519=Ie;function xt(D){const N=(0,i.hash)(D.subarray(0,32));N[0]&=248,N[31]&=127,N[31]|=64;const C=new Uint8Array(N.subarray(0,32));return(0,n.wipe)(N),C}c.convertSecretKeyToX25519=xt})(mc);const U1="EdDSA",q1="JWT",Wl=".",Jl="base64url",B1="utf8",H1="utf8",k1=":",K1="did",V1="key",kh="base58btc",G1="z",W1="K36",J1=32;function uo(c){return fo(yc(Ui(c),B1),Jl)}function Yl(c){const r=yc(W1,kh),i=G1+fo(nm([r,c]),kh);return[K1,V1,i].join(k1)}function Y1(c){return fo(c,Jl)}function X1(c){return yc([uo(c.header),uo(c.payload)].join(Wl),H1)}function Z1(c){return[uo(c.header),uo(c.payload),Y1(c.signature)].join(Wl)}function Kh(c=Fl.randomBytes(J1)){return mc.generateKeyPairFromSeed(c)}async function Q1(c,r,i,n,o=ne.fromMiliseconds(Date.now())){const l={alg:U1,typ:q1},d=Yl(n.publicKey),v=o+i,b={iss:d,sub:c,aud:r,iat:o,exp:v},m=X1({header:l,payload:b}),S=mc.sign(n.secretKey,m);return Z1({header:l,payload:b,signature:S})}const ew="PARSE_ERROR",tw="INVALID_REQUEST",rw="METHOD_NOT_FOUND",iw="INVALID_PARAMS",Xl="INTERNAL_ERROR",wc="SERVER_ERROR",sw=[-32700,-32600,-32601,-32602,-32603],Hs={[ew]:{code:-32700,message:"Parse error"},[tw]:{code:-32600,message:"Invalid Request"},[rw]:{code:-32601,message:"Method not found"},[iw]:{code:-32602,message:"Invalid params"},[Xl]:{code:-32603,message:"Internal error"},[wc]:{code:-32e3,message:"Server error"}},Zl=wc;function nw(c){return sw.includes(c)}function Vh(c){return Object.keys(Hs).includes(c)?Hs[c]:Hs[Zl]}function ow(c){const r=Object.values(Hs).find(i=>i.code===c);return r||Hs[Zl]}function Ql(c,r,i){return c.message.includes("getaddrinfo ENOTFOUND")||c.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${i} RPC url at ${r}`):c}var ef={},ni={},Gh;function aw(){if(Gh)return ni;Gh=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.isBrowserCryptoAvailable=ni.getSubtleCrypto=ni.getBrowerCrypto=void 0;function c(){return(Mr===null||Mr===void 0?void 0:Mr.crypto)||(Mr===null||Mr===void 0?void 0:Mr.msCrypto)||{}}ni.getBrowerCrypto=c;function r(){const n=c();return n.subtle||n.webkitSubtle}ni.getSubtleCrypto=r;function i(){return!!c()&&!!r()}return ni.isBrowserCryptoAvailable=i,ni}var oi={},Wh;function cw(){if(Wh)return oi;Wh=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowser=oi.isNode=oi.isReactNative=void 0;function c(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}oi.isReactNative=c;function r(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}oi.isNode=r;function i(){return!c()&&!r()}return oi.isBrowser=i,oi}(function(c){Object.defineProperty(c,"__esModule",{value:!0});const r=ds;r.__exportStar(aw(),c),r.__exportStar(cw(),c)})(ef);function tf(c=3){const r=Date.now()*Math.pow(10,c),i=Math.floor(Math.random()*Math.pow(10,c));return r+i}function _c(c=6){return BigInt(tf(c))}function po(c,r,i){return{id:i||tf(),jsonrpc:"2.0",method:c,params:r}}function bc(c,r){return{id:c,jsonrpc:"2.0",result:r}}function go(c,r,i){return{id:c,jsonrpc:"2.0",error:uw(r,i)}}function uw(c,r){return typeof c>"u"?Vh(Xl):(typeof c=="string"&&(c=Object.assign(Object.assign({},Vh(wc)),{message:c})),typeof r<"u"&&(c.data=r),nw(c.code)&&(c=ow(c.code)),c)}class hw{}class lw extends hw{constructor(){super()}}class fw extends lw{constructor(r){super()}}const pw="^https?:",dw="^wss?:";function gw(c){const r=c.match(new RegExp(/^\w+:/,"gi"));if(!(!r||!r.length))return r[0]}function rf(c,r){const i=gw(c);return typeof i>"u"?!1:new RegExp(r).test(i)}function Jh(c){return rf(c,pw)}function Yh(c){return rf(c,dw)}function yw(c){return new RegExp("wss?://localhost(:d{2,5})?").test(c)}function sf(c){return typeof c=="object"&&"id"in c&&"jsonrpc"in c&&c.jsonrpc==="2.0"}function Ec(c){return sf(c)&&"method"in c}function yo(c){return sf(c)&&(ai(c)||$r(c))}function ai(c){return"result"in c}function $r(c){return"error"in c}class Ei extends fw{constructor(r){super(r),this.events=new Cr.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(r),this.connection.connected&&this.registerEventListeners()}async connect(r=this.connection){await this.open(r)}async disconnect(){await this.close()}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async request(r,i){return this.requestStrict(po(r.method,r.params||[],r.id||_c().toString()),i)}async requestStrict(r,i){return new Promise(async(n,o)=>{if(!this.connection.connected)try{await this.open()}catch(l){o(l)}this.events.on(`${r.id}`,l=>{$r(l)?o(l.error):n(l.result)});try{await this.connection.send(r,i)}catch(l){o(l)}})}setConnection(r=this.connection){return r}onPayload(r){this.events.emit("payload",r),yo(r)?this.events.emit(`${r.id}`,r):this.events.emit("message",{type:r.method,data:r.params})}onClose(r){r&&r.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${r.code} ${r.reason?`(${r.reason})`:""}`)),this.events.emit("disconnect")}async open(r=this.connection){this.connection===r&&this.connection.connected||(this.connection.connected&&this.close(),typeof r=="string"&&(await this.connection.open(r),r=this.connection),this.connection=this.setConnection(r),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",r=>this.onPayload(r)),this.connection.on("close",r=>this.onClose(r)),this.connection.on("error",r=>this.events.emit("error",r)),this.connection.on("register_error",r=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const vw=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),mw=()=>typeof window<"u",Xh=c=>c.split("?")[0],Zh=10,ww=vw();class _w{constructor(r){if(this.url=r,this.events=new Cr.EventEmitter,this.registering=!1,!Yh(r))throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);this.url=r}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async open(r=this.url){await this.register(r)}async close(){return new Promise((r,i)=>{if(typeof this.socket>"u"){i(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),r()},this.socket.close()})}async send(r,i){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ui(r))}catch(n){this.onError(r.id,n)}}register(r=this.url){if(!Yh(r))throw new Error(`Provided URL is not compatible with WebSocket connection: ${r}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((n,o)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),o(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=r,this.registering=!0,new Promise((i,n)=>{const o=ef.isReactNative()?void 0:{rejectUnauthorized:!yw(r)},l=new ww(r,[],o);mw()?l.onerror=d=>{const v=d;n(this.emitError(v.error))}:l.on("error",d=>{n(this.emitError(d))}),l.onopen=()=>{this.onOpen(l),i(l)}})}onOpen(r){r.onmessage=i=>this.onPayload(i),r.onclose=i=>this.onClose(i),this.socket=r,this.registering=!1,this.events.emit("open")}onClose(r){this.socket=void 0,this.registering=!1,this.events.emit("close",r)}onPayload(r){if(typeof r.data>"u")return;const i=typeof r.data=="string"?Ks(r.data):r.data;this.events.emit("payload",i)}onError(r,i){const n=this.parseError(i),o=n.message||n.toString(),l=go(r,o);this.events.emit("payload",l)}parseError(r,i=this.url){return Ql(r,Xh(i),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Zh&&this.events.setMaxListeners(Zh)}emitError(r){const i=this.parseError(new Error((r==null?void 0:r.message)||`WebSocket connection failed for host: ${Xh(this.url)}`));return this.events.emit("register_error",i),i}}var ho={exports:{}};ho.exports;(function(c,r){var i=200,n="__lodash_hash_undefined__",o=1,l=2,d=9007199254740991,v="[object Arguments]",b="[object Array]",m="[object AsyncFunction]",S="[object Boolean]",O="[object Date]",F="[object Error]",z="[object Function]",R="[object GeneratorFunction]",K="[object Map]",re="[object Number]",he="[object Null]",le="[object Object]",fe="[object Promise]",pe="[object Proxy]",de="[object RegExp]",L="[object Set]",q="[object String]",W="[object Symbol]",ve="[object Undefined]",ie="[object WeakMap]",ue="[object ArrayBuffer]",Te="[object DataView]",Ue="[object Float32Array]",y="[object Float64Array]",I="[object Int8Array]",X="[object Int16Array]",ce="[object Int32Array]",V="[object Uint8Array]",B="[object Uint8ClampedArray]",k="[object Uint16Array]",G="[object Uint32Array]",Je=/[\\^$.*+?()[\]{}|]/g,He=/^\[object .+?Constructor\]$/,jr=/^(?:0|[1-9]\d*)$/,Ie={};Ie[Ue]=Ie[y]=Ie[I]=Ie[X]=Ie[ce]=Ie[V]=Ie[B]=Ie[k]=Ie[G]=!0,Ie[v]=Ie[b]=Ie[ue]=Ie[S]=Ie[Te]=Ie[O]=Ie[F]=Ie[z]=Ie[K]=Ie[re]=Ie[le]=Ie[de]=Ie[L]=Ie[q]=Ie[ie]=!1;var xt=typeof Mr=="object"&&Mr&&Mr.Object===Object&&Mr,D=typeof self=="object"&&self&&self.Object===Object&&self,N=xt||D||Function("return this")(),C=r&&!r.nodeType&&r,u=C&&!0&&c&&!c.nodeType&&c,E=u&&u.exports===C,ee=E&&xt.process,ge=function(){try{return ee&&ee.binding&&ee.binding("util")}catch{}}(),be=ge&&ge.isTypedArray;function Ne(g,x){for(var U=-1,Y=g==null?0:g.length,Ve=0,me=[];++U-1}function Po(g,x){var U=this.__data__,Y=Si(U,g);return Y<0?(++this.size,U.push([g,x])):U[Y][1]=x,this}yr.prototype.clear=Eo,yr.prototype.delete=Io,yr.prototype.get=xo,yr.prototype.has=So,yr.prototype.set=Po;function Wr(g){var x=-1,U=g==null?0:g.length;for(this.clear();++xNt))return!1;var Ge=me.get(g);if(Ge&&me.get(x))return Ge==x;var _t=-1,ir=!0,Dt=U&l?new Vi:void 0;for(me.set(g,x),me.set(x,g);++_t-1&&g%1==0&&g-1&&g%1==0&&g<=d}function ln(g){var x=typeof g;return g!=null&&(x=="object"||x=="function")}function Ci(g){return g!=null&&typeof g=="object"}var fn=be?mt(be):Zs;function zo(g){return Mo(g)?Ys(g):Qs(g)}function Ke(){return[]}function Be(){return!1}c.exports=jo})(ho,ho.exports);var bw=ho.exports;const Ew=Ll(bw);function Iw(c,r){if(c.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),n=0;n>>0,pe=new Uint8Array(fe);he!==le;){for(var de=R[he],L=0,q=fe-1;(de!==0||L>>0,pe[q]=de%v>>>0,de=de/v>>>0;if(de!==0)throw new Error("Non-zero carry");re=L,he++}for(var W=fe-re;W!==fe&&pe[W]===0;)W++;for(var ve=b.repeat(K);W>>0,fe=new Uint8Array(le);R[K];){var pe=i[R.charCodeAt(K)];if(pe===255)return;for(var de=0,L=le-1;(pe!==0||de>>0,fe[L]=pe%256>>>0,pe=pe/256>>>0;if(pe!==0)throw new Error("Non-zero carry");he=de,K++}if(R[K]!==" "){for(var q=le-he;q!==le&&fe[q]===0;)q++;for(var W=new Uint8Array(re+(le-q)),ve=re;q!==le;)W[ve++]=fe[q++];return W}}}function z(R){var K=F(R);if(K)return K;throw new Error(`Non-${r} character`)}return{encode:O,decodeUnsafe:F,decode:z}}var xw=Iw,Sw=xw;const nf=c=>{if(c instanceof Uint8Array&&c.constructor.name==="Uint8Array")return c;if(c instanceof ArrayBuffer)return new Uint8Array(c);if(ArrayBuffer.isView(c))return new Uint8Array(c.buffer,c.byteOffset,c.byteLength);throw new Error("Unknown type, must be binary type")},Pw=c=>new TextEncoder().encode(c),Aw=c=>new TextDecoder().decode(c);class Cw{constructor(r,i,n){this.name=r,this.prefix=i,this.baseEncode=n}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}}class Ow{constructor(r,i,n){if(this.name=r,this.prefix=i,i.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i.codePointAt(0),this.baseDecode=n}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return of(this,r)}}class Rw{constructor(r){this.decoders=r}or(r){return of(this,r)}decode(r){const i=r[0],n=this.decoders[i];if(n)return n.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const of=(c,r)=>new Rw({...c.decoders||{[c.prefix]:c},...r.decoders||{[r.prefix]:r}});class Tw{constructor(r,i,n,o){this.name=r,this.prefix=i,this.baseEncode=n,this.baseDecode=o,this.encoder=new Cw(r,i,n),this.decoder=new Ow(r,i,o)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}}const vo=({name:c,prefix:r,encode:i,decode:n})=>new Tw(c,r,i,n),Vs=({prefix:c,name:r,alphabet:i})=>{const{encode:n,decode:o}=Sw(i,r);return vo({prefix:c,name:r,encode:n,decode:l=>nf(o(l))})},Nw=(c,r,i,n)=>{const o={};for(let S=0;S=8&&(v-=8,d[m++]=255&b>>v)}if(v>=i||255&b<<8-v)throw new SyntaxError("Unexpected end of data");return d},Dw=(c,r,i)=>{const n=r[r.length-1]==="=",o=(1<i;)d-=i,l+=r[o&v>>d];if(d&&(l+=r[o&v<vo({prefix:r,name:c,encode(o){return Dw(o,n,i)},decode(o){return Nw(o,n,i,c)}}),Fw=vo({prefix:"\0",name:"identity",encode:c=>Aw(c),decode:c=>Pw(c)});var Lw=Object.freeze({__proto__:null,identity:Fw});const $w=Kt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mw=Object.freeze({__proto__:null,base2:$w});const jw=Kt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zw=Object.freeze({__proto__:null,base8:jw});const Uw=Vs({prefix:"9",name:"base10",alphabet:"0123456789"});var qw=Object.freeze({__proto__:null,base10:Uw});const Bw=Kt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hw=Kt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var kw=Object.freeze({__proto__:null,base16:Bw,base16upper:Hw});const Kw=Kt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vw=Kt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gw=Kt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ww=Kt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jw=Kt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Yw=Kt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xw=Kt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zw=Kt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qw=Kt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var e_=Object.freeze({__proto__:null,base32:Kw,base32upper:Vw,base32pad:Gw,base32padupper:Ww,base32hex:Jw,base32hexupper:Yw,base32hexpad:Xw,base32hexpadupper:Zw,base32z:Qw});const t_=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),r_=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var i_=Object.freeze({__proto__:null,base36:t_,base36upper:r_});const s_=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),n_=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var o_=Object.freeze({__proto__:null,base58btc:s_,base58flickr:n_});const a_=Kt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c_=Kt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),u_=Kt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),h_=Kt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var l_=Object.freeze({__proto__:null,base64:a_,base64pad:c_,base64url:u_,base64urlpad:h_});const af=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),f_=af.reduce((c,r,i)=>(c[i]=r,c),[]),p_=af.reduce((c,r,i)=>(c[r.codePointAt(0)]=i,c),[]);function d_(c){return c.reduce((r,i)=>(r+=f_[i],r),"")}function g_(c){const r=[];for(const i of c){const n=p_[i.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${i}`);r.push(n)}return new Uint8Array(r)}const y_=vo({prefix:"🚀",name:"base256emoji",encode:d_,decode:g_});var v_=Object.freeze({__proto__:null,base256emoji:y_}),m_=cf,Qh=128,w_=127,__=~w_,b_=Math.pow(2,31);function cf(c,r,i){r=r||[],i=i||0;for(var n=i;c>=b_;)r[i++]=c&255|Qh,c/=128;for(;c&__;)r[i++]=c&255|Qh,c>>>=7;return r[i]=c|0,cf.bytes=i-n+1,r}var E_=uc,I_=128,el=127;function uc(c,n){var i=0,n=n||0,o=0,l=n,d,v=c.length;do{if(l>=v)throw uc.bytes=0,new RangeError("Could not decode varint");d=c[l++],i+=o<28?(d&el)<=I_);return uc.bytes=l-n,i}var x_=Math.pow(2,7),S_=Math.pow(2,14),P_=Math.pow(2,21),A_=Math.pow(2,28),C_=Math.pow(2,35),O_=Math.pow(2,42),R_=Math.pow(2,49),T_=Math.pow(2,56),N_=Math.pow(2,63),D_=function(c){return c(uf.encode(c,r,i),r),rl=c=>uf.encodingLength(c),hc=(c,r)=>{const i=r.byteLength,n=rl(c),o=n+rl(i),l=new Uint8Array(o+i);return tl(c,l,0),tl(i,l,n),l.set(r,o),new L_(c,i,r,l)};class L_{constructor(r,i,n,o){this.code=r,this.size=i,this.digest=n,this.bytes=o}}const hf=({name:c,code:r,encode:i})=>new $_(c,r,i);class $_{constructor(r,i,n){this.name=r,this.code=i,this.encode=n}digest(r){if(r instanceof Uint8Array){const i=this.encode(r);return i instanceof Uint8Array?hc(this.code,i):i.then(n=>hc(this.code,n))}else throw Error("Unknown type, must be binary type")}}const lf=c=>async r=>new Uint8Array(await crypto.subtle.digest(c,r)),M_=hf({name:"sha2-256",code:18,encode:lf("SHA-256")}),j_=hf({name:"sha2-512",code:19,encode:lf("SHA-512")});var z_=Object.freeze({__proto__:null,sha256:M_,sha512:j_});const ff=0,U_="identity",pf=nf,q_=c=>hc(ff,pf(c)),B_={code:ff,name:U_,encode:pf,digest:q_};var H_=Object.freeze({__proto__:null,identity:B_});new TextEncoder,new TextDecoder;const il={...Lw,...Mw,...zw,...qw,...kw,...e_,...i_,...o_,...l_,...v_};({...z_,...H_});function df(c){return globalThis.Buffer!=null?new Uint8Array(c.buffer,c.byteOffset,c.byteLength):c}function k_(c=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?df(globalThis.Buffer.allocUnsafe(c)):new Uint8Array(c)}function gf(c,r,i,n){return{name:c,prefix:r,encoder:{name:c,prefix:r,encode:i},decoder:{decode:n}}}const sl=gf("utf8","u",c=>"u"+new TextDecoder("utf8").decode(c),c=>new TextEncoder().encode(c.substring(1))),Xa=gf("ascii","a",c=>{let r="a";for(let i=0;i{c=c.substring(1);const r=k_(c.length);for(let i=0;i{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,o)=>{this.isInitialized(),this.keychain.set(n,o),await this.persist()},this.get=n=>{this.isInitialized();const o=this.keychain.get(n);if(typeof o>"u"){const{message:l}=Q("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(l)}return o},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=r,this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(r){await this.core.storage.setItem(this.storageKey,zl(r))}async getKeyChain(){const r=await this.core.storage.getItem(this.storageKey);return typeof r<"u"?Ul(r):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Eb{constructor(r,i,n){this.core=r,this.logger=i,this.name=Y_,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=o=>(this.isInitialized(),this.keychain.has(o)),this.getClientId=async()=>{this.isInitialized();const o=await this.getClientSeed(),l=Kh(o);return Yl(l.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const o=cm();return this.setPrivateKey(o.publicKey,o.privateKey)},this.signJWT=async o=>{this.isInitialized();const l=await this.getClientSeed(),d=Kh(l),v=oc();return await Q1(v,o,X_,d)},this.generateSharedKey=(o,l,d)=>{this.isInitialized();const v=this.getPrivateKey(o),b=um(v,l);return this.setSymKey(b,d)},this.setSymKey=async(o,l)=>{this.isInitialized();const d=l||hm(o);return await this.keychain.set(d,o),d},this.deleteKeyPair=async o=>{this.isInitialized(),await this.keychain.del(o)},this.deleteSymKey=async o=>{this.isInitialized(),await this.keychain.del(o)},this.encode=async(o,l,d)=>{this.isInitialized();const v=lm(d),b=Ui(l);if(Ah(v)){const F=v.senderPublicKey,z=v.receiverPublicKey;o=await this.generateSharedKey(F,z)}const m=this.getSymKey(o),{type:S,senderPublicKey:O}=v;return fm({type:S,symKey:m,message:b,senderPublicKey:O})},this.decode=async(o,l,d)=>{this.isInitialized();const v=pm(l,d);if(Ah(v)){const S=v.receiverPublicKey,O=v.senderPublicKey;o=await this.generateSharedKey(S,O)}const b=this.getSymKey(o),m=dm({symKey:b,encoded:l});return Ks(m)},this.getPayloadType=o=>{const l=Ch(o);return gm(l.type)},this.getPayloadSenderPublicKey=o=>{const l=Ch(o);return l.senderPublicKey?fo(l.senderPublicKey,ym):void 0},this.core=r,this.logger=Re.generateChildLogger(i,this.name),this.keychain=n||new bb(this.core,this.logger)}get context(){return Re.getLoggerContext(this.logger)}async setPrivateKey(r,i){return await this.keychain.set(r,i),r}getPrivateKey(r){return this.keychain.get(r)}async getClientSeed(){let r="";try{r=this.keychain.get(nl)}catch{r=oc(),await this.keychain.set(nl,r)}return V_(r,"base16")}getSymKey(r){return this.keychain.get(r)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Ib extends T1{constructor(r,i){super(r,i),this.logger=r,this.core=i,this.messages=new Map,this.name=eb,this.version=tb,this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,o)=>{this.isInitialized();const l=fs(o);let d=this.messages.get(n);return typeof d>"u"&&(d={}),typeof d[l]<"u"||(d[l]=o,this.messages.set(n,d),await this.persist()),l},this.get=n=>{this.isInitialized();let o=this.messages.get(n);return typeof o>"u"&&(o={}),o},this.has=(n,o)=>{this.isInitialized();const l=this.get(n),d=fs(o);return typeof l[d]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Re.generateChildLogger(r,this.name),this.core=i}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(r){await this.core.storage.setItem(this.storageKey,zl(r))}async getRelayerMessages(){const r=await this.core.storage.getItem(this.storageKey);return typeof r<"u"?Ul(r):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class xb extends N1{constructor(r,i){super(r,i),this.relayer=r,this.logger=i,this.events=new Cr.EventEmitter,this.name=ib,this.queue=new Map,this.publishTimeout=ne.toMiliseconds(ne.TEN_SECONDS),this.queueTimeout=ne.toMiliseconds(ne.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(n,o,l)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:o,opts:l}});try{const d=(l==null?void 0:l.ttl)||rb,v=ac(l),b=(l==null?void 0:l.prompt)||!1,m=(l==null?void 0:l.tag)||0,S=(l==null?void 0:l.id)||_c().toString(),O={topic:n,message:o,opts:{ttl:d,relay:v,prompt:b,tag:m,id:S}},F=setTimeout(()=>this.queue.set(S,O),this.queueTimeout);try{await await co(this.rpcPublish(n,o,d,v,b,m,S),this.publishTimeout),clearTimeout(F),this.relayer.events.emit(vt.publish,O)}catch{this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0;return}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:o,opts:l}})}catch(d){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(d),d}},this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.relayer=r,this.logger=Re.generateChildLogger(i,this.name),this.registerEventListeners()}get context(){return Re.getLoggerContext(this.logger)}rpcPublish(r,i,n,o,l,d,v){var b,m,S,O;const F={method:io(o.protocol).publish,params:{topic:r,message:i,ttl:n,prompt:l,tag:d},id:v};return _i((b=F.params)==null?void 0:b.prompt)&&((m=F.params)==null||delete m.prompt),_i((S=F.params)==null?void 0:S.tag)&&((O=F.params)==null||delete O.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:F}),this.relayer.request(F)}onPublish(r){this.queue.delete(r)}checkQueue(){this.queue.forEach(async r=>{const{topic:i,message:n,opts:o}=r;await this.publish(i,n,o)})}registerEventListeners(){this.relayer.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(vt.connection_stalled);return}this.checkQueue()}),this.relayer.on(vt.message_ack,r=>{this.onPublish(r.id.toString())})}}class Sb{constructor(){this.map=new Map,this.set=(r,i)=>{const n=this.get(r);this.exists(r,i)||this.map.set(r,[...n,i])},this.get=r=>this.map.get(r)||[],this.exists=(r,i)=>this.get(r).includes(i),this.delete=(r,i)=>{if(typeof i>"u"){this.map.delete(r);return}if(!this.map.has(r))return;const n=this.get(r);if(!this.exists(r,i))return;const o=n.filter(l=>l!==i);if(!o.length){this.map.delete(r);return}this.map.set(r,o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Pb=Object.defineProperty,Ab=Object.defineProperties,Cb=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,Ob=Object.prototype.hasOwnProperty,Rb=Object.prototype.propertyIsEnumerable,ul=(c,r,i)=>r in c?Pb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,zs=(c,r)=>{for(var i in r||(r={}))Ob.call(r,i)&&ul(c,i,r[i]);if(cl)for(var i of cl(r))Rb.call(r,i)&&ul(c,i,r[i]);return c},Qa=(c,r)=>Ab(c,Cb(r));class Tb extends L1{constructor(r,i){super(r,i),this.relayer=r,this.logger=i,this.subscriptions=new Map,this.topicMap=new Sb,this.events=new Cr.EventEmitter,this.name=fb,this.version=pb,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=bi,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(n,o)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:o}});try{const l=ac(o),d={topic:n,relay:l};this.pending.set(n,d);const v=await this.rpcSubscribe(n,l);return this.onSubscribe(v,d),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:o}}),v}catch(l){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(l),l}},this.unsubscribe=async(n,o)=>{await this.restartToComplete(),this.isInitialized(),typeof(o==null?void 0:o.id)<"u"?await this.unsubscribeById(n,o.id,o):await this.unsubscribeByTopic(n,o)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((o,l)=>{const d=new ne.Watch;d.start(this.pendingSubscriptionWatchLabel);const v=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(v),d.stop(this.pendingSubscriptionWatchLabel),o(!0)),d.elapsed(this.pendingSubscriptionWatchLabel)>=db&&(clearInterval(v),d.stop(this.pendingSubscriptionWatchLabel),l(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=r,this.logger=Re.generateChildLogger(i,this.name),this.clientId=""}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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}hasSubscription(r,i){let n=!1;try{n=this.getSubscription(r).topic===i}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(r,i){const n=this.topicMap.get(r);await Promise.all(n.map(async o=>await this.unsubscribeById(r,o,i)))}async unsubscribeById(r,i,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:r,id:i,opts:n}});try{const o=ac(n);await this.rpcUnsubscribe(r,i,o);const l=tr("USER_DISCONNECTED",`${this.name}, ${r}`);await this.onUnsubscribe(r,i,l),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:r,id:i,opts:n}})}catch(o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(o),o}}async rpcSubscribe(r,i){const n={method:io(i.protocol).subscribe,params:{topic:r}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await co(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(vt.connection_stalled)}return fs(r+this.clientId)}async rpcBatchSubscribe(r){if(!r.length)return;const i=r[0].relay,n={method:io(i.protocol).batchSubscribe,params:{topics:r.map(o=>o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await co(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(vt.connection_stalled)}}rpcUnsubscribe(r,i,n){const o={method:io(n.protocol).unsubscribe,params:{topic:r,id:i}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o}),this.relayer.request(o)}onSubscribe(r,i){this.setSubscription(r,Qa(zs({},i),{id:r})),this.pending.delete(i.topic)}onBatchSubscribe(r){r.length&&r.forEach(i=>{this.setSubscription(i.id,zs({},i)),this.pending.delete(i.topic)})}async onUnsubscribe(r,i,n){this.events.removeAllListeners(i),this.hasSubscription(i,r)&&this.deleteSubscription(i,n),await this.relayer.messages.del(r)}async setRelayerSubscriptions(r){await this.relayer.core.storage.setItem(this.storageKey,r)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(r,i){this.subscriptions.has(r)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:r,subscription:i}),this.addSubscription(r,i))}addSubscription(r,i){this.subscriptions.set(r,zs({},i)),this.topicMap.set(i.topic,r),this.events.emit(Vr.created,i)}getSubscription(r){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:r});const i=this.subscriptions.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}deleteSubscription(r,i){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:r,reason:i});const n=this.getSubscription(r);this.subscriptions.delete(r),this.topicMap.delete(n.topic,r),this.events.emit(Vr.deleted,Qa(zs({},n),{reason:i}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Vr.sync)}async reset(){if(this.cached.length){const r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i"u"||!r.length)return;if(this.subscriptions.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(r){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(r)}}async batchSubscribe(r){if(!r.length)return;const i=await this.rpcBatchSubscribe(r);ps(i)&&this.onBatchSubscribe(i.map((n,o)=>Qa(zs({},r[o]),{id:n})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const r=[];this.pending.forEach(i=>{r.push(i)}),await this.batchSubscribe(r)}registerEventListeners(){this.relayer.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(vt.connect,async()=>{await this.onConnect()}),this.relayer.on(vt.disconnect,()=>{this.onDisconnect()}),this.events.on(Vr.created,async r=>{const i=Vr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()}),this.events.on(Vr.deleted,async r=>{const i=Vr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}async restartToComplete(){this.restartInProgress&&await new Promise(r=>{const i=setInterval(()=>{this.restartInProgress||(clearInterval(i),r())},this.pollingInterval)})}}var Nb=Object.defineProperty,hl=Object.getOwnPropertySymbols,Db=Object.prototype.hasOwnProperty,Fb=Object.prototype.propertyIsEnumerable,ll=(c,r,i)=>r in c?Nb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Lb=(c,r)=>{for(var i in r||(r={}))Db.call(r,i)&&ll(c,i,r[i]);if(hl)for(var i of hl(r))Fb.call(r,i)&&ll(c,i,r[i]);return c};class $b extends D1{constructor(r){super(r),this.protocol="wc",this.version=2,this.events=new Cr.EventEmitter,this.name=nb,this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async i=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(i)}catch(n){throw this.logger.debug("Failed to Publish Request"),this.logger.error(n),n}},this.core=r.core,this.logger=typeof r.logger<"u"&&typeof r.logger!="string"?Re.generateChildLogger(r.logger,this.name):Re.pino(Re.getDefaultLoggerOptions({level:r.logger||sb})),this.messages=new Ib(this.logger,r.core),this.subscriber=new Tb(this,this.logger),this.publisher=new xb(this,this.logger),this.relayUrl=(r==null?void 0:r.relayUrl)||mf,this.projectId=r.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${ol}...`),await this.restartTransport(ol)}this.registerEventListeners(),this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},ub)}get context(){return Re.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(r,i,n){this.isInitialized(),await this.publisher.publish(r,i,n),await this.recordMessageEvent({topic:r,message:i,publishedAt:Date.now()})}async subscribe(r,i){var n;this.isInitialized();let o=((n=this.subscriber.topicMap.get(r))==null?void 0:n[0])||"";return o||(await Promise.all([new Promise(l=>{this.subscriber.once(Vr.created,d=>{d.topic===r&&l()})}),new Promise(async l=>{o=await this.subscriber.subscribe(r,i),l()})]),o)}async unsubscribe(r,i){this.isInitialized(),await this.subscriber.unsubscribe(r,i)}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(vt.transport_closed))}async transportOpen(r){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=r||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise(i=>{this.initialized||i(),this.subscriber.once(Vr.resubscribed,()=>{i()})}),await Promise.race([new Promise(async(i,n)=>{await co(this.provider.connect(),5e3,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>n(o)).then(()=>i()).finally(()=>this.removeListener(vt.transport_closed,this.rejectTransportOpen))}),new Promise(i=>this.once(vt.transport_closed,this.rejectTransportOpen))])])}catch(i){this.logger.error(i);const n=i;if(!this.isConnectionStalled(n.message))throw i;this.events.emit(vt.transport_closed)}finally{this.reconnecting=!1}}}async restartTransport(r){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=r||this.relayUrl,this.connected&&await Promise.all([new Promise(i=>{this.provider.once(Ms.disconnect,()=>{i()})}),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(r){return this.staleConnectionErrors.some(i=>r.includes(i))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const r=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ei(new _w(vm({sdkVersion:cb,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:r,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(r){const{topic:i,message:n}=r;await this.messages.set(i,n)}async shouldIgnoreMessageEvent(r){const{topic:i,message:n}=r;return await this.subscriber.isSubscribed(i)?this.messages.has(i,n):!0}async onProviderPayload(r){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:r}),Ec(r)){if(!r.method.endsWith(ob))return;const i=r.params,{topic:n,message:o,publishedAt:l}=i.data,d={topic:n,message:o,publishedAt:l};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Lb({type:"event",event:i.id},d)),this.events.emit(i.id,d),await this.acknowledgePayload(r),await this.onMessageEvent(d)}else yo(r)&&this.events.emit(vt.message_ack,r)}async onMessageEvent(r){await this.shouldIgnoreMessageEvent(r)||(this.events.emit(vt.message,r),await this.recordMessageEvent(r))}async acknowledgePayload(r){const i=bc(r.id,!0);await this.provider.connection.send(i)}registerProviderListeners(){this.provider.on(Ms.payload,r=>this.onProviderPayload(r)),this.provider.on(Ms.connect,()=>{this.events.emit(vt.connect)}),this.provider.on(Ms.disconnect,()=>{this.onProviderDisconnect()}),this.provider.on(Ms.error,r=>{this.logger.error(r),this.events.emit(vt.error,r)})}registerEventListeners(){this.events.on(vt.connection_stalled,async()=>{await this.restartTransport()})}onProviderDisconnect(){this.events.emit(vt.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.restartTransport()},ne.toMiliseconds(ab))}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise(r=>{const i=setInterval(()=>{this.connected&&(clearInterval(i),r())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var Mb=Object.defineProperty,fl=Object.getOwnPropertySymbols,jb=Object.prototype.hasOwnProperty,zb=Object.prototype.propertyIsEnumerable,pl=(c,r,i)=>r in c?Mb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,dl=(c,r)=>{for(var i in r||(r={}))jb.call(r,i)&&pl(c,i,r[i]);if(fl)for(var i of fl(r))zb.call(r,i)&&pl(c,i,r[i]);return c};class mo extends F1{constructor(r,i,n,o=bi,l=void 0){super(r,i,n,o),this.core=r,this.logger=i,this.name=n,this.map=new Map,this.version=hb,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(d=>{this.getKey&&d!==null&&!_i(d)?this.map.set(this.getKey(d),d):om(d)?this.map.set(d.id,d):am(d)&&this.map.set(d.topic,d)}),this.cached=[],this.initialized=!0)},this.set=async(d,v)=>{this.isInitialized(),this.map.has(d)?await this.update(d,v):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:d,value:v}),this.map.set(d,v),await this.persist())},this.get=d=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:d}),this.getData(d)),this.getAll=d=>(this.isInitialized(),d?this.values.filter(v=>Object.keys(d).every(b=>Ew(v[b],d[b]))):this.values),this.update=async(d,v)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:d,update:v});const b=dl(dl({},this.getData(d)),v);this.map.set(d,b),await this.persist()},this.delete=async(d,v)=>{this.isInitialized(),this.map.has(d)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:d,reason:v}),this.map.delete(d),await this.persist())},this.logger=Re.generateChildLogger(i,this.name),this.storagePrefix=o,this.getKey=l}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(r){await this.core.storage.setItem(this.storageKey,r)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(r){const i=this.map.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw this.logger.error(n),new Error(n)}return i}async persist(){await this.setDataStore(this.values)}async restore(){try{const r=await this.getDataStore();if(typeof r>"u"||!r.length)return;if(this.map.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(r){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(r)}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Ub{constructor(r,i){this.core=r,this.logger=i,this.name=gb,this.version=yb,this.events=new vc,this.initialized=!1,this.storagePrefix=bi,this.ignoredPayloadTypes=[$l],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=oc(),o=await this.core.crypto.setSymKey(n),l=Lr(ne.FIVE_MINUTES),d={protocol:vf},v={topic:o,expiry:l,relay:d,active:!1},b=mm({protocol:this.core.protocol,version:this.core.version,topic:o,symKey:n,relay:d});return await this.pairings.set(o,v),await this.core.relayer.subscribe(o),this.core.expirer.set(o,l),{topic:o,uri:b}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:o,symKey:l,relay:d}=wm(n.uri);if(this.pairings.keys.includes(o))throw new Error(`Pairing already exists: ${o}`);if(this.core.crypto.hasKeys(o))throw new Error(`Keychain already exists: ${o}`);const v=Lr(ne.FIVE_MINUTES),b={topic:o,relay:d,expiry:v,active:!1};return await this.pairings.set(o,b),await this.core.crypto.setSymKey(l,o),await this.core.relayer.subscribe(o,{relay:d}),this.core.expirer.set(o,v),n.activatePairing&&await this.activate({topic:o}),b},this.activate=async({topic:n})=>{this.isInitialized();const o=Lr(ne.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:o}),this.core.expirer.set(n,o)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:o}=n;if(this.pairings.keys.includes(o)){const l=await this.sendRequest(o,"wc_pairingPing",{}),{done:d,resolve:v,reject:b}=hs();this.events.once(Ft("pairing_ping",l),({error:m})=>{m?b(m):v()}),await d()}},this.updateExpiry=async({topic:n,expiry:o})=>{this.isInitialized(),await this.pairings.update(n,{expiry:o})},this.updateMetadata=async({topic:n,metadata:o})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:o}=n;this.pairings.keys.includes(o)&&(await this.sendRequest(o,"wc_pairingDelete",tr("USER_DISCONNECTED")),await this.deletePairing(o))},this.sendRequest=async(n,o,l)=>{const d=po(o,l),v=await this.core.crypto.encode(n,d),b=js[o].req;return this.core.history.set(n,d),this.core.relayer.publish(n,v,b),d.id},this.sendResult=async(n,o,l)=>{const d=bc(n,l),v=await this.core.crypto.encode(o,d),b=await this.core.history.get(o,n),m=js[b.request.method].res;await this.core.relayer.publish(o,v,m),await this.core.history.resolve(d)},this.sendError=async(n,o,l)=>{const d=go(n,l),v=await this.core.crypto.encode(o,d),b=await this.core.history.get(o,n),m=js[b.request.method]?js[b.request.method].res:js.unregistered_method.res;await this.core.relayer.publish(o,v,m),await this.core.history.resolve(d)},this.deletePairing=async(n,o)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,tr("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),o?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(o=>wi(o.expiry));await Promise.all(n.map(o=>this.deletePairing(o.topic)))},this.onRelayEventRequest=n=>{const{topic:o,payload:l}=n,d=l.method;if(this.pairings.keys.includes(o))switch(d){case"wc_pairingPing":return this.onPairingPingRequest(o,l);case"wc_pairingDelete":return this.onPairingDeleteRequest(o,l);default:return this.onUnknownRpcMethodRequest(o,l)}},this.onRelayEventResponse=async n=>{const{topic:o,payload:l}=n,d=(await this.core.history.get(o,l.id)).request.method;if(this.pairings.keys.includes(o))switch(d){case"wc_pairingPing":return this.onPairingPingResponse(o,l);default:return this.onUnknownRpcMethodResponse(d)}},this.onPairingPingRequest=async(n,o)=>{const{id:l}=o;try{this.isValidPing({topic:n}),await this.sendResult(l,n,!0),this.events.emit("pairing_ping",{id:l,topic:n})}catch(d){await this.sendError(l,n,d),this.logger.error(d)}},this.onPairingPingResponse=(n,o)=>{const{id:l}=o;setTimeout(()=>{ai(o)?this.events.emit(Ft("pairing_ping",l),{}):$r(o)&&this.events.emit(Ft("pairing_ping",l),{error:o.error})},500)},this.onPairingDeleteRequest=async(n,o)=>{const{id:l}=o;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit("pairing_delete",{id:l,topic:n})}catch(d){await this.sendError(l,n,d),this.logger.error(d)}},this.onUnknownRpcMethodRequest=async(n,o)=>{const{id:l,method:d}=o;try{if(this.registeredMethods.includes(d))return;const v=tr("WC_METHOD_UNSUPPORTED",d);await this.sendError(l,n,v),this.logger.error(v)}catch(v){await this.sendError(l,n,v),this.logger.error(v)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(tr("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!ur(n)){const{message:o}=Q("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(o)}if(!_m(n.uri)){const{message:o}=Q("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(o)}},this.isValidPing=async n=>{if(!ur(n)){const{message:l}=Q("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(l)}const{topic:o}=n;await this.isValidPairingTopic(o)},this.isValidDisconnect=async n=>{if(!ur(n)){const{message:l}=Q("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(l)}const{topic:o}=n;await this.isValidPairingTopic(o)},this.isValidPairingTopic=async n=>{if(!ls(n,!1)){const{message:o}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(o)}if(!this.pairings.keys.includes(n)){const{message:o}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(o)}if(wi(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:o}=Q("EXPIRED",`pairing topic: ${n}`);throw new Error(o)}},this.core=r,this.logger=Re.generateChildLogger(i,this.name),this.pairings=new mo(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Re.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}registerRelayerEvents(){this.core.relayer.on(vt.message,async r=>{const{topic:i,message:n}=r;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const o=await this.core.crypto.decode(i,n);Ec(o)?(this.core.history.set(i,o),this.onRelayEventRequest({topic:i,payload:o})):yo(o)&&(await this.core.history.resolve(o),await this.onRelayEventResponse({topic:i,payload:o}),this.core.history.delete(i,o.id))})}registerExpirerEvents(){this.core.expirer.on(Pr.expired,async r=>{const{topic:i}=Ml(r.target);i&&this.pairings.keys.includes(i)&&(await this.deletePairing(i,!0),this.events.emit("pairing_expire",{topic:i}))})}}class qb extends R1{constructor(r,i){super(r,i),this.core=r,this.logger=i,this.records=new Map,this.events=new Cr.EventEmitter,this.name=vb,this.version=mb,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,o,l)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:o,chainId:l}),this.records.has(o.id))return;const d={id:o.id,topic:n,request:{method:o.method,params:o.params||null},chainId:l,expiry:Lr(ne.THIRTY_DAYS)};this.records.set(d.id,d),this.events.emit(Kr.created,d)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const o=await this.getRecord(n.id);typeof o.response>"u"&&(o.response=$r(n)?{error:n.error}:{result:n.result},this.records.set(o.id,o),this.events.emit(Kr.updated,o))},this.get=async(n,o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:o}),await this.getRecord(o)),this.delete=(n,o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:o}),this.values.forEach(l=>{if(l.topic===n){if(typeof o<"u"&&l.id!==o)return;this.records.delete(l.id),this.events.emit(Kr.deleted,l)}})},this.exists=async(n,o)=>(this.isInitialized(),this.records.has(o)?(await this.getRecord(o)).topic===n:!1),this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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 r=[];return this.values.forEach(i=>{if(typeof i.response<"u")return;const n={topic:i.topic,request:po(i.request.method,i.request.params,i.id),chainId:i.chainId};return r.push(n)}),r}async setJsonRpcRecords(r){await this.core.storage.setItem(this.storageKey,r)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(r){this.isInitialized();const i=this.records.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw new Error(n)}return i}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Kr.sync)}async restore(){try{const r=await this.getJsonRpcRecords();if(typeof r>"u"||!r.length)return;if(this.records.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(r){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(r)}}registerEventListeners(){this.events.on(Kr.created,r=>{const i=Kr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.events.on(Kr.updated,r=>{const i=Kr.updated;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.events.on(Kr.deleted,r=>{const i=Kr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,record:r}),this.persist()}),this.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(r=>{ne.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.delete(r.topic,r.id))})}catch(r){this.logger.warn(r)}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Bb extends $1{constructor(r,i){super(r,i),this.core=r,this.logger=i,this.expirations=new Map,this.events=new Cr.EventEmitter,this.name=wb,this.version=_b,this.cached=[],this.initialized=!1,this.storagePrefix=bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const o=this.formatTarget(n);return typeof this.getExpiration(o)<"u"}catch{return!1}},this.set=(n,o)=>{this.isInitialized();const l=this.formatTarget(n),d={target:l,expiry:o};this.expirations.set(l,d),this.checkExpiry(l,d),this.events.emit(Pr.created,{target:l,expiration:d})},this.get=n=>{this.isInitialized();const o=this.formatTarget(n);return this.getExpiration(o)},this.del=n=>{if(this.isInitialized(),this.has(n)){const o=this.formatTarget(n),l=this.getExpiration(o);this.expirations.delete(o),this.events.emit(Pr.deleted,{target:o,expiration:l})}},this.on=(n,o)=>{this.events.on(n,o)},this.once=(n,o)=>{this.events.once(n,o)},this.off=(n,o)=>{this.events.off(n,o)},this.removeListener=(n,o)=>{this.events.removeListener(n,o)},this.logger=Re.generateChildLogger(i,this.name)}get context(){return Re.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+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(r){if(typeof r=="string")return bm(r);if(typeof r=="number")return Em(r);const{message:i}=Q("UNKNOWN_TYPE",`Target type: ${typeof r}`);throw new Error(i)}async setExpirations(r){await this.core.storage.setItem(this.storageKey,r)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Pr.sync)}async restore(){try{const r=await this.getExpirations();if(typeof r>"u"||!r.length)return;if(this.expirations.size){const{message:i}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(i),new Error(i)}this.cached=r,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(r){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(r)}}getExpiration(r){const i=this.expirations.get(r);if(!i){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${r}`);throw this.logger.error(n),new Error(n)}return i}checkExpiry(r,i){const{expiry:n}=i;ne.toMiliseconds(n)-Date.now()<=0&&this.expire(r,i)}expire(r,i){this.expirations.delete(r),this.events.emit(Pr.expired,{target:r,expiration:i})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((r,i)=>this.checkExpiry(i,r))}registerEventListeners(){this.core.heartbeat.on(gs.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Pr.created,r=>{const i=Pr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()}),this.events.on(Pr.expired,r=>{const i=Pr.expired;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()}),this.events.on(Pr.deleted,r=>{const i=Pr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:r}),this.persist()})}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}}class Hb extends M1{constructor(r,i){super(r,i),this.projectId=r,this.logger=i,this.name=Za,this.initialized=!1,this.init=async n=>{Im()||!jl()||(this.verifyUrl=(n==null?void 0:n.verifyUrl)||al,await this.createIframe())},this.register=async n=>{var o;if(this.initialized||await this.init(),!!this.iframe)try{(o=this.iframe.contentWindow)==null||o.postMessage(n.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${n.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async n=>{var o;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${n.attestationId}`);const l=this.startAbortTimer(ne.FIVE_SECONDS),d=await fetch(`${this.verifyUrl}/attestation/${n.attestationId}`,{signal:this.abortController.signal});return clearTimeout(l),d.status===200?(o=await d.json())==null?void 0:o.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise((n,o)=>{if(document.getElementById(Za))return n();const l=document.createElement("iframe");l.setAttribute("id",Za),l.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),l.style.display="none",l.addEventListener("load",()=>{this.initialized=!0,n()}),l.addEventListener("error",d=>{o(d)}),document.body.append(l),this.iframe=l}),new Promise(n=>{setTimeout(()=>n("iframe load timeout"),ne.toMiliseconds(ne.ONE_SECOND/2))})])}catch(n){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(n)}},this.logger=Re.generateChildLogger(i,this.name),this.verifyUrl=al,this.abortController=new AbortController,this.isDevEnv=xm()&&{}.IS_VITEST}get context(){return Re.getLoggerContext(this.logger)}startAbortTimer(r){return setTimeout(()=>this.abortController.abort(),ne.toMiliseconds(r))}}var kb=Object.defineProperty,gl=Object.getOwnPropertySymbols,Kb=Object.prototype.hasOwnProperty,Vb=Object.prototype.propertyIsEnumerable,yl=(c,r,i)=>r in c?kb(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,vl=(c,r)=>{for(var i in r||(r={}))Kb.call(r,i)&&yl(c,i,r[i]);if(gl)for(var i of gl(r))Vb.call(r,i)&&yl(c,i,r[i]);return c};class xc extends O1{constructor(r){super(r),this.protocol=yf,this.version=G_,this.name=Ic,this.events=new Cr.EventEmitter,this.initialized=!1,this.on=(n,o)=>this.events.on(n,o),this.once=(n,o)=>this.events.once(n,o),this.off=(n,o)=>this.events.off(n,o),this.removeListener=(n,o)=>this.events.removeListener(n,o),this.projectId=r==null?void 0:r.projectId,this.relayUrl=(r==null?void 0:r.relayUrl)||mf;const i=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||W_.logger}));this.logger=Re.generateChildLogger(i,this.name),this.heartbeat=new gs.HeartBeat,this.crypto=new Eb(this,this.logger,r==null?void 0:r.keychain),this.history=new qb(this,this.logger),this.expirer=new Bb(this,this.logger),this.storage=r!=null&&r.storage?r.storage:new _1(vl(vl({},J_),r==null?void 0:r.storageOptions)),this.relayer=new $b({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Ub(this,this.logger),this.verify=new Hb(this.projectId||"",this.logger)}static async init(r){const i=new xc(r);await i.initialize();const n=await i.crypto.getClientId();return await i.storage.setItem(lb,n),i}get context(){return Re.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(r){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,r),this.logger.error(r.message),r}}}const Gb=xc,wf="wc",_f=2,bf="client",Sc=`${wf}@${_f}:${bf}:`,ec={name:bf,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Wb="WALLETCONNECT_DEEPLINK_CHOICE",Jb="proposal",Ef="Proposal expired",Yb="session",eo=ne.SEVEN_DAYS,Xb="engine",Us={wc_sessionPropose:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ne.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ne.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1115}}},tc={min:ne.FIVE_MINUTES,max:ne.SEVEN_DAYS},Zb="request",Qb=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var eE=Object.defineProperty,tE=Object.defineProperties,rE=Object.getOwnPropertyDescriptors,ml=Object.getOwnPropertySymbols,iE=Object.prototype.hasOwnProperty,sE=Object.prototype.propertyIsEnumerable,wl=(c,r,i)=>r in c?eE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Sr=(c,r)=>{for(var i in r||(r={}))iE.call(r,i)&&wl(c,i,r[i]);if(ml)for(var i of ml(r))sE.call(r,i)&&wl(c,i,r[i]);return c},rc=(c,r)=>tE(c,rE(r));class nE extends z1{constructor(r){super(r),this.name=Xb,this.events=new vc,this.initialized=!1,this.ignoredPayloadTypes=[$l],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Us)}),this.initialized=!0)},this.connect=async i=>{this.isInitialized();const n=rc(Sr({},i),{requiredNamespaces:i.requiredNamespaces||{},optionalNamespaces:i.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:o,requiredNamespaces:l,optionalNamespaces:d,sessionProperties:v,relays:b}=n;let m=o,S,O=!1;if(m&&(O=this.client.core.pairing.pairings.get(m).active),!m||!O){const{topic:fe,uri:pe}=await this.client.core.pairing.create();m=fe,S=pe}const F=await this.client.core.crypto.generateKeyPair(),z=Sr({requiredNamespaces:l,optionalNamespaces:d,relays:b??[{protocol:vf}],proposer:{publicKey:F,metadata:this.client.metadata}},v&&{sessionProperties:v}),{reject:R,resolve:K,done:re}=hs(ne.FIVE_MINUTES,Ef);if(this.events.once(Ft("session_connect"),async({error:fe,session:pe})=>{if(fe)R(fe);else if(pe){pe.self.publicKey=F;const de=rc(Sr({},pe),{requiredNamespaces:pe.requiredNamespaces,optionalNamespaces:pe.optionalNamespaces});await this.client.session.set(pe.topic,de),await this.setExpiry(pe.topic,pe.expiry),m&&await this.client.core.pairing.updateMetadata({topic:m,metadata:pe.peer.metadata}),K(de)}}),!m){const{message:fe}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${m}`);throw new Error(fe)}const he=await this.sendRequest(m,"wc_sessionPropose",z),le=Lr(ne.FIVE_MINUTES);return await this.setProposal(he,Sr({id:he,expiry:le},z)),{uri:S,approval:re}},this.pair=async i=>(this.isInitialized(),await this.client.core.pairing.pair(i)),this.approve=async i=>{this.isInitialized(),await this.isValidApprove(i);const{id:n,relayProtocol:o,namespaces:l,sessionProperties:d}=i,v=this.client.proposal.get(n);let{pairingTopic:b,proposer:m,requiredNamespaces:S,optionalNamespaces:O}=v;b=b||"",so(S)||(S=Pm(l,"approve()"));const F=await this.client.core.crypto.generateKeyPair(),z=m.publicKey,R=await this.client.core.crypto.generateSharedKey(F,z);b&&n&&(await this.client.core.pairing.updateMetadata({topic:b,metadata:m.metadata}),await this.sendResult(n,b,{relay:{protocol:o??"irn"},responderPublicKey:F}),await this.client.proposal.delete(n,tr("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:b}));const K=Sr({relay:{protocol:o??"irn"},namespaces:l,requiredNamespaces:S,optionalNamespaces:O,pairingTopic:b,controller:{publicKey:F,metadata:this.client.metadata},expiry:Lr(eo)},d&&{sessionProperties:d});await this.client.core.relayer.subscribe(R),await this.sendRequest(R,"wc_sessionSettle",K);const re=rc(Sr({},K),{topic:R,pairingTopic:b,acknowledged:!1,self:K.controller,peer:{publicKey:m.publicKey,metadata:m.metadata},controller:F});return await this.client.session.set(R,re),await this.setExpiry(R,Lr(eo)),{topic:R,acknowledged:()=>new Promise(he=>setTimeout(()=>he(this.client.session.get(R)),500))}},this.reject=async i=>{this.isInitialized(),await this.isValidReject(i);const{id:n,reason:o}=i,{pairingTopic:l}=this.client.proposal.get(n);l&&(await this.sendError(n,l,o),await this.client.proposal.delete(n,tr("USER_DISCONNECTED")))},this.update=async i=>{this.isInitialized(),await this.isValidUpdate(i);const{topic:n,namespaces:o}=i,l=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:o}),{done:d,resolve:v,reject:b}=hs();return this.events.once(Ft("session_update",l),({error:m})=>{m?b(m):v()}),await this.client.session.update(n,{namespaces:o}),{acknowledged:d}},this.extend=async i=>{this.isInitialized(),await this.isValidExtend(i);const{topic:n}=i,o=await this.sendRequest(n,"wc_sessionExtend",{}),{done:l,resolve:d,reject:v}=hs();return this.events.once(Ft("session_extend",o),({error:b})=>{b?v(b):d()}),await this.setExpiry(n,Lr(eo)),{acknowledged:l}},this.request=async i=>{this.isInitialized(),await this.isValidRequest(i);const{chainId:n,request:o,topic:l,expiry:d}=i,v=await this.sendRequest(l,"wc_sessionRequest",{request:o,chainId:n},d),{done:b,resolve:m,reject:S}=hs(d);this.events.once(Ft("session_request",v),({error:F,result:z})=>{F?S(F):m(z)}),this.client.events.emit("session_request_sent",{topic:l,request:o,chainId:n,id:v});const O=await this.client.core.storage.getItem(Wb);return Am({id:v,topic:l,wcDeepLink:O}),await b()},this.respond=async i=>{this.isInitialized(),await this.isValidRespond(i);const{topic:n,response:o}=i,{id:l}=o;ai(o)?await this.sendResult(l,n,o.result):$r(o)&&await this.sendError(l,n,o.error),this.deletePendingSessionRequest(i.response.id,{message:"fulfilled",code:0})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.client.session.keys.includes(n)){const o=await this.sendRequest(n,"wc_sessionPing",{}),{done:l,resolve:d,reject:v}=hs();this.events.once(Ft("session_ping",o),({error:b})=>{b?v(b):d()}),await l()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async i=>{this.isInitialized(),await this.isValidEmit(i);const{topic:n,event:o,chainId:l}=i;await this.sendRequest(n,"wc_sessionEvent",{event:o,chainId:l})},this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;if(this.client.session.keys.includes(n)){const o=_c().toString();let l;const d=v=>{(v==null?void 0:v.id.toString())===o&&(this.client.core.relayer.events.removeListener(vt.message_ack,d),l())};await Promise.all([new Promise(v=>{l=v,this.client.core.relayer.on(vt.message_ack,d)}),this.sendRequest(n,"wc_sessionDelete",tr("USER_DISCONNECTED"),void 0,o)]),await this.deleteSession(n)}else await this.client.core.pairing.disconnect({topic:n})},this.find=i=>(this.isInitialized(),this.client.session.getAll().filter(n=>Cm(n,i))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async i=>{if(i.pairingTopic)try{const n=this.client.core.pairing.pairings.get(i.pairingTopic),o=this.client.core.pairing.pairings.getAll().filter(l=>{var d,v;return((d=l.peerMetadata)==null?void 0:d.url)&&((v=l.peerMetadata)==null?void 0:v.url)===i.peer.metadata.url&&l.topic&&l.topic!==n.topic});if(o.length===0)return;this.client.logger.info(`Cleaning up ${o.length} duplicate pairing(s)`),await Promise.all(o.map(l=>this.client.core.pairing.disconnect({topic:l.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async(i,n)=>{const{self:o}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),this.client.session.delete(i,tr("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),n||this.client.core.expirer.del(i)},this.deleteProposal=async(i,n)=>{await Promise.all([this.client.proposal.delete(i,tr("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(i)])},this.deletePendingSessionRequest=async(i,n,o=!1)=>{await Promise.all([this.client.pendingRequest.delete(i,n),o?Promise.resolve():this.client.core.expirer.del(i)])},this.setExpiry=async(i,n)=>{this.client.session.keys.includes(i)&&await this.client.session.update(i,{expiry:n}),this.client.core.expirer.set(i,n)},this.setProposal=async(i,n)=>{await this.client.proposal.set(i,n),this.client.core.expirer.set(i,n.expiry)},this.setPendingSessionRequest=async i=>{const n=Us.wc_sessionRequest.req.ttl,{id:o,topic:l,params:d}=i;await this.client.pendingRequest.set(o,{id:o,topic:l,params:d}),n&&this.client.core.expirer.set(o,Lr(n))},this.sendRequest=async(i,n,o,l,d)=>{const v=po(n,o);if(jl()&&Qb.includes(n)){const S=fs(JSON.stringify(v));await this.client.core.verify.register({attestationId:S})}const b=await this.client.core.crypto.encode(i,v),m=Us[n].req;return l&&(m.ttl=l),d&&(m.id=d),this.client.core.history.set(i,v),this.client.core.relayer.publish(i,b,m),v.id},this.sendResult=async(i,n,o)=>{const l=bc(i,o),d=await this.client.core.crypto.encode(n,l),v=await this.client.core.history.get(n,i),b=Us[v.request.method].res;this.client.core.relayer.publish(n,d,b),await this.client.core.history.resolve(l)},this.sendError=async(i,n,o)=>{const l=go(i,o),d=await this.client.core.crypto.encode(n,l),v=await this.client.core.history.get(n,i),b=Us[v.request.method].res;this.client.core.relayer.publish(n,d,b),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const i=[],n=[];this.client.session.getAll().forEach(o=>{wi(o.expiry)&&i.push(o.topic)}),this.client.proposal.getAll().forEach(o=>{wi(o.expiry)&&n.push(o.id)}),await Promise.all([...i.map(o=>this.deleteSession(o)),...n.map(o=>this.deleteProposal(o))])},this.onRelayEventRequest=i=>{const{topic:n,payload:o}=i,l=o.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeRequest(n,o);case"wc_sessionSettle":return this.onSessionSettleRequest(n,o);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,o);case"wc_sessionExtend":return this.onSessionExtendRequest(n,o);case"wc_sessionPing":return this.onSessionPingRequest(n,o);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,o);case"wc_sessionRequest":return this.onSessionRequest(n,o);case"wc_sessionEvent":return this.onSessionEventRequest(n,o);default:return this.client.logger.info(`Unsupported request method ${l}`)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:o}=i,l=(await this.client.core.history.get(n,o.id)).request.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeResponse(n,o);case"wc_sessionSettle":return this.onSessionSettleResponse(n,o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,o);case"wc_sessionExtend":return this.onSessionExtendResponse(n,o);case"wc_sessionPing":return this.onSessionPingResponse(n,o);case"wc_sessionRequest":return this.onSessionRequestResponse(n,o);default:return this.client.logger.info(`Unsupported response method ${l}`)}},this.onRelayEventUnknownPayload=i=>{const{topic:n}=i,{message:o}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(o)},this.onSessionProposeRequest=async(i,n)=>{const{params:o,id:l}=n;try{this.isValidConnect(Sr({},n.params));const d=Lr(ne.FIVE_MINUTES),v=Sr({id:l,pairingTopic:i,expiry:d},o);await this.setProposal(l,v);const b=fs(JSON.stringify(n)),m=await this.getVerifyContext(b,v.proposer.metadata);this.client.events.emit("session_proposal",{id:l,params:v,verifyContext:m})}catch(d){await this.sendError(l,i,d),this.client.logger.error(d)}},this.onSessionProposeResponse=async(i,n)=>{const{id:o}=n;if(ai(n)){const{result:l}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:l});const d=this.client.proposal.get(o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:d});const v=d.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:v});const b=l.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:b});const m=await this.client.core.crypto.generateSharedKey(v,b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:m});const S=await this.client.core.relayer.subscribe(m);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:S}),await this.client.core.pairing.activate({topic:i})}else $r(n)&&(await this.client.proposal.delete(o,tr("USER_DISCONNECTED")),this.events.emit(Ft("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidSessionSettleRequest(l);const{relay:d,controller:v,expiry:b,namespaces:m,requiredNamespaces:S,optionalNamespaces:O,sessionProperties:F,pairingTopic:z}=n.params,R=Sr({topic:i,relay:d,expiry:b,namespaces:m,acknowledged:!0,pairingTopic:z,requiredNamespaces:S,optionalNamespaces:O,controller:v.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:v.publicKey,metadata:v.metadata}},F&&{sessionProperties:F});await this.sendResult(n.id,i,!0),this.events.emit(Ft("session_connect"),{session:R}),this.cleanupDuplicatePairings(R)}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.onSessionSettleResponse=async(i,n)=>{const{id:o}=n;ai(n)?(await this.client.session.update(i,{acknowledged:!0}),this.events.emit(Ft("session_approve",o),{})):$r(n)&&(await this.client.session.delete(i,tr("USER_DISCONNECTED")),this.events.emit(Ft("session_approve",o),{error:n.error}))},this.onSessionUpdateRequest=async(i,n)=>{const{params:o,id:l}=n;try{this.isValidUpdate(Sr({topic:i},o)),await this.client.session.update(i,{namespaces:o.namespaces}),await this.sendResult(l,i,!0),this.client.events.emit("session_update",{id:l,topic:i,params:o})}catch(d){await this.sendError(l,i,d),this.client.logger.error(d)}},this.onSessionUpdateResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_update",o),{}):$r(n)&&this.events.emit(Ft("session_update",o),{error:n.error})},this.onSessionExtendRequest=async(i,n)=>{const{id:o}=n;try{this.isValidExtend({topic:i}),await this.setExpiry(i,Lr(eo)),await this.sendResult(o,i,!0),this.client.events.emit("session_extend",{id:o,topic:i})}catch(l){await this.sendError(o,i,l),this.client.logger.error(l)}},this.onSessionExtendResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_extend",o),{}):$r(n)&&this.events.emit(Ft("session_extend",o),{error:n.error})},this.onSessionPingRequest=async(i,n)=>{const{id:o}=n;try{this.isValidPing({topic:i}),await this.sendResult(o,i,!0),this.client.events.emit("session_ping",{id:o,topic:i})}catch(l){await this.sendError(o,i,l),this.client.logger.error(l)}},this.onSessionPingResponse=(i,n)=>{const{id:o}=n;setTimeout(()=>{ai(n)?this.events.emit(Ft("session_ping",o),{}):$r(n)&&this.events.emit(Ft("session_ping",o),{error:n.error})},500)},this.onSessionDeleteRequest=async(i,n)=>{const{id:o}=n;try{this.isValidDisconnect({topic:i,reason:n.params}),await Promise.all([new Promise(l=>{this.client.core.relayer.once(vt.publish,async()=>{l(await this.deleteSession(i))})}),this.sendResult(o,i,!0)]),this.client.events.emit("session_delete",{id:o,topic:i})}catch(l){this.client.logger.error(l)}},this.onSessionRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidRequest(Sr({topic:i},l)),await this.setPendingSessionRequest({id:o,topic:i,params:l});const d=fs(JSON.stringify(n)),v=this.client.session.get(i),b=await this.getVerifyContext(d,v.peer.metadata);this.client.events.emit("session_request",{id:o,topic:i,params:l,verifyContext:b})}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.onSessionRequestResponse=(i,n)=>{const{id:o}=n;ai(n)?this.events.emit(Ft("session_request",o),{result:n.result}):$r(n)&&this.events.emit(Ft("session_request",o),{error:n.error})},this.onSessionEventRequest=async(i,n)=>{const{id:o,params:l}=n;try{this.isValidEmit(Sr({topic:i},l)),this.client.events.emit("session_event",{id:o,topic:i,params:l})}catch(d){await this.sendError(o,i,d),this.client.logger.error(d)}},this.isValidConnect=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(i)}`);throw new Error(b)}const{pairingTopic:n,requiredNamespaces:o,optionalNamespaces:l,sessionProperties:d,relays:v}=i;if(_i(n)||await this.isValidPairingTopic(n),!Om(v,!0)){const{message:b}=Q("MISSING_OR_INVALID",`connect() relays: ${v}`);throw new Error(b)}!_i(o)&&so(o)!==0&&this.validateNamespaces(o,"requiredNamespaces"),!_i(l)&&so(l)!==0&&this.validateNamespaces(l,"optionalNamespaces"),_i(d)||this.validateSessionProps(d,"sessionProperties")},this.validateNamespaces=(i,n)=>{const o=Rm(i,"connect()",n);if(o)throw new Error(o.message)},this.isValidApprove=async i=>{if(!ur(i))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${i}`).message);const{id:n,namespaces:o,relayProtocol:l,sessionProperties:d}=i;await this.isValidProposalId(n);const v=this.client.proposal.get(n),b=Ha(o,"approve()");if(b)throw new Error(b.message);const m=Oh(v.requiredNamespaces,o,"approve()");if(m)throw new Error(m.message);if(!ls(l,!0)){const{message:S}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${l}`);throw new Error(S)}_i(d)||this.validateSessionProps(d,"sessionProperties")},this.isValidReject=async i=>{if(!ur(i)){const{message:l}=Q("MISSING_OR_INVALID",`reject() params: ${i}`);throw new Error(l)}const{id:n,reason:o}=i;if(await this.isValidProposalId(n),!Tm(o)){const{message:l}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(o)}`);throw new Error(l)}},this.isValidSessionSettleRequest=i=>{if(!ur(i)){const{message:m}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${i}`);throw new Error(m)}const{relay:n,controller:o,namespaces:l,expiry:d}=i;if(!Nm(n)){const{message:m}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(m)}const v=Dm(o,"onSessionSettleRequest()");if(v)throw new Error(v.message);const b=Ha(l,"onSessionSettleRequest()");if(b)throw new Error(b.message);if(wi(d)){const{message:m}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(m)}},this.isValidUpdate=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`update() params: ${i}`);throw new Error(b)}const{topic:n,namespaces:o}=i;await this.isValidSessionTopic(n);const l=this.client.session.get(n),d=Ha(o,"update()");if(d)throw new Error(d.message);const v=Oh(l.requiredNamespaces,o,"update()");if(v)throw new Error(v.message)},this.isValidExtend=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`extend() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionTopic(n)},this.isValidRequest=async i=>{if(!ur(i)){const{message:b}=Q("MISSING_OR_INVALID",`request() params: ${i}`);throw new Error(b)}const{topic:n,request:o,chainId:l,expiry:d}=i;await this.isValidSessionTopic(n);const{namespaces:v}=this.client.session.get(n);if(!Rh(v,l)){const{message:b}=Q("MISSING_OR_INVALID",`request() chainId: ${l}`);throw new Error(b)}if(!Fm(o)){const{message:b}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(o)}`);throw new Error(b)}if(!Lm(v,l,o.method)){const{message:b}=Q("MISSING_OR_INVALID",`request() method: ${o.method}`);throw new Error(b)}if(d&&!$m(d,tc)){const{message:b}=Q("MISSING_OR_INVALID",`request() expiry: ${d}. Expiry must be a number (in seconds) between ${tc.min} and ${tc.max}`);throw new Error(b)}},this.isValidRespond=async i=>{if(!ur(i)){const{message:l}=Q("MISSING_OR_INVALID",`respond() params: ${i}`);throw new Error(l)}const{topic:n,response:o}=i;if(await this.isValidSessionTopic(n),!Mm(o)){const{message:l}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(o)}`);throw new Error(l)}},this.isValidPing=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async i=>{if(!ur(i)){const{message:v}=Q("MISSING_OR_INVALID",`emit() params: ${i}`);throw new Error(v)}const{topic:n,event:o,chainId:l}=i;await this.isValidSessionTopic(n);const{namespaces:d}=this.client.session.get(n);if(!Rh(d,l)){const{message:v}=Q("MISSING_OR_INVALID",`emit() chainId: ${l}`);throw new Error(v)}if(!jm(o)){const{message:v}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(v)}if(!zm(d,l,o.name)){const{message:v}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(v)}},this.isValidDisconnect=async i=>{if(!ur(i)){const{message:o}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(o)}const{topic:n}=i;await this.isValidSessionOrPairingTopic(n)},this.getVerifyContext=async(i,n)=>{const o={verified:{verifyUrl:n.verifyUrl||"",validation:"UNKNOWN",origin:n.url||""}};try{const l=await this.client.core.verify.resolve({attestationId:i,verifyUrl:n.verifyUrl});l&&(o.verified.origin=l,o.verified.validation=l===n.url?"VALID":"INVALID")}catch(l){this.client.logger.error(l)}return this.client.logger.info(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(i,n)=>{Object.values(i).forEach(o=>{if(!ls(o,!1)){const{message:l}=Q("MISSING_OR_INVALID",`${n} must be in Record format. Received: ${JSON.stringify(o)}`);throw new Error(l)}})}}isInitialized(){if(!this.initialized){const{message:r}=Q("NOT_INITIALIZED",this.name);throw new Error(r)}}registerRelayerEvents(){this.client.core.relayer.on(vt.message,async r=>{const{topic:i,message:n}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const o=await this.client.core.crypto.decode(i,n);Ec(o)?(this.client.core.history.set(i,o),this.onRelayEventRequest({topic:i,payload:o})):yo(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:i,payload:o}),this.client.core.history.delete(i,o.id)):this.onRelayEventUnknownPayload({topic:i,payload:o})})}registerExpirerEvents(){this.client.core.expirer.on(Pr.expired,async r=>{const{topic:i,id:n}=Ml(r.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,Q("EXPIRED"),!0);i?this.client.session.keys.includes(i)&&(await this.deleteSession(i,!0),this.client.events.emit("session_expire",{topic:i})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}isValidPairingTopic(r){if(!ls(r,!1)){const{message:i}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(i)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.core.pairing.pairings.get(r).expiry)){const{message:i}=Q("EXPIRED",`pairing topic: ${r}`);throw new Error(i)}}async isValidSessionTopic(r){if(!ls(r,!1)){const{message:i}=Q("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(i)}if(!this.client.session.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.session.get(r).expiry)){await this.deleteSession(r);const{message:i}=Q("EXPIRED",`session topic: ${r}`);throw new Error(i)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(ls(r,!1)){const{message:i}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(i)}else{const{message:i}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(i)}}async isValidProposalId(r){if(!Um(r)){const{message:i}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(i)}if(!this.client.proposal.keys.includes(r)){const{message:i}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(i)}if(wi(this.client.proposal.get(r).expiry)){await this.deleteProposal(r);const{message:i}=Q("EXPIRED",`proposal id: ${r}`);throw new Error(i)}}}class oE extends mo{constructor(r,i){super(r,i,Jb,Sc),this.core=r,this.logger=i}}class aE extends mo{constructor(r,i){super(r,i,Yb,Sc),this.core=r,this.logger=i}}class cE extends mo{constructor(r,i){super(r,i,Zb,Sc,n=>n.id),this.core=r,this.logger=i}}let uE=class If extends j1{constructor(r){super(r),this.protocol=wf,this.version=_f,this.name=ec.name,this.events=new Cr.EventEmitter,this.on=(n,o)=>this.events.on(n,o),this.once=(n,o)=>this.events.once(n,o),this.off=(n,o)=>this.events.off(n,o),this.removeListener=(n,o)=>this.events.removeListener(n,o),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(o){throw this.logger.error(o.message),o}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(o){throw this.logger.error(o.message),o}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(o){throw this.logger.error(o.message),o}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(o){throw this.logger.error(o.message),o}},this.update=async n=>{try{return await this.engine.update(n)}catch(o){throw this.logger.error(o.message),o}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(o){throw this.logger.error(o.message),o}},this.request=async n=>{try{return await this.engine.request(n)}catch(o){throw this.logger.error(o.message),o}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(o){throw this.logger.error(o.message),o}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(o){throw this.logger.error(o.message),o}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(o){throw this.logger.error(o.message),o}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(o){throw this.logger.error(o.message),o}},this.find=n=>{try{return this.engine.find(n)}catch(o){throw this.logger.error(o.message),o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=(r==null?void 0:r.name)||ec.name,this.metadata=(r==null?void 0:r.metadata)||Sm();const i=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||ec.logger}));this.core=(r==null?void 0:r.core)||new Gb(r),this.logger=Re.generateChildLogger(i,this.name),this.session=new aE(this.core,this.logger),this.proposal=new oE(this.core,this.logger),this.pendingRequest=new cE(this.core,this.logger),this.engine=new nE(this)}static async init(r){const i=new If(r);return await i.initialize(),i}get context(){return Re.getLoggerContext(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.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};var lc={exports:{}};(function(c,r){var i=typeof self<"u"?self:Mr,n=function(){function l(){this.fetch=!1,this.DOMException=i.DOMException}return l.prototype=i,new l}();(function(l){(function(d){var v={searchParams:"URLSearchParams"in l,iterable:"Symbol"in l&&"iterator"in Symbol,blob:"FileReader"in l&&"Blob"in l&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in l,arrayBuffer:"ArrayBuffer"in l};function b(y){return y&&DataView.prototype.isPrototypeOf(y)}if(v.arrayBuffer)var m=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],S=ArrayBuffer.isView||function(y){return y&&m.indexOf(Object.prototype.toString.call(y))>-1};function O(y){if(typeof y!="string"&&(y=String(y)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(y))throw new TypeError("Invalid character in header field name");return y.toLowerCase()}function F(y){return typeof y!="string"&&(y=String(y)),y}function z(y){var I={next:function(){var X=y.shift();return{done:X===void 0,value:X}}};return v.iterable&&(I[Symbol.iterator]=function(){return I}),I}function R(y){this.map={},y instanceof R?y.forEach(function(I,X){this.append(X,I)},this):Array.isArray(y)?y.forEach(function(I){this.append(I[0],I[1])},this):y&&Object.getOwnPropertyNames(y).forEach(function(I){this.append(I,y[I])},this)}R.prototype.append=function(y,I){y=O(y),I=F(I);var X=this.map[y];this.map[y]=X?X+", "+I:I},R.prototype.delete=function(y){delete this.map[O(y)]},R.prototype.get=function(y){return y=O(y),this.has(y)?this.map[y]:null},R.prototype.has=function(y){return this.map.hasOwnProperty(O(y))},R.prototype.set=function(y,I){this.map[O(y)]=F(I)},R.prototype.forEach=function(y,I){for(var X in this.map)this.map.hasOwnProperty(X)&&y.call(I,this.map[X],X,this)},R.prototype.keys=function(){var y=[];return this.forEach(function(I,X){y.push(X)}),z(y)},R.prototype.values=function(){var y=[];return this.forEach(function(I){y.push(I)}),z(y)},R.prototype.entries=function(){var y=[];return this.forEach(function(I,X){y.push([X,I])}),z(y)},v.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function K(y){if(y.bodyUsed)return Promise.reject(new TypeError("Already read"));y.bodyUsed=!0}function re(y){return new Promise(function(I,X){y.onload=function(){I(y.result)},y.onerror=function(){X(y.error)}})}function he(y){var I=new FileReader,X=re(I);return I.readAsArrayBuffer(y),X}function le(y){var I=new FileReader,X=re(I);return I.readAsText(y),X}function fe(y){for(var I=new Uint8Array(y),X=new Array(I.length),ce=0;ce-1?I:y}function W(y,I){I=I||{};var X=I.body;if(y instanceof W){if(y.bodyUsed)throw new TypeError("Already read");this.url=y.url,this.credentials=y.credentials,I.headers||(this.headers=new R(y.headers)),this.method=y.method,this.mode=y.mode,this.signal=y.signal,!X&&y._bodyInit!=null&&(X=y._bodyInit,y.bodyUsed=!0)}else this.url=String(y);if(this.credentials=I.credentials||this.credentials||"same-origin",(I.headers||!this.headers)&&(this.headers=new R(I.headers)),this.method=q(I.method||this.method||"GET"),this.mode=I.mode||this.mode||null,this.signal=I.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&X)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(X)}W.prototype.clone=function(){return new W(this,{body:this._bodyInit})};function ve(y){var I=new FormData;return y.trim().split("&").forEach(function(X){if(X){var ce=X.split("="),V=ce.shift().replace(/\+/g," "),B=ce.join("=").replace(/\+/g," ");I.append(decodeURIComponent(V),decodeURIComponent(B))}}),I}function ie(y){var I=new R,X=y.replace(/\r?\n[\t ]+/g," ");return X.split(/\r?\n/).forEach(function(ce){var V=ce.split(":"),B=V.shift().trim();if(B){var k=V.join(":").trim();I.append(B,k)}}),I}de.call(W.prototype);function ue(y,I){I||(I={}),this.type="default",this.status=I.status===void 0?200:I.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in I?I.statusText:"OK",this.headers=new R(I.headers),this.url=I.url||"",this._initBody(y)}de.call(ue.prototype),ue.prototype.clone=function(){return new ue(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},ue.error=function(){var y=new ue(null,{status:0,statusText:""});return y.type="error",y};var Te=[301,302,303,307,308];ue.redirect=function(y,I){if(Te.indexOf(I)===-1)throw new RangeError("Invalid status code");return new ue(null,{status:I,headers:{location:y}})},d.DOMException=l.DOMException;try{new d.DOMException}catch{d.DOMException=function(I,X){this.message=I,this.name=X;var ce=Error(I);this.stack=ce.stack},d.DOMException.prototype=Object.create(Error.prototype),d.DOMException.prototype.constructor=d.DOMException}function Ue(y,I){return new Promise(function(X,ce){var V=new W(y,I);if(V.signal&&V.signal.aborted)return ce(new d.DOMException("Aborted","AbortError"));var B=new XMLHttpRequest;function k(){B.abort()}B.onload=function(){var G={status:B.status,statusText:B.statusText,headers:ie(B.getAllResponseHeaders()||"")};G.url="responseURL"in B?B.responseURL:G.headers.get("X-Request-URL");var Je="response"in B?B.response:B.responseText;X(new ue(Je,G))},B.onerror=function(){ce(new TypeError("Network request failed"))},B.ontimeout=function(){ce(new TypeError("Network request failed"))},B.onabort=function(){ce(new d.DOMException("Aborted","AbortError"))},B.open(V.method,V.url,!0),V.credentials==="include"?B.withCredentials=!0:V.credentials==="omit"&&(B.withCredentials=!1),"responseType"in B&&v.blob&&(B.responseType="blob"),V.headers.forEach(function(G,Je){B.setRequestHeader(Je,G)}),V.signal&&(V.signal.addEventListener("abort",k),B.onreadystatechange=function(){B.readyState===4&&V.signal.removeEventListener("abort",k)}),B.send(typeof V._bodyInit>"u"?null:V._bodyInit)})}return Ue.polyfill=!0,l.fetch||(l.fetch=Ue,l.Headers=R,l.Request=W,l.Response=ue),d.Headers=R,d.Request=W,d.Response=ue,d.fetch=Ue,Object.defineProperty(d,"__esModule",{value:!0}),d})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var o=n;r=o.fetch,r.default=o.fetch,r.fetch=o.fetch,r.Headers=o.Headers,r.Request=o.Request,r.Response=o.Response,c.exports=r})(lc,lc.exports);var hE=lc.exports;const _l=Ll(hE),lE={Accept:"application/json","Content-Type":"application/json"},fE="POST",bl={headers:lE,method:fE},El=10;class Hi{constructor(r,i=!1){if(this.url=r,this.disableProviderPing=i,this.events=new Cr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Jh(r))throw new Error(`Provided URL is not compatible with HTTP connection: ${r}`);this.url=r,this.disableProviderPing=i}get connected(){return this.isAvailable}get connecting(){return this.registering}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}off(r,i){this.events.off(r,i)}removeListener(r,i){this.events.removeListener(r,i)}async open(r=this.url){await this.register(r)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(r,i){this.isAvailable||await this.register();try{const n=Ui(r),l=await(await _l(this.url,Object.assign(Object.assign({},bl),{body:n}))).json();this.onPayload({data:l})}catch(n){this.onError(r.id,n)}}async register(r=this.url){if(!Jh(r))throw new Error(`Provided URL is not compatible with HTTP connection: ${r}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((n,o)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),o(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return o(new Error("HTTP connection is missing or invalid"));n()})})}this.url=r,this.registering=!0;try{if(!this.disableProviderPing){const i=Ui({id:1,jsonrpc:"2.0",method:"test",params:[]});await _l(r,Object.assign(Object.assign({},bl),{body:i}))}this.onOpen()}catch(i){const n=this.parseError(i);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(r){if(typeof r.data>"u")return;const i=typeof r.data=="string"?Ks(r.data):r.data;this.events.emit("payload",i)}onError(r,i){const n=this.parseError(i),o=n.message||n.toString(),l=go(r,o);this.events.emit("payload",l)}parseError(r,i=this.url){return Ql(r,i,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>El&&this.events.setMaxListeners(El)}}const Il="error",pE="wss://relay.walletconnect.com",dE="wc",gE="universal_provider",xl=`${dE}@2:${gE}:`,yE="https://rpc.walletconnect.com/v1",Ii={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var qs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},fc={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors @@ -24,4 +24,4 @@ __p += '`),Oe&&(H+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+H+`return __p -}`;var Ee=xh(function(){return Le(p,te+"return "+H).apply(i,w)});if(Ee.source=H,Na(Ee))throw Ee;return Ee}function hv(e){return Me(e).toLowerCase()}function lv(e){return Me(e).toUpperCase()}function fv(e,t,s){if(e=Me(e),e&&(s||t===i))return Dc(e);if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Tr(t),p=Fc(a,h),w=Lc(a,h)+1;return vi(a,p,w).join("")}function pv(e,t,s){if(e=Me(e),e&&(s||t===i))return e.slice(0,Mc(e)+1);if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Lc(a,Tr(t))+1;return vi(a,0,h).join("")}function dv(e,t,s){if(e=Me(e),e&&(s||t===i))return e.replace(dt,"");if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Fc(a,Tr(t));return vi(a,h).join("")}function gv(e,t){var s=ie,a=ue;if(ct(t)){var h="separator"in t?t.separator:h;s="length"in t?_e(t.length):s,a="omission"in t?fr(t.omission):a}e=Me(e);var p=e.length;if(Zi(e)){var w=Tr(e);p=w.length}if(s>=p)return e;var _=s-Qi(a);if(_<1)return a;var A=w?vi(w,0,_).join(""):e.slice(0,_);if(h===i)return A+a;if(w&&(_+=A.length-_),Da(h)){if(e.slice(_).search(h)){var M,j=A;for(h.global||(h=Jo(h.source,Me(yr.exec(h))+"g")),h.lastIndex=0;M=h.exec(j);)var H=M.index;A=A.slice(0,H===i?_:H)}}else if(e.indexOf(fr(h),_)!=_){var J=A.lastIndexOf(h);J>-1&&(A=A.slice(0,J))}return A+a}function yv(e){return e=Me(e),e&&ht.test(e)?e.replace(ci,Kf):e}var vv=os(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),$a=Su("toUpperCase");function Ih(e,t,s){return e=Me(e),t=s?i:t,t===i?Uf(e)?Wf(e):Tf(e):e.match(t)||[]}var xh=xe(function(e,t){try{return zt(e,i,t)}catch(s){return Na(s)?s:new ye(s)}}),mv=ei(function(e,t){return mr(t,function(s){s=kr(s),Zr(e,s,Ra(e[s],e))}),e});function wv(e){var t=e==null?0:e.length,s=se();return e=t?st(e,function(a){if(typeof a[1]!="function")throw new wr(d);return[s(a[0]),a[1]]}):[],xe(function(a){for(var h=-1;++hV)return[];var s=G,a=Vt(e,G);t=se(t),e-=G;for(var h=Vo(a,t);++s0||t<0)?new Ae(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==i&&(t=_e(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Ae.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ae.prototype.toArray=function(){return this.take(G)},Br(Ae.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),a=/^(?:head|last)$/.test(t),h=f[a?"take"+(t=="last"?"Right":""):t],p=a||/^find/.test(t);h&&(f.prototype[t]=function(){var w=this.__wrapped__,_=a?[1]:arguments,A=w instanceof Ae,M=_[0],j=A||we(w),H=function(Se){var Oe=h.apply(f,li([Se],_));return a&&J?Oe[0]:Oe};j&&s&&typeof M=="function"&&M.length!=1&&(A=j=!1);var J=this.__chain__,te=!!this.__actions__.length,oe=p&&!J,Ee=A&&!te;if(!p&&j){w=Ee?w:new Ae(this);var ae=e.apply(w,_);return ae.__actions__.push({func:kn,args:[H],thisArg:i}),new _r(ae,J)}return oe&&Ee?e.apply(this,_):(ae=this.thru(H),oe?a?ae.value()[0]:ae.value():ae)})}),mr(["pop","push","shift","sort","splice","unshift"],function(e){var t=yn[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",a=/^(?:pop|shift)$/.test(e);f.prototype[e]=function(){var h=arguments;if(a&&!this.__chain__){var p=this.value();return t.apply(we(p)?p:[],h)}return this[s](function(w){return t.apply(we(w)?w:[],h)})}}),Br(Ae.prototype,function(e,t){var s=f[t];if(s){var a=s.name+"";ze.call(is,a)||(is[a]=[]),is[a].push({name:t,func:s})}}),is[Mn(i,he).name]=[{name:"wrapper",func:i}],Ae.prototype.clone=yp,Ae.prototype.reverse=vp,Ae.prototype.value=mp,f.prototype.at=Gg,f.prototype.chain=Wg,f.prototype.commit=Jg,f.prototype.next=Yg,f.prototype.plant=Zg,f.prototype.reverse=Qg,f.prototype.toJSON=f.prototype.valueOf=f.prototype.value=ey,f.prototype.first=f.prototype.head,bs&&(f.prototype[bs]=Xg),f},es=Jf();_t?((_t.exports=es)._=es,Ge._=es):Ce._=es}).call(qs)})(fc,fc.exports);var vE=Object.defineProperty,mE=Object.defineProperties,wE=Object.getOwnPropertyDescriptors,Sl=Object.getOwnPropertySymbols,_E=Object.prototype.hasOwnProperty,bE=Object.prototype.propertyIsEnumerable,Pl=(c,r,i)=>r in c?vE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,to=(c,r)=>{for(var i in r||(r={}))_E.call(r,i)&&Pl(c,i,r[i]);if(Sl)for(var i of Sl(r))bE.call(r,i)&&Pl(c,i,r[i]);return c},EE=(c,r)=>mE(c,wE(r));function Ar(c,r,i){let n;const o=pc(c);return r.rpcMap&&(n=r.rpcMap[o]),n||(n=`${yE}?chainId=eip155:${o}&projectId=${i}`),n}function pc(c){return c.includes("eip155")?Number(c.split(":")[1]):Number(c)}function xf(c){return c.map(r=>`${r.split(":")[0]}:${r.split(":")[1]}`)}function IE(c,r){const i=Object.keys(r.namespaces).filter(o=>o.includes(c));if(!i.length)return[];const n=[];return i.forEach(o=>{const l=r.namespaces[o].accounts;n.push(...l)}),n}function xE(c={},r={}){const i=Al(c),n=Al(r);return fc.exports.merge(i,n)}function Al(c){var r,i,n,o;const l={};if(!so(c))return l;for(const[d,v]of Object.entries(c)){const b=ql(d)?[d]:v.chains,m=v.methods||[],S=v.events||[],O=v.rpcMap||{},F=no(d);l[F]=EE(to(to({},l[F]),v),{chains:ka(b,(r=l[F])==null?void 0:r.chains),methods:ka(m,(i=l[F])==null?void 0:i.methods),events:ka(S,(n=l[F])==null?void 0:n.events),rpcMap:to(to({},O),(o=l[F])==null?void 0:o.rpcMap)})}return l}function SE(c){return c.includes(":")?c.split(":")[2]:c}function PE(c){const r={};for(const[i,n]of Object.entries(c)){const o=n.methods||[],l=n.events||[],d=n.accounts||[],v=ql(i)?[i]:n.chains?n.chains:xf(n.accounts);r[i]={chains:v,methods:o,events:l,accounts:d}}return r}const Sf={},It=c=>Sf[c],ic=(c,r)=>{Sf[c]=r};class AE{constructor(r){this.name="polkadot",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class CE{constructor(r){this.name="eip155",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(r){switch(r.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(r);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(r.request.method)?await this.client.request(r):this.getHttpProvider().request(r.request)}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}setDefaultChain(r,i){const n=pc(r);if(!this.httpProviders[n]){const o=i||Ar(`${this.name}:${n}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${n}`);this.setHttpProvider(n,o)}this.chainId=n,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${n}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}createHttpProvider(r,i){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;const o=pc(i);r[o]=this.createHttpProvider(o,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const r=this.chainId,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}async handleSwitchChain(r){var i,n;let o=r.request.params?(i=r.request.params[0])==null?void 0:i.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const l=parseInt(o,16);if(this.isChainApproved(l))this.setDefaultChain(`${l}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:r.topic,request:{method:r.request.method,params:[{chainId:o}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${l}`);else throw new Error(`Failed to switch to chain 'eip155:${l}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(r){return this.namespace.chains.includes(`${this.name}:${r}`)}}class OE{constructor(r){this.name="solana",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class RE{constructor(r){this.name="cosmos",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class TE{constructor(r){this.name="cip34",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||this.getCardanoRPCUrl(r);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{const n=this.getCardanoRPCUrl(i);r[i]=this.createHttpProvider(i,n)}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}getCardanoRPCUrl(r){const i=this.namespace.rpcMap;if(i)return i[r]}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||this.getCardanoRPCUrl(r);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class NE{constructor(r){this.name="elrond",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class DE{constructor(r){this.name="multiversx",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}var FE=Object.defineProperty,LE=Object.defineProperties,$E=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,ME=Object.prototype.hasOwnProperty,jE=Object.prototype.propertyIsEnumerable,Ol=(c,r,i)=>r in c?FE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,ro=(c,r)=>{for(var i in r||(r={}))ME.call(r,i)&&Ol(c,i,r[i]);if(Cl)for(var i of Cl(r))jE.call(r,i)&&Ol(c,i,r[i]);return c},sc=(c,r)=>LE(c,$E(r));class Pc{constructor(r){this.events=new vc,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=r,this.logger=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||Il})),this.disableProviderPing=(r==null?void 0:r.disableProviderPing)||!1}static async init(r){const i=new Pc(r);return await i.initialize(),i}async request(r,i){const[n,o]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:ro({},r),chainId:`${n}:${o}`,topic:this.session.topic})}sendAsync(r,i,n){this.request(r,n).then(o=>i(null,o)).catch(o=>i(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}),await this.requestAccounts()}async disconnect(){var r;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(r=this.session)==null?void 0:r.topic,reason:tr("USER_DISCONNECTED")}),await this.cleanup()}async connect(r){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(r),await this.cleanupPendingPairings(),!r.skipPairing)return await this.pair(r.pairingTopic)}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}removeListener(r,i){this.events.removeListener(r,i)}off(r,i){this.events.off(r,i)}get isWalletConnect(){return!0}async pair(r){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:o}=await this.client.connect({pairingTopic:r,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await o().then(l=>{this.session=l,this.namespaces||(this.namespaces=PE(l.namespaces),this.persist("namespaces",this.namespaces))}).catch(l=>{if(l.message!==Ef)throw l;i++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(r,i){try{if(!this.session)return;const[n,o]=this.validateChain(r);this.getProvider(n).setDefaultChain(o,i)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(r={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(ps(i)){for(const n of i)r.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const r=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[r]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await uE.init({logger:this.providerOpts.logger||Il,relayUrl:this.providerOpts.relayUrl||pE,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,name:this.providerOpts.name}),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 r=[...new Set(Object.keys(this.session.namespaces).map(i=>no(i)))];ic("client",this.client),ic("events",this.events),ic("disableProviderPing",this.disableProviderPing),r.forEach(i=>{if(!this.session)return;const n=IE(i,this.session),o=xf(n),l=xE(this.namespaces,this.optionalNamespaces),d=sc(ro({},l[i]),{accounts:n,chains:o});switch(i){case"eip155":this.rpcProviders[i]=new CE({namespace:d});break;case"solana":this.rpcProviders[i]=new OE({namespace:d});break;case"cosmos":this.rpcProviders[i]=new RE({namespace:d});break;case"polkadot":this.rpcProviders[i]=new AE({namespace:d});break;case"cip34":this.rpcProviders[i]=new TE({namespace:d});break;case"elrond":this.rpcProviders[i]=new NE({namespace:d});break;case"multiversx":this.rpcProviders[i]=new DE({namespace:d});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",r=>{this.events.emit("session_ping",r)}),this.client.on("session_event",r=>{const{params:i}=r,{event:n}=i;if(n.name==="accountsChanged"){const o=n.data;o&&ps(o)&&this.events.emit("accountsChanged",o.map(SE))}else n.name==="chainChanged"?this.onChainChanged(i.chainId):this.events.emit(n.name,n.data);this.events.emit("session_event",r)}),this.client.on("session_update",({topic:r,params:i})=>{var n;const{namespaces:o}=i,l=(n=this.client)==null?void 0:n.session.get(r);this.session=sc(ro({},l),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:r,params:i})}),this.client.on("session_delete",async r=>{await this.cleanup(),this.events.emit("session_delete",r),this.events.emit("disconnect",sc(ro({},tr("USER_DISCONNECTED")),{data:r.topic}))}),this.on(Ii.DEFAULT_CHAIN_CHANGED,r=>{this.onChainChanged(r,!0)})}getProvider(r){if(!this.rpcProviders[r])throw new Error(`Provider not found: ${r}`);return this.rpcProviders[r]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(r=>{var i;this.getProvider(r).updateNamespace((i=this.session)==null?void 0:i.namespaces[r])})}setNamespaces(r){const{namespaces:i,optionalNamespaces:n,sessionProperties:o}=r;i&&Object.keys(i).length&&(this.namespaces=i),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=o,this.persist("namespaces",i),this.persist("optionalNamespaces",n)}validateChain(r){const[i,n]=(r==null?void 0:r.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[i,n];if(i&&!Object.keys(this.namespaces||{}).map(d=>no(d)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&n)return[i,n];const o=no(Object.keys(this.namespaces)[0]),l=this.rpcProviders[o].getDefaultChain();return[o,l]}async requestAccounts(){const[r]=this.validateChain();return await this.getProvider(r).requestAccounts()}onChainChanged(r,i=!1){var n;if(!this.namespaces)return;const[o,l]=this.validateChain(r);i||this.getProvider(o).setDefaultChain(l),((n=this.namespaces[o])!=null?n:this.namespaces[`${o}:${l}`]).defaultChain=l,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",l)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(r,i){this.client.core.storage.setItem(`${xl}/${r}`,i)}async getFromStore(r){return await this.client.core.storage.getItem(`${xl}/${r}`)}}const zE=Pc,UE="wc",qE="ethereum_provider",BE=`${UE}@2:${qE}:`,HE="https://rpc.walletconnect.com/v1/",dc=["eth_sendTransaction","personal_sign"],kE=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],gc=["chainChanged","accountsChanged"],KE=["message","disconnect","connect"];var VE=Object.defineProperty,GE=Object.defineProperties,WE=Object.getOwnPropertyDescriptors,Rl=Object.getOwnPropertySymbols,JE=Object.prototype.hasOwnProperty,YE=Object.prototype.propertyIsEnumerable,Tl=(c,r,i)=>r in c?VE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Bs=(c,r)=>{for(var i in r||(r={}))JE.call(r,i)&&Tl(c,i,r[i]);if(Rl)for(var i of Rl(r))YE.call(r,i)&&Tl(c,i,r[i]);return c},Nl=(c,r)=>GE(c,WE(r));function lo(c){return Number(c[0].split(":")[1])}function nc(c){return`0x${c.toString(16)}`}function XE(c){const{chains:r,optionalChains:i,methods:n,optionalMethods:o,events:l,optionalEvents:d,rpcMap:v}=c;if(!ps(r))throw new Error("Invalid chains");const b={chains:r,methods:n||dc,events:l||gc,rpcMap:Bs({},r.length?{[lo(r)]:v[lo(r)]}:{})},m=l==null?void 0:l.filter(z=>!gc.includes(z)),S=n==null?void 0:n.filter(z=>!dc.includes(z));if(!i&&!d&&!o&&!(m!=null&&m.length)&&!(S!=null&&S.length))return{required:r.length?b:void 0};const O=(m==null?void 0:m.length)&&(S==null?void 0:S.length)||!i,F={chains:[...new Set(O?b.chains.concat(i||[]):i)],methods:[...new Set(b.methods.concat(o!=null&&o.length?o:kE))],events:[...new Set(b.events.concat(d||KE))],rpcMap:v};return{required:r.length?b:void 0,optional:i.length?F:void 0}}class Ac{constructor(){this.events=new Cr.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=BE,this.on=(r,i)=>(this.events.on(r,i),this),this.once=(r,i)=>(this.events.once(r,i),this),this.removeListener=(r,i)=>(this.events.removeListener(r,i),this),this.off=(r,i)=>(this.events.off(r,i),this),this.parseAccount=r=>this.isCompatibleChainId(r)?this.parseAccountId(r).address:r,this.signer={},this.rpc={}}static async init(r){const i=new Ac;return await i.initialize(r),i}async request(r){return await this.signer.request(r,this.formatChainId(this.chainId))}sendAsync(r,i){this.signer.sendAsync(r,i,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(r);const{required:i,optional:n}=XE(this.rpc);try{const o=await new Promise(async(d,v)=>{var b;this.rpc.showQrModal&&((b=this.modal)==null||b.subscribeModal(m=>{!m.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),v(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Nl(Bs({namespaces:Bs({},i&&{[this.namespace]:i})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:r==null?void 0:r.pairingTopic})).then(m=>{d(m)}).catch(m=>{v(new Error(m.message))})});if(!o)return;this.setChainIds(this.rpc.chains);const l=qm(o.namespaces,[this.namespace]);this.setAccounts(l),this.events.emit("connect",{chainId:nc(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",r=>{const{params:i}=r,{event:n}=i;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",r)}),this.signer.on("chainChanged",r=>{const i=parseInt(r);this.chainId=i,this.events.emit("chainChanged",nc(this.chainId)),this.persist()}),this.signer.on("session_update",r=>{this.events.emit("session_update",r)}),this.signer.on("session_delete",r=>{this.reset(),this.events.emit("session_delete",r),this.events.emit("disconnect",Nl(Bs({},tr("USER_DISCONNECTED")),{data:r.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",r=>{var i,n;this.rpc.showQrModal&&((i=this.modal)==null||i.closeModal(),(n=this.modal)==null||n.openModal({uri:r})),this.events.emit("display_uri",r)})}switchEthereumChain(r){this.request({method:"wallet_switchEthereumChain",params:[{chainId:r.toString(16)}]})}isCompatibleChainId(r){return typeof r=="string"?r.startsWith(`${this.namespace}:`):!1}formatChainId(r){return`${this.namespace}:${r}`}parseChainId(r){return Number(r.split(":")[1])}setChainIds(r){const i=r.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));i.length&&(this.chainId=i[0],this.events.emit("chainChanged",nc(this.chainId)),this.persist())}setChainId(r){if(this.isCompatibleChainId(r)){const i=this.parseChainId(r);this.chainId=i,this.switchEthereumChain(i)}}parseAccountId(r){const[i,n,o]=r.split(":");return{chainId:`${i}:${n}`,address:o}}setAccounts(r){this.accounts=r.filter(i=>this.parseChainId(this.parseAccountId(i).chainId)===this.chainId).map(i=>this.parseAccountId(i).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(r){var i,n;const o=(i=r==null?void 0:r.chains)!=null?i:[],l=(n=r==null?void 0:r.optionalChains)!=null?n:[],d=o.concat(l);if(!d.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const v=o.length?(r==null?void 0:r.methods)||dc:[],b=o.length?(r==null?void 0:r.events)||gc:[],m=(r==null?void 0:r.optionalMethods)||[],S=(r==null?void 0:r.optionalEvents)||[],O=(r==null?void 0:r.rpcMap)||this.buildRpcMap(d,r.projectId),F=(r==null?void 0:r.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(z=>this.formatChainId(z)),optionalChains:l.map(z=>this.formatChainId(z)),methods:v,events:b,optionalMethods:m,optionalEvents:S,rpcMap:O,showQrModal:!!(r!=null&&r.showQrModal),qrModalOptions:F,projectId:r.projectId,metadata:r.metadata}}buildRpcMap(r,i){const n={};return r.forEach(o=>{n[o]=this.getRpcUrl(o,i)}),n}async initialize(r){if(this.rpc=this.getRpcConfig(r),this.chainId=this.rpc.chains.length?lo(this.rpc.chains):lo(this.rpc.optionalChains),this.signer=await zE.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:r.disableProviderPing,relayUrl:r.relayUrl,storageOptions:r.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;try{const{WalletConnectModal:n}=await Bm(()=>import("./index-e4b650d6.js").then(o=>o.a),["./index-e4b650d6.js","./index-da732aeb.js","./index-f4824932.css","./index-cc134824.js"],import.meta.url);i=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(i)try{this.modal=new i(Bs({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(r){if(!r)return;const{chains:i,optionalChains:n,rpcMap:o}=r;i&&ps(i)&&(this.rpc.chains=i.map(l=>this.formatChainId(l)),i.forEach(l=>{this.rpc.rpcMap[l]=(o==null?void 0:o[l])||this.getRpcUrl(l)})),n&&ps(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(l=>this.formatChainId(l)),n.forEach(l=>{this.rpc.rpcMap[l]=(o==null?void 0:o[l])||this.getRpcUrl(l)}))}getRpcUrl(r,i){var n;return((n=this.rpc.rpcMap)==null?void 0:n[r])||`${HE}?chainId=eip155:${r}&projectId=${i||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const r=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),i=this.session.namespaces[`${this.namespace}:${r}`]?this.session.namespaces[`${this.namespace}:${r}`]:this.session.namespaces[this.namespace];this.setChainIds(r?[this.formatChainId(r)]:i==null?void 0:i.accounts),this.setAccounts(i==null?void 0:i.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(r){return typeof r=="string"||r instanceof String?[this.parseAccount(r)]:r.map(i=>this.parseAccount(i))}}const lI=Ac;export{lI as EthereumProvider,KE as OPTIONAL_EVENTS,kE as OPTIONAL_METHODS,gc as REQUIRED_EVENTS,dc as REQUIRED_METHODS,Ac as default}; +}`;var Ee=xh(function(){return Le(p,te+"return "+H).apply(i,w)});if(Ee.source=H,Na(Ee))throw Ee;return Ee}function hv(e){return Me(e).toLowerCase()}function lv(e){return Me(e).toUpperCase()}function fv(e,t,s){if(e=Me(e),e&&(s||t===i))return Dc(e);if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Tr(t),p=Fc(a,h),w=Lc(a,h)+1;return vi(a,p,w).join("")}function pv(e,t,s){if(e=Me(e),e&&(s||t===i))return e.slice(0,Mc(e)+1);if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Lc(a,Tr(t))+1;return vi(a,0,h).join("")}function dv(e,t,s){if(e=Me(e),e&&(s||t===i))return e.replace(dt,"");if(!e||!(t=fr(t)))return e;var a=Tr(e),h=Fc(a,Tr(t));return vi(a,h).join("")}function gv(e,t){var s=ie,a=ue;if(ct(t)){var h="separator"in t?t.separator:h;s="length"in t?_e(t.length):s,a="omission"in t?fr(t.omission):a}e=Me(e);var p=e.length;if(Zi(e)){var w=Tr(e);p=w.length}if(s>=p)return e;var _=s-Qi(a);if(_<1)return a;var A=w?vi(w,0,_).join(""):e.slice(0,_);if(h===i)return A+a;if(w&&(_+=A.length-_),Da(h)){if(e.slice(_).search(h)){var M,j=A;for(h.global||(h=Jo(h.source,Me(yr.exec(h))+"g")),h.lastIndex=0;M=h.exec(j);)var H=M.index;A=A.slice(0,H===i?_:H)}}else if(e.indexOf(fr(h),_)!=_){var J=A.lastIndexOf(h);J>-1&&(A=A.slice(0,J))}return A+a}function yv(e){return e=Me(e),e&&ht.test(e)?e.replace(ci,Kf):e}var vv=os(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),$a=Su("toUpperCase");function Ih(e,t,s){return e=Me(e),t=s?i:t,t===i?Uf(e)?Wf(e):Tf(e):e.match(t)||[]}var xh=xe(function(e,t){try{return zt(e,i,t)}catch(s){return Na(s)?s:new ye(s)}}),mv=ei(function(e,t){return mr(t,function(s){s=kr(s),Zr(e,s,Ra(e[s],e))}),e});function wv(e){var t=e==null?0:e.length,s=se();return e=t?st(e,function(a){if(typeof a[1]!="function")throw new wr(d);return[s(a[0]),a[1]]}):[],xe(function(a){for(var h=-1;++hV)return[];var s=G,a=Vt(e,G);t=se(t),e-=G;for(var h=Vo(a,t);++s0||t<0)?new Ae(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==i&&(t=_e(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Ae.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ae.prototype.toArray=function(){return this.take(G)},Br(Ae.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),a=/^(?:head|last)$/.test(t),h=f[a?"take"+(t=="last"?"Right":""):t],p=a||/^find/.test(t);h&&(f.prototype[t]=function(){var w=this.__wrapped__,_=a?[1]:arguments,A=w instanceof Ae,M=_[0],j=A||we(w),H=function(Se){var Oe=h.apply(f,li([Se],_));return a&&J?Oe[0]:Oe};j&&s&&typeof M=="function"&&M.length!=1&&(A=j=!1);var J=this.__chain__,te=!!this.__actions__.length,oe=p&&!J,Ee=A&&!te;if(!p&&j){w=Ee?w:new Ae(this);var ae=e.apply(w,_);return ae.__actions__.push({func:kn,args:[H],thisArg:i}),new _r(ae,J)}return oe&&Ee?e.apply(this,_):(ae=this.thru(H),oe?a?ae.value()[0]:ae.value():ae)})}),mr(["pop","push","shift","sort","splice","unshift"],function(e){var t=yn[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",a=/^(?:pop|shift)$/.test(e);f.prototype[e]=function(){var h=arguments;if(a&&!this.__chain__){var p=this.value();return t.apply(we(p)?p:[],h)}return this[s](function(w){return t.apply(we(w)?w:[],h)})}}),Br(Ae.prototype,function(e,t){var s=f[t];if(s){var a=s.name+"";ze.call(is,a)||(is[a]=[]),is[a].push({name:t,func:s})}}),is[Mn(i,he).name]=[{name:"wrapper",func:i}],Ae.prototype.clone=yp,Ae.prototype.reverse=vp,Ae.prototype.value=mp,f.prototype.at=Gg,f.prototype.chain=Wg,f.prototype.commit=Jg,f.prototype.next=Yg,f.prototype.plant=Zg,f.prototype.reverse=Qg,f.prototype.toJSON=f.prototype.valueOf=f.prototype.value=ey,f.prototype.first=f.prototype.head,bs&&(f.prototype[bs]=Xg),f},es=Jf();_t?((_t.exports=es)._=es,Ge._=es):Ce._=es}).call(qs)})(fc,fc.exports);var vE=Object.defineProperty,mE=Object.defineProperties,wE=Object.getOwnPropertyDescriptors,Sl=Object.getOwnPropertySymbols,_E=Object.prototype.hasOwnProperty,bE=Object.prototype.propertyIsEnumerable,Pl=(c,r,i)=>r in c?vE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,to=(c,r)=>{for(var i in r||(r={}))_E.call(r,i)&&Pl(c,i,r[i]);if(Sl)for(var i of Sl(r))bE.call(r,i)&&Pl(c,i,r[i]);return c},EE=(c,r)=>mE(c,wE(r));function Ar(c,r,i){let n;const o=pc(c);return r.rpcMap&&(n=r.rpcMap[o]),n||(n=`${yE}?chainId=eip155:${o}&projectId=${i}`),n}function pc(c){return c.includes("eip155")?Number(c.split(":")[1]):Number(c)}function xf(c){return c.map(r=>`${r.split(":")[0]}:${r.split(":")[1]}`)}function IE(c,r){const i=Object.keys(r.namespaces).filter(o=>o.includes(c));if(!i.length)return[];const n=[];return i.forEach(o=>{const l=r.namespaces[o].accounts;n.push(...l)}),n}function xE(c={},r={}){const i=Al(c),n=Al(r);return fc.exports.merge(i,n)}function Al(c){var r,i,n,o;const l={};if(!so(c))return l;for(const[d,v]of Object.entries(c)){const b=ql(d)?[d]:v.chains,m=v.methods||[],S=v.events||[],O=v.rpcMap||{},F=no(d);l[F]=EE(to(to({},l[F]),v),{chains:ka(b,(r=l[F])==null?void 0:r.chains),methods:ka(m,(i=l[F])==null?void 0:i.methods),events:ka(S,(n=l[F])==null?void 0:n.events),rpcMap:to(to({},O),(o=l[F])==null?void 0:o.rpcMap)})}return l}function SE(c){return c.includes(":")?c.split(":")[2]:c}function PE(c){const r={};for(const[i,n]of Object.entries(c)){const o=n.methods||[],l=n.events||[],d=n.accounts||[],v=ql(i)?[i]:n.chains?n.chains:xf(n.accounts);r[i]={chains:v,methods:o,events:l,accounts:d}}return r}const Sf={},It=c=>Sf[c],ic=(c,r)=>{Sf[c]=r};class AE{constructor(r){this.name="polkadot",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class CE{constructor(r){this.name="eip155",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(r){switch(r.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(r);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(r.request.method)?await this.client.request(r):this.getHttpProvider().request(r.request)}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}setDefaultChain(r,i){const n=pc(r);if(!this.httpProviders[n]){const o=i||Ar(`${this.name}:${n}`,this.namespace,this.client.core.projectId);if(!o)throw new Error(`No RPC url provided for chainId: ${n}`);this.setHttpProvider(n,o)}this.chainId=n,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${n}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}createHttpProvider(r,i){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;const o=pc(i);r[o]=this.createHttpProvider(o,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const r=this.chainId,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}async handleSwitchChain(r){var i,n;let o=r.request.params?(i=r.request.params[0])==null?void 0:i.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const l=parseInt(o,16);if(this.isChainApproved(l))this.setDefaultChain(`${l}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:r.topic,request:{method:r.request.method,params:[{chainId:o}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${l}`);else throw new Error(`Failed to switch to chain 'eip155:${l}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(r){return this.namespace.chains.includes(`${this.name}:${r}`)}}class OE{constructor(r){this.name="solana",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class RE{constructor(r){this.name="cosmos",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class TE{constructor(r){this.name="cip34",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(this.chainId=r,!this.httpProviders[r]){const n=i||this.getCardanoRPCUrl(r);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{const n=this.getCardanoRPCUrl(i);r[i]=this.createHttpProvider(i,n)}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}getCardanoRPCUrl(r){const i=this.namespace.rpcMap;if(i)return i[r]}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||this.getCardanoRPCUrl(r);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class NE{constructor(r){this.name="elrond",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}class DE{constructor(r){this.name="multiversx",this.namespace=r.namespace,this.events=It("events"),this.client=It("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(r){this.namespace=Object.assign(this.namespace,r)}requestAccounts(){return this.getAccounts()}request(r){return this.namespace.methods.includes(r.request.method)?this.client.request(r):this.getHttpProvider().request(r.request)}setDefaultChain(r,i){if(!this.httpProviders[r]){const n=i||Ar(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,n)}this.chainId=r,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const r=this.namespace.chains[0];if(!r)throw new Error("ChainId not found");return r.split(":")[1]}getAccounts(){const r=this.namespace.accounts;return r?[...new Set(r.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const r={};return this.namespace.chains.forEach(i=>{var n;r[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[i])}),r}getHttpProvider(){const r=`${this.name}:${this.chainId}`,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${r} not found`);return i}setHttpProvider(r,i){const n=this.createHttpProvider(r,i);n&&(this.httpProviders[r]=n)}createHttpProvider(r,i){const n=i||Ar(r,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ei(new Hi(n,It("disableProviderPing")))}}var FE=Object.defineProperty,LE=Object.defineProperties,$E=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,ME=Object.prototype.hasOwnProperty,jE=Object.prototype.propertyIsEnumerable,Ol=(c,r,i)=>r in c?FE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,ro=(c,r)=>{for(var i in r||(r={}))ME.call(r,i)&&Ol(c,i,r[i]);if(Cl)for(var i of Cl(r))jE.call(r,i)&&Ol(c,i,r[i]);return c},sc=(c,r)=>LE(c,$E(r));class Pc{constructor(r){this.events=new vc,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=r,this.logger=typeof(r==null?void 0:r.logger)<"u"&&typeof(r==null?void 0:r.logger)!="string"?r.logger:Re.pino(Re.getDefaultLoggerOptions({level:(r==null?void 0:r.logger)||Il})),this.disableProviderPing=(r==null?void 0:r.disableProviderPing)||!1}static async init(r){const i=new Pc(r);return await i.initialize(),i}async request(r,i){const[n,o]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:ro({},r),chainId:`${n}:${o}`,topic:this.session.topic})}sendAsync(r,i,n){this.request(r,n).then(o=>i(null,o)).catch(o=>i(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}),await this.requestAccounts()}async disconnect(){var r;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(r=this.session)==null?void 0:r.topic,reason:tr("USER_DISCONNECTED")}),await this.cleanup()}async connect(r){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(r),await this.cleanupPendingPairings(),!r.skipPairing)return await this.pair(r.pairingTopic)}on(r,i){this.events.on(r,i)}once(r,i){this.events.once(r,i)}removeListener(r,i){this.events.removeListener(r,i)}off(r,i){this.events.off(r,i)}get isWalletConnect(){return!0}async pair(r){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:o}=await this.client.connect({pairingTopic:r,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await o().then(l=>{this.session=l,this.namespaces||(this.namespaces=PE(l.namespaces),this.persist("namespaces",this.namespaces))}).catch(l=>{if(l.message!==Ef)throw l;i++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(r,i){try{if(!this.session)return;const[n,o]=this.validateChain(r);this.getProvider(n).setDefaultChain(o,i)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(r={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(ps(i)){for(const n of i)r.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const r=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[r]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await uE.init({logger:this.providerOpts.logger||Il,relayUrl:this.providerOpts.relayUrl||pE,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,name:this.providerOpts.name}),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 r=[...new Set(Object.keys(this.session.namespaces).map(i=>no(i)))];ic("client",this.client),ic("events",this.events),ic("disableProviderPing",this.disableProviderPing),r.forEach(i=>{if(!this.session)return;const n=IE(i,this.session),o=xf(n),l=xE(this.namespaces,this.optionalNamespaces),d=sc(ro({},l[i]),{accounts:n,chains:o});switch(i){case"eip155":this.rpcProviders[i]=new CE({namespace:d});break;case"solana":this.rpcProviders[i]=new OE({namespace:d});break;case"cosmos":this.rpcProviders[i]=new RE({namespace:d});break;case"polkadot":this.rpcProviders[i]=new AE({namespace:d});break;case"cip34":this.rpcProviders[i]=new TE({namespace:d});break;case"elrond":this.rpcProviders[i]=new NE({namespace:d});break;case"multiversx":this.rpcProviders[i]=new DE({namespace:d});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",r=>{this.events.emit("session_ping",r)}),this.client.on("session_event",r=>{const{params:i}=r,{event:n}=i;if(n.name==="accountsChanged"){const o=n.data;o&&ps(o)&&this.events.emit("accountsChanged",o.map(SE))}else n.name==="chainChanged"?this.onChainChanged(i.chainId):this.events.emit(n.name,n.data);this.events.emit("session_event",r)}),this.client.on("session_update",({topic:r,params:i})=>{var n;const{namespaces:o}=i,l=(n=this.client)==null?void 0:n.session.get(r);this.session=sc(ro({},l),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:r,params:i})}),this.client.on("session_delete",async r=>{await this.cleanup(),this.events.emit("session_delete",r),this.events.emit("disconnect",sc(ro({},tr("USER_DISCONNECTED")),{data:r.topic}))}),this.on(Ii.DEFAULT_CHAIN_CHANGED,r=>{this.onChainChanged(r,!0)})}getProvider(r){if(!this.rpcProviders[r])throw new Error(`Provider not found: ${r}`);return this.rpcProviders[r]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(r=>{var i;this.getProvider(r).updateNamespace((i=this.session)==null?void 0:i.namespaces[r])})}setNamespaces(r){const{namespaces:i,optionalNamespaces:n,sessionProperties:o}=r;i&&Object.keys(i).length&&(this.namespaces=i),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=o,this.persist("namespaces",i),this.persist("optionalNamespaces",n)}validateChain(r){const[i,n]=(r==null?void 0:r.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[i,n];if(i&&!Object.keys(this.namespaces||{}).map(d=>no(d)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&n)return[i,n];const o=no(Object.keys(this.namespaces)[0]),l=this.rpcProviders[o].getDefaultChain();return[o,l]}async requestAccounts(){const[r]=this.validateChain();return await this.getProvider(r).requestAccounts()}onChainChanged(r,i=!1){var n;if(!this.namespaces)return;const[o,l]=this.validateChain(r);i||this.getProvider(o).setDefaultChain(l),((n=this.namespaces[o])!=null?n:this.namespaces[`${o}:${l}`]).defaultChain=l,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",l)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(r,i){this.client.core.storage.setItem(`${xl}/${r}`,i)}async getFromStore(r){return await this.client.core.storage.getItem(`${xl}/${r}`)}}const zE=Pc,UE="wc",qE="ethereum_provider",BE=`${UE}@2:${qE}:`,HE="https://rpc.walletconnect.com/v1/",dc=["eth_sendTransaction","personal_sign"],kE=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],gc=["chainChanged","accountsChanged"],KE=["message","disconnect","connect"];var VE=Object.defineProperty,GE=Object.defineProperties,WE=Object.getOwnPropertyDescriptors,Rl=Object.getOwnPropertySymbols,JE=Object.prototype.hasOwnProperty,YE=Object.prototype.propertyIsEnumerable,Tl=(c,r,i)=>r in c?VE(c,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[r]=i,Bs=(c,r)=>{for(var i in r||(r={}))JE.call(r,i)&&Tl(c,i,r[i]);if(Rl)for(var i of Rl(r))YE.call(r,i)&&Tl(c,i,r[i]);return c},Nl=(c,r)=>GE(c,WE(r));function lo(c){return Number(c[0].split(":")[1])}function nc(c){return`0x${c.toString(16)}`}function XE(c){const{chains:r,optionalChains:i,methods:n,optionalMethods:o,events:l,optionalEvents:d,rpcMap:v}=c;if(!ps(r))throw new Error("Invalid chains");const b={chains:r,methods:n||dc,events:l||gc,rpcMap:Bs({},r.length?{[lo(r)]:v[lo(r)]}:{})},m=l==null?void 0:l.filter(z=>!gc.includes(z)),S=n==null?void 0:n.filter(z=>!dc.includes(z));if(!i&&!d&&!o&&!(m!=null&&m.length)&&!(S!=null&&S.length))return{required:r.length?b:void 0};const O=(m==null?void 0:m.length)&&(S==null?void 0:S.length)||!i,F={chains:[...new Set(O?b.chains.concat(i||[]):i)],methods:[...new Set(b.methods.concat(o!=null&&o.length?o:kE))],events:[...new Set(b.events.concat(d||KE))],rpcMap:v};return{required:r.length?b:void 0,optional:i.length?F:void 0}}class Ac{constructor(){this.events=new Cr.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=BE,this.on=(r,i)=>(this.events.on(r,i),this),this.once=(r,i)=>(this.events.once(r,i),this),this.removeListener=(r,i)=>(this.events.removeListener(r,i),this),this.off=(r,i)=>(this.events.off(r,i),this),this.parseAccount=r=>this.isCompatibleChainId(r)?this.parseAccountId(r).address:r,this.signer={},this.rpc={}}static async init(r){const i=new Ac;return await i.initialize(r),i}async request(r){return await this.signer.request(r,this.formatChainId(this.chainId))}sendAsync(r,i){this.signer.sendAsync(r,i,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(r);const{required:i,optional:n}=XE(this.rpc);try{const o=await new Promise(async(d,v)=>{var b;this.rpc.showQrModal&&((b=this.modal)==null||b.subscribeModal(m=>{!m.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),v(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Nl(Bs({namespaces:Bs({},i&&{[this.namespace]:i})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:r==null?void 0:r.pairingTopic})).then(m=>{d(m)}).catch(m=>{v(new Error(m.message))})});if(!o)return;this.setChainIds(this.rpc.chains);const l=qm(o.namespaces,[this.namespace]);this.setAccounts(l),this.events.emit("connect",{chainId:nc(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",r=>{const{params:i}=r,{event:n}=i;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",r)}),this.signer.on("chainChanged",r=>{const i=parseInt(r);this.chainId=i,this.events.emit("chainChanged",nc(this.chainId)),this.persist()}),this.signer.on("session_update",r=>{this.events.emit("session_update",r)}),this.signer.on("session_delete",r=>{this.reset(),this.events.emit("session_delete",r),this.events.emit("disconnect",Nl(Bs({},tr("USER_DISCONNECTED")),{data:r.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",r=>{var i,n;this.rpc.showQrModal&&((i=this.modal)==null||i.closeModal(),(n=this.modal)==null||n.openModal({uri:r})),this.events.emit("display_uri",r)})}switchEthereumChain(r){this.request({method:"wallet_switchEthereumChain",params:[{chainId:r.toString(16)}]})}isCompatibleChainId(r){return typeof r=="string"?r.startsWith(`${this.namespace}:`):!1}formatChainId(r){return`${this.namespace}:${r}`}parseChainId(r){return Number(r.split(":")[1])}setChainIds(r){const i=r.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));i.length&&(this.chainId=i[0],this.events.emit("chainChanged",nc(this.chainId)),this.persist())}setChainId(r){if(this.isCompatibleChainId(r)){const i=this.parseChainId(r);this.chainId=i,this.switchEthereumChain(i)}}parseAccountId(r){const[i,n,o]=r.split(":");return{chainId:`${i}:${n}`,address:o}}setAccounts(r){this.accounts=r.filter(i=>this.parseChainId(this.parseAccountId(i).chainId)===this.chainId).map(i=>this.parseAccountId(i).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(r){var i,n;const o=(i=r==null?void 0:r.chains)!=null?i:[],l=(n=r==null?void 0:r.optionalChains)!=null?n:[],d=o.concat(l);if(!d.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const v=o.length?(r==null?void 0:r.methods)||dc:[],b=o.length?(r==null?void 0:r.events)||gc:[],m=(r==null?void 0:r.optionalMethods)||[],S=(r==null?void 0:r.optionalEvents)||[],O=(r==null?void 0:r.rpcMap)||this.buildRpcMap(d,r.projectId),F=(r==null?void 0:r.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(z=>this.formatChainId(z)),optionalChains:l.map(z=>this.formatChainId(z)),methods:v,events:b,optionalMethods:m,optionalEvents:S,rpcMap:O,showQrModal:!!(r!=null&&r.showQrModal),qrModalOptions:F,projectId:r.projectId,metadata:r.metadata}}buildRpcMap(r,i){const n={};return r.forEach(o=>{n[o]=this.getRpcUrl(o,i)}),n}async initialize(r){if(this.rpc=this.getRpcConfig(r),this.chainId=this.rpc.chains.length?lo(this.rpc.chains):lo(this.rpc.optionalChains),this.signer=await zE.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:r.disableProviderPing,relayUrl:r.relayUrl,storageOptions:r.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;try{const{WalletConnectModal:n}=await Bm(()=>import("./index-f6657797.js").then(o=>o.a),["./index-f6657797.js","./index-1b4dc470.js","./index-f4824932.css","./index-cc134824.js"],import.meta.url);i=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(i)try{this.modal=new i(Bs({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(r){if(!r)return;const{chains:i,optionalChains:n,rpcMap:o}=r;i&&ps(i)&&(this.rpc.chains=i.map(l=>this.formatChainId(l)),i.forEach(l=>{this.rpc.rpcMap[l]=(o==null?void 0:o[l])||this.getRpcUrl(l)})),n&&ps(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(l=>this.formatChainId(l)),n.forEach(l=>{this.rpc.rpcMap[l]=(o==null?void 0:o[l])||this.getRpcUrl(l)}))}getRpcUrl(r,i){var n;return((n=this.rpc.rpcMap)==null?void 0:n[r])||`${HE}?chainId=eip155:${r}&projectId=${i||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const r=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),i=this.session.namespaces[`${this.namespace}:${r}`]?this.session.namespaces[`${this.namespace}:${r}`]:this.session.namespaces[this.namespace];this.setChainIds(r?[this.formatChainId(r)]:i==null?void 0:i.accounts),this.setAccounts(i==null?void 0:i.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(r){return typeof r=="string"||r instanceof String?[this.parseAccount(r)]:r.map(i=>this.parseAccount(i))}}const lI=Ac;export{lI as EthereumProvider,KE as OPTIONAL_EVENTS,kE as OPTIONAL_METHODS,gc as REQUIRED_EVENTS,dc as REQUIRED_METHODS,Ac as default}; diff --git a/index.html b/index.html index 43262312..ed8caa27 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Sequence Kit Demo - +