@dcl/jump-site 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{auto-track-Cz-2K5Tt.js → auto-track-TsCb-0MA.js} +1 -1
- package/assets/{fortmatic-CGr3NA6k.js → fortmatic-IP1o1Mzm.js} +1 -1
- package/assets/{index-D1fX15Wb.js → index--zP1OIJk.js} +1 -1
- package/assets/{index-DY3apvom.js → index-BCrm-4fr.js} +2 -2
- package/assets/{index-CtePr37c.js → index-B_jIuiMf.js} +1 -1
- package/assets/{index-D8YwXqlJ.js → index-CLkWi2wn.js} +1 -1
- package/assets/{index-Bf-SmgZL.js → index-CLxsXT_F.js} +2 -2
- package/assets/{index-BJ40lMs9.js → index-C_ykjjYp.js} +1 -1
- package/assets/{index-C1oiUXlJ.js → index-DvJAAp_Q.js} +5 -5
- package/assets/{index-Cn4dnslz.js → index-QJ6zPsSV.js} +1 -1
- package/assets/{index.es-CnL8cHJw.js → index.es-DIoBVM4H.js} +4 -4
- package/assets/{index.umd-DlzixnUW.js → index.umd-ByZACMUG.js} +1 -1
- package/assets/{secp256k1-DHC-EBD6.js → secp256k1-CIC_BmhQ.js} +1 -1
- package/index.html +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secp256k1-
|
|
2
|
-
import{h as By,g as b6,j as Jc,f as pn}from"./index-C1oiUXlJ.js";var U0={exports:{}},yo=typeof Reflect=="object"?Reflect:null,V1=yo&&typeof yo.apply=="function"?yo.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Uu;yo&&typeof yo.ownKeys=="function"?Uu=yo.ownKeys:Object.getOwnPropertySymbols?Uu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Uu=function(e){return Object.getOwnPropertyNames(e)};function C6(t){console&&console.warn&&console.warn(t)}var My=Number.isNaN||function(e){return e!==e};function je(){je.init.call(this)}U0.exports=je;U0.exports.once=I6;je.EventEmitter=je;je.prototype._events=void 0;je.prototype._eventsCount=0;je.prototype._maxListeners=void 0;var K1=10;function Ph(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(je,"defaultMaxListeners",{enumerable:!0,get:function(){return K1},set:function(t){if(typeof t!="number"||t<0||My(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");K1=t}});je.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};je.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||My(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Uy(t){return t._maxListeners===void 0?je.defaultMaxListeners:t._maxListeners}je.prototype.getMaxListeners=function(){return Uy(this)};je.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")V1(c,this,r);else for(var l=c.length,u=qy(c,l),n=0;n<l;++n)V1(u[n],this,r);return!0};function jy(t,e,r,n){var i,s,o;if(Ph(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=Uy(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,C6(a)}return t}je.prototype.addListener=function(e,r){return jy(this,e,r,!1)};je.prototype.on=je.prototype.addListener;je.prototype.prependListener=function(e,r){return jy(this,e,r,!0)};function E6(){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 zy(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=E6.bind(n);return i.listener=r,n.wrapFn=i,i}je.prototype.once=function(e,r){return Ph(r),this.on(e,zy(this,e,r)),this};je.prototype.prependOnceListener=function(e,r){return Ph(r),this.prependListener(e,zy(this,e,r)),this};je.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Ph(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():x6(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};je.prototype.off=je.prototype.removeListener;je.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Fy(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?_6(i):qy(i,i.length)}je.prototype.listeners=function(e){return Fy(this,e,!0)};je.prototype.rawListeners=function(e){return Fy(this,e,!1)};je.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Hy.call(t,e)};je.prototype.listenerCount=Hy;function Hy(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Uu(this._events):[]};function qy(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function x6(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function _6(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function I6(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Wy(t,e,s,{once:!0}),e!=="error"&&A6(t,i,{once:!0})})}function A6(t,e,r){typeof t.on=="function"&&Wy(t,"error",e,r)}function Wy(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var $6=U0.exports,G1=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},S6=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),N6=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),O6=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),P6=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),k6=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),T6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,R6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Z1=3,L6=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",T6]],Y1=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function D6(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new k6:typeof navigator<"u"?M6(navigator.userAgent):j6()}function B6(t){return t!==""&&L6.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 M6(t){var e=B6(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new P6;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Z1&&(i=G1(G1([],i,!0),z6(Z1-i.length),!0)):i=[];var s=i.join("."),o=U6(t),a=R6.exec(t);return a&&a[1]?new O6(r,s,o,a[1]):new S6(r,s,o)}function U6(t){for(var e=0,r=Y1.length;e<r;e++){var n=Y1[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function j6(){var t=typeof process<"u"&&process.version;return t?new N6(process.version.slice(1)):null}function z6(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var K={};/*! *****************************************************************************
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secp256k1-CIC_BmhQ.js","assets/index-DvJAAp_Q.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{h as By,g as b6,j as Jc,f as pn}from"./index-DvJAAp_Q.js";var U0={exports:{}},yo=typeof Reflect=="object"?Reflect:null,V1=yo&&typeof yo.apply=="function"?yo.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Uu;yo&&typeof yo.ownKeys=="function"?Uu=yo.ownKeys:Object.getOwnPropertySymbols?Uu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Uu=function(e){return Object.getOwnPropertyNames(e)};function C6(t){console&&console.warn&&console.warn(t)}var My=Number.isNaN||function(e){return e!==e};function je(){je.init.call(this)}U0.exports=je;U0.exports.once=I6;je.EventEmitter=je;je.prototype._events=void 0;je.prototype._eventsCount=0;je.prototype._maxListeners=void 0;var K1=10;function Ph(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(je,"defaultMaxListeners",{enumerable:!0,get:function(){return K1},set:function(t){if(typeof t!="number"||t<0||My(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");K1=t}});je.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};je.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||My(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Uy(t){return t._maxListeners===void 0?je.defaultMaxListeners:t._maxListeners}je.prototype.getMaxListeners=function(){return Uy(this)};je.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")V1(c,this,r);else for(var l=c.length,u=qy(c,l),n=0;n<l;++n)V1(u[n],this,r);return!0};function jy(t,e,r,n){var i,s,o;if(Ph(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=Uy(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,C6(a)}return t}je.prototype.addListener=function(e,r){return jy(this,e,r,!1)};je.prototype.on=je.prototype.addListener;je.prototype.prependListener=function(e,r){return jy(this,e,r,!0)};function E6(){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 zy(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=E6.bind(n);return i.listener=r,n.wrapFn=i,i}je.prototype.once=function(e,r){return Ph(r),this.on(e,zy(this,e,r)),this};je.prototype.prependOnceListener=function(e,r){return Ph(r),this.prependListener(e,zy(this,e,r)),this};je.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Ph(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():x6(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};je.prototype.off=je.prototype.removeListener;je.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Fy(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?_6(i):qy(i,i.length)}je.prototype.listeners=function(e){return Fy(this,e,!0)};je.prototype.rawListeners=function(e){return Fy(this,e,!1)};je.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Hy.call(t,e)};je.prototype.listenerCount=Hy;function Hy(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Uu(this._events):[]};function qy(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function x6(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function _6(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function I6(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Wy(t,e,s,{once:!0}),e!=="error"&&A6(t,i,{once:!0})})}function A6(t,e,r){typeof t.on=="function"&&Wy(t,"error",e,r)}function Wy(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var $6=U0.exports,G1=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},S6=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),N6=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),O6=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),P6=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),k6=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),T6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,R6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Z1=3,L6=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",T6]],Y1=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function D6(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new k6:typeof navigator<"u"?M6(navigator.userAgent):j6()}function B6(t){return t!==""&&L6.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 M6(t){var e=B6(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new P6;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Z1&&(i=G1(G1([],i,!0),z6(Z1-i.length),!0)):i=[];var s=i.join("."),o=U6(t),a=R6.exec(t);return a&&a[1]?new O6(r,s,o,a[1]):new S6(r,s,o)}function U6(t){for(var e=0,r=Y1.length;e<r;e++){var n=Y1[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function j6(){var t=typeof process<"u"&&process.version;return t?new N6(process.version.slice(1)):null}function z6(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var K={};/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -13,7 +13,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */var Sf=function(t,e){return Sf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Sf(t,e)};function F6(t,e){Sf(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Nf=function(){return Nf=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Nf.apply(this,arguments)};function H6(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function q6(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function W6(t,e){return function(r,n){e(r,n,t)}}function V6(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function K6(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(u){try{l(n.next(u))}catch(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(t,e||[])).next())})}function G6(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Z6(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Y6(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Of(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vy(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function J6(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Vy(arguments[e]));return t}function X6(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function dc(t){return this instanceof dc?(this.v=t,this):new dc(t)}function Q6(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(d){n[d]&&(i[d]=function(p){return new Promise(function(f,g){s.push([d,p,f,g])>1||a(d,p)})})}function a(d,p){try{c(n[d](p))}catch(f){h(s[0][3],f)}}function c(d){d.value instanceof dc?Promise.resolve(d.value.v).then(l,u):h(s[0][2],d)}function l(d){a("next",d)}function u(d){a("throw",d)}function h(d,p){d(p),s.shift(),s.length&&a(s[0][0],s[0][1])}}function e8(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:dc(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function t8(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Of=="function"?Of(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}function r8(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function n8(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function i8(t){return t&&t.__esModule?t:{default:t}}function s8(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function o8(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const a8=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Nf},__asyncDelegator:e8,__asyncGenerator:Q6,__asyncValues:t8,__await:dc,__awaiter:K6,__classPrivateFieldGet:s8,__classPrivateFieldSet:o8,__createBinding:Z6,__decorate:q6,__exportStar:Y6,__extends:F6,__generator:G6,__importDefault:i8,__importStar:n8,__makeTemplateObject:r8,__metadata:V6,__param:W6,__read:Vy,__rest:H6,__spread:J6,__spreadArrays:X6,__values:Of},Symbol.toStringTag,{value:"Module"})),kh=By(a8);var Cd={},aa={},J1;function c8(){if(J1)return aa;J1=1,Object.defineProperty(aa,"__esModule",{value:!0}),aa.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return aa.delay=t,aa}var Ai={},Ed={},$i={},X1;function l8(){return X1||(X1=1,Object.defineProperty($i,"__esModule",{value:!0}),$i.ONE_THOUSAND=$i.ONE_HUNDRED=void 0,$i.ONE_HUNDRED=100,$i.ONE_THOUSAND=1e3),$i}var xd={},Q1;function u8(){return Q1||(Q1=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(xd)),xd}var eg;function Ky(){return eg||(eg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=kh;e.__exportStar(l8(),t),e.__exportStar(u8(),t)}(Ed)),Ed}var tg;function h8(){if(tg)return Ai;tg=1,Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.fromMiliseconds=Ai.toMiliseconds=void 0;const t=Ky();function e(n){return n*t.ONE_THOUSAND}Ai.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Ai.fromMiliseconds=r,Ai}var rg;function d8(){return rg||(rg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=kh;e.__exportStar(c8(),t),e.__exportStar(h8(),t)}(Cd)),Cd}var Os={},ng;function p8(){if(ng)return Os;ng=1,Object.defineProperty(Os,"__esModule",{value:!0}),Os.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return Os.Watch=t,Os.default=t,Os}var _d={},ca={},ig;function f8(){if(ig)return ca;ig=1,Object.defineProperty(ca,"__esModule",{value:!0}),ca.IWatch=void 0;class t{}return ca.IWatch=t,ca}var sg;function g8(){return sg||(sg=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),kh.__exportStar(f8(),t)}(_d)),_d}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=kh;e.__exportStar(d8(),t),e.__exportStar(p8(),t),e.__exportStar(g8(),t),e.__exportStar(Ky(),t)})(K);var rt={};Object.defineProperty(rt,"__esModule",{value:!0});rt.getLocalStorage=rt.getLocalStorageOrThrow=rt.getCrypto=rt.getCryptoOrThrow=Gy=rt.getLocation=rt.getLocationOrThrow=j0=rt.getNavigator=rt.getNavigatorOrThrow=Xc=rt.getDocument=rt.getDocumentOrThrow=rt.getFromWindowOrThrow=rt.getFromWindow=void 0;function xs(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}rt.getFromWindow=xs;function Zo(t){const e=xs(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}rt.getFromWindowOrThrow=Zo;function w8(){return Zo("document")}rt.getDocumentOrThrow=w8;function m8(){return xs("document")}var Xc=rt.getDocument=m8;function v8(){return Zo("navigator")}rt.getNavigatorOrThrow=v8;function y8(){return xs("navigator")}var j0=rt.getNavigator=y8;function b8(){return Zo("location")}rt.getLocationOrThrow=b8;function C8(){return xs("location")}var Gy=rt.getLocation=C8;function E8(){return Zo("crypto")}rt.getCryptoOrThrow=E8;function x8(){return xs("crypto")}rt.getCrypto=x8;function _8(){return Zo("localStorage")}rt.getLocalStorageOrThrow=_8;function I8(){return xs("localStorage")}rt.getLocalStorage=I8;var z0={};Object.defineProperty(z0,"__esModule",{value:!0});var Zy=z0.getWindowMetadata=void 0;const og=rt;function A8(){let t,e;try{t=og.getDocumentOrThrow(),e=og.getLocationOrThrow()}catch{return null}function r(){const h=t.getElementsByTagName("link"),d=[];for(let p=0;p<h.length;p++){const f=h[p],g=f.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const w=f.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(w.indexOf("/")===0)v+=w;else{const b=e.pathname.split("/");b.pop();const C=b.join("/");v+=C+"/"+w}d.push(v)}else if(w.indexOf("//")===0){const v=e.protocol+w;d.push(v)}else d.push(w)}}return d}function n(...h){const d=t.getElementsByTagName("meta");for(let p=0;p<d.length;p++){const f=d[p],g=["itemprop","property","name"].map(w=>f.getAttribute(w)).filter(w=>w?h.includes(w):!1);if(g.length&&g){const w=f.getAttribute("content");if(w)return w}}return""}function i(){let h=n("name","og:site_name","og:title","twitter:title");return h||(h=t.title),h}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),a=s(),c=e.origin,l=r();return{description:a,url:c,icons:l,name:o}}Zy=z0.getWindowMetadata=A8;function pc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ag(t){return pc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Yy="2.23.2";let la={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${Yy}`};class ps extends Error{constructor(e,r={}){var a;const n=(()=>{var c;return r.cause instanceof ps?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),i=r.cause instanceof ps&&r.cause.docsPath||r.docsPath,s=(a=la.getDocsUrl)==null?void 0:a.call(la,{...r,docsPath:i}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...la.version?[`Version: ${la.version}`]:[]].join(`
|
|
16
|
-
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=Yy}walk(e){return Jy(this,e)}}function Jy(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Jy(t.cause,e):e?null:t}class Xy extends ps{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function Yo(t,{dir:e,size:r=32}={}){return typeof t=="string"?$8(t,{dir:e,size:r}):S8(t,{dir:e,size:r})}function $8(t,{dir:e,size:r=32}={}){if(r===null)return t;const n=t.replace("0x","");if(n.length>r*2)throw new Xy({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function S8(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new Xy({size:t.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const s=e==="right";n[s?i:r-i-1]=t[s?i:t.length-i-1]}return n}class N8 extends ps{constructor({max:e,min:r,signed:n,size:i,value:s}){super(`Number "${s}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class O8 extends ps{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Jo(t,{size:e}){if(ag(t)>e)throw new O8({givenSize:ag(t),maxSize:e})}function Pf(t,e={}){const{signed:r}=e;e.size&&Jo(t,{size:e.size});const n=BigInt(t);if(!r)return n;const i=(t.length-2)/2,s=(1n<<BigInt(i)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function P8(t,e={}){return Number(Pf(t,e))}const k8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function kf(t,e={}){return typeof t=="number"||typeof t=="bigint"?eb(t,e):typeof t=="string"?L8(t,e):typeof t=="boolean"?T8(t,e):Qy(t,e)}function T8(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{size:e.size})):r}function Qy(t,e={}){let r="";for(let i=0;i<t.length;i++)r+=k8[t[i]];const n=`0x${r}`;return typeof e.size=="number"?(Jo(n,{size:e.size}),Yo(n,{dir:"right",size:e.size})):n}function eb(t,e={}){const{signed:r,size:n}=e,i=BigInt(t);let s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&i>s||i<o){const c=typeof t=="bigint"?"n":"";throw new N8({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:n,value:`${t}${c}`})}const a=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?Yo(a,{size:n}):a}const R8=new TextEncoder;function L8(t,e={}){const r=R8.encode(t);return Qy(r,e)}const D8=new TextEncoder;function B8(t,e={}){return typeof t=="number"||typeof t=="bigint"?U8(t,e):typeof t=="boolean"?M8(t,e):pc(t)?tb(t,e):rb(t,e)}function M8(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{size:e.size})):r}const Cn={zero:48,nine:57,A:65,F:70,a:97,f:102};function cg(t){if(t>=Cn.zero&&t<=Cn.nine)return t-Cn.zero;if(t>=Cn.A&&t<=Cn.F)return t-(Cn.A-10);if(t>=Cn.a&&t<=Cn.f)return t-(Cn.a-10)}function tb(t,e={}){let r=t;e.size&&(Jo(r,{size:e.size}),r=Yo(r,{dir:"right",size:e.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,s=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=cg(n.charCodeAt(a++)),l=cg(n.charCodeAt(a++));if(c===void 0||l===void 0)throw new ps(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[o]=c*16+l}return s}function U8(t,e){const r=eb(t,e);return tb(r)}function rb(t,e={}){const r=D8.encode(t);return typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{dir:"right",size:e.size})):r}function ih(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function j8(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Th(t,...e){if(!j8(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function zV(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ih(t.outputLen),ih(t.blockLen)}function lg(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function z8(t,e){Th(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Cl=BigInt(2**32-1),ug=BigInt(32);function F8(t,e=!1){return e?{h:Number(t&Cl),l:Number(t>>ug&Cl)}:{h:Number(t>>ug&Cl)|0,l:Number(t&Cl)|0}}function H8(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=F8(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const q8=(t,e,r)=>t<<r|e>>>32-r,W8=(t,e,r)=>e<<r|t>>>32-r,V8=(t,e,r)=>e<<r-32|t>>>64-r,K8=(t,e,r)=>t<<r-32|e>>>64-r,Ps=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function G8(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function FV(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function HV(t,e){return t<<32-e|t>>>e}const hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Z8(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function dg(t){for(let e=0;e<t.length;e++)t[e]=Z8(t[e])}function Y8(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function nb(t){return typeof t=="string"&&(t=Y8(t)),Th(t),t}function qV(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];Th(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}class J8{clone(){return this._cloneInto()}}function X8(t){const e=n=>t().update(nb(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function WV(t=32){if(Ps&&typeof Ps.getRandomValues=="function")return Ps.getRandomValues(new Uint8Array(t));if(Ps&&typeof Ps.randomBytes=="function")return Ps.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ib=[],sb=[],ob=[],Q8=BigInt(0),ua=BigInt(1),eC=BigInt(2),tC=BigInt(7),rC=BigInt(256),nC=BigInt(113);for(let t=0,e=ua,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],ib.push(2*(5*n+r)),sb.push((t+1)*(t+2)/2%64);let i=Q8;for(let s=0;s<7;s++)e=(e<<ua^(e>>tC)*nC)%rC,e&eC&&(i^=ua<<(ua<<BigInt(s))-ua);ob.push(i)}const[iC,sC]=H8(ob,!0),pg=(t,e,r)=>r>32?V8(t,e,r):q8(t,e,r),fg=(t,e,r)=>r>32?K8(t,e,r):W8(t,e,r);function oC(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=r[c],u=r[c+1],h=pg(l,u,1)^r[a],d=fg(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=sb[o],c=pg(i,s,a),l=fg(i,s,a),u=ib[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=iC[n],t[1]^=sC[n]}r.fill(0)}class F0 extends J8{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ih(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=G8(this.state)}keccak(){hg||dg(this.state32),oC(this.state32,this.rounds),hg||dg(this.state32),this.posOut=0,this.pos=0}update(e){lg(this);const{blockLen:r,state:n}=this;e=nb(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,r&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){lg(this,!1),Th(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ih(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(z8(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new F0(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const aC=(t,e,r)=>X8(()=>new F0(e,t,r)),cC=aC(1,136,256/8);function ab(t,e){const r=e||"hex",n=cC(pc(t,{strict:!1})?B8(t):t);return r==="bytes"?n:kf(n)}class lC extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const Id=new lC(8192);function uC(t,e){if(Id.has(`${t}.${e}`))return Id.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),n=ab(rb(r),"bytes"),i=r.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(n[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const s=`0x${i.join("")}`;return Id.set(`${t}.${e}`,s),s}function hC(t){const e=ab(`0x${t.substring(4)}`).substring(26);return uC(`0x${e}`)}async function dC({hash:t,signature:e}){const r=pc(t)?t:kf(t),{secp256k1:n}=await b6(async()=>{const{secp256k1:o}=await import("./secp256k1-DHC-EBD6.js");return{secp256k1:o}},__vite__mapDeps([0,1]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:h,yParity:d}=e,p=Number(d??h),f=gg(p);return new n.Signature(Pf(l),Pf(u)).addRecoveryBit(f)}const o=pc(e)?e:kf(e),a=P8(`0x${o.slice(130)}`),c=gg(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function gg(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function pC({hash:t,signature:e}){return hC(await dC({hash:t,signature:e}))}function fC(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<t.length;l++){const u=t.charAt(l),h=u.charCodeAt(0);if(e[h]!==255)throw new TypeError(u+" is ambiguous");e[h]=l}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),s=Math.log(256)/Math.log(r);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let u=0,h=0,d=0;const p=l.length;for(;d!==p&&l[d]===0;)d++,u++;const f=(p-d)*s+1>>>0,g=new Uint8Array(f);for(;d!==p;){let b=l[d],C=0;for(let E=f-1;(b!==0||C<h)&&E!==-1;E--,C++)b+=256*g[E]>>>0,g[E]=b%r>>>0,b=b/r>>>0;if(b!==0)throw new Error("Non-zero carry");h=C,d++}let w=f-h;for(;w!==f&&g[w]===0;)w++;let v=n.repeat(u);for(;w<f;++w)v+=t.charAt(g[w]);return v}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let u=0,h=0,d=0;for(;l[u]===n;)h++,u++;const p=(l.length-u)*i+1>>>0,f=new Uint8Array(p);for(;u<l.length;){const b=l.charCodeAt(u);if(b>255)return;let C=e[b];if(C===255)return;let E=0;for(let A=p-1;(C!==0||E<d)&&A!==-1;A--,E++)C+=r*f[A]>>>0,f[A]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");d=E,u++}let g=p-d;for(;g!==p&&f[g]===0;)g++;const w=new Uint8Array(h+(p-g));let v=h;for(;g!==p;)w[v++]=f[g++];return w}function c(l){const u=a(l);if(u)return u;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var gC="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const wC=fC(gC),mC=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),vC=t=>{const e=/([\[:])?(\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,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function fs(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return vC(t)}catch{return t}}function Gn(t){return typeof t=="string"?t:mC(t)||""}function yC(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function cb(t,...e){if(!yC(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function wg(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bC(t,e){cb(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ks=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ad=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function CC(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function lb(t){return typeof t=="string"&&(t=CC(t)),cb(t),t}let EC=class{clone(){return this._cloneInto()}};function xC(t){const e=n=>t().update(lb(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ub(t=32){if(ks&&typeof ks.getRandomValues=="function")return ks.getRandomValues(new Uint8Array(t));if(ks&&typeof ks.randomBytes=="function")return ks.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function _C(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}let IC=class extends EC{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ad(this.buffer)}update(e){wg(this);const{view:r,buffer:n,blockLen:i}=this;e=lb(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Ad(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){wg(this),bC(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;_C(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Ad(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};const El=BigInt(2**32-1),Tf=BigInt(32);function hb(t,e=!1){return e?{h:Number(t&El),l:Number(t>>Tf&El)}:{h:Number(t>>Tf&El)|0,l:Number(t&El)|0}}function AC(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=hb(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const $C=(t,e)=>BigInt(t>>>0)<<Tf|BigInt(e>>>0),SC=(t,e,r)=>t>>>r,NC=(t,e,r)=>t<<32-r|e>>>r,OC=(t,e,r)=>t>>>r|e<<32-r,PC=(t,e,r)=>t<<32-r|e>>>r,kC=(t,e,r)=>t<<64-r|e>>>r-32,TC=(t,e,r)=>t>>>r-32|e<<64-r,RC=(t,e)=>e,LC=(t,e)=>t,DC=(t,e,r)=>t<<r|e>>>32-r,BC=(t,e,r)=>e<<r|t>>>32-r,MC=(t,e,r)=>e<<r-32|t>>>64-r,UC=(t,e,r)=>t<<r-32|e>>>64-r;function jC(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}const zC=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),FC=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,HC=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),qC=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,WC=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),VC=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,ye={fromBig:hb,split:AC,toBig:$C,shrSH:SC,shrSL:NC,rotrSH:OC,rotrSL:PC,rotrBH:kC,rotrBL:TC,rotr32H:RC,rotr32L:LC,rotlSH:DC,rotlSL:BC,rotlBH:MC,rotlBL:UC,add:jC,add3L:zC,add3H:FC,add4L:HC,add4H:qC,add5H:VC,add5L:WC},[KC,GC]=ye.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Xn=new Uint32Array(80),Qn=new Uint32Array(80);let ZC=class extends IC{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:h,Fl:d,Gh:p,Gl:f,Hh:g,Hl:w}=this;return[e,r,n,i,s,o,a,c,l,u,h,d,p,f,g,w]}set(e,r,n,i,s,o,a,c,l,u,h,d,p,f,g,w){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=h|0,this.Fl=d|0,this.Gh=p|0,this.Gl=f|0,this.Hh=g|0,this.Hl=w|0}process(e,r){for(let C=0;C<16;C++,r+=4)Xn[C]=e.getUint32(r),Qn[C]=e.getUint32(r+=4);for(let C=16;C<80;C++){const E=Xn[C-15]|0,A=Qn[C-15]|0,S=ye.rotrSH(E,A,1)^ye.rotrSH(E,A,8)^ye.shrSH(E,A,7),T=ye.rotrSL(E,A,1)^ye.rotrSL(E,A,8)^ye.shrSL(E,A,7),k=Xn[C-2]|0,I=Qn[C-2]|0,B=ye.rotrSH(k,I,19)^ye.rotrBH(k,I,61)^ye.shrSH(k,I,6),D=ye.rotrSL(k,I,19)^ye.rotrBL(k,I,61)^ye.shrSL(k,I,6),M=ye.add4L(T,D,Qn[C-7],Qn[C-16]),W=ye.add4H(M,S,B,Xn[C-7],Xn[C-16]);Xn[C]=W|0,Qn[C]=M|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:h,El:d,Fh:p,Fl:f,Gh:g,Gl:w,Hh:v,Hl:b}=this;for(let C=0;C<80;C++){const E=ye.rotrSH(h,d,14)^ye.rotrSH(h,d,18)^ye.rotrBH(h,d,41),A=ye.rotrSL(h,d,14)^ye.rotrSL(h,d,18)^ye.rotrBL(h,d,41),S=h&p^~h&g,T=d&f^~d&w,k=ye.add5L(b,A,T,GC[C],Qn[C]),I=ye.add5H(k,v,E,S,KC[C],Xn[C]),B=k|0,D=ye.rotrSH(n,i,28)^ye.rotrBH(n,i,34)^ye.rotrBH(n,i,39),M=ye.rotrSL(n,i,28)^ye.rotrBL(n,i,34)^ye.rotrBL(n,i,39),W=n&s^n&a^s&a,$=i&o^i&c^o&c;v=g|0,b=w|0,g=p|0,w=f|0,p=h|0,f=d|0,{h,l:d}=ye.add(l|0,u|0,I|0,B|0),l=a|0,u=c|0,a=s|0,c=o|0,s=n|0,o=i|0;const m=ye.add3L(B,M,$);n=ye.add3H(m,I,D,W),i=m|0}({h:n,l:i}=ye.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=ye.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=ye.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=ye.add(this.Dh|0,this.Dl|0,l|0,u|0),{h,l:d}=ye.add(this.Eh|0,this.El|0,h|0,d|0),{h:p,l:f}=ye.add(this.Fh|0,this.Fl|0,p|0,f|0),{h:g,l:w}=ye.add(this.Gh|0,this.Gl|0,g|0,w|0),{h:v,l:b}=ye.add(this.Hh|0,this.Hl|0,v|0,b|0),this.set(n,i,s,o,a,c,l,u,h,d,p,f,g,w,v,b)}roundClean(){Xn.fill(0),Qn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const YC=xC(()=>new ZC);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const H0=BigInt(0),db=BigInt(1),JC=BigInt(2);function q0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function W0(t){if(!q0(t))throw new Error("Uint8Array expected")}function $d(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const XC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function V0(t){W0(t);let e="";for(let r=0;r<t.length;r++)e+=XC[t[r]];return e}function pb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?H0:BigInt("0x"+t)}const En={_0:48,_9:57,A:65,F:70,a:97,f:102};function mg(t){if(t>=En._0&&t<=En._9)return t-En._0;if(t>=En.A&&t<=En.F)return t-(En.A-10);if(t>=En.a&&t<=En.f)return t-(En.a-10)}function fb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){const o=mg(t.charCodeAt(s)),a=mg(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function QC(t){return pb(V0(t))}function ju(t){return W0(t),pb(V0(Uint8Array.from(t).reverse()))}function gb(t,e){return fb(t.toString(16).padStart(e*2,"0"))}function Rf(t,e){return gb(t,e).reverse()}function xn(t,e,r){let n;if(typeof e=="string")try{n=fb(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(q0(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function vg(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];W0(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}const Sd=t=>typeof t=="bigint"&&H0<=t;function e9(t,e,r){return Sd(t)&&Sd(e)&&Sd(r)&&e<=t&&t<r}function ha(t,e,r,n){if(!e9(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function t9(t){let e;for(e=0;t>H0;t>>=db,e+=1);return e}const r9=t=>(JC<<BigInt(t-1))-db,n9={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||q0(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function K0(t,e,r={}){const n=(i,s,o)=>{const a=n9[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+c)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return t}function yg(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(i!==void 0)return i;const s=t(r,...n);return e.set(r,s),s}}const $t=BigInt(0),ot=BigInt(1),Yi=BigInt(2),i9=BigInt(3),Lf=BigInt(4),bg=BigInt(5),Cg=BigInt(8);function wt(t,e){const r=t%e;return r>=$t?r:e+r}function s9(t,e,r){if(e<$t)throw new Error("invalid exponent, negatives unsupported");if(r<=$t)throw new Error("invalid modulus");if(r===ot)return $t;let n=ot;for(;e>$t;)e&ot&&(n=n*t%r),t=t*t%r,e>>=ot;return n}function Qr(t,e,r){let n=t;for(;e-- >$t;)n*=n,n%=r;return n}function Eg(t,e){if(t===$t)throw new Error("invert: expected non-zero number");if(e<=$t)throw new Error("invert: expected positive modulus, got "+e);let r=wt(t,e),n=e,i=$t,s=ot;for(;r!==$t;){const o=n/r,a=n%r,c=i-s*o;n=r,r=a,i=s,s=c}if(n!==ot)throw new Error("invert: does not exist");return wt(i,e)}function o9(t){const e=(t-ot)/Yi;let r,n,i;for(r=t-ot,n=0;r%Yi===$t;r/=Yi,n++);for(i=Yi;i<t&&s9(i,e,t)!==t-ot;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(t+ot)/Lf;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(r+ot)/Yi;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=n,l=o.pow(o.mul(o.ONE,i),r),u=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let f=o.sqr(h);d<c&&!o.eql(f,o.ONE);d++)f=o.sqr(f);const p=o.pow(l,ot<<BigInt(c-d-1));l=o.sqr(p),u=o.mul(u,p),h=o.mul(h,l),c=d}return u}}function a9(t){if(t%Lf===i9){const e=(t+ot)/Lf;return function(r,n){const i=r.pow(n,e);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}}if(t%Cg===bg){const e=(t-bg)/Cg;return function(r,n){const i=r.mul(n,Yi),s=r.pow(i,e),o=r.mul(n,s),a=r.mul(r.mul(o,Yi),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),n))throw new Error("Cannot find square root");return c}}return o9(t)}const c9=(t,e)=>(wt(t,e)&ot)===ot,l9=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function u9(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=l9.reduce((n,i)=>(n[i]="function",n),e);return K0(t,r)}function h9(t,e,r){if(r<$t)throw new Error("invalid exponent, negatives unsupported");if(r===$t)return t.ONE;if(r===ot)return e;let n=t.ONE,i=e;for(;r>$t;)r&ot&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ot;return n}function d9(t,e){const r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function wb(t,e){const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function mb(t,e,r=!1,n={}){if(t<=$t)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:s}=wb(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:i,BYTES:s,MASK:r9(i),ZERO:$t,ONE:ot,create:c=>wt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return $t<=c&&c<t},is0:c=>c===$t,isOdd:c=>(c&ot)===ot,neg:c=>wt(-c,t),eql:(c,l)=>c===l,sqr:c=>wt(c*c,t),add:(c,l)=>wt(c+l,t),sub:(c,l)=>wt(c-l,t),mul:(c,l)=>wt(c*l,t),pow:(c,l)=>h9(a,c,l),div:(c,l)=>wt(c*Eg(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Eg(c,t),sqrt:n.sqrt||(c=>(o||(o=a9(t)),o(a,c))),invertBatch:c=>d9(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Rf(c,s):gb(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?ju(c):QC(c)}});return Object.freeze(a)}const xg=BigInt(0),xl=BigInt(1);function Nd(t,e){const r=e.negate();return t?r:e}function vb(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Od(t,e){vb(t,e);const r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function p9(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function f9(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}const Pd=new WeakMap,yb=new WeakMap;function kd(t){return yb.get(t)||1}function g9(t,e){return{constTimeNegate:Nd,hasPrecomputes(r){return kd(r)!==1},unsafeLadder(r,n,i=t.ZERO){let s=r;for(;n>xg;)n&xl&&(i=i.add(s)),s=s.double(),n>>=xl;return i},precomputeWindow(r,n){const{windows:i,windowSize:s}=Od(n,e),o=[];let a=r,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,n,i){const{windows:s,windowSize:o}=Od(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,h=BigInt(r);for(let d=0;d<s;d++){const p=d*o;let f=Number(i&l);i>>=h,f>o&&(f-=u,i+=xl);const g=p,w=p+Math.abs(f)-1,v=d%2!==0,b=f<0;f===0?c=c.add(Nd(v,n[g])):a=a.add(Nd(b,n[w]))}return{p:a,f:c}},wNAFUnsafe(r,n,i,s=t.ZERO){const{windows:o,windowSize:a}=Od(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let h=0;h<o;h++){const d=h*a;if(i===xg)break;let p=Number(i&c);if(i>>=u,p>a&&(p-=l,i+=xl),p===0)continue;let f=n[d+Math.abs(p)-1];p<0&&(f=f.negate()),s=s.add(f)}return s},getPrecomputes(r,n,i){let s=Pd.get(n);return s||(s=this.precomputeWindow(n,r),r!==1&&Pd.set(n,i(s))),s},wNAFCached(r,n,i){const s=kd(r);return this.wNAF(s,this.getPrecomputes(s,r,i),n)},wNAFCachedUnsafe(r,n,i,s){const o=kd(r);return o===1?this.unsafeLadder(r,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,i),n,s)},setWindowSize(r,n){vb(n,e),yb.set(r,n),Pd.delete(r)}}}function w9(t,e,r,n){if(p9(r,t),f9(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,s=t9(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let p=0;p<n.length;p++){const f=n[p],g=Number(f>>BigInt(h)&BigInt(a));c[g]=c[g].add(r[p])}let d=i;for(let p=c.length-1,f=i;p>0;p--)f=f.add(c[p]),d=d.add(f);if(u=u.add(d),h!==0)for(let p=0;p<o;p++)u=u.double()}return u}function m9(t){return u9(t.Fp),K0(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wb(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Mr=BigInt(0),Zt=BigInt(1),_l=BigInt(2),v9=BigInt(8),y9={zip215:!0};function b9(t){const e=m9(t);return K0(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function C9(t){const e=b9(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=_l<<BigInt(a*8)-Zt,u=r.create,h=mb(e.n,e.nBitLength),d=e.uvRatio||((m,y)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(y))}}catch{return{isValid:!1,value:Mr}}}),p=e.adjustScalarBytes||(m=>m),f=e.domain||((m,y,x)=>{if($d("phflag",x),y.length||x)throw new Error("Contexts/pre-hash are not supported");return m});function g(m,y){ha("coordinate "+m,y,Mr,l)}function w(m){if(!(m instanceof C))throw new Error("ExtendedPoint expected")}const v=yg((m,y)=>{const{ex:x,ey:_,ez:O}=m,R=m.is0();y==null&&(y=R?v9:r.inv(O));const U=u(x*y),j=u(_*y),V=u(O*y);if(R)return{x:Mr,y:Zt};if(V!==Zt)throw new Error("invZ was invalid");return{x:U,y:j}}),b=yg(m=>{const{a:y,d:x}=e;if(m.is0())throw new Error("bad point: ZERO");const{ex:_,ey:O,ez:R,et:U}=m,j=u(_*_),V=u(O*O),z=u(R*R),te=u(z*z),he=u(j*y),Ce=u(z*u(he+V)),we=u(te+u(x*u(j*V)));if(Ce!==we)throw new Error("bad point: equation left != right (1)");const ge=u(_*O),Ee=u(R*U);if(ge!==Ee)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(y,x,_,O){this.ex=y,this.ey=x,this.ez=_,this.et=O,g("x",y),g("y",x),g("z",_),g("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof C)throw new Error("extended point not allowed");const{x,y:_}=y||{};return g("x",x),g("y",_),new C(x,_,Zt,u(x*_))}static normalizeZ(y){const x=r.invertBatch(y.map(_=>_.ez));return y.map((_,O)=>_.toAffine(x[O])).map(C.fromAffine)}static msm(y,x){return w9(C,h,y,x)}_setWindowSize(y){S.setWindowSize(this,y)}assertValidity(){b(this)}equals(y){w(y);const{ex:x,ey:_,ez:O}=this,{ex:R,ey:U,ez:j}=y,V=u(x*j),z=u(R*O),te=u(_*j),he=u(U*O);return V===z&&te===he}is0(){return this.equals(C.ZERO)}negate(){return new C(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:y}=e,{ex:x,ey:_,ez:O}=this,R=u(x*x),U=u(_*_),j=u(_l*u(O*O)),V=u(y*R),z=x+_,te=u(u(z*z)-R-U),he=V+U,Ce=he-j,we=V-U,ge=u(te*Ce),Ee=u(he*we),Se=u(te*we),Le=u(Ce*he);return new C(ge,Ee,Le,Se)}add(y){w(y);const{a:x,d:_}=e,{ex:O,ey:R,ez:U,et:j}=this,{ex:V,ey:z,ez:te,et:he}=y;if(x===BigInt(-1)){const U1=u((R-O)*(z+V)),j1=u((R+O)*(z-V)),bd=u(j1-U1);if(bd===Mr)return this.double();const z1=u(U*_l*he),F1=u(j*_l*te),H1=F1+z1,q1=j1+U1,W1=F1-z1,w6=u(H1*bd),m6=u(q1*W1),v6=u(H1*W1),y6=u(bd*q1);return new C(w6,m6,y6,v6)}const Ce=u(O*V),we=u(R*z),ge=u(j*_*he),Ee=u(U*te),Se=u((O+R)*(V+z)-Ce-we),Le=Ee-ge,nt=Ee+ge,yt=u(we-x*Ce),bn=u(Se*Le),p6=u(nt*yt),f6=u(Se*yt),g6=u(Le*nt);return new C(bn,p6,g6,f6)}subtract(y){return this.add(y.negate())}wNAF(y){return S.wNAFCached(this,y,C.normalizeZ)}multiply(y){const x=y;ha("scalar",x,Zt,n);const{p:_,f:O}=this.wNAF(x);return C.normalizeZ([_,O])[0]}multiplyUnsafe(y,x=C.ZERO){const _=y;return ha("scalar",_,Mr,n),_===Mr?A:this.is0()||_===Zt?this:S.wNAFCachedUnsafe(this,_,C.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return S.unsafeLadder(this,n).is0()}toAffine(y){return v(this,y)}clearCofactor(){const{h:y}=e;return y===Zt?this:this.multiplyUnsafe(y)}static fromHex(y,x=!1){const{d:_,a:O}=e,R=r.BYTES;y=xn("pointHex",y,R),$d("zip215",x);const U=y.slice(),j=y[R-1];U[R-1]=j&-129;const V=ju(U),z=x?l:r.ORDER;ha("pointHex.y",V,Mr,z);const te=u(V*V),he=u(te-Zt),Ce=u(_*te-O);let{isValid:we,value:ge}=d(he,Ce);if(!we)throw new Error("Point.fromHex: invalid y coordinate");const Ee=(ge&Zt)===Zt,Se=(j&128)!==0;if(!x&&ge===Mr&&Se)throw new Error("Point.fromHex: x=0 and x_0=1");return Se!==Ee&&(ge=u(-ge)),C.fromAffine({x:ge,y:V})}static fromPrivateKey(y){return I(y).point}toRawBytes(){const{x:y,y:x}=this.toAffine(),_=Rf(x,r.BYTES);return _[_.length-1]|=y&Zt?128:0,_}toHex(){return V0(this.toRawBytes())}}C.BASE=new C(e.Gx,e.Gy,Zt,u(e.Gx*e.Gy)),C.ZERO=new C(Mr,Zt,Zt,Mr);const{BASE:E,ZERO:A}=C,S=g9(C,a*8);function T(m){return wt(m,n)}function k(m){return T(ju(m))}function I(m){const y=r.BYTES;m=xn("private key",m,y);const x=xn("hashed private key",s(m),2*y),_=p(x.slice(0,y)),O=x.slice(y,2*y),R=k(_),U=E.multiply(R),j=U.toRawBytes();return{head:_,prefix:O,scalar:R,point:U,pointBytes:j}}function B(m){return I(m).pointBytes}function D(m=new Uint8Array,...y){const x=vg(...y);return k(s(f(x,xn("context",m),!!i)))}function M(m,y,x={}){m=xn("message",m),i&&(m=i(m));const{prefix:_,scalar:O,pointBytes:R}=I(y),U=D(x.context,_,m),j=E.multiply(U).toRawBytes(),V=D(x.context,j,R,m),z=T(U+V*O);ha("signature.s",z,Mr,n);const te=vg(j,Rf(z,r.BYTES));return xn("result",te,r.BYTES*2)}const W=y9;function $(m,y,x,_=W){const{context:O,zip215:R}=_,U=r.BYTES;m=xn("signature",m,2*U),y=xn("message",y),x=xn("publicKey",x,U),R!==void 0&&$d("zip215",R),i&&(y=i(y));const j=ju(m.slice(U,2*U));let V,z,te;try{V=C.fromHex(x,R),z=C.fromHex(m.slice(0,U),R),te=E.multiplyUnsafe(j)}catch{return!1}if(!R&&V.isSmallOrder())return!1;const he=D(O,z.toRawBytes(),V.toRawBytes(),y);return z.add(V.multiplyUnsafe(he)).subtract(te).clearCofactor().equals(C.ZERO)}return E._setWindowSize(8),{CURVE:e,getPublicKey:B,sign:M,verify:$,ExtendedPoint:C,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>o(r.BYTES),precompute(m=8,y=C.BASE){return y._setWindowSize(m),y.multiply(BigInt(3)),y}}}}BigInt(0),BigInt(1);const G0=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_g=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const E9=BigInt(1),Ig=BigInt(2);BigInt(3);const x9=BigInt(5),_9=BigInt(8);function I9(t){const e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=G0,o=t*t%s*t%s,a=Qr(o,Ig,s)*o%s,c=Qr(a,E9,s)*t%s,l=Qr(c,x9,s)*c%s,u=Qr(l,e,s)*l%s,h=Qr(u,r,s)*u%s,d=Qr(h,n,s)*h%s,p=Qr(d,i,s)*d%s,f=Qr(p,i,s)*d%s,g=Qr(f,e,s)*l%s;return{pow_p_5_8:Qr(g,Ig,s)*t%s,b2:o}}function A9(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function $9(t,e){const r=G0,n=wt(e*e*e,r),i=wt(n*n*e,r),s=I9(t*i).pow_p_5_8;let o=wt(t*n*s,r);const a=wt(e*o*o,r),c=o,l=wt(o*_g,r),u=a===t,h=a===wt(-t,r),d=a===wt(-t*_g,r);return u&&(o=c),(h||d)&&(o=l),c9(o,r)&&(o=wt(-o,r)),{isValid:u||h,value:o}}const S9=mb(G0,void 0,!0),N9={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:S9,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_9,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:YC,randomBytes:ub,adjustScalarBytes:A9,uvRatio:$9},bb=C9(N9),O9="EdDSA",P9="JWT",sh=".",Rh="base64url",Cb="utf8",Eb="utf8",k9=":",T9="did",R9="key",Ag="base58btc",L9="z",D9="K36",B9=32;function Z0(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function xb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Z0(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function _b(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=xb(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return Z0(r)}function M9(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,w=0,v=0,b=f.length;v!==b&&f[v]===0;)v++,g++;for(var C=(b-v)*u+1>>>0,E=new Uint8Array(C);v!==b;){for(var A=f[v],S=0,T=C-1;(A!==0||S<w)&&T!==-1;T--,S++)A+=256*E[T]>>>0,E[T]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=S,v++}for(var k=C-w;k!==C&&E[k]===0;)k++;for(var I=c.repeat(g);k<C;++k)I+=t.charAt(E[k]);return I}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var w=0,v=0;f[g]===c;)w++,g++;for(var b=(f.length-g)*l+1>>>0,C=new Uint8Array(b);f[g];){var E=r[f.charCodeAt(g)];if(E===255)return;for(var A=0,S=b-1;(E!==0||A<v)&&S!==-1;S--,A++)E+=a*C[S]>>>0,C[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");v=A,g++}if(f[g]!==" "){for(var T=b-v;T!==b&&C[T]===0;)T++;for(var k=new Uint8Array(w+(b-T)),I=w;T!==b;)k[I++]=C[T++];return k}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:p}}var U9=M9,j9=U9;const Ib=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")},z9=t=>new TextEncoder().encode(t),F9=t=>new TextDecoder().decode(t);let H9=class{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")}},q9=class{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 Ab(this,e)}},W9=class{constructor(e){this.decoders=e}or(e){return Ab(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 Ab=(t,e)=>new W9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let V9=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new H9(e,r,n),this.decoder=new q9(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Lh=({name:t,prefix:e,encode:r,decode:n})=>new V9(t,e,r,n),Qc=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=j9(r,e);return Lh({prefix:t,name:e,encode:n,decode:s=>Ib(i(s))})},K9=(t,e,r,n)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},G9=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Rt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Lh({prefix:e,name:t,encode(i){return G9(i,n,r)},decode(i){return K9(i,n,r,t)}}),Z9=Lh({prefix:"\0",name:"identity",encode:t=>F9(t),decode:t=>z9(t)});var Y9=Object.freeze({__proto__:null,identity:Z9});const J9=Rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var X9=Object.freeze({__proto__:null,base2:J9});const Q9=Rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var e7=Object.freeze({__proto__:null,base8:Q9});const t7=Qc({prefix:"9",name:"base10",alphabet:"0123456789"});var r7=Object.freeze({__proto__:null,base10:t7});const n7=Rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),i7=Rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var s7=Object.freeze({__proto__:null,base16:n7,base16upper:i7});const o7=Rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),a7=Rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),c7=Rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),l7=Rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),u7=Rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),h7=Rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),d7=Rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),p7=Rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),f7=Rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var g7=Object.freeze({__proto__:null,base32:o7,base32upper:a7,base32pad:c7,base32padupper:l7,base32hex:u7,base32hexupper:h7,base32hexpad:d7,base32hexpadupper:p7,base32z:f7});const w7=Qc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),m7=Qc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var v7=Object.freeze({__proto__:null,base36:w7,base36upper:m7});const y7=Qc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),b7=Qc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var C7=Object.freeze({__proto__:null,base58btc:y7,base58flickr:b7});const E7=Rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),x7=Rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_7=Rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),I7=Rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var A7=Object.freeze({__proto__:null,base64:E7,base64pad:x7,base64url:_7,base64urlpad:I7});const $b=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),$7=$b.reduce((t,e,r)=>(t[r]=e,t),[]),S7=$b.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function N7(t){return t.reduce((e,r)=>(e+=$7[r],e),"")}function O7(t){const e=[];for(const r of t){const n=S7[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const P7=Lh({prefix:"🚀",name:"base256emoji",encode:N7,decode:O7});var k7=Object.freeze({__proto__:null,base256emoji:P7}),T7=Sb,$g=128,R7=127,L7=~R7,D7=Math.pow(2,31);function Sb(t,e,r){e=e||[],r=r||0;for(var n=r;t>=D7;)e[r++]=t&255|$g,t/=128;for(;t&L7;)e[r++]=t&255|$g,t>>>=7;return e[r]=t|0,Sb.bytes=r-n+1,e}var B7=Df,M7=128,Sg=127;function Df(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw Df.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Sg)<<i:(o&Sg)*Math.pow(2,i),i+=7}while(o>=M7);return Df.bytes=s-n,r}var U7=Math.pow(2,7),j7=Math.pow(2,14),z7=Math.pow(2,21),F7=Math.pow(2,28),H7=Math.pow(2,35),q7=Math.pow(2,42),W7=Math.pow(2,49),V7=Math.pow(2,56),K7=Math.pow(2,63),G7=function(t){return t<U7?1:t<j7?2:t<z7?3:t<F7?4:t<H7?5:t<q7?6:t<W7?7:t<V7?8:t<K7?9:10},Z7={encode:T7,decode:B7,encodingLength:G7},Nb=Z7;const Ng=(t,e,r=0)=>(Nb.encode(t,e,r),e),Og=t=>Nb.encodingLength(t),Bf=(t,e)=>{const r=e.byteLength,n=Og(t),i=n+Og(r),s=new Uint8Array(i+r);return Ng(t,s,0),Ng(r,s,n),s.set(e,i),new Y7(t,r,e,s)};let Y7=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};const Ob=({name:t,code:e,encode:r})=>new J7(t,e,r);let J7=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Bf(this.code,r):r.then(n=>Bf(this.code,n))}else throw Error("Unknown type, must be binary type")}};const Pb=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),X7=Ob({name:"sha2-256",code:18,encode:Pb("SHA-256")}),Q7=Ob({name:"sha2-512",code:19,encode:Pb("SHA-512")});var eE=Object.freeze({__proto__:null,sha256:X7,sha512:Q7});const kb=0,tE="identity",Tb=Ib,rE=t=>Bf(kb,Tb(t)),nE={code:kb,name:tE,encode:Tb,digest:rE};var iE=Object.freeze({__proto__:null,identity:nE});new TextEncoder,new TextDecoder;const Pg={...Y9,...X9,...e7,...r7,...s7,...g7,...v7,...C7,...A7,...k7};({...eE,...iE});function Rb(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const kg=Rb("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Td=Rb("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=xb(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Lb={utf8:kg,"utf-8":kg,hex:Pg.base16,latin1:Td,ascii:Td,binary:Td,...Pg};function Dh(t,e="utf8"){const r=Lb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Xo(t,e="utf8"){const r=Lb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Z0(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Tg(t){return fs(Dh(Xo(t,Rh),Cb))}function oh(t){return Dh(Xo(Gn(t),Cb),Rh)}function Db(t){const e=Xo(D9,Ag),r=L9+Dh(_b([e,t]),Ag);return[T9,R9,r].join(k9)}function sE(t){return Dh(t,Rh)}function oE(t){return Xo(t,Rh)}function aE(t){return Xo([oh(t.header),oh(t.payload)].join(sh),Eb)}function cE(t){return[oh(t.header),oh(t.payload),sE(t.signature)].join(sh)}function Mf(t){const e=t.split(sh),r=Tg(e[0]),n=Tg(e[1]),i=oE(e[2]),s=Xo(e.slice(0,2).join(sh),Eb);return{header:r,payload:n,signature:i,data:s}}function Rg(t=ub(B9)){const e=bb.getPublicKey(t);return{secretKey:_b([t,e]),publicKey:e}}async function lE(t,e,r,n,i=K.fromMiliseconds(Date.now())){const s={alg:O9,typ:P9},o=Db(n.publicKey),a=i+r,c={iss:o,sub:t,aud:e,iat:i,exp:a},l=aE({header:s,payload:c}),u=bb.sign(l,n.secretKey.slice(0,32));return cE({header:s,payload:c,signature:u})}function Bb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function tc(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=Bb(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function uE(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,w=0,v=0,b=f.length;v!==b&&f[v]===0;)v++,g++;for(var C=(b-v)*u+1>>>0,E=new Uint8Array(C);v!==b;){for(var A=f[v],S=0,T=C-1;(A!==0||S<w)&&T!==-1;T--,S++)A+=256*E[T]>>>0,E[T]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=S,v++}for(var k=C-w;k!==C&&E[k]===0;)k++;for(var I=c.repeat(g);k<C;++k)I+=t.charAt(E[k]);return I}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var w=0,v=0;f[g]===c;)w++,g++;for(var b=(f.length-g)*l+1>>>0,C=new Uint8Array(b);f[g];){var E=r[f.charCodeAt(g)];if(E===255)return;for(var A=0,S=b-1;(E!==0||A<v)&&S!==-1;S--,A++)E+=a*C[S]>>>0,C[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");v=A,g++}if(f[g]!==" "){for(var T=b-v;T!==b&&C[T]===0;)T++;for(var k=new Uint8Array(w+(b-T)),I=w;T!==b;)k[I++]=C[T++];return k}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:p}}var hE=uE,dE=hE;const pE=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")},fE=t=>new TextEncoder().encode(t),gE=t=>new TextDecoder().decode(t);class wE{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 mE{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 Mb(this,e)}}class vE{constructor(e){this.decoders=e}or(e){return Mb(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 Mb=(t,e)=>new vE({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class yE{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new wE(e,r,n),this.decoder=new mE(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Bh=({name:t,prefix:e,encode:r,decode:n})=>new yE(t,e,r,n),el=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=dE(r,e);return Bh({prefix:t,name:e,encode:n,decode:s=>pE(i(s))})},bE=(t,e,r,n)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},CE=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Lt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Bh({prefix:e,name:t,encode(i){return CE(i,n,r)},decode(i){return bE(i,n,r,t)}}),EE=Bh({prefix:"\0",name:"identity",encode:t=>gE(t),decode:t=>fE(t)}),xE=Object.freeze(Object.defineProperty({__proto__:null,identity:EE},Symbol.toStringTag,{value:"Module"})),_E=Lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),IE=Object.freeze(Object.defineProperty({__proto__:null,base2:_E},Symbol.toStringTag,{value:"Module"})),AE=Lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$E=Object.freeze(Object.defineProperty({__proto__:null,base8:AE},Symbol.toStringTag,{value:"Module"})),SE=el({prefix:"9",name:"base10",alphabet:"0123456789"}),NE=Object.freeze(Object.defineProperty({__proto__:null,base10:SE},Symbol.toStringTag,{value:"Module"})),OE=Lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),PE=Lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),kE=Object.freeze(Object.defineProperty({__proto__:null,base16:OE,base16upper:PE},Symbol.toStringTag,{value:"Module"})),TE=Lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),RE=Lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),LE=Lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),DE=Lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),BE=Lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ME=Lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),UE=Lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jE=Lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zE=Lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),FE=Object.freeze(Object.defineProperty({__proto__:null,base32:TE,base32hex:BE,base32hexpad:UE,base32hexpadupper:jE,base32hexupper:ME,base32pad:LE,base32padupper:DE,base32upper:RE,base32z:zE},Symbol.toStringTag,{value:"Module"})),HE=el({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qE=el({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),WE=Object.freeze(Object.defineProperty({__proto__:null,base36:HE,base36upper:qE},Symbol.toStringTag,{value:"Module"})),VE=el({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KE=el({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),GE=Object.freeze(Object.defineProperty({__proto__:null,base58btc:VE,base58flickr:KE},Symbol.toStringTag,{value:"Module"})),ZE=Lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),YE=Lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),JE=Lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),XE=Lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),QE=Object.freeze(Object.defineProperty({__proto__:null,base64:ZE,base64pad:YE,base64url:JE,base64urlpad:XE},Symbol.toStringTag,{value:"Module"})),Ub=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ex=Ub.reduce((t,e,r)=>(t[r]=e,t),[]),tx=Ub.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function rx(t){return t.reduce((e,r)=>(e+=ex[r],e),"")}function nx(t){const e=[];for(const r of t){const n=tx[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const ix=Bh({prefix:"🚀",name:"base256emoji",encode:rx,decode:nx}),sx=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:ix},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Lg={...xE,...IE,...$E,...NE,...kE,...FE,...WE,...GE,...QE,...sx};function jb(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Dg=jb("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Rd=jb("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Bb(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),zb={utf8:Dg,"utf-8":Dg,hex:Lg.base16,latin1:Rd,ascii:Rd,binary:Rd,...Lg};function Lr(t,e="utf8"){const r=zb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function or(t,e="utf8"){const r=zb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}const ox={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var ax={VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm"};const cx=":";function bo(t){const[e,r]=t.split(cx);return{namespace:e,reference:r}}function Bg(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function Fb(t,e){return t.includes(":")?[t]:e.chains||[]}var lx=Object.defineProperty,ux=Object.defineProperties,hx=Object.getOwnPropertyDescriptors,Mg=Object.getOwnPropertySymbols,dx=Object.prototype.hasOwnProperty,px=Object.prototype.propertyIsEnumerable,Ug=(t,e,r)=>e in t?lx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jg=(t,e)=>{for(var r in e||(e={}))dx.call(e,r)&&Ug(t,r,e[r]);if(Mg)for(var r of Mg(e))px.call(e,r)&&Ug(t,r,e[r]);return t},fx=(t,e)=>ux(t,hx(e));const gx="ReactNative",yr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},wx="js";function ah(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ii(){return!Xc()&&!!j0()&&navigator.product===gx}function mx(){return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function vx(){return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function tl(){return!ah()&&!!j0()&&!!Xc()}function rl(){return Ii()?yr.reactNative:ah()?yr.node:tl()?yr.browser:yr.unknown}function zg(){var t;try{return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function yx(t,e){const r=new URLSearchParams(t);for(const n of Object.keys(e).sort())if(e.hasOwnProperty(n)){const i=e[n];i!==void 0&&r.set(n,i)}return r.toString()}function bx(t){var e,r;const n=Hb();try{return t!=null&&t.url&&n.url&&t.url!==n.url&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${n.url}. This is probably unintended and can lead to issues.`),t.url=n.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),fx(jg(jg({},n),t),{url:(t==null?void 0:t.url)||n.url,name:(t==null?void 0:t.name)||n.name,description:(t==null?void 0:t.description)||n.description,icons:(r=t==null?void 0:t.icons)!=null&&r.length&&t.icons.length>0?t.icons:n.icons})}catch(i){return console.warn("Error populating app metadata",i),t||n}}function Hb(){return Zy()||{name:"",description:"",url:"",icons:[""]}}function Cx(){if(rl()===yr.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:n}=global.Platform;return[r,n].join("-")}const t=D6();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Ex(){var t;const e=rl();return e===yr.browser?[e,((t=Gy())==null?void 0:t.host)||"unknown"].join(":"):e}function qb(t,e,r){const n=Cx(),i=Ex();return[[t,e].join("-"),[wx,r].join("-"),n,i].join("/")}function xx({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=r.split("?"),u=qb(t,e,n),h={auth:i,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=yx(l[1]||"",h);return l[0]+"?"+d}function rs(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Uf(t){return Object.fromEntries(t.entries())}function jf(t){return new Map(Object.entries(t))}function Ki(t=K.FIVE_MINUTES,e){const r=K.toMiliseconds(t||K.FIVE_MINUTES);let n,i,s,o;return{resolve:a=>{s&&n&&(clearTimeout(s),n(a),o=Promise.resolve(a))},reject:a=>{s&&i&&(clearTimeout(s),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},r),n=a,i=c})}}function pi(t,e,r){return new Promise(async(n,i)=>{const s=setTimeout(()=>i(new Error(r)),e);try{const o=await t;n(o)}catch(o){i(o)}clearTimeout(s)})}function Wb(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function _x(t){return Wb("topic",t)}function Ix(t){return Wb("id",t)}function Vb(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function pt(t,e){return K.fromMiliseconds(Date.now()+K.toMiliseconds(t))}function ci(t){return Date.now()>=K.toMiliseconds(t)}function Re(t,e){return`${t}${e?`:${e}`:""}`}function zu(t=[],e=[]){return[...new Set([...t,...e])]}async function Ax({id:t,topic:e,wcDeepLink:r}){var n;try{if(!r)return;const i=typeof r=="string"?JSON.parse(r):r,s=i==null?void 0:i.href;if(typeof s!="string")return;const o=$x(s,t,e),a=rl();if(a===yr.browser){if(!((n=Xc())!=null&&n.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Sx(o)}else a===yr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function $x(t,e,r){const n=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${s}${kx(n,!0)}`}else i=`${i}/wc?${n}`;return i}function Sx(t){let e="_self";Px()?e="_top":(Ox()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Nx(t,e){let r="";try{if(tl()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(n){console.error(n)}return r}function Fg(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),n=r.indexOf(e);return r[n+2]}function Hg(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Y0(){return typeof process<"u"&&ax.IS_VITEST==="true"}function Ox(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Px(){try{return window.self!==window.top}catch{return!1}}function kx(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Kb(t){return Buffer.from(t,"base64").toString("utf-8")}function Tx(t){return new Promise(e=>setTimeout(e,t))}function fc(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Rx(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function nl(t,...e){if(!Rx(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function J0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fc(t.outputLen),fc(t.blockLen)}function Po(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gb(t,e){nl(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Il=BigInt(2**32-1),qg=BigInt(32);function Lx(t,e=!1){return e?{h:Number(t&Il),l:Number(t>>qg&Il)}:{h:Number(t>>qg&Il)|0,l:Number(t&Il)|0}}function Dx(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Lx(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const Bx=(t,e,r)=>t<<r|e>>>32-r,Mx=(t,e,r)=>e<<r|t>>>32-r,Ux=(t,e,r)=>e<<r-32|t>>>64-r,jx=(t,e,r)=>t<<r-32|e>>>64-r,Ts=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function zx(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ld(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function en(t,e){return t<<32-e|t>>>e}const Wg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fx(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Vg(t){for(let e=0;e<t.length;e++)t[e]=Fx(t[e])}function Hx(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ko(t){return typeof t=="string"&&(t=Hx(t)),nl(t),t}function qx(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];nl(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}let X0=class{clone(){return this._cloneInto()}};function Zb(t){const e=n=>t().update(ko(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Qo(t=32){if(Ts&&typeof Ts.getRandomValues=="function")return Ts.getRandomValues(new Uint8Array(t));if(Ts&&typeof Ts.randomBytes=="function")return Ts.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Yb=[],Jb=[],Xb=[],Wx=BigInt(0),da=BigInt(1),Vx=BigInt(2),Kx=BigInt(7),Gx=BigInt(256),Zx=BigInt(113);for(let t=0,e=da,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Yb.push(2*(5*n+r)),Jb.push((t+1)*(t+2)/2%64);let i=Wx;for(let s=0;s<7;s++)e=(e<<da^(e>>Kx)*Zx)%Gx,e&Vx&&(i^=da<<(da<<BigInt(s))-da);Xb.push(i)}const[Yx,Jx]=Dx(Xb,!0),Kg=(t,e,r)=>r>32?Ux(t,e,r):Bx(t,e,r),Gg=(t,e,r)=>r>32?jx(t,e,r):Mx(t,e,r);function Xx(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=r[c],u=r[c+1],h=Kg(l,u,1)^r[a],d=Gg(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=Jb[o],c=Kg(i,s,a),l=Gg(i,s,a),u=Yb[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=Yx[n],t[1]^=Jx[n]}r.fill(0)}let Qx=class Qb extends X0{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,fc(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=zx(this.state)}keccak(){Wg||Vg(this.state32),Xx(this.state32,this.rounds),Wg||Vg(this.state32),this.posOut=0,this.pos=0}update(e){Po(this);const{blockLen:r,state:n}=this;e=ko(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,r&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Po(this,!1),nl(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return fc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Gb(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new Qb(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const e_=(t,e,r)=>Zb(()=>new Qx(e,t,r)),t_=e_(1,136,256/8),r_="https://rpc.walletconnect.org/v1";function e2(t){const e=`Ethereum Signed Message:
|
|
16
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=Yy}walk(e){return Jy(this,e)}}function Jy(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Jy(t.cause,e):e?null:t}class Xy extends ps{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function Yo(t,{dir:e,size:r=32}={}){return typeof t=="string"?$8(t,{dir:e,size:r}):S8(t,{dir:e,size:r})}function $8(t,{dir:e,size:r=32}={}){if(r===null)return t;const n=t.replace("0x","");if(n.length>r*2)throw new Xy({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function S8(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new Xy({size:t.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const s=e==="right";n[s?i:r-i-1]=t[s?i:t.length-i-1]}return n}class N8 extends ps{constructor({max:e,min:r,signed:n,size:i,value:s}){super(`Number "${s}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class O8 extends ps{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Jo(t,{size:e}){if(ag(t)>e)throw new O8({givenSize:ag(t),maxSize:e})}function Pf(t,e={}){const{signed:r}=e;e.size&&Jo(t,{size:e.size});const n=BigInt(t);if(!r)return n;const i=(t.length-2)/2,s=(1n<<BigInt(i)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function P8(t,e={}){return Number(Pf(t,e))}const k8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function kf(t,e={}){return typeof t=="number"||typeof t=="bigint"?eb(t,e):typeof t=="string"?L8(t,e):typeof t=="boolean"?T8(t,e):Qy(t,e)}function T8(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{size:e.size})):r}function Qy(t,e={}){let r="";for(let i=0;i<t.length;i++)r+=k8[t[i]];const n=`0x${r}`;return typeof e.size=="number"?(Jo(n,{size:e.size}),Yo(n,{dir:"right",size:e.size})):n}function eb(t,e={}){const{signed:r,size:n}=e,i=BigInt(t);let s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&i>s||i<o){const c=typeof t=="bigint"?"n":"";throw new N8({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:n,value:`${t}${c}`})}const a=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?Yo(a,{size:n}):a}const R8=new TextEncoder;function L8(t,e={}){const r=R8.encode(t);return Qy(r,e)}const D8=new TextEncoder;function B8(t,e={}){return typeof t=="number"||typeof t=="bigint"?U8(t,e):typeof t=="boolean"?M8(t,e):pc(t)?tb(t,e):rb(t,e)}function M8(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{size:e.size})):r}const Cn={zero:48,nine:57,A:65,F:70,a:97,f:102};function cg(t){if(t>=Cn.zero&&t<=Cn.nine)return t-Cn.zero;if(t>=Cn.A&&t<=Cn.F)return t-(Cn.A-10);if(t>=Cn.a&&t<=Cn.f)return t-(Cn.a-10)}function tb(t,e={}){let r=t;e.size&&(Jo(r,{size:e.size}),r=Yo(r,{dir:"right",size:e.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,s=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=cg(n.charCodeAt(a++)),l=cg(n.charCodeAt(a++));if(c===void 0||l===void 0)throw new ps(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[o]=c*16+l}return s}function U8(t,e){const r=eb(t,e);return tb(r)}function rb(t,e={}){const r=D8.encode(t);return typeof e.size=="number"?(Jo(r,{size:e.size}),Yo(r,{dir:"right",size:e.size})):r}function ih(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function j8(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Th(t,...e){if(!j8(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function zV(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ih(t.outputLen),ih(t.blockLen)}function lg(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function z8(t,e){Th(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Cl=BigInt(2**32-1),ug=BigInt(32);function F8(t,e=!1){return e?{h:Number(t&Cl),l:Number(t>>ug&Cl)}:{h:Number(t>>ug&Cl)|0,l:Number(t&Cl)|0}}function H8(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=F8(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const q8=(t,e,r)=>t<<r|e>>>32-r,W8=(t,e,r)=>e<<r|t>>>32-r,V8=(t,e,r)=>e<<r-32|t>>>64-r,K8=(t,e,r)=>t<<r-32|e>>>64-r,Ps=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function G8(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function FV(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function HV(t,e){return t<<32-e|t>>>e}const hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Z8(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function dg(t){for(let e=0;e<t.length;e++)t[e]=Z8(t[e])}function Y8(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function nb(t){return typeof t=="string"&&(t=Y8(t)),Th(t),t}function qV(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];Th(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}class J8{clone(){return this._cloneInto()}}function X8(t){const e=n=>t().update(nb(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function WV(t=32){if(Ps&&typeof Ps.getRandomValues=="function")return Ps.getRandomValues(new Uint8Array(t));if(Ps&&typeof Ps.randomBytes=="function")return Ps.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ib=[],sb=[],ob=[],Q8=BigInt(0),ua=BigInt(1),eC=BigInt(2),tC=BigInt(7),rC=BigInt(256),nC=BigInt(113);for(let t=0,e=ua,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],ib.push(2*(5*n+r)),sb.push((t+1)*(t+2)/2%64);let i=Q8;for(let s=0;s<7;s++)e=(e<<ua^(e>>tC)*nC)%rC,e&eC&&(i^=ua<<(ua<<BigInt(s))-ua);ob.push(i)}const[iC,sC]=H8(ob,!0),pg=(t,e,r)=>r>32?V8(t,e,r):q8(t,e,r),fg=(t,e,r)=>r>32?K8(t,e,r):W8(t,e,r);function oC(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=r[c],u=r[c+1],h=pg(l,u,1)^r[a],d=fg(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=sb[o],c=pg(i,s,a),l=fg(i,s,a),u=ib[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=iC[n],t[1]^=sC[n]}r.fill(0)}class F0 extends J8{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ih(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=G8(this.state)}keccak(){hg||dg(this.state32),oC(this.state32,this.rounds),hg||dg(this.state32),this.posOut=0,this.pos=0}update(e){lg(this);const{blockLen:r,state:n}=this;e=nb(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,r&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){lg(this,!1),Th(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ih(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(z8(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new F0(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const aC=(t,e,r)=>X8(()=>new F0(e,t,r)),cC=aC(1,136,256/8);function ab(t,e){const r=e||"hex",n=cC(pc(t,{strict:!1})?B8(t):t);return r==="bytes"?n:kf(n)}class lC extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const Id=new lC(8192);function uC(t,e){if(Id.has(`${t}.${e}`))return Id.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),n=ab(rb(r),"bytes"),i=r.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(n[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const s=`0x${i.join("")}`;return Id.set(`${t}.${e}`,s),s}function hC(t){const e=ab(`0x${t.substring(4)}`).substring(26);return uC(`0x${e}`)}async function dC({hash:t,signature:e}){const r=pc(t)?t:kf(t),{secp256k1:n}=await b6(async()=>{const{secp256k1:o}=await import("./secp256k1-CIC_BmhQ.js");return{secp256k1:o}},__vite__mapDeps([0,1]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:h,yParity:d}=e,p=Number(d??h),f=gg(p);return new n.Signature(Pf(l),Pf(u)).addRecoveryBit(f)}const o=pc(e)?e:kf(e),a=P8(`0x${o.slice(130)}`),c=gg(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function gg(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function pC({hash:t,signature:e}){return hC(await dC({hash:t,signature:e}))}function fC(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<t.length;l++){const u=t.charAt(l),h=u.charCodeAt(0);if(e[h]!==255)throw new TypeError(u+" is ambiguous");e[h]=l}const r=t.length,n=t.charAt(0),i=Math.log(r)/Math.log(256),s=Math.log(256)/Math.log(r);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let u=0,h=0,d=0;const p=l.length;for(;d!==p&&l[d]===0;)d++,u++;const f=(p-d)*s+1>>>0,g=new Uint8Array(f);for(;d!==p;){let b=l[d],C=0;for(let E=f-1;(b!==0||C<h)&&E!==-1;E--,C++)b+=256*g[E]>>>0,g[E]=b%r>>>0,b=b/r>>>0;if(b!==0)throw new Error("Non-zero carry");h=C,d++}let w=f-h;for(;w!==f&&g[w]===0;)w++;let v=n.repeat(u);for(;w<f;++w)v+=t.charAt(g[w]);return v}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let u=0,h=0,d=0;for(;l[u]===n;)h++,u++;const p=(l.length-u)*i+1>>>0,f=new Uint8Array(p);for(;u<l.length;){const b=l.charCodeAt(u);if(b>255)return;let C=e[b];if(C===255)return;let E=0;for(let A=p-1;(C!==0||E<d)&&A!==-1;A--,E++)C+=r*f[A]>>>0,f[A]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");d=E,u++}let g=p-d;for(;g!==p&&f[g]===0;)g++;const w=new Uint8Array(h+(p-g));let v=h;for(;g!==p;)w[v++]=f[g++];return w}function c(l){const u=a(l);if(u)return u;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var gC="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const wC=fC(gC),mC=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),vC=t=>{const e=/([\[:])?(\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,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function fs(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return vC(t)}catch{return t}}function Gn(t){return typeof t=="string"?t:mC(t)||""}function yC(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function cb(t,...e){if(!yC(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function wg(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bC(t,e){cb(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ks=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ad=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function CC(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function lb(t){return typeof t=="string"&&(t=CC(t)),cb(t),t}let EC=class{clone(){return this._cloneInto()}};function xC(t){const e=n=>t().update(lb(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ub(t=32){if(ks&&typeof ks.getRandomValues=="function")return ks.getRandomValues(new Uint8Array(t));if(ks&&typeof ks.randomBytes=="function")return ks.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function _C(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}let IC=class extends EC{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ad(this.buffer)}update(e){wg(this);const{view:r,buffer:n,blockLen:i}=this;e=lb(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Ad(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){wg(this),bC(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;_C(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Ad(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};const El=BigInt(2**32-1),Tf=BigInt(32);function hb(t,e=!1){return e?{h:Number(t&El),l:Number(t>>Tf&El)}:{h:Number(t>>Tf&El)|0,l:Number(t&El)|0}}function AC(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=hb(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const $C=(t,e)=>BigInt(t>>>0)<<Tf|BigInt(e>>>0),SC=(t,e,r)=>t>>>r,NC=(t,e,r)=>t<<32-r|e>>>r,OC=(t,e,r)=>t>>>r|e<<32-r,PC=(t,e,r)=>t<<32-r|e>>>r,kC=(t,e,r)=>t<<64-r|e>>>r-32,TC=(t,e,r)=>t>>>r-32|e<<64-r,RC=(t,e)=>e,LC=(t,e)=>t,DC=(t,e,r)=>t<<r|e>>>32-r,BC=(t,e,r)=>e<<r|t>>>32-r,MC=(t,e,r)=>e<<r-32|t>>>64-r,UC=(t,e,r)=>t<<r-32|e>>>64-r;function jC(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}const zC=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),FC=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,HC=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),qC=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,WC=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),VC=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,ye={fromBig:hb,split:AC,toBig:$C,shrSH:SC,shrSL:NC,rotrSH:OC,rotrSL:PC,rotrBH:kC,rotrBL:TC,rotr32H:RC,rotr32L:LC,rotlSH:DC,rotlSL:BC,rotlBH:MC,rotlBL:UC,add:jC,add3L:zC,add3H:FC,add4L:HC,add4H:qC,add5H:VC,add5L:WC},[KC,GC]=ye.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Xn=new Uint32Array(80),Qn=new Uint32Array(80);let ZC=class extends IC{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:h,Fl:d,Gh:p,Gl:f,Hh:g,Hl:w}=this;return[e,r,n,i,s,o,a,c,l,u,h,d,p,f,g,w]}set(e,r,n,i,s,o,a,c,l,u,h,d,p,f,g,w){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=h|0,this.Fl=d|0,this.Gh=p|0,this.Gl=f|0,this.Hh=g|0,this.Hl=w|0}process(e,r){for(let C=0;C<16;C++,r+=4)Xn[C]=e.getUint32(r),Qn[C]=e.getUint32(r+=4);for(let C=16;C<80;C++){const E=Xn[C-15]|0,A=Qn[C-15]|0,S=ye.rotrSH(E,A,1)^ye.rotrSH(E,A,8)^ye.shrSH(E,A,7),T=ye.rotrSL(E,A,1)^ye.rotrSL(E,A,8)^ye.shrSL(E,A,7),k=Xn[C-2]|0,I=Qn[C-2]|0,B=ye.rotrSH(k,I,19)^ye.rotrBH(k,I,61)^ye.shrSH(k,I,6),D=ye.rotrSL(k,I,19)^ye.rotrBL(k,I,61)^ye.shrSL(k,I,6),M=ye.add4L(T,D,Qn[C-7],Qn[C-16]),W=ye.add4H(M,S,B,Xn[C-7],Xn[C-16]);Xn[C]=W|0,Qn[C]=M|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:h,El:d,Fh:p,Fl:f,Gh:g,Gl:w,Hh:v,Hl:b}=this;for(let C=0;C<80;C++){const E=ye.rotrSH(h,d,14)^ye.rotrSH(h,d,18)^ye.rotrBH(h,d,41),A=ye.rotrSL(h,d,14)^ye.rotrSL(h,d,18)^ye.rotrBL(h,d,41),S=h&p^~h&g,T=d&f^~d&w,k=ye.add5L(b,A,T,GC[C],Qn[C]),I=ye.add5H(k,v,E,S,KC[C],Xn[C]),B=k|0,D=ye.rotrSH(n,i,28)^ye.rotrBH(n,i,34)^ye.rotrBH(n,i,39),M=ye.rotrSL(n,i,28)^ye.rotrBL(n,i,34)^ye.rotrBL(n,i,39),W=n&s^n&a^s&a,$=i&o^i&c^o&c;v=g|0,b=w|0,g=p|0,w=f|0,p=h|0,f=d|0,{h,l:d}=ye.add(l|0,u|0,I|0,B|0),l=a|0,u=c|0,a=s|0,c=o|0,s=n|0,o=i|0;const m=ye.add3L(B,M,$);n=ye.add3H(m,I,D,W),i=m|0}({h:n,l:i}=ye.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=ye.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=ye.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=ye.add(this.Dh|0,this.Dl|0,l|0,u|0),{h,l:d}=ye.add(this.Eh|0,this.El|0,h|0,d|0),{h:p,l:f}=ye.add(this.Fh|0,this.Fl|0,p|0,f|0),{h:g,l:w}=ye.add(this.Gh|0,this.Gl|0,g|0,w|0),{h:v,l:b}=ye.add(this.Hh|0,this.Hl|0,v|0,b|0),this.set(n,i,s,o,a,c,l,u,h,d,p,f,g,w,v,b)}roundClean(){Xn.fill(0),Qn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const YC=xC(()=>new ZC);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const H0=BigInt(0),db=BigInt(1),JC=BigInt(2);function q0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function W0(t){if(!q0(t))throw new Error("Uint8Array expected")}function $d(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const XC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function V0(t){W0(t);let e="";for(let r=0;r<t.length;r++)e+=XC[t[r]];return e}function pb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?H0:BigInt("0x"+t)}const En={_0:48,_9:57,A:65,F:70,a:97,f:102};function mg(t){if(t>=En._0&&t<=En._9)return t-En._0;if(t>=En.A&&t<=En.F)return t-(En.A-10);if(t>=En.a&&t<=En.f)return t-(En.a-10)}function fb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){const o=mg(t.charCodeAt(s)),a=mg(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function QC(t){return pb(V0(t))}function ju(t){return W0(t),pb(V0(Uint8Array.from(t).reverse()))}function gb(t,e){return fb(t.toString(16).padStart(e*2,"0"))}function Rf(t,e){return gb(t,e).reverse()}function xn(t,e,r){let n;if(typeof e=="string")try{n=fb(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(q0(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function vg(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];W0(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}const Sd=t=>typeof t=="bigint"&&H0<=t;function e9(t,e,r){return Sd(t)&&Sd(e)&&Sd(r)&&e<=t&&t<r}function ha(t,e,r,n){if(!e9(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function t9(t){let e;for(e=0;t>H0;t>>=db,e+=1);return e}const r9=t=>(JC<<BigInt(t-1))-db,n9={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||q0(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function K0(t,e,r={}){const n=(i,s,o)=>{const a=n9[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+c)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return t}function yg(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(i!==void 0)return i;const s=t(r,...n);return e.set(r,s),s}}const $t=BigInt(0),ot=BigInt(1),Yi=BigInt(2),i9=BigInt(3),Lf=BigInt(4),bg=BigInt(5),Cg=BigInt(8);function wt(t,e){const r=t%e;return r>=$t?r:e+r}function s9(t,e,r){if(e<$t)throw new Error("invalid exponent, negatives unsupported");if(r<=$t)throw new Error("invalid modulus");if(r===ot)return $t;let n=ot;for(;e>$t;)e&ot&&(n=n*t%r),t=t*t%r,e>>=ot;return n}function Qr(t,e,r){let n=t;for(;e-- >$t;)n*=n,n%=r;return n}function Eg(t,e){if(t===$t)throw new Error("invert: expected non-zero number");if(e<=$t)throw new Error("invert: expected positive modulus, got "+e);let r=wt(t,e),n=e,i=$t,s=ot;for(;r!==$t;){const o=n/r,a=n%r,c=i-s*o;n=r,r=a,i=s,s=c}if(n!==ot)throw new Error("invert: does not exist");return wt(i,e)}function o9(t){const e=(t-ot)/Yi;let r,n,i;for(r=t-ot,n=0;r%Yi===$t;r/=Yi,n++);for(i=Yi;i<t&&s9(i,e,t)!==t-ot;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(t+ot)/Lf;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(r+ot)/Yi;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=n,l=o.pow(o.mul(o.ONE,i),r),u=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let f=o.sqr(h);d<c&&!o.eql(f,o.ONE);d++)f=o.sqr(f);const p=o.pow(l,ot<<BigInt(c-d-1));l=o.sqr(p),u=o.mul(u,p),h=o.mul(h,l),c=d}return u}}function a9(t){if(t%Lf===i9){const e=(t+ot)/Lf;return function(r,n){const i=r.pow(n,e);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}}if(t%Cg===bg){const e=(t-bg)/Cg;return function(r,n){const i=r.mul(n,Yi),s=r.pow(i,e),o=r.mul(n,s),a=r.mul(r.mul(o,Yi),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),n))throw new Error("Cannot find square root");return c}}return o9(t)}const c9=(t,e)=>(wt(t,e)&ot)===ot,l9=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function u9(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=l9.reduce((n,i)=>(n[i]="function",n),e);return K0(t,r)}function h9(t,e,r){if(r<$t)throw new Error("invalid exponent, negatives unsupported");if(r===$t)return t.ONE;if(r===ot)return e;let n=t.ONE,i=e;for(;r>$t;)r&ot&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ot;return n}function d9(t,e){const r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function wb(t,e){const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function mb(t,e,r=!1,n={}){if(t<=$t)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:s}=wb(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:i,BYTES:s,MASK:r9(i),ZERO:$t,ONE:ot,create:c=>wt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return $t<=c&&c<t},is0:c=>c===$t,isOdd:c=>(c&ot)===ot,neg:c=>wt(-c,t),eql:(c,l)=>c===l,sqr:c=>wt(c*c,t),add:(c,l)=>wt(c+l,t),sub:(c,l)=>wt(c-l,t),mul:(c,l)=>wt(c*l,t),pow:(c,l)=>h9(a,c,l),div:(c,l)=>wt(c*Eg(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Eg(c,t),sqrt:n.sqrt||(c=>(o||(o=a9(t)),o(a,c))),invertBatch:c=>d9(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Rf(c,s):gb(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?ju(c):QC(c)}});return Object.freeze(a)}const xg=BigInt(0),xl=BigInt(1);function Nd(t,e){const r=e.negate();return t?r:e}function vb(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Od(t,e){vb(t,e);const r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function p9(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function f9(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}const Pd=new WeakMap,yb=new WeakMap;function kd(t){return yb.get(t)||1}function g9(t,e){return{constTimeNegate:Nd,hasPrecomputes(r){return kd(r)!==1},unsafeLadder(r,n,i=t.ZERO){let s=r;for(;n>xg;)n&xl&&(i=i.add(s)),s=s.double(),n>>=xl;return i},precomputeWindow(r,n){const{windows:i,windowSize:s}=Od(n,e),o=[];let a=r,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,n,i){const{windows:s,windowSize:o}=Od(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,h=BigInt(r);for(let d=0;d<s;d++){const p=d*o;let f=Number(i&l);i>>=h,f>o&&(f-=u,i+=xl);const g=p,w=p+Math.abs(f)-1,v=d%2!==0,b=f<0;f===0?c=c.add(Nd(v,n[g])):a=a.add(Nd(b,n[w]))}return{p:a,f:c}},wNAFUnsafe(r,n,i,s=t.ZERO){const{windows:o,windowSize:a}=Od(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let h=0;h<o;h++){const d=h*a;if(i===xg)break;let p=Number(i&c);if(i>>=u,p>a&&(p-=l,i+=xl),p===0)continue;let f=n[d+Math.abs(p)-1];p<0&&(f=f.negate()),s=s.add(f)}return s},getPrecomputes(r,n,i){let s=Pd.get(n);return s||(s=this.precomputeWindow(n,r),r!==1&&Pd.set(n,i(s))),s},wNAFCached(r,n,i){const s=kd(r);return this.wNAF(s,this.getPrecomputes(s,r,i),n)},wNAFCachedUnsafe(r,n,i,s){const o=kd(r);return o===1?this.unsafeLadder(r,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,i),n,s)},setWindowSize(r,n){vb(n,e),yb.set(r,n),Pd.delete(r)}}}function w9(t,e,r,n){if(p9(r,t),f9(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,s=t9(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let p=0;p<n.length;p++){const f=n[p],g=Number(f>>BigInt(h)&BigInt(a));c[g]=c[g].add(r[p])}let d=i;for(let p=c.length-1,f=i;p>0;p--)f=f.add(c[p]),d=d.add(f);if(u=u.add(d),h!==0)for(let p=0;p<o;p++)u=u.double()}return u}function m9(t){return u9(t.Fp),K0(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wb(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Mr=BigInt(0),Zt=BigInt(1),_l=BigInt(2),v9=BigInt(8),y9={zip215:!0};function b9(t){const e=m9(t);return K0(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function C9(t){const e=b9(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=_l<<BigInt(a*8)-Zt,u=r.create,h=mb(e.n,e.nBitLength),d=e.uvRatio||((m,y)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(y))}}catch{return{isValid:!1,value:Mr}}}),p=e.adjustScalarBytes||(m=>m),f=e.domain||((m,y,x)=>{if($d("phflag",x),y.length||x)throw new Error("Contexts/pre-hash are not supported");return m});function g(m,y){ha("coordinate "+m,y,Mr,l)}function w(m){if(!(m instanceof C))throw new Error("ExtendedPoint expected")}const v=yg((m,y)=>{const{ex:x,ey:_,ez:O}=m,R=m.is0();y==null&&(y=R?v9:r.inv(O));const U=u(x*y),j=u(_*y),V=u(O*y);if(R)return{x:Mr,y:Zt};if(V!==Zt)throw new Error("invZ was invalid");return{x:U,y:j}}),b=yg(m=>{const{a:y,d:x}=e;if(m.is0())throw new Error("bad point: ZERO");const{ex:_,ey:O,ez:R,et:U}=m,j=u(_*_),V=u(O*O),z=u(R*R),te=u(z*z),he=u(j*y),Ce=u(z*u(he+V)),we=u(te+u(x*u(j*V)));if(Ce!==we)throw new Error("bad point: equation left != right (1)");const ge=u(_*O),Ee=u(R*U);if(ge!==Ee)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(y,x,_,O){this.ex=y,this.ey=x,this.ez=_,this.et=O,g("x",y),g("y",x),g("z",_),g("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof C)throw new Error("extended point not allowed");const{x,y:_}=y||{};return g("x",x),g("y",_),new C(x,_,Zt,u(x*_))}static normalizeZ(y){const x=r.invertBatch(y.map(_=>_.ez));return y.map((_,O)=>_.toAffine(x[O])).map(C.fromAffine)}static msm(y,x){return w9(C,h,y,x)}_setWindowSize(y){S.setWindowSize(this,y)}assertValidity(){b(this)}equals(y){w(y);const{ex:x,ey:_,ez:O}=this,{ex:R,ey:U,ez:j}=y,V=u(x*j),z=u(R*O),te=u(_*j),he=u(U*O);return V===z&&te===he}is0(){return this.equals(C.ZERO)}negate(){return new C(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:y}=e,{ex:x,ey:_,ez:O}=this,R=u(x*x),U=u(_*_),j=u(_l*u(O*O)),V=u(y*R),z=x+_,te=u(u(z*z)-R-U),he=V+U,Ce=he-j,we=V-U,ge=u(te*Ce),Ee=u(he*we),Se=u(te*we),Le=u(Ce*he);return new C(ge,Ee,Le,Se)}add(y){w(y);const{a:x,d:_}=e,{ex:O,ey:R,ez:U,et:j}=this,{ex:V,ey:z,ez:te,et:he}=y;if(x===BigInt(-1)){const U1=u((R-O)*(z+V)),j1=u((R+O)*(z-V)),bd=u(j1-U1);if(bd===Mr)return this.double();const z1=u(U*_l*he),F1=u(j*_l*te),H1=F1+z1,q1=j1+U1,W1=F1-z1,w6=u(H1*bd),m6=u(q1*W1),v6=u(H1*W1),y6=u(bd*q1);return new C(w6,m6,y6,v6)}const Ce=u(O*V),we=u(R*z),ge=u(j*_*he),Ee=u(U*te),Se=u((O+R)*(V+z)-Ce-we),Le=Ee-ge,nt=Ee+ge,yt=u(we-x*Ce),bn=u(Se*Le),p6=u(nt*yt),f6=u(Se*yt),g6=u(Le*nt);return new C(bn,p6,g6,f6)}subtract(y){return this.add(y.negate())}wNAF(y){return S.wNAFCached(this,y,C.normalizeZ)}multiply(y){const x=y;ha("scalar",x,Zt,n);const{p:_,f:O}=this.wNAF(x);return C.normalizeZ([_,O])[0]}multiplyUnsafe(y,x=C.ZERO){const _=y;return ha("scalar",_,Mr,n),_===Mr?A:this.is0()||_===Zt?this:S.wNAFCachedUnsafe(this,_,C.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return S.unsafeLadder(this,n).is0()}toAffine(y){return v(this,y)}clearCofactor(){const{h:y}=e;return y===Zt?this:this.multiplyUnsafe(y)}static fromHex(y,x=!1){const{d:_,a:O}=e,R=r.BYTES;y=xn("pointHex",y,R),$d("zip215",x);const U=y.slice(),j=y[R-1];U[R-1]=j&-129;const V=ju(U),z=x?l:r.ORDER;ha("pointHex.y",V,Mr,z);const te=u(V*V),he=u(te-Zt),Ce=u(_*te-O);let{isValid:we,value:ge}=d(he,Ce);if(!we)throw new Error("Point.fromHex: invalid y coordinate");const Ee=(ge&Zt)===Zt,Se=(j&128)!==0;if(!x&&ge===Mr&&Se)throw new Error("Point.fromHex: x=0 and x_0=1");return Se!==Ee&&(ge=u(-ge)),C.fromAffine({x:ge,y:V})}static fromPrivateKey(y){return I(y).point}toRawBytes(){const{x:y,y:x}=this.toAffine(),_=Rf(x,r.BYTES);return _[_.length-1]|=y&Zt?128:0,_}toHex(){return V0(this.toRawBytes())}}C.BASE=new C(e.Gx,e.Gy,Zt,u(e.Gx*e.Gy)),C.ZERO=new C(Mr,Zt,Zt,Mr);const{BASE:E,ZERO:A}=C,S=g9(C,a*8);function T(m){return wt(m,n)}function k(m){return T(ju(m))}function I(m){const y=r.BYTES;m=xn("private key",m,y);const x=xn("hashed private key",s(m),2*y),_=p(x.slice(0,y)),O=x.slice(y,2*y),R=k(_),U=E.multiply(R),j=U.toRawBytes();return{head:_,prefix:O,scalar:R,point:U,pointBytes:j}}function B(m){return I(m).pointBytes}function D(m=new Uint8Array,...y){const x=vg(...y);return k(s(f(x,xn("context",m),!!i)))}function M(m,y,x={}){m=xn("message",m),i&&(m=i(m));const{prefix:_,scalar:O,pointBytes:R}=I(y),U=D(x.context,_,m),j=E.multiply(U).toRawBytes(),V=D(x.context,j,R,m),z=T(U+V*O);ha("signature.s",z,Mr,n);const te=vg(j,Rf(z,r.BYTES));return xn("result",te,r.BYTES*2)}const W=y9;function $(m,y,x,_=W){const{context:O,zip215:R}=_,U=r.BYTES;m=xn("signature",m,2*U),y=xn("message",y),x=xn("publicKey",x,U),R!==void 0&&$d("zip215",R),i&&(y=i(y));const j=ju(m.slice(U,2*U));let V,z,te;try{V=C.fromHex(x,R),z=C.fromHex(m.slice(0,U),R),te=E.multiplyUnsafe(j)}catch{return!1}if(!R&&V.isSmallOrder())return!1;const he=D(O,z.toRawBytes(),V.toRawBytes(),y);return z.add(V.multiplyUnsafe(he)).subtract(te).clearCofactor().equals(C.ZERO)}return E._setWindowSize(8),{CURVE:e,getPublicKey:B,sign:M,verify:$,ExtendedPoint:C,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>o(r.BYTES),precompute(m=8,y=C.BASE){return y._setWindowSize(m),y.multiply(BigInt(3)),y}}}}BigInt(0),BigInt(1);const G0=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_g=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const E9=BigInt(1),Ig=BigInt(2);BigInt(3);const x9=BigInt(5),_9=BigInt(8);function I9(t){const e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=G0,o=t*t%s*t%s,a=Qr(o,Ig,s)*o%s,c=Qr(a,E9,s)*t%s,l=Qr(c,x9,s)*c%s,u=Qr(l,e,s)*l%s,h=Qr(u,r,s)*u%s,d=Qr(h,n,s)*h%s,p=Qr(d,i,s)*d%s,f=Qr(p,i,s)*d%s,g=Qr(f,e,s)*l%s;return{pow_p_5_8:Qr(g,Ig,s)*t%s,b2:o}}function A9(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function $9(t,e){const r=G0,n=wt(e*e*e,r),i=wt(n*n*e,r),s=I9(t*i).pow_p_5_8;let o=wt(t*n*s,r);const a=wt(e*o*o,r),c=o,l=wt(o*_g,r),u=a===t,h=a===wt(-t,r),d=a===wt(-t*_g,r);return u&&(o=c),(h||d)&&(o=l),c9(o,r)&&(o=wt(-o,r)),{isValid:u||h,value:o}}const S9=mb(G0,void 0,!0),N9={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:S9,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_9,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:YC,randomBytes:ub,adjustScalarBytes:A9,uvRatio:$9},bb=C9(N9),O9="EdDSA",P9="JWT",sh=".",Rh="base64url",Cb="utf8",Eb="utf8",k9=":",T9="did",R9="key",Ag="base58btc",L9="z",D9="K36",B9=32;function Z0(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function xb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Z0(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function _b(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=xb(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return Z0(r)}function M9(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,w=0,v=0,b=f.length;v!==b&&f[v]===0;)v++,g++;for(var C=(b-v)*u+1>>>0,E=new Uint8Array(C);v!==b;){for(var A=f[v],S=0,T=C-1;(A!==0||S<w)&&T!==-1;T--,S++)A+=256*E[T]>>>0,E[T]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=S,v++}for(var k=C-w;k!==C&&E[k]===0;)k++;for(var I=c.repeat(g);k<C;++k)I+=t.charAt(E[k]);return I}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var w=0,v=0;f[g]===c;)w++,g++;for(var b=(f.length-g)*l+1>>>0,C=new Uint8Array(b);f[g];){var E=r[f.charCodeAt(g)];if(E===255)return;for(var A=0,S=b-1;(E!==0||A<v)&&S!==-1;S--,A++)E+=a*C[S]>>>0,C[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");v=A,g++}if(f[g]!==" "){for(var T=b-v;T!==b&&C[T]===0;)T++;for(var k=new Uint8Array(w+(b-T)),I=w;T!==b;)k[I++]=C[T++];return k}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:p}}var U9=M9,j9=U9;const Ib=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")},z9=t=>new TextEncoder().encode(t),F9=t=>new TextDecoder().decode(t);let H9=class{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")}},q9=class{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 Ab(this,e)}},W9=class{constructor(e){this.decoders=e}or(e){return Ab(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 Ab=(t,e)=>new W9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let V9=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new H9(e,r,n),this.decoder=new q9(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Lh=({name:t,prefix:e,encode:r,decode:n})=>new V9(t,e,r,n),Qc=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=j9(r,e);return Lh({prefix:t,name:e,encode:n,decode:s=>Ib(i(s))})},K9=(t,e,r,n)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},G9=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Rt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Lh({prefix:e,name:t,encode(i){return G9(i,n,r)},decode(i){return K9(i,n,r,t)}}),Z9=Lh({prefix:"\0",name:"identity",encode:t=>F9(t),decode:t=>z9(t)});var Y9=Object.freeze({__proto__:null,identity:Z9});const J9=Rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var X9=Object.freeze({__proto__:null,base2:J9});const Q9=Rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var e7=Object.freeze({__proto__:null,base8:Q9});const t7=Qc({prefix:"9",name:"base10",alphabet:"0123456789"});var r7=Object.freeze({__proto__:null,base10:t7});const n7=Rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),i7=Rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var s7=Object.freeze({__proto__:null,base16:n7,base16upper:i7});const o7=Rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),a7=Rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),c7=Rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),l7=Rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),u7=Rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),h7=Rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),d7=Rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),p7=Rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),f7=Rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var g7=Object.freeze({__proto__:null,base32:o7,base32upper:a7,base32pad:c7,base32padupper:l7,base32hex:u7,base32hexupper:h7,base32hexpad:d7,base32hexpadupper:p7,base32z:f7});const w7=Qc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),m7=Qc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var v7=Object.freeze({__proto__:null,base36:w7,base36upper:m7});const y7=Qc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),b7=Qc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var C7=Object.freeze({__proto__:null,base58btc:y7,base58flickr:b7});const E7=Rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),x7=Rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_7=Rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),I7=Rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var A7=Object.freeze({__proto__:null,base64:E7,base64pad:x7,base64url:_7,base64urlpad:I7});const $b=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),$7=$b.reduce((t,e,r)=>(t[r]=e,t),[]),S7=$b.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function N7(t){return t.reduce((e,r)=>(e+=$7[r],e),"")}function O7(t){const e=[];for(const r of t){const n=S7[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const P7=Lh({prefix:"🚀",name:"base256emoji",encode:N7,decode:O7});var k7=Object.freeze({__proto__:null,base256emoji:P7}),T7=Sb,$g=128,R7=127,L7=~R7,D7=Math.pow(2,31);function Sb(t,e,r){e=e||[],r=r||0;for(var n=r;t>=D7;)e[r++]=t&255|$g,t/=128;for(;t&L7;)e[r++]=t&255|$g,t>>>=7;return e[r]=t|0,Sb.bytes=r-n+1,e}var B7=Df,M7=128,Sg=127;function Df(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw Df.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Sg)<<i:(o&Sg)*Math.pow(2,i),i+=7}while(o>=M7);return Df.bytes=s-n,r}var U7=Math.pow(2,7),j7=Math.pow(2,14),z7=Math.pow(2,21),F7=Math.pow(2,28),H7=Math.pow(2,35),q7=Math.pow(2,42),W7=Math.pow(2,49),V7=Math.pow(2,56),K7=Math.pow(2,63),G7=function(t){return t<U7?1:t<j7?2:t<z7?3:t<F7?4:t<H7?5:t<q7?6:t<W7?7:t<V7?8:t<K7?9:10},Z7={encode:T7,decode:B7,encodingLength:G7},Nb=Z7;const Ng=(t,e,r=0)=>(Nb.encode(t,e,r),e),Og=t=>Nb.encodingLength(t),Bf=(t,e)=>{const r=e.byteLength,n=Og(t),i=n+Og(r),s=new Uint8Array(i+r);return Ng(t,s,0),Ng(r,s,n),s.set(e,i),new Y7(t,r,e,s)};let Y7=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};const Ob=({name:t,code:e,encode:r})=>new J7(t,e,r);let J7=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Bf(this.code,r):r.then(n=>Bf(this.code,n))}else throw Error("Unknown type, must be binary type")}};const Pb=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),X7=Ob({name:"sha2-256",code:18,encode:Pb("SHA-256")}),Q7=Ob({name:"sha2-512",code:19,encode:Pb("SHA-512")});var eE=Object.freeze({__proto__:null,sha256:X7,sha512:Q7});const kb=0,tE="identity",Tb=Ib,rE=t=>Bf(kb,Tb(t)),nE={code:kb,name:tE,encode:Tb,digest:rE};var iE=Object.freeze({__proto__:null,identity:nE});new TextEncoder,new TextDecoder;const Pg={...Y9,...X9,...e7,...r7,...s7,...g7,...v7,...C7,...A7,...k7};({...eE,...iE});function Rb(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const kg=Rb("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Td=Rb("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=xb(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Lb={utf8:kg,"utf-8":kg,hex:Pg.base16,latin1:Td,ascii:Td,binary:Td,...Pg};function Dh(t,e="utf8"){const r=Lb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Xo(t,e="utf8"){const r=Lb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Z0(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Tg(t){return fs(Dh(Xo(t,Rh),Cb))}function oh(t){return Dh(Xo(Gn(t),Cb),Rh)}function Db(t){const e=Xo(D9,Ag),r=L9+Dh(_b([e,t]),Ag);return[T9,R9,r].join(k9)}function sE(t){return Dh(t,Rh)}function oE(t){return Xo(t,Rh)}function aE(t){return Xo([oh(t.header),oh(t.payload)].join(sh),Eb)}function cE(t){return[oh(t.header),oh(t.payload),sE(t.signature)].join(sh)}function Mf(t){const e=t.split(sh),r=Tg(e[0]),n=Tg(e[1]),i=oE(e[2]),s=Xo(e.slice(0,2).join(sh),Eb);return{header:r,payload:n,signature:i,data:s}}function Rg(t=ub(B9)){const e=bb.getPublicKey(t);return{secretKey:_b([t,e]),publicKey:e}}async function lE(t,e,r,n,i=K.fromMiliseconds(Date.now())){const s={alg:O9,typ:P9},o=Db(n.publicKey),a=i+r,c={iss:o,sub:t,aud:e,iat:i,exp:a},l=aE({header:s,payload:c}),u=bb.sign(l,n.secretKey.slice(0,32));return cE({header:s,payload:c,signature:u})}function Bb(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function tc(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=Bb(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function uE(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,w=0,v=0,b=f.length;v!==b&&f[v]===0;)v++,g++;for(var C=(b-v)*u+1>>>0,E=new Uint8Array(C);v!==b;){for(var A=f[v],S=0,T=C-1;(A!==0||S<w)&&T!==-1;T--,S++)A+=256*E[T]>>>0,E[T]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=S,v++}for(var k=C-w;k!==C&&E[k]===0;)k++;for(var I=c.repeat(g);k<C;++k)I+=t.charAt(E[k]);return I}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var w=0,v=0;f[g]===c;)w++,g++;for(var b=(f.length-g)*l+1>>>0,C=new Uint8Array(b);f[g];){var E=r[f.charCodeAt(g)];if(E===255)return;for(var A=0,S=b-1;(E!==0||A<v)&&S!==-1;S--,A++)E+=a*C[S]>>>0,C[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");v=A,g++}if(f[g]!==" "){for(var T=b-v;T!==b&&C[T]===0;)T++;for(var k=new Uint8Array(w+(b-T)),I=w;T!==b;)k[I++]=C[T++];return k}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:p}}var hE=uE,dE=hE;const pE=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")},fE=t=>new TextEncoder().encode(t),gE=t=>new TextDecoder().decode(t);class wE{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 mE{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 Mb(this,e)}}class vE{constructor(e){this.decoders=e}or(e){return Mb(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 Mb=(t,e)=>new vE({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class yE{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new wE(e,r,n),this.decoder=new mE(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Bh=({name:t,prefix:e,encode:r,decode:n})=>new yE(t,e,r,n),el=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=dE(r,e);return Bh({prefix:t,name:e,encode:n,decode:s=>pE(i(s))})},bE=(t,e,r,n)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},CE=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Lt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Bh({prefix:e,name:t,encode(i){return CE(i,n,r)},decode(i){return bE(i,n,r,t)}}),EE=Bh({prefix:"\0",name:"identity",encode:t=>gE(t),decode:t=>fE(t)}),xE=Object.freeze(Object.defineProperty({__proto__:null,identity:EE},Symbol.toStringTag,{value:"Module"})),_E=Lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),IE=Object.freeze(Object.defineProperty({__proto__:null,base2:_E},Symbol.toStringTag,{value:"Module"})),AE=Lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$E=Object.freeze(Object.defineProperty({__proto__:null,base8:AE},Symbol.toStringTag,{value:"Module"})),SE=el({prefix:"9",name:"base10",alphabet:"0123456789"}),NE=Object.freeze(Object.defineProperty({__proto__:null,base10:SE},Symbol.toStringTag,{value:"Module"})),OE=Lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),PE=Lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),kE=Object.freeze(Object.defineProperty({__proto__:null,base16:OE,base16upper:PE},Symbol.toStringTag,{value:"Module"})),TE=Lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),RE=Lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),LE=Lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),DE=Lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),BE=Lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ME=Lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),UE=Lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jE=Lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zE=Lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),FE=Object.freeze(Object.defineProperty({__proto__:null,base32:TE,base32hex:BE,base32hexpad:UE,base32hexpadupper:jE,base32hexupper:ME,base32pad:LE,base32padupper:DE,base32upper:RE,base32z:zE},Symbol.toStringTag,{value:"Module"})),HE=el({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qE=el({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),WE=Object.freeze(Object.defineProperty({__proto__:null,base36:HE,base36upper:qE},Symbol.toStringTag,{value:"Module"})),VE=el({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KE=el({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),GE=Object.freeze(Object.defineProperty({__proto__:null,base58btc:VE,base58flickr:KE},Symbol.toStringTag,{value:"Module"})),ZE=Lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),YE=Lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),JE=Lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),XE=Lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),QE=Object.freeze(Object.defineProperty({__proto__:null,base64:ZE,base64pad:YE,base64url:JE,base64urlpad:XE},Symbol.toStringTag,{value:"Module"})),Ub=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ex=Ub.reduce((t,e,r)=>(t[r]=e,t),[]),tx=Ub.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function rx(t){return t.reduce((e,r)=>(e+=ex[r],e),"")}function nx(t){const e=[];for(const r of t){const n=tx[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const ix=Bh({prefix:"🚀",name:"base256emoji",encode:rx,decode:nx}),sx=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:ix},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Lg={...xE,...IE,...$E,...NE,...kE,...FE,...WE,...GE,...QE,...sx};function jb(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Dg=jb("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Rd=jb("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Bb(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),zb={utf8:Dg,"utf-8":Dg,hex:Lg.base16,latin1:Rd,ascii:Rd,binary:Rd,...Lg};function Lr(t,e="utf8"){const r=zb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function or(t,e="utf8"){const r=zb[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}const ox={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var ax={VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm"};const cx=":";function bo(t){const[e,r]=t.split(cx);return{namespace:e,reference:r}}function Bg(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function Fb(t,e){return t.includes(":")?[t]:e.chains||[]}var lx=Object.defineProperty,ux=Object.defineProperties,hx=Object.getOwnPropertyDescriptors,Mg=Object.getOwnPropertySymbols,dx=Object.prototype.hasOwnProperty,px=Object.prototype.propertyIsEnumerable,Ug=(t,e,r)=>e in t?lx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jg=(t,e)=>{for(var r in e||(e={}))dx.call(e,r)&&Ug(t,r,e[r]);if(Mg)for(var r of Mg(e))px.call(e,r)&&Ug(t,r,e[r]);return t},fx=(t,e)=>ux(t,hx(e));const gx="ReactNative",yr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},wx="js";function ah(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ii(){return!Xc()&&!!j0()&&navigator.product===gx}function mx(){return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function vx(){return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function tl(){return!ah()&&!!j0()&&!!Xc()}function rl(){return Ii()?yr.reactNative:ah()?yr.node:tl()?yr.browser:yr.unknown}function zg(){var t;try{return Ii()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function yx(t,e){const r=new URLSearchParams(t);for(const n of Object.keys(e).sort())if(e.hasOwnProperty(n)){const i=e[n];i!==void 0&&r.set(n,i)}return r.toString()}function bx(t){var e,r;const n=Hb();try{return t!=null&&t.url&&n.url&&t.url!==n.url&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${n.url}. This is probably unintended and can lead to issues.`),t.url=n.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),fx(jg(jg({},n),t),{url:(t==null?void 0:t.url)||n.url,name:(t==null?void 0:t.name)||n.name,description:(t==null?void 0:t.description)||n.description,icons:(r=t==null?void 0:t.icons)!=null&&r.length&&t.icons.length>0?t.icons:n.icons})}catch(i){return console.warn("Error populating app metadata",i),t||n}}function Hb(){return Zy()||{name:"",description:"",url:"",icons:[""]}}function Cx(){if(rl()===yr.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:n}=global.Platform;return[r,n].join("-")}const t=D6();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Ex(){var t;const e=rl();return e===yr.browser?[e,((t=Gy())==null?void 0:t.host)||"unknown"].join(":"):e}function qb(t,e,r){const n=Cx(),i=Ex();return[[t,e].join("-"),[wx,r].join("-"),n,i].join("/")}function xx({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=r.split("?"),u=qb(t,e,n),h={auth:i,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=yx(l[1]||"",h);return l[0]+"?"+d}function rs(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Uf(t){return Object.fromEntries(t.entries())}function jf(t){return new Map(Object.entries(t))}function Ki(t=K.FIVE_MINUTES,e){const r=K.toMiliseconds(t||K.FIVE_MINUTES);let n,i,s,o;return{resolve:a=>{s&&n&&(clearTimeout(s),n(a),o=Promise.resolve(a))},reject:a=>{s&&i&&(clearTimeout(s),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},r),n=a,i=c})}}function pi(t,e,r){return new Promise(async(n,i)=>{const s=setTimeout(()=>i(new Error(r)),e);try{const o=await t;n(o)}catch(o){i(o)}clearTimeout(s)})}function Wb(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function _x(t){return Wb("topic",t)}function Ix(t){return Wb("id",t)}function Vb(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function pt(t,e){return K.fromMiliseconds(Date.now()+K.toMiliseconds(t))}function ci(t){return Date.now()>=K.toMiliseconds(t)}function Re(t,e){return`${t}${e?`:${e}`:""}`}function zu(t=[],e=[]){return[...new Set([...t,...e])]}async function Ax({id:t,topic:e,wcDeepLink:r}){var n;try{if(!r)return;const i=typeof r=="string"?JSON.parse(r):r,s=i==null?void 0:i.href;if(typeof s!="string")return;const o=$x(s,t,e),a=rl();if(a===yr.browser){if(!((n=Xc())!=null&&n.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Sx(o)}else a===yr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function $x(t,e,r){const n=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${s}${kx(n,!0)}`}else i=`${i}/wc?${n}`;return i}function Sx(t){let e="_self";Px()?e="_top":(Ox()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Nx(t,e){let r="";try{if(tl()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(n){console.error(n)}return r}function Fg(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),n=r.indexOf(e);return r[n+2]}function Hg(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Y0(){return typeof process<"u"&&ax.IS_VITEST==="true"}function Ox(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Px(){try{return window.self!==window.top}catch{return!1}}function kx(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Kb(t){return Buffer.from(t,"base64").toString("utf-8")}function Tx(t){return new Promise(e=>setTimeout(e,t))}function fc(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Rx(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function nl(t,...e){if(!Rx(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function J0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fc(t.outputLen),fc(t.blockLen)}function Po(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gb(t,e){nl(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Il=BigInt(2**32-1),qg=BigInt(32);function Lx(t,e=!1){return e?{h:Number(t&Il),l:Number(t>>qg&Il)}:{h:Number(t>>qg&Il)|0,l:Number(t&Il)|0}}function Dx(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Lx(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const Bx=(t,e,r)=>t<<r|e>>>32-r,Mx=(t,e,r)=>e<<r|t>>>32-r,Ux=(t,e,r)=>e<<r-32|t>>>64-r,jx=(t,e,r)=>t<<r-32|e>>>64-r,Ts=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function zx(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ld(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function en(t,e){return t<<32-e|t>>>e}const Wg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fx(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Vg(t){for(let e=0;e<t.length;e++)t[e]=Fx(t[e])}function Hx(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ko(t){return typeof t=="string"&&(t=Hx(t)),nl(t),t}function qx(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];nl(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}let X0=class{clone(){return this._cloneInto()}};function Zb(t){const e=n=>t().update(ko(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Qo(t=32){if(Ts&&typeof Ts.getRandomValues=="function")return Ts.getRandomValues(new Uint8Array(t));if(Ts&&typeof Ts.randomBytes=="function")return Ts.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Yb=[],Jb=[],Xb=[],Wx=BigInt(0),da=BigInt(1),Vx=BigInt(2),Kx=BigInt(7),Gx=BigInt(256),Zx=BigInt(113);for(let t=0,e=da,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Yb.push(2*(5*n+r)),Jb.push((t+1)*(t+2)/2%64);let i=Wx;for(let s=0;s<7;s++)e=(e<<da^(e>>Kx)*Zx)%Gx,e&Vx&&(i^=da<<(da<<BigInt(s))-da);Xb.push(i)}const[Yx,Jx]=Dx(Xb,!0),Kg=(t,e,r)=>r>32?Ux(t,e,r):Bx(t,e,r),Gg=(t,e,r)=>r>32?jx(t,e,r):Mx(t,e,r);function Xx(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=r[c],u=r[c+1],h=Kg(l,u,1)^r[a],d=Gg(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=Jb[o],c=Kg(i,s,a),l=Gg(i,s,a),u=Yb[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=Yx[n],t[1]^=Jx[n]}r.fill(0)}let Qx=class Qb extends X0{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,fc(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=zx(this.state)}keccak(){Wg||Vg(this.state32),Xx(this.state32,this.rounds),Wg||Vg(this.state32),this.posOut=0,this.pos=0}update(e){Po(this);const{blockLen:r,state:n}=this;e=ko(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,r&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Po(this,!1),nl(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return fc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Gb(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new Qb(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}};const e_=(t,e,r)=>Zb(()=>new Qx(e,t,r)),t_=e_(1,136,256/8),r_="https://rpc.walletconnect.org/v1";function e2(t){const e=`Ethereum Signed Message:
|
|
17
17
|
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(t_(r)).toString("hex")}async function n_(t,e,r,n,i,s){switch(r.t){case"eip191":return await i_(t,e,r.s);case"eip1271":return await s_(t,e,r.s,n,i,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function i_(t,e,r){return(await pC({hash:e2(e),signature:r})).toLowerCase()===t.toLowerCase()}async function s_(t,e,r,n,i,s){const o=bo(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),h=e2(e).substring(2),d=a+h+c+l+u,p=await fetch(`${s||r_}/?chainId=${n}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:o_(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:f}=await p.json();return f?f.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function o_(){return Date.now()+Math.floor(Math.random()*1e3)}function a_(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);const n=r[0];if(n===0)throw new Error("No signatures found");const i=1+n*64;if(r.length<i)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const s=Buffer.from(t,"base64").slice(1,65);return wC.encode(s)}var c_=Object.defineProperty,l_=Object.defineProperties,u_=Object.getOwnPropertyDescriptors,Zg=Object.getOwnPropertySymbols,h_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,Yg=(t,e,r)=>e in t?c_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,p_=(t,e)=>{for(var r in e||(e={}))h_.call(e,r)&&Yg(t,r,e[r]);if(Zg)for(var r of Zg(e))d_.call(e,r)&&Yg(t,r,e[r]);return t},f_=(t,e)=>l_(t,u_(e));const g_="did:pkh:",Q0=t=>t==null?void 0:t.split(":"),w_=t=>{const e=t&&Q0(t);if(e)return t.includes(g_)?e[3]:e[1]},zf=t=>{const e=t&&Q0(t);if(e)return e[2]+":"+e[3]},ch=t=>{const e=t&&Q0(t);if(e)return e.pop()};async function Jg(t){const{cacao:e,projectId:r}=t,{s:n,p:i}=e,s=t2(i,i.iss),o=ch(i.iss);return await n_(o,s,n,zf(i.iss),r)}const t2=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,n=ch(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${w_(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,p=t.resources?`Resources:${t.resources.map(g=>`
|
|
18
18
|
- ${g}`).join("")}`:void 0,f=Fu(t.resources);if(f){const g=gc(f);i=I_(i,g)}return[r,n,"",i,"",s,o,a,c,l,u,h,d,p].filter(g=>g!=null).join(`
|
|
19
19
|
`)};function m_(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function v_(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function gs(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const n=t.att[r];if(Array.isArray(n))throw new Error(`Resource must be an object: ${r}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(n).forEach(i=>{const s=n[i];if(!Array.isArray(s))throw new Error(`Ability limits ${i} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function y_(t,e,r,n={}){return r==null||r.sort((i,s)=>i.localeCompare(s)),{att:{[t]:b_(e,r,n)}}}function b_(t,e,r={}){e=e==null?void 0:e.sort((i,s)=>i.localeCompare(s));const n=e.map(i=>({[`${t}/${i}`]:[r]}));return Object.assign({},...n)}function r2(t){return gs(t),`urn:recap:${m_(t).replace(/=/g,"")}`}function gc(t){const e=v_(t.replace("urn:recap:",""));return gs(e),e}function C_(t,e,r){const n=y_(t,e,r);return r2(n)}function E_(t){return t&&t.includes("urn:recap:")}function x_(t,e){const r=gc(t),n=gc(e),i=__(r,n);return r2(i)}function __(t,e){gs(t),gs(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,s)=>i.localeCompare(s)),n={att:{}};return r.forEach(i=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;n.att[i]=f_(p_({},n.att[i]),{[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])})})}),n}function I_(t="",e){gs(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const n=[];let i=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));c.sort((h,d)=>h.action.localeCompare(d.action));const l={};c.forEach(h=>{l[h.ability]||(l[h.ability]=[]),l[h.ability].push(h.action)});const u=Object.keys(l).map(h=>(i++,`(${i}) '${h}': '${l[h].join("', '")}' for '${a}'.`));n.push(u.join(", ").replace(".,","."))});const s=n.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Xg(t){var e;const r=gc(t);gs(r);const n=(e=r.att)==null?void 0:e.eip155;return n?Object.keys(n).map(i=>i.split("/")[1]):[]}function Qg(t){const e=gc(t);gs(e);const r=[];return Object.values(e.att).forEach(n=>{Object.values(n).forEach(i=>{var s;(s=i==null?void 0:i[0])!=null&&s.chains&&r.push(i[0].chains)})}),[...new Set(r.flat())]}function Fu(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return E_(e)?e:void 0}function Dd(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function n2(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mr(t,...e){if(!n2(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ew(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function A_(t,e){mr(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function tw(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const mi=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),$_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),S_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!S_)throw new Error("Non little-endian hardware is not supported");function N_(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ff(t){if(typeof t=="string")t=N_(t);else if(n2(t))t=Hf(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function O_(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function P_(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}const k_=(t,e)=>{function r(n,...i){if(mr(n),t.nonceLength!==void 0){const l=i[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?mr(l):mr(l,t.nonceLength)}const s=t.tagLength;s&&i[1]!==void 0&&mr(i[1]);const o=e(n,...i),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");mr(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mr(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(mr(l),s&&l.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(r,t),r};function rw(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!T_(e))throw new Error("invalid output, must be aligned");return e}function nw(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s);t.setUint32(e+4,o,n),t.setUint32(e+0,a,n)}function T_(t){return t.byteOffset%4===0}function Hf(t){return Uint8Array.from(t)}function To(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const i2=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),R_=i2("expand 16-byte k"),L_=i2("expand 32-byte k"),D_=mi(R_),B_=mi(L_);function Ne(t,e){return t<<e|t>>>32-e}function qf(t){return t.byteOffset%4===0}const Al=64,M_=16,s2=2**32-1,iw=new Uint32Array;function U_(t,e,r,n,i,s,o,a){const c=i.length,l=new Uint8Array(Al),u=mi(l),h=qf(i)&&qf(s),d=h?mi(i):iw,p=h?mi(s):iw;for(let f=0;f<c;o++){if(t(e,r,n,u,o,a),o>=s2)throw new Error("arx: counter overflow");const g=Math.min(Al,c-f);if(h&&g===Al){const w=f/4;if(f%4!==0)throw new Error("arx: invalid block position");for(let v=0,b;v<M_;v++)b=w+v,p[b]=d[b]^u[v];f+=Al;continue}for(let w=0,v;w<g;w++)v=f+w,s[v]=i[v]^l[w];f+=g}}function j_(t,e){const{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:s,rounds:o}=O_({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Dd(i),Dd(o),tw(s),tw(r),(a,c,l,u,h=0)=>{mr(a),mr(c),mr(l);const d=l.length;if(u===void 0&&(u=new Uint8Array(d)),mr(u),Dd(h),h<0||h>=s2)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const p=[];let f=a.length,g,w;if(f===32)p.push(g=Hf(a)),w=B_;else if(f===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),w=D_,p.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${f}`);qf(c)||p.push(c=Hf(c));const v=mi(g);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(w,v,mi(c.subarray(0,16)),v),c=c.subarray(16)}const b=16-i;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const E=new Uint8Array(12);E.set(c,s?0:12-c.length),c=E,p.push(c)}const C=mi(c);return U_(t,w,v,C,l,u,h,o),To(...p),u}}const Ot=(t,e)=>t[e++]&255|(t[e++]&255)<<8;let z_=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Ff(e),mr(e,32);const r=Ot(e,0),n=Ot(e,2),i=Ot(e,4),s=Ot(e,6),o=Ot(e,8),a=Ot(e,10),c=Ot(e,12),l=Ot(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ot(e,16+2*u)}process(e,r,n=!1){const i=n?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],d=o[5],p=o[6],f=o[7],g=o[8],w=o[9],v=Ot(e,r+0),b=Ot(e,r+2),C=Ot(e,r+4),E=Ot(e,r+6),A=Ot(e,r+8),S=Ot(e,r+10),T=Ot(e,r+12),k=Ot(e,r+14);let I=s[0]+(v&8191),B=s[1]+((v>>>13|b<<3)&8191),D=s[2]+((b>>>10|C<<6)&8191),M=s[3]+((C>>>7|E<<9)&8191),W=s[4]+((E>>>4|A<<12)&8191),$=s[5]+(A>>>1&8191),m=s[6]+((A>>>14|S<<2)&8191),y=s[7]+((S>>>11|T<<5)&8191),x=s[8]+((T>>>8|k<<8)&8191),_=s[9]+(k>>>5|i),O=0,R=O+I*a+B*(5*w)+D*(5*g)+M*(5*f)+W*(5*p);O=R>>>13,R&=8191,R+=$*(5*d)+m*(5*h)+y*(5*u)+x*(5*l)+_*(5*c),O+=R>>>13,R&=8191;let U=O+I*c+B*a+D*(5*w)+M*(5*g)+W*(5*f);O=U>>>13,U&=8191,U+=$*(5*p)+m*(5*d)+y*(5*h)+x*(5*u)+_*(5*l),O+=U>>>13,U&=8191;let j=O+I*l+B*c+D*a+M*(5*w)+W*(5*g);O=j>>>13,j&=8191,j+=$*(5*f)+m*(5*p)+y*(5*d)+x*(5*h)+_*(5*u),O+=j>>>13,j&=8191;let V=O+I*u+B*l+D*c+M*a+W*(5*w);O=V>>>13,V&=8191,V+=$*(5*g)+m*(5*f)+y*(5*p)+x*(5*d)+_*(5*h),O+=V>>>13,V&=8191;let z=O+I*h+B*u+D*l+M*c+W*a;O=z>>>13,z&=8191,z+=$*(5*w)+m*(5*g)+y*(5*f)+x*(5*p)+_*(5*d),O+=z>>>13,z&=8191;let te=O+I*d+B*h+D*u+M*l+W*c;O=te>>>13,te&=8191,te+=$*a+m*(5*w)+y*(5*g)+x*(5*f)+_*(5*p),O+=te>>>13,te&=8191;let he=O+I*p+B*d+D*h+M*u+W*l;O=he>>>13,he&=8191,he+=$*c+m*a+y*(5*w)+x*(5*g)+_*(5*f),O+=he>>>13,he&=8191;let Ce=O+I*f+B*p+D*d+M*h+W*u;O=Ce>>>13,Ce&=8191,Ce+=$*l+m*c+y*a+x*(5*w)+_*(5*g),O+=Ce>>>13,Ce&=8191;let we=O+I*g+B*f+D*p+M*d+W*h;O=we>>>13,we&=8191,we+=$*u+m*l+y*c+x*a+_*(5*w),O+=we>>>13,we&=8191;let ge=O+I*w+B*g+D*f+M*p+W*d;O=ge>>>13,ge&=8191,ge+=$*h+m*u+y*l+x*c+_*a,O+=ge>>>13,ge&=8191,O=(O<<2)+O|0,O=O+R|0,R=O&8191,O=O>>>13,U+=O,s[0]=R,s[1]=U,s[2]=j,s[3]=V,s[4]=z,s[5]=te,s[6]=he,s[7]=Ce,s[8]=we,s[9]=ge}finalize(){const{h:e,pad:r}=this,n=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let s=(i^1)-1;for(let a=0;a<10;a++)n[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;To(n)}update(e){ew(this);const{buffer:r,blockLen:n}=this;e=Ff(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o===n){for(;n<=i-s;s+=n)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){To(this.h,this.r,this.buffer,this.pad)}digestInto(e){ew(this),A_(e,this),this.finished=!0;const{buffer:r,h:n}=this;let{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=n[o]>>>0,e[s++]=n[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}};function F_(t){const e=(n,i)=>t(i).update(Ff(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}const H_=F_(t=>new z_(t));function q_(t,e,r,n,i,s=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],p=e[3],f=e[4],g=e[5],w=e[6],v=e[7],b=i,C=r[0],E=r[1],A=r[2],S=o,T=a,k=c,I=l,B=u,D=h,M=d,W=p,$=f,m=g,y=w,x=v,_=b,O=C,R=E,U=A;for(let V=0;V<s;V+=2)S=S+B|0,_=Ne(_^S,16),$=$+_|0,B=Ne(B^$,12),S=S+B|0,_=Ne(_^S,8),$=$+_|0,B=Ne(B^$,7),T=T+D|0,O=Ne(O^T,16),m=m+O|0,D=Ne(D^m,12),T=T+D|0,O=Ne(O^T,8),m=m+O|0,D=Ne(D^m,7),k=k+M|0,R=Ne(R^k,16),y=y+R|0,M=Ne(M^y,12),k=k+M|0,R=Ne(R^k,8),y=y+R|0,M=Ne(M^y,7),I=I+W|0,U=Ne(U^I,16),x=x+U|0,W=Ne(W^x,12),I=I+W|0,U=Ne(U^I,8),x=x+U|0,W=Ne(W^x,7),S=S+D|0,U=Ne(U^S,16),y=y+U|0,D=Ne(D^y,12),S=S+D|0,U=Ne(U^S,8),y=y+U|0,D=Ne(D^y,7),T=T+M|0,_=Ne(_^T,16),x=x+_|0,M=Ne(M^x,12),T=T+M|0,_=Ne(_^T,8),x=x+_|0,M=Ne(M^x,7),k=k+W|0,O=Ne(O^k,16),$=$+O|0,W=Ne(W^$,12),k=k+W|0,O=Ne(O^k,8),$=$+O|0,W=Ne(W^$,7),I=I+B|0,R=Ne(R^I,16),m=m+R|0,B=Ne(B^m,12),I=I+B|0,R=Ne(R^I,8),m=m+R|0,B=Ne(B^m,7);let j=0;n[j++]=o+S|0,n[j++]=a+T|0,n[j++]=c+k|0,n[j++]=l+I|0,n[j++]=u+B|0,n[j++]=h+D|0,n[j++]=d+M|0,n[j++]=p+W|0,n[j++]=f+$|0,n[j++]=g+m|0,n[j++]=w+y|0,n[j++]=v+x|0,n[j++]=b+_|0,n[j++]=C+O|0,n[j++]=E+R|0,n[j++]=A+U|0}const W_=j_(q_,{counterRight:!1,counterLength:4,allowShortKeys:!1}),V_=new Uint8Array(16),sw=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(V_.subarray(r))},K_=new Uint8Array(32);function ow(t,e,r,n,i){const s=t(e,r,K_),o=H_.create(s);i&&sw(o,i),sw(o,n);const a=new Uint8Array(16),c=$_(a);nw(c,0,BigInt(i?i.length:0),!0),nw(c,8,BigInt(n.length),!0),o.update(a);const l=o.digest();return To(s,a),l}const G_=t=>(e,r,n)=>({encrypt(i,s){const o=i.length;s=rw(o+16,s,!1),s.set(i);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=ow(t,e,r,a,n);return s.set(c,o),To(c),s},decrypt(i,s){s=rw(i.length-16,s,!1);const o=i.subarray(0,-16),a=i.subarray(-16),c=ow(t,e,r,o,n);if(!P_(a,c))throw new Error("invalid tag");return s.set(i.subarray(0,-16)),t(e,r,s,s,1),To(c),s}}),o2=k_({blockSize:64,nonceLength:12,tagLength:16},G_(W_));let a2=class extends X0{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,J0(e);const n=ko(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Po(this),this.iHash.update(e),this}digestInto(e){Po(this),nl(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:n,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Mh=(t,e,r)=>new a2(t,e).update(r).digest();Mh.create=(t,e)=>new a2(t,e);function Z_(t,e,r){return J0(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Mh(t,ko(r),ko(e))}const Bd=new Uint8Array([0]),aw=new Uint8Array;function Y_(t,e,r,n=32){if(J0(t),fc(n),n>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(n/t.outputLen);r===void 0&&(r=aw);const s=new Uint8Array(i*t.outputLen),o=Mh.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)Bd[0]=l+1,a.update(l===0?aw:c).update(r).update(Bd).digestInto(c),s.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Bd.fill(0),s.slice(0,n)}const J_=(t,e,r,n,i)=>Y_(t,Z_(t,e,r),n,i);function X_(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}function Q_(t,e,r){return t&e^~t&r}function eI(t,e,r){return t&e^t&r^e&r}let tI=class extends X0{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ld(this.buffer)}update(e){Po(this);const{view:r,buffer:n,blockLen:i}=this;e=ko(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Ld(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Po(this),Gb(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;X_(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=Ld(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};const rI=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ti=new Uint32Array(64);let nI=class extends tI{constructor(){super(64,32,8,!1),this.A=ei[0]|0,this.B=ei[1]|0,this.C=ei[2]|0,this.D=ei[3]|0,this.E=ei[4]|0,this.F=ei[5]|0,this.G=ei[6]|0,this.H=ei[7]|0}get(){const{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)ti[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const d=ti[h-15],p=ti[h-2],f=en(d,7)^en(d,18)^d>>>3,g=en(p,17)^en(p,19)^p>>>10;ti[h]=g+ti[h-7]+f+ti[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let h=0;h<64;h++){const d=en(a,6)^en(a,11)^en(a,25),p=u+d+Q_(a,c,l)+rI[h]+ti[h]|0,f=(en(n,2)^en(n,13)^en(n,22))+eI(n,i,s)|0;u=l,l=c,c=a,a=o+p|0,o=s,s=i,i=n,n=p+f|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,i,s,o,a,c,l,u)}roundClean(){ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const il=Zb(()=>new nI);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Uh=BigInt(0),jh=BigInt(1),iI=BigInt(2);function ws(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function sl(t){if(!ws(t))throw new Error("Uint8Array expected")}function Ro(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const sI=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Lo(t){sl(t);let e="";for(let r=0;r<t.length;r++)e+=sI[t[r]];return e}function wo(t){const e=t.toString(16);return e.length&1?"0"+e:e}function e1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Uh:BigInt("0x"+t)}const _n={_0:48,_9:57,A:65,F:70,a:97,f:102};function cw(t){if(t>=_n._0&&t<=_n._9)return t-_n._0;if(t>=_n.A&&t<=_n.F)return t-(_n.A-10);if(t>=_n.a&&t<=_n.f)return t-(_n.a-10)}function Do(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){const o=cw(t.charCodeAt(s)),a=cw(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function os(t){return e1(Lo(t))}function wc(t){return sl(t),e1(Lo(Uint8Array.from(t).reverse()))}function Bo(t,e){return Do(t.toString(16).padStart(e*2,"0"))}function zh(t,e){return Bo(t,e).reverse()}function oI(t){return Do(wo(t))}function wr(t,e,r){let n;if(typeof e=="string")try{n=Do(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(ws(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function mc(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];sl(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}function aI(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function cI(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Md=t=>typeof t=="bigint"&&Uh<=t;function Fh(t,e,r){return Md(t)&&Md(e)&&Md(r)&&e<=t&&t<r}function qn(t,e,r,n){if(!Fh(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function c2(t){let e;for(e=0;t>Uh;t>>=jh,e+=1);return e}function lI(t,e){return t>>BigInt(e)&jh}function uI(t,e,r){return t|(r?jh:Uh)<<BigInt(e)}const t1=t=>(iI<<BigInt(t-1))-jh,Ud=t=>new Uint8Array(t),lw=t=>Uint8Array.from(t);function l2(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Ud(t),i=Ud(t),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...u)=>r(i,n,...u),c=(u=Ud())=>{i=a(lw([0]),u),n=a(),u.length!==0&&(i=a(lw([1]),u),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u<e;){n=a();const d=n.slice();h.push(d),u+=n.length}return mc(...h)};return(u,h)=>{o(),c(u);let d;for(;!(d=h(l()));)c();return o(),d}}const hI={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ws(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ea(t,e,r={}){const n=(i,s,o)=>{const a=hI[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+c)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return t}const dI=()=>{throw new Error("not implemented")};function Wf(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(i!==void 0)return i;const s=t(r,...n);return e.set(r,s),s}}var pI=Object.freeze({__proto__:null,isBytes:ws,abytes:sl,abool:Ro,bytesToHex:Lo,numberToHexUnpadded:wo,hexToNumber:e1,hexToBytes:Do,bytesToNumberBE:os,bytesToNumberLE:wc,numberToBytesBE:Bo,numberToBytesLE:zh,numberToVarBytesBE:oI,ensureBytes:wr,concatBytes:mc,equalBytes:aI,utf8ToBytes:cI,inRange:Fh,aInRange:qn,bitLen:c2,bitGet:lI,bitSet:uI,bitMask:t1,createHmacDrbg:l2,validateObject:ea,notImplemented:dI,memoized:Wf});const St=BigInt(0),at=BigInt(1),Ji=BigInt(2),fI=BigInt(3),Vf=BigInt(4),uw=BigInt(5),hw=BigInt(8);function nr(t,e){const r=t%e;return r>=St?r:e+r}function u2(t,e,r){if(e<St)throw new Error("invalid exponent, negatives unsupported");if(r<=St)throw new Error("invalid modulus");if(r===at)return St;let n=at;for(;e>St;)e&at&&(n=n*t%r),t=t*t%r,e>>=at;return n}function Kr(t,e,r){let n=t;for(;e-- >St;)n*=n,n%=r;return n}function Kf(t,e){if(t===St)throw new Error("invert: expected non-zero number");if(e<=St)throw new Error("invert: expected positive modulus, got "+e);let r=nr(t,e),n=e,i=St,s=at;for(;r!==St;){const o=n/r,a=n%r,c=i-s*o;n=r,r=a,i=s,s=c}if(n!==at)throw new Error("invert: does not exist");return nr(i,e)}function gI(t){const e=(t-at)/Ji;let r,n,i;for(r=t-at,n=0;r%Ji===St;r/=Ji,n++);for(i=Ji;i<t&&u2(i,e,t)!==t-at;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(t+at)/Vf;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(r+at)/Ji;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=n,l=o.pow(o.mul(o.ONE,i),r),u=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let d=1;for(let f=o.sqr(h);d<c&&!o.eql(f,o.ONE);d++)f=o.sqr(f);const p=o.pow(l,at<<BigInt(c-d-1));l=o.sqr(p),u=o.mul(u,p),h=o.mul(h,l),c=d}return u}}function wI(t){if(t%Vf===fI){const e=(t+at)/Vf;return function(r,n){const i=r.pow(n,e);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}}if(t%hw===uw){const e=(t-uw)/hw;return function(r,n){const i=r.mul(n,Ji),s=r.pow(i,e),o=r.mul(n,s),a=r.mul(r.mul(o,Ji),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),n))throw new Error("Cannot find square root");return c}}return gI(t)}const mI=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vI(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=mI.reduce((n,i)=>(n[i]="function",n),e);return ea(t,r)}function yI(t,e,r){if(r<St)throw new Error("invalid exponent, negatives unsupported");if(r===St)return t.ONE;if(r===at)return e;let n=t.ONE,i=e;for(;r>St;)r&at&&(n=t.mul(n,i)),i=t.sqr(i),r>>=at;return n}function bI(t,e){const r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function h2(t,e){const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function d2(t,e,r=!1,n={}){if(t<=St)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:s}=h2(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:i,BYTES:s,MASK:t1(i),ZERO:St,ONE:at,create:c=>nr(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return St<=c&&c<t},is0:c=>c===St,isOdd:c=>(c&at)===at,neg:c=>nr(-c,t),eql:(c,l)=>c===l,sqr:c=>nr(c*c,t),add:(c,l)=>nr(c+l,t),sub:(c,l)=>nr(c-l,t),mul:(c,l)=>nr(c*l,t),pow:(c,l)=>yI(a,c,l),div:(c,l)=>nr(c*Kf(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Kf(c,t),sqrt:n.sqrt||(c=>(o||(o=wI(t)),o(a,c))),invertBatch:c=>bI(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?zh(c,s):Bo(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?wc(c):os(c)}});return Object.freeze(a)}function p2(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function f2(t){const e=p2(t);return e+Math.ceil(e/2)}function CI(t,e,r=!1){const n=t.length,i=p2(e),s=f2(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=r?wc(t):os(t),a=nr(o,e-at)+at;return r?zh(a,i):Bo(a,i)}const dw=BigInt(0),$l=BigInt(1);function jd(t,e){const r=e.negate();return t?r:e}function g2(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function zd(t,e){g2(t,e);const r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function EI(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function xI(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}const Fd=new WeakMap,w2=new WeakMap;function Hd(t){return w2.get(t)||1}function _I(t,e){return{constTimeNegate:jd,hasPrecomputes(r){return Hd(r)!==1},unsafeLadder(r,n,i=t.ZERO){let s=r;for(;n>dw;)n&$l&&(i=i.add(s)),s=s.double(),n>>=$l;return i},precomputeWindow(r,n){const{windows:i,windowSize:s}=zd(n,e),o=[];let a=r,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,n,i){const{windows:s,windowSize:o}=zd(r,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**r-1),u=2**r,h=BigInt(r);for(let d=0;d<s;d++){const p=d*o;let f=Number(i&l);i>>=h,f>o&&(f-=u,i+=$l);const g=p,w=p+Math.abs(f)-1,v=d%2!==0,b=f<0;f===0?c=c.add(jd(v,n[g])):a=a.add(jd(b,n[w]))}return{p:a,f:c}},wNAFUnsafe(r,n,i,s=t.ZERO){const{windows:o,windowSize:a}=zd(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let h=0;h<o;h++){const d=h*a;if(i===dw)break;let p=Number(i&c);if(i>>=u,p>a&&(p-=l,i+=$l),p===0)continue;let f=n[d+Math.abs(p)-1];p<0&&(f=f.negate()),s=s.add(f)}return s},getPrecomputes(r,n,i){let s=Fd.get(n);return s||(s=this.precomputeWindow(n,r),r!==1&&Fd.set(n,i(s))),s},wNAFCached(r,n,i){const s=Hd(r);return this.wNAF(s,this.getPrecomputes(s,r,i),n)},wNAFCachedUnsafe(r,n,i,s){const o=Hd(r);return o===1?this.unsafeLadder(r,n,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,i),n,s)},setWindowSize(r,n){g2(n,e),w2.set(r,n),Fd.delete(r)}}}function II(t,e,r,n){if(EI(r,t),xI(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,s=c2(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let u=i;for(let h=l;h>=0;h-=o){c.fill(i);for(let p=0;p<n.length;p++){const f=n[p],g=Number(f>>BigInt(h)&BigInt(a));c[g]=c[g].add(r[p])}let d=i;for(let p=c.length-1,f=i;p>0;p--)f=f.add(c[p]),d=d.add(f);if(u=u.add(d),h!==0)for(let p=0;p<o;p++)u=u.double()}return u}function m2(t){return vI(t.Fp),ea(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...h2(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Rs=BigInt(0),qd=BigInt(1);function AI(t){return ea(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function $I(t){const e=AI(t),{P:r}=e,n=b=>nr(b,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>u2(b,r-BigInt(2),r));function l(b,C,E){const A=n(b*(C-E));return C=n(C-A),E=n(E+A),[C,E]}const u=(e.a-BigInt(2))/BigInt(4);function h(b,C){qn("u",b,Rs,r),qn("scalar",C,Rs,r);const E=C,A=b;let S=qd,T=Rs,k=b,I=qd,B=Rs,D;for(let W=BigInt(i-1);W>=Rs;W--){const $=E>>W&qd;B^=$,D=l(B,S,k),S=D[0],k=D[1],D=l(B,T,I),T=D[0],I=D[1],B=$;const m=S+T,y=n(m*m),x=S-T,_=n(x*x),O=y-_,R=k+I,U=k-I,j=n(U*m),V=n(R*x),z=j+V,te=j-V;k=n(z*z),I=n(A*n(te*te)),S=n(y*_),T=n(O*(y+n(u*O)))}D=l(B,S,k),S=D[0],k=D[1],D=l(B,T,I),T=D[0],I=D[1];const M=c(T);return n(S*M)}function d(b){return zh(n(b),s)}function p(b){const C=wr("u coordinate",b,s);return o===32&&(C[31]&=127),wc(C)}function f(b){const C=wr("scalar",b),E=C.length;if(E!==s&&E!==o){let A=""+s+" or "+o;throw new Error("invalid scalar, expected "+A+" bytes, got "+E)}return wc(a(C))}function g(b,C){const E=p(C),A=f(b),S=h(E,A);if(S===Rs)throw new Error("invalid private or public key received");return d(S)}const w=d(e.Gu);function v(b){return g(b,w)}return{scalarMult:g,scalarMultBase:v,getSharedSecret:(b,C)=>g(b,C),getPublicKey:b=>v(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:w}}const Gf=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const SI=BigInt(1),pw=BigInt(2),NI=BigInt(3),OI=BigInt(5);BigInt(8);function PI(t){const e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Gf,o=t*t%s*t%s,a=Kr(o,pw,s)*o%s,c=Kr(a,SI,s)*t%s,l=Kr(c,OI,s)*c%s,u=Kr(l,e,s)*l%s,h=Kr(u,r,s)*u%s,d=Kr(h,n,s)*h%s,p=Kr(d,i,s)*d%s,f=Kr(p,i,s)*d%s,g=Kr(f,e,s)*l%s;return{pow_p_5_8:Kr(g,pw,s)*t%s,b2:o}}function kI(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Zf=$I({P:Gf,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Gf,{pow_p_5_8:r,b2:n}=PI(t);return nr(Kr(r,NI,e)*n,e)},adjustScalarBytes:kI,randomBytes:Qo});function fw(t){t.lowS!==void 0&&Ro("lowS",t.lowS),t.prehash!==void 0&&Ro("prehash",t.prehash)}function TI(t){const e=m2(t);ea(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:RI,hexToBytes:LI}=pI;let DI=class extends Error{constructor(e=""){super(e)}};const Un={Err:DI,_tlv:{encode:(t,e)=>{const{Err:r}=Un;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=wo(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?wo(i.length/2|128):"";return wo(t)+s+i+e},decode(t,e){const{Err:r}=Un;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=Un;if(t<zn)throw new e("integer: negative integers are not allowed");let r=wo(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Un;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return RI(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=Un,i=typeof t=="string"?LI(t):t;sl(i);const{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=n.decode(2,s),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){const{_tlv:e,_int:r}=Un,n=e.encode(2,r.encode(t.r)),i=e.encode(2,r.encode(t.s)),s=n+i;return e.encode(48,s)}},zn=BigInt(0),xt=BigInt(1);BigInt(2);const gw=BigInt(3);BigInt(4);function BI(t){const e=TI(t),{Fp:r}=e,n=d2(e.n,e.nBitLength),i=e.toBytes||((g,w,v)=>{const b=w.toAffine();return mc(Uint8Array.from([4]),r.toBytes(b.x),r.toBytes(b.y))}),s=e.fromBytes||(g=>{const w=g.subarray(1),v=r.fromBytes(w.subarray(0,r.BYTES)),b=r.fromBytes(w.subarray(r.BYTES,2*r.BYTES));return{x:v,y:b}});function o(g){const{a:w,b:v}=e,b=r.sqr(g),C=r.mul(b,g);return r.add(r.add(C,r.mul(g,w)),v)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(g){return Fh(g,xt,e.n)}function c(g){const{allowedPrivateKeyLengths:w,nByteLength:v,wrapPrivateKey:b,n:C}=e;if(w&&typeof g!="bigint"){if(ws(g)&&(g=Lo(g)),typeof g!="string"||!w.includes(g.length))throw new Error("invalid private key");g=g.padStart(v*2,"0")}let E;try{E=typeof g=="bigint"?g:os(wr("private key",g,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof g)}return b&&(E=nr(E,C)),qn("private key",E,xt,C),E}function l(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}const u=Wf((g,w)=>{const{px:v,py:b,pz:C}=g;if(r.eql(C,r.ONE))return{x:v,y:b};const E=g.is0();w==null&&(w=E?r.ONE:r.inv(C));const A=r.mul(v,w),S=r.mul(b,w),T=r.mul(C,w);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(T,r.ONE))throw new Error("invZ was invalid");return{x:A,y:S}}),h=Wf(g=>{if(g.is0()){if(e.allowInfinityPoint&&!r.is0(g.py))return;throw new Error("bad point: ZERO")}const{x:w,y:v}=g.toAffine();if(!r.isValid(w)||!r.isValid(v))throw new Error("bad point: x or y not FE");const b=r.sqr(v),C=o(w);if(!r.eql(b,C))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(w,v,b){if(this.px=w,this.py=v,this.pz=b,w==null||!r.isValid(w))throw new Error("x required");if(v==null||!r.isValid(v))throw new Error("y required");if(b==null||!r.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(w){const{x:v,y:b}=w||{};if(!w||!r.isValid(v)||!r.isValid(b))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");const C=E=>r.eql(E,r.ZERO);return C(v)&&C(b)?d.ZERO:new d(v,b,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const v=r.invertBatch(w.map(b=>b.pz));return w.map((b,C)=>b.toAffine(v[C])).map(d.fromAffine)}static fromHex(w){const v=d.fromAffine(s(wr("pointHex",w)));return v.assertValidity(),v}static fromPrivateKey(w){return d.BASE.multiply(c(w))}static msm(w,v){return II(d,n,w,v)}_setWindowSize(w){f.setWindowSize(this,w)}assertValidity(){h(this)}hasEvenY(){const{y:w}=this.toAffine();if(r.isOdd)return!r.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){l(w);const{px:v,py:b,pz:C}=this,{px:E,py:A,pz:S}=w,T=r.eql(r.mul(v,S),r.mul(E,C)),k=r.eql(r.mul(b,S),r.mul(A,C));return T&&k}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){const{a:w,b:v}=e,b=r.mul(v,gw),{px:C,py:E,pz:A}=this;let S=r.ZERO,T=r.ZERO,k=r.ZERO,I=r.mul(C,C),B=r.mul(E,E),D=r.mul(A,A),M=r.mul(C,E);return M=r.add(M,M),k=r.mul(C,A),k=r.add(k,k),S=r.mul(w,k),T=r.mul(b,D),T=r.add(S,T),S=r.sub(B,T),T=r.add(B,T),T=r.mul(S,T),S=r.mul(M,S),k=r.mul(b,k),D=r.mul(w,D),M=r.sub(I,D),M=r.mul(w,M),M=r.add(M,k),k=r.add(I,I),I=r.add(k,I),I=r.add(I,D),I=r.mul(I,M),T=r.add(T,I),D=r.mul(E,A),D=r.add(D,D),I=r.mul(D,M),S=r.sub(S,I),k=r.mul(D,B),k=r.add(k,k),k=r.add(k,k),new d(S,T,k)}add(w){l(w);const{px:v,py:b,pz:C}=this,{px:E,py:A,pz:S}=w;let T=r.ZERO,k=r.ZERO,I=r.ZERO;const B=e.a,D=r.mul(e.b,gw);let M=r.mul(v,E),W=r.mul(b,A),$=r.mul(C,S),m=r.add(v,b),y=r.add(E,A);m=r.mul(m,y),y=r.add(M,W),m=r.sub(m,y),y=r.add(v,C);let x=r.add(E,S);return y=r.mul(y,x),x=r.add(M,$),y=r.sub(y,x),x=r.add(b,C),T=r.add(A,S),x=r.mul(x,T),T=r.add(W,$),x=r.sub(x,T),I=r.mul(B,y),T=r.mul(D,$),I=r.add(T,I),T=r.sub(W,I),I=r.add(W,I),k=r.mul(T,I),W=r.add(M,M),W=r.add(W,M),$=r.mul(B,$),y=r.mul(D,y),W=r.add(W,$),$=r.sub(M,$),$=r.mul(B,$),y=r.add(y,$),M=r.mul(W,y),k=r.add(k,M),M=r.mul(x,y),T=r.mul(m,T),T=r.sub(T,M),M=r.mul(m,W),I=r.mul(x,I),I=r.add(I,M),new d(T,k,I)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return f.wNAFCached(this,w,d.normalizeZ)}multiplyUnsafe(w){const{endo:v,n:b}=e;qn("scalar",w,zn,b);const C=d.ZERO;if(w===zn)return C;if(this.is0()||w===xt)return this;if(!v||f.hasPrecomputes(this))return f.wNAFCachedUnsafe(this,w,d.normalizeZ);let{k1neg:E,k1:A,k2neg:S,k2:T}=v.splitScalar(w),k=C,I=C,B=this;for(;A>zn||T>zn;)A&xt&&(k=k.add(B)),T&xt&&(I=I.add(B)),B=B.double(),A>>=xt,T>>=xt;return E&&(k=k.negate()),S&&(I=I.negate()),I=new d(r.mul(I.px,v.beta),I.py,I.pz),k.add(I)}multiply(w){const{endo:v,n:b}=e;qn("scalar",w,xt,b);let C,E;if(v){const{k1neg:A,k1:S,k2neg:T,k2:k}=v.splitScalar(w);let{p:I,f:B}=this.wNAF(S),{p:D,f:M}=this.wNAF(k);I=f.constTimeNegate(A,I),D=f.constTimeNegate(T,D),D=new d(r.mul(D.px,v.beta),D.py,D.pz),C=I.add(D),E=B.add(M)}else{const{p:A,f:S}=this.wNAF(w);C=A,E=S}return d.normalizeZ([C,E])[0]}multiplyAndAddUnsafe(w,v,b){const C=d.BASE,E=(S,T)=>T===zn||T===xt||!S.equals(C)?S.multiplyUnsafe(T):S.multiply(T),A=E(this,v).add(E(w,b));return A.is0()?void 0:A}toAffine(w){return u(this,w)}isTorsionFree(){const{h:w,isTorsionFree:v}=e;if(w===xt)return!0;if(v)return v(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:v}=e;return w===xt?this:v?v(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return Ro("isCompressed",w),this.assertValidity(),i(d,this,w)}toHex(w=!0){return Ro("isCompressed",w),Lo(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);const p=e.nBitLength,f=_I(d,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function MI(t){const e=m2(t);return ea(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function UI(t){const e=MI(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o($){return nr($,n)}function a($){return Kf($,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=BI({...e,toBytes($,m,y){const x=m.toAffine(),_=r.toBytes(x.x),O=mc;return Ro("isCompressed",y),y?O(Uint8Array.from([m.hasEvenY()?2:3]),_):O(Uint8Array.from([4]),_,r.toBytes(x.y))},fromBytes($){const m=$.length,y=$[0],x=$.subarray(1);if(m===i&&(y===2||y===3)){const _=os(x);if(!Fh(_,xt,r.ORDER))throw new Error("Point is not on curve");const O=u(_);let R;try{R=r.sqrt(O)}catch(j){const V=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+V)}const U=(R&xt)===xt;return(y&1)===1!==U&&(R=r.neg(R)),{x:_,y:R}}else if(m===s&&y===4){const _=r.fromBytes(x.subarray(0,r.BYTES)),O=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:_,y:O}}else{const _=i,O=s;throw new Error("invalid Point, expected length of "+_+", or uncompressed "+O+", got "+m)}}}),d=$=>Lo(Bo($,e.nByteLength));function p($){const m=n>>xt;return $>m}function f($){return p($)?o(-$):$}const g=($,m,y)=>os($.slice(m,y));class w{constructor(m,y,x){this.r=m,this.s=y,this.recovery=x,this.assertValidity()}static fromCompact(m){const y=e.nByteLength;return m=wr("compactSignature",m,y*2),new w(g(m,0,y),g(m,y,2*y))}static fromDER(m){const{r:y,s:x}=Un.toSig(wr("DER",m));return new w(y,x)}assertValidity(){qn("r",this.r,xt,n),qn("s",this.s,xt,n)}addRecoveryBit(m){return new w(this.r,this.s,m)}recoverPublicKey(m){const{r:y,s:x,recovery:_}=this,O=S(wr("msgHash",m));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");const R=_===2||_===3?y+e.n:y;if(R>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const U=_&1?"03":"02",j=c.fromHex(U+d(R)),V=a(R),z=o(-O*V),te=o(x*V),he=c.BASE.multiplyAndAddUnsafe(j,z,te);if(!he)throw new Error("point at infinify");return he.assertValidity(),he}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Do(this.toDERHex())}toDERHex(){return Un.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Do(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const v={isValidPrivateKey($){try{return l($),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const $=f2(e.n);return CI(e.randomBytes($),e.n)},precompute($=8,m=c.BASE){return m._setWindowSize($),m.multiply(BigInt(3)),m}};function b($,m=!0){return c.fromPrivateKey($).toRawBytes(m)}function C($){const m=ws($),y=typeof $=="string",x=(m||y)&&$.length;return m?x===i||x===s:y?x===2*i||x===2*s:$ instanceof c}function E($,m,y=!0){if(C($))throw new Error("first arg must be private key");if(!C(m))throw new Error("second arg must be public key");return c.fromHex(m).multiply(l($)).toRawBytes(y)}const A=e.bits2int||function($){if($.length>8192)throw new Error("input is too large");const m=os($),y=$.length*8-e.nBitLength;return y>0?m>>BigInt(y):m},S=e.bits2int_modN||function($){return o(A($))},T=t1(e.nBitLength);function k($){return qn("num < 2^"+e.nBitLength,$,zn,T),Bo($,e.nByteLength)}function I($,m,y=B){if(["recovered","canonical"].some(we=>we in y))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:_}=e;let{lowS:O,prehash:R,extraEntropy:U}=y;O==null&&(O=!0),$=wr("msgHash",$),fw(y),R&&($=wr("prehashed msgHash",x($)));const j=S($),V=l(m),z=[k(V),k(j)];if(U!=null&&U!==!1){const we=U===!0?_(r.BYTES):U;z.push(wr("extraEntropy",we))}const te=mc(...z),he=j;function Ce(we){const ge=A(we);if(!h(ge))return;const Ee=a(ge),Se=c.BASE.multiply(ge).toAffine(),Le=o(Se.x);if(Le===zn)return;const nt=o(Ee*o(he+Le*V));if(nt===zn)return;let yt=(Se.x===Le?0:2)|Number(Se.y&xt),bn=nt;return O&&p(nt)&&(bn=f(nt),yt^=1),new w(Le,bn,yt)}return{seed:te,k2sig:Ce}}const B={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function M($,m,y=B){const{seed:x,k2sig:_}=I($,m,y),O=e;return l2(O.hash.outputLen,O.nByteLength,O.hmac)(x,_)}c.BASE._setWindowSize(8);function W($,m,y,x=D){var nt;const _=$;m=wr("msgHash",m),y=wr("publicKey",y);const{lowS:O,prehash:R,format:U}=x;if(fw(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");const j=typeof _=="string"||ws(_),V=!j&&!U&&typeof _=="object"&&_!==null&&typeof _.r=="bigint"&&typeof _.s=="bigint";if(!j&&!V)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let z,te;try{if(V&&(z=new w(_.r,_.s)),j){try{U!=="compact"&&(z=w.fromDER(_))}catch(yt){if(!(yt instanceof Un.Err))throw yt}!z&&U!=="der"&&(z=w.fromCompact(_))}te=c.fromHex(y)}catch{return!1}if(!z||O&&z.hasHighS())return!1;R&&(m=e.hash(m));const{r:he,s:Ce}=z,we=S(m),ge=a(Ce),Ee=o(we*ge),Se=o(he*ge),Le=(nt=c.BASE.multiplyAndAddUnsafe(te,Ee,Se))==null?void 0:nt.toAffine();return Le?o(Le.x)===he:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:E,sign:M,verify:W,ProjectivePoint:c,Signature:w,utils:v}}function jI(t){return{hash:t,hmac:(e,...r)=>Mh(t,e,qx(...r)),randomBytes:Qo}}function zI(t,e){const r=n=>UI({...t,...jI(n)});return{...r(e),create:r}}const v2=d2(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),FI=v2.create(BigInt("-3")),HI=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),qI=zI({a:FI,b:HI,Fp:v2,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},il),y2="base10",Wt="base16",Zr="base64pad",hi="base64url",ol="utf8",b2=0,Wn=1,al=2,WI=0,ww=1,rc=12,r1=32;function VI(){const t=Zf.utils.randomPrivateKey(),e=Zf.getPublicKey(t);return{privateKey:or(t,Wt),publicKey:or(e,Wt)}}function Yf(){const t=Qo(r1);return or(t,Wt)}function KI(t,e){const r=Zf.getSharedSecret(Lr(t,Wt),Lr(e,Wt)),n=J_(il,r,void 0,void 0,r1);return or(n,Wt)}function Hu(t){const e=il(Lr(t,Wt));return or(e,Wt)}function fn(t){const e=il(Lr(t,ol));return or(e,Wt)}function C2(t){return Lr(`${t}`,y2)}function ms(t){return Number(or(t,y2))}function E2(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function x2(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4;return e+"=".repeat(r)}function GI(t){const e=C2(typeof t.type<"u"?t.type:b2);if(ms(e)===Wn&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Lr(t.senderPublicKey,Wt):void 0,n=typeof t.iv<"u"?Lr(t.iv,Wt):Qo(rc),i=Lr(t.symKey,Wt),s=o2(i,n).encrypt(Lr(t.message,ol)),o=_2({type:e,sealed:s,iv:n,senderPublicKey:r});return t.encoding===hi?E2(o):o}function ZI(t){const e=Lr(t.symKey,Wt),{sealed:r,iv:n}=vc({encoded:t.encoded,encoding:t.encoding}),i=o2(e,n).decrypt(r);if(i===null)throw new Error("Failed to decrypt");return or(i,ol)}function YI(t,e){const r=C2(al),n=Qo(rc),i=Lr(t,ol),s=_2({type:r,sealed:i,iv:n});return e===hi?E2(s):s}function JI(t,e){const{sealed:r}=vc({encoded:t,encoding:e});return or(r,ol)}function _2(t){if(ms(t.type)===al)return or(tc([t.type,t.sealed]),Zr);if(ms(t.type)===Wn){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return or(tc([t.type,t.senderPublicKey,t.iv,t.sealed]),Zr)}return or(tc([t.type,t.iv,t.sealed]),Zr)}function vc(t){const e=(t.encoding||Zr)===hi?x2(t.encoded):t.encoded,r=Lr(e,Zr),n=r.slice(WI,ww),i=ww;if(ms(n)===Wn){const c=i+r1,l=c+rc,u=r.slice(i,c),h=r.slice(c,l),d=r.slice(l);return{type:n,sealed:d,iv:h,senderPublicKey:u}}if(ms(n)===al){const c=r.slice(i),l=Qo(rc);return{type:n,sealed:c,iv:l}}const s=i+rc,o=r.slice(i,s),a=r.slice(s);return{type:n,sealed:a,iv:o}}function XI(t,e){const r=vc({encoded:t,encoding:e==null?void 0:e.encoding});return I2({type:ms(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?or(r.senderPublicKey,Wt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function I2(t){const e=(t==null?void 0:t.type)||b2;if(e===Wn){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function mw(t){return t.type===Wn&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function vw(t){return t.type===al}function QI(t){const e=Buffer.from(t.x,"base64"),r=Buffer.from(t.y,"base64");return tc([new Uint8Array([4]),e,r])}function eA(t,e){const[r,n,i]=t.split("."),s=Buffer.from(x2(i),"base64");if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32),a=s.slice(32,64),c=`${r}.${n}`,l=il(c),u=QI(e);if(!qI.verify(tc([o,a]),l,u))throw new Error("Invalid signature");return Mf(t).payload}const tA="irn";function lh(t){return(t==null?void 0:t.relay)||{protocol:tA}}function Va(t){const e=ox[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function rA(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),o=t[i];r[s]=o}}),r}function yw(t){if(!t.includes("wc:")){const l=Kb(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((l,u)=>{a[u]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:n,topic:nA(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:rA(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function nA(t){return t.startsWith("//")?t.substring(2):t}function iA(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=i,o=r+e+s;t[s]&&(n[o]=t[s])}),n}function bw(t){const e=new URLSearchParams,r=iA(t.relay);Object.keys(r).sort().forEach(i=>{e.set(i,r[i])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const n=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${n}`}function Sl(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function ta(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function sA(t){const e=[];return Object.values(t).forEach(r=>{e.push(...ta(r.accounts))}),e}function oA(t,e){const r=[];return Object.values(t).forEach(n=>{ta(n.accounts).includes(e)&&r.push(...n.methods)}),r}function aA(t,e){const r=[];return Object.values(t).forEach(n=>{ta(n.accounts).includes(e)&&r.push(...n.events)}),r}function n1(t){return t.includes(":")}function Ka(t){return n1(t)?t.split(":")[0]:t}function cA(t){const e={};return t==null||t.forEach(r=>{var n;const[i,s]=r.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[],methods:[]}),e[i].accounts.push(r),(n=e[i].chains)==null||n.push(`${i}:${s}`)}),e}function Cw(t,e){e=e.map(n=>n.replace("did:pkh:",""));const r=cA(e);for(const[n,i]of Object.entries(r))i.methods?i.methods=zu(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return r}const lA={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},uA={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function G(t,e){const{message:r,code:n}=uA[t];return{message:e?`${r} ${e}`:r,code:n}}function Ue(t,e){const{message:r,code:n}=lA[t];return{message:e?`${r} ${e}`:r,code:n}}function Yr(t,e){return!!Array.isArray(t)}function yc(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function jt(t){return typeof t>"u"}function ht(t,e){return e&&jt(t)?!0:typeof t=="string"&&!!t.trim().length}function i1(t,e){return typeof t=="number"&&!isNaN(t)}function hA(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return rs(i,n)?(n.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=ta(a),h=r[o];(!rs(Fb(o,h),u)||!rs(h.methods,c)||!rs(h.events,l))&&(s=!1)}),s):!1}function uh(t){return ht(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function dA(t){if(ht(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&uh(r)}}return!1}function pA(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(ht(t,!1)){if(e(t))return!0;const r=Kb(t);return e(r)}}catch{}return!1}function fA(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function gA(t){return t==null?void 0:t.topic}function wA(t,e){let r=null;return ht(t==null?void 0:t.publicKey,!1)||(r=G("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Ew(t){let e=!0;return Yr(t)?t.length&&(e=t.every(r=>ht(r,!1))):e=!1,e}function mA(t,e,r){let n=null;return Yr(e)&&e.length?e.forEach(i=>{n||uh(i)||(n=Ue("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):uh(t)||(n=Ue("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}function vA(t,e,r){let n=null;return Object.entries(t).forEach(([i,s])=>{if(n)return;const o=mA(i,Fb(i,s),`${e} ${r}`);o&&(n=o)}),n}function yA(t,e){let r=null;return Yr(t)?t.forEach(n=>{r||dA(n)||(r=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function bA(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=yA(n==null?void 0:n.accounts,`${e} namespace`);i&&(r=i)}),r}function CA(t,e){let r=null;return Ew(t==null?void 0:t.methods)?Ew(t==null?void 0:t.events)||(r=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function A2(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=CA(n,`${e}, namespace`);i&&(r=i)}),r}function EA(t,e,r){let n=null;if(t&&yc(t)){const i=A2(t,e);i&&(n=i);const s=vA(t,e,r);s&&(n=s)}else n=G("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return n}function Wd(t,e){let r=null;if(t&&yc(t)){const n=A2(t,e);n&&(r=n);const i=bA(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function $2(t){return ht(t.protocol,!0)}function xA(t,e){let r=!1;return t?t&&Yr(t)&&t.length&&t.forEach(n=>{r=$2(n)}):r=!0,r}function _A(t){return typeof t=="number"}function rr(t){return typeof t<"u"&&typeof t!==null}function IA(t){return!(!t||typeof t!="object"||!t.code||!i1(t.code)||!t.message||!ht(t.message,!1))}function AA(t){return!(jt(t)||!ht(t.method,!1))}function $A(t){return!(jt(t)||jt(t.result)&&jt(t.error)||!i1(t.id)||!ht(t.jsonrpc,!1))}function SA(t){return!(jt(t)||!ht(t.name,!1))}function xw(t,e){return!(!uh(e)||!sA(t).includes(e))}function NA(t,e,r){return ht(r,!1)?oA(t,e).includes(r):!1}function OA(t,e,r){return ht(r,!1)?aA(t,e).includes(r):!1}function _w(t,e,r){let n=null;const i=PA(t),s=kA(e),o=Object.keys(i),a=Object.keys(s),c=Iw(Object.keys(t)),l=Iw(Object.keys(e)),u=c.filter(h=>!l.includes(h));return u.length&&(n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
@@ -36,7 +36,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
36
36
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
37
37
|
PERFORMANCE OF THIS SOFTWARE.
|
|
38
38
|
***************************************************************************** */var Qf=function(t,e){return Qf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Qf(t,e)};function YS(t,e){Qf(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var e0=function(){return e0=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},e0.apply(this,arguments)};function JS(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function XS(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function QS(t,e){return function(r,n){e(r,n,t)}}function eN(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function tN(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(u){try{l(n.next(u))}catch(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(t,e||[])).next())})}function rN(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function nN(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function iN(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function t0(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function w3(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function sN(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(w3(arguments[e]));return t}function oN(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Ec(t){return this instanceof Ec?(this.v=t,this):new Ec(t)}function aN(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(d){n[d]&&(i[d]=function(p){return new Promise(function(f,g){s.push([d,p,f,g])>1||a(d,p)})})}function a(d,p){try{c(n[d](p))}catch(f){h(s[0][3],f)}}function c(d){d.value instanceof Ec?Promise.resolve(d.value.v).then(l,u):h(s[0][2],d)}function l(d){a("next",d)}function u(d){a("throw",d)}function h(d,p){d(p),s.shift(),s.length&&a(s[0][0],s[0][1])}}function cN(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Ec(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function lN(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof t0=="function"?t0(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}function uN(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function hN(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function dN(t){return t&&t.__esModule?t:{default:t}}function pN(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function fN(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const gN=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return e0},__asyncDelegator:cN,__asyncGenerator:aN,__asyncValues:lN,__await:Ec,__awaiter:tN,__classPrivateFieldGet:pN,__classPrivateFieldSet:fN,__createBinding:nN,__decorate:XS,__exportStar:iN,__extends:YS,__generator:rN,__importDefault:dN,__importStar:hN,__makeTemplateObject:uN,__metadata:eN,__param:QS,__read:w3,__rest:JS,__spread:sN,__spreadArrays:oN,__values:t0},Symbol.toStringTag,{value:"Module"})),wN=By(gN);var In={},Kw;function mN(){if(Kw)return In;Kw=1,Object.defineProperty(In,"__esModule",{value:!0}),In.isBrowserCryptoAvailable=In.getSubtleCrypto=In.getBrowerCrypto=void 0;function t(){return(pn===null||pn===void 0?void 0:pn.crypto)||(pn===null||pn===void 0?void 0:pn.msCrypto)||{}}In.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}In.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return In.isBrowserCryptoAvailable=r,In}var An={},Gw;function vN(){if(Gw)return An;Gw=1,Object.defineProperty(An,"__esModule",{value:!0}),An.isBrowser=An.isNode=An.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}An.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}An.isNode=e;function r(){return!t()&&!e()}return An.isBrowser=r,An}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=wN;e.__exportStar(mN(),t),e.__exportStar(vN(),t)})(g3);function hn(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function ns(t=6){return BigInt(hn(t))}function fi(t,e,r){return{id:r||hn(),jsonrpc:"2.0",method:t,params:e}}function Zh(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Yh(t,e,r){return{id:t,jsonrpc:"2.0",error:yN(e)}}function yN(t,e){return typeof t>"u"?Vw(d3):(typeof t=="string"&&(t=Object.assign(Object.assign({},Vw(l1)),{message:t})),GS(t.code)&&(t=ZS(t.code)),t)}class bN{}class CN extends bN{constructor(){super()}}class EN extends CN{constructor(e){super()}}const xN="^https?:",_N="^wss?:";function IN(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function m3(t,e){const r=IN(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Zw(t){return m3(t,xN)}function Yw(t){return m3(t,_N)}function AN(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function v3(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function u1(t){return v3(t)&&"method"in t}function Jh(t){return v3(t)&&(dn(t)||Rr(t))}function dn(t){return"result"in t}function Rr(t){return"error"in t}let Dr=class extends EN{constructor(e){super(e),this.events=new FS.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(fi(e.method,e.params||[],e.id||ns().toString()),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{Rr(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Jh(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var h1={exports:{}},Io=typeof Reflect=="object"?Reflect:null,Jw=Io&&typeof Io.apply=="function"?Io.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Yu;Io&&typeof Io.ownKeys=="function"?Yu=Io.ownKeys:Object.getOwnPropertySymbols?Yu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yu=function(e){return Object.getOwnPropertyNames(e)};function $N(t){console&&console.warn&&console.warn(t)}var y3=Number.isNaN||function(e){return e!==e};function We(){We.init.call(this)}h1.exports=We;h1.exports.once=PN;We.EventEmitter=We;We.prototype._events=void 0;We.prototype._eventsCount=0;We.prototype._maxListeners=void 0;var Xw=10;function Xh(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(We,"defaultMaxListeners",{enumerable:!0,get:function(){return Xw},set:function(t){if(typeof t!="number"||t<0||y3(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Xw=t}});We.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};We.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||y3(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function b3(t){return t._maxListeners===void 0?We.defaultMaxListeners:t._maxListeners}We.prototype.getMaxListeners=function(){return b3(this)};We.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")Jw(c,this,r);else for(var l=c.length,u=I3(c,l),n=0;n<l;++n)Jw(u[n],this,r);return!0};function C3(t,e,r,n){var i,s,o;if(Xh(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=b3(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,$N(a)}return t}We.prototype.addListener=function(e,r){return C3(this,e,r,!1)};We.prototype.on=We.prototype.addListener;We.prototype.prependListener=function(e,r){return C3(this,e,r,!0)};function SN(){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 E3(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=SN.bind(n);return i.listener=r,n.wrapFn=i,i}We.prototype.once=function(e,r){return Xh(r),this.on(e,E3(this,e,r)),this};We.prototype.prependOnceListener=function(e,r){return Xh(r),this.prependListener(e,E3(this,e,r)),this};We.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Xh(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():NN(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};We.prototype.off=We.prototype.removeListener;We.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function x3(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?ON(i):I3(i,i.length)}We.prototype.listeners=function(e){return x3(this,e,!0)};We.prototype.rawListeners=function(e){return x3(this,e,!1)};We.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):_3.call(t,e)};We.prototype.listenerCount=_3;function _3(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}We.prototype.eventNames=function(){return this._eventsCount>0?Yu(this._events):[]};function I3(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function NN(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ON(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function PN(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}A3(t,e,s,{once:!0}),e!=="error"&&kN(t,i,{once:!0})})}function kN(t,e,r){typeof t.on=="function"&&A3(t,"error",e,r)}function A3(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var TN=h1.exports;const RN=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),LN=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Qw=t=>t.split("?")[0],em=10,DN=RN();let BN=class{constructor(e){if(this.url=e,this.events=new TN.EventEmitter,this.registering=!1,!Yw(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Gn(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!Yw(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=g3.isReactNative()?void 0:{rejectUnauthorized:!AN(e)},s=new DN(e,[],i);LN()?s.onerror=o=>{const a=o;n(this.emitError(a.error))}:s.on("error",o=>{n(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?fs(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Yh(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return f3(e,Qw(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>em&&this.events.setMaxListeners(em)}emitError(e){const r=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${Qw(this.url)}`));return this.events.emit("register_error",r),r}};var MN={VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm"};const $3="wc",S3=2,ph="core",yn=`${$3}@2:${ph}:`,UN={name:ph,logger:"error"},jN={database:":memory:"},zN="crypto",tm="client_ed25519_seed",FN=K.ONE_DAY,HN="keychain",qN="0.3",WN="messages",VN="0.3",rm=K.SIX_HOURS,KN="publisher",N3="irn",GN="error",O3="wss://relay.walletconnect.org",ZN="relayer",At={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},YN="_subscription",Er={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},JN=.1,r0="2.20.2",it={link_mode:"link_mode",relay:"relay"},Ju={inbound:"inbound",outbound:"outbound"},XN="0.3",QN="WALLETCONNECT_CLIENT_ID",nm="WALLETCONNECT_LINK_MODE_APPS",gr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},eO="subscription",tO="0.3",rO="pairing",nO="0.3",fa={wc_pairingDelete:{req:{ttl:K.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:K.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:K.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:K.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:K.ONE_DAY,prompt:!1,tag:0},res:{ttl:K.ONE_DAY,prompt:!1,tag:0}}},Xi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ur={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},iO="history",sO="0.3",oO="expirer",Tr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},aO="0.3",cO="verify-api",lO="https://verify.walletconnect.com",P3="https://verify.walletconnect.org",ic=P3,uO=`${ic}/v3`,hO=[lO,P3],dO="echo",pO="https://echo.walletconnect.com",ln={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Mn={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},jr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Si={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Ni={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ga={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},fO=.1,gO="event-client",wO=86400,mO="https://pulse.walletconnect.org/batch";function vO(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,w=0,v=0,b=f.length;v!==b&&f[v]===0;)v++,g++;for(var C=(b-v)*u+1>>>0,E=new Uint8Array(C);v!==b;){for(var A=f[v],S=0,T=C-1;(A!==0||S<w)&&T!==-1;T--,S++)A+=256*E[T]>>>0,E[T]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");w=S,v++}for(var k=C-w;k!==C&&E[k]===0;)k++;for(var I=c.repeat(g);k<C;++k)I+=t.charAt(E[k]);return I}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var w=0,v=0;f[g]===c;)w++,g++;for(var b=(f.length-g)*l+1>>>0,C=new Uint8Array(b);f[g];){var E=r[f.charCodeAt(g)];if(E===255)return;for(var A=0,S=b-1;(E!==0||A<v)&&S!==-1;S--,A++)E+=a*C[S]>>>0,C[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");v=A,g++}if(f[g]!==" "){for(var T=b-v;T!==b&&C[T]===0;)T++;for(var k=new Uint8Array(w+(b-T)),I=w;T!==b;)k[I++]=C[T++];return k}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:d,decode:p}}var yO=vO,bO=yO;const k3=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")},CO=t=>new TextEncoder().encode(t),EO=t=>new TextDecoder().decode(t);let xO=class{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")}},_O=class{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 T3(this,e)}},IO=class{constructor(e){this.decoders=e}or(e){return T3(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 T3=(t,e)=>new IO({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let AO=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new xO(e,r,n),this.decoder=new _O(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Qh=({name:t,prefix:e,encode:r,decode:n})=>new AO(t,e,r,n),hl=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=bO(r,e);return Qh({prefix:t,name:e,encode:n,decode:s=>k3(i(s))})},$O=(t,e,r,n)=>{const i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=i[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},SO=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Dt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Qh({prefix:e,name:t,encode(i){return SO(i,n,r)},decode(i){return $O(i,n,r,t)}}),NO=Qh({prefix:"\0",name:"identity",encode:t=>EO(t),decode:t=>CO(t)});var OO=Object.freeze({__proto__:null,identity:NO});const PO=Dt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kO=Object.freeze({__proto__:null,base2:PO});const TO=Dt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var RO=Object.freeze({__proto__:null,base8:TO});const LO=hl({prefix:"9",name:"base10",alphabet:"0123456789"});var DO=Object.freeze({__proto__:null,base10:LO});const BO=Dt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),MO=Dt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var UO=Object.freeze({__proto__:null,base16:BO,base16upper:MO});const jO=Dt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zO=Dt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),FO=Dt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),HO=Dt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qO=Dt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),WO=Dt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),VO=Dt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),KO=Dt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),GO=Dt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ZO=Object.freeze({__proto__:null,base32:jO,base32upper:zO,base32pad:FO,base32padupper:HO,base32hex:qO,base32hexupper:WO,base32hexpad:VO,base32hexpadupper:KO,base32z:GO});const YO=hl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JO=hl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var XO=Object.freeze({__proto__:null,base36:YO,base36upper:JO});const QO=hl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),eP=hl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tP=Object.freeze({__proto__:null,base58btc:QO,base58flickr:eP});const rP=Dt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nP=Dt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),iP=Dt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sP=Dt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var oP=Object.freeze({__proto__:null,base64:rP,base64pad:nP,base64url:iP,base64urlpad:sP});const R3=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),aP=R3.reduce((t,e,r)=>(t[r]=e,t),[]),cP=R3.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function lP(t){return t.reduce((e,r)=>(e+=aP[r],e),"")}function uP(t){const e=[];for(const r of t){const n=cP[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const hP=Qh({prefix:"🚀",name:"base256emoji",encode:lP,decode:uP});var dP=Object.freeze({__proto__:null,base256emoji:hP}),pP=L3,im=128,fP=127,gP=~fP,wP=Math.pow(2,31);function L3(t,e,r){e=e||[],r=r||0;for(var n=r;t>=wP;)e[r++]=t&255|im,t/=128;for(;t&gP;)e[r++]=t&255|im,t>>>=7;return e[r]=t|0,L3.bytes=r-n+1,e}var mP=n0,vP=128,sm=127;function n0(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw n0.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&sm)<<i:(o&sm)*Math.pow(2,i),i+=7}while(o>=vP);return n0.bytes=s-n,r}var yP=Math.pow(2,7),bP=Math.pow(2,14),CP=Math.pow(2,21),EP=Math.pow(2,28),xP=Math.pow(2,35),_P=Math.pow(2,42),IP=Math.pow(2,49),AP=Math.pow(2,56),$P=Math.pow(2,63),SP=function(t){return t<yP?1:t<bP?2:t<CP?3:t<EP?4:t<xP?5:t<_P?6:t<IP?7:t<AP?8:t<$P?9:10},NP={encode:pP,decode:mP,encodingLength:SP},D3=NP;const om=(t,e,r=0)=>(D3.encode(t,e,r),e),am=t=>D3.encodingLength(t),i0=(t,e)=>{const r=e.byteLength,n=am(t),i=n+am(r),s=new Uint8Array(i+r);return om(t,s,0),om(r,s,n),s.set(e,i),new OP(t,r,e,s)};let OP=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};const B3=({name:t,code:e,encode:r})=>new PP(t,e,r);let PP=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?i0(this.code,r):r.then(n=>i0(this.code,n))}else throw Error("Unknown type, must be binary type")}};const M3=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),kP=B3({name:"sha2-256",code:18,encode:M3("SHA-256")}),TP=B3({name:"sha2-512",code:19,encode:M3("SHA-512")});var RP=Object.freeze({__proto__:null,sha256:kP,sha512:TP});const U3=0,LP="identity",j3=k3,DP=t=>i0(U3,j3(t)),BP={code:U3,name:LP,encode:j3,digest:DP};var MP=Object.freeze({__proto__:null,identity:BP});new TextEncoder,new TextDecoder;const cm={...OO,...kO,...RO,...DO,...UO,...ZO,...XO,...tP,...oP,...dP};({...RP,...MP});function UP(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function z3(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const lm=z3("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Yd=z3("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=UP(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),jP={utf8:lm,"utf-8":lm,hex:cm.base16,latin1:Yd,ascii:Yd,binary:Yd,...cm};function zP(t,e="utf8"){const r=jP[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var FP=Object.defineProperty,HP=(t,e,r)=>e in t?FP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,tn=(t,e,r)=>HP(t,typeof e!="symbol"?e+"":e,r);let qP=class{constructor(e,r){this.core=e,this.logger=r,tn(this,"keychain",new Map),tn(this,"name",HN),tn(this,"version",qN),tn(this,"initialized",!1),tn(this,"storagePrefix",yn),tn(this,"init",async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}}),tn(this,"has",n=>(this.isInitialized(),this.keychain.has(n))),tn(this,"set",async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()}),tn(this,"get",n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=G("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i}),tn(this,"del",async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()}),this.core=e,this.logger=Kt(r,this.name)}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Uf(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?jf(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var WP=Object.defineProperty,VP=(t,e,r)=>e in t?WP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pt=(t,e,r)=>VP(t,typeof e!="symbol"?e+"":e,r);let KP=class{constructor(e,r,n){this.core=e,this.logger=r,Pt(this,"name",zN),Pt(this,"keychain"),Pt(this,"randomSessionIdentifier",Yf()),Pt(this,"initialized",!1),Pt(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Pt(this,"hasKeys",i=>(this.isInitialized(),this.keychain.has(i))),Pt(this,"getClientId",async()=>{this.isInitialized();const i=await this.getClientSeed(),s=Rg(i);return Db(s.publicKey)}),Pt(this,"generateKeyPair",()=>{this.isInitialized();const i=VI();return this.setPrivateKey(i.publicKey,i.privateKey)}),Pt(this,"signJWT",async i=>{this.isInitialized();const s=await this.getClientSeed(),o=Rg(s),a=this.randomSessionIdentifier;return await lE(a,i,FN,o)}),Pt(this,"generateSharedKey",(i,s,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=KI(a,s);return this.setSymKey(c,o)}),Pt(this,"setSymKey",async(i,s)=>{this.isInitialized();const o=s||Hu(i);return await this.keychain.set(o,i),o}),Pt(this,"deleteKeyPair",async i=>{this.isInitialized(),await this.keychain.del(i)}),Pt(this,"deleteSymKey",async i=>{this.isInitialized(),await this.keychain.del(i)}),Pt(this,"encode",async(i,s,o)=>{this.isInitialized();const a=I2(o),c=Gn(s);if(vw(a))return YI(c,o==null?void 0:o.encoding);if(mw(a)){const d=a.senderPublicKey,p=a.receiverPublicKey;i=await this.generateSharedKey(d,p)}const l=this.getSymKey(i),{type:u,senderPublicKey:h}=a;return GI({type:u,symKey:l,message:c,senderPublicKey:h,encoding:o==null?void 0:o.encoding})}),Pt(this,"decode",async(i,s,o)=>{this.isInitialized();const a=XI(s,o);if(vw(a)){const c=JI(s,o==null?void 0:o.encoding);return fs(c)}if(mw(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=ZI({symKey:c,encoded:s,encoding:o==null?void 0:o.encoding});return fs(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Pt(this,"getPayloadType",(i,s=Zr)=>{const o=vc({encoded:i,encoding:s});return ms(o.type)}),Pt(this,"getPayloadSenderPublicKey",(i,s=Zr)=>{const o=vc({encoded:i,encoding:s});return o.senderPublicKey?or(o.senderPublicKey,Wt):void 0}),this.core=e,this.logger=Kt(r,this.name),this.keychain=n||new qP(this.core,this.logger)}get context(){return ar(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(tm)}catch{e=Yf(),await this.keychain.set(tm,e)}return zP(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var GP=Object.defineProperty,ZP=Object.defineProperties,YP=Object.getOwnPropertyDescriptors,um=Object.getOwnPropertySymbols,JP=Object.prototype.hasOwnProperty,XP=Object.prototype.propertyIsEnumerable,s0=(t,e,r)=>e in t?GP(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,QP=(t,e)=>{for(var r in e||(e={}))JP.call(e,r)&&s0(t,r,e[r]);if(um)for(var r of um(e))XP.call(e,r)&&s0(t,r,e[r]);return t},ek=(t,e)=>ZP(t,YP(e)),lr=(t,e,r)=>s0(t,typeof e!="symbol"?e+"":e,r);let tk=class extends xS{constructor(e,r){super(e,r),this.logger=e,this.core=r,lr(this,"messages",new Map),lr(this,"messagesWithoutClientAck",new Map),lr(this,"name",WN),lr(this,"version",VN),lr(this,"initialized",!1),lr(this,"storagePrefix",yn),lr(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}}),lr(this,"set",async(n,i,s)=>{this.isInitialized();const o=fn(i);let a=this.messages.get(n);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(n,a),s===Ju.inbound){const c=this.messagesWithoutClientAck.get(n)||{};this.messagesWithoutClientAck.set(n,ek(QP({},c),{[o]:i}))}return await this.persist(),o}),lr(this,"get",n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i}),lr(this,"getWithoutAck",n=>{this.isInitialized();const i={};for(const s of n){const o=this.messagesWithoutClientAck.get(s)||{};i[s]=Object.values(o)}return i}),lr(this,"has",(n,i)=>{this.isInitialized();const s=this.get(n),o=fn(i);return typeof s[o]<"u"}),lr(this,"ack",async(n,i)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(n);if(typeof s>"u")return;const o=fn(i);delete s[o],Object.keys(s).length===0?this.messagesWithoutClientAck.delete(n):this.messagesWithoutClientAck.set(n,s),await this.persist()}),lr(this,"del",async n=>{this.isInitialized(),this.messages.delete(n),this.messagesWithoutClientAck.delete(n),await this.persist()}),this.logger=Kt(e,this.name),this.core=r}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Uf(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,Uf(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?jf(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?jf(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var rk=Object.defineProperty,nk=Object.defineProperties,ik=Object.getOwnPropertyDescriptors,hm=Object.getOwnPropertySymbols,sk=Object.prototype.hasOwnProperty,ok=Object.prototype.propertyIsEnumerable,o0=(t,e,r)=>e in t?rk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kl=(t,e)=>{for(var r in e||(e={}))sk.call(e,r)&&o0(t,r,e[r]);if(hm)for(var r of hm(e))ok.call(e,r)&&o0(t,r,e[r]);return t},Jd=(t,e)=>nk(t,ik(e)),zr=(t,e,r)=>o0(t,typeof e!="symbol"?e+"":e,r);let ak=class extends _S{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,zr(this,"events",new _s.EventEmitter),zr(this,"name",KN),zr(this,"queue",new Map),zr(this,"publishTimeout",K.toMiliseconds(K.ONE_MINUTE)),zr(this,"initialPublishTimeout",K.toMiliseconds(K.ONE_SECOND*15)),zr(this,"needsTransportRestart",!1),zr(this,"publish",async(n,i,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});const a=(s==null?void 0:s.ttl)||rm,c=lh(s),l=(s==null?void 0:s.prompt)||!1,u=(s==null?void 0:s.tag)||0,h=(s==null?void 0:s.id)||ns().toString(),d={topic:n,message:i,opts:{ttl:a,relay:c,prompt:l,tag:u,id:h,attestation:s==null?void 0:s.attestation,tvf:s==null?void 0:s.tvf}},p=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const f=new Promise(async g=>{const w=({id:b})=>{d.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(At.publish,w),g(d))};this.relayer.events.on(At.publish,w);const v=pi(new Promise((b,C)=>{this.rpcPublish({topic:n,message:i,ttl:a,prompt:l,tag:u,id:h,attestation:s==null?void 0:s.attestation,tvf:s==null?void 0:s.tvf}).then(b).catch(E=>{this.logger.warn(E,E==null?void 0:E.message),C(E)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await v,this.events.removeListener(At.publish,w)}catch(b){this.queue.set(h,Jd(kl({},d),{attempt:1})),this.logger.warn(b,b==null?void 0:b.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:n,message:i,opts:s}}),await pi(f,this.publishTimeout,p)}catch(f){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(f),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw f}finally{this.queue.delete(h)}}),zr(this,"on",(n,i)=>{this.events.on(n,i)}),zr(this,"once",(n,i)=>{this.events.once(n,i)}),zr(this,"off",(n,i)=>{this.events.off(n,i)}),zr(this,"removeListener",(n,i)=>{this.events.removeListener(n,i)}),this.relayer=e,this.logger=Kt(r,this.name),this.registerEventListeners()}get context(){return ar(this.logger)}async rpcPublish(e){var r,n,i,s;const{topic:o,message:a,ttl:c=rm,prompt:l,tag:u,id:h,attestation:d,tvf:p}=e,f={method:Va(lh().protocol).publish,params:kl({topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:d},p),id:h};jt((r=f.params)==null?void 0:r.prompt)&&((n=f.params)==null||delete n.prompt),jt((i=f.params)==null?void 0:i.tag)&&((s=f.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f});const g=await this.relayer.request(f);return this.relayer.events.emit(At.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const n=e.attempt+1;this.queue.set(r,Jd(kl({},e),{attempt:n}));const{topic:i,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${n}`),await this.rpcPublish(Jd(kl({},e),{topic:i,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(ra.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(At.connection_stalled);return}this.checkQueue()}),this.relayer.on(At.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}};var ck=Object.defineProperty,lk=(t,e,r)=>e in t?ck(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bs=(t,e,r)=>lk(t,typeof e!="symbol"?e+"":e,r);let uk=class{constructor(){Bs(this,"map",new Map),Bs(this,"set",(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])}),Bs(this,"get",e=>this.map.get(e)||[]),Bs(this,"exists",(e,r)=>this.get(e).includes(r)),Bs(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)}),Bs(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}};var hk=Object.defineProperty,dk=Object.defineProperties,pk=Object.getOwnPropertyDescriptors,dm=Object.getOwnPropertySymbols,fk=Object.prototype.hasOwnProperty,gk=Object.prototype.propertyIsEnumerable,a0=(t,e,r)=>e in t?hk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wa=(t,e)=>{for(var r in e||(e={}))fk.call(e,r)&&a0(t,r,e[r]);if(dm)for(var r of dm(e))gk.call(e,r)&&a0(t,r,e[r]);return t},Xd=(t,e)=>dk(t,pk(e)),Ze=(t,e,r)=>a0(t,typeof e!="symbol"?e+"":e,r);let wk=class extends $S{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,Ze(this,"subscriptions",new Map),Ze(this,"topicMap",new uk),Ze(this,"events",new _s.EventEmitter),Ze(this,"name",eO),Ze(this,"version",tO),Ze(this,"pending",new Map),Ze(this,"cached",[]),Ze(this,"initialized",!1),Ze(this,"storagePrefix",yn),Ze(this,"subscribeTimeout",K.toMiliseconds(K.ONE_MINUTE)),Ze(this,"initialSubscribeTimeout",K.toMiliseconds(K.ONE_SECOND*15)),Ze(this,"clientId"),Ze(this,"batchSubscribeTopicsLimit",500),Ze(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ze(this,"subscribe",async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=lh(i),o={topic:n,relay:s,transportType:i==null?void 0:i.transportType};this.pending.set(n,o);const a=await this.rpcSubscribe(n,s,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),Ze(this,"unsubscribe",async(n,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)}),Ze(this,"isSubscribed",n=>new Promise(i=>{i(this.topicMap.topics.includes(n))})),Ze(this,"isKnownTopic",n=>new Promise(i=>{i(this.topicMap.topics.includes(n)||this.pending.has(n)||this.cached.some(s=>s.topic===n))})),Ze(this,"on",(n,i)=>{this.events.on(n,i)}),Ze(this,"once",(n,i)=>{this.events.once(n,i)}),Ze(this,"off",(n,i)=>{this.events.off(n,i)}),Ze(this,"removeListener",(n,i)=>{this.events.removeListener(n,i)}),Ze(this,"start",async()=>{await this.onConnect()}),Ze(this,"stop",async()=>{await this.onDisconnect()}),Ze(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Ze(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const n=[];this.pending.forEach(i=>{n.push(i)}),await this.batchSubscribe(n)}),Ze(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(ra.pulse,async()=>{await this.checkPending()}),this.events.on(gr.created,async n=>{const i=gr.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:n}),await this.persist()}),this.events.on(gr.deleted,async n=>{const i=gr.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:n}),await this.persist()})}),this.relayer=e,this.logger=Kt(r,this.name),this.clientId=""}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=lh(n);await this.restartToComplete({topic:e,id:r,relay:i}),await this.rpcUnsubscribe(e,r,i);const s=Ue("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r,n){var i;(!n||(n==null?void 0:n.transportType)===it.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const s={method:Va(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(i=n==null?void 0:n.internal)==null?void 0:i.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((n==null?void 0:n.transportType)===it.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},K.toMiliseconds(K.ONE_SECOND)),a;const c=new Promise(async u=>{const h=d=>{d.topic===e&&(this.events.removeListener(gr.created,h),u(d.id))};this.events.on(gr.created,h);try{const d=await pi(new Promise((p,f)=>{this.relayer.request(s).catch(g=>{this.logger.warn(g,g==null?void 0:g.message),f(g)}).then(p)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(gr.created,h),u(d)}catch{}}),l=await pi(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(At.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,n={method:Va(r.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await pi(new Promise(i=>{this.relayer.request(n).catch(s=>this.logger.warn(s)).then(i)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(At.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,n={method:Va(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await pi(new Promise((s,o)=>{this.relayer.request(n).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(At.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:Va(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,r){this.setSubscription(e,Xd(wa({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,wa({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,wa({},r)),this.topicMap.set(r.topic,e),this.events.emit(gr.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(gr.deleted,Xd(wa({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(gr.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let n=0;n<r;n++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(gr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>Xd(wa({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await Tx(K.toMiliseconds(K.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return fn(e+await this.getClientId())}};var mk=Object.defineProperty,pm=Object.getOwnPropertySymbols,vk=Object.prototype.hasOwnProperty,yk=Object.prototype.propertyIsEnumerable,c0=(t,e,r)=>e in t?mk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fm=(t,e)=>{for(var r in e||(e={}))vk.call(e,r)&&c0(t,r,e[r]);if(pm)for(var r of pm(e))yk.call(e,r)&&c0(t,r,e[r]);return t},Oe=(t,e,r)=>c0(t,typeof e!="symbol"?e+"":e,r);let bk=class extends IS{constructor(e){super(e),Oe(this,"protocol","wc"),Oe(this,"version",2),Oe(this,"core"),Oe(this,"logger"),Oe(this,"events",new _s.EventEmitter),Oe(this,"provider"),Oe(this,"messages"),Oe(this,"subscriber"),Oe(this,"publisher"),Oe(this,"name",ZN),Oe(this,"transportExplicitlyClosed",!1),Oe(this,"initialized",!1),Oe(this,"connectionAttemptInProgress",!1),Oe(this,"relayUrl"),Oe(this,"projectId"),Oe(this,"packageName"),Oe(this,"bundleId"),Oe(this,"hasExperiencedNetworkDisruption",!1),Oe(this,"pingTimeout"),Oe(this,"heartBeatTimeout",K.toMiliseconds(K.THIRTY_SECONDS+K.FIVE_SECONDS)),Oe(this,"reconnectTimeout"),Oe(this,"connectPromise"),Oe(this,"reconnectInProgress",!1),Oe(this,"requestsInFlight",[]),Oe(this,"connectTimeout",K.toMiliseconds(K.ONE_SECOND*15)),Oe(this,"request",async r=>{var n,i;this.logger.debug("Publishing Request Payload");const s=r.id||ns().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - publishing...");const o=`${s}:${((i=r.params)==null?void 0:i.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}}),Oe(this,"resetPingTimeout",()=>{ah()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n,i,s;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(s=(i=(n=(r=this.provider)==null?void 0:r.connection)==null?void 0:n.socket)==null?void 0:i.terminate)==null||s.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),Oe(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),Oe(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(At.connect)}),Oe(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Oe(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(At.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Oe(this,"registerProviderListeners",()=>{this.provider.on(Er.payload,this.onPayloadHandler),this.provider.on(Er.connect,this.onConnectHandler),this.provider.on(Er.disconnect,this.onDisconnectHandler),this.provider.on(Er.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Kt(e.logger,this.name):ll(Vh({level:e.logger||GN})),this.messages=new tk(this.logger,e.core),this.subscriber=new wk(this,this.logger),this.publisher=new ak(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||O3,this.projectId=e.projectId,mx()?this.packageName=zg():vx()&&(this.bundleId=zg()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return ar(this.logger)}get connected(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===1||!1}get connecting(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:it.relay},Ju.outbound)}async subscribe(e,r){var n,i,s;this.isInitialized(),(!(r!=null&&r.transportType)||(r==null?void 0:r.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((n=r==null?void 0:r.internal)==null?void 0:n.throwOnFailedPublish)>"u"?!0:(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(gr.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(gr.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,fm({internal:{throwOnFailedPublish:o}},r)).catch(d=>{o&&h(d)})||a,u()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await pi(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,n)=>{await this.connect(e).then(r).catch(n).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Aw())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const n of r)try{await this.onMessageEvent(n)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:n}=e;if(!r.sessionExists){const i=pt(K.FIVE_MINUTES),s={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,s)}this.events.emit(At.message,e),await this.recordMessageEvent(e,Ju.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(n,i)=>{const s=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Er.disconnect,s),await pi(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{i(o)}).finally(()=>{this.provider.off(Er.disconnect,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Er.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Er.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,n()})}catch(n){await this.subscriber.stop();const i=n;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(n=>setTimeout(n,K.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,n,i,s;if(ah())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(i=(n=this.provider)==null?void 0:n.connection)==null?void 0:i.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Dr(new BN(xx({sdkVersion:r0,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,r){const{topic:n,message:i}=e;await this.messages.set(n,i,r)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;if(!n||n.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isKnownTopic(r))return this.logger.warn(`Ignoring message for unknown topic ${r}`),!0;const i=this.messages.has(r,n);return i&&this.logger.warn(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),u1(e)){if(!e.method.endsWith(YN))return;const r=e.params,{topic:n,message:i,publishedAt:s,attestation:o}=r.data,a={topic:n,message:i,publishedAt:s,transportType:it.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(fm({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Jh(e)&&this.events.emit(At.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Ju.inbound),this.events.emit(At.message,e))}async acknowledgePayload(e){const r=Zh(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Er.payload,this.onPayloadHandler),this.provider.off(Er.connect,this.onConnectHandler),this.provider.off(Er.disconnect,this.onDisconnectHandler),this.provider.off(Er.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Aw();BA(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(n=>this.logger.error(n,n==null?void 0:n.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(At.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},K.toMiliseconds(JN)))))}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}};function Ck(){}function gm(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function wm(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function mm(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Ek="[object RegExp]",xk="[object String]",_k="[object Number]",Ik="[object Boolean]",vm="[object Arguments]",Ak="[object Symbol]",$k="[object Date]",Sk="[object Map]",Nk="[object Set]",Ok="[object Array]",Pk="[object Function]",kk="[object ArrayBuffer]",Qd="[object Object]",Tk="[object Error]",Rk="[object DataView]",Lk="[object Uint8Array]",Dk="[object Uint8ClampedArray]",Bk="[object Uint16Array]",Mk="[object Uint32Array]",Uk="[object BigUint64Array]",jk="[object Int8Array]",zk="[object Int16Array]",Fk="[object Int32Array]",Hk="[object BigInt64Array]",qk="[object Float32Array]",Wk="[object Float64Array]";function Vk(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function Kk(t,e,r){return Ga(t,e,void 0,void 0,void 0,void 0,r)}function Ga(t,e,r,n,i,s,o){const a=o(t,e,r,n,i,s);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return sc(t,e,s,o)}return sc(t,e,s,o)}function sc(t,e,r,n){if(Object.is(t,e))return!0;let i=mm(t),s=mm(e);if(i===vm&&(i=Qd),s===vm&&(s=Qd),i!==s)return!1;switch(i){case xk:return t.toString()===e.toString();case _k:{const c=t.valueOf(),l=e.valueOf();return Vk(c,l)}case Ik:case $k:case Ak:return Object.is(t.valueOf(),e.valueOf());case Ek:return t.source===e.source&&t.flags===e.flags;case Pk:return t===e}r=r??new Map;const o=r.get(t),a=r.get(e);if(o!=null&&a!=null)return o===e;r.set(t,e),r.set(e,t);try{switch(i){case Sk:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Ga(l,e.get(c),c,t,e,r,n))return!1;return!0}case Nk:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let u=0;u<c.length;u++){const h=c[u],d=l.findIndex(p=>Ga(h,p,void 0,t,e,r,n));if(d===-1)return!1;l.splice(d,1)}return!0}case Ok:case Lk:case Dk:case Bk:case Mk:case Uk:case jk:case zk:case Fk:case Hk:case qk:case Wk:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ga(t[c],e[c],c,t,e,r,n))return!1;return!0}case kk:return t.byteLength!==e.byteLength?!1:sc(new Uint8Array(t),new Uint8Array(e),r,n);case Rk:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:sc(new Uint8Array(t),new Uint8Array(e),r,n);case Tk:return t.name===e.name&&t.message===e.message;case Qd:{if(!(sc(t.constructor,e.constructor,r,n)||gm(t)&&gm(e)))return!1;const c=[...Object.keys(t),...wm(t)],l=[...Object.keys(e),...wm(e)];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){const h=c[u],d=t[h];if(!Object.hasOwn(e,h))return!1;const p=e[h];if(!Ga(d,p,h,t,e,r,n))return!1}return!0}default:return!1}}finally{r.delete(t),r.delete(e)}}function Gk(t,e){return Kk(t,e,Ck)}var Zk=Object.defineProperty,ym=Object.getOwnPropertySymbols,Yk=Object.prototype.hasOwnProperty,Jk=Object.prototype.propertyIsEnumerable,l0=(t,e,r)=>e in t?Zk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bm=(t,e)=>{for(var r in e||(e={}))Yk.call(e,r)&&l0(t,r,e[r]);if(ym)for(var r of ym(e))Jk.call(e,r)&&l0(t,r,e[r]);return t},Yt=(t,e,r)=>l0(t,typeof e!="symbol"?e+"":e,r);let $s=class extends AS{constructor(e,r,n,i=yn,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,Yt(this,"map",new Map),Yt(this,"version",XN),Yt(this,"cached",[]),Yt(this,"initialized",!1),Yt(this,"getKey"),Yt(this,"storagePrefix",yn),Yt(this,"recentlyDeleted",[]),Yt(this,"recentlyDeletedLimit",200),Yt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!jt(o)?this.map.set(this.getKey(o),o):fA(o)?this.map.set(o.id,o):gA(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Yt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Yt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Yt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>Gk(a[c],o[c]))):this.values)),Yt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=bm(bm({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Yt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Kt(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:i}=G("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var Xk=Object.defineProperty,Qk=(t,e,r)=>e in t?Xk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xe=(t,e,r)=>Qk(t,typeof e!="symbol"?e+"":e,r);let eT=class{constructor(e,r){this.core=e,this.logger=r,xe(this,"name",rO),xe(this,"version",nO),xe(this,"events",new VA),xe(this,"pairings"),xe(this,"initialized",!1),xe(this,"storagePrefix",yn),xe(this,"ignoredPayloadTypes",[Wn]),xe(this,"registeredMethods",[]),xe(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),xe(this,"register",({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]}),xe(this,"create",async n=>{this.isInitialized();const i=Yf(),s=await this.core.crypto.setSymKey(i),o=pt(K.FIVE_MINUTES),a={protocol:N3},c={topic:s,expiry:o,relay:a,active:!1,methods:n==null?void 0:n.methods},l=bw({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:a,expiryTimestamp:o,methods:n==null?void 0:n.methods});return this.events.emit(Xi.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:n==null?void 0:n.transportType}),{topic:s,uri:l}}),xe(this,"pair",async n=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:n==null?void 0:n.uri,trace:[ln.pairing_started]}});this.isValidPair(n,i);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:l}=yw(n.uri);i.props.properties.topic=s,i.addTrace(ln.pairing_uri_validation_success),i.addTrace(ln.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),i.addTrace(ln.existing_pairing),u.active)throw i.setError(Mn.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);i.addTrace(ln.pairing_not_expired)}const h=c||pt(K.FIVE_MINUTES),d={topic:s,relay:a,expiry:h,active:!1,methods:l};this.core.expirer.set(s,h),await this.pairings.set(s,d),i.addTrace(ln.store_new_pairing),n.activatePairing&&await this.activate({topic:s}),this.events.emit(Xi.create,d),i.addTrace(ln.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),i.addTrace(ln.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(Mn.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(p){throw i.setError(Mn.subscribe_pairing_topic_failure),p}return i.addTrace(ln.subscribe_pairing_topic_success),d}),xe(this,"activate",async({topic:n})=>{this.isInitialized();const i=pt(K.FIVE_MINUTES);this.core.expirer.set(n,i),await this.pairings.update(n,{active:!0,expiry:i})}),xe(this,"ping",async n=>{this.isInitialized(),await this.isValidPing(n),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Ki();this.events.once(Re("pairing_ping",s),({error:l})=>{l?c(l):a()}),await o()}}),xe(this,"updateExpiry",async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})}),xe(this,"updateMetadata",async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})}),xe(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),xe(this,"disconnect",async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Ue("USER_DISCONNECTED")),await this.deletePairing(i))}),xe(this,"formatUriFromPairing",n=>{this.isInitialized();const{topic:i,relay:s,expiry:o,methods:a}=n,c=this.core.crypto.keychain.get(i);return bw({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),xe(this,"sendRequest",async(n,i,s)=>{const o=fi(i,s),a=await this.core.crypto.encode(n,o),c=fa[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,c),o.id}),xe(this,"sendResult",async(n,i,s)=>{const o=Zh(n,s),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,n)).request.method,l=fa[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),xe(this,"sendError",async(n,i,s)=>{const o=Yh(n,s),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,n)).request.method,l=fa[c]?fa[c].res:fa.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)}),xe(this,"deletePairing",async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Ue("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])}),xe(this,"cleanup",async()=>{const n=this.pairings.getAll().filter(i=>ci(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))}),xe(this,"onRelayEventRequest",async n=>{const{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,s);default:return await this.onUnknownRpcMethodRequest(i,s)}}),xe(this,"onRelayEventResponse",async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}}),xe(this,"onPairingPingRequest",async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit(Xi.ping,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}}),xe(this,"onPairingPingResponse",(n,i)=>{const{id:s}=i;setTimeout(()=>{dn(i)?this.events.emit(Re("pairing_ping",s),{}):Rr(i)&&this.events.emit(Re("pairing_ping",s),{error:i.error})},500)}),xe(this,"onPairingDeleteRequest",async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(Xi.delete,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}}),xe(this,"onUnknownRpcMethodRequest",async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Ue("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,a),this.logger.error(a)}catch(a){await this.sendError(s,n,a),this.logger.error(a)}}),xe(this,"onUnknownRpcMethodResponse",n=>{this.registeredMethods.includes(n)||this.logger.error(Ue("WC_METHOD_UNSUPPORTED",n))}),xe(this,"isValidPair",(n,i)=>{var s;if(!rr(n)){const{message:a}=G("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(Mn.malformed_pairing_uri),new Error(a)}if(!pA(n.uri)){const{message:a}=G("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(Mn.malformed_pairing_uri),new Error(a)}const o=yw(n==null?void 0:n.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){const{message:a}=G("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(Mn.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=G("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(Mn.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&K.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(Mn.pairing_expired);const{message:a}=G("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),xe(this,"isValidPing",async n=>{if(!rr(n)){const{message:s}=G("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)}),xe(this,"isValidDisconnect",async n=>{if(!rr(n)){const{message:s}=G("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)}),xe(this,"isValidPairingTopic",async n=>{if(!ht(n,!1)){const{message:i}=G("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=G("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(ci(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=G("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}}),this.core=e,this.logger=Kt(r,this.name),this.pairings=new $s(this.core,this.logger,this.name,this.storagePrefix)}get context(){return ar(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(At.message,async e=>{const{topic:r,message:n,transportType:i}=e;if(this.pairings.keys.includes(r)&&i!==it.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))try{const s=await this.core.crypto.decode(r,n);u1(s)?(this.core.history.set(r,s),await this.onRelayEventRequest({topic:r,payload:s})):Jh(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id)),await this.core.relayer.messages.ack(r,n)}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(Tr.expired,async e=>{const{topic:r}=Vb(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Xi.expire,{topic:r}))})}};var tT=Object.defineProperty,rT=(t,e,r)=>e in t?tT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r)=>rT(t,typeof e!="symbol"?e+"":e,r);let nT=class extends ES{constructor(e,r){super(e,r),this.core=e,this.logger=r,kt(this,"records",new Map),kt(this,"events",new _s.EventEmitter),kt(this,"name",iO),kt(this,"version",sO),kt(this,"cached",[]),kt(this,"initialized",!1),kt(this,"storagePrefix",yn),kt(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)}),kt(this,"set",(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:pt(K.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Ur.created,o)}),kt(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 i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=Rr(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(Ur.updated,i))}),kt(this,"get",async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i))),kt(this,"delete",(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Ur.deleted,s)}}),this.persist()}),kt(this,"exists",async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1)),kt(this,"on",(n,i)=>{this.events.on(n,i)}),kt(this,"once",(n,i)=>{this.events.once(n,i)}),kt(this,"off",(n,i)=>{this.events.off(n,i)}),kt(this,"removeListener",(n,i)=>{this.events.removeListener(n,i)}),this.logger=Kt(r,this.name)}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:fi(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ur.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Ur.created,e=>{const r=Ur.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.updated,e=>{const r=Ur.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.deleted,e=>{const r=Ur.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(ra.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{K.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Ur.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var iT=Object.defineProperty,sT=(t,e,r)=>e in t?iT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mt=(t,e,r)=>sT(t,typeof e!="symbol"?e+"":e,r);let oT=class extends SS{constructor(e,r){super(e,r),this.core=e,this.logger=r,Mt(this,"expirations",new Map),Mt(this,"events",new _s.EventEmitter),Mt(this,"name",oO),Mt(this,"version",aO),Mt(this,"cached",[]),Mt(this,"initialized",!1),Mt(this,"storagePrefix",yn),Mt(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)}),Mt(this,"has",n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}}),Mt(this,"set",(n,i)=>{this.isInitialized();const s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Tr.created,{target:s,expiration:o})}),Mt(this,"get",n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)}),Mt(this,"del",n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Tr.deleted,{target:i,expiration:s})}}),Mt(this,"on",(n,i)=>{this.events.on(n,i)}),Mt(this,"once",(n,i)=>{this.events.once(n,i)}),Mt(this,"off",(n,i)=>{this.events.off(n,i)}),Mt(this,"removeListener",(n,i)=>{this.events.removeListener(n,i)}),this.logger=Kt(r,this.name)}get context(){return ar(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return _x(e);if(typeof e=="number")return Ix(e);const{message:r}=G("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Tr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;K.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Tr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(ra.pulse,()=>this.checkExpirations()),this.events.on(Tr.created,e=>{const r=Tr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Tr.expired,e=>{const r=Tr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Tr.deleted,e=>{const r=Tr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}};var aT=Object.defineProperty,cT=(t,e,r)=>e in t?aT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e,r)=>cT(t,typeof e!="symbol"?e+"":e,r);let lT=class extends NS{constructor(e,r,n){super(e,r,n),this.core=e,this.logger=r,this.store=n,ut(this,"name",cO),ut(this,"abortController"),ut(this,"isDevEnv"),ut(this,"verifyUrlV3",uO),ut(this,"storagePrefix",yn),ut(this,"version",S3),ut(this,"publicKey"),ut(this,"fetchPromise"),ut(this,"init",async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&K.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ut(this,"register",async i=>{if(!tl()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const l=Xc(),u=this.startAbortTimer(K.ONE_SECOND*5),h=await new Promise((d,p)=>{const f=()=>{window.removeEventListener("message",w),l.body.removeChild(g),p("attestation aborted")};this.abortController.signal.addEventListener("abort",f);const g=l.createElement("iframe");g.src=c,g.style.display="none",g.addEventListener("error",f,{signal:this.abortController.signal});const w=v=>{if(v.data&&typeof v.data=="string")try{const b=JSON.parse(v.data);if(b.type==="verify_attestation"){if(Mf(b.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(g),this.abortController.signal.removeEventListener("abort",f),window.removeEventListener("message",w),d(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};l.body.appendChild(g),window.addEventListener("message",w,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(l){this.logger.warn(l)}return""}),ut(this,"resolve",async i=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=i;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Mf(s).payload.id!==a)return;const l=await this.isValidJwtAttestation(s);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),ut(this,"fetchAttestation",async(i,s)=>{this.logger.debug(`resolving attestation: ${i} from url: ${s}`);const o=this.startAbortTimer(K.ONE_SECOND*5),a=await fetch(`${s}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),ut(this,"getVerifyUrl",i=>{let s=i||ic;return hO.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${ic}`),s=ic),s}),ut(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(K.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await s.json()}catch(i){this.logger.warn(i)}}),ut(this,"persistPublicKey",async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i}),ut(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ut(this,"isValidJwtAttestation",async i=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(i,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),ut(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ut(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i}),ut(this,"validateAttestation",(i,s)=>{const o=eA(i,s.publicKey),a={hasExpired:K.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Kt(r,this.name),this.abortController=new AbortController,this.isDevEnv=Y0(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return ar(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),K.toMiliseconds(e))}};var uT=Object.defineProperty,hT=(t,e,r)=>e in t?uT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Cm=(t,e,r)=>hT(t,typeof e!="symbol"?e+"":e,r);let dT=class extends OS{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,Cm(this,"context",dO),Cm(this,"registerDeviceToken",async n=>{const{clientId:i,token:s,notificationType:o,enableEncrypted:a=!1}=n,c=`${pO}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:s,always_raw:a})})}),this.logger=Kt(r,this.context)}};var pT=Object.defineProperty,Em=Object.getOwnPropertySymbols,fT=Object.prototype.hasOwnProperty,gT=Object.prototype.propertyIsEnumerable,u0=(t,e,r)=>e in t?pT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ma=(t,e)=>{for(var r in e||(e={}))fT.call(e,r)&&u0(t,r,e[r]);if(Em)for(var r of Em(e))gT.call(e,r)&&u0(t,r,e[r]);return t},bt=(t,e,r)=>u0(t,typeof e!="symbol"?e+"":e,r);let wT=class extends PS{constructor(e,r,n=!0){super(e,r,n),this.core=e,this.logger=r,bt(this,"context",gO),bt(this,"storagePrefix",yn),bt(this,"storageVersion",fO),bt(this,"events",new Map),bt(this,"shouldPersist",!1),bt(this,"init",async()=>{if(!Y0())try{const i={eventId:Hg(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:qb(this.core.relayer.protocol,this.core.relayer.version,r0)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}}),bt(this,"createEvent",i=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=Hg(),u=this.core.projectId||"",h=Date.now(),d=ma({eventId:l,timestamp:h,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d}),bt(this,"getEvent",i=>{const{eventId:s,topic:o}=i;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return ma(ma({},a),this.setMethods(a.eventId))}),bt(this,"deleteEvent",i=>{const{eventId:s}=i;this.events.delete(s),this.shouldPersist=!0}),bt(this,"setEventListeners",()=>{this.core.heartbeat.on(ra.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{K.fromMiliseconds(Date.now())-K.fromMiliseconds(i.timestamp)>wO&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})}),bt(this,"setMethods",i=>({addTrace:s=>this.addTrace(i,s),setError:s=>this.setError(i,s)})),bt(this,"addTrace",(i,s)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(s),this.events.set(i,o),this.shouldPersist=!0)}),bt(this,"setError",(i,s)=>{const o=this.events.get(i);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)}),bt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),bt(this,"restore",async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(s=>{this.events.set(s.eventId,ma(ma({},s),this.setMethods(s.eventId)))})}catch(i){this.logger.warn(i)}}),bt(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[s,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const s of i)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),bt(this,"sendEvent",async i=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${mO}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${r0}${s}`,{method:"POST",body:JSON.stringify(i)})}),bt(this,"getAppDomain",()=>Hb().url),this.logger=Kt(r,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}};var mT=Object.defineProperty,xm=Object.getOwnPropertySymbols,vT=Object.prototype.hasOwnProperty,yT=Object.prototype.propertyIsEnumerable,h0=(t,e,r)=>e in t?mT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_m=(t,e)=>{for(var r in e||(e={}))vT.call(e,r)&&h0(t,r,e[r]);if(xm)for(var r of xm(e))yT.call(e,r)&&h0(t,r,e[r]);return t},Qe=(t,e,r)=>h0(t,typeof e!="symbol"?e+"":e,r);let bT=class F3 extends vS{constructor(e){var r;super(e),Qe(this,"protocol",$3),Qe(this,"version",S3),Qe(this,"name",ph),Qe(this,"relayUrl"),Qe(this,"projectId"),Qe(this,"customStoragePrefix"),Qe(this,"events",new _s.EventEmitter),Qe(this,"logger"),Qe(this,"heartbeat"),Qe(this,"relayer"),Qe(this,"crypto"),Qe(this,"storage"),Qe(this,"history"),Qe(this,"expirer"),Qe(this,"pairing"),Qe(this,"verify"),Qe(this,"echoClient"),Qe(this,"linkModeSupportedApps"),Qe(this,"eventClient"),Qe(this,"initialized",!1),Qe(this,"logChunkController"),Qe(this,"on",(a,c)=>this.events.on(a,c)),Qe(this,"once",(a,c)=>this.events.once(a,c)),Qe(this,"off",(a,c)=>this.events.off(a,c)),Qe(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Qe(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:it.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const n=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(n)try{return this.customStoragePrefix=n.customStoragePrefix,this.logger=n.logger,this.heartbeat=n.heartbeat,this.crypto=n.crypto,this.history=n.history,this.expirer=n.expirer,this.storage=n.storage,this.relayer=n.relayer,this.pairing=n.pairing,this.verify=n.verify,this.echoClient=n.echoClient,this.linkModeSupportedApps=n.linkModeSupportedApps,this.eventClient=n.eventClient,this.initialized=n.initialized,this.logChunkController=n.logChunkController,n}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||O3,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Vh({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:UN.logger,name:ph}),{logger:s,chunkLoggerController:o}=lS({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Kt(s,this.name),this.heartbeat=new t$,this.crypto=new KP(this,this.logger,e==null?void 0:e.keychain),this.history=new nT(this,this.logger),this.expirer=new oT(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new L$(_m(_m({},jN),e==null?void 0:e.storageOptions)),this.relayer=new bk({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new eT(this,this.logger),this.verify=new lT(this,this.logger,this.storage),this.echoClient=new dT(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new wT(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const r=new F3(e);await r.initialize();const n=await r.crypto.getClientId();return await r.storage.setItem(QN,n),r}get context(){return ar(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(nm,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(nm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${e}`,n=`${r}_count`;return globalThis[n]=(globalThis[n]||0)+1,globalThis[n]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[n]} times.`),globalThis[r]}catch(r){console.warn("Failed to get global WalletConnect core",r);return}}setGlobalCore(e){var r;try{if(this.isGlobalCoreDisabled())return;const n=`_walletConnectCore_${((r=e.opts)==null?void 0:r.customStoragePrefix)||""}`;globalThis[n]=e}catch(n){console.warn("Failed to set global WalletConnect core",n)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&MN.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const CT=bT;var d1={exports:{}},Ao=typeof Reflect=="object"?Reflect:null,Im=Ao&&typeof Ao.apply=="function"?Ao.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Xu;Ao&&typeof Ao.ownKeys=="function"?Xu=Ao.ownKeys:Object.getOwnPropertySymbols?Xu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Xu=function(e){return Object.getOwnPropertyNames(e)};function ET(t){console&&console.warn&&console.warn(t)}var H3=Number.isNaN||function(e){return e!==e};function Ve(){Ve.init.call(this)}d1.exports=Ve;d1.exports.once=AT;Ve.EventEmitter=Ve;Ve.prototype._events=void 0;Ve.prototype._eventsCount=0;Ve.prototype._maxListeners=void 0;var Am=10;function ed(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ve,"defaultMaxListeners",{enumerable:!0,get:function(){return Am},set:function(t){if(typeof t!="number"||t<0||H3(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Am=t}});Ve.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ve.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||H3(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function q3(t){return t._maxListeners===void 0?Ve.defaultMaxListeners:t._maxListeners}Ve.prototype.getMaxListeners=function(){return q3(this)};Ve.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")Im(c,this,r);else for(var l=c.length,u=Z3(c,l),n=0;n<l;++n)Im(u[n],this,r);return!0};function W3(t,e,r,n){var i,s,o;if(ed(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=q3(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,ET(a)}return t}Ve.prototype.addListener=function(e,r){return W3(this,e,r,!1)};Ve.prototype.on=Ve.prototype.addListener;Ve.prototype.prependListener=function(e,r){return W3(this,e,r,!0)};function xT(){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 V3(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=xT.bind(n);return i.listener=r,n.wrapFn=i,i}Ve.prototype.once=function(e,r){return ed(r),this.on(e,V3(this,e,r)),this};Ve.prototype.prependOnceListener=function(e,r){return ed(r),this.prependListener(e,V3(this,e,r)),this};Ve.prototype.removeListener=function(e,r){var n,i,s,o,a;if(ed(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():_T(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function K3(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?IT(i):Z3(i,i.length)}Ve.prototype.listeners=function(e){return K3(this,e,!0)};Ve.prototype.rawListeners=function(e){return K3(this,e,!1)};Ve.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):G3.call(t,e)};Ve.prototype.listenerCount=G3;function G3(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ve.prototype.eventNames=function(){return this._eventsCount>0?Xu(this._events):[]};function Z3(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function _T(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function IT(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function AT(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Y3(t,e,s,{once:!0}),e!=="error"&&$T(t,i,{once:!0})})}function $T(t,e,r){typeof t.on=="function"&&Y3(t,"error",e,r)}function Y3(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var J3=d1.exports;const ST=Jc(J3),X3="wc",Q3=2,e5="client",p1=`${X3}@${Q3}:${e5}:`,ep={name:e5,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},$m="WALLETCONNECT_DEEPLINK_CHOICE",NT="proposal",Sm="Proposal expired",OT="session",Ms=K.SEVEN_DAYS,PT="engine",Ct={wc_sessionPropose:{req:{ttl:K.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:K.ONE_DAY,prompt:!1,tag:1104},res:{ttl:K.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:K.ONE_DAY,prompt:!1,tag:1106},res:{ttl:K.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:K.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:K.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:K.ONE_DAY,prompt:!1,tag:1112},res:{ttl:K.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:K.ONE_DAY,prompt:!1,tag:1114},res:{ttl:K.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:K.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:K.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:K.FIVE_MINUTES,prompt:!1,tag:1119}}},tp={min:K.FIVE_MINUTES,max:K.SEVEN_DAYS},rn={idle:"IDLE",active:"ACTIVE"},Nm={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},kT="request",TT=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],RT="wc",LT="auth",DT="authKeys",BT="pairingTopics",MT="requests",td=`${RT}@${1.5}:${LT}:`,Qu=`${td}:PUB_KEY`;var UT=Object.defineProperty,jT=Object.defineProperties,zT=Object.getOwnPropertyDescriptors,Om=Object.getOwnPropertySymbols,FT=Object.prototype.hasOwnProperty,HT=Object.prototype.propertyIsEnumerable,d0=(t,e,r)=>e in t?UT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ye=(t,e)=>{for(var r in e||(e={}))FT.call(e,r)&&d0(t,r,e[r]);if(Om)for(var r of Om(e))HT.call(e,r)&&d0(t,r,e[r]);return t},Ft=(t,e)=>jT(t,zT(e)),F=(t,e,r)=>d0(t,typeof e!="symbol"?e+"":e,r);let qT=class extends LS{constructor(e){super(e),F(this,"name",PT),F(this,"events",new ST),F(this,"initialized",!1),F(this,"requestQueue",{state:rn.idle,queue:[]}),F(this,"sessionRequestQueue",{state:rn.idle,queue:[]}),F(this,"requestQueueDelay",K.ONE_SECOND),F(this,"expectedPairingMethodMap",new Map),F(this,"recentlyDeletedMap",new Map),F(this,"recentlyDeletedLimit",200),F(this,"relayMessageCache",[]),F(this,"pendingSessions",new Map),F(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Ct)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},K.toMiliseconds(this.requestQueueDelay)))}),F(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const n=Ft(Ye({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l}=n;let u=i,h,d=!1;try{if(u){const S=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=S.active}}catch(S){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),S}if(!u||!d){const{topic:S,uri:T}=await this.client.core.pairing.create();u=S,h=T}if(!u){const{message:S}=G("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(S)}const p=await this.client.core.crypto.generateKeyPair(),f=Ct.wc_sessionPropose.req.ttl||K.FIVE_MINUTES,g=pt(f),w=Ft(Ye(Ye({requiredNamespaces:s,optionalNamespaces:o,relays:l??[{protocol:N3}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:hn()}),v=Re("session_connect",w.id),{reject:b,resolve:C,done:E}=Ki(f,Sm),A=({id:S})=>{S===w.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(w.id),this.events.emit(v,{error:{message:Sm,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(v,({error:S,session:T})=>{this.client.events.off("proposal_expire",A),S?b(S):T&&C(T)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:h,approval:E}}),F(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(n){throw this.client.logger.error("pair() failed"),n}}),F(this,"approve",async r=>{var n,i,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(n=r==null?void 0:r.id)==null?void 0:n.toString(),trace:[jr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(I){throw o.setError(Si.no_internet_connection),I}try{await this.isValidProposalId(r==null?void 0:r.id)}catch(I){throw this.client.logger.error(`approve() -> proposal.get(${r==null?void 0:r.id}) failed`),o.setError(Si.proposal_not_found),I}try{await this.isValidApprove(r)}catch(I){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Si.session_approve_namespace_validation_failure),I}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,scopedProperties:h,sessionConfig:d}=r,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:f,proposer:g,requiredNamespaces:w,optionalNamespaces:v}=p;let b=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:f});b||(b=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:jr.session_approve_started,properties:{topic:f,trace:[jr.session_approve_started,jr.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),E=g.publicKey,A=await this.client.core.crypto.generateSharedKey(C,E),S=Ye(Ye(Ye({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:C,metadata:this.client.metadata},expiry:pt(Ms)},u&&{sessionProperties:u}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),T=it.relay;b.addTrace(jr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:T})}catch(I){throw b.setError(Si.subscribe_session_topic_failure),I}b.addTrace(jr.subscribe_session_topic_success);const k=Ft(Ye({},S),{topic:A,requiredNamespaces:w,optionalNamespaces:v,pairingTopic:f,acknowledged:!1,self:S.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:C,transportType:it.relay});await this.client.session.set(A,k),b.addTrace(jr.store_session);try{b.addTrace(jr.publishing_session_settle),await this.sendRequest({topic:A,method:"wc_sessionSettle",params:S,throwOnFailedPublish:!0}).catch(I=>{throw b==null||b.setError(Si.session_settle_publish_failure),I}),b.addTrace(jr.session_settle_publish_success),b.addTrace(jr.publishing_session_approve),await this.sendResult({id:a,topic:f,result:{relay:{protocol:c??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(I=>{throw b==null||b.setError(Si.session_approve_publish_failure),I}),b.addTrace(jr.session_approve_publish_success)}catch(I){throw this.client.logger.error(I),this.client.session.delete(A,Ue("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(A),I}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:g.metadata}),await this.client.proposal.delete(a,Ue("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(A,pt(Ms)),{topic:A,acknowledged:()=>Promise.resolve(this.client.session.get(A))}}),F(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:n,reason:i}=r;let s;try{s=this.client.proposal.get(n).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),o}s&&(await this.sendError({id:n,topic:s,error:i,rpcOpts:Ct.wc_sessionPropose.reject}),await this.client.proposal.delete(n,Ue("USER_DISCONNECTED")))}),F(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:n,namespaces:i}=r,{done:s,resolve:o,reject:a}=Ki(),c=hn(),l=ns().toString(),u=this.client.session.get(n).namespaces;return this.events.once(Re("session_update",c),({error:h})=>{h?a(h):o()}),await this.client.session.update(n,{namespaces:i}),await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(h=>{this.client.logger.error(h),this.client.session.update(n,{namespaces:u}),a(h)}),{acknowledged:s}}),F(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:n}=r,i=hn(),{done:s,resolve:o,reject:a}=Ki();return this.events.once(Re("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(n,pt(Ms)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),F(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(v){throw this.client.logger.error("request() -> isValidRequest() failed"),v}const{chainId:n,request:i,topic:s,expiry:o=Ct.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);(a==null?void 0:a.transportType)===it.relay&&await this.confirmOnlineStateOrThrow();const c=hn(),l=ns().toString(),{done:u,resolve:h,reject:d}=Ki(o,"Request expired. Please try again.");this.events.once(Re("session_request",c),({error:v,result:b})=>{v?d(v):h(b)});const p="wc_sessionRequest",f=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(f)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:s,method:p,params:{request:Ft(Ye({},i),{expiryTimestamp:pt(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0,appLink:f}).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:c}),await u();const g={request:Ft(Ye({},i),{expiryTimestamp:pt(o)}),chainId:n},w=this.shouldSetTVF(p,g);return await Promise.all([new Promise(async v=>{await this.sendRequest(Ye({clientRpcId:c,relayRpcId:l,topic:s,method:p,params:g,expiry:o,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,g)})).catch(b=>d(b)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:c}),v()}),new Promise(async v=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const C=await Nx(this.client.core.storage,$m);await Ax({id:c,topic:s,wcDeepLink:C})}v()}),u()]).then(v=>v[2])}),F(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i,o=this.client.session.get(n);o.transportType===it.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);dn(i)?await this.sendResult({id:s,topic:n,result:i.result,throwOnFailedPublish:!0,appLink:a}):Rr(i)&&await this.sendError({id:s,topic:n,error:i.error,appLink:a}),this.cleanupAfterResponse(r)}),F(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=hn(),s=ns().toString(),{done:o,resolve:a,reject:c}=Ki();this.events.once(Re("session_ping",i),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(n)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:n}))}),F(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r,o=ns().toString(),a=hn();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:i,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),F(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:n}=r;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Ue("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:i}=G("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(i)}}),F(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(n=>hA(n,r)))),F(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),F(this,"authenticate",async(r,n)=>{var i;this.isInitialized(),this.isValidAuthenticate(r);const s=n&&this.client.core.linkModeSupportedApps.includes(n)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=s?it.link_mode:it.relay;o===it.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:h,type:d,exp:p,nbf:f,methods:g=[],expiry:w}=r,v=[...r.resources||[]],{topic:b,uri:C}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:C}});const E=await this.client.core.crypto.generateKeyPair(),A=Hu(E);if(await Promise.all([this.client.auth.authKeys.set(Qu,{responseTopic:A,publicKey:E}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:b})]),await this.client.core.relayer.subscribe(A,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),g.length>0){const{namespace:O}=bo(a[0]);let R=C_(O,"request",g);Fu(v)&&(R=x_(R,v.pop())),v.push(R)}const S=w&&w>Ct.wc_sessionAuthenticate.req.ttl?w:Ct.wc_sessionAuthenticate.req.ttl,T={authPayload:{type:d??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:h,iat:new Date().toISOString(),exp:p,nbf:f,resources:v},requester:{publicKey:E,metadata:this.client.metadata},expiryTimestamp:pt(S)},k={eip155:{chains:a,methods:[...new Set(["personal_sign",...g])],events:["chainChanged","accountsChanged"]}},I={requiredNamespaces:{},optionalNamespaces:k,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:E,metadata:this.client.metadata},expiryTimestamp:pt(Ct.wc_sessionPropose.req.ttl),id:hn()},{done:B,resolve:D,reject:M}=Ki(S,"Request expired"),W=hn(),$=Re("session_connect",I.id),m=Re("session_request",W),y=async({error:O,session:R})=>{this.events.off(m,x),O?M(O):R&&D({session:R})},x=async O=>{var R,U,j;if(await this.deletePendingAuthRequest(W,{message:"fulfilled",code:0}),O.error){const ge=Ue("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return O.error.code===ge.code?void 0:(this.events.off($,y),M(O.error.message))}await this.deleteProposal(I.id),this.events.off($,y);const{cacaos:V,responder:z}=O.result,te=[],he=[];for(const ge of V){await Jg({cacao:ge,projectId:this.client.core.projectId})||(this.client.logger.error(ge,"Signature verification failed"),M(Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Ee}=ge,Se=Fu(Ee.resources),Le=[zf(Ee.iss)],nt=ch(Ee.iss);if(Se){const yt=Xg(Se),bn=Qg(Se);te.push(...yt),Le.push(...bn)}for(const yt of Le)he.push(`${yt}:${nt}`)}const Ce=await this.client.core.crypto.generateSharedKey(E,z.publicKey);let we;te.length>0&&(we={topic:Ce,acknowledged:!0,self:{publicKey:E,metadata:this.client.metadata},peer:z,controller:z.publicKey,expiry:pt(Ms),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:Cw([...new Set(te)],[...new Set(he)]),transportType:o},await this.client.core.relayer.subscribe(Ce,{transportType:o}),await this.client.session.set(Ce,we),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:z.metadata}),we=this.client.session.get(Ce)),(R=this.client.metadata.redirect)!=null&&R.linkMode&&(U=z.metadata.redirect)!=null&&U.linkMode&&(j=z.metadata.redirect)!=null&&j.universal&&n&&(this.client.core.addLinkModeSupportedApp(z.metadata.redirect.universal),this.client.session.update(Ce,{transportType:it.link_mode})),D({auths:V,session:we})};this.events.once($,y),this.events.once(m,x);let _;try{if(s){const O=fi("wc_sessionAuthenticate",T,W);this.client.core.history.set(b,O);const R=await this.client.core.crypto.encode("",O,{type:al,encoding:hi});_=Sl(n,b,R)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:T,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:W}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:I,expiry:Ct.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:I.id})])}catch(O){throw this.events.off($,y),this.events.off(m,x),O}return await this.setProposal(I.id,I),await this.setAuthRequest(W,{request:Ft(Ye({},T),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:_??C,response:B}}),F(this,"approveSessionAuthenticate",async r=>{const{id:n,auths:i}=r,s=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[Ni.authenticated_session_approve_started]}});try{this.isInitialized()}catch(w){throw s.setError(ga.no_internet_connection),w}const o=this.getPendingAuthRequest(n);if(!o)throw s.setError(ga.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${n}`);const a=o.transportType||it.relay;a===it.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=Hu(c),h={type:Wn,receiverPublicKey:c,senderPublicKey:l},d=[],p=[];for(const w of i){if(!await Jg({cacao:w,projectId:this.client.core.projectId})){s.setError(ga.invalid_cacao);const A=Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:u,error:A,encodeOpts:h}),new Error(A.message)}s.addTrace(Ni.cacaos_verified);const{p:v}=w,b=Fu(v.resources),C=[zf(v.iss)],E=ch(v.iss);if(b){const A=Xg(b),S=Qg(b);d.push(...A),C.push(...S)}for(const A of C)p.push(`${A}:${E}`)}const f=await this.client.core.crypto.generateSharedKey(l,c);s.addTrace(Ni.create_authenticated_session_topic);let g;if((d==null?void 0:d.length)>0){g={topic:f,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:pt(Ms),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Cw([...new Set(d)],[...new Set(p)]),transportType:a},s.addTrace(Ni.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:a})}catch(w){throw s.setError(ga.subscribe_authenticated_session_topic_failure),w}s.addTrace(Ni.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),s.addTrace(Ni.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Ni.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:n,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(w){throw s.setError(ga.authenticated_session_approve_publish_failure),w}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:g}}),F(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:n,reason:i}=r,s=this.getPendingAuthRequest(n);if(!s)throw new Error(`Could not find pending auth request with id ${n}`);s.transportType===it.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Hu(o),l={type:Wn,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:n,topic:c,error:i,encodeOpts:l,rpcOpts:Ct.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.client.proposal.delete(n,Ue("USER_DISCONNECTED"))}),F(this,"formatAuthMessage",r=>{this.isInitialized();const{request:n,iss:i}=r;return t2(n,i)}),F(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),F(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const n=this.client.core.pairing.pairings.get(r.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==n.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}}),F(this,"deleteSession",async r=>{var n;const{topic:i,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,Ue("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem($m).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,Ue("USER_DISCONNECTED"))}),i===((n=this.sessionRequestQueue.queue[0])==null?void 0:n.topic)&&(this.sessionRequestQueue.state=rn.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})}),F(this,"deleteProposal",async(r,n)=>{if(n)try{const i=this.client.proposal.get(r),s=this.client.core.eventClient.getEvent({topic:i.pairingTopic});s==null||s.setError(Si.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,Ue("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),F(this,"deletePendingSessionRequest",async(r,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),i&&(this.sessionRequestQueue.state=rn.idle,this.client.events.emit("session_request_expire",{id:r}))}),F(this,"deletePendingAuthRequest",async(r,n,i=!1)=>{await Promise.all([this.client.auth.requests.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)])}),F(this,"setExpiry",async(r,n)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,n),await this.client.session.update(r,{expiry:n}))}),F(this,"setProposal",async(r,n)=>{this.client.core.expirer.set(r,pt(Ct.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,n)}),F(this,"setAuthRequest",async(r,n)=>{const{request:i,pairingTopic:s,transportType:o=it.relay}=n;this.client.core.expirer.set(r,i.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:r,pairingTopic:s,verifyContext:i.verifyContext,transportType:o})}),F(this,"setPendingSessionRequest",async r=>{const{id:n,topic:i,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||pt(Ct.wc_sessionRequest.req.ttl);this.client.core.expirer.set(n,a),await this.client.pendingRequest.set(n,{id:n,topic:i,params:s,verifyContext:o})}),F(this,"sendRequest",async r=>{const{topic:n,method:i,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:h}=r,d=fi(i,s,c);let p;const f=!!u;try{const v=f?hi:Zr;p=await this.client.core.crypto.encode(n,d,{encoding:v})}catch(v){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),v}let g;if(TT.includes(i)){const v=fn(JSON.stringify(d)),b=fn(p);g=await this.client.core.verify.register({id:b,decryptedId:v})}const w=Ct[i].req;if(w.attestation=g,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(n,d),f){const v=Sl(u,n,p);await global.Linking.openURL(v,this.client.name)}else{const v=Ct[i].req;o&&(v.ttl=o),a&&(v.id=a),v.tvf=Ft(Ye({},h),{correlationId:d.id}),l?(v.internal=Ft(Ye({},v.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,p,v)):this.client.core.relayer.publish(n,p,v).catch(b=>this.client.logger.error(b))}return d.id}),F(this,"sendResult",async r=>{const{id:n,topic:i,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,l=Zh(n,s);let u;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=h?hi:Zr;u=await this.client.core.crypto.encode(i,l,Ft(Ye({},a||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),f}let d,p;try{d=await this.client.core.history.get(i,n);const f=d.request;try{this.shouldSetTVF(f.method,f.params)&&(p=this.getTVFParams(n,f.params,s))}catch(g){this.client.logger.warn("sendResult() -> getTVFParams() failed",g)}}catch(f){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`),f}if(h){const f=Sl(c,i,u);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,g=Ct[f].res;g.tvf=Ft(Ye({},p),{correlationId:n}),o?(g.internal=Ft(Ye({},g.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,g)):this.client.core.relayer.publish(i,u,g).catch(w=>this.client.logger.error(w))}await this.client.core.history.resolve(l)}),F(this,"sendError",async r=>{const{id:n,topic:i,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,l=Yh(n,s);let u;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=h?hi:Zr;u=await this.client.core.crypto.encode(i,l,Ft(Ye({},o||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),p}let d;try{d=await this.client.core.history.get(i,n)}catch(p){throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`),p}if(h){const p=Sl(c,i,u);await global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,f=a||Ct[p].res;this.client.core.relayer.publish(i,u,f)}await this.client.core.history.resolve(l)}),F(this,"cleanup",async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{let s=!1;ci(i.expiry)&&(s=!0),this.client.core.crypto.keychain.has(i.topic)||(s=!0),s&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{ci(i.expiryTimestamp)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession({topic:i})),...n.map(i=>this.deleteProposal(i))])}),F(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),F(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),F(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===rn.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=rn.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=rn.idle}),F(this,"processRequest",async r=>{const{topic:n,payload:i,attestation:s,transportType:o,encryptedId:a}=r,c=i.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:n,payload:i,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(n,i);case"wc_sessionPing":return await this.onSessionPingRequest(n,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(n,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),F(this,"onRelayEventResponse",async r=>{const{topic:n,payload:i,transportType:s}=r,o=(await this.client.core.history.get(n,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),F(this,"onRelayEventUnknownPayload",r=>{const{topic:n}=r,{message:i}=G("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),F(this,"shouldIgnorePairingRequest",r=>{const{topic:n,requestMethod:i}=r,s=this.expectedPairingMethodMap.get(n);return!s||s.includes(i)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),F(this,"onSessionProposeRequest",async r=>{const{topic:n,payload:i,attestation:s,encryptedId:o}=r,{params:a,id:c}=i;try{const l=this.client.core.eventClient.getEvent({topic:n});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(Mn.proposal_listener_not_found)),this.isValidConnect(Ye({},i.params));const u=a.expiryTimestamp||pt(Ct.wc_sessionPropose.req.ttl),h=Ye({id:c,pairingTopic:n,expiryTimestamp:u},a);await this.setProposal(c,h);const d=await this.getVerifyContext({attestationId:s,hash:fn(JSON.stringify(i)),encryptedId:o,metadata:h.proposer.metadata});l==null||l.addTrace(ln.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:d})}catch(l){await this.sendError({id:c,topic:n,error:l,rpcOpts:Ct.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),F(this,"onSessionProposeResponse",async(r,n,i)=>{const{id:s}=n;if(dn(n)){const{result:o}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(s,{sessionTopic:u,pairingTopic:r,proposalId:s,publicKey:c});const h=await this.client.core.relayer.subscribe(u,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:r})}else if(Rr(n)){await this.client.proposal.delete(s,Ue("USER_DISCONNECTED"));const o=Re("session_connect",s);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:n.error})}}),F(this,"onSessionSettleRequest",async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,scopedProperties:h,sessionConfig:d}=n.params,p=[...this.pendingSessions.values()].find(w=>w.sessionTopic===r);if(!p)return this.client.logger.error(`Pending session not found for topic ${r}`);const f=this.client.proposal.get(p.proposalId),g=Ft(Ye(Ye(Ye({topic:r,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces,controller:a.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),h&&{scopedProperties:h}),d&&{sessionConfig:d}),{transportType:it.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit(Re("session_connect",p.proposalId),{session:g}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:n.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}}),F(this,"onSessionSettleResponse",async(r,n)=>{const{id:i}=n;dn(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Re("session_approve",i),{})):Rr(n)&&(await this.client.session.delete(r,Ue("USER_DISCONNECTED")),this.events.emit(Re("session_approve",i),{error:n.error}))}),F(this,"onSessionUpdateRequest",async(r,n)=>{const{params:i,id:s}=n;try{const o=`${r}_session_update`,a=pa.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:Ue("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ye({topic:r},i));try{pa.set(o,s),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw pa.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),F(this,"isRequestOutOfSync",(r,n)=>n.toString().slice(0,-3)<r.toString().slice(0,-3)),F(this,"onSessionUpdateResponse",(r,n)=>{const{id:i}=n,s=Re("session_update",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);dn(n)?this.events.emit(Re("session_update",i),{}):Rr(n)&&this.events.emit(Re("session_update",i),{error:n.error})}),F(this,"onSessionExtendRequest",async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,pt(Ms)),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}}),F(this,"onSessionExtendResponse",(r,n)=>{const{id:i}=n,s=Re("session_extend",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);dn(n)?this.events.emit(Re("session_extend",i),{}):Rr(n)&&this.events.emit(Re("session_extend",i),{error:n.error})}),F(this,"onSessionPingRequest",async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}}),F(this,"onSessionPingResponse",(r,n)=>{const{id:i}=n,s=Re("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners 2176`);dn(n)?this.events.emit(Re("session_ping",i),{}):Rr(n)&&this.events.emit(Re("session_ping",i),{error:n.error})},500)}),F(this,"onSessionDeleteRequest",async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(At.publish,async()=>{s(await this.deleteSession({topic:r,id:i}))})}),this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Ue("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),F(this,"onSessionRequest",async r=>{var n,i,s;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=r,{id:h,params:d}=a;try{await this.isValidRequest(Ye({topic:o},d));const p=this.client.session.get(o),f=await this.getVerifyContext({attestationId:c,hash:fn(JSON.stringify(fi("wc_sessionRequest",d,h))),encryptedId:l,metadata:p.peer.metadata,transportType:u}),g={id:h,topic:o,params:d,verifyContext:f};await this.setPendingSessionRequest(g),u===it.link_mode&&(n=p.peer.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp((i=p.peer.metadata.redirect)==null?void 0:i.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(p){await this.sendError({id:h,topic:o,error:p}),this.client.logger.error(p)}}),F(this,"onSessionRequestResponse",(r,n)=>{const{id:i}=n,s=Re("session_request",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);dn(n)?this.events.emit(Re("session_request",i),{result:n.result}):Rr(n)&&this.events.emit(Re("session_request",i),{error:n.error})}),F(this,"onSessionEventRequest",async(r,n)=>{const{id:i,params:s}=n;try{const o=`${r}_session_event_${s.event.name}`,a=pa.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(Ye({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s}),pa.set(o,i)}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}}),F(this,"onSessionAuthenticateResponse",(r,n)=>{const{id:i}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:n}),dn(n)?this.events.emit(Re("session_request",i),{result:n.result}):Rr(n)&&this.events.emit(Re("session_request",i),{error:n.error})}),F(this,"onSessionAuthenticateRequest",async r=>{var n;const{topic:i,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:l,authPayload:u,expiryTimestamp:h}=s.params,d=await this.getVerifyContext({attestationId:o,hash:fn(JSON.stringify(s)),encryptedId:a,metadata:l.metadata,transportType:c}),p={requester:l,pairingTopic:i,id:s.id,authPayload:u,verifyContext:d,expiryTimestamp:h};await this.setAuthRequest(s.id,{request:p,pairingTopic:i,transportType:c}),c===it.link_mode&&(n=l.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:s.params,id:s.id,verifyContext:d})}catch(l){this.client.logger.error(l);const u=s.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(s.params.requester.metadata,c),p={type:Wn,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:s.id,topic:i,error:l,encodeOpts:p,rpcOpts:Ct.wc_sessionAuthenticate.autoReject,appLink:d})}}),F(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),F(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=rn.idle,this.processSessionRequestQueue()},K.toMiliseconds(this.requestQueueDelay))}),F(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:n})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=Re("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Re("session_request",s.request.id),{error:n})})}),F(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===rn.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=rn.active,this.emitSessionRequest(r)}catch(n){this.client.logger.error(n)}}),F(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),F(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const n=this.client.proposal.getAll().find(i=>i.pairingTopic===r.topic);n&&this.onSessionProposeRequest({topic:r.topic,payload:fi("wc_sessionPropose",Ft(Ye({},n),{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties,scopedProperties:n.scopedProperties}),n.id)})}),F(this,"isValidConnect",async r=>{if(!rr(r)){const{message:l}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(l)}const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:o,scopedProperties:a,relays:c}=r;if(jt(n)||await this.isValidPairingTopic(n),!xA(c)){const{message:l}=G("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!jt(i)&&yc(i)!==0&&this.validateNamespaces(i,"requiredNamespaces"),!jt(s)&&yc(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),jt(o)||this.validateSessionProps(o,"sessionProperties"),!jt(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(i||{}).concat(Object.keys(s||{}));if(!Object.keys(a).every(u=>l.includes(u)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),F(this,"validateNamespaces",(r,n)=>{const i=EA(r,"connect()",n);if(i)throw new Error(i.message)}),F(this,"isValidApprove",async r=>{if(!rr(r))throw new Error(G("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const c=this.client.proposal.get(n),l=Wd(i,"approve()");if(l)throw new Error(l.message);const u=_w(c.requiredNamespaces,i,"approve()");if(u)throw new Error(u.message);if(!ht(s,!0)){const{message:h}=G("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}if(jt(o)||this.validateSessionProps(o,"sessionProperties"),!jt(a)){this.validateSessionProps(a,"scopedProperties");const h=new Set(Object.keys(i));if(!Object.keys(a).every(d=>h.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),F(this,"isValidReject",async r=>{if(!rr(r)){const{message:s}=G("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!IA(i)){const{message:s}=G("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}}),F(this,"isValidSessionSettleRequest",r=>{if(!rr(r)){const{message:l}=G("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!$2(n)){const{message:l}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=wA(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Wd(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ci(o)){const{message:l}=G("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),F(this,"isValidUpdate",async r=>{if(!rr(r)){const{message:c}=G("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:n,namespaces:i}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=Wd(i,"update()");if(o)throw new Error(o.message);const a=_w(s.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)}),F(this,"isValidExtend",async r=>{if(!rr(r)){const{message:i}=G("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)}),F(this,"isValidRequest",async r=>{if(!rr(r)){const{message:c}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:n,request:i,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!xw(a,s)){const{message:c}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!AA(i)){const{message:c}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!NA(a,s,i.method)){const{message:c}=G("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}if(o&&!TA(o,tp)){const{message:c}=G("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${tp.min} and ${tp.max}`);throw new Error(c)}}),F(this,"isValidRespond",async r=>{var n;if(!rr(r)){const{message:o}=G("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:i,response:s}=r;try{await this.isValidSessionTopic(i)}catch(o){throw(n=r==null?void 0:r.response)!=null&&n.id&&this.cleanupAfterResponse(r),o}if(!$A(s)){const{message:o}=G("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),F(this,"isValidPing",async r=>{if(!rr(r)){const{message:i}=G("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}),F(this,"isValidEmit",async r=>{if(!rr(r)){const{message:a}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!xw(o,s)){const{message:a}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!SA(i)){const{message:a}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!OA(o,s,i.name)){const{message:a}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}}),F(this,"isValidDisconnect",async r=>{if(!rr(r)){const{message:i}=G("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}),F(this,"isValidAuthenticate",r=>{const{chains:n,uri:i,domain:s,nonce:o}=r;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!ht(i,!1))throw new Error("uri is required parameter");if(!ht(s,!1))throw new Error("domain is required parameter");if(!ht(o,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(c=>bo(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=bo(n[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),F(this,"getVerifyContext",async r=>{const{attestationId:n,hash:i,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||ic,validation:"UNKNOWN",origin:o.url||""}};try{if(a===it.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:n,hash:i,encryptedId:s,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),F(this,"validateSessionProps",(r,n)=>{Object.values(r).forEach((i,s)=>{if(i==null){const{message:o}=G("MISSING_OR_INVALID",`${n} must contain an existing value for each key. Received: ${i} for key ${Object.keys(r)[s]}`);throw new Error(o)}})}),F(this,"getPendingAuthRequest",r=>{const n=this.client.auth.requests.get(r);return typeof n=="object"?n:void 0}),F(this,"addToRecentlyDeleted",(r,n)=>{if(this.recentlyDeletedMap.set(r,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=s)break;this.recentlyDeletedMap.delete(o)}}}),F(this,"checkRecentlyDeleted",r=>{const n=this.recentlyDeletedMap.get(r);if(n){const{message:i}=G("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${r}`);throw new Error(i)}}),F(this,"isLinkModeEnabled",(r,n)=>{var i,s,o,a,c,l,u,h,d;return!r||n!==it.link_mode?!1:((s=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=r==null?void 0:r.redirect)==null?void 0:u.universal)!==void 0&&((h=r==null?void 0:r.redirect)==null?void 0:h.universal)!==""&&((d=r==null?void 0:r.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),F(this,"getAppLinkIfEnabled",(r,n)=>{var i;return this.isLinkModeEnabled(r,n)?(i=r==null?void 0:r.redirect)==null?void 0:i.universal:void 0}),F(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const n=Fg(r,"topic")||"",i=decodeURIComponent(Fg(r,"wc_ev")||""),s=this.client.session.keys.includes(n);s&&this.client.session.update(n,{transportType:it.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:i,sessionExists:s})}),F(this,"registerLinkModeListeners",async()=>{var r;if(Y0()||Ii()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const n=global==null?void 0:global.Linking;if(typeof n<"u"){n.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await n.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}),F(this,"shouldSetTVF",(r,n)=>{if(!n||r!=="wc_sessionRequest")return!1;const{request:i}=n;return Object.keys(Nm).includes(i.method)}),F(this,"getTVFParams",(r,n,i)=>{var s,o;try{const a=n.request.method,c=this.extractTxHashesFromResult(a,i);return Ft(Ye({correlationId:r,rpcMethods:[a],chainId:n.chainId},this.isValidContractData(n.request.params)&&{contractAddresses:[(o=(s=n.request.params)==null?void 0:s[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),F(this,"isValidContractData",r=>{var n;if(!r)return!1;try{const i=(r==null?void 0:r.data)||((n=r==null?void 0:r[0])==null?void 0:n.data);if(!i.startsWith("0x"))return!1;const s=i.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),F(this,"extractTxHashesFromResult",(r,n)=>{try{const i=Nm[r];if(typeof n=="string")return[n];const s=n[i.key];if(Yr(s))return r==="solana_signAllTransactions"?s.map(o=>a_(o)):s;if(typeof s=="string")return[s]}catch(i){this.client.logger.warn("Error extracting tx hashes from result",i)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[n,i]of Object.entries(r))for(const s of i)try{await this.onProviderMessageEvent({topic:n,message:s,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${n}, message: ${s}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(At.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:n,attestation:i,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Qu)?this.client.auth.authKeys.get(Qu):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,n,{receiverPublicKey:o,encoding:s===it.link_mode?hi:Zr});u1(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:i,transportType:s,encryptedId:fn(n)})):Jh(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s}),await this.client.core.relayer.messages.ack(r,n)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(Tr.expired,async e=>{const{topic:r,id:n}=Vb(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,G("EXPIRED"),!0);if(n&&this.client.auth.requests.keys.includes(n))return await this.deletePendingAuthRequest(n,G("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(Xi.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Xi.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ht(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(ci(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=G("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ht(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(ci(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=G("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=G("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(ht(e,!1)){const{message:r}=G("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=G("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!_A(e)){const{message:r}=G("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(ci(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=G("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}},WT=class extends $s{constructor(e,r){super(e,r,NT,p1),this.core=e,this.logger=r}},VT=class extends $s{constructor(e,r){super(e,r,OT,p1),this.core=e,this.logger=r}},KT=class extends $s{constructor(e,r){super(e,r,kT,p1,n=>n.id),this.core=e,this.logger=r}},GT=class extends $s{constructor(e,r){super(e,r,DT,td,()=>Qu),this.core=e,this.logger=r}},ZT=class extends $s{constructor(e,r){super(e,r,BT,td),this.core=e,this.logger=r}},YT=class extends $s{constructor(e,r){super(e,r,MT,td,n=>n.id),this.core=e,this.logger=r}};var JT=Object.defineProperty,XT=(t,e,r)=>e in t?JT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rp=(t,e,r)=>XT(t,typeof e!="symbol"?e+"":e,r);let QT=class{constructor(e,r){this.core=e,this.logger=r,rp(this,"authKeys"),rp(this,"pairingTopics"),rp(this,"requests"),this.authKeys=new GT(this.core,this.logger),this.pairingTopics=new ZT(this.core,this.logger),this.requests=new YT(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}};var eR=Object.defineProperty,tR=(t,e,r)=>e in t?eR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_e=(t,e,r)=>tR(t,typeof e!="symbol"?e+"":e,r);let rR=class t5 extends RS{constructor(e){super(e),_e(this,"protocol",X3),_e(this,"version",Q3),_e(this,"name",ep.name),_e(this,"metadata"),_e(this,"core"),_e(this,"logger"),_e(this,"events",new J3.EventEmitter),_e(this,"engine"),_e(this,"session"),_e(this,"proposal"),_e(this,"pendingRequest"),_e(this,"auth"),_e(this,"signConfig"),_e(this,"on",(n,i)=>this.events.on(n,i)),_e(this,"once",(n,i)=>this.events.once(n,i)),_e(this,"off",(n,i)=>this.events.off(n,i)),_e(this,"removeListener",(n,i)=>this.events.removeListener(n,i)),_e(this,"removeAllListeners",n=>this.events.removeAllListeners(n)),_e(this,"connect",async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"pair",async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"approve",async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"reject",async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"update",async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"extend",async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"request",async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"respond",async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"ping",async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"emit",async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"disconnect",async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"find",n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}}),_e(this,"authenticate",async(n,i)=>{try{return await this.engine.authenticate(n,i)}catch(s){throw this.logger.error(s.message),s}}),_e(this,"formatAuthMessage",n=>{try{return this.engine.formatAuthMessage(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"approveSessionAuthenticate",async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}}),_e(this,"rejectSessionAuthenticate",async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}}),this.name=(e==null?void 0:e.name)||ep.name,this.metadata=bx(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const r=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:ll(Vh({level:(e==null?void 0:e.logger)||ep.logger}));this.core=(e==null?void 0:e.core)||new CT(e),this.logger=Kt(r,this.name),this.session=new VT(this.core,this.logger),this.proposal=new WT(this.core,this.logger),this.pendingRequest=new KT(this.core,this.logger),this.engine=new qT(this),this.auth=new QT(this.core,this.logger)}static async init(e){const r=new t5(e);return await r.initialize(),r}get context(){return ar(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},K.toMiliseconds(K.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var f1={exports:{}},$o=typeof Reflect=="object"?Reflect:null,Pm=$o&&typeof $o.apply=="function"?$o.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},eh;$o&&typeof $o.ownKeys=="function"?eh=$o.ownKeys:Object.getOwnPropertySymbols?eh=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:eh=function(e){return Object.getOwnPropertyNames(e)};function nR(t){console&&console.warn&&console.warn(t)}var r5=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}f1.exports=Ke;f1.exports.once=aR;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var km=10;function rd(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return km},set:function(t){if(typeof t!="number"||t<0||r5(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");km=t}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||r5(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function n5(t){return t._maxListeners===void 0?Ke.defaultMaxListeners:t._maxListeners}Ke.prototype.getMaxListeners=function(){return n5(this)};Ke.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")Pm(c,this,r);else for(var l=c.length,u=c5(c,l),n=0;n<l;++n)Pm(u[n],this,r);return!0};function i5(t,e,r,n){var i,s,o;if(rd(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=n5(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,nR(a)}return t}Ke.prototype.addListener=function(e,r){return i5(this,e,r,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,r){return i5(this,e,r,!0)};function iR(){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 s5(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=iR.bind(n);return i.listener=r,n.wrapFn=i,i}Ke.prototype.once=function(e,r){return rd(r),this.on(e,s5(this,e,r)),this};Ke.prototype.prependOnceListener=function(e,r){return rd(r),this.prependListener(e,s5(this,e,r)),this};Ke.prototype.removeListener=function(e,r){var n,i,s,o,a;if(rd(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():sR(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function o5(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?oR(i):c5(i,i.length)}Ke.prototype.listeners=function(e){return o5(this,e,!0)};Ke.prototype.rawListeners=function(e){return o5(this,e,!1)};Ke.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):a5.call(t,e)};Ke.prototype.listenerCount=a5;function a5(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?eh(this._events):[]};function c5(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function sR(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function oR(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function aR(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}l5(t,e,s,{once:!0}),e!=="error"&&cR(t,i,{once:!0})})}function cR(t,e,r){typeof t.on=="function"&&l5(t,"error",e,r)}function l5(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var lR=f1.exports,p0={exports:{}};(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof pn<"u"&&pn,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof pn<"u"&&pn||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(m){return m&&DataView.prototype.isPrototypeOf(m)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(m){return m&&u.indexOf(Object.prototype.toString.call(m))>-1};function d(m){if(typeof m!="string"&&(m=String(m)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(m)||m==="")throw new TypeError('Invalid character in header field name: "'+m+'"');return m.toLowerCase()}function p(m){return typeof m!="string"&&(m=String(m)),m}function f(m){var y={next:function(){var x=m.shift();return{done:x===void 0,value:x}}};return c.iterable&&(y[Symbol.iterator]=function(){return y}),y}function g(m){this.map={},m instanceof g?m.forEach(function(y,x){this.append(x,y)},this):Array.isArray(m)?m.forEach(function(y){if(y.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+y.length);this.append(y[0],y[1])},this):m&&Object.getOwnPropertyNames(m).forEach(function(y){this.append(y,m[y])},this)}g.prototype.append=function(m,y){m=d(m),y=p(y);var x=this.map[m];this.map[m]=x?x+", "+y:y},g.prototype.delete=function(m){delete this.map[d(m)]},g.prototype.get=function(m){return m=d(m),this.has(m)?this.map[m]:null},g.prototype.has=function(m){return this.map.hasOwnProperty(d(m))},g.prototype.set=function(m,y){this.map[d(m)]=p(y)},g.prototype.forEach=function(m,y){for(var x in this.map)this.map.hasOwnProperty(x)&&m.call(y,this.map[x],x,this)},g.prototype.keys=function(){var m=[];return this.forEach(function(y,x){m.push(x)}),f(m)},g.prototype.values=function(){var m=[];return this.forEach(function(y){m.push(y)}),f(m)},g.prototype.entries=function(){var m=[];return this.forEach(function(y,x){m.push([x,y])}),f(m)},c.iterable&&(g.prototype[Symbol.iterator]=g.prototype.entries);function w(m){if(!m._noBody){if(m.bodyUsed)return Promise.reject(new TypeError("Already read"));m.bodyUsed=!0}}function v(m){return new Promise(function(y,x){m.onload=function(){y(m.result)},m.onerror=function(){x(m.error)}})}function b(m){var y=new FileReader,x=v(y);return y.readAsArrayBuffer(m),x}function C(m){var y=new FileReader,x=v(y),_=/charset=([A-Za-z0-9_-]+)/.exec(m.type),O=_?_[1]:"utf-8";return y.readAsText(m,O),x}function E(m){for(var y=new Uint8Array(m),x=new Array(y.length),_=0;_<y.length;_++)x[_]=String.fromCharCode(y[_]);return x.join("")}function A(m){if(m.slice)return m.slice(0);var y=new Uint8Array(m.byteLength);return y.set(new Uint8Array(m)),y.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(m){this.bodyUsed=this.bodyUsed,this._bodyInit=m,m?typeof m=="string"?this._bodyText=m:c.blob&&Blob.prototype.isPrototypeOf(m)?this._bodyBlob=m:c.formData&&FormData.prototype.isPrototypeOf(m)?this._bodyFormData=m:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(m)?this._bodyText=m.toString():c.arrayBuffer&&c.blob&&l(m)?(this._bodyArrayBuffer=A(m.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(m)||h(m))?this._bodyArrayBuffer=A(m):this._bodyText=m=Object.prototype.toString.call(m):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof m=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(m)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var m=w(this);if(m)return m;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var m=w(this);return m||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(b);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var m=w(this);if(m)return m;if(this._bodyBlob)return C(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(E(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(B)}),this.json=function(){return this.text().then(JSON.parse)},this}var T=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function k(m){var y=m.toUpperCase();return T.indexOf(y)>-1?y:m}function I(m,y){if(!(this instanceof I))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');y=y||{};var x=y.body;if(m instanceof I){if(m.bodyUsed)throw new TypeError("Already read");this.url=m.url,this.credentials=m.credentials,y.headers||(this.headers=new g(m.headers)),this.method=m.method,this.mode=m.mode,this.signal=m.signal,!x&&m._bodyInit!=null&&(x=m._bodyInit,m.bodyUsed=!0)}else this.url=String(m);if(this.credentials=y.credentials||this.credentials||"same-origin",(y.headers||!this.headers)&&(this.headers=new g(y.headers)),this.method=k(y.method||this.method||"GET"),this.mode=y.mode||this.mode||null,this.signal=y.signal||this.signal||function(){if("AbortController"in a){var R=new AbortController;return R.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&x)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(x),(this.method==="GET"||this.method==="HEAD")&&(y.cache==="no-store"||y.cache==="no-cache")){var _=/([?&])_=[^&]*/;if(_.test(this.url))this.url=this.url.replace(_,"$1_="+new Date().getTime());else{var O=/\?/;this.url+=(O.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}I.prototype.clone=function(){return new I(this,{body:this._bodyInit})};function B(m){var y=new FormData;return m.trim().split("&").forEach(function(x){if(x){var _=x.split("="),O=_.shift().replace(/\+/g," "),R=_.join("=").replace(/\+/g," ");y.append(decodeURIComponent(O),decodeURIComponent(R))}}),y}function D(m){var y=new g,x=m.replace(/\r?\n[\t ]+/g," ");return x.split("\r").map(function(_){return _.indexOf(`
|
|
39
|
-
`)===0?_.substr(1,_.length):_}).forEach(function(_){var O=_.split(":"),R=O.shift().trim();if(R){var U=O.join(":").trim();try{y.append(R,U)}catch(j){console.warn("Response "+j.message)}}}),y}S.call(I.prototype);function M(m,y){if(!(this instanceof M))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(y||(y={}),this.type="default",this.status=y.status===void 0?200:y.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=y.statusText===void 0?"":""+y.statusText,this.headers=new g(y.headers),this.url=y.url||"",this._initBody(m)}S.call(M.prototype),M.prototype.clone=function(){return new M(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new g(this.headers),url:this.url})},M.error=function(){var m=new M(null,{status:200,statusText:""});return m.ok=!1,m.status=0,m.type="error",m};var W=[301,302,303,307,308];M.redirect=function(m,y){if(W.indexOf(y)===-1)throw new RangeError("Invalid status code");return new M(null,{status:y,headers:{location:m}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(y,x){this.message=y,this.name=x;var _=Error(y);this.stack=_.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function $(m,y){return new Promise(function(x,_){var O=new I(m,y);if(O.signal&&O.signal.aborted)return _(new o.DOMException("Aborted","AbortError"));var R=new XMLHttpRequest;function U(){R.abort()}R.onload=function(){var z={statusText:R.statusText,headers:D(R.getAllResponseHeaders()||"")};O.url.indexOf("file://")===0&&(R.status<200||R.status>599)?z.status=200:z.status=R.status,z.url="responseURL"in R?R.responseURL:z.headers.get("X-Request-URL");var te="response"in R?R.response:R.responseText;setTimeout(function(){x(new M(te,z))},0)},R.onerror=function(){setTimeout(function(){_(new TypeError("Network request failed"))},0)},R.ontimeout=function(){setTimeout(function(){_(new TypeError("Network request timed out"))},0)},R.onabort=function(){setTimeout(function(){_(new o.DOMException("Aborted","AbortError"))},0)};function j(z){try{return z===""&&a.location.href?a.location.href:z}catch{return z}}if(R.open(O.method,j(O.url),!0),O.credentials==="include"?R.withCredentials=!0:O.credentials==="omit"&&(R.withCredentials=!1),"responseType"in R&&(c.blob?R.responseType="blob":c.arrayBuffer&&(R.responseType="arraybuffer")),y&&typeof y.headers=="object"&&!(y.headers instanceof g||a.Headers&&y.headers instanceof a.Headers)){var V=[];Object.getOwnPropertyNames(y.headers).forEach(function(z){V.push(d(z)),R.setRequestHeader(z,p(y.headers[z]))}),O.headers.forEach(function(z,te){V.indexOf(te)===-1&&R.setRequestHeader(te,z)})}else O.headers.forEach(function(z,te){R.setRequestHeader(te,z)});O.signal&&(O.signal.addEventListener("abort",U),R.onreadystatechange=function(){R.readyState===4&&O.signal.removeEventListener("abort",U)}),R.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return $.polyfill=!0,a.fetch||(a.fetch=$,a.Headers=g,a.Request=I,a.Response=M),o.Headers=g,o.Request=I,o.Response=M,o.fetch=$,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=r.fetch?r:n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(p0,p0.exports);var uR=p0.exports;const Tm=Jc(uR);var hR=Object.defineProperty,dR=Object.defineProperties,pR=Object.getOwnPropertyDescriptors,Rm=Object.getOwnPropertySymbols,fR=Object.prototype.hasOwnProperty,gR=Object.prototype.propertyIsEnumerable,Lm=(t,e,r)=>e in t?hR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dm=(t,e)=>{for(var r in e||(e={}))fR.call(e,r)&&Lm(t,r,e[r]);if(Rm)for(var r of Rm(e))gR.call(e,r)&&Lm(t,r,e[r]);return t},Bm=(t,e)=>dR(t,pR(e));const wR={Accept:"application/json","Content-Type":"application/json"},mR="POST",Mm={headers:wR,method:mR},Um=10;let Xr=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new lR.EventEmitter,this.isAvailable=!1,this.registering=!1,!Zw(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Gn(e),n=await(await Tm(this.url,Bm(Dm({},Mm),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!Zw(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Gn({id:1,jsonrpc:"2.0",method:"test",params:[]});await Tm(e,Bm(Dm({},Mm),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);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(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?fs(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Yh(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return f3(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Um&&this.events.setMaxListeners(Um)}};var g1={exports:{}},So=typeof Reflect=="object"?Reflect:null,jm=So&&typeof So.apply=="function"?So.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},th;So&&typeof So.ownKeys=="function"?th=So.ownKeys:Object.getOwnPropertySymbols?th=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:th=function(e){return Object.getOwnPropertyNames(e)};function vR(t){console&&console.warn&&console.warn(t)}var u5=Number.isNaN||function(e){return e!==e};function Ge(){Ge.init.call(this)}g1.exports=Ge;g1.exports.once=ER;Ge.EventEmitter=Ge;Ge.prototype._events=void 0;Ge.prototype._eventsCount=0;Ge.prototype._maxListeners=void 0;var zm=10;function nd(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ge,"defaultMaxListeners",{enumerable:!0,get:function(){return zm},set:function(t){if(typeof t!="number"||t<0||u5(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");zm=t}});Ge.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ge.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||u5(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function h5(t){return t._maxListeners===void 0?Ge.defaultMaxListeners:t._maxListeners}Ge.prototype.getMaxListeners=function(){return h5(this)};Ge.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")jm(c,this,r);else for(var l=c.length,u=w5(c,l),n=0;n<l;++n)jm(u[n],this,r);return!0};function d5(t,e,r,n){var i,s,o;if(nd(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=h5(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,vR(a)}return t}Ge.prototype.addListener=function(e,r){return d5(this,e,r,!1)};Ge.prototype.on=Ge.prototype.addListener;Ge.prototype.prependListener=function(e,r){return d5(this,e,r,!0)};function yR(){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 p5(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=yR.bind(n);return i.listener=r,n.wrapFn=i,i}Ge.prototype.once=function(e,r){return nd(r),this.on(e,p5(this,e,r)),this};Ge.prototype.prependOnceListener=function(e,r){return nd(r),this.prependListener(e,p5(this,e,r)),this};Ge.prototype.removeListener=function(e,r){var n,i,s,o,a;if(nd(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():bR(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Ge.prototype.off=Ge.prototype.removeListener;Ge.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function f5(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?CR(i):w5(i,i.length)}Ge.prototype.listeners=function(e){return f5(this,e,!0)};Ge.prototype.rawListeners=function(e){return f5(this,e,!1)};Ge.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):g5.call(t,e)};Ge.prototype.listenerCount=g5;function g5(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ge.prototype.eventNames=function(){return this._eventsCount>0?th(this._events):[]};function w5(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function bR(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function CR(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ER(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}m5(t,e,s,{once:!0}),e!=="error"&&xR(t,i,{once:!0})})}function xR(t,e,r){typeof t.on=="function"&&m5(t,"error",e,r)}function m5(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var _R=g1.exports;const IR=Jc(_R),Fm="error",AR="wss://relay.walletconnect.org",$R="wc",SR="universal_provider",Tl=`${$R}@2:${SR}:`,v5="https://rpc.walletconnect.org/v1/",ao="generic",NR=`${v5}bundler`,Br={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function OR(){}function w1(t){return t==null||typeof t!="object"&&typeof t!="function"}function m1(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function PR(t){if(w1(t))return t;if(Array.isArray(t)||m1(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),r=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new r(t);if(t instanceof RegExp){const n=new r(t);return n.lastIndex=t.lastIndex,n}if(t instanceof DataView)return new r(t.buffer.slice(0));if(t instanceof Error){const n=new r(t.message);return n.stack=t.stack,n.name=t.name,n.cause=t.cause,n}if(typeof File<"u"&&t instanceof File)return new r([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const n=Object.create(e);return Object.assign(n,t)}return t}function Hm(t){return typeof t=="object"&&t!==null}function y5(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function b5(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kR="[object RegExp]",C5="[object String]",E5="[object Number]",x5="[object Boolean]",_5="[object Arguments]",TR="[object Symbol]",RR="[object Date]",LR="[object Map]",DR="[object Set]",BR="[object Array]",MR="[object ArrayBuffer]",UR="[object Object]",jR="[object DataView]",zR="[object Uint8Array]",FR="[object Uint8ClampedArray]",HR="[object Uint16Array]",qR="[object Uint32Array]",WR="[object Int8Array]",VR="[object Int16Array]",KR="[object Int32Array]",GR="[object Float32Array]",ZR="[object Float64Array]";function YR(t,e){return mo(t,void 0,t,new Map,e)}function mo(t,e,r,n=new Map,i=void 0){const s=i==null?void 0:i(t,e,r,n);if(s!=null)return s;if(w1(t))return t;if(n.has(t))return n.get(t);if(Array.isArray(t)){const o=new Array(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=mo(t[a],a,r,n,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;n.set(t,o);for(const[a,c]of t)o.set(a,mo(c,a,r,n,i));return o}if(t instanceof Set){const o=new Set;n.set(t,o);for(const a of t)o.add(mo(a,void 0,r,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(m1(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=mo(t[a],a,r,n,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return n.set(t,o),Qi(o,t,r,n,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return n.set(t,o),Qi(o,t,r,n,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return n.set(t,o),Qi(o,t,r,n,i),o}if(t instanceof Error){const o=new t.constructor;return n.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Qi(o,t,r,n,i),o}if(typeof t=="object"&&JR(t)){const o=Object.create(Object.getPrototypeOf(t));return n.set(t,o),Qi(o,t,r,n,i),o}return t}function Qi(t,e,r=t,n,i){const s=[...Object.keys(e),...y5(e)];for(let o=0;o<s.length;o++){const a=s[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=mo(e[a],a,r,n,i))}}function JR(t){switch(b5(t)){case _5:case BR:case MR:case jR:case x5:case RR:case GR:case ZR:case WR:case VR:case KR:case LR:case E5:case UR:case kR:case DR:case C5:case TR:case zR:case FR:case HR:case qR:return!0;default:return!1}}function XR(t,e){return YR(t,(r,n,i,s)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case E5:case C5:case x5:{const o=new t.constructor(t==null?void 0:t.valueOf());return Qi(o,t),o}case _5:{const o={};return Qi(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function qm(t){return XR(t)}function Wm(t){return t!==null&&typeof t=="object"&&b5(t)==="[object Arguments]"}function QR(t){return m1(t)}function eL(t){var r;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const n=t[Symbol.toStringTag];return n==null||!((r=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&r.writable)?!1:t.toString()===`[object ${n}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function tL(t,...e){const r=e.slice(0,-1),n=e[e.length-1];let i=t;for(let s=0;s<r.length;s++){const o=r[s];i=f0(i,o,n,new Map)}return i}function f0(t,e,r,n){if(w1(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(n.has(e))return PR(n.get(e));if(n.set(e,t),Array.isArray(e)){e=e.slice();for(let s=0;s<e.length;s++)e[s]=e[s]??void 0}const i=[...Object.keys(e),...y5(e)];for(let s=0;s<i.length;s++){const o=i[s];let a=e[o],c=t[o];if(Wm(a)&&(a={...a}),Wm(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=qm(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],h=Reflect.ownKeys(c);for(let d=0;d<h.length;d++){const p=h[d];u[p]=c[p]}c=u}else c=[];const l=r(c,a,o,t,e,n);l!=null?t[o]=l:Array.isArray(a)||Hm(c)&&Hm(a)?t[o]=f0(c,a,r,n):c==null&&eL(a)?t[o]=f0({},a,r,n):c==null&&QR(a)?t[o]=qm(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function rL(t,...e){return tL(t,...e,OR)}var nL=Object.defineProperty,iL=Object.defineProperties,sL=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertySymbols,oL=Object.prototype.hasOwnProperty,aL=Object.prototype.propertyIsEnumerable,Km=(t,e,r)=>e in t?nL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rl=(t,e)=>{for(var r in e||(e={}))oL.call(e,r)&&Km(t,r,e[r]);if(Vm)for(var r of Vm(e))aL.call(e,r)&&Km(t,r,e[r]);return t},cL=(t,e)=>iL(t,sL(e));function br(t,e,r){var n;const i=bo(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${v5}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function Ss(t){return t.includes(":")?t.split(":")[1]:t}function I5(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function lL(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function np(t={},e={}){const r=Gm(t),n=Gm(e);return rL(r,n)}function Gm(t){var e,r,n,i;const s={};if(!yc(t))return s;for(const[o,a]of Object.entries(t)){const c=n1(o)?[o]:a.chains,l=a.methods||[],u=a.events||[],h=a.rpcMap||{},d=Ka(o);s[d]=cL(Rl(Rl({},s[d]),a),{chains:zu(c,(e=s[d])==null?void 0:e.chains),methods:zu(l,(r=s[d])==null?void 0:r.methods),events:zu(u,(n=s[d])==null?void 0:n.events),rpcMap:Rl(Rl({},h),(i=s[d])==null?void 0:i.rpcMap)})}return s}function Zm(t){return t.includes(":")?t.split(":")[2]:t}function Ym(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=n1(r)?[r]:n.chains?n.chains:I5(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function ip(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const A5={},Pe=t=>A5[t],sp=(t,e)=>{A5[t]=e};var uL=Object.defineProperty,hL=(t,e,r)=>e in t?uL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Us=(t,e,r)=>hL(t,typeof e!="symbol"?e+"":e,r);let dL=class{constructor(e){Us(this,"name","polkadot"),Us(this,"client"),Us(this,"httpProviders"),Us(this,"events"),Us(this,"namespace"),Us(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var pL=Object.defineProperty,fL=Object.defineProperties,gL=Object.getOwnPropertyDescriptors,Jm=Object.getOwnPropertySymbols,wL=Object.prototype.hasOwnProperty,mL=Object.prototype.propertyIsEnumerable,g0=(t,e,r)=>e in t?pL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xm=(t,e)=>{for(var r in e||(e={}))wL.call(e,r)&&g0(t,r,e[r]);if(Jm)for(var r of Jm(e))mL.call(e,r)&&g0(t,r,e[r]);return t},Qm=(t,e)=>fL(t,gL(e)),js=(t,e,r)=>g0(t,typeof e!="symbol"?e+"":e,r);let vL=class{constructor(e){js(this,"name","eip155"),js(this,"client"),js(this,"chainId"),js(this,"namespace"),js(this,"httpProviders"),js(this,"events"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const n=r||br(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(Ss(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Qm(Xm({},o.sessionProperties||{}),{capabilities:Qm(Xm({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fi("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${NR}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}};var yL=Object.defineProperty,bL=(t,e,r)=>e in t?yL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zs=(t,e,r)=>bL(t,typeof e!="symbol"?e+"":e,r);let CL=class{constructor(e){zs(this,"name","solana"),zs(this,"client"),zs(this,"httpProviders"),zs(this,"events"),zs(this,"namespace"),zs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var EL=Object.defineProperty,xL=(t,e,r)=>e in t?EL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fs=(t,e,r)=>xL(t,typeof e!="symbol"?e+"":e,r);let _L=class{constructor(e){Fs(this,"name","cosmos"),Fs(this,"client"),Fs(this,"httpProviders"),Fs(this,"events"),Fs(this,"namespace"),Fs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var IL=Object.defineProperty,AL=(t,e,r)=>e in t?IL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e,r)=>AL(t,typeof e!="symbol"?e+"":e,r);let $L=class{constructor(e){Hs(this,"name","algorand"),Hs(this,"client"),Hs(this,"httpProviders"),Hs(this,"events"),Hs(this,"namespace"),Hs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Dr(new Xr(n,Pe("disableProviderPing")))}};var SL=Object.defineProperty,NL=(t,e,r)=>e in t?SL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qs=(t,e,r)=>NL(t,typeof e!="symbol"?e+"":e,r);class OL{constructor(e){qs(this,"name","cip34"),qs(this,"client"),qs(this,"httpProviders"),qs(this,"events"),qs(this,"namespace"),qs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=Ss(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}}var PL=Object.defineProperty,kL=(t,e,r)=>e in t?PL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ws=(t,e,r)=>kL(t,typeof e!="symbol"?e+"":e,r);class TL{constructor(e){Ws(this,"name","elrond"),Ws(this,"client"),Ws(this,"httpProviders"),Ws(this,"events"),Ws(this,"namespace"),Ws(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}}var RL=Object.defineProperty,LL=(t,e,r)=>e in t?RL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vs=(t,e,r)=>LL(t,typeof e!="symbol"?e+"":e,r);let DL=class{constructor(e){Vs(this,"name","multiversx"),Vs(this,"client"),Vs(this,"httpProviders"),Vs(this,"events"),Vs(this,"namespace"),Vs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var BL=Object.defineProperty,ML=(t,e,r)=>e in t?BL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e,r)=>ML(t,typeof e!="symbol"?e+"":e,r);let UL=class{constructor(e){Ks(this,"name","near"),Ks(this,"client"),Ks(this,"httpProviders"),Ks(this,"events"),Ks(this,"namespace"),Ks(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace);return typeof n>"u"?void 0:new Dr(new Xr(n,Pe("disableProviderPing")))}};var jL=Object.defineProperty,zL=(t,e,r)=>e in t?jL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gs=(t,e,r)=>zL(t,typeof e!="symbol"?e+"":e,r);let FL=class{constructor(e){Gs(this,"name","tezos"),Gs(this,"client"),Gs(this,"httpProviders"),Gs(this,"events"),Gs(this,"namespace"),Gs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace);return typeof n>"u"?void 0:new Dr(new Xr(n))}};var HL=Object.defineProperty,qL=(t,e,r)=>e in t?HL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zs=(t,e,r)=>qL(t,typeof e!="symbol"?e+"":e,r);let WL=class{constructor(e){Zs(this,"name",ao),Zs(this,"client"),Zs(this,"httpProviders"),Zs(this,"events"),Zs(this,"namespace"),Zs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=bo(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var VL=Object.defineProperty,KL=Object.defineProperties,GL=Object.getOwnPropertyDescriptors,ev=Object.getOwnPropertySymbols,ZL=Object.prototype.hasOwnProperty,YL=Object.prototype.propertyIsEnumerable,w0=(t,e,r)=>e in t?VL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ll=(t,e)=>{for(var r in e||(e={}))ZL.call(e,r)&&w0(t,r,e[r]);if(ev)for(var r of ev(e))YL.call(e,r)&&w0(t,r,e[r]);return t},op=(t,e)=>KL(t,GL(e)),xr=(t,e,r)=>w0(t,typeof e!="symbol"?e+"":e,r);class id{constructor(e){xr(this,"client"),xr(this,"namespaces"),xr(this,"optionalNamespaces"),xr(this,"sessionProperties"),xr(this,"scopedProperties"),xr(this,"events",new IR),xr(this,"rpcProviders",{}),xr(this,"session"),xr(this,"providerOpts"),xr(this,"logger"),xr(this,"uri"),xr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:ll(Vh({level:(e==null?void 0:e.logger)||Fm})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new id(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ll({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,Zh(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Ue("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=Ym(this.session.namespaces);this.namespaces=np(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){const{uri:r,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});r&&(this.uri=r,this.events.emit("display_uri",r));const i=await n();this.session=i;const s=Ym(i.namespaces);return this.namespaces=np(this.namespaces,s),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===ao?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Yr(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,r;if(this.client=this.providerOpts.client||await rR.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Fm,relayUrl:this.providerOpts.relayUrl||AR,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(n){throw this.logger.error("Failed to get session",n),new Error(`The provided session: ${(r=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:r.topic} doesn't exist in the Sign client`)}else{const n=this.client.session.getAll();this.session=n[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>Ka(r)))];sp("client",this.client),sp("events",this.events),sp("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=lL(r,this.session),i=I5(n),s=np(this.namespaces,this.optionalNamespaces),o=op(Ll({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new vL({namespace:o});break;case"algorand":this.rpcProviders[r]=new $L({namespace:o});break;case"solana":this.rpcProviders[r]=new CL({namespace:o});break;case"cosmos":this.rpcProviders[r]=new _L({namespace:o});break;case"polkadot":this.rpcProviders[r]=new dL({namespace:o});break;case"cip34":this.rpcProviders[r]=new OL({namespace:o});break;case"elrond":this.rpcProviders[r]=new TL({namespace:o});break;case"multiversx":this.rpcProviders[r]=new DL({namespace:o});break;case"near":this.rpcProviders[r]=new UL({namespace:o});break;case"tezos":this.rpcProviders[r]=new FL({namespace:o});break;default:this.rpcProviders[ao]?this.rpcProviders[ao].updateNamespace(o):this.rpcProviders[ao]=new WL({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var r;const{topic:n}=e;n===((r=this.session)==null?void 0:r.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:n,topic:i}=e;if(i!==((r=this.session)==null?void 0:r.topic))return;const{event:s}=n;if(s.name==="accountsChanged"){const o=s.data;o&&Yr(o)&&this.events.emit("accountsChanged",o.map(Zm))}else if(s.name==="chainChanged"){const o=n.chainId,a=n.event.data,c=Ka(o),l=ip(o)!==ip(a)?`${c}:${ip(a)}`:o;this.onChainChanged(l)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n,i;if(e!==((n=this.session)==null?void 0:n.topic))return;const{namespaces:s}=r,o=(i=this.client)==null?void 0:i.session.get(e);this.session=op(Ll({},o),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{var r;e.topic===((r=this.session)==null?void 0:r.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",op(Ll({},Ue("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Br.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[ao]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i,scopedProperties:s}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.scopedProperties=s}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>Ka(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=Ka(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(n,i),this.events.emit("chainChanged",i);const s=this.getProvider(n).getDefaultChain();r||this.getProvider(n).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:n,previousChainId:s,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:r,newChainId:n}){var i,s;try{if(r===n)return;const o=(s=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:s.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${n}:`)).map(Zm);if(!Yr(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,r){if(!this.namespaces)return;const n=this.namespaces[e]?e:`${e}:${r}`,i={chains:[],methods:[],events:[],defaultChain:r};this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=r):this.namespaces[n]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var n;const i=((n=this.session)==null?void 0:n.topic)||"";await this.client.core.storage.setItem(`${Tl}/${e}${i}`,r)}async getFromStore(e){var r;const n=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${Tl}/${e}${n}`)}async deleteFromStore(e){var r;const n=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${Tl}/${e}${n}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const r=await this.client.core.storage.getKeys();for(const n of r)n.startsWith(Tl)&&await this.client.core.storage.removeItem(n)}catch(r){this.logger.warn("Failed to cleanup storage",r)}}}const JL=id;var fh={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/jump-site/0.2.0",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm",VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",BASE_URL:"https://cdn.decentraland.org/@dcl/jump-site/0.2.0",MODE:"production",DEV:!1,PROD:!0,SSR:!1},gh={VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm"};const XL="wc",QL="ethereum_provider",eD=`${XL}@2:${QL}:`,tD="https://rpc.walletconnect.org/v1/",wh=["eth_sendTransaction","personal_sign"],$5=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],mh=["chainChanged","accountsChanged"],S5=["chainChanged","accountsChanged","message","disconnect","connect"];var rD=Object.defineProperty,nD=Object.defineProperties,iD=Object.getOwnPropertyDescriptors,tv=Object.getOwnPropertySymbols,sD=Object.prototype.hasOwnProperty,oD=Object.prototype.propertyIsEnumerable,m0=(t,e,r)=>e in t?rD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gi=(t,e)=>{for(var r in e||(e={}))sD.call(e,r)&&m0(t,r,e[r]);if(tv)for(var r of tv(e))oD.call(e,r)&&m0(t,r,e[r]);return t},va=(t,e)=>nD(t,iD(e)),ur=(t,e,r)=>m0(t,typeof e!="symbol"?e+"":e,r);function vh(t){return Number(t[0].split(":")[1])}function Dl(t){return`0x${t.toString(16)}`}function aD(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!Yr(e))throw new Error("Invalid chains");const c={chains:e,methods:n||wh,events:s||mh,rpcMap:Gi({},e.length?{[vh(e)]:a[vh(e)]}:{})},l=s==null?void 0:s.filter(p=>!mh.includes(p)),u=n==null?void 0:n.filter(p=>!wh.includes(p));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(u!=null&&u.length))return{required:e.length?c:void 0};const h=(l==null?void 0:l.length)&&(u==null?void 0:u.length)||!r,d={chains:[...new Set(h?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:$5))],events:[...new Set(c.events.concat(o!=null&&o.length?o:S5))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?d:void 0}}class sd{constructor(){ur(this,"events",new $6.EventEmitter),ur(this,"namespace","eip155"),ur(this,"accounts",[]),ur(this,"signer"),ur(this,"chainId",1),ur(this,"modal"),ur(this,"rpc"),ur(this,"STORAGE_KEY",eD),ur(this,"on",(e,r)=>(this.events.on(e,r),this)),ur(this,"once",(e,r)=>(this.events.once(e,r),this)),ur(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),ur(this,"off",(e,r)=>(this.events.off(e,r),this)),ur(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new sd;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),n)}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(e){var r;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:n,optional:i}=aD(this.rpc);try{const s=await new Promise(async(a,c)=>{var l,u;this.rpc.showQrModal&&((l=this.modal)==null||l.open(),(u=this.modal)==null||u.subscribeState(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const h=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(va(Gi({namespaces:Gi({},n&&{[this.namespace]:n})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic,scopedProperties:h})).then(d=>{a(d)}).catch(d=>{var p;(p=this.modal)==null||p.showErrorMessage("Unable to connect"),c(new Error(d.message))})});if(!s)return;const o=Bg(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Dl(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{(r=this.modal)==null||r.close()}}async authenticate(e,r){var n;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(o,a)=>{var c,l;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(l=this.modal)==null||l.subscribeState(u=>{!u.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(va(Gi({},e),{chains:this.rpc.chains}),r).then(u=>{o(u)}).catch(u=>{var h;(h=this.modal)==null||h.showErrorMessage("Unable to connect"),a(new Error(u.message))})}),s=i.session;if(s){const o=Bg(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Dl(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{(n=this.modal)==null||n.close()}}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",e=>{const{params:r}=e,{event:n}=r;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",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Dl(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",va(Gi({},Ue("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Dl(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||wh:[],c=i.length?(e==null?void 0:e.events)||mh:[],l=(e==null?void 0:e.optionalMethods)||[],u=(e==null?void 0:e.optionalEvents)||[],h=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),d=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(p=>this.formatChainId(p)),optionalChains:s.map(p=>this.formatChainId(p)),methods:a,events:c,optionalMethods:l,optionalEvents:u,rpcMap:h,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?vh(this.rpc.chains):vh(this.rpc.optionalChains),this.signer=await JL.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{createAppKit:n}=await Promise.resolve().then(function(){return Sz}),{convertWCMToAppKitOptions:i}=await Promise.resolve().then(function(){return Uz}),s=i(va(Gi({},this.rpc.qrModalOptions),{chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId}));if(!s.networks.length)throw new Error("No networks found for WalletConnect·");r=n(va(Gi({},s),{universalProvider:this.signer,manualWCControl:!0}))}catch{throw new Error("To use QR modal, please install @reown/appkit package")}if(r)try{this.modal=r}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:n,rpcMap:i}=e;r&&Yr(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&Yr(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${tD}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const cD=sd;var od=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},N5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){var r=1e3,n=6e4,i=36e5,s="millisecond",o="second",a="minute",c="hour",l="day",u="week",h="month",d="quarter",p="year",f="date",g="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var m=["th","st","nd","rd"],y=$%100;return"["+$+(m[(y-20)%10]||m[y]||m[0])+"]"}},C=function($,m,y){var x=String($);return!x||x.length>=m?$:""+Array(m+1-x.length).join(y)+$},E={s:C,z:function($){var m=-$.utcOffset(),y=Math.abs(m),x=Math.floor(y/60),_=y%60;return(m<=0?"+":"-")+C(x,2,"0")+":"+C(_,2,"0")},m:function $(m,y){if(m.date()<y.date())return-$(y,m);var x=12*(y.year()-m.year())+(y.month()-m.month()),_=m.clone().add(x,h),O=y-_<0,R=m.clone().add(x+(O?-1:1),h);return+(-(x+(y-_)/(O?_-R:R-_))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:h,y:p,w:u,d:l,D:f,h:c,m:a,s:o,ms:s,Q:d}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},A="en",S={};S[A]=b;var T="$isDayjsObject",k=function($){return $ instanceof M||!(!$||!$[T])},I=function $(m,y,x){var _;if(!m)return A;if(typeof m=="string"){var O=m.toLowerCase();S[O]&&(_=O),y&&(S[O]=y,_=O);var R=m.split("-");if(!_&&R.length>1)return $(R[0])}else{var U=m.name;S[U]=m,_=U}return!x&&_&&(A=_),_||!x&&A},B=function($,m){if(k($))return $.clone();var y=typeof m=="object"?m:{};return y.date=$,y.args=arguments,new M(y)},D=E;D.l=I,D.i=k,D.w=function($,m){return B($,{locale:m.$L,utc:m.$u,x:m.$x,$offset:m.$offset})};var M=function(){function $(y){this.$L=I(y.locale,null,!0),this.parse(y),this.$x=this.$x||y.x||{},this[T]=!0}var m=$.prototype;return m.parse=function(y){this.$d=function(x){var _=x.date,O=x.utc;if(_===null)return new Date(NaN);if(D.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var R=_.match(w);if(R){var U=R[2]-1||0,j=(R[7]||"0").substring(0,3);return O?new Date(Date.UTC(R[1],U,R[3]||1,R[4]||0,R[5]||0,R[6]||0,j)):new Date(R[1],U,R[3]||1,R[4]||0,R[5]||0,R[6]||0,j)}}return new Date(_)}(y),this.init()},m.init=function(){var y=this.$d;this.$y=y.getFullYear(),this.$M=y.getMonth(),this.$D=y.getDate(),this.$W=y.getDay(),this.$H=y.getHours(),this.$m=y.getMinutes(),this.$s=y.getSeconds(),this.$ms=y.getMilliseconds()},m.$utils=function(){return D},m.isValid=function(){return this.$d.toString()!==g},m.isSame=function(y,x){var _=B(y);return this.startOf(x)<=_&&_<=this.endOf(x)},m.isAfter=function(y,x){return B(y)<this.startOf(x)},m.isBefore=function(y,x){return this.endOf(x)<B(y)},m.$g=function(y,x,_){return D.u(y)?this[x]:this.set(_,y)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(y,x){var _=this,O=!!D.u(x)||x,R=D.p(y),U=function(ge,Ee){var Se=D.w(_.$u?Date.UTC(_.$y,Ee,ge):new Date(_.$y,Ee,ge),_);return O?Se:Se.endOf(l)},j=function(ge,Ee){return D.w(_.toDate()[ge].apply(_.toDate("s"),(O?[0,0,0,0]:[23,59,59,999]).slice(Ee)),_)},V=this.$W,z=this.$M,te=this.$D,he="set"+(this.$u?"UTC":"");switch(R){case p:return O?U(1,0):U(31,11);case h:return O?U(1,z):U(0,z+1);case u:var Ce=this.$locale().weekStart||0,we=(V<Ce?V+7:V)-Ce;return U(O?te-we:te+(6-we),z);case l:case f:return j(he+"Hours",0);case c:return j(he+"Minutes",1);case a:return j(he+"Seconds",2);case o:return j(he+"Milliseconds",3);default:return this.clone()}},m.endOf=function(y){return this.startOf(y,!1)},m.$set=function(y,x){var _,O=D.p(y),R="set"+(this.$u?"UTC":""),U=(_={},_[l]=R+"Date",_[f]=R+"Date",_[h]=R+"Month",_[p]=R+"FullYear",_[c]=R+"Hours",_[a]=R+"Minutes",_[o]=R+"Seconds",_[s]=R+"Milliseconds",_)[O],j=O===l?this.$D+(x-this.$W):x;if(O===h||O===p){var V=this.clone().set(f,1);V.$d[U](j),V.init(),this.$d=V.set(f,Math.min(this.$D,V.daysInMonth())).$d}else U&&this.$d[U](j);return this.init(),this},m.set=function(y,x){return this.clone().$set(y,x)},m.get=function(y){return this[D.p(y)]()},m.add=function(y,x){var _,O=this;y=Number(y);var R=D.p(x),U=function(z){var te=B(O);return D.w(te.date(te.date()+Math.round(z*y)),O)};if(R===h)return this.set(h,this.$M+y);if(R===p)return this.set(p,this.$y+y);if(R===l)return U(1);if(R===u)return U(7);var j=(_={},_[a]=n,_[c]=i,_[o]=r,_)[R]||1,V=this.$d.getTime()+y*j;return D.w(V,this)},m.subtract=function(y,x){return this.add(-1*y,x)},m.format=function(y){var x=this,_=this.$locale();if(!this.isValid())return _.invalidDate||g;var O=y||"YYYY-MM-DDTHH:mm:ssZ",R=D.z(this),U=this.$H,j=this.$m,V=this.$M,z=_.weekdays,te=_.months,he=_.meridiem,Ce=function(Ee,Se,Le,nt){return Ee&&(Ee[Se]||Ee(x,O))||Le[Se].slice(0,nt)},we=function(Ee){return D.s(U%12||12,Ee,"0")},ge=he||function(Ee,Se,Le){var nt=Ee<12?"AM":"PM";return Le?nt.toLowerCase():nt};return O.replace(v,function(Ee,Se){return Se||function(Le){switch(Le){case"YY":return String(x.$y).slice(-2);case"YYYY":return D.s(x.$y,4,"0");case"M":return V+1;case"MM":return D.s(V+1,2,"0");case"MMM":return Ce(_.monthsShort,V,te,3);case"MMMM":return Ce(te,V);case"D":return x.$D;case"DD":return D.s(x.$D,2,"0");case"d":return String(x.$W);case"dd":return Ce(_.weekdaysMin,x.$W,z,2);case"ddd":return Ce(_.weekdaysShort,x.$W,z,3);case"dddd":return z[x.$W];case"H":return String(U);case"HH":return D.s(U,2,"0");case"h":return we(1);case"hh":return we(2);case"a":return ge(U,j,!0);case"A":return ge(U,j,!1);case"m":return String(j);case"mm":return D.s(j,2,"0");case"s":return String(x.$s);case"ss":return D.s(x.$s,2,"0");case"SSS":return D.s(x.$ms,3,"0");case"Z":return R}return null}(Ee)||R.replace(":","")})},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(y,x,_){var O,R=this,U=D.p(x),j=B(y),V=(j.utcOffset()-this.utcOffset())*n,z=this-j,te=function(){return D.m(R,j)};switch(U){case p:O=te()/12;break;case h:O=te();break;case d:O=te()/3;break;case u:O=(z-V)/6048e5;break;case l:O=(z-V)/864e5;break;case c:O=z/i;break;case a:O=z/n;break;case o:O=z/r;break;default:O=z}return _?O:D.a(O)},m.daysInMonth=function(){return this.endOf(h).$D},m.$locale=function(){return S[this.$L]},m.locale=function(y,x){if(!y)return this.$L;var _=this.clone(),O=I(y,x,!0);return O&&(_.$L=O),_},m.clone=function(){return D.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},$}(),W=M.prototype;return B.prototype=W,[["$ms",s],["$s",o],["$m",a],["$H",c],["$W",l],["$M",h],["$y",p],["$D",f]].forEach(function($){W[$[1]]=function(m){return this.$g(m,$[0],$[1])}}),B.extend=function($,m){return $.$i||($(m,M,B),$.$i=!0),B},B.locale=I,B.isDayjs=k,B.unix=function($){return B(1e3*$)},B.en=S[A],B.Ls=S,B.p={},B})})(N5);var v0=N5.exports,O5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(r){var n=["th","st","nd","rd"],i=r%100;return"["+r+(n[(i-20)%10]||n[i]||n[0])+"]"}}})})(O5);var lD=O5.exports,P5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return function(r,n,i){r=r||{};var s=n.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function a(l,u,h,d){return s.fromToBase(l,u,h,d)}i.en.relativeTime=o,s.fromToBase=function(l,u,h,d,p){for(var f,g,w,v=h.$locale().relativeTime||o,b=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],C=b.length,E=0;E<C;E+=1){var A=b[E];A.d&&(f=d?i(l).diff(h,A.d,!0):h.diff(l,A.d,!0));var S=(r.rounding||Math.round)(Math.abs(f));if(w=f>0,S<=A.r||!A.r){S<=1&&E>0&&(A=b[E-1]);var T=v[A.l];p&&(S=p(""+S)),g=typeof T=="string"?T.replace("%d",S):T(S,u,A.l,w);break}}if(u)return g;var k=w?v.future:v.past;return typeof k=="function"?k(g):k.replace("%s",g)},s.to=function(l,u){return a(l,u,this,!0)},s.from=function(l,u){return a(l,u,this)};var c=function(l){return l.$u?i.utc():i()};s.toNow=function(l){return this.to(c(this),l)},s.fromNow=function(l){return this.from(c(this),l)}}})})(P5);var uD=P5.exports,k5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return function(r,n,i){i.updateLocale=function(s,o){var a=i.Ls[s];if(a)return(o?Object.keys(o):[]).forEach(function(c){a[c]=o[c]}),a}}})})(k5);var hD=k5.exports;v0.extend(uD),v0.extend(hD);const dD={...lD,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}};v0.locale("en-web3-modal",dD);const T5={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(r=>r.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]}};var pD=20,fD=1,Oi=1e6,rv=1e6,gD=-7,wD=21,mD=!1,oc="[big.js] ",as=oc+"Invalid ",Bl=as+"decimal places",vD=as+"rounding mode",nv=oc+"Division by zero",Me={},gn=void 0,yD=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function R5(){function t(e){var r=this;if(!(r instanceof t))return e===gn?R5():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(as+"value");e=e===0&&1/e<0?"-0":String(e)}bD(r,e)}r.constructor=t}return t.prototype=Me,t.DP=pD,t.RM=fD,t.NE=gD,t.PE=wD,t.strict=mD,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function bD(t,e){var r,n,i;if(!yD.test(e))throw Error(as+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function Pi(t,e,r,n){var i=t.c;if(r===gn&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(vD);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==gn))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==gn||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function ki(t,e,r){var n=t.e,i=t.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>s)for(n-=s;n--;)i+="0";else n<s&&(i=i.slice(0,n)+"."+i.slice(n));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}Me.abs=function(){var t=new this.constructor(this);return t.s=1,t},Me.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=i.length)?a:c,s=-1;++s<o;)if(n[s]!=i[s])return n[s]>i[s]^e?1:-1;return a==c?0:a>c^e?1:-1},Me.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,s=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>Oi)throw Error(Bl);if(!i[0])throw Error(nv);if(!n[0])return t.s=s,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),p=a=i.length,f=n.length,g=n.slice(0,a),w=g.length,v=t,b=v.c=[],C=0,E=o+(v.e=e.e-t.e)+1;for(v.s=s,s=E<0?0:E,d.unshift(0);w++<a;)g.push(0);do{for(l=0;l<10;l++){if(a!=(w=g.length))u=a>w?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=g[h]){u=i[h]>g[h]?1:-1;break}if(u<0){for(c=w==a?i:d;w;){if(g[--w]<c[w]){for(h=w;h&&!g[--h];)g[h]=9;--g[h],g[w]+=10}g[w]-=c[w]}for(;!g[0];)g.shift()}else break}b[C++]=u?l:++l,g[0]&&u?g[w]=n[p]||0:g=[n[p]]}while((p++<f||g[0]!==gn)&&s--);return!b[0]&&C!=1&&(b.shift(),v.e--,E--),C>E&&Pi(v,E,r.RM,g[0]!==gn),v},Me.eq=function(t){return this.cmp(t)===0},Me.gt=function(t){return this.cmp(t)>0},Me.gte=function(t){return this.cmp(t)>-1},Me.lt=function(t){return this.cmp(t)<0},Me.lte=function(t){return this.cmp(t)<1},Me.minus=Me.sub=function(t){var e,r,n,i,s=this,o=s.constructor,a=s.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,s.plus(t);var l=s.c.slice(),u=s.e,h=t.c,d=t.e;if(!l[0]||!h[0])return h[0]?t.s=-c:l[0]?t=new o(s):t.s=1,t;if(a=u-d){for((i=a<0)?(a=-a,n=l):(d=u,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=l.length<h.length)?l:h).length,a=c=0;c<r;c++)if(l[c]!=h[c]){i=l[c]<h[c];break}if(i&&(n=l,l=h,h=n,t.s=-t.s),(c=(r=h.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;r>a;){if(l[--r]<h[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=h[r]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t},Me.mod=function(t){var e,r=this,n=r.constructor,i=r.s,s=(t=new n(t)).s;if(!t.c[0])throw Error(nv);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=s,e?new n(r):(i=n.DP,s=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=s,this.minus(r.times(t)))},Me.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},Me.plus=Me.add=function(t){var e,r,n,i=this,s=i.constructor;if(t=new s(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new s(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+l[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t},Me.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-rv||t>rv)throw Error(as+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n},Me.prec=function(t,e){if(t!==~~t||t<1||t>Oi)throw Error(as+"precision");return Pi(new this.constructor(this),t,e)},Me.round=function(t,e){if(t===gn)t=0;else if(t!==~~t||t<-Oi||t>Oi)throw Error(Bl);return Pi(new this.constructor(this),t+this.e+1,e)},Me.sqrt=function(){var t,e,r,n=this,i=n.constructor,s=n.s,o=n.e,a=new i("0.5");if(!n.c[0])return new i(n);if(s<0)throw Error(oc+"No square root");s=Math.sqrt(+ki(n,!0,!0)),s===0||s===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):t=new i(s+""),o=t.e+(i.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Pi(t,(i.DP-=4)+t.e+1,i.RM)},Me.times=Me.mul=function(t){var e,r=this,n=r.constructor,i=r.c,s=(t=new n(t)).c,o=i.length,a=s.length,c=r.e,l=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!s[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=s,s=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+s[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},Me.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==gn){if(t!==~~t||t<0||t>Oi)throw Error(Bl);for(r=Pi(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return ki(r,!0,!!n)},Me.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==gn){if(t!==~~t||t<0||t>Oi)throw Error(Bl);for(r=Pi(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return ki(r,!1,!!n)},Me[Symbol.for("nodejs.util.inspect.custom")]=Me.toJSON=Me.toString=function(){var t=this,e=t.constructor;return ki(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},Me.toNumber=function(){var t=+ki(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(oc+"Imprecise conversion");return t},Me.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==gn){if(t!==~~t||t<1||t>Oi)throw Error(as+"precision");for(r=Pi(new n(r),t,e);r.c.length<t;)r.c.push(0)}return ki(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)},Me.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(oc+"valueOf disallowed");return ki(t,t.e<=e.NE||t.e>=e.PE,!0)};var ya=R5();const Ml={bigNumber(t){return t?new ya(t):new ya(0)},multiply(t,e){if(t===void 0||e===void 0)return new ya(0);const r=new ya(t),n=new ya(e);return r.times(n)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},CD=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],ED=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],xD=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],oe={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"},_D={getERC20Abi:t=>oe.USDT_CONTRACT_ADDRESSES.includes(t)?xD:CD,getSwapAbi:()=>ED},ri={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[r,n,i]=e;if(!r||!n||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:r,chainId:n,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[r,n]=e;if(!r||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:r,chainId:n}}},ve={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types"};function ap(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const me={setItem(t,e){Za()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Za())return localStorage.getItem(t)||void 0},removeItem(t){Za()&&localStorage.removeItem(t)},clear(){Za()&&localStorage.clear()}};function Za(){return typeof window<"u"&&typeof localStorage<"u"}function gi(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const ID=Symbol(),iv=Object.getPrototypeOf,y0=new WeakMap,AD=t=>t&&(y0.has(t)?y0.get(t):iv(t)===Object.prototype||iv(t)===Array.prototype),$D=t=>AD(t)&&t[ID]||null,sv=(t,e=!0)=>{y0.set(t,e)},cp=t=>typeof t=="object"&&t!==null,li=new WeakMap,Ya=new WeakSet,SD=(t=Object.is,e=(l,u)=>new Proxy(l,u),r=l=>cp(l)&&!Ya.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),n=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,s=(l,u,h=n)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const p=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return sv(p,!0),i.set(l,[u,p]),Reflect.ownKeys(l).forEach(f=>{if(Object.getOwnPropertyDescriptor(p,f))return;const g=Reflect.get(l,f),{enumerable:w}=Reflect.getOwnPropertyDescriptor(l,f),v={value:g,enumerable:w,configurable:!0};if(Ya.has(g))sv(g,!1);else if(g instanceof Promise)delete v.value,v.get=()=>h(g);else if(li.has(g)){const[b,C]=li.get(g);v.value=s(b,C(),h)}Object.defineProperty(p,f,v)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],c=l=>{if(!cp(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,p=(k,I=++a[0])=>{h!==I&&(h=I,d.forEach(B=>B(k,I)))};let f=a[1];const g=(k=++a[1])=>(f!==k&&!d.size&&(f=k,v.forEach(([I])=>{const B=I[1](k);B>h&&(h=B)})),h),w=k=>(I,B)=>{const D=[...I];D[1]=[k,...D[1]],p(D,B)},v=new Map,b=(k,I)=>{if((fh?"production":void 0)!=="production"&&v.has(k))throw new Error("prop listener already exists");if(d.size){const B=I[3](w(k));v.set(k,[I,B])}else v.set(k,[I])},C=k=>{var I;const B=v.get(k);B&&(v.delete(k),(I=B[1])==null||I.call(B))},E=k=>(d.add(k),d.size===1&&v.forEach(([I,B],D)=>{if((fh?"production":void 0)!=="production"&&B)throw new Error("remove already exists");const M=I[3](w(D));v.set(D,[I,M])}),()=>{d.delete(k),d.size===0&&v.forEach(([I,B],D)=>{B&&(B(),v.set(D,[I]))})}),A=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e(A,{deleteProperty(k,I){const B=Reflect.get(k,I);C(I);const D=Reflect.deleteProperty(k,I);return D&&p(["delete",[I],B]),D},set(k,I,B,D){const M=Reflect.has(k,I),W=Reflect.get(k,I,D);if(M&&(t(W,B)||o.has(B)&&t(W,o.get(B))))return!0;C(I),cp(B)&&(B=$D(B)||B);let $=B;if(B instanceof Promise)B.then(m=>{B.status="fulfilled",B.value=m,p(["resolve",[I],m])}).catch(m=>{B.status="rejected",B.reason=m,p(["reject",[I],m])});else{!li.has(B)&&r(B)&&($=c(B));const m=!Ya.has($)&&li.get($);m&&b(I,m)}return Reflect.set(k,I,$,D),p(["set",[I],B,W]),!0}});o.set(l,S);const T=[A,g,s,E];return li.set(S,T),Reflect.ownKeys(l).forEach(k=>{const I=Object.getOwnPropertyDescriptor(l,k);"value"in I&&(S[k]=l[k],delete I.value,delete I.writable),Object.defineProperty(A,k,I)}),S})=>[c,li,Ya,t,e,r,n,i,s,o,a],[ND]=SD();function Xe(t={}){return ND(t)}function zt(t,e,r){const n=li.get(t);(fh?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let i;const s=[],o=n[3];let a=!1;const c=o(l=>{s.push(l),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(s.splice(0))}))});return a=!0,()=>{a=!1,c()}}function xc(t,e){const r=li.get(t);(fh?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");const[n,i,s]=r;return s(n,i(),e)}function vs(t){return Ya.add(t),t}function Gt(t,e,r,n){let i=t[e];return zt(t,()=>{const s=t[e];Object.is(i,s)||r(i=s)},n)}function OD(t){const e=Xe({data:Array.from([]),has(r){return this.data.some(n=>n[0]===r)},set(r,n){const i=this.data.find(s=>s[0]===r);return i?i[1]=n:this.data.push([r,n]),this},get(r){var n;return(n=this.data.find(i=>i[0]===r))==null?void 0:n[1]},delete(r){const n=this.data.findIndex(i=>i[0]===r);return n===-1?!1:(this.data.splice(n,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(r){this.data.forEach(n=>{r(n[1],n[0],this)})},keys(){return this.data.map(r=>r[0]).values()},values(){return this.data.map(r=>r[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const lp=(typeof process<"u"&&typeof gh<"u"?gh.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",PD=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],mt={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:lp,SECURE_SITE_DASHBOARD:`${lp}/dashboard`,SECURE_SITE_FAVICON:`${lp}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},se={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=se.getActiveNamespace(),e=se.getActiveCaipNetworkId(),r=e?e.split(":")[1]:void 0,n=r?isNaN(Number(r))?r:Number(r):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{me.setItem(ve.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=me.getItem(ve.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{me.removeItem(ve.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{me.setItem(ve.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{me.setItem(ve.ACTIVE_CAIP_NETWORK_ID,t),se.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return me.getItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{me.removeItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=ap(t);me.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=se.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),me.setItem(ve.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=me.getItem(ve.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const r=ap(t);me.setItem(r,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return me.getItem(ve.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=ap(t);return me.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{me.setItem(ve.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return me.getItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{me.removeItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return me.getItem(ve.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var t,e;return(e=(t=me.getItem(ve.ACTIVE_CAIP_NETWORK_ID))==null?void 0:t.split(":"))==null?void 0:e[1]},setConnectionStatus(t){try{me.setItem(ve.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return me.getItem(ve.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=me.getItem(ve.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));me.setItem(ve.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=se.getConnectedNamespaces();e.includes(t)||(e.push(t),se.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=se.getConnectedNamespaces(),r=e.indexOf(t);r>-1&&(e.splice(r,1),se.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return me.getItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{me.setItem(ve.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{me.removeItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=me.getItem(ve.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=se.getBalanceCache();me.setItem(ve.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const e=se.getBalanceCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.portfolio))return e.balance;se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=se.getBalanceCache();e[t.caipAddress]=t,me.setItem(ve.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=me.getItem(ve.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=se.getBalanceCache();me.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const e=se.getNativeBalanceCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.nativeBalance))return e;console.info("Discarding cache for address",t),se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=se.getNativeBalanceCache();e[t.caipAddress]=t,me.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=me.getItem(ve.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const e=se.getEnsCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.ens))return e.ens;se.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=se.getEnsCache();e[t.address]=t,me.setItem(ve.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=se.getEnsCache();me.setItem(ve.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=me.getItem(ve.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const e=se.getIdentityCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.identity))return e.identity;se.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=se.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},me.setItem(ve.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=se.getIdentityCache();me.setItem(ve.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{me.removeItem(ve.PORTFOLIO_CACHE),me.removeItem(ve.NATIVE_BALANCE_CACHE),me.removeItem(ve.ENS_CACHE),me.removeItem(ve.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{me.setItem(ve.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=me.getItem(ve.PREFERRED_ACCOUNT_TYPES);return JSON.parse(t)}catch{console.info("Unable to get preferred account types")}}},Z={isMobile(){var t;return this.isClient()?!!((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return Z.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=mt.TEN_SEC_MS:!0},isAllowedRetry(t,e=mt.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},getPairingExpiry(){return Date.now()+mt.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let r;return(...n)=>{function i(){t(...n)}r&&clearTimeout(r),r=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e){if(Z.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,href:r}},formatUniversalUrl(t,e){if(!Z.isHttpUrl(t))return this.formatNativeUrl(t,e);let r=t;r.endsWith("/")||(r=`${r}/`);const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,href:r}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?se.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,r){window==null||window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},returnOpenHref(t,e,r){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},async preloadImage(t){const e=new Promise((r,n)=>{const i=new Image;i.onload=r,i.onerror=n,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,Z.wait(2e3)])},formatBalance(t,e){let r="0.000";if(typeof t=="string"){const n=Number(t);if(n){const i=Math.floor(n*1e3)/1e3;i&&(r=i.toString())}}return`${r}${e?` ${e}`:""}`},formatBalance2(t,e){var n;let r;if(t==="0")r="0";else if(typeof t=="string"){const i=Number(t);i&&(r=(n=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:n[0])}return{value:r??"0",rest:r==="0"?"000":"",symbol:e}},getApiUrl(){return oe.W3M_API_URL},getBlockchainApiUrl(){return oe.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return oe.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,r;return typeof t=="string"?t:typeof((r=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:r.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const r={};return e&&t&&(t.forEach((n,i)=>{r[n]=i}),e.sort((n,i)=>{const s=r[n.id],o=r[i.id];return s!==void 0&&o!==void 0?s-o:s!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const r of t)e+=r.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[r,n]=e.split(".");return{dollars:r,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const r=new Set;return t.filter(n=>{const i=n[e];return r.has(i)?!1:(r.add(i),!0)})},generateSdkVersion(t,e,r){const n=t.length===0?mt.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${n}-${r}`},createAccount(t,e,r,n,i){return{namespace:t,address:e,type:r,publicKey:n,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),r=e[0];return e.filter(Boolean).length===3&&r in oe.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,r="state=";if(new URL(t).host==="auth.magic.link"){const n="provider_authorization_url=",i=t.substring(t.indexOf(n)+n.length),s=this.injectIntoUrl(decodeURIComponent(i),r,e);return t.replace(i,encodeURIComponent(s))}return this.injectIntoUrl(t,r,e)},injectIntoUrl(t,e,r){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",n),s=e.length,o=i!==-1?i:t.length,a=t.substring(0,n+s),c=t.substring(n+s,o),l=t.substring(i),u=c+r;return a+u+l}};async function ba(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class ad{constructor({baseUrl:e,clientId:r}){this.baseUrl=e,this.clientId=r}async get({headers:e,signal:r,cache:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"GET",headers:e,signal:r,cache:n})).json()}async getBlob({headers:e,signal:r,...n}){const i=this.createUrl(n);return(await ba(i,{method:"GET",headers:e,signal:r})).blob()}async post({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"POST",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"PUT",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"DELETE",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:r}){const n=new URL(e,this.baseUrl);return r&&Object.entries(r).forEach(([i,s])=>{s&&n.searchParams.append(i,s)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}}const kD={handleSolanaDeeplinkRedirect(t){if(N.state.activeChain===oe.CHAIN.SOLANA){const e=window.location.href,r=encodeURIComponent(e);if(t==="Phantom"&&!("phantom"in window)){const n=e.startsWith("https")?"https":"http",i=e.split("/")[2],s=encodeURIComponent(`${n}://${i}`);window.location.href=`https://phantom.app/ul/browse/${r}?ref=${s}`}t==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${r}`)}}},hr=Xe({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),sr={state:hr,subscribeNetworkImages(t){return zt(hr.networkImages,()=>t(hr.networkImages))},subscribeKey(t,e){return Gt(hr,t,e)},subscribe(t){return zt(hr,()=>t(hr))},setWalletImage(t,e){hr.walletImages[t]=e},setNetworkImage(t,e){hr.networkImages[t]=e},setChainImage(t,e){hr.chainImages[t]=e},setConnectorImage(t,e){hr.connectorImages={...hr.connectorImages,[t]:e}},setTokenImage(t,e){hr.tokenImages[t]=e},setCurrencyImage(t,e){hr.currencyImages[t]=e}},TD={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},up=Xe({networkImagePromises:{}}),vt={async fetchWalletImage(t){if(t)return await Q._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){return t?this.getNetworkImageById(t)||(up.networkImagePromises[t]||(up.networkImagePromises[t]=Q._fetchNetworkImage(t)),await up.networkImagePromises[t],this.getNetworkImageById(t)):void 0},getWalletImageById(t){if(t)return sr.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return sr.state.walletImages[t.image_id]},getNetworkImage(t){var e,r,n;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(r=t==null?void 0:t.assets)==null?void 0:r.imageUrl;if((n=t==null?void 0:t.assets)!=null&&n.imageId)return sr.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return sr.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return sr.state.connectorImages[t.imageId]},getChainImage(t){return sr.state.networkImages[TD[t]]}},RD={getFeatureValue(t,e){const r=e==null?void 0:e[t];return r===void 0?mt.DEFAULT_FEATURES[t]:r},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(Z.isTelegram()){if(Z.isIos())return t.filter(e=>e!=="google");if(Z.isMac())return t.filter(e=>e!=="x");if(Z.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},de=Xe({features:mt.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:{solana:"eoa",bip122:"payment",polkadot:"eoa",eip155:"smartAccount"},enableNetworkSwitch:!0}),H={state:de,subscribeKey(t,e){return Gt(de,t,e)},setOptions(t){Object.assign(de,t)},setFeatures(t){if(!t)return;de.features||(de.features=mt.DEFAULT_FEATURES);const e={...de.features,...t};de.features=e,de.features.socials&&(de.features.socials=RD.filterSocialsByPlatform(de.features.socials))},setProjectId(t){de.projectId=t},setCustomRpcUrls(t){de.customRpcUrls=t},setAllWallets(t){de.allWallets=t},setIncludeWalletIds(t){de.includeWalletIds=t},setExcludeWalletIds(t){de.excludeWalletIds=t},setFeaturedWalletIds(t){de.featuredWalletIds=t},setTokens(t){de.tokens=t},setTermsConditionsUrl(t){de.termsConditionsUrl=t},setPrivacyPolicyUrl(t){de.privacyPolicyUrl=t},setCustomWallets(t){de.customWallets=t},setIsSiweEnabled(t){de.isSiweEnabled=t},setIsUniversalProvider(t){de.isUniversalProvider=t},setSdkVersion(t){de.sdkVersion=t},setMetadata(t){de.metadata=t},setDisableAppend(t){de.disableAppend=t},setEIP6963Enabled(t){de.enableEIP6963=t},setDebug(t){de.debug=t},setEnableWalletConnect(t){de.enableWalletConnect=t},setEnableWalletGuide(t){de.enableWalletGuide=t},setEnableAuthLogger(t){de.enableAuthLogger=t},setEnableWallets(t){de.enableWallets=t},setHasMultipleAddresses(t){de.hasMultipleAddresses=t},setSIWX(t){de.siwx=t},setConnectMethodsOrder(t){de.features={...de.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){de.features={...de.features,walletFeaturesOrder:t}},setSocialsOrder(t){de.features={...de.features,socials:t}},setCollapseWallets(t){de.features={...de.features,collapseWallets:t}},setEnableEmbedded(t){de.enableEmbedded=t},setAllowUnsupportedChain(t){de.allowUnsupportedChain=t},setManualWCControl(t){de.manualWCControl=t},setEnableNetworkSwitch(t){de.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,r])=>{r&&(de.defaultAccountTypes[e]=r)})},setUniversalProviderConfigOverride(t){de.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return de.universalProviderConfigOverride},getSnapshot(){return xc(de)}},ni=Xe({message:"",variant:"info",open:!1}),vi={state:ni,subscribeKey(t,e){return Gt(ni,t,e)},open(t,e){const{debug:r}=H.state,{shortMessage:n,longMessage:i}=t;r&&(ni.message=n,ni.variant=e,ni.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){ni.open=!1,ni.message="",ni.variant="info"}},LD=Z.getAnalyticsUrl(),DD=new ad({baseUrl:LD,clientId:null}),BD=["MODAL_CREATED"],$n=Xe({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),be={state:$n,subscribe(t){return zt($n,()=>t($n))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=H.state;return{projectId:t,st:e,sv:r||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=ce.state.address;if(BD.includes(t.data.event)||typeof window>"u")return;await DD.post({path:"/e",params:be.getSdkProperties(),body:{eventId:Z.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),$n.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===oe.HTTP_STATUS_CODES.FORBIDDEN&&!$n.reportedErrors.FORBIDDEN&&(vi.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${Za()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),$n.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;$n.timestamp=Date.now(),$n.data=t,(e=H.state.features)!=null&&e.analytics&&be._sendAnalyticsEvent($n)}},MD=["1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79","fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa","a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393"],UD=Z.getApiUrl(),_r=new ad({baseUrl:UD,clientId:null}),jD=40,ov=4,zD=20,De=Xe({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),Q={state:De,subscribeKey(t,e){return Gt(De,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=H.state;return{projectId:t,st:e||"appkit",sv:r||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return H.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${_r.baseUrl}/getWalletImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setWalletImage(t,URL.createObjectURL(r))},async _fetchNetworkImage(t){const e=`${_r.baseUrl}/public/getAssetImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setNetworkImage(t,URL.createObjectURL(r))},async _fetchConnectorImage(t){const e=`${_r.baseUrl}/public/getAssetImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setConnectorImage(t,URL.createObjectURL(r))},async _fetchCurrencyImage(t){const e=`${_r.baseUrl}/public/getCurrencyImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setCurrencyImage(t,URL.createObjectURL(r))},async _fetchTokenImage(t){const e=`${_r.baseUrl}/public/getTokenImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setTokenImage(t,URL.createObjectURL(r))},async fetchNetworkImages(){var e;const t=(e=N.getAllRequestedCaipNetworks())==null?void 0:e.map(({assets:r})=>r==null?void 0:r.imageId).filter(Boolean).filter(r=>!vt.getNetworkImageById(r));t&&await Promise.allSettled(t.map(r=>Q._fetchNetworkImage(r)))},async fetchConnectorImages(){const{connectors:t}=ee.state,e=t.map(({imageId:r})=>r).filter(Boolean);await Promise.allSettled(e.map(r=>Q._fetchConnectorImage(r)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>Q._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>Q._fetchTokenImage(e)))},async fetchWallets(t){var r,n;const e=t.exclude??[];return Q._getSdkProperties().sv.startsWith("html-core-")&&e.push(...MD),await _r.get({path:"/getWallets",params:{...Q._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(r=t.include)==null?void 0:r.join(","),exclude:(n=t.exclude)==null?void 0:n.join(",")}})},async fetchFeaturedWallets(){const{featuredWalletIds:t}=H.state;if(t!=null&&t.length){const e={...Q._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??ov,include:t},{data:r}=await Q.fetchWallets(e);r.sort((i,s)=>t.indexOf(i.id)-t.indexOf(s.id));const n=r.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(n.map(i=>Q._fetchWalletImage(i))),De.featured=r,De.allFeatured=r}},async fetchRecommendedWallets(){try{De.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:r}=H.state,n=[...e??[],...r??[]].filter(Boolean),i=N.getRequestedCaipNetworkIds().join(","),s={page:1,entries:ov,include:t,exclude:n,chains:i},{data:o,count:a}=await Q.fetchWallets(s),c=se.getRecentWallets(),l=o.map(h=>h.image_id).filter(Boolean),u=c.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(h=>Q._fetchWalletImage(h))),De.recommended=o,De.allRecommended=o,De.count=a??0}catch{}finally{De.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:r,featuredWalletIds:n}=H.state,i=N.getRequestedCaipNetworkIds().join(","),s=[...De.recommended.map(({id:u})=>u),...r??[],...n??[]].filter(Boolean),o={page:t,entries:jD,include:e,exclude:s,chains:i},{data:a,count:c}=await Q.fetchWallets(o),l=a.slice(0,zD).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>Q._fetchWalletImage(u))),De.wallets=Z.uniqueBy([...De.wallets,...Q._filterOutExtensions(a)],"id"),De.count=c>De.count?c:De.count,De.page=t},async initializeExcludedWallets({ids:t}){const e=N.getRequestedCaipNetworkIds().join(","),r={page:1,entries:t.length,include:t,chains:e},{data:n}=await Q.fetchWallets(r);n&&n.forEach(i=>{De.excludedWallets.push({rdns:i.rdns,name:i.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:r,excludeWalletIds:n}=H.state,i=N.getRequestedCaipNetworkIds().join(",");De.search=[];const s={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:r,exclude:n,chains:i},{data:o}=await Q.fetchWallets(s);be.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>Q._fetchWalletImage(c)),Z.wait(300)]),De.search=Q._filterOutExtensions(o)},initPromise(t,e){return De.promises[t]||(De.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:r=!0,fetchNetworkImages:n=!0}={}){const i=[t&&Q.initPromise("connectorImages",Q.fetchConnectorImages),e&&Q.initPromise("featuredWallets",Q.fetchFeaturedWallets),r&&Q.initPromise("recommendedWallets",Q.fetchRecommendedWallets),n&&Q.initPromise("networkImages",Q.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=H.state.features)!=null&&t.analytics&&Q.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await _r.get({path:"/getAnalyticsConfig",params:Q._getSdkProperties()});H.setFeatures({analytics:t})}catch{H.setFeatures({analytics:!1})}},setFilterByNamespace(t){if(!t){De.featured=De.allFeatured,De.recommended=De.allRecommended;return}const e=N.getRequestedCaipNetworkIds().join(",");De.featured=De.allFeatured.filter(r=>{var n;return(n=r.chains)==null?void 0:n.some(i=>e.includes(i))}),De.recommended=De.allRecommended.filter(r=>{var n;return(n=r.chains)==null?void 0:n.some(i=>e.includes(i))})}},Te=Xe({view:"Connect",history:["Connect"],transactionStack:[]}),X={state:Te,subscribeKey(t,e){return Gt(Te,t,e)},pushTransactionStack(t){Te.transactionStack.push(t)},popTransactionStack(t){var r,n;const e=Te.transactionStack.pop();if(e)if(t)this.goBack(),(r=e==null?void 0:e.onCancel)==null||r.call(e);else{if(e.goBack)this.goBack();else if(e.replace){const i=Te.history.indexOf("ConnectingSiwe");i>0?this.goBackToIndex(i-1):($e.close(),Te.history=[])}else e.view&&this.reset(e.view);(n=e==null?void 0:e.onSuccess)==null||n.call(e)}},push(t,e){t!==Te.view&&(Te.view=t,Te.history.push(t),Te.data=e)},reset(t,e){Te.view=t,Te.history=[t],Te.data=e},replace(t,e){Te.history.at(-1)===t||(Te.view=t,Te.history[Te.history.length-1]=t,Te.data=e)},goBack(){var e;const t=!N.state.activeCaipAddress&&this.state.view==="ConnectingFarcaster";if(Te.history.length>1&&!Te.history.includes("UnsupportedChain")){Te.history.pop();const[r]=Te.history.slice(-1);r&&(Te.view=r)}else $e.close();(e=Te.data)!=null&&e.wallet&&(Te.data.wallet=void 0),setTimeout(()=>{var r,n,i;if(t){ce.setFarcasterUrl(void 0,N.state.activeChain);const s=ee.getAuthConnector();(r=s==null?void 0:s.provider)==null||r.reload();const o=xc(H.state);(i=(n=s==null?void 0:s.provider)==null?void 0:n.syncDappData)==null||i.call(n,{metadata:o.metadata,sdkVersion:o.sdkVersion,projectId:o.projectId,sdkType:o.sdkType})}},100)},goBackToIndex(t){if(Te.history.length>1){Te.history=Te.history.slice(0,t+1);const[e]=Te.history.slice(-1);e&&(Te.view=e)}}},Sn=Xe({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),gt={state:Sn,subscribe(t){return zt(Sn,()=>t(Sn))},setThemeMode(t){Sn.themeMode=t;try{const e=ee.getAuthConnector();if(e){const r=gt.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:r,w3mThemeVariables:gi(r,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){Sn.themeVariables={...Sn.themeVariables,...t};try{const e=ee.getAuthConnector();if(e){const r=gt.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:r,w3mThemeVariables:gi(Sn.themeVariables,Sn.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return xc(Sn)}},L5={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},Be=Xe({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...L5}}),ee={state:Be,subscribe(t){return zt(Be,()=>{t(Be)})},subscribeKey(t,e){return Gt(Be,t,e)},initialize(t){t.forEach(e=>{const r=se.getConnectedConnectorId(e);r&&this.setConnectorId(r,e)})},setActiveConnector(t){t&&(Be.activeConnector=vs(t))},setConnectors(t){t.filter(e=>!Be.allConnectors.some(r=>r.id===e.id&&this.getConnectorName(r.name)===this.getConnectorName(e.name)&&r.chain===e.chain)).forEach(e=>{e.type!=="MULTI_CHAIN"&&Be.allConnectors.push(vs(e))}),Be.connectors=this.mergeMultiChainConnectors(Be.allConnectors)},removeAdapter(t){Be.allConnectors=Be.allConnectors.filter(e=>e.chain!==t),Be.connectors=this.mergeMultiChainConnectors(Be.allConnectors)},mergeMultiChainConnectors(t){const e=this.generateConnectorMapByName(t),r=[];return e.forEach(n=>{const i=n[0],s=(i==null?void 0:i.id)===oe.CONNECTOR_ID.AUTH;n.length>1&&i?r.push({name:i.name,imageUrl:i.imageUrl,imageId:i.imageId,connectors:[...n],type:s?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(i==null?void 0:i.id)||""}):i&&r.push(i)}),r},generateConnectorMapByName(t){const e=new Map;return t.forEach(r=>{const{name:n}=r,i=this.getConnectorName(n);if(!i)return;const s=e.get(i)||[];s.find(o=>o.chain===r.chain)||s.push(r),e.set(i,s)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(r=>{e.find(n=>n.chain===r.chain)||e.push(r)}),e},addConnector(t){var e,r,n;if(t.id===oe.CONNECTOR_ID.AUTH){const i=t,s=xc(H.state),o=gt.getSnapshot().themeMode,a=gt.getSnapshot().themeVariables;(r=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||r.call(e,{metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),(n=i==null?void 0:i.provider)==null||n.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:gi(a,o)}),this.setConnectors([t])}else this.setConnectors([t])},getAuthConnector(t){var n;const e=t||N.state.activeChain,r=Be.connectors.find(i=>i.id===oe.CONNECTOR_ID.AUTH);if(r)return(n=r==null?void 0:r.connectors)!=null&&n.length?r.connectors.find(i=>i.chain===e):r},getAnnouncedConnectorRdns(){return Be.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return Be.allConnectors.find(e=>e.id===t)},getConnector(t,e){return Be.allConnectors.filter(r=>r.chain===N.state.activeChain).find(r=>{var n;return r.explorerId===t||((n=r.info)==null?void 0:n.rdns)===e})},syncIfAuthConnector(t){var s,o;if(t.id!=="ID_AUTH")return;const e=t,r=xc(H.state),n=gt.getSnapshot().themeMode,i=gt.getSnapshot().themeVariables;(o=(s=e==null?void 0:e.provider)==null?void 0:s.syncDappData)==null||o.call(s,{metadata:r.metadata,sdkVersion:r.sdkVersion,sdkType:r.sdkType,projectId:r.projectId}),e.provider.syncTheme({themeMode:n,themeVariables:i,w3mThemeVariables:gi(i,n)})},getConnectorsByNamespace(t){const e=Be.allConnectors.filter(r=>r.chain===t);return this.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=ee.getConnector(t.id,t.rdns);N.state.activeChain===oe.CHAIN.SOLANA&&kD.handleSolanaDeeplinkRedirect((e==null?void 0:e.name)||t.name||""),e?X.push("ConnectingExternal",{connector:e}):X.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?this.getConnectorsByNamespace(t):this.mergeMultiChainConnectors(Be.allConnectors)},setFilterByNamespace(t){Be.filterByNamespace=t,Be.connectors=this.getConnectors(t),Q.setFilterByNamespace(t)},setConnectorId(t,e){t&&(Be.activeConnectorIds={...Be.activeConnectorIds,[e]:t},se.setConnectedConnectorId(e,t))},removeConnectorId(t){Be.activeConnectorIds={...Be.activeConnectorIds,[t]:void 0},se.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return Be.activeConnectorIds[t]},isConnected(t){return t?!!Be.activeConnectorIds[t]:Object.values(Be.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){Be.activeConnectorIds={...L5}}};function Ul(t,e){return ee.getConnectorId(t)===e}function FD(t){const e=Array.from(N.state.chains.keys());let r=[];return t?(r.push([t,N.state.chains.get(t)]),Ul(t,oe.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(n=>{n!==t&&Ul(n,oe.CONNECTOR_ID.WALLET_CONNECT)&&r.push([n,N.state.chains.get(n)])}):Ul(t,oe.CONNECTOR_ID.AUTH)&&e.forEach(n=>{n!==t&&Ul(n,oe.CONNECTOR_ID.AUTH)&&r.push([n,N.state.chains.get(n)])})):r=Array.from(N.state.chains.entries()),r}const ui={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Zi=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),dt=Xe({...Zi}),Je={state:dt,subscribeKey(t,e){return Gt(dt,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=Z.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){dt.message=Zi.message,dt.variant=Zi.variant,dt.svg=Zi.svg,dt.open=Zi.open,dt.autoClose=Zi.autoClose},_showMessage({message:t,svg:e,variant:r="success",autoClose:n=Zi.autoClose}){dt.open?(dt.open=!1,setTimeout(()=>{dt.message=t,dt.variant=r,dt.svg=e,dt.open=!0,dt.autoClose=n},150)):(dt.message=t,dt.variant=r,dt.svg=e,dt.open=!0,dt.autoClose=n)}},yi={getSIWX(){return H.state.siwx},async initializeIfEnabled(){var s;const t=H.state.siwx,e=N.getActiveCaipAddress();if(!(t&&e))return;const[r,n,i]=e.split(":");if(N.checkIfSupportedNetwork(r))try{if((await t.getSessions(`${r}:${n}`,i)).length)return;await $e.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((s=ae._getClient())==null?void 0:s.disconnect().catch(console.error)),X.reset("Connect"),Je.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=H.state.siwx,e=Z.getPlainAddress(N.getActiveCaipAddress()),r=N.getActiveCaipNetwork(),n=ae._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!r)throw new Error("No ActiveCaipNetwork or client found");if(!n)throw new Error("No ConnectionController client found");try{const i=await t.createMessage({chainId:r.caipNetworkId,accountAddress:e}),s=i.toString();ee.getConnectorId(r.chainNamespace)===oe.CONNECTOR_ID.AUTH&&X.pushTransactionStack({view:null,goBack:!1,replace:!0});const o=await n.signMessage(s);await t.addSession({data:i,message:s,signature:o}),$e.close(),be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const s=this.getSIWXEventProperties();(!$e.state.open||X.state.view==="ApproveTransaction")&&await $e.open({view:"SIWXSignMessage"}),s.isSmartAccount?Je.showError("This application might not support Smart Accounts"):Je.showError("Signature declined"),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:s}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){var t,e;try{(e=(t=this.getSIWX())==null?void 0:t.getRequired)!=null&&e.call(t)?await ae.disconnect():$e.close(),X.reset("Connect"),be.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(r){console.error("SIWXUtil:cancelSignMessage",r)}},async getSessions(){const t=H.state.siwx,e=Z.getPlainAddress(N.getActiveCaipAddress()),r=N.getActiveCaipNetwork();return t&&e&&r?t.getSessions(r.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const r=X.state.view==="ApproveTransaction",n=X.state.view==="SIWXSignMessage";if(r||n)return((e=t.getRequired)==null?void 0:e.call(t))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:r}){var a,c,l;const n=yi.getSIWX(),i=new Set(e.map(u=>u.split(":")[0]));if(!n||i.size!==1||!i.has("eip155"))return!1;const s=await n.createMessage({chainId:((a=N.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await t.authenticate({nonce:s.nonce,domain:s.domain,uri:s.uri,exp:s.expirationTime,iat:s.issuedAt,nbf:s.notBefore,requestId:s.requestId,version:s.version,resources:s.resources,statement:s.statement,chainId:s.chainId,methods:r,chains:[s.chainId,...e.filter(u=>u!==s.chainId)]});if(Je.showLoading("Authenticating...",{autoClose:!1}),ce.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(i)[0]),(l=o==null?void 0:o.auths)==null?void 0:l.length){const u=o.auths.map(h=>{const d=t.client.formatAuthMessage({request:h.p,iss:h.p.iss});return{data:{...h.p,accountAddress:h.p.iss.split(":").slice(-1).join(""),chainId:h.p.iss.split(":").slice(2,4).join(":"),uri:h.p.aud,version:h.p.version||s.version,expirationTime:h.p.exp,issuedAt:h.p.iat,notBefore:h.p.nbf},message:d,signature:h.s.s,cacao:h}});try{await n.setSessions(u),be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:yi.getSIWXEventProperties()})}catch(h){throw console.error("SIWX:universalProviderAuth - failed to set sessions",h),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:yi.getSIWXEventProperties()}),await t.disconnect().catch(console.error),h}finally{Je.hide()}}return!0},getSIWXEventProperties(){var e,r;const t=N.state.activeChain;return{network:((e=N.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((r=ce.state.preferredAccountTypes)==null?void 0:r[t])===ui.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}},et=Xe({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),HD={state:et,subscribe(t){return zt(et,()=>t(et))},setLastNetworkInView(t){et.lastNetworkInView=t},async fetchTransactions(t,e){var r,n;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");et.loading=!0;try{const i=await pe.fetchTransactions({account:t,cursor:et.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(r=N.state.activeCaipNetwork)==null?void 0:r.caipNetworkId}),s=this.filterSpamTransactions(i.data),o=this.filterByConnectedChain(s),a=[...et.transactions,...o];et.loading=!1,e==="coinbase"?et.coinbaseTransactions=this.groupTransactionsByYearAndMonth(et.coinbaseTransactions,i.data):(et.transactions=a,et.transactionsByYear=this.groupTransactionsByYearAndMonth(et.transactionsByYear,o)),et.empty=a.length===0,et.next=i.next?i.next:void 0}catch{const i=N.state.activeChain;be.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:H.state.projectId,cursor:et.next,isSmartAccount:((n=ce.state.preferredAccountTypes)==null?void 0:n[i])===ui.ACCOUNT_TYPES.SMART_ACCOUNT}}),Je.showError("Failed to fetch transactions"),et.loading=!1,et.empty=!0,et.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const r=t;return e.forEach(n=>{const i=new Date(n.metadata.minedAt).getFullYear(),s=new Date(n.metadata.minedAt).getMonth(),o=r[i]??{},a=(o[s]??[]).filter(c=>c.id!==n.id);r[i]={...o,[s]:[...a,n].sort((c,l)=>new Date(l.metadata.minedAt).getTime()-new Date(c.metadata.minedAt).getTime())}}),r},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var n;return((n=r.nft_info)==null?void 0:n.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=N.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(n=>n.metadata.chain===e)},clearCursor(){et.next=void 0},resetTransactions(){et.transactions=[],et.transactionsByYear={},et.lastNetworkInView=void 0,et.loading=!1,et.empty=!1,et.next=void 0}},tt=Xe({wcError:!1,buffering:!1,status:"disconnected"});let Ys;const ae={state:tt,subscribeKey(t,e){return Gt(tt,t,e)},_getClient(){return tt._client},setClient(t){tt._client=vs(t)},async connectWalletConnect(){var t,e,r,n;if(Z.isTelegram()||Z.isSafari()&&Z.isIos()){if(Ys){await Ys,Ys=void 0;return}if(!Z.isPairingExpired(tt==null?void 0:tt.wcPairingExpiry)){const i=tt.wcUri;tt.wcUri=i;return}Ys=(e=(t=this._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),this.state.status="connecting",await Ys,Ys=void 0,tt.wcPairingExpiry=void 0,this.state.status="connected"}else await((n=(r=this._getClient())==null?void 0:r.connectWalletConnect)==null?void 0:n.call(r))},async connectExternal(t,e,r=!0){var n,i;await((i=(n=this._getClient())==null?void 0:n.connectExternal)==null?void 0:i.call(n,t)),r&&N.setActiveNamespace(e)},async reconnectExternal(t){var r,n;await((n=(r=this._getClient())==null?void 0:r.reconnectExternal)==null?void 0:n.call(r,t));const e=t.chain||N.state.activeChain;e&&ee.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var n;$e.setLoading(!0,N.state.activeChain);const r=ee.getAuthConnector();r&&(ce.setPreferredAccountType(t,e),await r.provider.setPreferredAccount(t),se.setPreferredAccountTypes(ce.state.preferredAccountTypes??{[e]:t}),await this.reconnectExternal(r),$e.setLoading(!1,N.state.activeChain),be.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((n=N.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=this._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var r;return(r=this._getClient())==null?void 0:r.parseUnits(t,e)},formatUnits(t,e){var r;return(r=this._getClient())==null?void 0:r.formatUnits(t,e)},async sendTransaction(t){var e;return(e=this._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=this._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=this._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=this._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=this._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=this._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=this._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=this._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,r;return((r=(e=this._getClient())==null?void 0:e.checkInstalled)==null?void 0:r.call(e,t))||!1},resetWcConnection(){tt.wcUri=void 0,tt.wcPairingExpiry=void 0,tt.wcLinking=void 0,tt.recentWallet=void 0,tt.status="disconnected",HD.resetTransactions(),se.deleteWalletConnectDeepLink()},resetUri(){tt.wcUri=void 0,tt.wcPairingExpiry=void 0},finalizeWcConnection(){var r,n;const{wcLinking:t,recentWallet:e}=ae.state;t&&se.setWalletConnectDeepLink(t),e&&se.setAppKitRecent(e),be.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((n=(r=X.state.data)==null?void 0:r.wallet)==null?void 0:n.name)||"Unknown"}})},setWcBasic(t){tt.wcBasic=t},setUri(t){tt.wcUri=t,tt.wcPairingExpiry=Z.getPairingExpiry()},setWcLinking(t){tt.wcLinking=t},setWcError(t){tt.wcError=t,tt.buffering=!1},setRecentWallet(t){tt.recentWallet=t},setBuffering(t){tt.buffering=t},setStatus(t){tt.status=t},async disconnect(t){try{$e.setLoading(!0,t),await yi.clearSessions(),await N.disconnect(t),$e.setLoading(!1,t),ee.setFilterByNamespace(void 0)}catch{throw new Error("Failed to disconnect")}}},Js=Xe({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Vn={state:Js,subscribe(t){return zt(Js,()=>t(Js))},subscribeOpen(t){return Gt(Js,"open",t)},set(t){Object.assign(Js,{...Js,...t})}};function dl(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Mo(t){return dl(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const D5="2.27.0";let Ca={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${D5}`};class Ie extends Error{constructor(e,r={}){var a,c;const n=r.cause instanceof Ie?r.cause.details:(a=r.cause)!=null&&a.message?r.cause.message:r.details,i=r.cause instanceof Ie&&r.cause.docsPath||r.docsPath,s=(c=Ca.getDocsUrl)==null?void 0:c.call(Ca,{...r,docsPath:i}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Ca.version?[`Version: ${Ca.version}`]:[]].join(`
|
|
39
|
+
`)===0?_.substr(1,_.length):_}).forEach(function(_){var O=_.split(":"),R=O.shift().trim();if(R){var U=O.join(":").trim();try{y.append(R,U)}catch(j){console.warn("Response "+j.message)}}}),y}S.call(I.prototype);function M(m,y){if(!(this instanceof M))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(y||(y={}),this.type="default",this.status=y.status===void 0?200:y.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=y.statusText===void 0?"":""+y.statusText,this.headers=new g(y.headers),this.url=y.url||"",this._initBody(m)}S.call(M.prototype),M.prototype.clone=function(){return new M(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new g(this.headers),url:this.url})},M.error=function(){var m=new M(null,{status:200,statusText:""});return m.ok=!1,m.status=0,m.type="error",m};var W=[301,302,303,307,308];M.redirect=function(m,y){if(W.indexOf(y)===-1)throw new RangeError("Invalid status code");return new M(null,{status:y,headers:{location:m}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(y,x){this.message=y,this.name=x;var _=Error(y);this.stack=_.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function $(m,y){return new Promise(function(x,_){var O=new I(m,y);if(O.signal&&O.signal.aborted)return _(new o.DOMException("Aborted","AbortError"));var R=new XMLHttpRequest;function U(){R.abort()}R.onload=function(){var z={statusText:R.statusText,headers:D(R.getAllResponseHeaders()||"")};O.url.indexOf("file://")===0&&(R.status<200||R.status>599)?z.status=200:z.status=R.status,z.url="responseURL"in R?R.responseURL:z.headers.get("X-Request-URL");var te="response"in R?R.response:R.responseText;setTimeout(function(){x(new M(te,z))},0)},R.onerror=function(){setTimeout(function(){_(new TypeError("Network request failed"))},0)},R.ontimeout=function(){setTimeout(function(){_(new TypeError("Network request timed out"))},0)},R.onabort=function(){setTimeout(function(){_(new o.DOMException("Aborted","AbortError"))},0)};function j(z){try{return z===""&&a.location.href?a.location.href:z}catch{return z}}if(R.open(O.method,j(O.url),!0),O.credentials==="include"?R.withCredentials=!0:O.credentials==="omit"&&(R.withCredentials=!1),"responseType"in R&&(c.blob?R.responseType="blob":c.arrayBuffer&&(R.responseType="arraybuffer")),y&&typeof y.headers=="object"&&!(y.headers instanceof g||a.Headers&&y.headers instanceof a.Headers)){var V=[];Object.getOwnPropertyNames(y.headers).forEach(function(z){V.push(d(z)),R.setRequestHeader(z,p(y.headers[z]))}),O.headers.forEach(function(z,te){V.indexOf(te)===-1&&R.setRequestHeader(te,z)})}else O.headers.forEach(function(z,te){R.setRequestHeader(te,z)});O.signal&&(O.signal.addEventListener("abort",U),R.onreadystatechange=function(){R.readyState===4&&O.signal.removeEventListener("abort",U)}),R.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return $.polyfill=!0,a.fetch||(a.fetch=$,a.Headers=g,a.Request=I,a.Response=M),o.Headers=g,o.Request=I,o.Response=M,o.fetch=$,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=r.fetch?r:n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(p0,p0.exports);var uR=p0.exports;const Tm=Jc(uR);var hR=Object.defineProperty,dR=Object.defineProperties,pR=Object.getOwnPropertyDescriptors,Rm=Object.getOwnPropertySymbols,fR=Object.prototype.hasOwnProperty,gR=Object.prototype.propertyIsEnumerable,Lm=(t,e,r)=>e in t?hR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dm=(t,e)=>{for(var r in e||(e={}))fR.call(e,r)&&Lm(t,r,e[r]);if(Rm)for(var r of Rm(e))gR.call(e,r)&&Lm(t,r,e[r]);return t},Bm=(t,e)=>dR(t,pR(e));const wR={Accept:"application/json","Content-Type":"application/json"},mR="POST",Mm={headers:wR,method:mR},Um=10;let Xr=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new lR.EventEmitter,this.isAvailable=!1,this.registering=!1,!Zw(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Gn(e),n=await(await Tm(this.url,Bm(Dm({},Mm),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!Zw(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Gn({id:1,jsonrpc:"2.0",method:"test",params:[]});await Tm(e,Bm(Dm({},Mm),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);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(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?fs(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Yh(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return f3(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Um&&this.events.setMaxListeners(Um)}};var g1={exports:{}},So=typeof Reflect=="object"?Reflect:null,jm=So&&typeof So.apply=="function"?So.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},th;So&&typeof So.ownKeys=="function"?th=So.ownKeys:Object.getOwnPropertySymbols?th=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:th=function(e){return Object.getOwnPropertyNames(e)};function vR(t){console&&console.warn&&console.warn(t)}var u5=Number.isNaN||function(e){return e!==e};function Ge(){Ge.init.call(this)}g1.exports=Ge;g1.exports.once=ER;Ge.EventEmitter=Ge;Ge.prototype._events=void 0;Ge.prototype._eventsCount=0;Ge.prototype._maxListeners=void 0;var zm=10;function nd(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ge,"defaultMaxListeners",{enumerable:!0,get:function(){return zm},set:function(t){if(typeof t!="number"||t<0||u5(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");zm=t}});Ge.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ge.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||u5(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function h5(t){return t._maxListeners===void 0?Ge.defaultMaxListeners:t._maxListeners}Ge.prototype.getMaxListeners=function(){return h5(this)};Ge.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")jm(c,this,r);else for(var l=c.length,u=w5(c,l),n=0;n<l;++n)jm(u[n],this,r);return!0};function d5(t,e,r,n){var i,s,o;if(nd(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=h5(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,vR(a)}return t}Ge.prototype.addListener=function(e,r){return d5(this,e,r,!1)};Ge.prototype.on=Ge.prototype.addListener;Ge.prototype.prependListener=function(e,r){return d5(this,e,r,!0)};function yR(){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 p5(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=yR.bind(n);return i.listener=r,n.wrapFn=i,i}Ge.prototype.once=function(e,r){return nd(r),this.on(e,p5(this,e,r)),this};Ge.prototype.prependOnceListener=function(e,r){return nd(r),this.prependListener(e,p5(this,e,r)),this};Ge.prototype.removeListener=function(e,r){var n,i,s,o,a;if(nd(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():bR(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Ge.prototype.off=Ge.prototype.removeListener;Ge.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function f5(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?CR(i):w5(i,i.length)}Ge.prototype.listeners=function(e){return f5(this,e,!0)};Ge.prototype.rawListeners=function(e){return f5(this,e,!1)};Ge.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):g5.call(t,e)};Ge.prototype.listenerCount=g5;function g5(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ge.prototype.eventNames=function(){return this._eventsCount>0?th(this._events):[]};function w5(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function bR(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function CR(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ER(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}m5(t,e,s,{once:!0}),e!=="error"&&xR(t,i,{once:!0})})}function xR(t,e,r){typeof t.on=="function"&&m5(t,"error",e,r)}function m5(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var _R=g1.exports;const IR=Jc(_R),Fm="error",AR="wss://relay.walletconnect.org",$R="wc",SR="universal_provider",Tl=`${$R}@2:${SR}:`,v5="https://rpc.walletconnect.org/v1/",ao="generic",NR=`${v5}bundler`,Br={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function OR(){}function w1(t){return t==null||typeof t!="object"&&typeof t!="function"}function m1(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function PR(t){if(w1(t))return t;if(Array.isArray(t)||m1(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),r=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new r(t);if(t instanceof RegExp){const n=new r(t);return n.lastIndex=t.lastIndex,n}if(t instanceof DataView)return new r(t.buffer.slice(0));if(t instanceof Error){const n=new r(t.message);return n.stack=t.stack,n.name=t.name,n.cause=t.cause,n}if(typeof File<"u"&&t instanceof File)return new r([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const n=Object.create(e);return Object.assign(n,t)}return t}function Hm(t){return typeof t=="object"&&t!==null}function y5(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function b5(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const kR="[object RegExp]",C5="[object String]",E5="[object Number]",x5="[object Boolean]",_5="[object Arguments]",TR="[object Symbol]",RR="[object Date]",LR="[object Map]",DR="[object Set]",BR="[object Array]",MR="[object ArrayBuffer]",UR="[object Object]",jR="[object DataView]",zR="[object Uint8Array]",FR="[object Uint8ClampedArray]",HR="[object Uint16Array]",qR="[object Uint32Array]",WR="[object Int8Array]",VR="[object Int16Array]",KR="[object Int32Array]",GR="[object Float32Array]",ZR="[object Float64Array]";function YR(t,e){return mo(t,void 0,t,new Map,e)}function mo(t,e,r,n=new Map,i=void 0){const s=i==null?void 0:i(t,e,r,n);if(s!=null)return s;if(w1(t))return t;if(n.has(t))return n.get(t);if(Array.isArray(t)){const o=new Array(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=mo(t[a],a,r,n,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;n.set(t,o);for(const[a,c]of t)o.set(a,mo(c,a,r,n,i));return o}if(t instanceof Set){const o=new Set;n.set(t,o);for(const a of t)o.add(mo(a,void 0,r,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(m1(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=mo(t[a],a,r,n,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return n.set(t,o),Qi(o,t,r,n,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return n.set(t,o),Qi(o,t,r,n,i),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return n.set(t,o),Qi(o,t,r,n,i),o}if(t instanceof Error){const o=new t.constructor;return n.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Qi(o,t,r,n,i),o}if(typeof t=="object"&&JR(t)){const o=Object.create(Object.getPrototypeOf(t));return n.set(t,o),Qi(o,t,r,n,i),o}return t}function Qi(t,e,r=t,n,i){const s=[...Object.keys(e),...y5(e)];for(let o=0;o<s.length;o++){const a=s[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=mo(e[a],a,r,n,i))}}function JR(t){switch(b5(t)){case _5:case BR:case MR:case jR:case x5:case RR:case GR:case ZR:case WR:case VR:case KR:case LR:case E5:case UR:case kR:case DR:case C5:case TR:case zR:case FR:case HR:case qR:return!0;default:return!1}}function XR(t,e){return YR(t,(r,n,i,s)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case E5:case C5:case x5:{const o=new t.constructor(t==null?void 0:t.valueOf());return Qi(o,t),o}case _5:{const o={};return Qi(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function qm(t){return XR(t)}function Wm(t){return t!==null&&typeof t=="object"&&b5(t)==="[object Arguments]"}function QR(t){return m1(t)}function eL(t){var r;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const n=t[Symbol.toStringTag];return n==null||!((r=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&r.writable)?!1:t.toString()===`[object ${n}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function tL(t,...e){const r=e.slice(0,-1),n=e[e.length-1];let i=t;for(let s=0;s<r.length;s++){const o=r[s];i=f0(i,o,n,new Map)}return i}function f0(t,e,r,n){if(w1(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(n.has(e))return PR(n.get(e));if(n.set(e,t),Array.isArray(e)){e=e.slice();for(let s=0;s<e.length;s++)e[s]=e[s]??void 0}const i=[...Object.keys(e),...y5(e)];for(let s=0;s<i.length;s++){const o=i[s];let a=e[o],c=t[o];if(Wm(a)&&(a={...a}),Wm(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=qm(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],h=Reflect.ownKeys(c);for(let d=0;d<h.length;d++){const p=h[d];u[p]=c[p]}c=u}else c=[];const l=r(c,a,o,t,e,n);l!=null?t[o]=l:Array.isArray(a)||Hm(c)&&Hm(a)?t[o]=f0(c,a,r,n):c==null&&eL(a)?t[o]=f0({},a,r,n):c==null&&QR(a)?t[o]=qm(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function rL(t,...e){return tL(t,...e,OR)}var nL=Object.defineProperty,iL=Object.defineProperties,sL=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertySymbols,oL=Object.prototype.hasOwnProperty,aL=Object.prototype.propertyIsEnumerable,Km=(t,e,r)=>e in t?nL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rl=(t,e)=>{for(var r in e||(e={}))oL.call(e,r)&&Km(t,r,e[r]);if(Vm)for(var r of Vm(e))aL.call(e,r)&&Km(t,r,e[r]);return t},cL=(t,e)=>iL(t,sL(e));function br(t,e,r){var n;const i=bo(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${v5}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function Ss(t){return t.includes(":")?t.split(":")[1]:t}function I5(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function lL(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function np(t={},e={}){const r=Gm(t),n=Gm(e);return rL(r,n)}function Gm(t){var e,r,n,i;const s={};if(!yc(t))return s;for(const[o,a]of Object.entries(t)){const c=n1(o)?[o]:a.chains,l=a.methods||[],u=a.events||[],h=a.rpcMap||{},d=Ka(o);s[d]=cL(Rl(Rl({},s[d]),a),{chains:zu(c,(e=s[d])==null?void 0:e.chains),methods:zu(l,(r=s[d])==null?void 0:r.methods),events:zu(u,(n=s[d])==null?void 0:n.events),rpcMap:Rl(Rl({},h),(i=s[d])==null?void 0:i.rpcMap)})}return s}function Zm(t){return t.includes(":")?t.split(":")[2]:t}function Ym(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=n1(r)?[r]:n.chains?n.chains:I5(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function ip(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const A5={},Pe=t=>A5[t],sp=(t,e)=>{A5[t]=e};var uL=Object.defineProperty,hL=(t,e,r)=>e in t?uL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Us=(t,e,r)=>hL(t,typeof e!="symbol"?e+"":e,r);let dL=class{constructor(e){Us(this,"name","polkadot"),Us(this,"client"),Us(this,"httpProviders"),Us(this,"events"),Us(this,"namespace"),Us(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var pL=Object.defineProperty,fL=Object.defineProperties,gL=Object.getOwnPropertyDescriptors,Jm=Object.getOwnPropertySymbols,wL=Object.prototype.hasOwnProperty,mL=Object.prototype.propertyIsEnumerable,g0=(t,e,r)=>e in t?pL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xm=(t,e)=>{for(var r in e||(e={}))wL.call(e,r)&&g0(t,r,e[r]);if(Jm)for(var r of Jm(e))mL.call(e,r)&&g0(t,r,e[r]);return t},Qm=(t,e)=>fL(t,gL(e)),js=(t,e,r)=>g0(t,typeof e!="symbol"?e+"":e,r);let vL=class{constructor(e){js(this,"name","eip155"),js(this,"client"),js(this,"chainId"),js(this,"namespace"),js(this,"httpProviders"),js(this,"events"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const n=r||br(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(Ss(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Qm(Xm({},o.sessionProperties||{}),{capabilities:Qm(Xm({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fi("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${NR}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}};var yL=Object.defineProperty,bL=(t,e,r)=>e in t?yL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zs=(t,e,r)=>bL(t,typeof e!="symbol"?e+"":e,r);let CL=class{constructor(e){zs(this,"name","solana"),zs(this,"client"),zs(this,"httpProviders"),zs(this,"events"),zs(this,"namespace"),zs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var EL=Object.defineProperty,xL=(t,e,r)=>e in t?EL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fs=(t,e,r)=>xL(t,typeof e!="symbol"?e+"":e,r);let _L=class{constructor(e){Fs(this,"name","cosmos"),Fs(this,"client"),Fs(this,"httpProviders"),Fs(this,"events"),Fs(this,"namespace"),Fs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var IL=Object.defineProperty,AL=(t,e,r)=>e in t?IL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e,r)=>AL(t,typeof e!="symbol"?e+"":e,r);let $L=class{constructor(e){Hs(this,"name","algorand"),Hs(this,"client"),Hs(this,"httpProviders"),Hs(this,"events"),Hs(this,"namespace"),Hs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Dr(new Xr(n,Pe("disableProviderPing")))}};var SL=Object.defineProperty,NL=(t,e,r)=>e in t?SL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qs=(t,e,r)=>NL(t,typeof e!="symbol"?e+"":e,r);class OL{constructor(e){qs(this,"name","cip34"),qs(this,"client"),qs(this,"httpProviders"),qs(this,"events"),qs(this,"namespace"),qs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=Ss(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}}var PL=Object.defineProperty,kL=(t,e,r)=>e in t?PL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ws=(t,e,r)=>kL(t,typeof e!="symbol"?e+"":e,r);class TL{constructor(e){Ws(this,"name","elrond"),Ws(this,"client"),Ws(this,"httpProviders"),Ws(this,"events"),Ws(this,"namespace"),Ws(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}}var RL=Object.defineProperty,LL=(t,e,r)=>e in t?RL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vs=(t,e,r)=>LL(t,typeof e!="symbol"?e+"":e,r);let DL=class{constructor(e){Vs(this,"name","multiversx"),Vs(this,"client"),Vs(this,"httpProviders"),Vs(this,"events"),Vs(this,"namespace"),Vs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Ss(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var BL=Object.defineProperty,ML=(t,e,r)=>e in t?BL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e,r)=>ML(t,typeof e!="symbol"?e+"":e,r);let UL=class{constructor(e){Ks(this,"name","near"),Ks(this,"client"),Ks(this,"httpProviders"),Ks(this,"events"),Ks(this,"namespace"),Ks(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace);return typeof n>"u"?void 0:new Dr(new Xr(n,Pe("disableProviderPing")))}};var jL=Object.defineProperty,zL=(t,e,r)=>e in t?jL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gs=(t,e,r)=>zL(t,typeof e!="symbol"?e+"":e,r);let FL=class{constructor(e){Gs(this,"name","tezos"),Gs(this,"client"),Gs(this,"httpProviders"),Gs(this,"events"),Gs(this,"namespace"),Gs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||br(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace);return typeof n>"u"?void 0:new Dr(new Xr(n))}};var HL=Object.defineProperty,qL=(t,e,r)=>e in t?HL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zs=(t,e,r)=>qL(t,typeof e!="symbol"?e+"":e,r);let WL=class{constructor(e){Zs(this,"name",ao),Zs(this,"client"),Zs(this,"httpProviders"),Zs(this,"events"),Zs(this,"namespace"),Zs(this,"chainId"),this.namespace=e.namespace,this.events=Pe("events"),this.client=Pe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Br.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=bo(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||br(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Dr(new Xr(n,Pe("disableProviderPing")))}};var VL=Object.defineProperty,KL=Object.defineProperties,GL=Object.getOwnPropertyDescriptors,ev=Object.getOwnPropertySymbols,ZL=Object.prototype.hasOwnProperty,YL=Object.prototype.propertyIsEnumerable,w0=(t,e,r)=>e in t?VL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ll=(t,e)=>{for(var r in e||(e={}))ZL.call(e,r)&&w0(t,r,e[r]);if(ev)for(var r of ev(e))YL.call(e,r)&&w0(t,r,e[r]);return t},op=(t,e)=>KL(t,GL(e)),xr=(t,e,r)=>w0(t,typeof e!="symbol"?e+"":e,r);class id{constructor(e){xr(this,"client"),xr(this,"namespaces"),xr(this,"optionalNamespaces"),xr(this,"sessionProperties"),xr(this,"scopedProperties"),xr(this,"events",new IR),xr(this,"rpcProviders",{}),xr(this,"session"),xr(this,"providerOpts"),xr(this,"logger"),xr(this,"uri"),xr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:ll(Vh({level:(e==null?void 0:e.logger)||Fm})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new id(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ll({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,Zh(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Ue("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=Ym(this.session.namespaces);this.namespaces=np(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){const{uri:r,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});r&&(this.uri=r,this.events.emit("display_uri",r));const i=await n();this.session=i;const s=Ym(i.namespaces);return this.namespaces=np(this.namespaces,s),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===ao?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Yr(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,r;if(this.client=this.providerOpts.client||await rR.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Fm,relayUrl:this.providerOpts.relayUrl||AR,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(n){throw this.logger.error("Failed to get session",n),new Error(`The provided session: ${(r=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:r.topic} doesn't exist in the Sign client`)}else{const n=this.client.session.getAll();this.session=n[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>Ka(r)))];sp("client",this.client),sp("events",this.events),sp("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=lL(r,this.session),i=I5(n),s=np(this.namespaces,this.optionalNamespaces),o=op(Ll({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new vL({namespace:o});break;case"algorand":this.rpcProviders[r]=new $L({namespace:o});break;case"solana":this.rpcProviders[r]=new CL({namespace:o});break;case"cosmos":this.rpcProviders[r]=new _L({namespace:o});break;case"polkadot":this.rpcProviders[r]=new dL({namespace:o});break;case"cip34":this.rpcProviders[r]=new OL({namespace:o});break;case"elrond":this.rpcProviders[r]=new TL({namespace:o});break;case"multiversx":this.rpcProviders[r]=new DL({namespace:o});break;case"near":this.rpcProviders[r]=new UL({namespace:o});break;case"tezos":this.rpcProviders[r]=new FL({namespace:o});break;default:this.rpcProviders[ao]?this.rpcProviders[ao].updateNamespace(o):this.rpcProviders[ao]=new WL({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var r;const{topic:n}=e;n===((r=this.session)==null?void 0:r.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:n,topic:i}=e;if(i!==((r=this.session)==null?void 0:r.topic))return;const{event:s}=n;if(s.name==="accountsChanged"){const o=s.data;o&&Yr(o)&&this.events.emit("accountsChanged",o.map(Zm))}else if(s.name==="chainChanged"){const o=n.chainId,a=n.event.data,c=Ka(o),l=ip(o)!==ip(a)?`${c}:${ip(a)}`:o;this.onChainChanged(l)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n,i;if(e!==((n=this.session)==null?void 0:n.topic))return;const{namespaces:s}=r,o=(i=this.client)==null?void 0:i.session.get(e);this.session=op(Ll({},o),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{var r;e.topic===((r=this.session)==null?void 0:r.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",op(Ll({},Ue("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Br.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[ao]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i,scopedProperties:s}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.scopedProperties=s}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>Ka(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=Ka(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(n,i),this.events.emit("chainChanged",i);const s=this.getProvider(n).getDefaultChain();r||this.getProvider(n).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:n,previousChainId:s,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:r,newChainId:n}){var i,s;try{if(r===n)return;const o=(s=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:s.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${n}:`)).map(Zm);if(!Yr(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,r){if(!this.namespaces)return;const n=this.namespaces[e]?e:`${e}:${r}`,i={chains:[],methods:[],events:[],defaultChain:r};this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=r):this.namespaces[n]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var n;const i=((n=this.session)==null?void 0:n.topic)||"";await this.client.core.storage.setItem(`${Tl}/${e}${i}`,r)}async getFromStore(e){var r;const n=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${Tl}/${e}${n}`)}async deleteFromStore(e){var r;const n=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${Tl}/${e}${n}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const r=await this.client.core.storage.getKeys();for(const n of r)n.startsWith(Tl)&&await this.client.core.storage.removeItem(n)}catch(r){this.logger.warn("Failed to cleanup storage",r)}}}const JL=id;var fh={VITE_BASE_URL:"https://cdn.decentraland.org/@dcl/jump-site/0.2.1",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm",VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",BASE_URL:"https://cdn.decentraland.org/@dcl/jump-site/0.2.1",MODE:"production",DEV:!1,PROD:!0,SSR:!1},gh={VITE_SEGMENT_DEV_API_KEY:"UJLmm39XefLTcE55pRdWiwBT1JoTs6OI",VITE_SEGMENT_PRD_API_KEY:"uMHQo9dBTi626Bv11I3RxcH3Jui8lKMm"};const XL="wc",QL="ethereum_provider",eD=`${XL}@2:${QL}:`,tD="https://rpc.walletconnect.org/v1/",wh=["eth_sendTransaction","personal_sign"],$5=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],mh=["chainChanged","accountsChanged"],S5=["chainChanged","accountsChanged","message","disconnect","connect"];var rD=Object.defineProperty,nD=Object.defineProperties,iD=Object.getOwnPropertyDescriptors,tv=Object.getOwnPropertySymbols,sD=Object.prototype.hasOwnProperty,oD=Object.prototype.propertyIsEnumerable,m0=(t,e,r)=>e in t?rD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gi=(t,e)=>{for(var r in e||(e={}))sD.call(e,r)&&m0(t,r,e[r]);if(tv)for(var r of tv(e))oD.call(e,r)&&m0(t,r,e[r]);return t},va=(t,e)=>nD(t,iD(e)),ur=(t,e,r)=>m0(t,typeof e!="symbol"?e+"":e,r);function vh(t){return Number(t[0].split(":")[1])}function Dl(t){return`0x${t.toString(16)}`}function aD(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!Yr(e))throw new Error("Invalid chains");const c={chains:e,methods:n||wh,events:s||mh,rpcMap:Gi({},e.length?{[vh(e)]:a[vh(e)]}:{})},l=s==null?void 0:s.filter(p=>!mh.includes(p)),u=n==null?void 0:n.filter(p=>!wh.includes(p));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(u!=null&&u.length))return{required:e.length?c:void 0};const h=(l==null?void 0:l.length)&&(u==null?void 0:u.length)||!r,d={chains:[...new Set(h?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:$5))],events:[...new Set(c.events.concat(o!=null&&o.length?o:S5))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?d:void 0}}class sd{constructor(){ur(this,"events",new $6.EventEmitter),ur(this,"namespace","eip155"),ur(this,"accounts",[]),ur(this,"signer"),ur(this,"chainId",1),ur(this,"modal"),ur(this,"rpc"),ur(this,"STORAGE_KEY",eD),ur(this,"on",(e,r)=>(this.events.on(e,r),this)),ur(this,"once",(e,r)=>(this.events.once(e,r),this)),ur(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),ur(this,"off",(e,r)=>(this.events.off(e,r),this)),ur(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new sd;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),n)}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(e){var r;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:n,optional:i}=aD(this.rpc);try{const s=await new Promise(async(a,c)=>{var l,u;this.rpc.showQrModal&&((l=this.modal)==null||l.open(),(u=this.modal)==null||u.subscribeState(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const h=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(va(Gi({namespaces:Gi({},n&&{[this.namespace]:n})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic,scopedProperties:h})).then(d=>{a(d)}).catch(d=>{var p;(p=this.modal)==null||p.showErrorMessage("Unable to connect"),c(new Error(d.message))})});if(!s)return;const o=Bg(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Dl(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{(r=this.modal)==null||r.close()}}async authenticate(e,r){var n;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(o,a)=>{var c,l;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(l=this.modal)==null||l.subscribeState(u=>{!u.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(va(Gi({},e),{chains:this.rpc.chains}),r).then(u=>{o(u)}).catch(u=>{var h;(h=this.modal)==null||h.showErrorMessage("Unable to connect"),a(new Error(u.message))})}),s=i.session;if(s){const o=Bg(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Dl(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{(n=this.modal)==null||n.close()}}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",e=>{const{params:r}=e,{event:n}=r;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",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Dl(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",va(Gi({},Ue("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Dl(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||wh:[],c=i.length?(e==null?void 0:e.events)||mh:[],l=(e==null?void 0:e.optionalMethods)||[],u=(e==null?void 0:e.optionalEvents)||[],h=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),d=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(p=>this.formatChainId(p)),optionalChains:s.map(p=>this.formatChainId(p)),methods:a,events:c,optionalMethods:l,optionalEvents:u,rpcMap:h,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?vh(this.rpc.chains):vh(this.rpc.optionalChains),this.signer=await JL.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{createAppKit:n}=await Promise.resolve().then(function(){return Sz}),{convertWCMToAppKitOptions:i}=await Promise.resolve().then(function(){return Uz}),s=i(va(Gi({},this.rpc.qrModalOptions),{chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId}));if(!s.networks.length)throw new Error("No networks found for WalletConnect·");r=n(va(Gi({},s),{universalProvider:this.signer,manualWCControl:!0}))}catch{throw new Error("To use QR modal, please install @reown/appkit package")}if(r)try{this.modal=r}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:n,rpcMap:i}=e;r&&Yr(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&Yr(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${tD}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const cD=sd;var od=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},N5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){var r=1e3,n=6e4,i=36e5,s="millisecond",o="second",a="minute",c="hour",l="day",u="week",h="month",d="quarter",p="year",f="date",g="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var m=["th","st","nd","rd"],y=$%100;return"["+$+(m[(y-20)%10]||m[y]||m[0])+"]"}},C=function($,m,y){var x=String($);return!x||x.length>=m?$:""+Array(m+1-x.length).join(y)+$},E={s:C,z:function($){var m=-$.utcOffset(),y=Math.abs(m),x=Math.floor(y/60),_=y%60;return(m<=0?"+":"-")+C(x,2,"0")+":"+C(_,2,"0")},m:function $(m,y){if(m.date()<y.date())return-$(y,m);var x=12*(y.year()-m.year())+(y.month()-m.month()),_=m.clone().add(x,h),O=y-_<0,R=m.clone().add(x+(O?-1:1),h);return+(-(x+(y-_)/(O?_-R:R-_))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:h,y:p,w:u,d:l,D:f,h:c,m:a,s:o,ms:s,Q:d}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},A="en",S={};S[A]=b;var T="$isDayjsObject",k=function($){return $ instanceof M||!(!$||!$[T])},I=function $(m,y,x){var _;if(!m)return A;if(typeof m=="string"){var O=m.toLowerCase();S[O]&&(_=O),y&&(S[O]=y,_=O);var R=m.split("-");if(!_&&R.length>1)return $(R[0])}else{var U=m.name;S[U]=m,_=U}return!x&&_&&(A=_),_||!x&&A},B=function($,m){if(k($))return $.clone();var y=typeof m=="object"?m:{};return y.date=$,y.args=arguments,new M(y)},D=E;D.l=I,D.i=k,D.w=function($,m){return B($,{locale:m.$L,utc:m.$u,x:m.$x,$offset:m.$offset})};var M=function(){function $(y){this.$L=I(y.locale,null,!0),this.parse(y),this.$x=this.$x||y.x||{},this[T]=!0}var m=$.prototype;return m.parse=function(y){this.$d=function(x){var _=x.date,O=x.utc;if(_===null)return new Date(NaN);if(D.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var R=_.match(w);if(R){var U=R[2]-1||0,j=(R[7]||"0").substring(0,3);return O?new Date(Date.UTC(R[1],U,R[3]||1,R[4]||0,R[5]||0,R[6]||0,j)):new Date(R[1],U,R[3]||1,R[4]||0,R[5]||0,R[6]||0,j)}}return new Date(_)}(y),this.init()},m.init=function(){var y=this.$d;this.$y=y.getFullYear(),this.$M=y.getMonth(),this.$D=y.getDate(),this.$W=y.getDay(),this.$H=y.getHours(),this.$m=y.getMinutes(),this.$s=y.getSeconds(),this.$ms=y.getMilliseconds()},m.$utils=function(){return D},m.isValid=function(){return this.$d.toString()!==g},m.isSame=function(y,x){var _=B(y);return this.startOf(x)<=_&&_<=this.endOf(x)},m.isAfter=function(y,x){return B(y)<this.startOf(x)},m.isBefore=function(y,x){return this.endOf(x)<B(y)},m.$g=function(y,x,_){return D.u(y)?this[x]:this.set(_,y)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(y,x){var _=this,O=!!D.u(x)||x,R=D.p(y),U=function(ge,Ee){var Se=D.w(_.$u?Date.UTC(_.$y,Ee,ge):new Date(_.$y,Ee,ge),_);return O?Se:Se.endOf(l)},j=function(ge,Ee){return D.w(_.toDate()[ge].apply(_.toDate("s"),(O?[0,0,0,0]:[23,59,59,999]).slice(Ee)),_)},V=this.$W,z=this.$M,te=this.$D,he="set"+(this.$u?"UTC":"");switch(R){case p:return O?U(1,0):U(31,11);case h:return O?U(1,z):U(0,z+1);case u:var Ce=this.$locale().weekStart||0,we=(V<Ce?V+7:V)-Ce;return U(O?te-we:te+(6-we),z);case l:case f:return j(he+"Hours",0);case c:return j(he+"Minutes",1);case a:return j(he+"Seconds",2);case o:return j(he+"Milliseconds",3);default:return this.clone()}},m.endOf=function(y){return this.startOf(y,!1)},m.$set=function(y,x){var _,O=D.p(y),R="set"+(this.$u?"UTC":""),U=(_={},_[l]=R+"Date",_[f]=R+"Date",_[h]=R+"Month",_[p]=R+"FullYear",_[c]=R+"Hours",_[a]=R+"Minutes",_[o]=R+"Seconds",_[s]=R+"Milliseconds",_)[O],j=O===l?this.$D+(x-this.$W):x;if(O===h||O===p){var V=this.clone().set(f,1);V.$d[U](j),V.init(),this.$d=V.set(f,Math.min(this.$D,V.daysInMonth())).$d}else U&&this.$d[U](j);return this.init(),this},m.set=function(y,x){return this.clone().$set(y,x)},m.get=function(y){return this[D.p(y)]()},m.add=function(y,x){var _,O=this;y=Number(y);var R=D.p(x),U=function(z){var te=B(O);return D.w(te.date(te.date()+Math.round(z*y)),O)};if(R===h)return this.set(h,this.$M+y);if(R===p)return this.set(p,this.$y+y);if(R===l)return U(1);if(R===u)return U(7);var j=(_={},_[a]=n,_[c]=i,_[o]=r,_)[R]||1,V=this.$d.getTime()+y*j;return D.w(V,this)},m.subtract=function(y,x){return this.add(-1*y,x)},m.format=function(y){var x=this,_=this.$locale();if(!this.isValid())return _.invalidDate||g;var O=y||"YYYY-MM-DDTHH:mm:ssZ",R=D.z(this),U=this.$H,j=this.$m,V=this.$M,z=_.weekdays,te=_.months,he=_.meridiem,Ce=function(Ee,Se,Le,nt){return Ee&&(Ee[Se]||Ee(x,O))||Le[Se].slice(0,nt)},we=function(Ee){return D.s(U%12||12,Ee,"0")},ge=he||function(Ee,Se,Le){var nt=Ee<12?"AM":"PM";return Le?nt.toLowerCase():nt};return O.replace(v,function(Ee,Se){return Se||function(Le){switch(Le){case"YY":return String(x.$y).slice(-2);case"YYYY":return D.s(x.$y,4,"0");case"M":return V+1;case"MM":return D.s(V+1,2,"0");case"MMM":return Ce(_.monthsShort,V,te,3);case"MMMM":return Ce(te,V);case"D":return x.$D;case"DD":return D.s(x.$D,2,"0");case"d":return String(x.$W);case"dd":return Ce(_.weekdaysMin,x.$W,z,2);case"ddd":return Ce(_.weekdaysShort,x.$W,z,3);case"dddd":return z[x.$W];case"H":return String(U);case"HH":return D.s(U,2,"0");case"h":return we(1);case"hh":return we(2);case"a":return ge(U,j,!0);case"A":return ge(U,j,!1);case"m":return String(j);case"mm":return D.s(j,2,"0");case"s":return String(x.$s);case"ss":return D.s(x.$s,2,"0");case"SSS":return D.s(x.$ms,3,"0");case"Z":return R}return null}(Ee)||R.replace(":","")})},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(y,x,_){var O,R=this,U=D.p(x),j=B(y),V=(j.utcOffset()-this.utcOffset())*n,z=this-j,te=function(){return D.m(R,j)};switch(U){case p:O=te()/12;break;case h:O=te();break;case d:O=te()/3;break;case u:O=(z-V)/6048e5;break;case l:O=(z-V)/864e5;break;case c:O=z/i;break;case a:O=z/n;break;case o:O=z/r;break;default:O=z}return _?O:D.a(O)},m.daysInMonth=function(){return this.endOf(h).$D},m.$locale=function(){return S[this.$L]},m.locale=function(y,x){if(!y)return this.$L;var _=this.clone(),O=I(y,x,!0);return O&&(_.$L=O),_},m.clone=function(){return D.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},$}(),W=M.prototype;return B.prototype=W,[["$ms",s],["$s",o],["$m",a],["$H",c],["$W",l],["$M",h],["$y",p],["$D",f]].forEach(function($){W[$[1]]=function(m){return this.$g(m,$[0],$[1])}}),B.extend=function($,m){return $.$i||($(m,M,B),$.$i=!0),B},B.locale=I,B.isDayjs=k,B.unix=function($){return B(1e3*$)},B.en=S[A],B.Ls=S,B.p={},B})})(N5);var v0=N5.exports,O5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(r){var n=["th","st","nd","rd"],i=r%100;return"["+r+(n[(i-20)%10]||n[i]||n[0])+"]"}}})})(O5);var lD=O5.exports,P5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return function(r,n,i){r=r||{};var s=n.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function a(l,u,h,d){return s.fromToBase(l,u,h,d)}i.en.relativeTime=o,s.fromToBase=function(l,u,h,d,p){for(var f,g,w,v=h.$locale().relativeTime||o,b=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],C=b.length,E=0;E<C;E+=1){var A=b[E];A.d&&(f=d?i(l).diff(h,A.d,!0):h.diff(l,A.d,!0));var S=(r.rounding||Math.round)(Math.abs(f));if(w=f>0,S<=A.r||!A.r){S<=1&&E>0&&(A=b[E-1]);var T=v[A.l];p&&(S=p(""+S)),g=typeof T=="string"?T.replace("%d",S):T(S,u,A.l,w);break}}if(u)return g;var k=w?v.future:v.past;return typeof k=="function"?k(g):k.replace("%s",g)},s.to=function(l,u){return a(l,u,this,!0)},s.from=function(l,u){return a(l,u,this)};var c=function(l){return l.$u?i.utc():i()};s.toNow=function(l){return this.to(c(this),l)},s.fromNow=function(l){return this.from(c(this),l)}}})})(P5);var uD=P5.exports,k5={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(od,function(){return function(r,n,i){i.updateLocale=function(s,o){var a=i.Ls[s];if(a)return(o?Object.keys(o):[]).forEach(function(c){a[c]=o[c]}),a}}})})(k5);var hD=k5.exports;v0.extend(uD),v0.extend(hD);const dD={...lD,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}};v0.locale("en-web3-modal",dD);const T5={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(r=>r.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]}};var pD=20,fD=1,Oi=1e6,rv=1e6,gD=-7,wD=21,mD=!1,oc="[big.js] ",as=oc+"Invalid ",Bl=as+"decimal places",vD=as+"rounding mode",nv=oc+"Division by zero",Me={},gn=void 0,yD=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function R5(){function t(e){var r=this;if(!(r instanceof t))return e===gn?R5():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(as+"value");e=e===0&&1/e<0?"-0":String(e)}bD(r,e)}r.constructor=t}return t.prototype=Me,t.DP=pD,t.RM=fD,t.NE=gD,t.PE=wD,t.strict=mD,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function bD(t,e){var r,n,i;if(!yD.test(e))throw Error(as+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function Pi(t,e,r,n){var i=t.c;if(r===gn&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(vD);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==gn))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==gn||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function ki(t,e,r){var n=t.e,i=t.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>s)for(n-=s;n--;)i+="0";else n<s&&(i=i.slice(0,n)+"."+i.slice(n));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}Me.abs=function(){var t=new this.constructor(this);return t.s=1,t},Me.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=i.length)?a:c,s=-1;++s<o;)if(n[s]!=i[s])return n[s]>i[s]^e?1:-1;return a==c?0:a>c^e?1:-1},Me.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,s=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>Oi)throw Error(Bl);if(!i[0])throw Error(nv);if(!n[0])return t.s=s,t.c=[t.e=0],t;var a,c,l,u,h,d=i.slice(),p=a=i.length,f=n.length,g=n.slice(0,a),w=g.length,v=t,b=v.c=[],C=0,E=o+(v.e=e.e-t.e)+1;for(v.s=s,s=E<0?0:E,d.unshift(0);w++<a;)g.push(0);do{for(l=0;l<10;l++){if(a!=(w=g.length))u=a>w?1:-1;else for(h=-1,u=0;++h<a;)if(i[h]!=g[h]){u=i[h]>g[h]?1:-1;break}if(u<0){for(c=w==a?i:d;w;){if(g[--w]<c[w]){for(h=w;h&&!g[--h];)g[h]=9;--g[h],g[w]+=10}g[w]-=c[w]}for(;!g[0];)g.shift()}else break}b[C++]=u?l:++l,g[0]&&u?g[w]=n[p]||0:g=[n[p]]}while((p++<f||g[0]!==gn)&&s--);return!b[0]&&C!=1&&(b.shift(),v.e--,E--),C>E&&Pi(v,E,r.RM,g[0]!==gn),v},Me.eq=function(t){return this.cmp(t)===0},Me.gt=function(t){return this.cmp(t)>0},Me.gte=function(t){return this.cmp(t)>-1},Me.lt=function(t){return this.cmp(t)<0},Me.lte=function(t){return this.cmp(t)<1},Me.minus=Me.sub=function(t){var e,r,n,i,s=this,o=s.constructor,a=s.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,s.plus(t);var l=s.c.slice(),u=s.e,h=t.c,d=t.e;if(!l[0]||!h[0])return h[0]?t.s=-c:l[0]?t=new o(s):t.s=1,t;if(a=u-d){for((i=a<0)?(a=-a,n=l):(d=u,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=l.length<h.length)?l:h).length,a=c=0;c<r;c++)if(l[c]!=h[c]){i=l[c]<h[c];break}if(i&&(n=l,l=h,h=n,t.s=-t.s),(c=(r=h.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;r>a;){if(l[--r]<h[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=h[r]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--d;return l[0]||(t.s=1,l=[d=0]),t.c=l,t.e=d,t},Me.mod=function(t){var e,r=this,n=r.constructor,i=r.s,s=(t=new n(t)).s;if(!t.c[0])throw Error(nv);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=s,e?new n(r):(i=n.DP,s=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=s,this.minus(r.times(t)))},Me.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},Me.plus=Me.add=function(t){var e,r,n,i=this,s=i.constructor;if(t=new s(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new s(i):t.s=i.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+l[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t},Me.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-rv||t>rv)throw Error(as+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n},Me.prec=function(t,e){if(t!==~~t||t<1||t>Oi)throw Error(as+"precision");return Pi(new this.constructor(this),t,e)},Me.round=function(t,e){if(t===gn)t=0;else if(t!==~~t||t<-Oi||t>Oi)throw Error(Bl);return Pi(new this.constructor(this),t+this.e+1,e)},Me.sqrt=function(){var t,e,r,n=this,i=n.constructor,s=n.s,o=n.e,a=new i("0.5");if(!n.c[0])return new i(n);if(s<0)throw Error(oc+"No square root");s=Math.sqrt(+ki(n,!0,!0)),s===0||s===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):t=new i(s+""),o=t.e+(i.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Pi(t,(i.DP-=4)+t.e+1,i.RM)},Me.times=Me.mul=function(t){var e,r=this,n=r.constructor,i=r.c,s=(t=new n(t)).c,o=i.length,a=s.length,c=r.e,l=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!s[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=i,i=s,s=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+s[c]*i[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},Me.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==gn){if(t!==~~t||t<0||t>Oi)throw Error(Bl);for(r=Pi(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return ki(r,!0,!!n)},Me.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==gn){if(t!==~~t||t<0||t>Oi)throw Error(Bl);for(r=Pi(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return ki(r,!1,!!n)},Me[Symbol.for("nodejs.util.inspect.custom")]=Me.toJSON=Me.toString=function(){var t=this,e=t.constructor;return ki(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},Me.toNumber=function(){var t=+ki(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(oc+"Imprecise conversion");return t},Me.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==gn){if(t!==~~t||t<1||t>Oi)throw Error(as+"precision");for(r=Pi(new n(r),t,e);r.c.length<t;)r.c.push(0)}return ki(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)},Me.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(oc+"valueOf disallowed");return ki(t,t.e<=e.NE||t.e>=e.PE,!0)};var ya=R5();const Ml={bigNumber(t){return t?new ya(t):new ya(0)},multiply(t,e){if(t===void 0||e===void 0)return new ya(0);const r=new ya(t),n=new ya(e);return r.times(n)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},CD=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],ED=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],xD=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],oe={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"},_D={getERC20Abi:t=>oe.USDT_CONTRACT_ADDRESSES.includes(t)?xD:CD,getSwapAbi:()=>ED},ri={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[r,n,i]=e;if(!r||!n||!i)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:r,chainId:n,address:i}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[r,n]=e;if(!r||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:r,chainId:n}}},ve={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types"};function ap(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const me={setItem(t,e){Za()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Za())return localStorage.getItem(t)||void 0},removeItem(t){Za()&&localStorage.removeItem(t)},clear(){Za()&&localStorage.clear()}};function Za(){return typeof window<"u"&&typeof localStorage<"u"}function gi(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const ID=Symbol(),iv=Object.getPrototypeOf,y0=new WeakMap,AD=t=>t&&(y0.has(t)?y0.get(t):iv(t)===Object.prototype||iv(t)===Array.prototype),$D=t=>AD(t)&&t[ID]||null,sv=(t,e=!0)=>{y0.set(t,e)},cp=t=>typeof t=="object"&&t!==null,li=new WeakMap,Ya=new WeakSet,SD=(t=Object.is,e=(l,u)=>new Proxy(l,u),r=l=>cp(l)&&!Ya.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),n=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},i=new WeakMap,s=(l,u,h=n)=>{const d=i.get(l);if((d==null?void 0:d[0])===u)return d[1];const p=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return sv(p,!0),i.set(l,[u,p]),Reflect.ownKeys(l).forEach(f=>{if(Object.getOwnPropertyDescriptor(p,f))return;const g=Reflect.get(l,f),{enumerable:w}=Reflect.getOwnPropertyDescriptor(l,f),v={value:g,enumerable:w,configurable:!0};if(Ya.has(g))sv(g,!1);else if(g instanceof Promise)delete v.value,v.get=()=>h(g);else if(li.has(g)){const[b,C]=li.get(g);v.value=s(b,C(),h)}Object.defineProperty(p,f,v)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],c=l=>{if(!cp(l))throw new Error("object required");const u=o.get(l);if(u)return u;let h=a[0];const d=new Set,p=(k,I=++a[0])=>{h!==I&&(h=I,d.forEach(B=>B(k,I)))};let f=a[1];const g=(k=++a[1])=>(f!==k&&!d.size&&(f=k,v.forEach(([I])=>{const B=I[1](k);B>h&&(h=B)})),h),w=k=>(I,B)=>{const D=[...I];D[1]=[k,...D[1]],p(D,B)},v=new Map,b=(k,I)=>{if((fh?"production":void 0)!=="production"&&v.has(k))throw new Error("prop listener already exists");if(d.size){const B=I[3](w(k));v.set(k,[I,B])}else v.set(k,[I])},C=k=>{var I;const B=v.get(k);B&&(v.delete(k),(I=B[1])==null||I.call(B))},E=k=>(d.add(k),d.size===1&&v.forEach(([I,B],D)=>{if((fh?"production":void 0)!=="production"&&B)throw new Error("remove already exists");const M=I[3](w(D));v.set(D,[I,M])}),()=>{d.delete(k),d.size===0&&v.forEach(([I,B],D)=>{B&&(B(),v.set(D,[I]))})}),A=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),S=e(A,{deleteProperty(k,I){const B=Reflect.get(k,I);C(I);const D=Reflect.deleteProperty(k,I);return D&&p(["delete",[I],B]),D},set(k,I,B,D){const M=Reflect.has(k,I),W=Reflect.get(k,I,D);if(M&&(t(W,B)||o.has(B)&&t(W,o.get(B))))return!0;C(I),cp(B)&&(B=$D(B)||B);let $=B;if(B instanceof Promise)B.then(m=>{B.status="fulfilled",B.value=m,p(["resolve",[I],m])}).catch(m=>{B.status="rejected",B.reason=m,p(["reject",[I],m])});else{!li.has(B)&&r(B)&&($=c(B));const m=!Ya.has($)&&li.get($);m&&b(I,m)}return Reflect.set(k,I,$,D),p(["set",[I],B,W]),!0}});o.set(l,S);const T=[A,g,s,E];return li.set(S,T),Reflect.ownKeys(l).forEach(k=>{const I=Object.getOwnPropertyDescriptor(l,k);"value"in I&&(S[k]=l[k],delete I.value,delete I.writable),Object.defineProperty(A,k,I)}),S})=>[c,li,Ya,t,e,r,n,i,s,o,a],[ND]=SD();function Xe(t={}){return ND(t)}function zt(t,e,r){const n=li.get(t);(fh?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let i;const s=[],o=n[3];let a=!1;const c=o(l=>{s.push(l),i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(s.splice(0))}))});return a=!0,()=>{a=!1,c()}}function xc(t,e){const r=li.get(t);(fh?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");const[n,i,s]=r;return s(n,i(),e)}function vs(t){return Ya.add(t),t}function Gt(t,e,r,n){let i=t[e];return zt(t,()=>{const s=t[e];Object.is(i,s)||r(i=s)},n)}function OD(t){const e=Xe({data:Array.from([]),has(r){return this.data.some(n=>n[0]===r)},set(r,n){const i=this.data.find(s=>s[0]===r);return i?i[1]=n:this.data.push([r,n]),this},get(r){var n;return(n=this.data.find(i=>i[0]===r))==null?void 0:n[1]},delete(r){const n=this.data.findIndex(i=>i[0]===r);return n===-1?!1:(this.data.splice(n,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(r){this.data.forEach(n=>{r(n[1],n[0],this)})},keys(){return this.data.map(r=>r[0]).values()},values(){return this.data.map(r=>r[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const lp=(typeof process<"u"&&typeof gh<"u"?gh.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",PD=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],mt={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:lp,SECURE_SITE_DASHBOARD:`${lp}/dashboard`,SECURE_SITE_FAVICON:`${lp}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},se={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=se.getActiveNamespace(),e=se.getActiveCaipNetworkId(),r=e?e.split(":")[1]:void 0,n=r?isNaN(Number(r))?r:Number(r):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{me.setItem(ve.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=me.getItem(ve.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{me.removeItem(ve.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{me.setItem(ve.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{me.setItem(ve.ACTIVE_CAIP_NETWORK_ID,t),se.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return me.getItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{me.removeItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=ap(t);me.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=se.getRecentWallets();e.find(r=>r.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),me.setItem(ve.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=me.getItem(ve.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const r=ap(t);me.setItem(r,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return me.getItem(ve.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=ap(t);return me.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{me.setItem(ve.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return me.getItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{me.removeItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return me.getItem(ve.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var t,e;return(e=(t=me.getItem(ve.ACTIVE_CAIP_NETWORK_ID))==null?void 0:t.split(":"))==null?void 0:e[1]},setConnectionStatus(t){try{me.setItem(ve.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return me.getItem(ve.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=me.getItem(ve.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));me.setItem(ve.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=se.getConnectedNamespaces();e.includes(t)||(e.push(t),se.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=se.getConnectedNamespaces(),r=e.indexOf(t);r>-1&&(e.splice(r,1),se.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return me.getItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{me.setItem(ve.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{me.removeItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=me.getItem(ve.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=se.getBalanceCache();me.setItem(ve.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const e=se.getBalanceCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.portfolio))return e.balance;se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=se.getBalanceCache();e[t.caipAddress]=t,me.setItem(ve.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=me.getItem(ve.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=se.getBalanceCache();me.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const e=se.getNativeBalanceCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.nativeBalance))return e;console.info("Discarding cache for address",t),se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=se.getNativeBalanceCache();e[t.caipAddress]=t,me.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=me.getItem(ve.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const e=se.getEnsCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.ens))return e.ens;se.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=se.getEnsCache();e[t.address]=t,me.setItem(ve.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=se.getEnsCache();me.setItem(ve.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=me.getItem(ve.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const e=se.getIdentityCache()[t];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.identity))return e.identity;se.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=se.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},me.setItem(ve.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=se.getIdentityCache();me.setItem(ve.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{me.removeItem(ve.PORTFOLIO_CACHE),me.removeItem(ve.NATIVE_BALANCE_CACHE),me.removeItem(ve.ENS_CACHE),me.removeItem(ve.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{me.setItem(ve.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=me.getItem(ve.PREFERRED_ACCOUNT_TYPES);return JSON.parse(t)}catch{console.info("Unable to get preferred account types")}}},Z={isMobile(){var t;return this.isClient()?!!((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return Z.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=mt.TEN_SEC_MS:!0},isAllowedRetry(t,e=mt.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},getPairingExpiry(){return Date.now()+mt.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let r;return(...n)=>{function i(){t(...n)}r&&clearTimeout(r),r=setTimeout(i,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e){if(Z.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,href:r}},formatUniversalUrl(t,e){if(!Z.isHttpUrl(t))return this.formatNativeUrl(t,e);let r=t;r.endsWith("/")||(r=`${r}/`);const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,href:r}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?se.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,r){window==null||window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},returnOpenHref(t,e,r){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},async preloadImage(t){const e=new Promise((r,n)=>{const i=new Image;i.onload=r,i.onerror=n,i.crossOrigin="anonymous",i.src=t});return Promise.race([e,Z.wait(2e3)])},formatBalance(t,e){let r="0.000";if(typeof t=="string"){const n=Number(t);if(n){const i=Math.floor(n*1e3)/1e3;i&&(r=i.toString())}}return`${r}${e?` ${e}`:""}`},formatBalance2(t,e){var n;let r;if(t==="0")r="0";else if(typeof t=="string"){const i=Number(t);i&&(r=(n=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:n[0])}return{value:r??"0",rest:r==="0"?"000":"",symbol:e}},getApiUrl(){return oe.W3M_API_URL},getBlockchainApiUrl(){return oe.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return oe.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,r;return typeof t=="string"?t:typeof((r=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:r.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const r={};return e&&t&&(t.forEach((n,i)=>{r[n]=i}),e.sort((n,i)=>{const s=r[n.id],o=r[i.id];return s!==void 0&&o!==void 0?s-o:s!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const r of t)e+=r.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[r,n]=e.split(".");return{dollars:r,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const r=new Set;return t.filter(n=>{const i=n[e];return r.has(i)?!1:(r.add(i),!0)})},generateSdkVersion(t,e,r){const n=t.length===0?mt.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${n}-${r}`},createAccount(t,e,r,n,i){return{namespace:t,address:e,type:r,publicKey:n,path:i}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),r=e[0];return e.filter(Boolean).length===3&&r in oe.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,r="state=";if(new URL(t).host==="auth.magic.link"){const n="provider_authorization_url=",i=t.substring(t.indexOf(n)+n.length),s=this.injectIntoUrl(decodeURIComponent(i),r,e);return t.replace(i,encodeURIComponent(s))}return this.injectIntoUrl(t,r,e)},injectIntoUrl(t,e,r){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const i=t.indexOf("&",n),s=e.length,o=i!==-1?i:t.length,a=t.substring(0,n+s),c=t.substring(n+s,o),l=t.substring(i),u=c+r;return a+u+l}};async function ba(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class ad{constructor({baseUrl:e,clientId:r}){this.baseUrl=e,this.clientId=r}async get({headers:e,signal:r,cache:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"GET",headers:e,signal:r,cache:n})).json()}async getBlob({headers:e,signal:r,...n}){const i=this.createUrl(n);return(await ba(i,{method:"GET",headers:e,signal:r})).blob()}async post({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"POST",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"PUT",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:r,signal:n,...i}){const s=this.createUrl(i);return(await ba(s,{method:"DELETE",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:r}){const n=new URL(e,this.baseUrl);return r&&Object.entries(r).forEach(([i,s])=>{s&&n.searchParams.append(i,s)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}}const kD={handleSolanaDeeplinkRedirect(t){if(N.state.activeChain===oe.CHAIN.SOLANA){const e=window.location.href,r=encodeURIComponent(e);if(t==="Phantom"&&!("phantom"in window)){const n=e.startsWith("https")?"https":"http",i=e.split("/")[2],s=encodeURIComponent(`${n}://${i}`);window.location.href=`https://phantom.app/ul/browse/${r}?ref=${s}`}t==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${r}`)}}},hr=Xe({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),sr={state:hr,subscribeNetworkImages(t){return zt(hr.networkImages,()=>t(hr.networkImages))},subscribeKey(t,e){return Gt(hr,t,e)},subscribe(t){return zt(hr,()=>t(hr))},setWalletImage(t,e){hr.walletImages[t]=e},setNetworkImage(t,e){hr.networkImages[t]=e},setChainImage(t,e){hr.chainImages[t]=e},setConnectorImage(t,e){hr.connectorImages={...hr.connectorImages,[t]:e}},setTokenImage(t,e){hr.tokenImages[t]=e},setCurrencyImage(t,e){hr.currencyImages[t]=e}},TD={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},up=Xe({networkImagePromises:{}}),vt={async fetchWalletImage(t){if(t)return await Q._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){return t?this.getNetworkImageById(t)||(up.networkImagePromises[t]||(up.networkImagePromises[t]=Q._fetchNetworkImage(t)),await up.networkImagePromises[t],this.getNetworkImageById(t)):void 0},getWalletImageById(t){if(t)return sr.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return sr.state.walletImages[t.image_id]},getNetworkImage(t){var e,r,n;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(r=t==null?void 0:t.assets)==null?void 0:r.imageUrl;if((n=t==null?void 0:t.assets)!=null&&n.imageId)return sr.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return sr.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return sr.state.connectorImages[t.imageId]},getChainImage(t){return sr.state.networkImages[TD[t]]}},RD={getFeatureValue(t,e){const r=e==null?void 0:e[t];return r===void 0?mt.DEFAULT_FEATURES[t]:r},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(Z.isTelegram()){if(Z.isIos())return t.filter(e=>e!=="google");if(Z.isMac())return t.filter(e=>e!=="x");if(Z.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},de=Xe({features:mt.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:{solana:"eoa",bip122:"payment",polkadot:"eoa",eip155:"smartAccount"},enableNetworkSwitch:!0}),H={state:de,subscribeKey(t,e){return Gt(de,t,e)},setOptions(t){Object.assign(de,t)},setFeatures(t){if(!t)return;de.features||(de.features=mt.DEFAULT_FEATURES);const e={...de.features,...t};de.features=e,de.features.socials&&(de.features.socials=RD.filterSocialsByPlatform(de.features.socials))},setProjectId(t){de.projectId=t},setCustomRpcUrls(t){de.customRpcUrls=t},setAllWallets(t){de.allWallets=t},setIncludeWalletIds(t){de.includeWalletIds=t},setExcludeWalletIds(t){de.excludeWalletIds=t},setFeaturedWalletIds(t){de.featuredWalletIds=t},setTokens(t){de.tokens=t},setTermsConditionsUrl(t){de.termsConditionsUrl=t},setPrivacyPolicyUrl(t){de.privacyPolicyUrl=t},setCustomWallets(t){de.customWallets=t},setIsSiweEnabled(t){de.isSiweEnabled=t},setIsUniversalProvider(t){de.isUniversalProvider=t},setSdkVersion(t){de.sdkVersion=t},setMetadata(t){de.metadata=t},setDisableAppend(t){de.disableAppend=t},setEIP6963Enabled(t){de.enableEIP6963=t},setDebug(t){de.debug=t},setEnableWalletConnect(t){de.enableWalletConnect=t},setEnableWalletGuide(t){de.enableWalletGuide=t},setEnableAuthLogger(t){de.enableAuthLogger=t},setEnableWallets(t){de.enableWallets=t},setHasMultipleAddresses(t){de.hasMultipleAddresses=t},setSIWX(t){de.siwx=t},setConnectMethodsOrder(t){de.features={...de.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){de.features={...de.features,walletFeaturesOrder:t}},setSocialsOrder(t){de.features={...de.features,socials:t}},setCollapseWallets(t){de.features={...de.features,collapseWallets:t}},setEnableEmbedded(t){de.enableEmbedded=t},setAllowUnsupportedChain(t){de.allowUnsupportedChain=t},setManualWCControl(t){de.manualWCControl=t},setEnableNetworkSwitch(t){de.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,r])=>{r&&(de.defaultAccountTypes[e]=r)})},setUniversalProviderConfigOverride(t){de.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return de.universalProviderConfigOverride},getSnapshot(){return xc(de)}},ni=Xe({message:"",variant:"info",open:!1}),vi={state:ni,subscribeKey(t,e){return Gt(ni,t,e)},open(t,e){const{debug:r}=H.state,{shortMessage:n,longMessage:i}=t;r&&(ni.message=n,ni.variant=e,ni.open=!0),i&&console.error(typeof i=="function"?i():i)},close(){ni.open=!1,ni.message="",ni.variant="info"}},LD=Z.getAnalyticsUrl(),DD=new ad({baseUrl:LD,clientId:null}),BD=["MODAL_CREATED"],$n=Xe({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),be={state:$n,subscribe(t){return zt($n,()=>t($n))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=H.state;return{projectId:t,st:e,sv:r||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=ce.state.address;if(BD.includes(t.data.event)||typeof window>"u")return;await DD.post({path:"/e",params:be.getSdkProperties(),body:{eventId:Z.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),$n.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===oe.HTTP_STATUS_CODES.FORBIDDEN&&!$n.reportedErrors.FORBIDDEN&&(vi.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${Za()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),$n.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;$n.timestamp=Date.now(),$n.data=t,(e=H.state.features)!=null&&e.analytics&&be._sendAnalyticsEvent($n)}},MD=["1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79","fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa","a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393"],UD=Z.getApiUrl(),_r=new ad({baseUrl:UD,clientId:null}),jD=40,ov=4,zD=20,De=Xe({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),Q={state:De,subscribeKey(t,e){return Gt(De,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=H.state;return{projectId:t,st:e||"appkit",sv:r||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return H.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${_r.baseUrl}/getWalletImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setWalletImage(t,URL.createObjectURL(r))},async _fetchNetworkImage(t){const e=`${_r.baseUrl}/public/getAssetImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setNetworkImage(t,URL.createObjectURL(r))},async _fetchConnectorImage(t){const e=`${_r.baseUrl}/public/getAssetImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setConnectorImage(t,URL.createObjectURL(r))},async _fetchCurrencyImage(t){const e=`${_r.baseUrl}/public/getCurrencyImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setCurrencyImage(t,URL.createObjectURL(r))},async _fetchTokenImage(t){const e=`${_r.baseUrl}/public/getTokenImage/${t}`,r=await _r.getBlob({path:e,params:Q._getSdkProperties()});sr.setTokenImage(t,URL.createObjectURL(r))},async fetchNetworkImages(){var e;const t=(e=N.getAllRequestedCaipNetworks())==null?void 0:e.map(({assets:r})=>r==null?void 0:r.imageId).filter(Boolean).filter(r=>!vt.getNetworkImageById(r));t&&await Promise.allSettled(t.map(r=>Q._fetchNetworkImage(r)))},async fetchConnectorImages(){const{connectors:t}=ee.state,e=t.map(({imageId:r})=>r).filter(Boolean);await Promise.allSettled(e.map(r=>Q._fetchConnectorImage(r)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>Q._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>Q._fetchTokenImage(e)))},async fetchWallets(t){var r,n;const e=t.exclude??[];return Q._getSdkProperties().sv.startsWith("html-core-")&&e.push(...MD),await _r.get({path:"/getWallets",params:{...Q._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(r=t.include)==null?void 0:r.join(","),exclude:(n=t.exclude)==null?void 0:n.join(",")}})},async fetchFeaturedWallets(){const{featuredWalletIds:t}=H.state;if(t!=null&&t.length){const e={...Q._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??ov,include:t},{data:r}=await Q.fetchWallets(e);r.sort((i,s)=>t.indexOf(i.id)-t.indexOf(s.id));const n=r.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(n.map(i=>Q._fetchWalletImage(i))),De.featured=r,De.allFeatured=r}},async fetchRecommendedWallets(){try{De.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:r}=H.state,n=[...e??[],...r??[]].filter(Boolean),i=N.getRequestedCaipNetworkIds().join(","),s={page:1,entries:ov,include:t,exclude:n,chains:i},{data:o,count:a}=await Q.fetchWallets(s),c=se.getRecentWallets(),l=o.map(h=>h.image_id).filter(Boolean),u=c.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(h=>Q._fetchWalletImage(h))),De.recommended=o,De.allRecommended=o,De.count=a??0}catch{}finally{De.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:r,featuredWalletIds:n}=H.state,i=N.getRequestedCaipNetworkIds().join(","),s=[...De.recommended.map(({id:u})=>u),...r??[],...n??[]].filter(Boolean),o={page:t,entries:jD,include:e,exclude:s,chains:i},{data:a,count:c}=await Q.fetchWallets(o),l=a.slice(0,zD).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(l.map(u=>Q._fetchWalletImage(u))),De.wallets=Z.uniqueBy([...De.wallets,...Q._filterOutExtensions(a)],"id"),De.count=c>De.count?c:De.count,De.page=t},async initializeExcludedWallets({ids:t}){const e=N.getRequestedCaipNetworkIds().join(","),r={page:1,entries:t.length,include:t,chains:e},{data:n}=await Q.fetchWallets(r);n&&n.forEach(i=>{De.excludedWallets.push({rdns:i.rdns,name:i.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:r,excludeWalletIds:n}=H.state,i=N.getRequestedCaipNetworkIds().join(",");De.search=[];const s={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:r,exclude:n,chains:i},{data:o}=await Q.fetchWallets(s);be.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>Q._fetchWalletImage(c)),Z.wait(300)]),De.search=Q._filterOutExtensions(o)},initPromise(t,e){return De.promises[t]||(De.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:r=!0,fetchNetworkImages:n=!0}={}){const i=[t&&Q.initPromise("connectorImages",Q.fetchConnectorImages),e&&Q.initPromise("featuredWallets",Q.fetchFeaturedWallets),r&&Q.initPromise("recommendedWallets",Q.fetchRecommendedWallets),n&&Q.initPromise("networkImages",Q.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=H.state.features)!=null&&t.analytics&&Q.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await _r.get({path:"/getAnalyticsConfig",params:Q._getSdkProperties()});H.setFeatures({analytics:t})}catch{H.setFeatures({analytics:!1})}},setFilterByNamespace(t){if(!t){De.featured=De.allFeatured,De.recommended=De.allRecommended;return}const e=N.getRequestedCaipNetworkIds().join(",");De.featured=De.allFeatured.filter(r=>{var n;return(n=r.chains)==null?void 0:n.some(i=>e.includes(i))}),De.recommended=De.allRecommended.filter(r=>{var n;return(n=r.chains)==null?void 0:n.some(i=>e.includes(i))})}},Te=Xe({view:"Connect",history:["Connect"],transactionStack:[]}),X={state:Te,subscribeKey(t,e){return Gt(Te,t,e)},pushTransactionStack(t){Te.transactionStack.push(t)},popTransactionStack(t){var r,n;const e=Te.transactionStack.pop();if(e)if(t)this.goBack(),(r=e==null?void 0:e.onCancel)==null||r.call(e);else{if(e.goBack)this.goBack();else if(e.replace){const i=Te.history.indexOf("ConnectingSiwe");i>0?this.goBackToIndex(i-1):($e.close(),Te.history=[])}else e.view&&this.reset(e.view);(n=e==null?void 0:e.onSuccess)==null||n.call(e)}},push(t,e){t!==Te.view&&(Te.view=t,Te.history.push(t),Te.data=e)},reset(t,e){Te.view=t,Te.history=[t],Te.data=e},replace(t,e){Te.history.at(-1)===t||(Te.view=t,Te.history[Te.history.length-1]=t,Te.data=e)},goBack(){var e;const t=!N.state.activeCaipAddress&&this.state.view==="ConnectingFarcaster";if(Te.history.length>1&&!Te.history.includes("UnsupportedChain")){Te.history.pop();const[r]=Te.history.slice(-1);r&&(Te.view=r)}else $e.close();(e=Te.data)!=null&&e.wallet&&(Te.data.wallet=void 0),setTimeout(()=>{var r,n,i;if(t){ce.setFarcasterUrl(void 0,N.state.activeChain);const s=ee.getAuthConnector();(r=s==null?void 0:s.provider)==null||r.reload();const o=xc(H.state);(i=(n=s==null?void 0:s.provider)==null?void 0:n.syncDappData)==null||i.call(n,{metadata:o.metadata,sdkVersion:o.sdkVersion,projectId:o.projectId,sdkType:o.sdkType})}},100)},goBackToIndex(t){if(Te.history.length>1){Te.history=Te.history.slice(0,t+1);const[e]=Te.history.slice(-1);e&&(Te.view=e)}}},Sn=Xe({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),gt={state:Sn,subscribe(t){return zt(Sn,()=>t(Sn))},setThemeMode(t){Sn.themeMode=t;try{const e=ee.getAuthConnector();if(e){const r=gt.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:r,w3mThemeVariables:gi(r,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){Sn.themeVariables={...Sn.themeVariables,...t};try{const e=ee.getAuthConnector();if(e){const r=gt.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:r,w3mThemeVariables:gi(Sn.themeVariables,Sn.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return xc(Sn)}},L5={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},Be=Xe({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...L5}}),ee={state:Be,subscribe(t){return zt(Be,()=>{t(Be)})},subscribeKey(t,e){return Gt(Be,t,e)},initialize(t){t.forEach(e=>{const r=se.getConnectedConnectorId(e);r&&this.setConnectorId(r,e)})},setActiveConnector(t){t&&(Be.activeConnector=vs(t))},setConnectors(t){t.filter(e=>!Be.allConnectors.some(r=>r.id===e.id&&this.getConnectorName(r.name)===this.getConnectorName(e.name)&&r.chain===e.chain)).forEach(e=>{e.type!=="MULTI_CHAIN"&&Be.allConnectors.push(vs(e))}),Be.connectors=this.mergeMultiChainConnectors(Be.allConnectors)},removeAdapter(t){Be.allConnectors=Be.allConnectors.filter(e=>e.chain!==t),Be.connectors=this.mergeMultiChainConnectors(Be.allConnectors)},mergeMultiChainConnectors(t){const e=this.generateConnectorMapByName(t),r=[];return e.forEach(n=>{const i=n[0],s=(i==null?void 0:i.id)===oe.CONNECTOR_ID.AUTH;n.length>1&&i?r.push({name:i.name,imageUrl:i.imageUrl,imageId:i.imageId,connectors:[...n],type:s?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(i==null?void 0:i.id)||""}):i&&r.push(i)}),r},generateConnectorMapByName(t){const e=new Map;return t.forEach(r=>{const{name:n}=r,i=this.getConnectorName(n);if(!i)return;const s=e.get(i)||[];s.find(o=>o.chain===r.chain)||s.push(r),e.set(i,s)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(r=>{e.find(n=>n.chain===r.chain)||e.push(r)}),e},addConnector(t){var e,r,n;if(t.id===oe.CONNECTOR_ID.AUTH){const i=t,s=xc(H.state),o=gt.getSnapshot().themeMode,a=gt.getSnapshot().themeVariables;(r=(e=i==null?void 0:i.provider)==null?void 0:e.syncDappData)==null||r.call(e,{metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),(n=i==null?void 0:i.provider)==null||n.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:gi(a,o)}),this.setConnectors([t])}else this.setConnectors([t])},getAuthConnector(t){var n;const e=t||N.state.activeChain,r=Be.connectors.find(i=>i.id===oe.CONNECTOR_ID.AUTH);if(r)return(n=r==null?void 0:r.connectors)!=null&&n.length?r.connectors.find(i=>i.chain===e):r},getAnnouncedConnectorRdns(){return Be.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return Be.allConnectors.find(e=>e.id===t)},getConnector(t,e){return Be.allConnectors.filter(r=>r.chain===N.state.activeChain).find(r=>{var n;return r.explorerId===t||((n=r.info)==null?void 0:n.rdns)===e})},syncIfAuthConnector(t){var s,o;if(t.id!=="ID_AUTH")return;const e=t,r=xc(H.state),n=gt.getSnapshot().themeMode,i=gt.getSnapshot().themeVariables;(o=(s=e==null?void 0:e.provider)==null?void 0:s.syncDappData)==null||o.call(s,{metadata:r.metadata,sdkVersion:r.sdkVersion,sdkType:r.sdkType,projectId:r.projectId}),e.provider.syncTheme({themeMode:n,themeVariables:i,w3mThemeVariables:gi(i,n)})},getConnectorsByNamespace(t){const e=Be.allConnectors.filter(r=>r.chain===t);return this.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=ee.getConnector(t.id,t.rdns);N.state.activeChain===oe.CHAIN.SOLANA&&kD.handleSolanaDeeplinkRedirect((e==null?void 0:e.name)||t.name||""),e?X.push("ConnectingExternal",{connector:e}):X.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?this.getConnectorsByNamespace(t):this.mergeMultiChainConnectors(Be.allConnectors)},setFilterByNamespace(t){Be.filterByNamespace=t,Be.connectors=this.getConnectors(t),Q.setFilterByNamespace(t)},setConnectorId(t,e){t&&(Be.activeConnectorIds={...Be.activeConnectorIds,[e]:t},se.setConnectedConnectorId(e,t))},removeConnectorId(t){Be.activeConnectorIds={...Be.activeConnectorIds,[t]:void 0},se.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return Be.activeConnectorIds[t]},isConnected(t){return t?!!Be.activeConnectorIds[t]:Object.values(Be.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){Be.activeConnectorIds={...L5}}};function Ul(t,e){return ee.getConnectorId(t)===e}function FD(t){const e=Array.from(N.state.chains.keys());let r=[];return t?(r.push([t,N.state.chains.get(t)]),Ul(t,oe.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(n=>{n!==t&&Ul(n,oe.CONNECTOR_ID.WALLET_CONNECT)&&r.push([n,N.state.chains.get(n)])}):Ul(t,oe.CONNECTOR_ID.AUTH)&&e.forEach(n=>{n!==t&&Ul(n,oe.CONNECTOR_ID.AUTH)&&r.push([n,N.state.chains.get(n)])})):r=Array.from(N.state.chains.entries()),r}const ui={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Zi=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),dt=Xe({...Zi}),Je={state:dt,subscribeKey(t,e){return Gt(dt,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=Z.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){dt.message=Zi.message,dt.variant=Zi.variant,dt.svg=Zi.svg,dt.open=Zi.open,dt.autoClose=Zi.autoClose},_showMessage({message:t,svg:e,variant:r="success",autoClose:n=Zi.autoClose}){dt.open?(dt.open=!1,setTimeout(()=>{dt.message=t,dt.variant=r,dt.svg=e,dt.open=!0,dt.autoClose=n},150)):(dt.message=t,dt.variant=r,dt.svg=e,dt.open=!0,dt.autoClose=n)}},yi={getSIWX(){return H.state.siwx},async initializeIfEnabled(){var s;const t=H.state.siwx,e=N.getActiveCaipAddress();if(!(t&&e))return;const[r,n,i]=e.split(":");if(N.checkIfSupportedNetwork(r))try{if((await t.getSessions(`${r}:${n}`,i)).length)return;await $e.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((s=ae._getClient())==null?void 0:s.disconnect().catch(console.error)),X.reset("Connect"),Je.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=H.state.siwx,e=Z.getPlainAddress(N.getActiveCaipAddress()),r=N.getActiveCaipNetwork(),n=ae._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!r)throw new Error("No ActiveCaipNetwork or client found");if(!n)throw new Error("No ConnectionController client found");try{const i=await t.createMessage({chainId:r.caipNetworkId,accountAddress:e}),s=i.toString();ee.getConnectorId(r.chainNamespace)===oe.CONNECTOR_ID.AUTH&&X.pushTransactionStack({view:null,goBack:!1,replace:!0});const o=await n.signMessage(s);await t.addSession({data:i,message:s,signature:o}),$e.close(),be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(i){const s=this.getSIWXEventProperties();(!$e.state.open||X.state.view==="ApproveTransaction")&&await $e.open({view:"SIWXSignMessage"}),s.isSmartAccount?Je.showError("This application might not support Smart Accounts"):Je.showError("Signature declined"),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:s}),console.error("SWIXUtil:requestSignMessage",i)}},async cancelSignMessage(){var t,e;try{(e=(t=this.getSIWX())==null?void 0:t.getRequired)!=null&&e.call(t)?await ae.disconnect():$e.close(),X.reset("Connect"),be.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(r){console.error("SIWXUtil:cancelSignMessage",r)}},async getSessions(){const t=H.state.siwx,e=Z.getPlainAddress(N.getActiveCaipAddress()),r=N.getActiveCaipNetwork();return t&&e&&r?t.getSessions(r.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const t=this.getSIWX();if(t){const r=X.state.view==="ApproveTransaction",n=X.state.view==="SIWXSignMessage";if(r||n)return((e=t.getRequired)==null?void 0:e.call(t))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:r}){var a,c,l;const n=yi.getSIWX(),i=new Set(e.map(u=>u.split(":")[0]));if(!n||i.size!==1||!i.has("eip155"))return!1;const s=await n.createMessage({chainId:((a=N.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await t.authenticate({nonce:s.nonce,domain:s.domain,uri:s.uri,exp:s.expirationTime,iat:s.issuedAt,nbf:s.notBefore,requestId:s.requestId,version:s.version,resources:s.resources,statement:s.statement,chainId:s.chainId,methods:r,chains:[s.chainId,...e.filter(u=>u!==s.chainId)]});if(Je.showLoading("Authenticating...",{autoClose:!1}),ce.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(c=o.session.peer.metadata.icons)==null?void 0:c[0],type:"WALLET_CONNECT"},Array.from(i)[0]),(l=o==null?void 0:o.auths)==null?void 0:l.length){const u=o.auths.map(h=>{const d=t.client.formatAuthMessage({request:h.p,iss:h.p.iss});return{data:{...h.p,accountAddress:h.p.iss.split(":").slice(-1).join(""),chainId:h.p.iss.split(":").slice(2,4).join(":"),uri:h.p.aud,version:h.p.version||s.version,expirationTime:h.p.exp,issuedAt:h.p.iat,notBefore:h.p.nbf},message:d,signature:h.s.s,cacao:h}});try{await n.setSessions(u),be.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:yi.getSIWXEventProperties()})}catch(h){throw console.error("SIWX:universalProviderAuth - failed to set sessions",h),be.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:yi.getSIWXEventProperties()}),await t.disconnect().catch(console.error),h}finally{Je.hide()}}return!0},getSIWXEventProperties(){var e,r;const t=N.state.activeChain;return{network:((e=N.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||"",isSmartAccount:((r=ce.state.preferredAccountTypes)==null?void 0:r[t])===ui.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}},et=Xe({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),HD={state:et,subscribe(t){return zt(et,()=>t(et))},setLastNetworkInView(t){et.lastNetworkInView=t},async fetchTransactions(t,e){var r,n;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");et.loading=!0;try{const i=await pe.fetchTransactions({account:t,cursor:et.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(r=N.state.activeCaipNetwork)==null?void 0:r.caipNetworkId}),s=this.filterSpamTransactions(i.data),o=this.filterByConnectedChain(s),a=[...et.transactions,...o];et.loading=!1,e==="coinbase"?et.coinbaseTransactions=this.groupTransactionsByYearAndMonth(et.coinbaseTransactions,i.data):(et.transactions=a,et.transactionsByYear=this.groupTransactionsByYearAndMonth(et.transactionsByYear,o)),et.empty=a.length===0,et.next=i.next?i.next:void 0}catch{const i=N.state.activeChain;be.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:H.state.projectId,cursor:et.next,isSmartAccount:((n=ce.state.preferredAccountTypes)==null?void 0:n[i])===ui.ACCOUNT_TYPES.SMART_ACCOUNT}}),Je.showError("Failed to fetch transactions"),et.loading=!1,et.empty=!0,et.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const r=t;return e.forEach(n=>{const i=new Date(n.metadata.minedAt).getFullYear(),s=new Date(n.metadata.minedAt).getMonth(),o=r[i]??{},a=(o[s]??[]).filter(c=>c.id!==n.id);r[i]={...o,[s]:[...a,n].sort((c,l)=>new Date(l.metadata.minedAt).getTime()-new Date(c.metadata.minedAt).getTime())}}),r},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(r=>{var n;return((n=r.nft_info)==null?void 0:n.flags.is_spam)===!0}))},filterByConnectedChain(t){var r;const e=(r=N.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;return t.filter(n=>n.metadata.chain===e)},clearCursor(){et.next=void 0},resetTransactions(){et.transactions=[],et.transactionsByYear={},et.lastNetworkInView=void 0,et.loading=!1,et.empty=!1,et.next=void 0}},tt=Xe({wcError:!1,buffering:!1,status:"disconnected"});let Ys;const ae={state:tt,subscribeKey(t,e){return Gt(tt,t,e)},_getClient(){return tt._client},setClient(t){tt._client=vs(t)},async connectWalletConnect(){var t,e,r,n;if(Z.isTelegram()||Z.isSafari()&&Z.isIos()){if(Ys){await Ys,Ys=void 0;return}if(!Z.isPairingExpired(tt==null?void 0:tt.wcPairingExpiry)){const i=tt.wcUri;tt.wcUri=i;return}Ys=(e=(t=this._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:e.call(t).catch(()=>{}),this.state.status="connecting",await Ys,Ys=void 0,tt.wcPairingExpiry=void 0,this.state.status="connected"}else await((n=(r=this._getClient())==null?void 0:r.connectWalletConnect)==null?void 0:n.call(r))},async connectExternal(t,e,r=!0){var n,i;await((i=(n=this._getClient())==null?void 0:n.connectExternal)==null?void 0:i.call(n,t)),r&&N.setActiveNamespace(e)},async reconnectExternal(t){var r,n;await((n=(r=this._getClient())==null?void 0:r.reconnectExternal)==null?void 0:n.call(r,t));const e=t.chain||N.state.activeChain;e&&ee.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var n;$e.setLoading(!0,N.state.activeChain);const r=ee.getAuthConnector();r&&(ce.setPreferredAccountType(t,e),await r.provider.setPreferredAccount(t),se.setPreferredAccountTypes(ce.state.preferredAccountTypes??{[e]:t}),await this.reconnectExternal(r),$e.setLoading(!1,N.state.activeChain),be.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((n=N.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=this._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var r;return(r=this._getClient())==null?void 0:r.parseUnits(t,e)},formatUnits(t,e){var r;return(r=this._getClient())==null?void 0:r.formatUnits(t,e)},async sendTransaction(t){var e;return(e=this._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=this._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=this._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=this._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=this._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=this._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=this._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=this._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,r;return((r=(e=this._getClient())==null?void 0:e.checkInstalled)==null?void 0:r.call(e,t))||!1},resetWcConnection(){tt.wcUri=void 0,tt.wcPairingExpiry=void 0,tt.wcLinking=void 0,tt.recentWallet=void 0,tt.status="disconnected",HD.resetTransactions(),se.deleteWalletConnectDeepLink()},resetUri(){tt.wcUri=void 0,tt.wcPairingExpiry=void 0},finalizeWcConnection(){var r,n;const{wcLinking:t,recentWallet:e}=ae.state;t&&se.setWalletConnectDeepLink(t),e&&se.setAppKitRecent(e),be.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:((n=(r=X.state.data)==null?void 0:r.wallet)==null?void 0:n.name)||"Unknown"}})},setWcBasic(t){tt.wcBasic=t},setUri(t){tt.wcUri=t,tt.wcPairingExpiry=Z.getPairingExpiry()},setWcLinking(t){tt.wcLinking=t},setWcError(t){tt.wcError=t,tt.buffering=!1},setRecentWallet(t){tt.recentWallet=t},setBuffering(t){tt.buffering=t},setStatus(t){tt.status=t},async disconnect(t){try{$e.setLoading(!0,t),await yi.clearSessions(),await N.disconnect(t),$e.setLoading(!1,t),ee.setFilterByNamespace(void 0)}catch{throw new Error("Failed to disconnect")}}},Js=Xe({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Vn={state:Js,subscribe(t){return zt(Js,()=>t(Js))},subscribeOpen(t){return Gt(Js,"open",t)},set(t){Object.assign(Js,{...Js,...t})}};function dl(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Mo(t){return dl(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const D5="2.27.0";let Ca={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${D5}`};class Ie extends Error{constructor(e,r={}){var a,c;const n=r.cause instanceof Ie?r.cause.details:(a=r.cause)!=null&&a.message?r.cause.message:r.details,i=r.cause instanceof Ie&&r.cause.docsPath||r.docsPath,s=(c=Ca.getDocsUrl)==null?void 0:c.call(Ca,{...r,docsPath:i}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Ca.version?[`Version: ${Ca.version}`]:[]].join(`
|
|
40
40
|
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=D5}walk(e){return B5(this,e)}}function B5(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?B5(t.cause,e):e?null:t}class qD extends Ie{constructor({offset:e,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class M5 extends Ie{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function na(t,{dir:e,size:r=32}={}){return typeof t=="string"?WD(t,{dir:e,size:r}):VD(t,{dir:e,size:r})}function WD(t,{dir:e,size:r=32}={}){if(r===null)return t;const n=t.replace("0x","");if(n.length>r*2)throw new M5({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function VD(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new M5({size:t.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const s=e==="right";n[s?i:r-i-1]=t[s?i:t.length-i-1]}return n}class KD extends Ie{constructor({max:e,min:r,signed:n,size:i,value:s}){super(`Number "${s}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class GD extends Ie{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Uo(t,{dir:e="left"}={}){let r=typeof t=="string"?t.replace("0x",""):t,n=0;for(let i=0;i<r.length-1&&r[e==="left"?i:r.length-i-1].toString()==="0";i++)n++;return r=e==="left"?r.slice(n):r.slice(0,r.length-n),typeof t=="string"?(r.length===1&&e==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}function ia(t,{size:e}){if(Mo(t)>e)throw new GD({givenSize:Mo(t),maxSize:e})}function Fn(t,e={}){const{signed:r}=e;e.size&&ia(t,{size:e.size});const n=BigInt(t);if(!r)return n;const i=(t.length-2)/2,s=(1n<<BigInt(i)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function yh(t,e={}){return Number(Fn(t,e))}const ZD=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fe(t,e={}){return typeof t=="number"||typeof t=="bigint"?qt(t,e):typeof t=="string"?U5(t,e):typeof t=="boolean"?YD(t,e):Jn(t,e)}function YD(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(ia(r,{size:e.size}),na(r,{size:e.size})):r}function Jn(t,e={}){let r="";for(let i=0;i<t.length;i++)r+=ZD[t[i]];const n=`0x${r}`;return typeof e.size=="number"?(ia(n,{size:e.size}),na(n,{dir:"right",size:e.size})):n}function qt(t,e={}){const{signed:r,size:n}=e,i=BigInt(t);let s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&i>s||i<o){const c=typeof t=="bigint"?"n":"";throw new KD({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:n,value:`${t}${c}`})}const a=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?na(a,{size:n}):a}const JD=new TextEncoder;function U5(t,e={}){const r=JD.encode(t);return Jn(r,e)}const XD=new TextEncoder;function j5(t,e={}){return typeof t=="number"||typeof t=="bigint"?eB(t,e):typeof t=="boolean"?QD(t,e):dl(t)?ys(t,e):z5(t,e)}function QD(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(ia(r,{size:e.size}),na(r,{size:e.size})):r}const Nn={zero:48,nine:57,A:65,F:70,a:97,f:102};function av(t){if(t>=Nn.zero&&t<=Nn.nine)return t-Nn.zero;if(t>=Nn.A&&t<=Nn.F)return t-(Nn.A-10);if(t>=Nn.a&&t<=Nn.f)return t-(Nn.a-10)}function ys(t,e={}){let r=t;e.size&&(ia(r,{size:e.size}),r=na(r,{dir:"right",size:e.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,s=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const c=av(n.charCodeAt(a++)),l=av(n.charCodeAt(a++));if(c===void 0||l===void 0)throw new Ie(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[o]=c*16+l}return s}function eB(t,e){const r=qt(t,e);return ys(r)}function z5(t,e={}){const r=XD.encode(t);return typeof e.size=="number"?(ia(r,{size:e.size}),na(r,{dir:"right",size:e.size})):r}function bh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tB(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function pl(t,...e){if(!tB(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function rB(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bh(t.outputLen),bh(t.blockLen)}function jo(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function F5(t,e){pl(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const jl=BigInt(2**32-1),cv=BigInt(32);function nB(t,e=!1){return e?{h:Number(t&jl),l:Number(t>>cv&jl)}:{h:Number(t>>cv&jl)|0,l:Number(t&jl)|0}}function iB(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=nB(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const sB=(t,e,r)=>t<<r|e>>>32-r,oB=(t,e,r)=>e<<r|t>>>32-r,aB=(t,e,r)=>e<<r-32|t>>>64-r,cB=(t,e,r)=>t<<r-32|e>>>64-r,Xs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function lB(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function hp(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function nn(t,e){return t<<32-e|t>>>e}const lv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function uB(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function uv(t){for(let e=0;e<t.length;e++)t[e]=uB(t[e])}function hB(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function cd(t){return typeof t=="string"&&(t=hB(t)),pl(t),t}function dB(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];pl(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}class v1{clone(){return this._cloneInto()}}function H5(t){const e=n=>t().update(cd(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function pB(t=32){if(Xs&&typeof Xs.getRandomValues=="function")return Xs.getRandomValues(new Uint8Array(t));if(Xs&&typeof Xs.randomBytes=="function")return Xs.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const q5=[],W5=[],V5=[],fB=BigInt(0),Ea=BigInt(1),gB=BigInt(2),wB=BigInt(7),mB=BigInt(256),vB=BigInt(113);for(let t=0,e=Ea,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],q5.push(2*(5*n+r)),W5.push((t+1)*(t+2)/2%64);let i=fB;for(let s=0;s<7;s++)e=(e<<Ea^(e>>wB)*vB)%mB,e&gB&&(i^=Ea<<(Ea<<BigInt(s))-Ea);V5.push(i)}const[yB,bB]=iB(V5,!0),hv=(t,e,r)=>r>32?aB(t,e,r):sB(t,e,r),dv=(t,e,r)=>r>32?cB(t,e,r):oB(t,e,r);function CB(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=r[c],u=r[c+1],h=hv(l,u,1)^r[a],d=dv(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)t[o+p]^=h,t[o+p+1]^=d}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=W5[o],c=hv(i,s,a),l=dv(i,s,a),u=q5[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=yB[n],t[1]^=bB[n]}r.fill(0)}class y1 extends v1{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,bh(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=lB(this.state)}keccak(){lv||uv(this.state32),CB(this.state32,this.rounds),lv||uv(this.state32),this.posOut=0,this.pos=0}update(e){jo(this);const{blockLen:r,state:n}=this;e=cd(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,r&128&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){jo(this,!1),pl(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return bh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(F5(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new y1(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const EB=(t,e,r)=>H5(()=>new y1(e,t,r)),K5=EB(1,136,256/8);function xB(t,e){const r=e,n=K5(dl(t,{strict:!1})?j5(t):t);return r==="bytes"?n:fe(n)}class xi extends Ie{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class ld extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const dp=new ld(8192);function _B(t,e){if(dp.has(`${t}.${e}`))return dp.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),n=xB(z5(r),"bytes"),i=r.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(n[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const s=`0x${i.join("")}`;return dp.set(`${t}.${e}`,s),s}const IB=/^0x[a-fA-F0-9]{40}$/,pp=new ld(8192);function Zn(t,e){const{strict:r=!0}=e??{},n=`${t}.${r}`;if(pp.has(n))return pp.get(n);const i=IB.test(t)?t.toLowerCase()===t?!0:r?_B(t)===t:!0:!1;return pp.set(n,i),i}function sa(t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function AB(t,e,r,{strict:n}={}){return dl(t,{strict:!1})?SB(t,e,r,{strict:n}):$B(t,e,r,{strict:n})}function G5(t,e,r){if(Mo(t)!==r-e)throw new qD({offset:r,position:"end",size:Mo(t)})}function $B(t,e,r,{strict:n}={}){const i=t.slice(e,r);return n&&G5(i,e,r),i}function SB(t,e,r,{strict:n}={}){const i=`0x${t.replace("0x","").slice(e*2,r*2)}`;return n&&G5(i,e,r),i}class pv extends Ie{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class NB extends Ie{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class OB extends Ie{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const PB={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new OB({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new NB({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new pv({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new pv({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const r=e??this.position;return this.assertPosition(r+t-1),this.bytes.subarray(r,r+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const r=this.inspectBytes(t);return this.position+=e??t,r},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Z5(t,{recursiveReadLimit:e=8192}={}){const r=Object.create(PB);return r.bytes=t,r.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=e,r}const cs=(t,e,r)=>JSON.stringify(t,(n,i)=>typeof i=="bigint"?i.toString():i,r),kB={ether:-9,wei:9};function Y5(t,e){let r=t.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(e,"0");let[i,s]=[r.slice(0,r.length-e),r.slice(r.length-e)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${s?`.${s}`:""}`}function b0(t,e="wei"){return Y5(t,kB[e])}function TB(t){const e=Object.entries(t).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=e.reduce((n,[i])=>Math.max(n,i.length),0);return e.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(`
|
|
41
41
|
`)}class RB extends Ie{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class LB extends Ie{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",TB(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class DB extends Ie{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}const b1=t=>t;class ac extends Ie{constructor({body:e,cause:r,details:n,headers:i,status:s,url:o}){super("HTTP request failed.",{cause:r,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${b1(o)}`,e&&`Request body: ${cs(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=i,this.status=s,this.url=o}}class J5 extends Ie{constructor({body:e,error:r,url:n}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${b1(n)}`,`Request body: ${cs(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data}}class fv extends Ie{constructor({body:e,url:r}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${b1(r)}`,`Request body: ${cs(e)}`],name:"TimeoutError"})}}const BB=-1;class cr extends Ie{constructor(e,{code:r,docsPath:n,metaMessages:i,name:s,shortMessage:o}){super(o,{cause:e,docsPath:n,metaMessages:i||(e==null?void 0:e.metaMessages),name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof J5?e.code:r??BB}}class Cr extends cr{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class _c extends cr{constructor(e){super(e,{code:_c.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(_c,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Ic extends cr{constructor(e){super(e,{code:Ic.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Ic,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Ac extends cr{constructor(e,{method:r}={}){super(e,{code:Ac.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(Ac,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class $c extends cr{constructor(e){super(e,{code:$c.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
|
|
42
42
|
`)})}}Object.defineProperty($c,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class zo extends cr{constructor(e){super(e,{code:zo.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(zo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Sc extends cr{constructor(e){super(e,{code:Sc.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|