@walletconnect/ethereum-provider 2.2.1 → 2.3.0

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/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(St,ke){typeof exports=="object"&&typeof module<"u"?ke(exports):typeof define=="function"&&define.amd?define(["exports"],ke):(St=typeof globalThis<"u"?globalThis:St||self,ke(St["@walletconnect/ethereum-provider"]={}))})(this,function(St){"use strict";var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Uu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Zt(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Wn={exports:{}},hr=typeof Reflect=="object"?Reflect:null,vs=hr&&typeof hr.apply=="function"?hr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},rn;hr&&typeof hr.ownKeys=="function"?rn=hr.ownKeys:Object.getOwnPropertySymbols?rn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:rn=function(e){return Object.getOwnPropertyNames(e)};function ju(t){console&&console.warn&&console.warn(t)}var _s=Number.isNaN||function(e){return e!==e};function xe(){xe.init.call(this)}Wn.exports=xe,Wn.exports.once=qu,xe.EventEmitter=xe,xe.prototype._events=void 0,xe.prototype._eventsCount=0,xe.prototype._maxListeners=void 0;var bs=10;function nn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(xe,"defaultMaxListeners",{enumerable:!0,get:function(){return bs},set:function(t){if(typeof t!="number"||t<0||_s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");bs=t}}),xe.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},xe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||_s(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 ms(t){return t._maxListeners===void 0?xe.defaultMaxListeners:t._maxListeners}xe.prototype.getMaxListeners=function(){return ms(this)},xe.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")vs(f,this,r);else for(var h=f.length,l=Ss(f,h),n=0;n<h;++n)vs(l[n],this,r);return!0};function ws(t,e,r,n){var i,s,o;if(nn(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=ms(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,ju(a)}return t}xe.prototype.addListener=function(e,r){return ws(this,e,r,!1)},xe.prototype.on=xe.prototype.addListener,xe.prototype.prependListener=function(e,r){return ws(this,e,r,!0)};function Bu(){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 Es(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Bu.bind(n);return i.listener=r,n.wrapFn=i,i}xe.prototype.once=function(e,r){return nn(r),this.on(e,Es(this,e,r)),this},xe.prototype.prependOnceListener=function(e,r){return nn(r),this.prependListener(e,Es(this,e,r)),this},xe.prototype.removeListener=function(e,r){var n,i,s,o,a;if(nn(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():zu(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},xe.prototype.off=xe.prototype.removeListener,xe.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 Ds(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?Ku(i):Ss(i,i.length)}xe.prototype.listeners=function(e){return Ds(this,e,!0)},xe.prototype.rawListeners=function(e){return Ds(this,e,!1)},xe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):xs.call(t,e)},xe.prototype.listenerCount=xs;function xs(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}xe.prototype.eventNames=function(){return this._eventsCount>0?rn(this._events):[]};function Ss(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function zu(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Ku(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function qu(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))}Os(t,e,s,{once:!0}),e!=="error"&&Hu(t,i,{once:!0})})}function Hu(t,e,r){typeof t.on=="function"&&Os(t,"error",e,r)}function Os(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)}function Ye(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var kn=Ye;Ye.EventEmitter=Ye,Ye.prototype._events=void 0,Ye.prototype._maxListeners=void 0,Ye.defaultMaxListeners=10,Ye.prototype.setMaxListeners=function(t){if(!Vu(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ye.prototype.emit=function(t){var e,r,n,i,s,o;if(this._events||(this._events={}),t==="error"&&(!this._events.error||xr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var a=new Error('Uncaught, unspecified "error" event. ('+e+")");throw a.context=e,a}if(r=this._events[t],Ls(r))return!1;if(Mt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(xr(r))for(i=Array.prototype.slice.call(arguments,1),o=r.slice(),n=o.length,s=0;s<n;s++)o[s].apply(this,i);return!0},Ye.prototype.addListener=function(t,e){var r;if(!Mt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Mt(e.listener)?e.listener:e),this._events[t]?xr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,xr(this._events[t])&&!this._events[t].warned&&(Ls(this._maxListeners)?r=Ye.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ye.prototype.on=Ye.prototype.addListener,Ye.prototype.once=function(t,e){if(!Mt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ye.prototype.removeListener=function(t,e){var r,n,i,s;if(!Mt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Mt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(xr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ye.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Mt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ye.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Mt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ye.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Mt(e))return 1;if(e)return e.length}return 0},Ye.listenerCount=function(t,e){return t.listenerCount(e)};function Mt(t){return typeof t=="function"}function Vu(t){return typeof t=="number"}function xr(t){return typeof t=="object"&&t!==null}function Ls(t){return t===void 0}const Gu="PARSE_ERROR",Wu="INVALID_REQUEST",ku="METHOD_NOT_FOUND",Yu="INVALID_PARAMS",Is="INTERNAL_ERROR",Yn="SERVER_ERROR",Ju=[-32700,-32600,-32601,-32602,-32603],Sr={[Gu]:{code:-32700,message:"Parse error"},[Wu]:{code:-32600,message:"Invalid Request"},[ku]:{code:-32601,message:"Method not found"},[Yu]:{code:-32602,message:"Invalid params"},[Is]:{code:-32603,message:"Internal error"},[Yn]:{code:-32e3,message:"Server error"}},As=Yn;function Xu(t){return Ju.includes(t)}function Ts(t){return Object.keys(Sr).includes(t)?Sr[t]:Sr[As]}function Zu(t){const e=Object.values(Sr).find(r=>r.code===t);return e||Sr[As]}function Cs(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Rs={};/*! *****************************************************************************
1
+ (function(vt,He){typeof exports=="object"&&typeof module<"u"?He(exports):typeof define=="function"&&define.amd?define(["exports"],He):(vt=typeof globalThis<"u"?globalThis:vt||self,He(vt["@walletconnect/ethereum-provider"]={}))})(this,function(vt){"use strict";var He=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Kt(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Ze={exports:{}},nr=typeof Reflect=="object"?Reflect:null,qi=nr&&typeof nr.apply=="function"?nr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},qr;nr&&typeof nr.ownKeys=="function"?qr=nr.ownKeys:Object.getOwnPropertySymbols?qr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:qr=function(e){return Object.getOwnPropertyNames(e)};function uc(t){console&&console.warn&&console.warn(t)}var Hi=Number.isNaN||function(e){return e!==e};function Se(){Se.init.call(this)}Ze.exports=Se,Ze.exports.once=dc,Se.EventEmitter=Se,Se.prototype._events=void 0,Se.prototype._eventsCount=0,Se.prototype._maxListeners=void 0;var Ki=10;function Hr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Se,"defaultMaxListeners",{enumerable:!0,get:function(){return Ki},set:function(t){if(typeof t!="number"||t<0||Hi(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ki=t}}),Se.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},Se.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Hi(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 Vi(t){return t._maxListeners===void 0?Se.defaultMaxListeners:t._maxListeners}Se.prototype.getMaxListeners=function(){return Vi(this)},Se.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 c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")qi(f,this,r);else for(var h=f.length,l=Ji(f,h),n=0;n<h;++n)qi(l[n],this,r);return!0};function Gi(t,e,r,n){var i,s,o;if(Hr(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=Vi(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,uc(c)}return t}Se.prototype.addListener=function(e,r){return Gi(this,e,r,!1)},Se.prototype.on=Se.prototype.addListener,Se.prototype.prependListener=function(e,r){return Gi(this,e,r,!0)};function hc(){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 Wi(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=hc.bind(n);return i.listener=r,n.wrapFn=i,i}Se.prototype.once=function(e,r){return Hr(r),this.on(e,Wi(this,e,r)),this},Se.prototype.prependOnceListener=function(e,r){return Hr(r),this.prependListener(e,Wi(this,e,r)),this},Se.prototype.removeListener=function(e,r){var n,i,s,o,c;if(Hr(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){c=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():fc(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this},Se.prototype.off=Se.prototype.removeListener,Se.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 ki(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?lc(i):Ji(i,i.length)}Se.prototype.listeners=function(e){return ki(this,e,!0)},Se.prototype.rawListeners=function(e){return ki(this,e,!1)},Se.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Yi.call(t,e)},Se.prototype.listenerCount=Yi;function Yi(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}Se.prototype.eventNames=function(){return this._eventsCount>0?qr(this._events):[]};function Ji(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function fc(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function lc(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function dc(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))}Xi(t,e,s,{once:!0}),e!=="error"&&pc(t,i,{once:!0})})}function pc(t,e,r){typeof t.on=="function"&&Xi(t,"error",e,r)}function Xi(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)}const gc="PARSE_ERROR",yc="INVALID_REQUEST",_c="METHOD_NOT_FOUND",bc="INVALID_PARAMS",Zi="INTERNAL_ERROR",Dn="SERVER_ERROR",vc=[-32700,-32600,-32601,-32602,-32603],fr={[gc]:{code:-32700,message:"Parse error"},[yc]:{code:-32600,message:"Invalid Request"},[_c]:{code:-32601,message:"Method not found"},[bc]:{code:-32602,message:"Invalid params"},[Zi]:{code:-32603,message:"Internal error"},[Dn]:{code:-32e3,message:"Server error"}},Qi=Dn;function wc(t){return vc.includes(t)}function es(t){return Object.keys(fr).includes(t)?fr[t]:fr[Qi]}function mc(t){const e=Object.values(fr).find(r=>r.code===t);return e||fr[Qi]}function ts(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var rs={};/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -11,7 +11,7 @@
11
11
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */var Jn=function(t,e){return Jn=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])},Jn(t,e)};function Qu(t,e){Jn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Xn=function(){return Xn=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},Xn.apply(this,arguments)};function ef(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 tf(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 rf(t,e){return function(r,n){e(r,n,t)}}function nf(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function sf(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(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(a,f)}h((n=n.apply(t,e||[])).next())})}function of(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(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function af(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function cf(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zn(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 Ns(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 uf(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ns(arguments[e]));return t}function ff(){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 Or(t){return this instanceof Or?(this.v=t,this):new Or(t)}function hf(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(v){n[v]&&(i[v]=function(m){return new Promise(function(w,P){s.push([v,m,w,P])>1||a(v,m)})})}function a(v,m){try{f(n[v](m))}catch(w){D(s[0][3],w)}}function f(v){v.value instanceof Or?Promise.resolve(v.value.v).then(h,l):D(s[0][2],v)}function h(v){a("next",v)}function l(v){a("throw",v)}function D(v,m){v(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function lf(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:Or(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function df(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 Zn=="function"?Zn(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,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(h){s({value:h,done:a})},o)}}function pf(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function gf(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 yf(t){return t&&t.__esModule?t:{default:t}}function vf(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function _f(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var bf=Object.freeze({__proto__:null,__extends:Qu,get __assign(){return Xn},__rest:ef,__decorate:tf,__param:rf,__metadata:nf,__awaiter:sf,__generator:of,__createBinding:af,__exportStar:cf,__values:Zn,__read:Ns,__spread:uf,__spreadArrays:ff,__await:Or,__asyncGenerator:hf,__asyncDelegator:lf,__asyncValues:df,__makeTemplateObject:pf,__importStar:gf,__importDefault:yf,__classPrivateFieldGet:vf,__classPrivateFieldSet:_f}),mf=Zt(bf),Ut={},Ps;function wf(){if(Ps)return Ut;Ps=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.isBrowserCryptoAvailable=Ut.getSubtleCrypto=Ut.getBrowerCrypto=void 0;function t(){return ke?.crypto||ke?.msCrypto||{}}Ut.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Ut.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Ut.isBrowserCryptoAvailable=r,Ut}var jt={},$s;function Ef(){if($s)return jt;$s=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.isBrowser=jt.isNode=jt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}jt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}jt.isNode=e;function r(){return!t()&&!e()}return jt.isBrowser=r,jt}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=mf;e.__exportStar(wf(),t),e.__exportStar(Ef(),t)})(Rs);function Df(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function sn(t,e,r){return{id:r||Df(),jsonrpc:"2.0",method:t,params:e}}function on(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Lr(t,e,r){return{id:t,jsonrpc:"2.0",error:xf(e,r)}}function xf(t,e){return typeof t>"u"?Ts(Is):(typeof t=="string"&&(t=Object.assign(Object.assign({},Ts(Yn)),{message:t})),typeof e<"u"&&(t.data=e),Xu(t.code)&&(t=Zu(t.code)),t)}class Fs{}class Sf extends Fs{constructor(e){super()}}class Of extends Fs{constructor(){super()}}class Lf extends Of{constructor(e){super()}}const If="^https?:",Af="^wss?:";function Tf(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Ms(t,e){const r=Tf(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Us(t){return Ms(t,If)}function js(t){return Ms(t,Af)}function Cf(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Bs(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Qn(t){return Bs(t)&&"method"in t}function ei(t){return Bs(t)&&(Bt(t)||Ot(t))}function Bt(t){return"result"in t}function Ot(t){return"error"in t}class ti extends Lf{constructor(e){super(e),this.events=new kn.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(sn(e.method,e.params||[]),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=>{Ot(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),ei(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var ri={exports:{}};(function(t,e){var r=typeof self<"u"?self:ke,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function f(g){return g&&DataView.prototype.isPrototypeOf(g)}if(a.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(g){return g&&h.indexOf(Object.prototype.toString.call(g))>-1};function D(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(g))throw new TypeError("Invalid character in header field name");return g.toLowerCase()}function v(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var _={next:function(){var F=g.shift();return{done:F===void 0,value:F}}};return a.iterable&&(_[Symbol.iterator]=function(){return _}),_}function w(g){this.map={},g instanceof w?g.forEach(function(_,F){this.append(F,_)},this):Array.isArray(g)?g.forEach(function(_){this.append(_[0],_[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(_){this.append(_,g[_])},this)}w.prototype.append=function(g,_){g=D(g),_=v(_);var F=this.map[g];this.map[g]=F?F+", "+_:_},w.prototype.delete=function(g){delete this.map[D(g)]},w.prototype.get=function(g){return g=D(g),this.has(g)?this.map[g]:null},w.prototype.has=function(g){return this.map.hasOwnProperty(D(g))},w.prototype.set=function(g,_){this.map[D(g)]=v(_)},w.prototype.forEach=function(g,_){for(var F in this.map)this.map.hasOwnProperty(F)&&g.call(_,this.map[F],F,this)},w.prototype.keys=function(){var g=[];return this.forEach(function(_,F){g.push(F)}),m(g)},w.prototype.values=function(){var g=[];return this.forEach(function(_){g.push(_)}),m(g)},w.prototype.entries=function(){var g=[];return this.forEach(function(_,F){g.push([F,_])}),m(g)},a.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function P(g){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}function R(g){return new Promise(function(_,F){g.onload=function(){_(g.result)},g.onerror=function(){F(g.error)}})}function B(g){var _=new FileReader,F=R(_);return _.readAsArrayBuffer(g),F}function S(g){var _=new FileReader,F=R(_);return _.readAsText(g),F}function I(g){for(var _=new Uint8Array(g),F=new Array(_.length),M=0;M<_.length;M++)F[M]=String.fromCharCode(_[M]);return F.join("")}function y(g){if(g.slice)return g.slice(0);var _=new Uint8Array(g.byteLength);return _.set(new Uint8Array(g)),_.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(g){this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:a.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:a.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():a.arrayBuffer&&a.blob&&f(g)?(this._bodyArrayBuffer=y(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=y(g):this._bodyText=g=Object.prototype.toString.call(g):this._bodyText="",this.headers.get("content-type")||(typeof g=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var g=P(this);if(g)return g;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(){return this._bodyArrayBuffer?P(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var g=P(this);if(g)return g;if(this._bodyBlob)return S(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(U)}),this.json=function(){return this.text().then(JSON.parse)},this}var E=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function c(g){var _=g.toUpperCase();return E.indexOf(_)>-1?_:g}function d(g,_){_=_||{};var F=_.body;if(g instanceof d){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,_.headers||(this.headers=new w(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!F&&g._bodyInit!=null&&(F=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new w(_.headers)),this.method=c(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&F)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(F)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function U(g){var _=new FormData;return g.trim().split("&").forEach(function(F){if(F){var M=F.split("="),N=M.shift().replace(/\+/g," "),C=M.join("=").replace(/\+/g," ");_.append(decodeURIComponent(N),decodeURIComponent(C))}}),_}function K(g){var _=new w,F=g.replace(/\r?\n[\t ]+/g," ");return F.split(/\r?\n/).forEach(function(M){var N=M.split(":"),C=N.shift().trim();if(C){var j=N.join(":").trim();_.append(C,j)}}),_}x.call(d.prototype);function G(g,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new w(_.headers),this.url=_.url||"",this._initBody(g)}x.call(G.prototype),G.prototype.clone=function(){return new G(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},G.error=function(){var g=new G(null,{status:0,statusText:""});return g.type="error",g};var J=[301,302,303,307,308];G.redirect=function(g,_){if(J.indexOf(_)===-1)throw new RangeError("Invalid status code");return new G(null,{status:_,headers:{location:g}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(_,F){this.message=_,this.name=F;var M=Error(_);this.stack=M.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function X(g,_){return new Promise(function(F,M){var N=new d(g,_);if(N.signal&&N.signal.aborted)return M(new o.DOMException("Aborted","AbortError"));var C=new XMLHttpRequest;function j(){C.abort()}C.onload=function(){var z={status:C.status,statusText:C.statusText,headers:K(C.getAllResponseHeaders()||"")};z.url="responseURL"in C?C.responseURL:z.headers.get("X-Request-URL");var Q="response"in C?C.response:C.responseText;F(new G(Q,z))},C.onerror=function(){M(new TypeError("Network request failed"))},C.ontimeout=function(){M(new TypeError("Network request failed"))},C.onabort=function(){M(new o.DOMException("Aborted","AbortError"))},C.open(N.method,N.url,!0),N.credentials==="include"?C.withCredentials=!0:N.credentials==="omit"&&(C.withCredentials=!1),"responseType"in C&&a.blob&&(C.responseType="blob"),N.headers.forEach(function(z,Q){C.setRequestHeader(Q,z)}),N.signal&&(N.signal.addEventListener("abort",j),C.onreadystatechange=function(){C.readyState===4&&N.signal.removeEventListener("abort",j)}),C.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=w,s.Request=d,s.Response=G),o.Headers=w,o.Request=d,o.Response=G,o.fetch=X,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=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})(ri,ri.exports);var zs=Uu(ri.exports);function ni(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function Ir(t){return typeof t=="string"?t:JSON.stringify(t)}const Ks={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},qs=10;class Rf{constructor(e){if(this.url=e,this.events=new kn.EventEmitter,this.isAvailable=!1,this.registering=!1,!Us(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}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,r){this.isAvailable||await this.register();try{const n=Ir(e),s=await(await zs(this.url,Object.assign(Object.assign({},Ks),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!Us(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{const r=Ir({id:1,jsonrpc:"2.0",method:"test",params:[]});await zs(e,Object.assign(Object.assign({},Ks),{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"?ni(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Lr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return Cs(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>qs&&this.events.setMaxListeners(qs)}}var ii={},an={},re={},Hs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(a,f){var h=a>>>16&65535,l=a&65535,D=f>>>16&65535,v=f&65535;return l*v+(h*v+l*D<<16>>>0)|0}t.mul=Math.imul||e;function r(a,f){return a+f|0}t.add=r;function n(a,f){return a-f|0}t.sub=n;function i(a,f){return a<<f|a>>>32-f}t.rotl=i;function s(a,f){return a<<32-f|a>>>f}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(Hs),Object.defineProperty(re,"__esModule",{value:!0});var Vs=Hs;function Nf(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=Nf;function Pf(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=Pf;function $f(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=$f;function Ff(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=Ff;function Gs(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=Gs,re.writeInt16BE=Gs;function Ws(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=Ws,re.writeInt16LE=Ws;function si(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=si;function oi(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=oi;function ai(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=ai;function ci(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=ci;function cn(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=cn,re.writeInt32BE=cn;function un(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=un,re.writeInt32LE=un;function Mf(t,e){e===void 0&&(e=0);var r=si(t,e),n=si(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=Mf;function Uf(t,e){e===void 0&&(e=0);var r=oi(t,e),n=oi(t,e+4);return r*4294967296+n}re.readUint64BE=Uf;function jf(t,e){e===void 0&&(e=0);var r=ai(t,e),n=ai(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=jf;function Bf(t,e){e===void 0&&(e=0);var r=ci(t,e),n=ci(t,e+4);return n*4294967296+r}re.readUint64LE=Bf;function ks(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),cn(t/4294967296>>>0,e,r),cn(t>>>0,e,r+4),e}re.writeUint64BE=ks,re.writeInt64BE=ks;function Ys(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),un(t>>>0,e,r),un(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=Ys,re.writeInt64LE=Ys;function zf(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=zf;function Kf(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=Kf;function qf(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Vs.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=qf;function Hf(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Vs.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=Hf;function Vf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Vf;function Gf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Gf;function Wf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Wf;function kf(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=kf;function Yf(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=Yf;function Jf(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=Jf;function Xf(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=Xf;function Zf(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=Zf;var _t={};Object.defineProperty(_t,"__esModule",{value:!0});function Qf(t){for(var e=0;e<t.length;e++)t[e]=0;return t}_t.wipe=Qf,Object.defineProperty(an,"__esModule",{value:!0});var ct=re,ui=_t,eh=20;function th(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],f=r[7]<<24|r[6]<<16|r[5]<<8|r[4],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],l=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],v=r[23]<<24|r[22]<<16|r[21]<<8|r[20],m=r[27]<<24|r[26]<<16|r[25]<<8|r[24],w=r[31]<<24|r[30]<<16|r[29]<<8|r[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],R=e[7]<<24|e[6]<<16|e[5]<<8|e[4],B=e[11]<<24|e[10]<<16|e[9]<<8|e[8],S=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=n,y=i,x=s,E=o,c=a,d=f,U=h,K=l,G=D,J=v,X=m,g=w,_=P,F=R,M=B,N=S,C=0;C<eh;C+=2)I=I+c|0,_^=I,_=_>>>32-16|_<<16,G=G+_|0,c^=G,c=c>>>32-12|c<<12,y=y+d|0,F^=y,F=F>>>32-16|F<<16,J=J+F|0,d^=J,d=d>>>32-12|d<<12,x=x+U|0,M^=x,M=M>>>32-16|M<<16,X=X+M|0,U^=X,U=U>>>32-12|U<<12,E=E+K|0,N^=E,N=N>>>32-16|N<<16,g=g+N|0,K^=g,K=K>>>32-12|K<<12,x=x+U|0,M^=x,M=M>>>32-8|M<<8,X=X+M|0,U^=X,U=U>>>32-7|U<<7,E=E+K|0,N^=E,N=N>>>32-8|N<<8,g=g+N|0,K^=g,K=K>>>32-7|K<<7,y=y+d|0,F^=y,F=F>>>32-8|F<<8,J=J+F|0,d^=J,d=d>>>32-7|d<<7,I=I+c|0,_^=I,_=_>>>32-8|_<<8,G=G+_|0,c^=G,c=c>>>32-7|c<<7,I=I+d|0,N^=I,N=N>>>32-16|N<<16,X=X+N|0,d^=X,d=d>>>32-12|d<<12,y=y+U|0,_^=y,_=_>>>32-16|_<<16,g=g+_|0,U^=g,U=U>>>32-12|U<<12,x=x+K|0,F^=x,F=F>>>32-16|F<<16,G=G+F|0,K^=G,K=K>>>32-12|K<<12,E=E+c|0,M^=E,M=M>>>32-16|M<<16,J=J+M|0,c^=J,c=c>>>32-12|c<<12,x=x+K|0,F^=x,F=F>>>32-8|F<<8,G=G+F|0,K^=G,K=K>>>32-7|K<<7,E=E+c|0,M^=E,M=M>>>32-8|M<<8,J=J+M|0,c^=J,c=c>>>32-7|c<<7,y=y+U|0,_^=y,_=_>>>32-8|_<<8,g=g+_|0,U^=g,U=U>>>32-7|U<<7,I=I+d|0,N^=I,N=N>>>32-8|N<<8,X=X+N|0,d^=X,d=d>>>32-7|d<<7;ct.writeUint32LE(I+n|0,t,0),ct.writeUint32LE(y+i|0,t,4),ct.writeUint32LE(x+s|0,t,8),ct.writeUint32LE(E+o|0,t,12),ct.writeUint32LE(c+a|0,t,16),ct.writeUint32LE(d+f|0,t,20),ct.writeUint32LE(U+h|0,t,24),ct.writeUint32LE(K+l|0,t,28),ct.writeUint32LE(G+D|0,t,32),ct.writeUint32LE(J+v|0,t,36),ct.writeUint32LE(X+m|0,t,40),ct.writeUint32LE(g+w|0,t,44),ct.writeUint32LE(_+P|0,t,48),ct.writeUint32LE(F+R|0,t,52),ct.writeUint32LE(M+B|0,t,56),ct.writeUint32LE(N+S|0,t,60)}function Js(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}for(var a=new Uint8Array(64),f=0;f<r.length;f+=64){th(a,s,t);for(var h=f;h<f+64&&h<r.length;h++)n[h]=r[h]^a[h-f];nh(s,0,o)}return ui.wipe(a),i===0&&ui.wipe(s),n}an.streamXOR=Js;function rh(t,e,r,n){return n===void 0&&(n=0),ui.wipe(r),Js(t,e,r,r,n)}an.stream=rh;function nh(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var Xs={},Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});function ih(t,e,r){return~(t-1)&e|t-1&r}Vt.select=ih;function sh(t,e){return(t|0)-(e|0)-1>>>31&1}Vt.lessOrEqual=sh;function Zs(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Vt.compare=Zs;function oh(t,e){return t.length===0||e.length===0?!1:Zs(t,e)!==0}Vt.equal=oh,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vt,r=_t;t.DIGEST_LENGTH=16;var n=function(){function o(a){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=a[0]|a[1]<<8;this._r[0]=f&8191;var h=a[2]|a[3]<<8;this._r[1]=(f>>>13|h<<3)&8191;var l=a[4]|a[5]<<8;this._r[2]=(h>>>10|l<<6)&7939;var D=a[6]|a[7]<<8;this._r[3]=(l>>>7|D<<9)&8191;var v=a[8]|a[9]<<8;this._r[4]=(D>>>4|v<<12)&255,this._r[5]=v>>>1&8190;var m=a[10]|a[11]<<8;this._r[6]=(v>>>14|m<<2)&8191;var w=a[12]|a[13]<<8;this._r[7]=(m>>>11|w<<5)&8065;var P=a[14]|a[15]<<8;this._r[8]=(w>>>8|P<<8)&8191,this._r[9]=P>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,f,h){for(var l=this._fin?0:2048,D=this._h[0],v=this._h[1],m=this._h[2],w=this._h[3],P=this._h[4],R=this._h[5],B=this._h[6],S=this._h[7],I=this._h[8],y=this._h[9],x=this._r[0],E=this._r[1],c=this._r[2],d=this._r[3],U=this._r[4],K=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],g=this._r[9];h>=16;){var _=a[f+0]|a[f+1]<<8;D+=_&8191;var F=a[f+2]|a[f+3]<<8;v+=(_>>>13|F<<3)&8191;var M=a[f+4]|a[f+5]<<8;m+=(F>>>10|M<<6)&8191;var N=a[f+6]|a[f+7]<<8;w+=(M>>>7|N<<9)&8191;var C=a[f+8]|a[f+9]<<8;P+=(N>>>4|C<<12)&8191,R+=C>>>1&8191;var j=a[f+10]|a[f+11]<<8;B+=(C>>>14|j<<2)&8191;var z=a[f+12]|a[f+13]<<8;S+=(j>>>11|z<<5)&8191;var Q=a[f+14]|a[f+15]<<8;I+=(z>>>8|Q<<8)&8191,y+=Q>>>5|l;var q=0,ee=q;ee+=D*x,ee+=v*(5*g),ee+=m*(5*X),ee+=w*(5*J),ee+=P*(5*G),q=ee>>>13,ee&=8191,ee+=R*(5*K),ee+=B*(5*U),ee+=S*(5*d),ee+=I*(5*c),ee+=y*(5*E),q+=ee>>>13,ee&=8191;var Y=q;Y+=D*E,Y+=v*x,Y+=m*(5*g),Y+=w*(5*X),Y+=P*(5*J),q=Y>>>13,Y&=8191,Y+=R*(5*G),Y+=B*(5*K),Y+=S*(5*U),Y+=I*(5*d),Y+=y*(5*c),q+=Y>>>13,Y&=8191;var ae=q;ae+=D*c,ae+=v*E,ae+=m*x,ae+=w*(5*g),ae+=P*(5*X),q=ae>>>13,ae&=8191,ae+=R*(5*J),ae+=B*(5*G),ae+=S*(5*K),ae+=I*(5*U),ae+=y*(5*d),q+=ae>>>13,ae&=8191;var T=q;T+=D*d,T+=v*c,T+=m*E,T+=w*x,T+=P*(5*g),q=T>>>13,T&=8191,T+=R*(5*X),T+=B*(5*J),T+=S*(5*G),T+=I*(5*K),T+=y*(5*U),q+=T>>>13,T&=8191;var A=q;A+=D*U,A+=v*d,A+=m*c,A+=w*E,A+=P*x,q=A>>>13,A&=8191,A+=R*(5*g),A+=B*(5*X),A+=S*(5*J),A+=I*(5*G),A+=y*(5*K),q+=A>>>13,A&=8191;var O=q;O+=D*K,O+=v*U,O+=m*d,O+=w*c,O+=P*E,q=O>>>13,O&=8191,O+=R*x,O+=B*(5*g),O+=S*(5*X),O+=I*(5*J),O+=y*(5*G),q+=O>>>13,O&=8191;var u=q;u+=D*G,u+=v*K,u+=m*U,u+=w*d,u+=P*c,q=u>>>13,u&=8191,u+=R*E,u+=B*x,u+=S*(5*g),u+=I*(5*X),u+=y*(5*J),q+=u>>>13,u&=8191;var b=q;b+=D*J,b+=v*G,b+=m*K,b+=w*U,b+=P*d,q=b>>>13,b&=8191,b+=R*c,b+=B*E,b+=S*x,b+=I*(5*g),b+=y*(5*X),q+=b>>>13,b&=8191;var H=q;H+=D*X,H+=v*J,H+=m*G,H+=w*K,H+=P*U,q=H>>>13,H&=8191,H+=R*d,H+=B*c,H+=S*E,H+=I*x,H+=y*(5*g),q+=H>>>13,H&=8191;var W=q;W+=D*g,W+=v*X,W+=m*J,W+=w*G,W+=P*K,q=W>>>13,W&=8191,W+=R*U,W+=B*d,W+=S*c,W+=I*E,W+=y*x,q+=W>>>13,W&=8191,q=(q<<2)+q|0,q=q+ee|0,ee=q&8191,q=q>>>13,Y+=q,D=ee,v=Y,m=ae,w=T,P=A,R=O,B=u,S=b,I=H,y=W,f+=16,h-=16}this._h[0]=D,this._h[1]=v,this._h[2]=m,this._h[3]=w,this._h[4]=P,this._h[5]=R,this._h[6]=B,this._h[7]=S,this._h[8]=I,this._h[9]=y},o.prototype.finish=function(a,f){f===void 0&&(f=0);var h=new Uint16Array(10),l,D,v,m;if(this._leftover){for(m=this._leftover,this._buffer[m++]=1;m<16;m++)this._buffer[m]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(l=this._h[1]>>>13,this._h[1]&=8191,m=2;m<10;m++)this._h[m]+=l,l=this._h[m]>>>13,this._h[m]&=8191;for(this._h[0]+=l*5,l=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=l,l=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=l,h[0]=this._h[0]+5,l=h[0]>>>13,h[0]&=8191,m=1;m<10;m++)h[m]=this._h[m]+l,l=h[m]>>>13,h[m]&=8191;for(h[9]-=1<<13,D=(l^1)-1,m=0;m<10;m++)h[m]&=D;for(D=~D,m=0;m<10;m++)this._h[m]=this._h[m]&D|h[m];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,v=this._h[0]+this._pad[0],this._h[0]=v&65535,m=1;m<8;m++)v=(this._h[m]+this._pad[m]|0)+(v>>>16)|0,this._h[m]=v&65535;return a[f+0]=this._h[0]>>>0,a[f+1]=this._h[0]>>>8,a[f+2]=this._h[1]>>>0,a[f+3]=this._h[1]>>>8,a[f+4]=this._h[2]>>>0,a[f+5]=this._h[2]>>>8,a[f+6]=this._h[3]>>>0,a[f+7]=this._h[3]>>>8,a[f+8]=this._h[4]>>>0,a[f+9]=this._h[4]>>>8,a[f+10]=this._h[5]>>>0,a[f+11]=this._h[5]>>>8,a[f+12]=this._h[6]>>>0,a[f+13]=this._h[6]>>>8,a[f+14]=this._h[7]>>>0,a[f+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var f=0,h=a.length,l;if(this._leftover){l=16-this._leftover,l>h&&(l=h);for(var D=0;D<l;D++)this._buffer[this._leftover+D]=a[f+D];if(h-=l,f+=l,this._leftover+=l,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(l=h-h%16,this._blocks(a,f,l),f+=l,h-=l),h){for(var D=0;D<h;D++)this._buffer[this._leftover+D]=a[f+D];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var a=new Uint8Array(16);return this.finish(a),a},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=n;function i(o,a){var f=new n(o);f.update(a);var h=f.digest();return f.clean(),h}t.oneTimeAuth=i;function s(o,a){return o.length!==t.DIGEST_LENGTH||a.length!==t.DIGEST_LENGTH?!1:e.equal(o,a)}t.equal=s}(Xs),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=an,r=Xs,n=_t,i=re,s=Vt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),a=function(){function f(h){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,h.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return f.prototype.seal=function(h,l,D,v){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var m=new Uint8Array(16);m.set(h,m.length-h.length);var w=new Uint8Array(32);e.stream(this._key,m,w,4);var P=l.length+this.tagLength,R;if(v){if(v.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");R=v}else R=new Uint8Array(P);return e.streamXOR(this._key,m,l,R,4),this._authenticate(R.subarray(R.length-this.tagLength,R.length),w,R.subarray(0,R.length-this.tagLength),D),n.wipe(m),R},f.prototype.open=function(h,l,D,v){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(l.length<this.tagLength)return null;var m=new Uint8Array(16);m.set(h,m.length-h.length);var w=new Uint8Array(32);e.stream(this._key,m,w,4);var P=new Uint8Array(this.tagLength);if(this._authenticate(P,w,l.subarray(0,l.length-this.tagLength),D),!s.equal(P,l.subarray(l.length-this.tagLength,l.length)))return null;var R=l.length-this.tagLength,B;if(v){if(v.length!==R)throw new Error("ChaCha20Poly1305: incorrect destination length");B=v}else B=new Uint8Array(R);return e.streamXOR(this._key,m,l.subarray(0,l.length-this.tagLength),B,4),n.wipe(m),B},f.prototype.clean=function(){return n.wipe(this._key),this},f.prototype._authenticate=function(h,l,D,v){var m=new r.Poly1305(l);v&&(m.update(v),v.length%16>0&&m.update(o.subarray(v.length%16))),m.update(D),D.length%16>0&&m.update(o.subarray(D.length%16));var w=new Uint8Array(8);v&&i.writeUint64LE(v.length,w),m.update(w),i.writeUint64LE(D.length,w),m.update(w);for(var P=m.digest(),R=0;R<P.length;R++)h[R]=P[R];m.clean(),n.wipe(P),n.wipe(w)},f}();t.ChaCha20Poly1305=a}(ii);var Qs={},Ar={},fi={};Object.defineProperty(fi,"__esModule",{value:!0});function ah(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}fi.isSerializableHash=ah,Object.defineProperty(Ar,"__esModule",{value:!0});var At=fi,ch=Vt,uh=_t,eo=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),At.isSerializableHash(this._inner)&&At.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),uh.wipe(n)}return t.prototype.reset=function(){if(!At.isSerializableHash(this._inner)||!At.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){At.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),At.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!At.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!At.isSerializableHash(this._inner)||!At.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!At.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();Ar.HMAC=eo;function fh(t,e,r){var n=new eo(t,e);n.update(r);var i=n.digest();return n.clean(),i}Ar.hmac=fh,Ar.equal=ch.equal,Object.defineProperty(Qs,"__esModule",{value:!0});var to=Ar,ro=_t,hh=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=to.hmac(this._hash,n,r);this._hmac=new to.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),ro.wipe(this._buffer),ro.wipe(this._counter),this._bufpos=0},t}(),lh=Qs.HKDF=hh,lr={},fn={},hn={};Object.defineProperty(hn,"__esModule",{value:!0}),hn.BrowserRandomSource=void 0;const no=65536;class dh{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let n=0;n<r.length;n+=no)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,no)));return r}}hn.BrowserRandomSource=dh;function ph(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ln={},gh={},yh=Object.freeze({__proto__:null,default:gh}),vh=Zt(yh);Object.defineProperty(ln,"__esModule",{value:!0}),ln.NodeRandomSource=void 0;const _h=_t;class bh{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ph<"u"){const e=vh;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(e);for(let i=0;i<n.length;i++)n[i]=r[i];return(0,_h.wipe)(r),n}}ln.NodeRandomSource=bh,Object.defineProperty(fn,"__esModule",{value:!0}),fn.SystemRandomSource=void 0;const mh=hn,wh=ln;class Eh{constructor(){if(this.isAvailable=!1,this.name="",this._source=new mh.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new wh.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}fn.SystemRandomSource=Eh,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=fn,r=re,n=_t;t.defaultRandomSource=new e.SystemRandomSource;function i(h,l=t.defaultRandomSource){return l.randomBytes(h)}t.randomBytes=i;function s(h=t.defaultRandomSource){const l=i(4,h),D=(0,r.readUint32LE)(l);return(0,n.wipe)(l),D}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function a(h,l=o,D=t.defaultRandomSource){if(l.length<2)throw new Error("randomString charset is too short");if(l.length>256)throw new Error("randomString charset is too long");let v="";const m=l.length,w=256-256%m;for(;h>0;){const P=i(Math.ceil(h*256/w),D);for(let R=0;R<P.length&&h>0;R++){const B=P[R];B<w&&(v+=l.charAt(B%m),h--)}(0,n.wipe)(P)}return v}t.randomString=a;function f(h,l=o,D=t.defaultRandomSource){const v=Math.ceil(h/(Math.log(l.length)/Math.LN2));return a(v,l,D)}t.randomStringForEntropy=f}(lr);var dn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=_t;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function a(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return a.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},a.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},a.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},a.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._temp,this._state,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},a.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,v=h<<3,m=h%64<56?64:128;this._buffer[l]=128;for(var w=l+1;w<m-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(v,this._buffer,m-4),s(this._temp,this._state,this._buffer,0,m),this._finished=!0}for(var w=0;w<this.digestLength/4;w++)e.writeUint32BE(this._state[w],f,w*4);return this},a.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},a.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(f){return this._state.set(f.state),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(f){r.wipe(f.state),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},a}();t.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(a,f,h,l,D){for(;D>=64;){for(var v=f[0],m=f[1],w=f[2],P=f[3],R=f[4],B=f[5],S=f[6],I=f[7],y=0;y<16;y++){var x=l+y*4;a[y]=e.readUint32BE(h,x)}for(var y=16;y<64;y++){var E=a[y-2],c=(E>>>17|E<<32-17)^(E>>>19|E<<32-19)^E>>>10;E=a[y-15];var d=(E>>>7|E<<32-7)^(E>>>18|E<<32-18)^E>>>3;a[y]=(c+a[y-7]|0)+(d+a[y-16]|0)}for(var y=0;y<64;y++){var c=(((R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7))+(R&B^~R&S)|0)+(I+(i[y]+a[y]|0)|0)|0,d=((v>>>2|v<<32-2)^(v>>>13|v<<32-13)^(v>>>22|v<<32-22))+(v&m^v&w^m&w)|0;I=S,S=B,B=R,R=P+c|0,P=w,w=m,m=v,v=c+d|0}f[0]+=v,f[1]+=m,f[2]+=w,f[3]+=P,f[4]+=R,f[5]+=B,f[6]+=S,f[7]+=I,l+=64,D-=64}return l}function o(a){var f=new n;f.update(a);var h=f.digest();return f.clean(),h}t.hash=o})(dn);var hi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=lr,r=_t;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(y){const x=new Float64Array(16);if(y)for(let E=0;E<y.length;E++)x[E]=y[E];return x}const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(y){let x=1;for(let E=0;E<16;E++){let c=y[E]+x+65535;x=Math.floor(c/65536),y[E]=c-x*65536}y[0]+=x-1+37*(x-1)}function a(y,x,E){const c=~(E-1);for(let d=0;d<16;d++){const U=c&(y[d]^x[d]);y[d]^=U,x[d]^=U}}function f(y,x){const E=n(),c=n();for(let d=0;d<16;d++)c[d]=x[d];o(c),o(c),o(c);for(let d=0;d<2;d++){E[0]=c[0]-65517;for(let K=1;K<15;K++)E[K]=c[K]-65535-(E[K-1]>>16&1),E[K-1]&=65535;E[15]=c[15]-32767-(E[14]>>16&1);const U=E[15]>>16&1;E[14]&=65535,a(c,E,1-U)}for(let d=0;d<16;d++)y[2*d]=c[d]&255,y[2*d+1]=c[d]>>8}function h(y,x){for(let E=0;E<16;E++)y[E]=x[2*E]+(x[2*E+1]<<8);y[15]&=32767}function l(y,x,E){for(let c=0;c<16;c++)y[c]=x[c]+E[c]}function D(y,x,E){for(let c=0;c<16;c++)y[c]=x[c]-E[c]}function v(y,x,E){let c,d,U=0,K=0,G=0,J=0,X=0,g=0,_=0,F=0,M=0,N=0,C=0,j=0,z=0,Q=0,q=0,ee=0,Y=0,ae=0,T=0,A=0,O=0,u=0,b=0,H=0,W=0,he=0,ve=0,de=0,me=0,Be=0,$e=0,ye=E[0],pe=E[1],le=E[2],ue=E[3],ce=E[4],oe=E[5],se=E[6],te=E[7],fe=E[8],ge=E[9],ne=E[10],_e=E[11],be=E[12],Ee=E[13],De=E[14],we=E[15];c=x[0],U+=c*ye,K+=c*pe,G+=c*le,J+=c*ue,X+=c*ce,g+=c*oe,_+=c*se,F+=c*te,M+=c*fe,N+=c*ge,C+=c*ne,j+=c*_e,z+=c*be,Q+=c*Ee,q+=c*De,ee+=c*we,c=x[1],K+=c*ye,G+=c*pe,J+=c*le,X+=c*ue,g+=c*ce,_+=c*oe,F+=c*se,M+=c*te,N+=c*fe,C+=c*ge,j+=c*ne,z+=c*_e,Q+=c*be,q+=c*Ee,ee+=c*De,Y+=c*we,c=x[2],G+=c*ye,J+=c*pe,X+=c*le,g+=c*ue,_+=c*ce,F+=c*oe,M+=c*se,N+=c*te,C+=c*fe,j+=c*ge,z+=c*ne,Q+=c*_e,q+=c*be,ee+=c*Ee,Y+=c*De,ae+=c*we,c=x[3],J+=c*ye,X+=c*pe,g+=c*le,_+=c*ue,F+=c*ce,M+=c*oe,N+=c*se,C+=c*te,j+=c*fe,z+=c*ge,Q+=c*ne,q+=c*_e,ee+=c*be,Y+=c*Ee,ae+=c*De,T+=c*we,c=x[4],X+=c*ye,g+=c*pe,_+=c*le,F+=c*ue,M+=c*ce,N+=c*oe,C+=c*se,j+=c*te,z+=c*fe,Q+=c*ge,q+=c*ne,ee+=c*_e,Y+=c*be,ae+=c*Ee,T+=c*De,A+=c*we,c=x[5],g+=c*ye,_+=c*pe,F+=c*le,M+=c*ue,N+=c*ce,C+=c*oe,j+=c*se,z+=c*te,Q+=c*fe,q+=c*ge,ee+=c*ne,Y+=c*_e,ae+=c*be,T+=c*Ee,A+=c*De,O+=c*we,c=x[6],_+=c*ye,F+=c*pe,M+=c*le,N+=c*ue,C+=c*ce,j+=c*oe,z+=c*se,Q+=c*te,q+=c*fe,ee+=c*ge,Y+=c*ne,ae+=c*_e,T+=c*be,A+=c*Ee,O+=c*De,u+=c*we,c=x[7],F+=c*ye,M+=c*pe,N+=c*le,C+=c*ue,j+=c*ce,z+=c*oe,Q+=c*se,q+=c*te,ee+=c*fe,Y+=c*ge,ae+=c*ne,T+=c*_e,A+=c*be,O+=c*Ee,u+=c*De,b+=c*we,c=x[8],M+=c*ye,N+=c*pe,C+=c*le,j+=c*ue,z+=c*ce,Q+=c*oe,q+=c*se,ee+=c*te,Y+=c*fe,ae+=c*ge,T+=c*ne,A+=c*_e,O+=c*be,u+=c*Ee,b+=c*De,H+=c*we,c=x[9],N+=c*ye,C+=c*pe,j+=c*le,z+=c*ue,Q+=c*ce,q+=c*oe,ee+=c*se,Y+=c*te,ae+=c*fe,T+=c*ge,A+=c*ne,O+=c*_e,u+=c*be,b+=c*Ee,H+=c*De,W+=c*we,c=x[10],C+=c*ye,j+=c*pe,z+=c*le,Q+=c*ue,q+=c*ce,ee+=c*oe,Y+=c*se,ae+=c*te,T+=c*fe,A+=c*ge,O+=c*ne,u+=c*_e,b+=c*be,H+=c*Ee,W+=c*De,he+=c*we,c=x[11],j+=c*ye,z+=c*pe,Q+=c*le,q+=c*ue,ee+=c*ce,Y+=c*oe,ae+=c*se,T+=c*te,A+=c*fe,O+=c*ge,u+=c*ne,b+=c*_e,H+=c*be,W+=c*Ee,he+=c*De,ve+=c*we,c=x[12],z+=c*ye,Q+=c*pe,q+=c*le,ee+=c*ue,Y+=c*ce,ae+=c*oe,T+=c*se,A+=c*te,O+=c*fe,u+=c*ge,b+=c*ne,H+=c*_e,W+=c*be,he+=c*Ee,ve+=c*De,de+=c*we,c=x[13],Q+=c*ye,q+=c*pe,ee+=c*le,Y+=c*ue,ae+=c*ce,T+=c*oe,A+=c*se,O+=c*te,u+=c*fe,b+=c*ge,H+=c*ne,W+=c*_e,he+=c*be,ve+=c*Ee,de+=c*De,me+=c*we,c=x[14],q+=c*ye,ee+=c*pe,Y+=c*le,ae+=c*ue,T+=c*ce,A+=c*oe,O+=c*se,u+=c*te,b+=c*fe,H+=c*ge,W+=c*ne,he+=c*_e,ve+=c*be,de+=c*Ee,me+=c*De,Be+=c*we,c=x[15],ee+=c*ye,Y+=c*pe,ae+=c*le,T+=c*ue,A+=c*ce,O+=c*oe,u+=c*se,b+=c*te,H+=c*fe,W+=c*ge,he+=c*ne,ve+=c*_e,de+=c*be,me+=c*Ee,Be+=c*De,$e+=c*we,U+=38*Y,K+=38*ae,G+=38*T,J+=38*A,X+=38*O,g+=38*u,_+=38*b,F+=38*H,M+=38*W,N+=38*he,C+=38*ve,j+=38*de,z+=38*me,Q+=38*Be,q+=38*$e,d=1,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=K+d+65535,d=Math.floor(c/65536),K=c-d*65536,c=G+d+65535,d=Math.floor(c/65536),G=c-d*65536,c=J+d+65535,d=Math.floor(c/65536),J=c-d*65536,c=X+d+65535,d=Math.floor(c/65536),X=c-d*65536,c=g+d+65535,d=Math.floor(c/65536),g=c-d*65536,c=_+d+65535,d=Math.floor(c/65536),_=c-d*65536,c=F+d+65535,d=Math.floor(c/65536),F=c-d*65536,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=N+d+65535,d=Math.floor(c/65536),N=c-d*65536,c=C+d+65535,d=Math.floor(c/65536),C=c-d*65536,c=j+d+65535,d=Math.floor(c/65536),j=c-d*65536,c=z+d+65535,d=Math.floor(c/65536),z=c-d*65536,c=Q+d+65535,d=Math.floor(c/65536),Q=c-d*65536,c=q+d+65535,d=Math.floor(c/65536),q=c-d*65536,c=ee+d+65535,d=Math.floor(c/65536),ee=c-d*65536,U+=d-1+37*(d-1),d=1,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=K+d+65535,d=Math.floor(c/65536),K=c-d*65536,c=G+d+65535,d=Math.floor(c/65536),G=c-d*65536,c=J+d+65535,d=Math.floor(c/65536),J=c-d*65536,c=X+d+65535,d=Math.floor(c/65536),X=c-d*65536,c=g+d+65535,d=Math.floor(c/65536),g=c-d*65536,c=_+d+65535,d=Math.floor(c/65536),_=c-d*65536,c=F+d+65535,d=Math.floor(c/65536),F=c-d*65536,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=N+d+65535,d=Math.floor(c/65536),N=c-d*65536,c=C+d+65535,d=Math.floor(c/65536),C=c-d*65536,c=j+d+65535,d=Math.floor(c/65536),j=c-d*65536,c=z+d+65535,d=Math.floor(c/65536),z=c-d*65536,c=Q+d+65535,d=Math.floor(c/65536),Q=c-d*65536,c=q+d+65535,d=Math.floor(c/65536),q=c-d*65536,c=ee+d+65535,d=Math.floor(c/65536),ee=c-d*65536,U+=d-1+37*(d-1),y[0]=U,y[1]=K,y[2]=G,y[3]=J,y[4]=X,y[5]=g,y[6]=_,y[7]=F,y[8]=M,y[9]=N,y[10]=C,y[11]=j,y[12]=z,y[13]=Q,y[14]=q,y[15]=ee}function m(y,x){v(y,x,x)}function w(y,x){const E=n();for(let c=0;c<16;c++)E[c]=x[c];for(let c=253;c>=0;c--)m(E,E),c!==2&&c!==4&&v(E,E,x);for(let c=0;c<16;c++)y[c]=E[c]}function P(y,x){const E=new Uint8Array(32),c=new Float64Array(80),d=n(),U=n(),K=n(),G=n(),J=n(),X=n();for(let M=0;M<31;M++)E[M]=y[M];E[31]=y[31]&127|64,E[0]&=248,h(c,x);for(let M=0;M<16;M++)U[M]=c[M];d[0]=G[0]=1;for(let M=254;M>=0;--M){const N=E[M>>>3]>>>(M&7)&1;a(d,U,N),a(K,G,N),l(J,d,K),D(d,d,K),l(K,U,G),D(U,U,G),m(G,J),m(X,d),v(d,K,d),v(K,U,J),l(J,d,K),D(d,d,K),m(U,d),D(K,G,X),v(d,K,s),l(d,d,G),v(K,K,d),v(d,G,X),v(G,U,c),m(U,J),a(d,U,N),a(K,G,N)}for(let M=0;M<16;M++)c[M+16]=d[M],c[M+32]=K[M],c[M+48]=U[M],c[M+64]=G[M];const g=c.subarray(32),_=c.subarray(16);w(g,g),v(_,_,g);const F=new Uint8Array(32);return f(F,_),F}t.scalarMult=P;function R(y){return P(y,i)}t.scalarMultBase=R;function B(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const x=new Uint8Array(y);return{publicKey:R(x),secretKey:x}}t.generateKeyPairFromSeed=B;function S(y){const x=(0,e.randomBytes)(32,y),E=B(x);return(0,r.wipe)(x),E}t.generateKeyPair=S;function I(y,x,E=!1){if(y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(x.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const c=P(y,x);if(E){let d=0;for(let U=0;U<c.length;U++)d|=c[U];if(d===0)throw new Error("X25519: invalid shared key")}return c}t.sharedKey=I})(hi);function io(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function li(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=io(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Dh(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,f=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var P=0,R=0,B=0,S=w.length;B!==S&&w[B]===0;)B++,P++;for(var I=(S-B)*l+1>>>0,y=new Uint8Array(I);B!==S;){for(var x=w[B],E=0,c=I-1;(x!==0||E<R)&&c!==-1;c--,E++)x+=256*y[c]>>>0,y[c]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");R=E,B++}for(var d=I-R;d!==I&&y[d]===0;)d++;for(var U=f.repeat(P);d<I;++d)U+=t.charAt(y[d]);return U}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var P=0;if(w[P]!==" "){for(var R=0,B=0;w[P]===f;)R++,P++;for(var S=(w.length-P)*h+1>>>0,I=new Uint8Array(S);w[P];){var y=r[w.charCodeAt(P)];if(y===255)return;for(var x=0,E=S-1;(y!==0||x<B)&&E!==-1;E--,x++)y+=a*I[E]>>>0,I[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=x,P++}if(w[P]!==" "){for(var c=S-B;c!==S&&I[c]===0;)c++;for(var d=new Uint8Array(R+(S-c)),U=R;c!==S;)d[U++]=I[c++];return d}}}function m(w){var P=v(w);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:v,decode:m}}var xh=Dh,Sh=xh;const so=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")},Oh=t=>new TextEncoder().encode(t),Lh=t=>new TextDecoder().decode(t);class Ih{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 Ah{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 oo(this,e)}}class Th{constructor(e){this.decoders=e}or(e){return oo(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 oo=(t,e)=>new Th({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Ch{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ih(e,r,n),this.decoder=new Ah(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pn=({name:t,prefix:e,encode:r,decode:n})=>new Ch(t,e,r,n),Tr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Sh(r,e);return pn({prefix:t,name:e,encode:n,decode:s=>so(i(s))})},Rh=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,a+=r,a>=8&&(a-=8,o[h++]=255&f>>a)}if(a>=r||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},Nh=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],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},it=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>pn({prefix:e,name:t,encode(i){return Nh(i,n,r)},decode(i){return Rh(i,n,r,t)}}),Ph=pn({prefix:"\0",name:"identity",encode:t=>Lh(t),decode:t=>Oh(t)});var $h=Object.freeze({__proto__:null,identity:Ph});const Fh=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mh=Object.freeze({__proto__:null,base2:Fh});const Uh=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jh=Object.freeze({__proto__:null,base8:Uh});const Bh=Tr({prefix:"9",name:"base10",alphabet:"0123456789"});var zh=Object.freeze({__proto__:null,base10:Bh});const Kh=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qh=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Hh=Object.freeze({__proto__:null,base16:Kh,base16upper:qh});const Vh=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gh=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wh=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),kh=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yh=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jh=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xh=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zh=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qh=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var el=Object.freeze({__proto__:null,base32:Vh,base32upper:Gh,base32pad:Wh,base32padupper:kh,base32hex:Yh,base32hexupper:Jh,base32hexpad:Xh,base32hexpadupper:Zh,base32z:Qh});const tl=Tr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rl=Tr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nl=Object.freeze({__proto__:null,base36:tl,base36upper:rl});const il=Tr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sl=Tr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ol=Object.freeze({__proto__:null,base58btc:il,base58flickr:sl});const al=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),cl=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ul=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fl=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var hl=Object.freeze({__proto__:null,base64:al,base64pad:cl,base64url:ul,base64urlpad:fl});const ao=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ll=ao.reduce((t,e,r)=>(t[r]=e,t),[]),dl=ao.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function pl(t){return t.reduce((e,r)=>(e+=ll[r],e),"")}function gl(t){const e=[];for(const r of t){const n=dl[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const yl=pn({prefix:"\u{1F680}",name:"base256emoji",encode:pl,decode:gl});var vl=Object.freeze({__proto__:null,base256emoji:yl}),_l=uo,co=128,bl=127,ml=~bl,wl=Math.pow(2,31);function uo(t,e,r){e=e||[],r=r||0;for(var n=r;t>=wl;)e[r++]=t&255|co,t/=128;for(;t&ml;)e[r++]=t&255|co,t>>>=7;return e[r]=t|0,uo.bytes=r-n+1,e}var El=di,Dl=128,fo=127;function di(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw di.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&fo)<<i:(o&fo)*Math.pow(2,i),i+=7}while(o>=Dl);return di.bytes=s-n,r}var xl=Math.pow(2,7),Sl=Math.pow(2,14),Ol=Math.pow(2,21),Ll=Math.pow(2,28),Il=Math.pow(2,35),Al=Math.pow(2,42),Tl=Math.pow(2,49),Cl=Math.pow(2,56),Rl=Math.pow(2,63),Nl=function(t){return t<xl?1:t<Sl?2:t<Ol?3:t<Ll?4:t<Il?5:t<Al?6:t<Tl?7:t<Cl?8:t<Rl?9:10},Pl={encode:_l,decode:El,encodingLength:Nl},ho=Pl;const lo=(t,e,r=0)=>(ho.encode(t,e,r),e),po=t=>ho.encodingLength(t),pi=(t,e)=>{const r=e.byteLength,n=po(t),i=n+po(r),s=new Uint8Array(i+r);return lo(t,s,0),lo(r,s,n),s.set(e,i),new $l(t,r,e,s)};class $l{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const go=({name:t,code:e,encode:r})=>new Fl(t,e,r);class Fl{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?pi(this.code,r):r.then(n=>pi(this.code,n))}else throw Error("Unknown type, must be binary type")}}const yo=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ml=go({name:"sha2-256",code:18,encode:yo("SHA-256")}),Ul=go({name:"sha2-512",code:19,encode:yo("SHA-512")});var jl=Object.freeze({__proto__:null,sha256:Ml,sha512:Ul});const vo=0,Bl="identity",_o=so;var zl=Object.freeze({__proto__:null,identity:{code:vo,name:Bl,encode:_o,digest:t=>pi(vo,_o(t))}});new TextEncoder,new TextDecoder;const bo={...$h,...Mh,...jh,...zh,...Hh,...el,...nl,...ol,...hl,...vl};({...jl,...zl});function mo(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const wo=mo("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),gi=mo("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=io(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Eo={utf8:wo,"utf-8":wo,hex:bo.base16,latin1:gi,ascii:gi,binary:gi,...bo};function dt(t,e="utf8"){const r=Eo[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 pt(t,e="utf8"){const r=Eo[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)}var Do=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))},Kl=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),ql=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Hl=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}(),Vl=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Gl=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Wl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,kl=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,xo=3,Yl=[["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",Wl]],So=[["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 Jl(t){return t?Oo(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Gl:typeof navigator<"u"?Oo(navigator.userAgent):Ql()}function Xl(t){return t!==""&&Yl.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 Oo(t){var e=Xl(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Vl;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<xo&&(i=Do(Do([],i,!0),ed(xo-i.length),!0)):i=[];var s=i.join("."),o=Zl(t),a=kl.exec(t);return a&&a[1]?new Hl(r,s,o,a[1]):new Kl(r,s,o)}function Zl(t){for(var e=0,r=So.length;e<r;e++){var n=So[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function Ql(){var t=typeof process<"u"&&process.version;return t?new ql(process.version.slice(1)):null}function ed(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Z={};/*! *****************************************************************************
14
+ ***************************************************************************** */var Sn=function(t,e){return Sn=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])},Sn(t,e)};function Ec(t,e){Sn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var xn=function(){return xn=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},xn.apply(this,arguments)};function Dc(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 Sc(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 xc(t,e){return function(r,n){e(r,n,t)}}function Oc(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ic(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 c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Ac(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Tc(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Pc(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function On(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 ns(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(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Rc(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ns(arguments[e]));return t}function Cc(){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,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function lr(t){return this instanceof lr?(this.v=t,this):new lr(t)}function Nc(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(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof lr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Fc(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:lr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Lc(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 On=="function"?On(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(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Uc(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function $c(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 Mc(t){return t&&t.__esModule?t:{default:t}}function jc(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Bc(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var zc=Object.freeze({__proto__:null,__extends:Ec,get __assign(){return xn},__rest:Dc,__decorate:Sc,__param:xc,__metadata:Oc,__awaiter:Ic,__generator:Ac,__createBinding:Tc,__exportStar:Pc,__values:On,__read:ns,__spread:Rc,__spreadArrays:Cc,__await:lr,__asyncGenerator:Nc,__asyncDelegator:Fc,__asyncValues:Lc,__makeTemplateObject:Uc,__importStar:$c,__importDefault:Mc,__classPrivateFieldGet:jc,__classPrivateFieldSet:Bc}),qc=Kt(zc),Pt={},is;function Hc(){if(is)return Pt;is=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.isBrowserCryptoAvailable=Pt.getSubtleCrypto=Pt.getBrowerCrypto=void 0;function t(){return He?.crypto||He?.msCrypto||{}}Pt.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Pt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Pt.isBrowserCryptoAvailable=r,Pt}var Rt={},ss;function Kc(){if(ss)return Rt;ss=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.isBrowser=Rt.isNode=Rt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Rt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Rt.isNode=e;function r(){return!t()&&!e()}return Rt.isBrowser=r,Rt}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=qc;e.__exportStar(Hc(),t),e.__exportStar(Kc(),t)})(rs);function Vc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function Kr(t,e,r){return{id:r||Vc(),jsonrpc:"2.0",method:t,params:e}}function Vr(t,e){return{id:t,jsonrpc:"2.0",result:e}}function dr(t,e,r){return{id:t,jsonrpc:"2.0",error:Gc(e,r)}}function Gc(t,e){return typeof t>"u"?es(Zi):(typeof t=="string"&&(t=Object.assign(Object.assign({},es(Dn)),{message:t})),typeof e<"u"&&(t.data=e),wc(t.code)&&(t=mc(t.code)),t)}class os{}class Wc extends os{constructor(e){super()}}class kc extends os{constructor(){super()}}class Yc extends kc{constructor(e){super()}}const Jc="^https?:",Xc="^wss?:";function Zc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function as(t,e){const r=Zc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function cs(t){return as(t,Jc)}function us(t){return as(t,Xc)}function Qc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function hs(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function In(t){return hs(t)&&"method"in t}function An(t){return hs(t)&&(Ct(t)||wt(t))}function Ct(t){return"result"in t}function wt(t){return"error"in t}class Tn extends Yc{constructor(e){super(e),this.events=new Ze.exports.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(Kr(e.method,e.params||[]),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=>{wt(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),An(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var Pn={exports:{}};(function(t,e){var r=typeof self<"u"?self:He,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function f(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(g){return g&&h.indexOf(Object.prototype.toString.call(g))>-1};function D(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(g))throw new TypeError("Invalid character in header field name");return g.toLowerCase()}function w(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var _={next:function(){var U=g.shift();return{done:U===void 0,value:U}}};return c.iterable&&(_[Symbol.iterator]=function(){return _}),_}function E(g){this.map={},g instanceof E?g.forEach(function(_,U){this.append(U,_)},this):Array.isArray(g)?g.forEach(function(_){this.append(_[0],_[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(_){this.append(_,g[_])},this)}E.prototype.append=function(g,_){g=D(g),_=w(_);var U=this.map[g];this.map[g]=U?U+", "+_:_},E.prototype.delete=function(g){delete this.map[D(g)]},E.prototype.get=function(g){return g=D(g),this.has(g)?this.map[g]:null},E.prototype.has=function(g){return this.map.hasOwnProperty(D(g))},E.prototype.set=function(g,_){this.map[D(g)]=w(_)},E.prototype.forEach=function(g,_){for(var U in this.map)this.map.hasOwnProperty(U)&&g.call(_,this.map[U],U,this)},E.prototype.keys=function(){var g=[];return this.forEach(function(_,U){g.push(U)}),m(g)},E.prototype.values=function(){var g=[];return this.forEach(function(_){g.push(_)}),m(g)},E.prototype.entries=function(){var g=[];return this.forEach(function(_,U){g.push([U,_])}),m(g)},c.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function F(g){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}function N(g){return new Promise(function(_,U){g.onload=function(){_(g.result)},g.onerror=function(){U(g.error)}})}function B(g){var _=new FileReader,U=N(_);return _.readAsArrayBuffer(g),U}function x(g){var _=new FileReader,U=N(_);return _.readAsText(g),U}function A(g){for(var _=new Uint8Array(g),U=new Array(_.length),$=0;$<_.length;$++)U[$]=String.fromCharCode(_[$]);return U.join("")}function y(g){if(g.slice)return g.slice(0);var _=new Uint8Array(g.byteLength);return _.set(new Uint8Array(g)),_.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(g){this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:c.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:c.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():c.arrayBuffer&&c.blob&&f(g)?(this._bodyArrayBuffer=y(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=y(g):this._bodyText=g=Object.prototype.toString.call(g):this._bodyText="",this.headers.get("content-type")||(typeof g=="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(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var g=F(this);if(g)return g;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(){return this._bodyArrayBuffer?F(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var g=F(this);if(g)return g;if(this._bodyBlob)return x(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(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(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function a(g){var _=g.toUpperCase();return v.indexOf(_)>-1?_:g}function d(g,_){_=_||{};var U=_.body;if(g instanceof d){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,_.headers||(this.headers=new E(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!U&&g._bodyInit!=null&&(U=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new E(_.headers)),this.method=a(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(U)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function M(g){var _=new FormData;return g.trim().split("&").forEach(function(U){if(U){var $=U.split("="),C=$.shift().replace(/\+/g," "),R=$.join("=").replace(/\+/g," ");_.append(decodeURIComponent(C),decodeURIComponent(R))}}),_}function q(g){var _=new E,U=g.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function($){var C=$.split(":"),R=C.shift().trim();if(R){var j=C.join(":").trim();_.append(R,j)}}),_}S.call(d.prototype);function G(g,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new E(_.headers),this.url=_.url||"",this._initBody(g)}S.call(G.prototype),G.prototype.clone=function(){return new G(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},G.error=function(){var g=new G(null,{status:0,statusText:""});return g.type="error",g};var J=[301,302,303,307,308];G.redirect=function(g,_){if(J.indexOf(_)===-1)throw new RangeError("Invalid status code");return new G(null,{status:_,headers:{location:g}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(_,U){this.message=_,this.name=U;var $=Error(_);this.stack=$.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function X(g,_){return new Promise(function(U,$){var C=new d(g,_);if(C.signal&&C.signal.aborted)return $(new o.DOMException("Aborted","AbortError"));var R=new XMLHttpRequest;function j(){R.abort()}R.onload=function(){var z={status:R.status,statusText:R.statusText,headers:q(R.getAllResponseHeaders()||"")};z.url="responseURL"in R?R.responseURL:z.headers.get("X-Request-URL");var Q="response"in R?R.response:R.responseText;U(new G(Q,z))},R.onerror=function(){$(new TypeError("Network request failed"))},R.ontimeout=function(){$(new TypeError("Network request failed"))},R.onabort=function(){$(new o.DOMException("Aborted","AbortError"))},R.open(C.method,C.url,!0),C.credentials==="include"?R.withCredentials=!0:C.credentials==="omit"&&(R.withCredentials=!1),"responseType"in R&&c.blob&&(R.responseType="blob"),C.headers.forEach(function(z,Q){R.setRequestHeader(Q,z)}),C.signal&&(C.signal.addEventListener("abort",j),R.onreadystatechange=function(){R.readyState===4&&C.signal.removeEventListener("abort",j)}),R.send(typeof C._bodyInit>"u"?null:C._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=E,s.Request=d,s.Response=G),o.Headers=E,o.Request=d,o.Response=G,o.fetch=X,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=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})(Pn,Pn.exports);var fs=cc(Pn.exports);function Rn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function pr(t){return typeof t=="string"?t:JSON.stringify(t)}const ls={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},ds=10;class eu{constructor(e){if(this.url=e,this.events=new Ze.exports.EventEmitter,this.isAvailable=!1,this.registering=!1,!cs(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}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,r){this.isAvailable||await this.register();try{const n=pr(e),s=await(await fs(this.url,Object.assign(Object.assign({},ls),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!cs(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{const r=pr({id:1,jsonrpc:"2.0",method:"test",params:[]});await fs(e,Object.assign(Object.assign({},ls),{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"?Rn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=dr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ts(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ds&&this.events.setMaxListeners(ds)}}var Cn={},Gr={},re={},ps={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(c,f){var h=c>>>16&65535,l=c&65535,D=f>>>16&65535,w=f&65535;return l*w+(h*w+l*D<<16>>>0)|0}t.mul=Math.imul||e;function r(c,f){return c+f|0}t.add=r;function n(c,f){return c-f|0}t.sub=n;function i(c,f){return c<<f|c>>>32-f}t.rotl=i;function s(c,f){return c<<32-f|c>>>f}t.rotr=s;function o(c){return typeof c=="number"&&isFinite(c)&&Math.floor(c)===c}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(c){return t.isInteger(c)&&c>=-t.MAX_SAFE_INTEGER&&c<=t.MAX_SAFE_INTEGER}})(ps),Object.defineProperty(re,"__esModule",{value:!0});var gs=ps;function tu(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=tu;function ru(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=ru;function nu(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=nu;function iu(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=iu;function ys(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=ys,re.writeInt16BE=ys;function _s(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=_s,re.writeInt16LE=_s;function Nn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Nn;function Fn(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=Fn;function Ln(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Ln;function Un(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=Un;function Wr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=Wr,re.writeInt32BE=Wr;function kr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=kr,re.writeInt32LE=kr;function su(t,e){e===void 0&&(e=0);var r=Nn(t,e),n=Nn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=su;function ou(t,e){e===void 0&&(e=0);var r=Fn(t,e),n=Fn(t,e+4);return r*4294967296+n}re.readUint64BE=ou;function au(t,e){e===void 0&&(e=0);var r=Ln(t,e),n=Ln(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=au;function cu(t,e){e===void 0&&(e=0);var r=Un(t,e),n=Un(t,e+4);return n*4294967296+r}re.readUint64LE=cu;function bs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Wr(t/4294967296>>>0,e,r),Wr(t>>>0,e,r+4),e}re.writeUint64BE=bs,re.writeInt64BE=bs;function vs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),kr(t>>>0,e,r),kr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=vs,re.writeInt64LE=vs;function uu(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=uu;function hu(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=hu;function fu(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!gs.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=fu;function lu(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!gs.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=lu;function du(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=du;function pu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=pu;function gu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=gu;function yu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=yu;function _u(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=_u;function bu(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=bu;function vu(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=vu;function wu(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=wu;var lt={};Object.defineProperty(lt,"__esModule",{value:!0});function mu(t){for(var e=0;e<t.length;e++)t[e]=0;return t}lt.wipe=mu,Object.defineProperty(Gr,"__esModule",{value:!0});var nt=re,$n=lt,Eu=20;function Du(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],f=r[7]<<24|r[6]<<16|r[5]<<8|r[4],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],l=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],w=r[23]<<24|r[22]<<16|r[21]<<8|r[20],m=r[27]<<24|r[26]<<16|r[25]<<8|r[24],E=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],N=e[7]<<24|e[6]<<16|e[5]<<8|e[4],B=e[11]<<24|e[10]<<16|e[9]<<8|e[8],x=e[15]<<24|e[14]<<16|e[13]<<8|e[12],A=n,y=i,S=s,v=o,a=c,d=f,M=h,q=l,G=D,J=w,X=m,g=E,_=F,U=N,$=B,C=x,R=0;R<Eu;R+=2)A=A+a|0,_^=A,_=_>>>32-16|_<<16,G=G+_|0,a^=G,a=a>>>32-12|a<<12,y=y+d|0,U^=y,U=U>>>32-16|U<<16,J=J+U|0,d^=J,d=d>>>32-12|d<<12,S=S+M|0,$^=S,$=$>>>32-16|$<<16,X=X+$|0,M^=X,M=M>>>32-12|M<<12,v=v+q|0,C^=v,C=C>>>32-16|C<<16,g=g+C|0,q^=g,q=q>>>32-12|q<<12,S=S+M|0,$^=S,$=$>>>32-8|$<<8,X=X+$|0,M^=X,M=M>>>32-7|M<<7,v=v+q|0,C^=v,C=C>>>32-8|C<<8,g=g+C|0,q^=g,q=q>>>32-7|q<<7,y=y+d|0,U^=y,U=U>>>32-8|U<<8,J=J+U|0,d^=J,d=d>>>32-7|d<<7,A=A+a|0,_^=A,_=_>>>32-8|_<<8,G=G+_|0,a^=G,a=a>>>32-7|a<<7,A=A+d|0,C^=A,C=C>>>32-16|C<<16,X=X+C|0,d^=X,d=d>>>32-12|d<<12,y=y+M|0,_^=y,_=_>>>32-16|_<<16,g=g+_|0,M^=g,M=M>>>32-12|M<<12,S=S+q|0,U^=S,U=U>>>32-16|U<<16,G=G+U|0,q^=G,q=q>>>32-12|q<<12,v=v+a|0,$^=v,$=$>>>32-16|$<<16,J=J+$|0,a^=J,a=a>>>32-12|a<<12,S=S+q|0,U^=S,U=U>>>32-8|U<<8,G=G+U|0,q^=G,q=q>>>32-7|q<<7,v=v+a|0,$^=v,$=$>>>32-8|$<<8,J=J+$|0,a^=J,a=a>>>32-7|a<<7,y=y+M|0,_^=y,_=_>>>32-8|_<<8,g=g+_|0,M^=g,M=M>>>32-7|M<<7,A=A+d|0,C^=A,C=C>>>32-8|C<<8,X=X+C|0,d^=X,d=d>>>32-7|d<<7;nt.writeUint32LE(A+n|0,t,0),nt.writeUint32LE(y+i|0,t,4),nt.writeUint32LE(S+s|0,t,8),nt.writeUint32LE(v+o|0,t,12),nt.writeUint32LE(a+c|0,t,16),nt.writeUint32LE(d+f|0,t,20),nt.writeUint32LE(M+h|0,t,24),nt.writeUint32LE(q+l|0,t,28),nt.writeUint32LE(G+D|0,t,32),nt.writeUint32LE(J+w|0,t,36),nt.writeUint32LE(X+m|0,t,40),nt.writeUint32LE(g+E|0,t,44),nt.writeUint32LE(_+F|0,t,48),nt.writeUint32LE(U+N|0,t,52),nt.writeUint32LE($+B|0,t,56),nt.writeUint32LE(C+x|0,t,60)}function ws(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}for(var c=new Uint8Array(64),f=0;f<r.length;f+=64){Du(c,s,t);for(var h=f;h<f+64&&h<r.length;h++)n[h]=r[h]^c[h-f];xu(s,0,o)}return $n.wipe(c),i===0&&$n.wipe(s),n}Gr.streamXOR=ws;function Su(t,e,r,n){return n===void 0&&(n=0),$n.wipe(r),ws(t,e,r,r,n)}Gr.stream=Su;function xu(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var ms={},Ut={};Object.defineProperty(Ut,"__esModule",{value:!0});function Ou(t,e,r){return~(t-1)&e|t-1&r}Ut.select=Ou;function Iu(t,e){return(t|0)-(e|0)-1>>>31&1}Ut.lessOrEqual=Iu;function Es(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Ut.compare=Es;function Au(t,e){return t.length===0||e.length===0?!1:Es(t,e)!==0}Ut.equal=Au,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ut,r=lt;t.DIGEST_LENGTH=16;var n=function(){function o(c){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=f&8191;var h=c[2]|c[3]<<8;this._r[1]=(f>>>13|h<<3)&8191;var l=c[4]|c[5]<<8;this._r[2]=(h>>>10|l<<6)&7939;var D=c[6]|c[7]<<8;this._r[3]=(l>>>7|D<<9)&8191;var w=c[8]|c[9]<<8;this._r[4]=(D>>>4|w<<12)&255,this._r[5]=w>>>1&8190;var m=c[10]|c[11]<<8;this._r[6]=(w>>>14|m<<2)&8191;var E=c[12]|c[13]<<8;this._r[7]=(m>>>11|E<<5)&8065;var F=c[14]|c[15]<<8;this._r[8]=(E>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return o.prototype._blocks=function(c,f,h){for(var l=this._fin?0:2048,D=this._h[0],w=this._h[1],m=this._h[2],E=this._h[3],F=this._h[4],N=this._h[5],B=this._h[6],x=this._h[7],A=this._h[8],y=this._h[9],S=this._r[0],v=this._r[1],a=this._r[2],d=this._r[3],M=this._r[4],q=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],g=this._r[9];h>=16;){var _=c[f+0]|c[f+1]<<8;D+=_&8191;var U=c[f+2]|c[f+3]<<8;w+=(_>>>13|U<<3)&8191;var $=c[f+4]|c[f+5]<<8;m+=(U>>>10|$<<6)&8191;var C=c[f+6]|c[f+7]<<8;E+=($>>>7|C<<9)&8191;var R=c[f+8]|c[f+9]<<8;F+=(C>>>4|R<<12)&8191,N+=R>>>1&8191;var j=c[f+10]|c[f+11]<<8;B+=(R>>>14|j<<2)&8191;var z=c[f+12]|c[f+13]<<8;x+=(j>>>11|z<<5)&8191;var Q=c[f+14]|c[f+15]<<8;A+=(z>>>8|Q<<8)&8191,y+=Q>>>5|l;var H=0,ee=H;ee+=D*S,ee+=w*(5*g),ee+=m*(5*X),ee+=E*(5*J),ee+=F*(5*G),H=ee>>>13,ee&=8191,ee+=N*(5*q),ee+=B*(5*M),ee+=x*(5*d),ee+=A*(5*a),ee+=y*(5*v),H+=ee>>>13,ee&=8191;var Y=H;Y+=D*v,Y+=w*S,Y+=m*(5*g),Y+=E*(5*X),Y+=F*(5*J),H=Y>>>13,Y&=8191,Y+=N*(5*G),Y+=B*(5*q),Y+=x*(5*M),Y+=A*(5*d),Y+=y*(5*a),H+=Y>>>13,Y&=8191;var ae=H;ae+=D*a,ae+=w*v,ae+=m*S,ae+=E*(5*g),ae+=F*(5*X),H=ae>>>13,ae&=8191,ae+=N*(5*J),ae+=B*(5*G),ae+=x*(5*q),ae+=A*(5*M),ae+=y*(5*d),H+=ae>>>13,ae&=8191;var P=H;P+=D*d,P+=w*a,P+=m*v,P+=E*S,P+=F*(5*g),H=P>>>13,P&=8191,P+=N*(5*X),P+=B*(5*J),P+=x*(5*G),P+=A*(5*q),P+=y*(5*M),H+=P>>>13,P&=8191;var T=H;T+=D*M,T+=w*d,T+=m*a,T+=E*v,T+=F*S,H=T>>>13,T&=8191,T+=N*(5*g),T+=B*(5*X),T+=x*(5*J),T+=A*(5*G),T+=y*(5*q),H+=T>>>13,T&=8191;var O=H;O+=D*q,O+=w*M,O+=m*d,O+=E*a,O+=F*v,H=O>>>13,O&=8191,O+=N*S,O+=B*(5*g),O+=x*(5*X),O+=A*(5*J),O+=y*(5*G),H+=O>>>13,O&=8191;var u=H;u+=D*G,u+=w*q,u+=m*M,u+=E*d,u+=F*a,H=u>>>13,u&=8191,u+=N*v,u+=B*S,u+=x*(5*g),u+=A*(5*X),u+=y*(5*J),H+=u>>>13,u&=8191;var b=H;b+=D*J,b+=w*G,b+=m*q,b+=E*M,b+=F*d,H=b>>>13,b&=8191,b+=N*a,b+=B*v,b+=x*S,b+=A*(5*g),b+=y*(5*X),H+=b>>>13,b&=8191;var K=H;K+=D*X,K+=w*J,K+=m*G,K+=E*q,K+=F*M,H=K>>>13,K&=8191,K+=N*d,K+=B*a,K+=x*v,K+=A*S,K+=y*(5*g),H+=K>>>13,K&=8191;var W=H;W+=D*g,W+=w*X,W+=m*J,W+=E*G,W+=F*q,H=W>>>13,W&=8191,W+=N*M,W+=B*d,W+=x*a,W+=A*v,W+=y*S,H+=W>>>13,W&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,Y+=H,D=ee,w=Y,m=ae,E=P,F=T,N=O,B=u,x=b,A=K,y=W,f+=16,h-=16}this._h[0]=D,this._h[1]=w,this._h[2]=m,this._h[3]=E,this._h[4]=F,this._h[5]=N,this._h[6]=B,this._h[7]=x,this._h[8]=A,this._h[9]=y},o.prototype.finish=function(c,f){f===void 0&&(f=0);var h=new Uint16Array(10),l,D,w,m;if(this._leftover){for(m=this._leftover,this._buffer[m++]=1;m<16;m++)this._buffer[m]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(l=this._h[1]>>>13,this._h[1]&=8191,m=2;m<10;m++)this._h[m]+=l,l=this._h[m]>>>13,this._h[m]&=8191;for(this._h[0]+=l*5,l=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=l,l=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=l,h[0]=this._h[0]+5,l=h[0]>>>13,h[0]&=8191,m=1;m<10;m++)h[m]=this._h[m]+l,l=h[m]>>>13,h[m]&=8191;for(h[9]-=1<<13,D=(l^1)-1,m=0;m<10;m++)h[m]&=D;for(D=~D,m=0;m<10;m++)this._h[m]=this._h[m]&D|h[m];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,w=this._h[0]+this._pad[0],this._h[0]=w&65535,m=1;m<8;m++)w=(this._h[m]+this._pad[m]|0)+(w>>>16)|0,this._h[m]=w&65535;return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(c){var f=0,h=c.length,l;if(this._leftover){l=16-this._leftover,l>h&&(l=h);for(var D=0;D<l;D++)this._buffer[this._leftover+D]=c[f+D];if(h-=l,f+=l,this._leftover+=l,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(l=h-h%16,this._blocks(c,f,l),f+=l,h-=l),h){for(var D=0;D<h;D++)this._buffer[this._leftover+D]=c[f+D];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=n;function i(o,c){var f=new n(o);f.update(c);var h=f.digest();return f.clean(),h}t.oneTimeAuth=i;function s(o,c){return o.length!==t.DIGEST_LENGTH||c.length!==t.DIGEST_LENGTH?!1:e.equal(o,c)}t.equal=s}(ms),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Gr,r=ms,n=lt,i=re,s=Ut;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),c=function(){function f(h){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,h.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return f.prototype.seal=function(h,l,D,w){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var m=new Uint8Array(16);m.set(h,m.length-h.length);var E=new Uint8Array(32);e.stream(this._key,m,E,4);var F=l.length+this.tagLength,N;if(w){if(w.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");N=w}else N=new Uint8Array(F);return e.streamXOR(this._key,m,l,N,4),this._authenticate(N.subarray(N.length-this.tagLength,N.length),E,N.subarray(0,N.length-this.tagLength),D),n.wipe(m),N},f.prototype.open=function(h,l,D,w){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(l.length<this.tagLength)return null;var m=new Uint8Array(16);m.set(h,m.length-h.length);var E=new Uint8Array(32);e.stream(this._key,m,E,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,E,l.subarray(0,l.length-this.tagLength),D),!s.equal(F,l.subarray(l.length-this.tagLength,l.length)))return null;var N=l.length-this.tagLength,B;if(w){if(w.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");B=w}else B=new Uint8Array(N);return e.streamXOR(this._key,m,l.subarray(0,l.length-this.tagLength),B,4),n.wipe(m),B},f.prototype.clean=function(){return n.wipe(this._key),this},f.prototype._authenticate=function(h,l,D,w){var m=new r.Poly1305(l);w&&(m.update(w),w.length%16>0&&m.update(o.subarray(w.length%16))),m.update(D),D.length%16>0&&m.update(o.subarray(D.length%16));var E=new Uint8Array(8);w&&i.writeUint64LE(w.length,E),m.update(E),i.writeUint64LE(D.length,E),m.update(E);for(var F=m.digest(),N=0;N<F.length;N++)h[N]=F[N];m.clean(),n.wipe(F),n.wipe(E)},f}();t.ChaCha20Poly1305=c}(Cn);var Ds={},gr={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});function Tu(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Mn.isSerializableHash=Tu,Object.defineProperty(gr,"__esModule",{value:!0});var Dt=Mn,Pu=Ut,Ru=lt,Ss=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),Dt.isSerializableHash(this._inner)&&Dt.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Ru.wipe(n)}return t.prototype.reset=function(){if(!Dt.isSerializableHash(this._inner)||!Dt.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Dt.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Dt.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Dt.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Dt.isSerializableHash(this._inner)||!Dt.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Dt.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();gr.HMAC=Ss;function Cu(t,e,r){var n=new Ss(t,e);n.update(r);var i=n.digest();return n.clean(),i}gr.hmac=Cu,gr.equal=Pu.equal,Object.defineProperty(Ds,"__esModule",{value:!0});var xs=gr,Os=lt,Nu=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=xs.hmac(this._hash,n,r);this._hmac=new xs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),Os.wipe(this._buffer),Os.wipe(this._counter),this._bufpos=0},t}(),Fu=Ds.HKDF=Nu,ir={},Yr={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.BrowserRandomSource=void 0;const Is=65536;class Lu{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let n=0;n<r.length;n+=Is)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,Is)));return r}}Jr.BrowserRandomSource=Lu;function Uu(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Xr={},$u={},Mu=Object.freeze({__proto__:null,default:$u}),ju=Kt(Mu);Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.NodeRandomSource=void 0;const Bu=lt;class zu{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Uu<"u"){const e=ju;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(e);for(let i=0;i<n.length;i++)n[i]=r[i];return(0,Bu.wipe)(r),n}}Xr.NodeRandomSource=zu,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.SystemRandomSource=void 0;const qu=Jr,Hu=Xr;class Ku{constructor(){if(this.isAvailable=!1,this.name="",this._source=new qu.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Hu.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}Yr.SystemRandomSource=Ku,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=Yr,r=re,n=lt;t.defaultRandomSource=new e.SystemRandomSource;function i(h,l=t.defaultRandomSource){return l.randomBytes(h)}t.randomBytes=i;function s(h=t.defaultRandomSource){const l=i(4,h),D=(0,r.readUint32LE)(l);return(0,n.wipe)(l),D}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(h,l=o,D=t.defaultRandomSource){if(l.length<2)throw new Error("randomString charset is too short");if(l.length>256)throw new Error("randomString charset is too long");let w="";const m=l.length,E=256-256%m;for(;h>0;){const F=i(Math.ceil(h*256/E),D);for(let N=0;N<F.length&&h>0;N++){const B=F[N];B<E&&(w+=l.charAt(B%m),h--)}(0,n.wipe)(F)}return w}t.randomString=c;function f(h,l=o,D=t.defaultRandomSource){const w=Math.ceil(h/(Math.log(l.length)/Math.LN2));return c(w,l,D)}t.randomStringForEntropy=f}(ir);var Zr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=lt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},c.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._temp,this._state,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},c.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,w=h<<3,m=h%64<56?64:128;this._buffer[l]=128;for(var E=l+1;E<m-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(w,this._buffer,m-4),s(this._temp,this._state,this._buffer,0,m),this._finished=!0}for(var E=0;E<this.digestLength/4;E++)e.writeUint32BE(this._state[E],f,E*4);return this},c.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(f){return this._state.set(f.state),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(f){r.wipe(f.state),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},c}();t.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(c,f,h,l,D){for(;D>=64;){for(var w=f[0],m=f[1],E=f[2],F=f[3],N=f[4],B=f[5],x=f[6],A=f[7],y=0;y<16;y++){var S=l+y*4;c[y]=e.readUint32BE(h,S)}for(var y=16;y<64;y++){var v=c[y-2],a=(v>>>17|v<<32-17)^(v>>>19|v<<32-19)^v>>>10;v=c[y-15];var d=(v>>>7|v<<32-7)^(v>>>18|v<<32-18)^v>>>3;c[y]=(a+c[y-7]|0)+(d+c[y-16]|0)}for(var y=0;y<64;y++){var a=(((N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7))+(N&B^~N&x)|0)+(A+(i[y]+c[y]|0)|0)|0,d=((w>>>2|w<<32-2)^(w>>>13|w<<32-13)^(w>>>22|w<<32-22))+(w&m^w&E^m&E)|0;A=x,x=B,B=N,N=F+a|0,F=E,E=m,m=w,w=a+d|0}f[0]+=w,f[1]+=m,f[2]+=E,f[3]+=F,f[4]+=N,f[5]+=B,f[6]+=x,f[7]+=A,l+=64,D-=64}return l}function o(c){var f=new n;f.update(c);var h=f.digest();return f.clean(),h}t.hash=o})(Zr);var jn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=ir,r=lt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(y){const S=new Float64Array(16);if(y)for(let v=0;v<y.length;v++)S[v]=y[v];return S}const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(y){let S=1;for(let v=0;v<16;v++){let a=y[v]+S+65535;S=Math.floor(a/65536),y[v]=a-S*65536}y[0]+=S-1+37*(S-1)}function c(y,S,v){const a=~(v-1);for(let d=0;d<16;d++){const M=a&(y[d]^S[d]);y[d]^=M,S[d]^=M}}function f(y,S){const v=n(),a=n();for(let d=0;d<16;d++)a[d]=S[d];o(a),o(a),o(a);for(let d=0;d<2;d++){v[0]=a[0]-65517;for(let q=1;q<15;q++)v[q]=a[q]-65535-(v[q-1]>>16&1),v[q-1]&=65535;v[15]=a[15]-32767-(v[14]>>16&1);const M=v[15]>>16&1;v[14]&=65535,c(a,v,1-M)}for(let d=0;d<16;d++)y[2*d]=a[d]&255,y[2*d+1]=a[d]>>8}function h(y,S){for(let v=0;v<16;v++)y[v]=S[2*v]+(S[2*v+1]<<8);y[15]&=32767}function l(y,S,v){for(let a=0;a<16;a++)y[a]=S[a]+v[a]}function D(y,S,v){for(let a=0;a<16;a++)y[a]=S[a]-v[a]}function w(y,S,v){let a,d,M=0,q=0,G=0,J=0,X=0,g=0,_=0,U=0,$=0,C=0,R=0,j=0,z=0,Q=0,H=0,ee=0,Y=0,ae=0,P=0,T=0,O=0,u=0,b=0,K=0,W=0,fe=0,_e=0,de=0,we=0,Le=0,Pe=0,ye=v[0],pe=v[1],le=v[2],ue=v[3],ce=v[4],oe=v[5],se=v[6],te=v[7],he=v[8],ge=v[9],ne=v[10],be=v[11],ve=v[12],Ee=v[13],De=v[14],me=v[15];a=S[0],M+=a*ye,q+=a*pe,G+=a*le,J+=a*ue,X+=a*ce,g+=a*oe,_+=a*se,U+=a*te,$+=a*he,C+=a*ge,R+=a*ne,j+=a*be,z+=a*ve,Q+=a*Ee,H+=a*De,ee+=a*me,a=S[1],q+=a*ye,G+=a*pe,J+=a*le,X+=a*ue,g+=a*ce,_+=a*oe,U+=a*se,$+=a*te,C+=a*he,R+=a*ge,j+=a*ne,z+=a*be,Q+=a*ve,H+=a*Ee,ee+=a*De,Y+=a*me,a=S[2],G+=a*ye,J+=a*pe,X+=a*le,g+=a*ue,_+=a*ce,U+=a*oe,$+=a*se,C+=a*te,R+=a*he,j+=a*ge,z+=a*ne,Q+=a*be,H+=a*ve,ee+=a*Ee,Y+=a*De,ae+=a*me,a=S[3],J+=a*ye,X+=a*pe,g+=a*le,_+=a*ue,U+=a*ce,$+=a*oe,C+=a*se,R+=a*te,j+=a*he,z+=a*ge,Q+=a*ne,H+=a*be,ee+=a*ve,Y+=a*Ee,ae+=a*De,P+=a*me,a=S[4],X+=a*ye,g+=a*pe,_+=a*le,U+=a*ue,$+=a*ce,C+=a*oe,R+=a*se,j+=a*te,z+=a*he,Q+=a*ge,H+=a*ne,ee+=a*be,Y+=a*ve,ae+=a*Ee,P+=a*De,T+=a*me,a=S[5],g+=a*ye,_+=a*pe,U+=a*le,$+=a*ue,C+=a*ce,R+=a*oe,j+=a*se,z+=a*te,Q+=a*he,H+=a*ge,ee+=a*ne,Y+=a*be,ae+=a*ve,P+=a*Ee,T+=a*De,O+=a*me,a=S[6],_+=a*ye,U+=a*pe,$+=a*le,C+=a*ue,R+=a*ce,j+=a*oe,z+=a*se,Q+=a*te,H+=a*he,ee+=a*ge,Y+=a*ne,ae+=a*be,P+=a*ve,T+=a*Ee,O+=a*De,u+=a*me,a=S[7],U+=a*ye,$+=a*pe,C+=a*le,R+=a*ue,j+=a*ce,z+=a*oe,Q+=a*se,H+=a*te,ee+=a*he,Y+=a*ge,ae+=a*ne,P+=a*be,T+=a*ve,O+=a*Ee,u+=a*De,b+=a*me,a=S[8],$+=a*ye,C+=a*pe,R+=a*le,j+=a*ue,z+=a*ce,Q+=a*oe,H+=a*se,ee+=a*te,Y+=a*he,ae+=a*ge,P+=a*ne,T+=a*be,O+=a*ve,u+=a*Ee,b+=a*De,K+=a*me,a=S[9],C+=a*ye,R+=a*pe,j+=a*le,z+=a*ue,Q+=a*ce,H+=a*oe,ee+=a*se,Y+=a*te,ae+=a*he,P+=a*ge,T+=a*ne,O+=a*be,u+=a*ve,b+=a*Ee,K+=a*De,W+=a*me,a=S[10],R+=a*ye,j+=a*pe,z+=a*le,Q+=a*ue,H+=a*ce,ee+=a*oe,Y+=a*se,ae+=a*te,P+=a*he,T+=a*ge,O+=a*ne,u+=a*be,b+=a*ve,K+=a*Ee,W+=a*De,fe+=a*me,a=S[11],j+=a*ye,z+=a*pe,Q+=a*le,H+=a*ue,ee+=a*ce,Y+=a*oe,ae+=a*se,P+=a*te,T+=a*he,O+=a*ge,u+=a*ne,b+=a*be,K+=a*ve,W+=a*Ee,fe+=a*De,_e+=a*me,a=S[12],z+=a*ye,Q+=a*pe,H+=a*le,ee+=a*ue,Y+=a*ce,ae+=a*oe,P+=a*se,T+=a*te,O+=a*he,u+=a*ge,b+=a*ne,K+=a*be,W+=a*ve,fe+=a*Ee,_e+=a*De,de+=a*me,a=S[13],Q+=a*ye,H+=a*pe,ee+=a*le,Y+=a*ue,ae+=a*ce,P+=a*oe,T+=a*se,O+=a*te,u+=a*he,b+=a*ge,K+=a*ne,W+=a*be,fe+=a*ve,_e+=a*Ee,de+=a*De,we+=a*me,a=S[14],H+=a*ye,ee+=a*pe,Y+=a*le,ae+=a*ue,P+=a*ce,T+=a*oe,O+=a*se,u+=a*te,b+=a*he,K+=a*ge,W+=a*ne,fe+=a*be,_e+=a*ve,de+=a*Ee,we+=a*De,Le+=a*me,a=S[15],ee+=a*ye,Y+=a*pe,ae+=a*le,P+=a*ue,T+=a*ce,O+=a*oe,u+=a*se,b+=a*te,K+=a*he,W+=a*ge,fe+=a*ne,_e+=a*be,de+=a*ve,we+=a*Ee,Le+=a*De,Pe+=a*me,M+=38*Y,q+=38*ae,G+=38*P,J+=38*T,X+=38*O,g+=38*u,_+=38*b,U+=38*K,$+=38*W,C+=38*fe,R+=38*_e,j+=38*de,z+=38*we,Q+=38*Le,H+=38*Pe,d=1,a=M+d+65535,d=Math.floor(a/65536),M=a-d*65536,a=q+d+65535,d=Math.floor(a/65536),q=a-d*65536,a=G+d+65535,d=Math.floor(a/65536),G=a-d*65536,a=J+d+65535,d=Math.floor(a/65536),J=a-d*65536,a=X+d+65535,d=Math.floor(a/65536),X=a-d*65536,a=g+d+65535,d=Math.floor(a/65536),g=a-d*65536,a=_+d+65535,d=Math.floor(a/65536),_=a-d*65536,a=U+d+65535,d=Math.floor(a/65536),U=a-d*65536,a=$+d+65535,d=Math.floor(a/65536),$=a-d*65536,a=C+d+65535,d=Math.floor(a/65536),C=a-d*65536,a=R+d+65535,d=Math.floor(a/65536),R=a-d*65536,a=j+d+65535,d=Math.floor(a/65536),j=a-d*65536,a=z+d+65535,d=Math.floor(a/65536),z=a-d*65536,a=Q+d+65535,d=Math.floor(a/65536),Q=a-d*65536,a=H+d+65535,d=Math.floor(a/65536),H=a-d*65536,a=ee+d+65535,d=Math.floor(a/65536),ee=a-d*65536,M+=d-1+37*(d-1),d=1,a=M+d+65535,d=Math.floor(a/65536),M=a-d*65536,a=q+d+65535,d=Math.floor(a/65536),q=a-d*65536,a=G+d+65535,d=Math.floor(a/65536),G=a-d*65536,a=J+d+65535,d=Math.floor(a/65536),J=a-d*65536,a=X+d+65535,d=Math.floor(a/65536),X=a-d*65536,a=g+d+65535,d=Math.floor(a/65536),g=a-d*65536,a=_+d+65535,d=Math.floor(a/65536),_=a-d*65536,a=U+d+65535,d=Math.floor(a/65536),U=a-d*65536,a=$+d+65535,d=Math.floor(a/65536),$=a-d*65536,a=C+d+65535,d=Math.floor(a/65536),C=a-d*65536,a=R+d+65535,d=Math.floor(a/65536),R=a-d*65536,a=j+d+65535,d=Math.floor(a/65536),j=a-d*65536,a=z+d+65535,d=Math.floor(a/65536),z=a-d*65536,a=Q+d+65535,d=Math.floor(a/65536),Q=a-d*65536,a=H+d+65535,d=Math.floor(a/65536),H=a-d*65536,a=ee+d+65535,d=Math.floor(a/65536),ee=a-d*65536,M+=d-1+37*(d-1),y[0]=M,y[1]=q,y[2]=G,y[3]=J,y[4]=X,y[5]=g,y[6]=_,y[7]=U,y[8]=$,y[9]=C,y[10]=R,y[11]=j,y[12]=z,y[13]=Q,y[14]=H,y[15]=ee}function m(y,S){w(y,S,S)}function E(y,S){const v=n();for(let a=0;a<16;a++)v[a]=S[a];for(let a=253;a>=0;a--)m(v,v),a!==2&&a!==4&&w(v,v,S);for(let a=0;a<16;a++)y[a]=v[a]}function F(y,S){const v=new Uint8Array(32),a=new Float64Array(80),d=n(),M=n(),q=n(),G=n(),J=n(),X=n();for(let $=0;$<31;$++)v[$]=y[$];v[31]=y[31]&127|64,v[0]&=248,h(a,S);for(let $=0;$<16;$++)M[$]=a[$];d[0]=G[0]=1;for(let $=254;$>=0;--$){const C=v[$>>>3]>>>($&7)&1;c(d,M,C),c(q,G,C),l(J,d,q),D(d,d,q),l(q,M,G),D(M,M,G),m(G,J),m(X,d),w(d,q,d),w(q,M,J),l(J,d,q),D(d,d,q),m(M,d),D(q,G,X),w(d,q,s),l(d,d,G),w(q,q,d),w(d,G,X),w(G,M,a),m(M,J),c(d,M,C),c(q,G,C)}for(let $=0;$<16;$++)a[$+16]=d[$],a[$+32]=q[$],a[$+48]=M[$],a[$+64]=G[$];const g=a.subarray(32),_=a.subarray(16);E(g,g),w(_,_,g);const U=new Uint8Array(32);return f(U,_),U}t.scalarMult=F;function N(y){return F(y,i)}t.scalarMultBase=N;function B(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const S=new Uint8Array(y);return{publicKey:N(S),secretKey:S}}t.generateKeyPairFromSeed=B;function x(y){const S=(0,e.randomBytes)(32,y),v=B(S);return(0,r.wipe)(S),v}t.generateKeyPair=x;function A(y,S,v=!1){if(y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const a=F(y,S);if(v){let d=0;for(let M=0;M<a.length;M++)d|=a[M];if(d===0)throw new Error("X25519: invalid shared key")}return a}t.sharedKey=A})(jn);function As(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Bn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=As(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Vu(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 c=t.length,f=t.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function D(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var F=0,N=0,B=0,x=E.length;B!==x&&E[B]===0;)B++,F++;for(var A=(x-B)*l+1>>>0,y=new Uint8Array(A);B!==x;){for(var S=E[B],v=0,a=A-1;(S!==0||v<N)&&a!==-1;a--,v++)S+=256*y[a]>>>0,y[a]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=v,B++}for(var d=A-N;d!==A&&y[d]===0;)d++;for(var M=f.repeat(F);d<A;++d)M+=t.charAt(y[d]);return M}function w(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var F=0;if(E[F]!==" "){for(var N=0,B=0;E[F]===f;)N++,F++;for(var x=(E.length-F)*h+1>>>0,A=new Uint8Array(x);E[F];){var y=r[E.charCodeAt(F)];if(y===255)return;for(var S=0,v=x-1;(y!==0||S<B)&&v!==-1;v--,S++)y+=c*A[v]>>>0,A[v]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=S,F++}if(E[F]!==" "){for(var a=x-B;a!==x&&A[a]===0;)a++;for(var d=new Uint8Array(N+(x-a)),M=N;a!==x;)d[M++]=A[a++];return d}}}function m(E){var F=w(E);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:w,decode:m}}var Gu=Vu,Wu=Gu;const Ts=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")},ku=t=>new TextEncoder().encode(t),Yu=t=>new TextDecoder().decode(t);class Ju{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 Xu{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 Ps(this,e)}}class Zu{constructor(e){this.decoders=e}or(e){return Ps(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 Ps=(t,e)=>new Zu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Qu{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ju(e,r,n),this.decoder=new Xu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qr=({name:t,prefix:e,encode:r,decode:n})=>new Qu(t,e,r,n),yr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Wu(r,e);return Qr({prefix:t,name:e,encode:n,decode:s=>Ts(i(s))})},eh=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,c+=r,c>=8&&(c-=8,o[h++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return o},th=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],o+=8;o>r;)o-=r,s+=e[i&c>>o];if(o&&(s+=e[i&c<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Qe=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Qr({prefix:e,name:t,encode(i){return th(i,n,r)},decode(i){return eh(i,n,r,t)}}),rh=Qr({prefix:"\0",name:"identity",encode:t=>Yu(t),decode:t=>ku(t)});var nh=Object.freeze({__proto__:null,identity:rh});const ih=Qe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sh=Object.freeze({__proto__:null,base2:ih});const oh=Qe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah=Object.freeze({__proto__:null,base8:oh});const ch=yr({prefix:"9",name:"base10",alphabet:"0123456789"});var uh=Object.freeze({__proto__:null,base10:ch});const hh=Qe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fh=Qe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lh=Object.freeze({__proto__:null,base16:hh,base16upper:fh});const dh=Qe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ph=Qe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gh=Qe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yh=Qe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_h=Qe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bh=Qe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vh=Qe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wh=Qe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),mh=Qe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Eh=Object.freeze({__proto__:null,base32:dh,base32upper:ph,base32pad:gh,base32padupper:yh,base32hex:_h,base32hexupper:bh,base32hexpad:vh,base32hexpadupper:wh,base32z:mh});const Dh=yr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sh=yr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xh=Object.freeze({__proto__:null,base36:Dh,base36upper:Sh});const Oh=yr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ih=yr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ah=Object.freeze({__proto__:null,base58btc:Oh,base58flickr:Ih});const Th=Qe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ph=Qe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rh=Qe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ch=Qe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nh=Object.freeze({__proto__:null,base64:Th,base64pad:Ph,base64url:Rh,base64urlpad:Ch});const Rs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Fh=Rs.reduce((t,e,r)=>(t[r]=e,t),[]),Lh=Rs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Uh(t){return t.reduce((e,r)=>(e+=Fh[r],e),"")}function $h(t){const e=[];for(const r of t){const n=Lh[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Mh=Qr({prefix:"\u{1F680}",name:"base256emoji",encode:Uh,decode:$h});var jh=Object.freeze({__proto__:null,base256emoji:Mh}),Bh=Ns,Cs=128,zh=127,qh=~zh,Hh=Math.pow(2,31);function Ns(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Hh;)e[r++]=t&255|Cs,t/=128;for(;t&qh;)e[r++]=t&255|Cs,t>>>=7;return e[r]=t|0,Ns.bytes=r-n+1,e}var Kh=zn,Vh=128,Fs=127;function zn(t,n){var r=0,n=n||0,i=0,s=n,o,c=t.length;do{if(s>=c)throw zn.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Fs)<<i:(o&Fs)*Math.pow(2,i),i+=7}while(o>=Vh);return zn.bytes=s-n,r}var Gh=Math.pow(2,7),Wh=Math.pow(2,14),kh=Math.pow(2,21),Yh=Math.pow(2,28),Jh=Math.pow(2,35),Xh=Math.pow(2,42),Zh=Math.pow(2,49),Qh=Math.pow(2,56),ef=Math.pow(2,63),tf=function(t){return t<Gh?1:t<Wh?2:t<kh?3:t<Yh?4:t<Jh?5:t<Xh?6:t<Zh?7:t<Qh?8:t<ef?9:10},rf={encode:Bh,decode:Kh,encodingLength:tf},Ls=rf;const Us=(t,e,r=0)=>(Ls.encode(t,e,r),e),$s=t=>Ls.encodingLength(t),qn=(t,e)=>{const r=e.byteLength,n=$s(t),i=n+$s(r),s=new Uint8Array(i+r);return Us(t,s,0),Us(r,s,n),s.set(e,i),new nf(t,r,e,s)};class nf{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Ms=({name:t,code:e,encode:r})=>new sf(t,e,r);class sf{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?qn(this.code,r):r.then(n=>qn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const js=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),of=Ms({name:"sha2-256",code:18,encode:js("SHA-256")}),af=Ms({name:"sha2-512",code:19,encode:js("SHA-512")});var cf=Object.freeze({__proto__:null,sha256:of,sha512:af});const Bs=0,uf="identity",zs=Ts;var hf=Object.freeze({__proto__:null,identity:{code:Bs,name:uf,encode:zs,digest:t=>qn(Bs,zs(t))}});new TextEncoder,new TextDecoder;const qs={...nh,...sh,...ah,...uh,...lh,...Eh,...xh,...Ah,...Nh,...jh};({...cf,...hf});function Hs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Ks=Hs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Hn=Hs("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=As(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Vs={utf8:Ks,"utf-8":Ks,hex:qs.base16,latin1:Hn,ascii:Hn,binary:Hn,...qs};function ct(t,e="utf8"){const r=Vs[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 ut(t,e="utf8"){const r=Vs[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)}var Gs=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))},ff=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),lf=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),df=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}(),pf=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),gf=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),yf=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,_f=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ws=3,bf=[["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",yf]],ks=[["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 vf(t){return t?Ys(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new gf:typeof navigator<"u"?Ys(navigator.userAgent):Ef()}function wf(t){return t!==""&&bf.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 Ys(t){var e=wf(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new pf;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Ws&&(i=Gs(Gs([],i,!0),Df(Ws-i.length),!0)):i=[];var s=i.join("."),o=mf(t),c=_f.exec(t);return c&&c[1]?new df(r,s,o,c[1]):new ff(r,s,o)}function mf(t){for(var e=0,r=ks.length;e<r;e++){var n=ks[e],i=n[0],s=n[1],o=s.exec(t);if(o)return i}return null}function Ef(){var t=typeof process<"u"&&process.version;return t?new lf(process.version.slice(1)):null}function Df(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Z={};/*! *****************************************************************************
15
15
  Copyright (c) Microsoft Corporation.
16
16
 
17
17
  Permission to use, copy, modify, and/or distribute this software for any
@@ -24,7 +24,7 @@
24
24
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
25
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
- ***************************************************************************** */var yi=function(t,e){return yi=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])},yi(t,e)};function td(t,e){yi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var vi=function(){return vi=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},vi.apply(this,arguments)};function rd(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 nd(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 id(t,e){return function(r,n){e(r,n,t)}}function sd(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function od(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(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(a,f)}h((n=n.apply(t,e||[])).next())})}function ad(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(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function cd(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function ud(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function _i(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 Lo(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 fd(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Lo(arguments[e]));return t}function hd(){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 Cr(t){return this instanceof Cr?(this.v=t,this):new Cr(t)}function ld(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(v){n[v]&&(i[v]=function(m){return new Promise(function(w,P){s.push([v,m,w,P])>1||a(v,m)})})}function a(v,m){try{f(n[v](m))}catch(w){D(s[0][3],w)}}function f(v){v.value instanceof Cr?Promise.resolve(v.value.v).then(h,l):D(s[0][2],v)}function h(v){a("next",v)}function l(v){a("throw",v)}function D(v,m){v(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function dd(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:Cr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function pd(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 _i=="function"?_i(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,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(h){s({value:h,done:a})},o)}}function gd(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function yd(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 vd(t){return t&&t.__esModule?t:{default:t}}function _d(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function bd(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var md=Object.freeze({__proto__:null,__extends:td,get __assign(){return vi},__rest:rd,__decorate:nd,__param:id,__metadata:sd,__awaiter:od,__generator:ad,__createBinding:cd,__exportStar:ud,__values:_i,__read:Lo,__spread:fd,__spreadArrays:hd,__await:Cr,__asyncGenerator:ld,__asyncDelegator:dd,__asyncValues:pd,__makeTemplateObject:gd,__importStar:yd,__importDefault:vd,__classPrivateFieldGet:_d,__classPrivateFieldSet:bd}),gn=Zt(md),bi={},Rr={},Io;function wd(){if(Io)return Rr;Io=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Rr.delay=t,Rr}var Qt={},mi={},er={},Ao;function Ed(){return Ao||(Ao=1,Object.defineProperty(er,"__esModule",{value:!0}),er.ONE_THOUSAND=er.ONE_HUNDRED=void 0,er.ONE_HUNDRED=100,er.ONE_THOUSAND=1e3),er}var wi={},To;function Dd(){return To||(To=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}(wi)),wi}var Co;function Ro(){return Co||(Co=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(Ed(),t),e.__exportStar(Dd(),t)}(mi)),mi}var No;function xd(){if(No)return Qt;No=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.fromMiliseconds=Qt.toMiliseconds=void 0;const t=Ro();function e(n){return n*t.ONE_THOUSAND}Qt.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Qt.fromMiliseconds=r,Qt}var Po;function Sd(){return Po||(Po=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(wd(),t),e.__exportStar(xd(),t)}(bi)),bi}var dr={},$o;function Od(){if($o)return dr;$o=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.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 dr.Watch=t,dr.default=t,dr}var Ei={},Nr={},Fo;function Ld(){if(Fo)return Nr;Fo=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.IWatch=void 0;class t{}return Nr.IWatch=t,Nr}var Mo;function Id(){return Mo||(Mo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),gn.__exportStar(Ld(),t)}(Ei)),Ei}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=gn;e.__exportStar(Sd(),t),e.__exportStar(Od(),t),e.__exportStar(Id(),t),e.__exportStar(Ro(),t)})(Z);var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.getLocalStorage=Ce.getLocalStorageOrThrow=Ce.getCrypto=Ce.getCryptoOrThrow=jo=Ce.getLocation=Ce.getLocationOrThrow=Di=Ce.getNavigator=Ce.getNavigatorOrThrow=Uo=Ce.getDocument=Ce.getDocumentOrThrow=Ce.getFromWindowOrThrow=Ce.getFromWindow=void 0;function tr(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Ce.getFromWindow=tr;function pr(t){const e=tr(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Ce.getFromWindowOrThrow=pr;function Ad(){return pr("document")}Ce.getDocumentOrThrow=Ad;function Td(){return tr("document")}var Uo=Ce.getDocument=Td;function Cd(){return pr("navigator")}Ce.getNavigatorOrThrow=Cd;function Rd(){return tr("navigator")}var Di=Ce.getNavigator=Rd;function Nd(){return pr("location")}Ce.getLocationOrThrow=Nd;function Pd(){return tr("location")}var jo=Ce.getLocation=Pd;function $d(){return pr("crypto")}Ce.getCryptoOrThrow=$d;function Fd(){return tr("crypto")}Ce.getCrypto=Fd;function Md(){return pr("localStorage")}Ce.getLocalStorageOrThrow=Md;function Ud(){return tr("localStorage")}Ce.getLocalStorage=Ud;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});var Bo=xi.getWindowMetadata=void 0;const zo=Ce;function jd(){let t,e;try{t=zo.getDocumentOrThrow(),e=zo.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),v=[];for(let m=0;m<D.length;m++){const w=D[m],P=w.getAttribute("rel");if(P&&P.toLowerCase().indexOf("icon")>-1){const R=w.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let B=e.protocol+"//"+e.host;if(R.indexOf("/")===0)B+=R;else{const S=e.pathname.split("/");S.pop();const I=S.join("/");B+=I+"/"+R}v.push(B)}else if(R.indexOf("//")===0){const B=e.protocol+R;v.push(B)}else v.push(R)}}return v}function n(...D){const v=t.getElementsByTagName("meta");for(let m=0;m<v.length;m++){const w=v[m],P=["itemprop","property","name"].map(R=>w.getAttribute(R)).filter(R=>R?D.includes(R):!1);if(P.length&&P){const R=w.getAttribute("content");if(R)return R}}return""}function i(){let D=n("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),a=s(),f=e.origin,h=r();return{description:a,url:f,icons:h,name:o}}Bo=xi.getWindowMetadata=jd;var Pr={},Bd=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ko="%[a-f0-9]{2}",qo=new RegExp(Ko,"gi"),Ho=new RegExp("("+Ko+")+","gi");function Si(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Si(r),Si(n))}function zd(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(qo),r=1;r<e.length;r++)t=Si(e,r).join(""),e=t.match(qo);return t}}function Kd(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Ho.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=zd(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Ho.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var o=i[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var qd=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return Kd(t)}},Hd=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},Vd=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var o=n[s],a=t[o];(i?e.indexOf(o)!==-1:e(o,a,t))&&(r[o]=a)}return r};(function(t){const e=Bd,r=qd,n=Hd,i=Vd,s=S=>S==null,o=Symbol("encodeFragmentIdentifier");function a(S){switch(S.arrayFormat){case"index":return I=>(y,x)=>{const E=y.length;return x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),"[",E,"]"].join("")]:[...y,[l(I,S),"[",l(E,S),"]=",l(x,S)].join("")]};case"bracket":return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),"[]"].join("")]:[...y,[l(I,S),"[]=",l(x,S)].join("")];case"colon-list-separator":return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,[l(I,S),":list="].join("")]:[...y,[l(I,S),":list=",l(x,S)].join("")];case"comma":case"separator":case"bracket-separator":{const I=S.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(x,E)=>E===void 0||S.skipNull&&E===null||S.skipEmptyString&&E===""?x:(E=E===null?"":E,x.length===0?[[l(y,S),I,l(E,S)].join("")]:[[x,l(E,S)].join(S.arrayFormatSeparator)])}default:return I=>(y,x)=>x===void 0||S.skipNull&&x===null||S.skipEmptyString&&x===""?y:x===null?[...y,l(I,S)]:[...y,[l(I,S),"=",l(x,S)].join("")]}}function f(S){let I;switch(S.arrayFormat){case"index":return(y,x,E)=>{if(I=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!I){E[y]=x;return}E[y]===void 0&&(E[y]={}),E[y][I[1]]=x};case"bracket":return(y,x,E)=>{if(I=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!I){E[y]=x;return}if(E[y]===void 0){E[y]=[x];return}E[y]=[].concat(E[y],x)};case"colon-list-separator":return(y,x,E)=>{if(I=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!I){E[y]=x;return}if(E[y]===void 0){E[y]=[x];return}E[y]=[].concat(E[y],x)};case"comma":case"separator":return(y,x,E)=>{const c=typeof x=="string"&&x.includes(S.arrayFormatSeparator),d=typeof x=="string"&&!c&&D(x,S).includes(S.arrayFormatSeparator);x=d?D(x,S):x;const U=c||d?x.split(S.arrayFormatSeparator).map(K=>D(K,S)):x===null?x:D(x,S);E[y]=U};case"bracket-separator":return(y,x,E)=>{const c=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!c){E[y]=x&&D(x,S);return}const d=x===null?[]:x.split(S.arrayFormatSeparator).map(U=>D(U,S));if(E[y]===void 0){E[y]=d;return}E[y]=[].concat(E[y],d)};default:return(y,x,E)=>{if(E[y]===void 0){E[y]=x;return}E[y]=[].concat(E[y],x)}}}function h(S){if(typeof S!="string"||S.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function l(S,I){return I.encode?I.strict?e(S):encodeURIComponent(S):S}function D(S,I){return I.decode?r(S):S}function v(S){return Array.isArray(S)?S.sort():typeof S=="object"?v(Object.keys(S)).sort((I,y)=>Number(I)-Number(y)).map(I=>S[I]):S}function m(S){const I=S.indexOf("#");return I!==-1&&(S=S.slice(0,I)),S}function w(S){let I="";const y=S.indexOf("#");return y!==-1&&(I=S.slice(y)),I}function P(S){S=m(S);const I=S.indexOf("?");return I===-1?"":S.slice(I+1)}function R(S,I){return I.parseNumbers&&!Number.isNaN(Number(S))&&typeof S=="string"&&S.trim()!==""?S=Number(S):I.parseBooleans&&S!==null&&(S.toLowerCase()==="true"||S.toLowerCase()==="false")&&(S=S.toLowerCase()==="true"),S}function B(S,I){I=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},I),h(I.arrayFormatSeparator);const y=f(I),x=Object.create(null);if(typeof S!="string"||(S=S.trim().replace(/^[?#&]/,""),!S))return x;for(const E of S.split("&")){if(E==="")continue;let[c,d]=n(I.decode?E.replace(/\+/g," "):E,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(I.arrayFormat)?d:D(d,I),y(D(c,I),d,x)}for(const E of Object.keys(x)){const c=x[E];if(typeof c=="object"&&c!==null)for(const d of Object.keys(c))c[d]=R(c[d],I);else x[E]=R(c,I)}return I.sort===!1?x:(I.sort===!0?Object.keys(x).sort():Object.keys(x).sort(I.sort)).reduce((E,c)=>{const d=x[c];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?E[c]=v(d):E[c]=d,E},Object.create(null))}t.extract=P,t.parse=B,t.stringify=(S,I)=>{if(!S)return"";I=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},I),h(I.arrayFormatSeparator);const y=d=>I.skipNull&&s(S[d])||I.skipEmptyString&&S[d]==="",x=a(I),E={};for(const d of Object.keys(S))y(d)||(E[d]=S[d]);const c=Object.keys(E);return I.sort!==!1&&c.sort(I.sort),c.map(d=>{const U=S[d];return U===void 0?"":U===null?l(d,I):Array.isArray(U)?U.length===0&&I.arrayFormat==="bracket-separator"?l(d,I)+"[]":U.reduce(x(d),[]).join("&"):l(d,I)+"="+l(U,I)}).filter(d=>d.length>0).join("&")},t.parseUrl=(S,I)=>{I=Object.assign({decode:!0},I);const[y,x]=n(S,"#");return Object.assign({url:y.split("?")[0]||"",query:B(P(S),I)},I&&I.parseFragmentIdentifier&&x?{fragmentIdentifier:D(x,I)}:{})},t.stringifyUrl=(S,I)=>{I=Object.assign({encode:!0,strict:!0,[o]:!0},I);const y=m(S.url).split("?")[0]||"",x=t.extract(S.url),E=t.parse(x,{sort:!1}),c=Object.assign(E,S.query);let d=t.stringify(c,I);d&&(d=`?${d}`);let U=w(S.url);return S.fragmentIdentifier&&(U=`#${I[o]?l(S.fragmentIdentifier,I):S.fragmentIdentifier}`),`${y}${d}${U}`},t.pick=(S,I,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[o]:!1},y);const{url:x,query:E,fragmentIdentifier:c}=t.parseUrl(S,y);return t.stringifyUrl({url:x,query:i(E,I),fragmentIdentifier:c},y)},t.exclude=(S,I,y)=>{const x=Array.isArray(I)?E=>!I.includes(E):(E,c)=>!I(E,c);return t.pick(S,x,y)}})(Pr);const Gd={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Vo=":";function Wd(t){const{namespace:e,reference:r}=t;return[e,r].join(Vo)}function kd(t){const[e,r,n]=t.split(Vo);return{namespace:e,reference:r,address:n}}function Yd(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function Jd(t){const{namespace:e,reference:r}=kd(t);return Wd({namespace:e,reference:r})}function Xd(t){return Yd(t,Jd)}function Oi(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 Li(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...Xd(i.accounts))}),r}function Zd(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const Go="base10",gt="base16",Ii="base64pad",Ai="utf8",Wo=0,rr=1,Qd=0,ko=1,Ti=12,Ci=32;function ep(){const t=hi.generateKeyPair();return{privateKey:pt(t.secretKey,gt),publicKey:pt(t.publicKey,gt)}}function Ri(){const t=lr.randomBytes(Ci);return pt(t,gt)}function tp(t,e){const r=hi.sharedKey(dt(t,gt),dt(e,gt)),n=new lh(dn.SHA256,r).expand(Ci);return pt(n,gt)}function rp(t){const e=dn.hash(dt(t,gt));return pt(e,gt)}function Ni(t){const e=dn.hash(dt(t,Ai));return pt(e,gt)}function np(t){return dt(`${t}`,Go)}function $r(t){return Number(pt(t,Go))}function ip(t){const e=np(typeof t.type<"u"?t.type:Wo);if($r(e)===rr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?dt(t.senderPublicKey,gt):void 0,n=typeof t.iv<"u"?dt(t.iv,gt):lr.randomBytes(Ti),i=new ii.ChaCha20Poly1305(dt(t.symKey,gt)).seal(n,dt(t.message,Ai));return op({type:e,sealed:i,iv:n,senderPublicKey:r})}function sp(t){const e=new ii.ChaCha20Poly1305(dt(t.symKey,gt)),{sealed:r,iv:n}=Pi(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return pt(i,Ai)}function op(t){if($r(t.type)===rr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return pt(li([t.type,t.senderPublicKey,t.iv,t.sealed]),Ii)}return pt(li([t.type,t.iv,t.sealed]),Ii)}function Pi(t){const e=dt(t,Ii),r=e.slice(Qd,ko),n=ko;if($r(r)===rr){const a=n+Ci,f=a+Ti,h=e.slice(n,a),l=e.slice(a,f),D=e.slice(f);return{type:r,sealed:D,iv:l,senderPublicKey:h}}const i=n+Ti,s=e.slice(n,i),o=e.slice(i);return{type:r,sealed:o,iv:s}}function ap(t,e){const r=Pi(t);return Yo({type:$r(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?pt(r.senderPublicKey,gt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Yo(t){const e=t?.type||Wo;if(e===rr){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Jo(t){return t.type===rr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var cp=Object.defineProperty,Xo=Object.getOwnPropertySymbols,up=Object.prototype.hasOwnProperty,fp=Object.prototype.propertyIsEnumerable,Zo=(t,e,r)=>e in t?cp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qo=(t,e)=>{for(var r in e||(e={}))up.call(e,r)&&Zo(t,r,e[r]);if(Xo)for(var r of Xo(e))fp.call(e,r)&&Zo(t,r,e[r]);return t};const hp="ReactNative",Fr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},lp="js";function ea(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function dp(){return!Uo()&&!!Di()&&navigator.product===hp}function pp(){return!ea()&&!!Di()}function gp(){return dp()?Fr.reactNative:ea()?Fr.node:pp()?Fr.browser:Fr.unknown}function yp(t,e){let r=Pr.parse(t);return r=Qo(Qo({},r),e),t=Pr.stringify(r),t}function vp(){return Bo()||{name:"",description:"",url:"",icons:[""]}}function _p(){const t=Jl();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 bp(){var t;const e=gp();return e===Fr.browser?[e,((t=jo())==null?void 0:t.host)||"unknown"].join(":"):e}function mp(t,e,r){const n=_p(),i=bp();return[[t,e].join("-"),[lp,r].join("-"),n,i].join("/")}function wp({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const o=r.split("?"),a=mp(t,e,n),f={auth:i,ua:a,projectId:s},h=yp(o[1]||"",f);return o[0]+"?"+h}function yt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function ta(t){return Object.fromEntries(t.entries())}function ra(t){return new Map(Object.entries(t))}function Tt(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function Gt(t){return Z.fromMiliseconds(Date.now())>=Z.toMiliseconds(t)}function nr(t){const e=Z.toMiliseconds(t||Z.FIVE_MINUTES);let r,n,i;return{resolve:s=>{i&&r&&(clearTimeout(i),r(s))},reject:s=>{i&&n&&(clearTimeout(i),n(s))},done:()=>new Promise((s,o)=>{i=setTimeout(o,e),r=s,n=o})}}function na(t,e){return new Promise(async(r,n)=>{const i=setTimeout(()=>n(),e),s=await t;clearTimeout(i),r(s)})}function ia(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 Ep(t){return ia("topic",t)}function Dp(t){return ia("id",t)}function sa(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 je(t,e){return`${t}${e?`:${e}`:""}`}const xp="irn";function $i(t){return t?.relay||{protocol:xp}}function Fi(t){const e=Gd[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Sp=Object.defineProperty,oa=Object.getOwnPropertySymbols,Op=Object.prototype.hasOwnProperty,Lp=Object.prototype.propertyIsEnumerable,aa=(t,e,r)=>e in t?Sp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ip=(t,e)=>{for(var r in e||(e={}))Op.call(e,r)&&aa(t,r,e[r]);if(oa)for(var r of oa(e))Lp.call(e,r)&&aa(t,r,e[r]);return t};function Ap(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 Tp(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=Pr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:o.symKey,relay:Ap(o)}}function Cp(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function Rp(t){return`${t.protocol}:${t.topic}@${t.version}?`+Pr.stringify(Ip({symKey:t.symKey},Cp(t.relay)))}function Ct(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function Np(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Ct(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...Ct(n.accounts))})}),e}function Pp(t,e){const r=[];return Object.values(t).forEach(n=>{Ct(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{Ct(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function $p(t,e){const r=[];return Object.values(t).forEach(n=>{Ct(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{Ct(i.accounts).includes(e)&&r.push(...i.events)})}),r}function Fp(t,e){const r=vn(t,e);if(r)throw new Error(r.message);const n={};for(const[i,s]of Object.entries(t))n[i]={methods:s.methods,events:s.events,chains:s.accounts.map(o=>`${o.split(":")[0]}:${o.split(":")[1]}`)};return n}const Mp={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}},Up={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 V(t,e){const{message:r,code:n}=Up[t];return{message:e?`${r} ${e}`:r,code:n}}function Ge(t,e){const{message:r,code:n}=Mp[t];return{message:e?`${r} ${e}`:r,code:n}}function Mr(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function yn(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function bt(t){return typeof t>"u"}function st(t,e){return e&&bt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function Mi(t,e){return e&&bt(t)?!0:typeof t=="number"&&!isNaN(t)}function jp(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return yt(i,n)?(n.forEach(o=>{const{accounts:a,methods:f,events:h,extension:l}=t.namespaces[o],D=Ct(a),v=r[o];(!yt(v.chains,D)||!yt(v.methods,f)||!yt(v.events,h))&&(s=!1),s&&l&&l.forEach(m=>{var w;const{accounts:P,methods:R,events:B}=m,S=Ct(P);(w=v.extension)!=null&&w.find(I=>yt(I.chains,S)&&yt(I.methods,R)&&yt(I.events,B))||(s=!1)})}),s):!1}function Ui(t){return st(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Bp(t){if(st(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Ui(r)}}return!1}function zp(t){if(st(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function Kp(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function qp(t){return t?.topic}function Hp(t,e){let r=null;return st(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function ji(t,e){let r=null;return bt(t?.extension)||(!Mr(t.extension)||!t.extension.length)&&(r=V("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function ca(t){let e=!0;return Mr(t)?t.length&&(e=t.every(r=>st(r,!1))):e=!1,e}function ua(t,e,r){let n=null;return Mr(e)?e.forEach(i=>{n||(!Ui(i)||!i.includes(t))&&(n=Ge("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=Ge("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function Vp(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=ua(n,i?.chains,`${e} requiredNamespace`),o=ji(i,e);s?r=s:o?r=o:i.extension&&i.extension.forEach(a=>{if(r)return;const f=ua(n,a.chains,`${e} extension`);f&&(r=f)})}),r}function fa(t,e){let r=null;return Mr(t)?t.forEach(n=>{r||Bp(n)||(r=Ge("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Ge("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Gp(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=fa(n?.accounts,`${e} namespace`),s=ji(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(o=>{if(r)return;const a=fa(o.accounts,`${e} extension`);a&&(r=a)})}),r}function ha(t,e){let r=null;return ca(t?.methods)?ca(t?.events)||(r=Ge("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Ge("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function la(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=ha(n,`${e}, namespace`),s=ji(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(o=>{if(r)return;const a=ha(o,`${e}, extension`);a&&(r=a)})}),r}function Wp(t,e){let r=null;if(t&&yn(t)){const n=la(t,e);n&&(r=n);const i=Vp(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function vn(t,e){let r=null;if(t&&yn(t)){const n=la(t,e);n&&(r=n);const i=Gp(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function da(t){return st(t.protocol,!0)}function kp(t,e){let r=!1;return e&&!t?r=!0:t&&Mr(t)&&t.length&&t.forEach(n=>{r=da(n)}),r}function Yp(t){return typeof t=="number"}function vt(t){return typeof t<"u"&&typeof t!==null}function Jp(t){return!(!t||typeof t!="object"||!t.code||!Mi(t.code,!1)||!t.message||!st(t.message,!1))}function Xp(t){return!(bt(t)||!st(t.method,!1))}function Zp(t){return!(bt(t)||bt(t.result)&&bt(t.error)||!Mi(t.id,!1)||!st(t.jsonrpc,!1))}function Qp(t){return!(bt(t)||!st(t.name,!1))}function pa(t,e){return!(!Ui(e)||!Np(t).includes(e))}function eg(t,e,r){return st(r,!1)?Pp(t,e).includes(r):!1}function tg(t,e,r){return st(r,!1)?$p(t,e).includes(r):!1}function ga(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return yt(i,s)?i.forEach(o=>{var a;if(n)return;const f=t[o].chains,h=Ct(e[o].accounts);yt(f,h)?yt(t[o].methods,e[o].methods)?yt(t[o].events,e[o].events)?t[o].extension&&!e[o].extension?n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${o}`):t[o].extension&&e[o].extension&&((a=t[o].extension)==null||a.forEach(({methods:l,events:D,chains:v})=>{var m;n||(m=e[o].extension)!=null&&m.find(w=>{const P=Ct(w.accounts);return yt(v,P)&&yt(D,w.events)&&yt(l,w.methods)})||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${o}`))})):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${o}`)}):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function rg(t,e){return Mi(t,!1)&&t<=e.max&&t>=e.min}function ng(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var ig=sg;function sg(t,e,r){var n=r&&r.stringify||ng,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var a=1;a<s;a++)o[a]=n(e[a]);return o.join(" ")}if(typeof t!="string")return t;var f=e.length;if(f===0)return t;for(var h="",l=1-i,D=-1,v=t&&t.length||0,m=0;m<v;){if(t.charCodeAt(m)===37&&m+1<v){switch(D=D>-1?D:0,t.charCodeAt(m+1)){case 100:case 102:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Number(e[l]),D=m+2,m++;break;case 105:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Math.floor(Number(e[l])),D=m+2,m++;break;case 79:case 111:case 106:if(l>=f||e[l]===void 0)break;D<m&&(h+=t.slice(D,m));var w=typeof e[l];if(w==="string"){h+="'"+e[l]+"'",D=m+2,m++;break}if(w==="function"){h+=e[l].name||"<anonymous>",D=m+2,m++;break}h+=n(e[l]),D=m+2,m++;break;case 115:if(l>=f)break;D<m&&(h+=t.slice(D,m)),h+=String(e[l]),D=m+2,m++;break;case 37:D<m&&(h+=t.slice(D,m)),h+="%",D=m+2,m++,l--;break}++l}++m}return D===-1?t:(D<v&&(h+=t.slice(D)),h)}const ya=ig;var _n=Rt;const Ur=gg().console||{},og={mapHttpRequest:mn,mapHttpResponse:mn,wrapRequestSerializer:zi,wrapResponseSerializer:zi,wrapErrorSerializer:zi,req:mn,res:mn,err:hg};function ag(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Rt(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||Ur;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=ag(t.browser.serialize,n);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",f=Object.create(r);f.log||(f.log=jr),Object.defineProperty(f,"levelVal",{get:l}),Object.defineProperty(f,"level",{get:D,set:v});const h={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:lg(t)};f.levels=Rt.levels,f.level=a,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=jr,f.serializers=n,f._serialize=i,f._stdErrSerialize=s,f.child=m,e&&(f._logEvent=Bi());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function v(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,gr(h,f,"error","log"),gr(h,f,"fatal","error"),gr(h,f,"warn","error"),gr(h,f,"info","log"),gr(h,f,"debug","log"),gr(h,f,"trace","log")}function m(w,P){if(!w)throw new Error("missing bindings for child Pino");P=P||{},i&&w.serializers&&(P.serializers=w.serializers);const R=P.serializers;if(i&&R){var B=Object.assign({},n,R),S=t.browser.serialize===!0?Object.keys(B):i;delete w.serializers,bn([w],S,B,this._stdErrSerialize)}function I(y){this._childLevel=(y._childLevel|0)+1,this.error=yr(y,w,"error"),this.fatal=yr(y,w,"fatal"),this.warn=yr(y,w,"warn"),this.info=yr(y,w,"info"),this.debug=yr(y,w,"debug"),this.trace=yr(y,w,"trace"),B&&(this.serializers=B,this._serialize=S),e&&(this._logEvent=Bi([].concat(y._logEvent.bindings,w)))}return I.prototype=this,new I(this)}return f}Rt.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Rt.stdSerializers=og,Rt.stdTimeFunctions=Object.assign({},{nullTime:va,epochTime:_a,unixTime:dg,isoTime:pg});function gr(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?jr:i[r]?i[r]:Ur[r]||Ur[n]||jr,cg(t,e,r)}function cg(t,e,r){!t.transmit&&e[r]===jr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ur?Ur:this;for(var f=0;f<o.length;f++)o[f]=arguments[f];if(t.serialize&&!t.asObject&&bn(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(a,ug(this,r,o,s)):n.apply(a,o),t.transmit){const h=t.transmit.level||e.level,l=Rt.levels.values[h],D=Rt.levels.values[r];if(D<l)return;fg(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:h,transmitValue:Rt.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function ug(t,e,r,n){t._serialize&&bn(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const o={};n&&(o.time=n),o.level=Rt.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof i[0]=="object";)Object.assign(o,i.shift());s=i.length?ya(i.shift(),i):void 0}else typeof s=="string"&&(s=ya(i.shift(),i));return s!==void 0&&(o.msg=s),o}function bn(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=Rt.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(const s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function yr(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function fg(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,f=t._logEvent.bindings;bn(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(h){return f.indexOf(h)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,n(s,t._logEvent,a),t._logEvent=Bi(f)}function Bi(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function hg(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function lg(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?va:_a}function mn(){return{}}function zi(t){return t}function jr(){}function va(){return!1}function _a(){return Date.now()}function dg(){return Math.round(Date.now()/1e3)}function pg(){return new Date(Date.now()).toISOString()}function gg(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}var zt={exports:{}},vr=typeof Reflect=="object"?Reflect:null,ba=vr&&typeof vr.apply=="function"?vr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},wn;vr&&typeof vr.ownKeys=="function"?wn=vr.ownKeys:Object.getOwnPropertySymbols?wn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:wn=function(e){return Object.getOwnPropertyNames(e)};function yg(t){console&&console.warn&&console.warn(t)}var ma=Number.isNaN||function(e){return e!==e};function Se(){Se.init.call(this)}zt.exports=Se,zt.exports.once=mg,Se.EventEmitter=Se,Se.prototype._events=void 0,Se.prototype._eventsCount=0,Se.prototype._maxListeners=void 0;var wa=10;function En(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Se,"defaultMaxListeners",{enumerable:!0,get:function(){return wa},set:function(t){if(typeof t!="number"||t<0||ma(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");wa=t}}),Se.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},Se.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ma(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 Ea(t){return t._maxListeners===void 0?Se.defaultMaxListeners:t._maxListeners}Se.prototype.getMaxListeners=function(){return Ea(this)},Se.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")ba(f,this,r);else for(var h=f.length,l=La(f,h),n=0;n<h;++n)ba(l[n],this,r);return!0};function Da(t,e,r,n){var i,s,o;if(En(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=Ea(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,yg(a)}return t}Se.prototype.addListener=function(e,r){return Da(this,e,r,!1)},Se.prototype.on=Se.prototype.addListener,Se.prototype.prependListener=function(e,r){return Da(this,e,r,!0)};function vg(){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 xa(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=vg.bind(n);return i.listener=r,n.wrapFn=i,i}Se.prototype.once=function(e,r){return En(r),this.on(e,xa(this,e,r)),this},Se.prototype.prependOnceListener=function(e,r){return En(r),this.prependListener(e,xa(this,e,r)),this},Se.prototype.removeListener=function(e,r){var n,i,s,o,a;if(En(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():_g(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Se.prototype.off=Se.prototype.removeListener,Se.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 Sa(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?bg(i):La(i,i.length)}Se.prototype.listeners=function(e){return Sa(this,e,!0)},Se.prototype.rawListeners=function(e){return Sa(this,e,!1)},Se.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Oa.call(t,e)},Se.prototype.listenerCount=Oa;function Oa(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}Se.prototype.eventNames=function(){return this._eventsCount>0?wn(this._events):[]};function La(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function _g(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function bg(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function mg(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))}Ia(t,e,s,{once:!0}),e!=="error"&&wg(t,i,{once:!0})})}function wg(t,e,r){typeof t.on=="function"&&Ia(t,"error",e,r)}function Ia(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 Dn={};/*! *****************************************************************************
27
+ ***************************************************************************** */var Kn=function(t,e){return Kn=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])},Kn(t,e)};function Sf(t,e){Kn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Vn=function(){return Vn=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},Vn.apply(this,arguments)};function xf(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 Of(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 If(t,e){return function(r,n){e(r,n,t)}}function Af(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Tf(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 c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Pf(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Rf(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Cf(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Gn(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 Js(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(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Nf(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Js(arguments[e]));return t}function Ff(){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,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function _r(t){return this instanceof _r?(this.v=t,this):new _r(t)}function Lf(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(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof _r?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Uf(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:_r(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function $f(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 Gn=="function"?Gn(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(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Mf(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function jf(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 Bf(t){return t&&t.__esModule?t:{default:t}}function zf(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function qf(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var Hf=Object.freeze({__proto__:null,__extends:Sf,get __assign(){return Vn},__rest:xf,__decorate:Of,__param:If,__metadata:Af,__awaiter:Tf,__generator:Pf,__createBinding:Rf,__exportStar:Cf,__values:Gn,__read:Js,__spread:Nf,__spreadArrays:Ff,__await:_r,__asyncGenerator:Lf,__asyncDelegator:Uf,__asyncValues:$f,__makeTemplateObject:Mf,__importStar:jf,__importDefault:Bf,__classPrivateFieldGet:zf,__classPrivateFieldSet:qf}),en=Kt(Hf),Wn={},br={},Xs;function Kf(){if(Xs)return br;Xs=1,Object.defineProperty(br,"__esModule",{value:!0}),br.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return br.delay=t,br}var Vt={},kn={},Gt={},Zs;function Vf(){return Zs||(Zs=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.ONE_THOUSAND=Gt.ONE_HUNDRED=void 0,Gt.ONE_HUNDRED=100,Gt.ONE_THOUSAND=1e3),Gt}var Yn={},Qs;function Gf(){return Qs||(Qs=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}(Yn)),Yn}var eo;function to(){return eo||(eo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(Vf(),t),e.__exportStar(Gf(),t)}(kn)),kn}var ro;function Wf(){if(ro)return Vt;ro=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.fromMiliseconds=Vt.toMiliseconds=void 0;const t=to();function e(n){return n*t.ONE_THOUSAND}Vt.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return Vt.fromMiliseconds=r,Vt}var no;function kf(){return no||(no=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(Kf(),t),e.__exportStar(Wf(),t)}(Wn)),Wn}var sr={},io;function Yf(){if(io)return sr;io=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.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 sr.Watch=t,sr.default=t,sr}var Jn={},vr={},so;function Jf(){if(so)return vr;so=1,Object.defineProperty(vr,"__esModule",{value:!0}),vr.IWatch=void 0;class t{}return vr.IWatch=t,vr}var oo;function Xf(){return oo||(oo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),en.__exportStar(Jf(),t)}(Jn)),Jn}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=en;e.__exportStar(kf(),t),e.__exportStar(Yf(),t),e.__exportStar(Xf(),t),e.__exportStar(to(),t)})(Z);var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.getLocalStorage=Oe.getLocalStorageOrThrow=Oe.getCrypto=Oe.getCryptoOrThrow=co=Oe.getLocation=Oe.getLocationOrThrow=Xn=Oe.getNavigator=Oe.getNavigatorOrThrow=ao=Oe.getDocument=Oe.getDocumentOrThrow=Oe.getFromWindowOrThrow=Oe.getFromWindow=void 0;function Wt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Oe.getFromWindow=Wt;function or(t){const e=Wt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Oe.getFromWindowOrThrow=or;function Zf(){return or("document")}Oe.getDocumentOrThrow=Zf;function Qf(){return Wt("document")}var ao=Oe.getDocument=Qf;function el(){return or("navigator")}Oe.getNavigatorOrThrow=el;function tl(){return Wt("navigator")}var Xn=Oe.getNavigator=tl;function rl(){return or("location")}Oe.getLocationOrThrow=rl;function nl(){return Wt("location")}var co=Oe.getLocation=nl;function il(){return or("crypto")}Oe.getCryptoOrThrow=il;function sl(){return Wt("crypto")}Oe.getCrypto=sl;function ol(){return or("localStorage")}Oe.getLocalStorageOrThrow=ol;function al(){return Wt("localStorage")}Oe.getLocalStorage=al;var Zn={};Object.defineProperty(Zn,"__esModule",{value:!0});var uo=Zn.getWindowMetadata=void 0;const ho=Oe;function cl(){let t,e;try{t=ho.getDocumentOrThrow(),e=ho.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),w=[];for(let m=0;m<D.length;m++){const E=D[m],F=E.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const N=E.getAttribute("href");if(N)if(N.toLowerCase().indexOf("https:")===-1&&N.toLowerCase().indexOf("http:")===-1&&N.indexOf("//")!==0){let B=e.protocol+"//"+e.host;if(N.indexOf("/")===0)B+=N;else{const x=e.pathname.split("/");x.pop();const A=x.join("/");B+=A+"/"+N}w.push(B)}else if(N.indexOf("//")===0){const B=e.protocol+N;w.push(B)}else w.push(N)}}return w}function n(...D){const w=t.getElementsByTagName("meta");for(let m=0;m<w.length;m++){const E=w[m],F=["itemprop","property","name"].map(N=>E.getAttribute(N)).filter(N=>N?D.includes(N):!1);if(F.length&&F){const N=E.getAttribute("content");if(N)return N}}return""}function i(){let D=n("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),c=s(),f=e.origin,h=r();return{description:c,url:f,icons:h,name:o}}uo=Zn.getWindowMetadata=cl;var wr={},ul=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),fo="%[a-f0-9]{2}",lo=new RegExp("("+fo+")|([^%]+?)","gi"),po=new RegExp("("+fo+")+","gi");function Qn(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Qn(r),Qn(n))}function hl(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(lo)||[],r=1;r<e.length;r++)t=Qn(e,r).join(""),e=t.match(lo)||[];return t}}function fl(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=po.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=hl(r[0]);n!==r[0]&&(e[r[0]]=n)}r=po.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var o=i[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var ll=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return fl(t)}},dl=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},pl=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var o=n[s],c=t[o];(i?e.indexOf(o)!==-1:e(o,c,t))&&(r[o]=c)}return r};(function(t){const e=ul,r=ll,n=dl,i=pl,s=x=>x==null,o=Symbol("encodeFragmentIdentifier");function c(x){switch(x.arrayFormat){case"index":return A=>(y,S)=>{const v=y.length;return S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),"[",v,"]"].join("")]:[...y,[l(A,x),"[",l(v,x),"]=",l(S,x)].join("")]};case"bracket":return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),"[]"].join("")]:[...y,[l(A,x),"[]=",l(S,x)].join("")];case"colon-list-separator":return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,[l(A,x),":list="].join("")]:[...y,[l(A,x),":list=",l(S,x)].join("")];case"comma":case"separator":case"bracket-separator":{const A=x.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(S,v)=>v===void 0||x.skipNull&&v===null||x.skipEmptyString&&v===""?S:(v=v===null?"":v,S.length===0?[[l(y,x),A,l(v,x)].join("")]:[[S,l(v,x)].join(x.arrayFormatSeparator)])}default:return A=>(y,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?y:S===null?[...y,l(A,x)]:[...y,[l(A,x),"=",l(S,x)].join("")]}}function f(x){let A;switch(x.arrayFormat){case"index":return(y,S,v)=>{if(A=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!A){v[y]=S;return}v[y]===void 0&&(v[y]={}),v[y][A[1]]=S};case"bracket":return(y,S,v)=>{if(A=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!A){v[y]=S;return}if(v[y]===void 0){v[y]=[S];return}v[y]=[].concat(v[y],S)};case"colon-list-separator":return(y,S,v)=>{if(A=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!A){v[y]=S;return}if(v[y]===void 0){v[y]=[S];return}v[y]=[].concat(v[y],S)};case"comma":case"separator":return(y,S,v)=>{const a=typeof S=="string"&&S.includes(x.arrayFormatSeparator),d=typeof S=="string"&&!a&&D(S,x).includes(x.arrayFormatSeparator);S=d?D(S,x):S;const M=a||d?S.split(x.arrayFormatSeparator).map(q=>D(q,x)):S===null?S:D(S,x);v[y]=M};case"bracket-separator":return(y,S,v)=>{const a=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!a){v[y]=S&&D(S,x);return}const d=S===null?[]:S.split(x.arrayFormatSeparator).map(M=>D(M,x));if(v[y]===void 0){v[y]=d;return}v[y]=[].concat(v[y],d)};default:return(y,S,v)=>{if(v[y]===void 0){v[y]=S;return}v[y]=[].concat(v[y],S)}}}function h(x){if(typeof x!="string"||x.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function l(x,A){return A.encode?A.strict?e(x):encodeURIComponent(x):x}function D(x,A){return A.decode?r(x):x}function w(x){return Array.isArray(x)?x.sort():typeof x=="object"?w(Object.keys(x)).sort((A,y)=>Number(A)-Number(y)).map(A=>x[A]):x}function m(x){const A=x.indexOf("#");return A!==-1&&(x=x.slice(0,A)),x}function E(x){let A="";const y=x.indexOf("#");return y!==-1&&(A=x.slice(y)),A}function F(x){x=m(x);const A=x.indexOf("?");return A===-1?"":x.slice(A+1)}function N(x,A){return A.parseNumbers&&!Number.isNaN(Number(x))&&typeof x=="string"&&x.trim()!==""?x=Number(x):A.parseBooleans&&x!==null&&(x.toLowerCase()==="true"||x.toLowerCase()==="false")&&(x=x.toLowerCase()==="true"),x}function B(x,A){A=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},A),h(A.arrayFormatSeparator);const y=f(A),S=Object.create(null);if(typeof x!="string"||(x=x.trim().replace(/^[?#&]/,""),!x))return S;for(const v of x.split("&")){if(v==="")continue;let[a,d]=n(A.decode?v.replace(/\+/g," "):v,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?d:D(d,A),y(D(a,A),d,S)}for(const v of Object.keys(S)){const a=S[v];if(typeof a=="object"&&a!==null)for(const d of Object.keys(a))a[d]=N(a[d],A);else S[v]=N(a,A)}return A.sort===!1?S:(A.sort===!0?Object.keys(S).sort():Object.keys(S).sort(A.sort)).reduce((v,a)=>{const d=S[a];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?v[a]=w(d):v[a]=d,v},Object.create(null))}t.extract=F,t.parse=B,t.stringify=(x,A)=>{if(!x)return"";A=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},A),h(A.arrayFormatSeparator);const y=d=>A.skipNull&&s(x[d])||A.skipEmptyString&&x[d]==="",S=c(A),v={};for(const d of Object.keys(x))y(d)||(v[d]=x[d]);const a=Object.keys(v);return A.sort!==!1&&a.sort(A.sort),a.map(d=>{const M=x[d];return M===void 0?"":M===null?l(d,A):Array.isArray(M)?M.length===0&&A.arrayFormat==="bracket-separator"?l(d,A)+"[]":M.reduce(S(d),[]).join("&"):l(d,A)+"="+l(M,A)}).filter(d=>d.length>0).join("&")},t.parseUrl=(x,A)=>{A=Object.assign({decode:!0},A);const[y,S]=n(x,"#");return Object.assign({url:y.split("?")[0]||"",query:B(F(x),A)},A&&A.parseFragmentIdentifier&&S?{fragmentIdentifier:D(S,A)}:{})},t.stringifyUrl=(x,A)=>{A=Object.assign({encode:!0,strict:!0,[o]:!0},A);const y=m(x.url).split("?")[0]||"",S=t.extract(x.url),v=t.parse(S,{sort:!1}),a=Object.assign(v,x.query);let d=t.stringify(a,A);d&&(d=`?${d}`);let M=E(x.url);return x.fragmentIdentifier&&(M=`#${A[o]?l(x.fragmentIdentifier,A):x.fragmentIdentifier}`),`${y}${d}${M}`},t.pick=(x,A,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[o]:!1},y);const{url:S,query:v,fragmentIdentifier:a}=t.parseUrl(x,y);return t.stringifyUrl({url:S,query:i(v,A),fragmentIdentifier:a},y)},t.exclude=(x,A,y)=>{const S=Array.isArray(A)?v=>!A.includes(v):(v,a)=>!A(v,a);return t.pick(x,S,y)}})(wr);const gl={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},go=":";function yl(t){const{namespace:e,reference:r}=t;return[e,r].join(go)}function _l(t){const[e,r,n]=t.split(go);return{namespace:e,reference:r,address:n}}function bl(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function vl(t){const{namespace:e,reference:r}=_l(t);return yl({namespace:e,reference:r})}function wl(t){return bl(t,vl)}function ei(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 ti(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...wl(i.accounts))}),r}function ml(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const yo="base10",ht="base16",ri="base64pad",ni="utf8",_o=0,kt=1,El=0,bo=1,ii=12,si=32;function Dl(){const t=jn.generateKeyPair();return{privateKey:ut(t.secretKey,ht),publicKey:ut(t.publicKey,ht)}}function oi(){const t=ir.randomBytes(si);return ut(t,ht)}function Sl(t,e){const r=jn.sharedKey(ct(t,ht),ct(e,ht)),n=new Fu(Zr.SHA256,r).expand(si);return ut(n,ht)}function xl(t){const e=Zr.hash(ct(t,ht));return ut(e,ht)}function ai(t){const e=Zr.hash(ct(t,ni));return ut(e,ht)}function Ol(t){return ct(`${t}`,yo)}function mr(t){return Number(ut(t,yo))}function Il(t){const e=Ol(typeof t.type<"u"?t.type:_o);if(mr(e)===kt&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ct(t.senderPublicKey,ht):void 0,n=typeof t.iv<"u"?ct(t.iv,ht):ir.randomBytes(ii),i=new Cn.ChaCha20Poly1305(ct(t.symKey,ht)).seal(n,ct(t.message,ni));return Tl({type:e,sealed:i,iv:n,senderPublicKey:r})}function Al(t){const e=new Cn.ChaCha20Poly1305(ct(t.symKey,ht)),{sealed:r,iv:n}=ci(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ut(i,ni)}function Tl(t){if(mr(t.type)===kt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ut(Bn([t.type,t.senderPublicKey,t.iv,t.sealed]),ri)}return ut(Bn([t.type,t.iv,t.sealed]),ri)}function ci(t){const e=ct(t,ri),r=e.slice(El,bo),n=bo;if(mr(r)===kt){const c=n+si,f=c+ii,h=e.slice(n,c),l=e.slice(c,f),D=e.slice(f);return{type:r,sealed:D,iv:l,senderPublicKey:h}}const i=n+ii,s=e.slice(n,i),o=e.slice(i);return{type:r,sealed:o,iv:s}}function Pl(t,e){const r=ci(t);return vo({type:mr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ut(r.senderPublicKey,ht):void 0,receiverPublicKey:e?.receiverPublicKey})}function vo(t){const e=t?.type||_o;if(e===kt){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function wo(t){return t.type===kt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var Rl=Object.defineProperty,mo=Object.getOwnPropertySymbols,Cl=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,Eo=(t,e,r)=>e in t?Rl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Do=(t,e)=>{for(var r in e||(e={}))Cl.call(e,r)&&Eo(t,r,e[r]);if(mo)for(var r of mo(e))Nl.call(e,r)&&Eo(t,r,e[r]);return t};const Fl="ReactNative",Er={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Ll="js";function So(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ul(){return!ao()&&!!Xn()&&navigator.product===Fl}function $l(){return!So()&&!!Xn()}function Ml(){return Ul()?Er.reactNative:So()?Er.node:$l()?Er.browser:Er.unknown}function jl(t,e){let r=wr.parse(t);return r=Do(Do({},r),e),t=wr.stringify(r),t}function Bl(){return uo()||{name:"",description:"",url:"",icons:[""]}}function zl(){const t=vf();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 ql(){var t;const e=Ml();return e===Er.browser?[e,((t=co())==null?void 0:t.host)||"unknown"].join(":"):e}function Hl(t,e,r){const n=zl(),i=ql();return[[t,e].join("-"),[Ll,r].join("-"),n,i].join("/")}function Kl({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const o=r.split("?"),c=Hl(t,e,n),f={auth:i,ua:c,projectId:s},h=jl(o[1]||"",f);return o[0]+"?"+h}function $t(t,e){return t.filter(r=>e.includes(r)).length===t.length}function xo(t){return Object.fromEntries(t.entries())}function Oo(t){return new Map(Object.entries(t))}function St(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function Mt(t){return Z.fromMiliseconds(Date.now())>=Z.toMiliseconds(t)}function Yt(t){const e=Z.toMiliseconds(t||Z.FIVE_MINUTES);let r,n,i;return{resolve:s=>{i&&r&&(clearTimeout(i),r(s))},reject:s=>{i&&n&&(clearTimeout(i),n(s))},done:()=>new Promise((s,o)=>{i=setTimeout(o,e),r=s,n=o})}}function Io(t,e){return new Promise(async(r,n)=>{const i=setTimeout(()=>n(),e),s=await t;clearTimeout(i),r(s)})}function Ao(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 Vl(t){return Ao("topic",t)}function Gl(t){return Ao("id",t)}function To(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 Fe(t,e){return`${t}${e?`:${e}`:""}`}const Wl="irn";function ui(t){return t?.relay||{protocol:Wl}}function hi(t){const e=gl[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var kl=Object.defineProperty,Po=Object.getOwnPropertySymbols,Yl=Object.prototype.hasOwnProperty,Jl=Object.prototype.propertyIsEnumerable,Ro=(t,e,r)=>e in t?kl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xl=(t,e)=>{for(var r in e||(e={}))Yl.call(e,r)&&Ro(t,r,e[r]);if(Po)for(var r of Po(e))Jl.call(e,r)&&Ro(t,r,e[r]);return t};function Zl(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 Ql(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=wr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:o.symKey,relay:Zl(o)}}function ed(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function td(t){return`${t.protocol}:${t.topic}@${t.version}?`+wr.stringify(Xl({symKey:t.symKey},ed(t.relay)))}function Dr(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function rd(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Dr(r.accounts))}),e}function nd(t,e){const r=[];return Object.values(t).forEach(n=>{Dr(n.accounts).includes(e)&&r.push(...n.methods)}),r}function id(t,e){const r=[];return Object.values(t).forEach(n=>{Dr(n.accounts).includes(e)&&r.push(...n.events)}),r}function sd(t,e){const r=nn(t,e);if(r)throw new Error(r.message);const n={};for(const[i,s]of Object.entries(t))n[i]={methods:s.methods,events:s.events,chains:s.accounts.map(o=>`${o.split(":")[0]}:${o.split(":")[1]}`)};return n}const od={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}},ad={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 V(t,e){const{message:r,code:n}=ad[t];return{message:e?`${r} ${e}`:r,code:n}}function ze(t,e){const{message:r,code:n}=od[t];return{message:e?`${r} ${e}`:r,code:n}}function tn(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function rn(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function gt(t){return typeof t>"u"}function et(t,e){return e&&gt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function fi(t,e){return e&&gt(t)?!0:typeof t=="number"&&!isNaN(t)}function cd(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return $t(i,n)?(n.forEach(o=>{const{accounts:c,methods:f,events:h}=t.namespaces[o],l=Dr(c),D=r[o];(!$t(D.chains,l)||!$t(D.methods,f)||!$t(D.events,h))&&(s=!1)}),s):!1}function li(t){return et(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function ud(t){if(et(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&li(r)}}return!1}function hd(t){if(et(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function fd(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function ld(t){return t?.topic}function dd(t,e){let r=null;return et(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Co(t){let e=!0;return tn(t)?t.length&&(e=t.every(r=>et(r,!1))):e=!1,e}function pd(t,e,r){let n=null;return tn(e)?e.forEach(i=>{n||(!li(i)||!i.includes(t))&&(n=ze("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=ze("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function gd(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=pd(n,i?.chains,`${e} requiredNamespace`);s&&(r=s)}),r}function yd(t,e){let r=null;return tn(t)?t.forEach(n=>{r||ud(n)||(r=ze("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=ze("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function _d(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=yd(n?.accounts,`${e} namespace`);i&&(r=i)}),r}function bd(t,e){let r=null;return Co(t?.methods)?Co(t?.events)||(r=ze("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ze("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function No(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=bd(n,`${e}, namespace`);i&&(r=i)}),r}function vd(t,e){let r=null;if(t&&rn(t)){const n=No(t,e);n&&(r=n);const i=gd(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function nn(t,e){let r=null;if(t&&rn(t)){const n=No(t,e);n&&(r=n);const i=_d(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Fo(t){return et(t.protocol,!0)}function wd(t,e){let r=!1;return e&&!t?r=!0:t&&tn(t)&&t.length&&t.forEach(n=>{r=Fo(n)}),r}function md(t){return typeof t=="number"}function ft(t){return typeof t<"u"&&typeof t!==null}function Ed(t){return!(!t||typeof t!="object"||!t.code||!fi(t.code,!1)||!t.message||!et(t.message,!1))}function Dd(t){return!(gt(t)||!et(t.method,!1))}function Sd(t){return!(gt(t)||gt(t.result)&&gt(t.error)||!fi(t.id,!1)||!et(t.jsonrpc,!1))}function xd(t){return!(gt(t)||!et(t.name,!1))}function Lo(t,e){return!(!li(e)||!rd(t).includes(e))}function Od(t,e,r){return et(r,!1)?nd(t,e).includes(r):!1}function Id(t,e,r){return et(r,!1)?id(t,e).includes(r):!1}function Uo(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return $t(i,s)?i.forEach(o=>{if(n)return;const c=t[o].chains,f=Dr(e[o].accounts);$t(c,f)?$t(t[o].methods,e[o].methods)?$t(t[o].events,e[o].events)||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${o}`)):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${o}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${o}`)}):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function Ad(t,e){return fi(t,!1)&&t<=e.max&&t>=e.min}function Td(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Pd=Rd;function Rd(t,e,r){var n=r&&r.stringify||Td,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var c=1;c<s;c++)o[c]=n(e[c]);return o.join(" ")}if(typeof t!="string")return t;var f=e.length;if(f===0)return t;for(var h="",l=1-i,D=-1,w=t&&t.length||0,m=0;m<w;){if(t.charCodeAt(m)===37&&m+1<w){switch(D=D>-1?D:0,t.charCodeAt(m+1)){case 100:case 102:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Number(e[l]),D=m+2,m++;break;case 105:if(l>=f||e[l]==null)break;D<m&&(h+=t.slice(D,m)),h+=Math.floor(Number(e[l])),D=m+2,m++;break;case 79:case 111:case 106:if(l>=f||e[l]===void 0)break;D<m&&(h+=t.slice(D,m));var E=typeof e[l];if(E==="string"){h+="'"+e[l]+"'",D=m+2,m++;break}if(E==="function"){h+=e[l].name||"<anonymous>",D=m+2,m++;break}h+=n(e[l]),D=m+2,m++;break;case 115:if(l>=f)break;D<m&&(h+=t.slice(D,m)),h+=String(e[l]),D=m+2,m++;break;case 37:D<m&&(h+=t.slice(D,m)),h+="%",D=m+2,m++,l--;break}++l}++m}return D===-1?t:(D<w&&(h+=t.slice(D)),h)}const $o=Pd;var sn=xt;const Sr=zd().console||{},Cd={mapHttpRequest:an,mapHttpResponse:an,wrapRequestSerializer:pi,wrapResponseSerializer:pi,wrapErrorSerializer:pi,req:an,res:an,err:$d};function Nd(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function xt(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||Sr;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=Nd(t.browser.serialize,n);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const c=t.level||"info",f=Object.create(r);f.log||(f.log=xr),Object.defineProperty(f,"levelVal",{get:l}),Object.defineProperty(f,"level",{get:D,set:w});const h={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:Md(t)};f.levels=xt.levels,f.level=c,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=xr,f.serializers=n,f._serialize=i,f._stdErrSerialize=s,f.child=m,e&&(f._logEvent=di());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function w(E){if(E!=="silent"&&!this.levels.values[E])throw Error("unknown level "+E);this._level=E,ar(h,f,"error","log"),ar(h,f,"fatal","error"),ar(h,f,"warn","error"),ar(h,f,"info","log"),ar(h,f,"debug","log"),ar(h,f,"trace","log")}function m(E,F){if(!E)throw new Error("missing bindings for child Pino");F=F||{},i&&E.serializers&&(F.serializers=E.serializers);const N=F.serializers;if(i&&N){var B=Object.assign({},n,N),x=t.browser.serialize===!0?Object.keys(B):i;delete E.serializers,on([E],x,B,this._stdErrSerialize)}function A(y){this._childLevel=(y._childLevel|0)+1,this.error=cr(y,E,"error"),this.fatal=cr(y,E,"fatal"),this.warn=cr(y,E,"warn"),this.info=cr(y,E,"info"),this.debug=cr(y,E,"debug"),this.trace=cr(y,E,"trace"),B&&(this.serializers=B,this._serialize=x),e&&(this._logEvent=di([].concat(y._logEvent.bindings,E)))}return A.prototype=this,new A(this)}return f}xt.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},xt.stdSerializers=Cd,xt.stdTimeFunctions=Object.assign({},{nullTime:Mo,epochTime:jo,unixTime:jd,isoTime:Bd});function ar(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?xr:i[r]?i[r]:Sr[r]||Sr[n]||xr,Fd(t,e,r)}function Fd(t,e,r){!t.transmit&&e[r]===xr||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Sr?Sr:this;for(var f=0;f<o.length;f++)o[f]=arguments[f];if(t.serialize&&!t.asObject&&on(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(c,Ld(this,r,o,s)):n.apply(c,o),t.transmit){const h=t.transmit.level||e.level,l=xt.levels.values[h],D=xt.levels.values[r];if(D<l)return;Ud(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:h,transmitValue:xt.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function Ld(t,e,r,n){t._serialize&&on(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const o={};n&&(o.time=n),o.level=xt.levels.values[e];let c=(t._childLevel|0)+1;if(c<1&&(c=1),s!==null&&typeof s=="object"){for(;c--&&typeof i[0]=="object";)Object.assign(o,i.shift());s=i.length?$o(i.shift(),i):void 0}else typeof s=="string"&&(s=$o(i.shift(),i));return s!==void 0&&(o.msg=s),o}function on(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=xt.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(const s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function cr(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function Ud(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,o=e.methodValue,c=e.val,f=t._logEvent.bindings;on(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(h){return f.indexOf(h)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,n(s,t._logEvent,c),t._logEvent=di(f)}function di(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function $d(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function Md(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Mo:jo}function an(){return{}}function pi(t){return t}function xr(){}function Mo(){return!1}function jo(){return Date.now()}function jd(){return Math.round(Date.now()/1e3)}function Bd(){return new Date(Date.now()).toISOString()}function zd(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}var cn={};/*! *****************************************************************************
28
28
  Copyright (c) Microsoft Corporation.
29
29
 
30
30
  Permission to use, copy, modify, and/or distribute this software for any
@@ -37,7 +37,7 @@
37
37
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38
38
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39
39
  PERFORMANCE OF THIS SOFTWARE.
40
- ***************************************************************************** */var Ki=function(t,e){return Ki=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])},Ki(t,e)};function Eg(t,e){Ki(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var qi=function(){return qi=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},qi.apply(this,arguments)};function Dg(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 xg(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 Sg(t,e){return function(r,n){e(r,n,t)}}function Og(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Lg(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(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(a,f)}h((n=n.apply(t,e||[])).next())})}function Ig(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(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Ag(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Tg(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Hi(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 Aa(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 Cg(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Aa(arguments[e]));return t}function Rg(){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 Br(t){return this instanceof Br?(this.v=t,this):new Br(t)}function Ng(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(v){n[v]&&(i[v]=function(m){return new Promise(function(w,P){s.push([v,m,w,P])>1||a(v,m)})})}function a(v,m){try{f(n[v](m))}catch(w){D(s[0][3],w)}}function f(v){v.value instanceof Br?Promise.resolve(v.value.v).then(h,l):D(s[0][2],v)}function h(v){a("next",v)}function l(v){a("throw",v)}function D(v,m){v(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Pg(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:Br(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function $g(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 Hi=="function"?Hi(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,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(h){s({value:h,done:a})},o)}}function Fg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Mg(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 Ug(t){return t&&t.__esModule?t:{default:t}}function jg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Bg(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var zg=Object.freeze({__proto__:null,__extends:Eg,get __assign(){return qi},__rest:Dg,__decorate:xg,__param:Sg,__metadata:Og,__awaiter:Lg,__generator:Ig,__createBinding:Ag,__exportStar:Tg,__values:Hi,__read:Aa,__spread:Cg,__spreadArrays:Rg,__await:Br,__asyncGenerator:Ng,__asyncDelegator:Pg,__asyncValues:$g,__makeTemplateObject:Fg,__importStar:Mg,__importDefault:Ug,__classPrivateFieldGet:jg,__classPrivateFieldSet:Bg}),Ta=Zt(zg),zr={};Object.defineProperty(zr,"__esModule",{value:!0});function Kg(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}zr.safeJsonParse=Kg;function qg(t){return typeof t=="string"?t:JSON.stringify(t,(e,r)=>typeof r>"u"?null:r)}zr.safeJsonStringify=qg;var Kr={exports:{}},Ca;function Hg(){return Ca||(Ca=1,function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof ke<"u"&&ke.localStorage?Kr.exports=ke.localStorage:typeof window<"u"&&window.localStorage?Kr.exports=window.localStorage:Kr.exports=new e}()),Kr.exports}var Vi={},qr={},Ra;function Vg(){if(Ra)return qr;Ra=1,Object.defineProperty(qr,"__esModule",{value:!0}),qr.IKeyValueStorage=void 0;class t{}return qr.IKeyValueStorage=t,qr}var Hr={},Na;function Gg(){if(Na)return Hr;Na=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.parseEntry=void 0;const t=zr;function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Hr.parseEntry=e,Hr}var Pa;function Wg(){return Pa||(Pa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Ta;e.__exportStar(Vg(),t),e.__exportStar(Gg(),t)}(Vi)),Vi}Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.KeyValueStorage=void 0;const _r=Ta,$a=zr,kg=_r.__importDefault(Hg()),Yg=Wg();class Fa{constructor(){this.localStorage=kg.default}getKeys(){return _r.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return _r.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Yg.parseEntry)})}getItem(e){return _r.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return $a.safeJsonParse(r)})}setItem(e,r){return _r.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,$a.safeJsonStringify(r))})}removeItem(e){return _r.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}Dn.KeyValueStorage=Fa;var Jg=Dn.default=Fa,Vr={};/*! *****************************************************************************
40
+ ***************************************************************************** */var gi=function(t,e){return gi=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])},gi(t,e)};function qd(t,e){gi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var yi=function(){return yi=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},yi.apply(this,arguments)};function Hd(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 Kd(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 Vd(t,e){return function(r,n){e(r,n,t)}}function Gd(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Wd(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 c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function kd(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Yd(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Jd(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function _i(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 Bo(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(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Xd(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Bo(arguments[e]));return t}function Zd(){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,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Or(t){return this instanceof Or?(this.v=t,this):new Or(t)}function Qd(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(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Or?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function ep(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:Or(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function tp(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 _i=="function"?_i(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(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function rp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function np(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 ip(t){return t&&t.__esModule?t:{default:t}}function sp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function op(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var ap=Object.freeze({__proto__:null,__extends:qd,get __assign(){return yi},__rest:Hd,__decorate:Kd,__param:Vd,__metadata:Gd,__awaiter:Wd,__generator:kd,__createBinding:Yd,__exportStar:Jd,__values:_i,__read:Bo,__spread:Xd,__spreadArrays:Zd,__await:Or,__asyncGenerator:Qd,__asyncDelegator:ep,__asyncValues:tp,__makeTemplateObject:rp,__importStar:np,__importDefault:ip,__classPrivateFieldGet:sp,__classPrivateFieldSet:op}),zo=Kt(ap),Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});function cp(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}Ir.safeJsonParse=cp;function up(t){return typeof t=="string"?t:JSON.stringify(t,(e,r)=>typeof r>"u"?null:r)}Ir.safeJsonStringify=up;var Ar={exports:{}},qo;function hp(){return qo||(qo=1,function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof He<"u"&&He.localStorage?Ar.exports=He.localStorage:typeof window<"u"&&window.localStorage?Ar.exports=window.localStorage:Ar.exports=new e}()),Ar.exports}var bi={},Tr={},Ho;function fp(){if(Ho)return Tr;Ho=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.IKeyValueStorage=void 0;class t{}return Tr.IKeyValueStorage=t,Tr}var Pr={},Ko;function lp(){if(Ko)return Pr;Ko=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.parseEntry=void 0;const t=Ir;function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Pr.parseEntry=e,Pr}var Vo;function dp(){return Vo||(Vo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=zo;e.__exportStar(fp(),t),e.__exportStar(lp(),t)}(bi)),bi}Object.defineProperty(cn,"__esModule",{value:!0}),cn.KeyValueStorage=void 0;const ur=zo,Go=Ir,pp=ur.__importDefault(hp()),gp=dp();class Wo{constructor(){this.localStorage=pp.default}getKeys(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(gp.parseEntry)})}getItem(e){return ur.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Go.safeJsonParse(r)})}setItem(e,r){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Go.safeJsonStringify(r))})}removeItem(e){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}cn.KeyValueStorage=Wo;var yp=cn.default=Wo,Rr={};/*! *****************************************************************************
41
41
  Copyright (c) Microsoft Corporation.
42
42
 
43
43
  Permission to use, copy, modify, and/or distribute this software for any
@@ -50,7 +50,7 @@
50
50
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
51
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
52
  PERFORMANCE OF THIS SOFTWARE.
53
- ***************************************************************************** */var Gi=function(t,e){return Gi=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])},Gi(t,e)};function Xg(t,e){Gi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Wi=function(){return Wi=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},Wi.apply(this,arguments)};function Zg(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 Qg(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 ey(t,e){return function(r,n){e(r,n,t)}}function ty(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ry(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(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(a,f)}h((n=n.apply(t,e||[])).next())})}function ny(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(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function iy(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function sy(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ki(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 Ma(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 oy(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ma(arguments[e]));return t}function ay(){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 Gr(t){return this instanceof Gr?(this.v=t,this):new Gr(t)}function cy(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(v){n[v]&&(i[v]=function(m){return new Promise(function(w,P){s.push([v,m,w,P])>1||a(v,m)})})}function a(v,m){try{f(n[v](m))}catch(w){D(s[0][3],w)}}function f(v){v.value instanceof Gr?Promise.resolve(v.value.v).then(h,l):D(s[0][2],v)}function h(v){a("next",v)}function l(v){a("throw",v)}function D(v,m){v(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function uy(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:Gr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function fy(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 ki=="function"?ki(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,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(h){s({value:h,done:a})},o)}}function hy(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ly(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 dy(t){return t&&t.__esModule?t:{default:t}}function py(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function gy(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var yy=Object.freeze({__proto__:null,__extends:Xg,get __assign(){return Wi},__rest:Zg,__decorate:Qg,__param:ey,__metadata:ty,__awaiter:ry,__generator:ny,__createBinding:iy,__exportStar:sy,__values:ki,__read:Ma,__spread:oy,__spreadArrays:ay,__await:Gr,__asyncGenerator:cy,__asyncDelegator:uy,__asyncValues:fy,__makeTemplateObject:hy,__importStar:ly,__importDefault:dy,__classPrivateFieldGet:py,__classPrivateFieldSet:gy}),xn=Zt(yy),Wr={},Yi={},kr={};class ir{}var vy=Object.freeze({__proto__:null,IEvents:ir}),_y=Zt(vy),Ua;function by(){if(Ua)return kr;Ua=1,Object.defineProperty(kr,"__esModule",{value:!0}),kr.IHeartBeat=void 0;const t=_y;class e extends t.IEvents{constructor(n){super()}}return kr.IHeartBeat=e,kr}var ja;function Ba(){return ja||(ja=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),xn.__exportStar(by(),t)}(Yi)),Yi}var Ji={},sr={},za;function my(){if(za)return sr;za=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.HEARTBEAT_EVENTS=sr.HEARTBEAT_INTERVAL=void 0;const t=Z;return sr.HEARTBEAT_INTERVAL=t.FIVE_SECONDS,sr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},sr}var Ka;function qa(){return Ka||(Ka=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),xn.__exportStar(my(),t)}(Ji)),Ji}var Ha;function wy(){if(Ha)return Wr;Ha=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.HeartBeat=void 0;const t=xn,e=kn,r=Z,n=Ba(),i=qa();class s extends n.IHeartBeat{constructor(a){super(a),this.events=new e.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=a?.interval||i.HEARTBEAT_INTERVAL}static init(a){return t.__awaiter(this,void 0,void 0,function*(){const f=new s(a);return yield f.init(),f})}init(){return t.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}on(a,f){this.events.on(a,f)}once(a,f){this.events.once(a,f)}off(a,f){this.events.off(a,f)}removeListener(a,f){this.events.removeListener(a,f)}initialize(){return t.__awaiter(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(i.HEARTBEAT_EVENTS.pulse)}}return Wr.HeartBeat=s,Wr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=xn;e.__exportStar(wy(),t),e.__exportStar(Ba(),t),e.__exportStar(qa(),t)})(Vr);var Oe={};/*! *****************************************************************************
53
+ ***************************************************************************** */var vi=function(t,e){return vi=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])},vi(t,e)};function _p(t,e){vi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var wi=function(){return wi=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},wi.apply(this,arguments)};function bp(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 vp(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 wp(t,e){return function(r,n){e(r,n,t)}}function mp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ep(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 c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function Dp(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Sp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function xp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function mi(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 ko(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(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Op(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ko(arguments[e]));return t}function Ip(){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,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Cr(t){return this instanceof Cr?(this.v=t,this):new Cr(t)}function Ap(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(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Cr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Tp(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:Cr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function Pp(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 mi=="function"?mi(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(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function Rp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Cp(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 Np(t){return t&&t.__esModule?t:{default:t}}function Fp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Lp(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var Up=Object.freeze({__proto__:null,__extends:_p,get __assign(){return wi},__rest:bp,__decorate:vp,__param:wp,__metadata:mp,__awaiter:Ep,__generator:Dp,__createBinding:Sp,__exportStar:xp,__values:mi,__read:ko,__spread:Op,__spreadArrays:Ip,__await:Cr,__asyncGenerator:Ap,__asyncDelegator:Tp,__asyncValues:Pp,__makeTemplateObject:Rp,__importStar:Cp,__importDefault:Np,__classPrivateFieldGet:Fp,__classPrivateFieldSet:Lp}),un=Kt(Up),Nr={},Ei={},Fr={};class Jt{}var $p=Object.freeze({__proto__:null,IEvents:Jt}),Mp=Kt($p),Yo;function jp(){if(Yo)return Fr;Yo=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.IHeartBeat=void 0;const t=Mp;class e extends t.IEvents{constructor(n){super()}}return Fr.IHeartBeat=e,Fr}var Jo;function Xo(){return Jo||(Jo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),un.__exportStar(jp(),t)}(Ei)),Ei}var Di={},Xt={},Zo;function Bp(){if(Zo)return Xt;Zo=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.HEARTBEAT_EVENTS=Xt.HEARTBEAT_INTERVAL=void 0;const t=Z;return Xt.HEARTBEAT_INTERVAL=t.FIVE_SECONDS,Xt.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Xt}var Qo;function ea(){return Qo||(Qo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),un.__exportStar(Bp(),t)}(Di)),Di}var ta;function zp(){if(ta)return Nr;ta=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.HeartBeat=void 0;const t=un,e=Ze.exports,r=Z,n=Xo(),i=ea();class s extends n.IHeartBeat{constructor(c){super(c),this.events=new e.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=c?.interval||i.HEARTBEAT_INTERVAL}static init(c){return t.__awaiter(this,void 0,void 0,function*(){const f=new s(c);return yield f.init(),f})}init(){return t.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(c,f){this.events.on(c,f)}once(c,f){this.events.once(c,f)}off(c,f){this.events.off(c,f)}removeListener(c,f){this.events.removeListener(c,f)}initialize(){return t.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(i.HEARTBEAT_EVENTS.pulse)}}return Nr.HeartBeat=s,Nr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=un;e.__exportStar(zp(),t),e.__exportStar(Xo(),t),e.__exportStar(ea(),t)})(Rr);var xe={};/*! *****************************************************************************
54
54
  Copyright (c) Microsoft Corporation.
55
55
 
56
56
  Permission to use, copy, modify, and/or distribute this software for any
@@ -63,5 +63,5 @@
63
63
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
64
64
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65
65
  PERFORMANCE OF THIS SOFTWARE.
66
- ***************************************************************************** */var Xi=function(t,e){return Xi=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])},Xi(t,e)};function Ey(t,e){Xi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Zi=function(){return Zi=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},Zi.apply(this,arguments)};function Dy(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 xy(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 Sy(t,e){return function(r,n){e(r,n,t)}}function Oy(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ly(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(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(a,f)}h((n=n.apply(t,e||[])).next())})}function Iy(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(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Ay(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Ty(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Qi(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 Va(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 Cy(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Va(arguments[e]));return t}function Ry(){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 Yr(t){return this instanceof Yr?(this.v=t,this):new Yr(t)}function Ny(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(v){n[v]&&(i[v]=function(m){return new Promise(function(w,P){s.push([v,m,w,P])>1||a(v,m)})})}function a(v,m){try{f(n[v](m))}catch(w){D(s[0][3],w)}}function f(v){v.value instanceof Yr?Promise.resolve(v.value.v).then(h,l):D(s[0][2],v)}function h(v){a("next",v)}function l(v){a("throw",v)}function D(v,m){v(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Py(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:Yr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function $y(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 Qi=="function"?Qi(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,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(h){s({value:h,done:a})},o)}}function Fy(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function My(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 Uy(t){return t&&t.__esModule?t:{default:t}}function jy(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function By(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var zy=Object.freeze({__proto__:null,__extends:Ey,get __assign(){return Zi},__rest:Dy,__decorate:xy,__param:Sy,__metadata:Oy,__awaiter:Ly,__generator:Iy,__createBinding:Ay,__exportStar:Ty,__values:Qi,__read:Va,__spread:Cy,__spreadArrays:Ry,__await:Yr,__asyncGenerator:Ny,__asyncDelegator:Py,__asyncValues:$y,__makeTemplateObject:Fy,__importStar:My,__importDefault:Uy,__classPrivateFieldGet:jy,__classPrivateFieldSet:By}),Ky=Zt(zy),or={},Ga;function Wa(){return Ga||(Ga=1,Object.defineProperty(or,"__esModule",{value:!0}),or.PINO_CUSTOM_CONTEXT_KEY=or.PINO_LOGGER_DEFAULTS=void 0,or.PINO_LOGGER_DEFAULTS={level:"info"},or.PINO_CUSTOM_CONTEXT_KEY="custom_context"),or}var ft={},ka;function qy(){if(ka)return ft;ka=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.generateChildLogger=ft.formatChildLoggerContext=ft.getLoggerContext=ft.setBrowserLoggerContext=ft.getBrowserLoggerContext=ft.getDefaultLoggerOptions=void 0;const t=Wa();function e(a){return Object.assign(Object.assign({},a),{level:a?.level||t.PINO_LOGGER_DEFAULTS.level})}ft.getDefaultLoggerOptions=e;function r(a,f=t.PINO_CUSTOM_CONTEXT_KEY){return a[f]||""}ft.getBrowserLoggerContext=r;function n(a,f,h=t.PINO_CUSTOM_CONTEXT_KEY){return a[h]=f,a}ft.setBrowserLoggerContext=n;function i(a,f=t.PINO_CUSTOM_CONTEXT_KEY){let h="";return typeof a.bindings>"u"?h=r(a,f):h=a.bindings().context||"",h}ft.getLoggerContext=i;function s(a,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=i(a,h);return l.trim()?`${l}/${f}`:f}ft.formatChildLoggerContext=s;function o(a,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=s(a,f,h),D=a.child({context:l});return n(D,l,h)}return ft.generateChildLogger=o,ft}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const e=Ky,r=e.__importDefault(_n);Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(Wa(),t),e.__exportStar(qy(),t)})(Oe);var Ya={exports:{}},br=typeof Reflect=="object"?Reflect:null,Ja=br&&typeof br.apply=="function"?br.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Sn;br&&typeof br.ownKeys=="function"?Sn=br.ownKeys:Object.getOwnPropertySymbols?Sn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Sn=function(e){return Object.getOwnPropertyNames(e)};function Hy(t){console&&console.warn&&console.warn(t)}var Xa=Number.isNaN||function(e){return e!==e};function Le(){Le.init.call(this)}Ya.exports=Le,Ya.exports.once=ky,Le.EventEmitter=Le,Le.prototype._events=void 0,Le.prototype._eventsCount=0,Le.prototype._maxListeners=void 0;var Za=10;function On(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return Za},set:function(t){if(typeof t!="number"||t<0||Xa(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Za=t}}),Le.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},Le.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Xa(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 Qa(t){return t._maxListeners===void 0?Le.defaultMaxListeners:t._maxListeners}Le.prototype.getMaxListeners=function(){return Qa(this)},Le.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")Ja(f,this,r);else for(var h=f.length,l=ic(f,h),n=0;n<h;++n)Ja(l[n],this,r);return!0};function ec(t,e,r,n){var i,s,o;if(On(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=Qa(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,Hy(a)}return t}Le.prototype.addListener=function(e,r){return ec(this,e,r,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(e,r){return ec(this,e,r,!0)};function Vy(){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 tc(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Vy.bind(n);return i.listener=r,n.wrapFn=i,i}Le.prototype.once=function(e,r){return On(r),this.on(e,tc(this,e,r)),this},Le.prototype.prependOnceListener=function(e,r){return On(r),this.prependListener(e,tc(this,e,r)),this},Le.prototype.removeListener=function(e,r){var n,i,s,o,a;if(On(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():Gy(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Le.prototype.off=Le.prototype.removeListener,Le.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 rc(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?Wy(i):ic(i,i.length)}Le.prototype.listeners=function(e){return rc(this,e,!0)},Le.prototype.rawListeners=function(e){return rc(this,e,!1)},Le.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):nc.call(t,e)},Le.prototype.listenerCount=nc;function nc(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}Le.prototype.eventNames=function(){return this._eventsCount>0?Sn(this._events):[]};function ic(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Gy(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Wy(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ky(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))}sc(t,e,s,{once:!0}),e!=="error"&&Yy(t,i,{once:!0})})}function Yy(t,e,r){typeof t.on=="function"&&sc(t,"error",e,r)}function sc(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)}class Jy extends ir{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Xy extends ir{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class Zy{constructor(e,r){this.logger=e,this.core=r}}class Qy extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class ev extends ir{constructor(e){super()}}class tv{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class rv extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class nv extends ir{constructor(e,r){super(),this.core=e,this.logger=r}}class iv{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class sv{constructor(e){this.client=e}}var es={},oc={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=_t;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function a(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return a.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},a.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},a.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},a.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},a.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,v=h<<3,m=h%128<112?128:256;this._buffer[l]=128;for(var w=l+1;w<m-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(v,this._buffer,m-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,m),this._finished=!0}for(var w=0;w<this.digestLength/8;w++)e.writeUint32BE(this._stateHi[w],f,w*8),e.writeUint32BE(this._stateLo[w],f,w*8+4);return this},a.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},a.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(f){return this._stateHi.set(f.stateHi),this._stateLo.set(f.stateLo),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(f){r.wipe(f.stateHi),r.wipe(f.stateLo),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},a}();t.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(a,f,h,l,D,v,m){for(var w=h[0],P=h[1],R=h[2],B=h[3],S=h[4],I=h[5],y=h[6],x=h[7],E=l[0],c=l[1],d=l[2],U=l[3],K=l[4],G=l[5],J=l[6],X=l[7],g,_,F,M,N,C,j,z;m>=128;){for(var Q=0;Q<16;Q++){var q=8*Q+v;a[Q]=e.readUint32BE(D,q),f[Q]=e.readUint32BE(D,q+4)}for(var Q=0;Q<80;Q++){var ee=w,Y=P,ae=R,T=B,A=S,O=I,u=y,b=x,H=E,W=c,he=d,ve=U,de=K,me=G,Be=J,$e=X;if(g=x,_=X,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=(S>>>14|K<<32-14)^(S>>>18|K<<32-18)^(K>>>41-32|S<<32-(41-32)),_=(K>>>14|S<<32-14)^(K>>>18|S<<32-18)^(S>>>41-32|K<<32-(41-32)),N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,g=S&I^~S&y,_=K&G^~K&J,N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,g=i[Q*2],_=i[Q*2+1],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,g=a[Q%16],_=f[Q%16],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,F=j&65535|z<<16,M=N&65535|C<<16,g=F,_=M,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=(w>>>28|E<<32-28)^(E>>>34-32|w<<32-(34-32))^(E>>>39-32|w<<32-(39-32)),_=(E>>>28|w<<32-28)^(w>>>34-32|E<<32-(34-32))^(w>>>39-32|E<<32-(39-32)),N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,g=w&P^w&R^P&R,_=E&c^E&d^c&d,N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,b=j&65535|z<<16,$e=N&65535|C<<16,g=T,_=ve,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=F,_=M,N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,T=j&65535|z<<16,ve=N&65535|C<<16,P=ee,R=Y,B=ae,S=T,I=A,y=O,x=u,w=b,c=H,d=W,U=he,K=ve,G=de,J=me,X=Be,E=$e,Q%16===15)for(var q=0;q<16;q++)g=a[q],_=f[q],N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=a[(q+9)%16],_=f[(q+9)%16],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,F=a[(q+1)%16],M=f[(q+1)%16],g=(F>>>1|M<<32-1)^(F>>>8|M<<32-8)^F>>>7,_=(M>>>1|F<<32-1)^(M>>>8|F<<32-8)^(M>>>7|F<<32-7),N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,F=a[(q+14)%16],M=f[(q+14)%16],g=(F>>>19|M<<32-19)^(M>>>61-32|F<<32-(61-32))^F>>>6,_=(M>>>19|F<<32-19)^(F>>>61-32|M<<32-(61-32))^(M>>>6|F<<32-6),N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,a[q]=j&65535|z<<16,f[q]=N&65535|C<<16}g=w,_=E,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[0],_=l[0],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[0]=w=j&65535|z<<16,l[0]=E=N&65535|C<<16,g=P,_=c,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[1],_=l[1],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[1]=P=j&65535|z<<16,l[1]=c=N&65535|C<<16,g=R,_=d,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[2],_=l[2],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[2]=R=j&65535|z<<16,l[2]=d=N&65535|C<<16,g=B,_=U,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[3],_=l[3],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[3]=B=j&65535|z<<16,l[3]=U=N&65535|C<<16,g=S,_=K,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[4],_=l[4],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[4]=S=j&65535|z<<16,l[4]=K=N&65535|C<<16,g=I,_=G,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[5],_=l[5],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[5]=I=j&65535|z<<16,l[5]=G=N&65535|C<<16,g=y,_=J,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[6],_=l[6],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[6]=y=j&65535|z<<16,l[6]=J=N&65535|C<<16,g=x,_=X,N=_&65535,C=_>>>16,j=g&65535,z=g>>>16,g=h[7],_=l[7],N+=_&65535,C+=_>>>16,j+=g&65535,z+=g>>>16,C+=N>>>16,j+=C>>>16,z+=j>>>16,h[7]=x=j&65535|z<<16,l[7]=X=N&65535|C<<16,v+=128,m-=128}return v}function o(a){var f=new n;f.update(a);var h=f.digest();return f.clean(),h}t.hash=o})(oc),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=lr,r=oc,n=_t;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(T){const A=new Float64Array(16);if(T)for(let O=0;O<T.length;O++)A[O]=T[O];return A}const s=new Uint8Array(32);s[0]=9;const o=i(),a=i([1]),f=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(T,A){for(let O=0;O<16;O++)T[O]=A[O]|0}function w(T){let A=1;for(let O=0;O<16;O++){let u=T[O]+A+65535;A=Math.floor(u/65536),T[O]=u-A*65536}T[0]+=A-1+37*(A-1)}function P(T,A,O){const u=~(O-1);for(let b=0;b<16;b++){const H=u&(T[b]^A[b]);T[b]^=H,A[b]^=H}}function R(T,A){const O=i(),u=i();for(let b=0;b<16;b++)u[b]=A[b];w(u),w(u),w(u);for(let b=0;b<2;b++){O[0]=u[0]-65517;for(let W=1;W<15;W++)O[W]=u[W]-65535-(O[W-1]>>16&1),O[W-1]&=65535;O[15]=u[15]-32767-(O[14]>>16&1);const H=O[15]>>16&1;O[14]&=65535,P(u,O,1-H)}for(let b=0;b<16;b++)T[2*b]=u[b]&255,T[2*b+1]=u[b]>>8}function B(T,A){let O=0;for(let u=0;u<32;u++)O|=T[u]^A[u];return(1&O-1>>>8)-1}function S(T,A){const O=new Uint8Array(32),u=new Uint8Array(32);return R(O,T),R(u,A),B(O,u)}function I(T){const A=new Uint8Array(32);return R(A,T),A[0]&1}function y(T,A){for(let O=0;O<16;O++)T[O]=A[2*O]+(A[2*O+1]<<8);T[15]&=32767}function x(T,A,O){for(let u=0;u<16;u++)T[u]=A[u]+O[u]}function E(T,A,O){for(let u=0;u<16;u++)T[u]=A[u]-O[u]}function c(T,A,O){let u,b,H=0,W=0,he=0,ve=0,de=0,me=0,Be=0,$e=0,ye=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,fe=0,ge=0,ne=0,_e=0,be=0,Ee=0,De=0,we=0,Lt=0,Ft=0,kt=0,mt=0,ar=0,Qr=0,Bn=0,ze=O[0],Fe=O[1],Ke=O[2],qe=O[3],He=O[4],Me=O[5],Je=O[6],Xe=O[7],Ze=O[8],Qe=O[9],et=O[10],We=O[11],Ve=O[12],Ne=O[13],tt=O[14],rt=O[15];u=A[0],H+=u*ze,W+=u*Fe,he+=u*Ke,ve+=u*qe,de+=u*He,me+=u*Me,Be+=u*Je,$e+=u*Xe,ye+=u*Ze,pe+=u*Qe,le+=u*et,ue+=u*We,ce+=u*Ve,oe+=u*Ne,se+=u*tt,te+=u*rt,u=A[1],W+=u*ze,he+=u*Fe,ve+=u*Ke,de+=u*qe,me+=u*He,Be+=u*Me,$e+=u*Je,ye+=u*Xe,pe+=u*Ze,le+=u*Qe,ue+=u*et,ce+=u*We,oe+=u*Ve,se+=u*Ne,te+=u*tt,fe+=u*rt,u=A[2],he+=u*ze,ve+=u*Fe,de+=u*Ke,me+=u*qe,Be+=u*He,$e+=u*Me,ye+=u*Je,pe+=u*Xe,le+=u*Ze,ue+=u*Qe,ce+=u*et,oe+=u*We,se+=u*Ve,te+=u*Ne,fe+=u*tt,ge+=u*rt,u=A[3],ve+=u*ze,de+=u*Fe,me+=u*Ke,Be+=u*qe,$e+=u*He,ye+=u*Me,pe+=u*Je,le+=u*Xe,ue+=u*Ze,ce+=u*Qe,oe+=u*et,se+=u*We,te+=u*Ve,fe+=u*Ne,ge+=u*tt,ne+=u*rt,u=A[4],de+=u*ze,me+=u*Fe,Be+=u*Ke,$e+=u*qe,ye+=u*He,pe+=u*Me,le+=u*Je,ue+=u*Xe,ce+=u*Ze,oe+=u*Qe,se+=u*et,te+=u*We,fe+=u*Ve,ge+=u*Ne,ne+=u*tt,_e+=u*rt,u=A[5],me+=u*ze,Be+=u*Fe,$e+=u*Ke,ye+=u*qe,pe+=u*He,le+=u*Me,ue+=u*Je,ce+=u*Xe,oe+=u*Ze,se+=u*Qe,te+=u*et,fe+=u*We,ge+=u*Ve,ne+=u*Ne,_e+=u*tt,be+=u*rt,u=A[6],Be+=u*ze,$e+=u*Fe,ye+=u*Ke,pe+=u*qe,le+=u*He,ue+=u*Me,ce+=u*Je,oe+=u*Xe,se+=u*Ze,te+=u*Qe,fe+=u*et,ge+=u*We,ne+=u*Ve,_e+=u*Ne,be+=u*tt,Ee+=u*rt,u=A[7],$e+=u*ze,ye+=u*Fe,pe+=u*Ke,le+=u*qe,ue+=u*He,ce+=u*Me,oe+=u*Je,se+=u*Xe,te+=u*Ze,fe+=u*Qe,ge+=u*et,ne+=u*We,_e+=u*Ve,be+=u*Ne,Ee+=u*tt,De+=u*rt,u=A[8],ye+=u*ze,pe+=u*Fe,le+=u*Ke,ue+=u*qe,ce+=u*He,oe+=u*Me,se+=u*Je,te+=u*Xe,fe+=u*Ze,ge+=u*Qe,ne+=u*et,_e+=u*We,be+=u*Ve,Ee+=u*Ne,De+=u*tt,we+=u*rt,u=A[9],pe+=u*ze,le+=u*Fe,ue+=u*Ke,ce+=u*qe,oe+=u*He,se+=u*Me,te+=u*Je,fe+=u*Xe,ge+=u*Ze,ne+=u*Qe,_e+=u*et,be+=u*We,Ee+=u*Ve,De+=u*Ne,we+=u*tt,Lt+=u*rt,u=A[10],le+=u*ze,ue+=u*Fe,ce+=u*Ke,oe+=u*qe,se+=u*He,te+=u*Me,fe+=u*Je,ge+=u*Xe,ne+=u*Ze,_e+=u*Qe,be+=u*et,Ee+=u*We,De+=u*Ve,we+=u*Ne,Lt+=u*tt,Ft+=u*rt,u=A[11],ue+=u*ze,ce+=u*Fe,oe+=u*Ke,se+=u*qe,te+=u*He,fe+=u*Me,ge+=u*Je,ne+=u*Xe,_e+=u*Ze,be+=u*Qe,Ee+=u*et,De+=u*We,we+=u*Ve,Lt+=u*Ne,Ft+=u*tt,kt+=u*rt,u=A[12],ce+=u*ze,oe+=u*Fe,se+=u*Ke,te+=u*qe,fe+=u*He,ge+=u*Me,ne+=u*Je,_e+=u*Xe,be+=u*Ze,Ee+=u*Qe,De+=u*et,we+=u*We,Lt+=u*Ve,Ft+=u*Ne,kt+=u*tt,mt+=u*rt,u=A[13],oe+=u*ze,se+=u*Fe,te+=u*Ke,fe+=u*qe,ge+=u*He,ne+=u*Me,_e+=u*Je,be+=u*Xe,Ee+=u*Ze,De+=u*Qe,we+=u*et,Lt+=u*We,Ft+=u*Ve,kt+=u*Ne,mt+=u*tt,ar+=u*rt,u=A[14],se+=u*ze,te+=u*Fe,fe+=u*Ke,ge+=u*qe,ne+=u*He,_e+=u*Me,be+=u*Je,Ee+=u*Xe,De+=u*Ze,we+=u*Qe,Lt+=u*et,Ft+=u*We,kt+=u*Ve,mt+=u*Ne,ar+=u*tt,Qr+=u*rt,u=A[15],te+=u*ze,fe+=u*Fe,ge+=u*Ke,ne+=u*qe,_e+=u*He,be+=u*Me,Ee+=u*Je,De+=u*Xe,we+=u*Ze,Lt+=u*Qe,Ft+=u*et,kt+=u*We,mt+=u*Ve,ar+=u*Ne,Qr+=u*tt,Bn+=u*rt,H+=38*fe,W+=38*ge,he+=38*ne,ve+=38*_e,de+=38*be,me+=38*Ee,Be+=38*De,$e+=38*we,ye+=38*Lt,pe+=38*Ft,le+=38*kt,ue+=38*mt,ce+=38*ar,oe+=38*Qr,se+=38*Bn,b=1,u=H+b+65535,b=Math.floor(u/65536),H=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=he+b+65535,b=Math.floor(u/65536),he=u-b*65536,u=ve+b+65535,b=Math.floor(u/65536),ve=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=me+b+65535,b=Math.floor(u/65536),me=u-b*65536,u=Be+b+65535,b=Math.floor(u/65536),Be=u-b*65536,u=$e+b+65535,b=Math.floor(u/65536),$e=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,H+=b-1+37*(b-1),b=1,u=H+b+65535,b=Math.floor(u/65536),H=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=he+b+65535,b=Math.floor(u/65536),he=u-b*65536,u=ve+b+65535,b=Math.floor(u/65536),ve=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=me+b+65535,b=Math.floor(u/65536),me=u-b*65536,u=Be+b+65535,b=Math.floor(u/65536),Be=u-b*65536,u=$e+b+65535,b=Math.floor(u/65536),$e=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,H+=b-1+37*(b-1),T[0]=H,T[1]=W,T[2]=he,T[3]=ve,T[4]=de,T[5]=me,T[6]=Be,T[7]=$e,T[8]=ye,T[9]=pe,T[10]=le,T[11]=ue,T[12]=ce,T[13]=oe,T[14]=se,T[15]=te}function d(T,A){c(T,A,A)}function U(T,A){const O=i();let u;for(u=0;u<16;u++)O[u]=A[u];for(u=253;u>=0;u--)d(O,O),u!==2&&u!==4&&c(O,O,A);for(u=0;u<16;u++)T[u]=O[u]}function K(T,A){const O=i();let u;for(u=0;u<16;u++)O[u]=A[u];for(u=250;u>=0;u--)d(O,O),u!==1&&c(O,O,A);for(u=0;u<16;u++)T[u]=O[u]}function G(T,A){const O=i(),u=i(),b=i(),H=i(),W=i(),he=i(),ve=i(),de=i(),me=i();E(O,T[1],T[0]),E(me,A[1],A[0]),c(O,O,me),x(u,T[0],T[1]),x(me,A[0],A[1]),c(u,u,me),c(b,T[3],A[3]),c(b,b,h),c(H,T[2],A[2]),x(H,H,H),E(W,u,O),E(he,H,b),x(ve,H,b),x(de,u,O),c(T[0],W,he),c(T[1],de,ve),c(T[2],ve,he),c(T[3],W,de)}function J(T,A,O){for(let u=0;u<4;u++)P(T[u],A[u],O)}function X(T,A){const O=i(),u=i(),b=i();U(b,A[2]),c(O,A[0],b),c(u,A[1],b),R(T,u),T[31]^=I(O)<<7}function g(T,A,O){m(T[0],o),m(T[1],a),m(T[2],a),m(T[3],o);for(let u=255;u>=0;--u){const b=O[u/8|0]>>(u&7)&1;J(T,A,b),G(A,T),G(T,T),J(T,A,b)}}function _(T,A){const O=[i(),i(),i(),i()];m(O[0],l),m(O[1],D),m(O[2],a),c(O[3],l,D),g(T,O,A)}function F(T){if(T.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const A=(0,r.hash)(T);A[0]&=248,A[31]&=127,A[31]|=64;const O=new Uint8Array(32),u=[i(),i(),i(),i()];_(u,A),X(O,u);const b=new Uint8Array(64);return b.set(T),b.set(O,32),{publicKey:O,secretKey:b}}t.generateKeyPairFromSeed=F;function M(T){const A=(0,e.randomBytes)(32,T),O=F(A);return(0,n.wipe)(A),O}t.generateKeyPair=M;function N(T){if(T.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(T.subarray(32))}t.extractPublicKeyFromSecretKey=N;const C=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(T,A){let O,u,b,H;for(u=63;u>=32;--u){for(O=0,b=u-32,H=u-12;b<H;++b)A[b]+=O-16*A[u]*C[b-(u-32)],O=Math.floor((A[b]+128)/256),A[b]-=O*256;A[b]+=O,A[u]=0}for(O=0,b=0;b<32;b++)A[b]+=O-(A[31]>>4)*C[b],O=A[b]>>8,A[b]&=255;for(b=0;b<32;b++)A[b]-=O*C[b];for(u=0;u<32;u++)A[u+1]+=A[u]>>8,T[u]=A[u]&255}function z(T){const A=new Float64Array(64);for(let O=0;O<64;O++)A[O]=T[O];for(let O=0;O<64;O++)T[O]=0;j(T,A)}function Q(T,A){const O=new Float64Array(64),u=[i(),i(),i(),i()],b=(0,r.hash)(T.subarray(0,32));b[0]&=248,b[31]&=127,b[31]|=64;const H=new Uint8Array(64);H.set(b.subarray(32),32);const W=new r.SHA512;W.update(H.subarray(32)),W.update(A);const he=W.digest();W.clean(),z(he),_(u,he),X(H,u),W.reset(),W.update(H.subarray(0,32)),W.update(T.subarray(32)),W.update(A);const ve=W.digest();z(ve);for(let de=0;de<32;de++)O[de]=he[de];for(let de=0;de<32;de++)for(let me=0;me<32;me++)O[de+me]+=ve[de]*b[me];return j(H.subarray(32),O),H}t.sign=Q;function q(T,A){const O=i(),u=i(),b=i(),H=i(),W=i(),he=i(),ve=i();return m(T[2],a),y(T[1],A),d(b,T[1]),c(H,b,f),E(b,b,T[2]),x(H,T[2],H),d(W,H),d(he,W),c(ve,he,W),c(O,ve,b),c(O,O,H),K(O,O),c(O,O,b),c(O,O,H),c(O,O,H),c(T[0],O,H),d(u,T[0]),c(u,u,H),S(u,b)&&c(T[0],T[0],v),d(u,T[0]),c(u,u,H),S(u,b)?-1:(I(T[0])===A[31]>>7&&E(T[0],o,T[0]),c(T[3],T[0],T[1]),0)}function ee(T,A,O){const u=new Uint8Array(32),b=[i(),i(),i(),i()],H=[i(),i(),i(),i()];if(O.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(q(H,T))return!1;const W=new r.SHA512;W.update(O.subarray(0,32)),W.update(T),W.update(A);const he=W.digest();return z(he),g(b,H,he),_(H,O.subarray(32)),G(b,H),X(u,b),!B(O,u)}t.verify=ee;function Y(T){let A=[i(),i(),i(),i()];if(q(A,T))throw new Error("Ed25519: invalid public key");let O=i(),u=i(),b=A[1];x(O,a,b),E(u,a,b),U(u,u),c(O,O,u);let H=new Uint8Array(32);return R(H,O),H}t.convertPublicKeyToX25519=Y;function ae(T){const A=(0,r.hash)(T.subarray(0,32));A[0]&=248,A[31]&=127,A[31]|=64;const O=new Uint8Array(A.subarray(0,32));return(0,n.wipe)(A),O}t.convertSecretKeyToX25519=ae}(es);const ov="EdDSA",av="JWT",ac=".",cc="base64url",cv="utf8",uv="utf8",fv=":",hv="did",lv="key",uc="base58btc",dv="z",pv="K36",gv=32;function Ln(t){return pt(dt(Ir(t),cv),cc)}function fc(t){const e=dt(pv,uc),r=dv+pt(li([e,t]),uc);return[hv,lv,r].join(fv)}function yv(t){return pt(t,cc)}function vv(t){return dt([Ln(t.header),Ln(t.payload)].join(ac),uv)}function _v(t){return[Ln(t.header),Ln(t.payload),yv(t.signature)].join(ac)}function hc(t=lr.randomBytes(gv)){return es.generateKeyPairFromSeed(t)}async function bv(t,e,r,n,i=Z.fromMiliseconds(Date.now())){const s={alg:ov,typ:av},o=fc(n.publicKey),a=i+r,f={iss:o,sub:t,aud:e,iat:i,exp:a},h=vv({header:s,payload:f}),l=es.sign(n.secretKey,h);return _v({header:s,payload:f,signature:l})}var ts={exports:{}},mr=typeof Reflect=="object"?Reflect:null,lc=mr&&typeof mr.apply=="function"?mr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},In;mr&&typeof mr.ownKeys=="function"?In=mr.ownKeys:Object.getOwnPropertySymbols?In=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:In=function(e){return Object.getOwnPropertyNames(e)};function mv(t){console&&console.warn&&console.warn(t)}var dc=Number.isNaN||function(e){return e!==e};function Ie(){Ie.init.call(this)}ts.exports=Ie,ts.exports.once=xv,Ie.EventEmitter=Ie,Ie.prototype._events=void 0,Ie.prototype._eventsCount=0,Ie.prototype._maxListeners=void 0;var pc=10;function An(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ie,"defaultMaxListeners",{enumerable:!0,get:function(){return pc},set:function(t){if(typeof t!="number"||t<0||dc(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");pc=t}}),Ie.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},Ie.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||dc(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 gc(t){return t._maxListeners===void 0?Ie.defaultMaxListeners:t._maxListeners}Ie.prototype.getMaxListeners=function(){return gc(this)},Ie.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")lc(f,this,r);else for(var h=f.length,l=mc(f,h),n=0;n<h;++n)lc(l[n],this,r);return!0};function yc(t,e,r,n){var i,s,o;if(An(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=gc(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,mv(a)}return t}Ie.prototype.addListener=function(e,r){return yc(this,e,r,!1)},Ie.prototype.on=Ie.prototype.addListener,Ie.prototype.prependListener=function(e,r){return yc(this,e,r,!0)};function wv(){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 vc(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=wv.bind(n);return i.listener=r,n.wrapFn=i,i}Ie.prototype.once=function(e,r){return An(r),this.on(e,vc(this,e,r)),this},Ie.prototype.prependOnceListener=function(e,r){return An(r),this.prependListener(e,vc(this,e,r)),this},Ie.prototype.removeListener=function(e,r){var n,i,s,o,a;if(An(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():Ev(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Ie.prototype.off=Ie.prototype.removeListener,Ie.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 _c(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?Dv(i):mc(i,i.length)}Ie.prototype.listeners=function(e){return _c(this,e,!0)},Ie.prototype.rawListeners=function(e){return _c(this,e,!1)},Ie.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):bc.call(t,e)},Ie.prototype.listenerCount=bc;function bc(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}Ie.prototype.eventNames=function(){return this._eventsCount>0?In(this._events):[]};function mc(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Ev(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Dv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function xv(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))}wc(t,e,s,{once:!0}),e!=="error"&&Sv(t,i,{once:!0})})}function Sv(t,e,r){typeof t.on=="function"&&wc(t,"error",e,r)}function wc(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)}const Ec=10,Ov=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),Lv=()=>typeof window<"u",Iv=Ov();class Av{constructor(e){if(this.url=e,this.events=new ts.exports.EventEmitter,this.registering=!1,!js(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(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ir(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!js(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=Rs.isReactNative()?void 0:{rejectUnauthorized:!Cf(e)},s=new Iv(e,[],i);Lv()?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=()=>this.onClose(),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?ni(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Lr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return Cs(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ec&&this.events.setMaxListeners(Ec)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for URL: ${this.url}`));return this.events.emit("register_error",r),r}}var rs={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",f="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",D="[object Date]",v="[object Error]",m="[object Function]",w="[object GeneratorFunction]",P="[object Map]",R="[object Number]",B="[object Null]",S="[object Object]",I="[object Promise]",y="[object Proxy]",x="[object RegExp]",E="[object Set]",c="[object String]",d="[object Symbol]",U="[object Undefined]",K="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",g="[object Float64Array]",_="[object Int8Array]",F="[object Int16Array]",M="[object Int32Array]",N="[object Uint8Array]",C="[object Uint8ClampedArray]",j="[object Uint16Array]",z="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,q=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[g]=Y[_]=Y[F]=Y[M]=Y[N]=Y[C]=Y[j]=Y[z]=!0,Y[a]=Y[f]=Y[G]=Y[l]=Y[J]=Y[D]=Y[v]=Y[m]=Y[P]=Y[R]=Y[S]=Y[x]=Y[E]=Y[c]=Y[K]=!1;var ae=typeof ke=="object"&&ke&&ke.Object===Object&&ke,T=typeof self=="object"&&self&&self.Object===Object&&self,A=ae||T||Function("return this")(),O=e&&!e.nodeType&&e,u=O&&!0&&t&&!t.nodeType&&t,b=u&&u.exports===O,H=b&&ae.process,W=function(){try{return H&&H.binding&&H.binding("util")}catch{}}(),he=W&&W.isTypedArray;function ve(p,L){for(var $=-1,k=p==null?0:p.length,Re=0,ie=[];++$<k;){var Ue=p[$];L(Ue,$,p)&&(ie[Re++]=Ue)}return ie}function de(p,L){for(var $=-1,k=L.length,Re=p.length;++$<k;)p[Re+$]=L[$];return p}function me(p,L){for(var $=-1,k=p==null?0:p.length;++$<k;)if(L(p[$],$,p))return!0;return!1}function Be(p,L){for(var $=-1,k=Array(p);++$<p;)k[$]=L($);return k}function $e(p){return function(L){return p(L)}}function ye(p,L){return p.has(L)}function pe(p,L){return p?.[L]}function le(p){var L=-1,$=Array(p.size);return p.forEach(function(k,Re){$[++L]=[Re,k]}),$}function ue(p,L){return function($){return p(L($))}}function ce(p){var L=-1,$=Array(p.size);return p.forEach(function(k){$[++L]=k}),$}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,fe=A["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,_e=function(){var p=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=b?A.Buffer:void 0,we=A.Symbol,Lt=A.Uint8Array,Ft=te.propertyIsEnumerable,kt=oe.splice,mt=we?we.toStringTag:void 0,ar=Object.getOwnPropertySymbols,Qr=De?De.isBuffer:void 0,Bn=ue(Object.keys,Object),ze=Dr(A,"DataView"),Fe=Dr(A,"Map"),Ke=Dr(A,"Promise"),qe=Dr(A,"Set"),He=Dr(A,"WeakMap"),Me=Dr(Object,"create"),Je=ur(ze),Xe=ur(Fe),Ze=ur(Ke),Qe=ur(qe),et=ur(He),We=we?we.prototype:void 0,Ve=We?We.valueOf:void 0;function Ne(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function tt(){this.__data__=Me?Me(null):{},this.size=0}function rt(p){var L=this.has(p)&&delete this.__data__[p];return this.size-=L?1:0,L}function Tb(p){var L=this.__data__;if(Me){var $=L[p];return $===n?void 0:$}return ne.call(L,p)?L[p]:void 0}function Cb(p){var L=this.__data__;return Me?L[p]!==void 0:ne.call(L,p)}function Rb(p,L){var $=this.__data__;return this.size+=this.has(p)?0:1,$[p]=Me&&L===void 0?n:L,this}Ne.prototype.clear=tt,Ne.prototype.delete=rt,Ne.prototype.get=Tb,Ne.prototype.has=Cb,Ne.prototype.set=Rb;function qt(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function Nb(){this.__data__=[],this.size=0}function Pb(p){var L=this.__data__,$=Kn(L,p);if($<0)return!1;var k=L.length-1;return $==k?L.pop():kt.call(L,$,1),--this.size,!0}function $b(p){var L=this.__data__,$=Kn(L,p);return $<0?void 0:L[$][1]}function Fb(p){return Kn(this.__data__,p)>-1}function Mb(p,L){var $=this.__data__,k=Kn($,p);return k<0?(++this.size,$.push([p,L])):$[k][1]=L,this}qt.prototype.clear=Nb,qt.prototype.delete=Pb,qt.prototype.get=$b,qt.prototype.has=Fb,qt.prototype.set=Mb;function cr(p){var L=-1,$=p==null?0:p.length;for(this.clear();++L<$;){var k=p[L];this.set(k[0],k[1])}}function Ub(){this.size=0,this.__data__={hash:new Ne,map:new(Fe||qt),string:new Ne}}function jb(p){var L=qn(this,p).delete(p);return this.size-=L?1:0,L}function Bb(p){return qn(this,p).get(p)}function zb(p){return qn(this,p).has(p)}function Kb(p,L){var $=qn(this,p),k=$.size;return $.set(p,L),this.size+=$.size==k?0:1,this}cr.prototype.clear=Ub,cr.prototype.delete=jb,cr.prototype.get=Bb,cr.prototype.has=zb,cr.prototype.set=Kb;function zn(p){var L=-1,$=p==null?0:p.length;for(this.__data__=new cr;++L<$;)this.add(p[L])}function qb(p){return this.__data__.set(p,n),this}function Hb(p){return this.__data__.has(p)}zn.prototype.add=zn.prototype.push=qb,zn.prototype.has=Hb;function Yt(p){var L=this.__data__=new qt(p);this.size=L.size}function Vb(){this.__data__=new qt,this.size=0}function Gb(p){var L=this.__data__,$=L.delete(p);return this.size=L.size,$}function Wb(p){return this.__data__.get(p)}function kb(p){return this.__data__.has(p)}function Yb(p,L){var $=this.__data__;if($ instanceof qt){var k=$.__data__;if(!Fe||k.length<r-1)return k.push([p,L]),this.size=++$.size,this;$=this.__data__=new cr(k)}return $.set(p,L),this.size=$.size,this}Yt.prototype.clear=Vb,Yt.prototype.delete=Gb,Yt.prototype.get=Wb,Yt.prototype.has=kb,Yt.prototype.set=Yb;function Jb(p,L){var $=Hn(p),k=!$&&h1(p),Re=!$&&!k&&ys(p),ie=!$&&!k&&!Re&&Fu(p),Ue=$||k||Re||ie,nt=Ue?Be(p.length,String):[],at=nt.length;for(var Pe in p)(L||ne.call(p,Pe))&&!(Ue&&(Pe=="length"||Re&&(Pe=="offset"||Pe=="parent")||ie&&(Pe=="buffer"||Pe=="byteLength"||Pe=="byteOffset")||o1(Pe,at)))&&nt.push(Pe);return nt}function Kn(p,L){for(var $=p.length;$--;)if(Ru(p[$][0],L))return $;return-1}function Xb(p,L,$){var k=L(p);return Hn(p)?k:de(k,$(p))}function en(p){return p==null?p===void 0?U:B:mt&&mt in Object(p)?i1(p):f1(p)}function Iu(p){return tn(p)&&en(p)==a}function Au(p,L,$,k,Re){return p===L?!0:p==null||L==null||!tn(p)&&!tn(L)?p!==p&&L!==L:Zb(p,L,$,k,Au,Re)}function Zb(p,L,$,k,Re,ie){var Ue=Hn(p),nt=Hn(L),at=Ue?f:Jt(p),Pe=nt?f:Jt(L);at=at==a?S:at,Pe=Pe==a?S:Pe;var wt=at==S,It=Pe==S,ut=at==Pe;if(ut&&ys(p)){if(!ys(L))return!1;Ue=!0,wt=!1}if(ut&&!wt)return ie||(ie=new Yt),Ue||Fu(p)?Tu(p,L,$,k,Re,ie):r1(p,L,at,$,k,Re,ie);if(!($&i)){var Dt=wt&&ne.call(p,"__wrapped__"),xt=It&&ne.call(L,"__wrapped__");if(Dt||xt){var Xt=Dt?p.value():p,Ht=xt?L.value():L;return ie||(ie=new Yt),Re(Xt,Ht,$,k,ie)}}return ut?(ie||(ie=new Yt),n1(p,L,$,k,Re,ie)):!1}function Qb(p){if(!$u(p)||c1(p))return!1;var L=Nu(p)?Ee:q;return L.test(ur(p))}function e1(p){return tn(p)&&Pu(p.length)&&!!Y[en(p)]}function t1(p){if(!u1(p))return Bn(p);var L=[];for(var $ in Object(p))ne.call(p,$)&&$!="constructor"&&L.push($);return L}function Tu(p,L,$,k,Re,ie){var Ue=$&i,nt=p.length,at=L.length;if(nt!=at&&!(Ue&&at>nt))return!1;var Pe=ie.get(p);if(Pe&&ie.get(L))return Pe==L;var wt=-1,It=!0,ut=$&s?new zn:void 0;for(ie.set(p,L),ie.set(L,p);++wt<nt;){var Dt=p[wt],xt=L[wt];if(k)var Xt=Ue?k(xt,Dt,wt,L,p,ie):k(Dt,xt,wt,p,L,ie);if(Xt!==void 0){if(Xt)continue;It=!1;break}if(ut){if(!me(L,function(Ht,fr){if(!ye(ut,fr)&&(Dt===Ht||Re(Dt,Ht,$,k,ie)))return ut.push(fr)})){It=!1;break}}else if(!(Dt===xt||Re(Dt,xt,$,k,ie))){It=!1;break}}return ie.delete(p),ie.delete(L),It}function r1(p,L,$,k,Re,ie,Ue){switch($){case J:if(p.byteLength!=L.byteLength||p.byteOffset!=L.byteOffset)return!1;p=p.buffer,L=L.buffer;case G:return!(p.byteLength!=L.byteLength||!ie(new Lt(p),new Lt(L)));case l:case D:case R:return Ru(+p,+L);case v:return p.name==L.name&&p.message==L.message;case x:case c:return p==L+"";case P:var nt=le;case E:var at=k&i;if(nt||(nt=ce),p.size!=L.size&&!at)return!1;var Pe=Ue.get(p);if(Pe)return Pe==L;k|=s,Ue.set(p,L);var wt=Tu(nt(p),nt(L),k,Re,ie,Ue);return Ue.delete(p),wt;case d:if(Ve)return Ve.call(p)==Ve.call(L)}return!1}function n1(p,L,$,k,Re,ie){var Ue=$&i,nt=Cu(p),at=nt.length,Pe=Cu(L),wt=Pe.length;if(at!=wt&&!Ue)return!1;for(var It=at;It--;){var ut=nt[It];if(!(Ue?ut in L:ne.call(L,ut)))return!1}var Dt=ie.get(p);if(Dt&&ie.get(L))return Dt==L;var xt=!0;ie.set(p,L),ie.set(L,p);for(var Xt=Ue;++It<at;){ut=nt[It];var Ht=p[ut],fr=L[ut];if(k)var Mu=Ue?k(fr,Ht,ut,L,p,ie):k(Ht,fr,ut,p,L,ie);if(!(Mu===void 0?Ht===fr||Re(Ht,fr,$,k,ie):Mu)){xt=!1;break}Xt||(Xt=ut=="constructor")}if(xt&&!Xt){var Vn=p.constructor,Gn=L.constructor;Vn!=Gn&&"constructor"in p&&"constructor"in L&&!(typeof Vn=="function"&&Vn instanceof Vn&&typeof Gn=="function"&&Gn instanceof Gn)&&(xt=!1)}return ie.delete(p),ie.delete(L),xt}function Cu(p){return Xb(p,p1,s1)}function qn(p,L){var $=p.__data__;return a1(L)?$[typeof L=="string"?"string":"hash"]:$.map}function Dr(p,L){var $=pe(p,L);return Qb($)?$:void 0}function i1(p){var L=ne.call(p,mt),$=p[mt];try{p[mt]=void 0;var k=!0}catch{}var Re=be.call(p);return k&&(L?p[mt]=$:delete p[mt]),Re}var s1=ar?function(p){return p==null?[]:(p=Object(p),ve(ar(p),function(L){return Ft.call(p,L)}))}:g1,Jt=en;(ze&&Jt(new ze(new ArrayBuffer(1)))!=J||Fe&&Jt(new Fe)!=P||Ke&&Jt(Ke.resolve())!=I||qe&&Jt(new qe)!=E||He&&Jt(new He)!=K)&&(Jt=function(p){var L=en(p),$=L==S?p.constructor:void 0,k=$?ur($):"";if(k)switch(k){case Je:return J;case Xe:return P;case Ze:return I;case Qe:return E;case et:return K}return L});function o1(p,L){return L=L??o,!!L&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<L}function a1(p){var L=typeof p;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?p!=="__proto__":p===null}function c1(p){return!!_e&&_e in p}function u1(p){var L=p&&p.constructor,$=typeof L=="function"&&L.prototype||te;return p===$}function f1(p){return be.call(p)}function ur(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function Ru(p,L){return p===L||p!==p&&L!==L}var h1=Iu(function(){return arguments}())?Iu:function(p){return tn(p)&&ne.call(p,"callee")&&!Ft.call(p,"callee")},Hn=Array.isArray;function l1(p){return p!=null&&Pu(p.length)&&!Nu(p)}var ys=Qr||y1;function d1(p,L){return Au(p,L)}function Nu(p){if(!$u(p))return!1;var L=en(p);return L==m||L==w||L==h||L==y}function Pu(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=o}function $u(p){var L=typeof p;return p!=null&&(L=="object"||L=="function")}function tn(p){return p!=null&&typeof p=="object"}var Fu=he?$e(he):e1;function p1(p){return l1(p)?Jb(p):t1(p)}function g1(){return[]}function y1(){return!1}t.exports=d1})(rs,rs.exports);var Tv=rs.exports,Cv=Object.defineProperty,Dc=Object.getOwnPropertySymbols,Rv=Object.prototype.hasOwnProperty,Nv=Object.prototype.propertyIsEnumerable,xc=(t,e,r)=>e in t?Cv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e)=>{for(var r in e||(e={}))Rv.call(e,r)&&xc(t,r,e[r]);if(Dc)for(var r of Dc(e))Nv.call(e,r)&&xc(t,r,e[r]);return t};function Pv(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,f=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var P=0,R=0,B=0,S=w.length;B!==S&&w[B]===0;)B++,P++;for(var I=(S-B)*l+1>>>0,y=new Uint8Array(I);B!==S;){for(var x=w[B],E=0,c=I-1;(x!==0||E<R)&&c!==-1;c--,E++)x+=256*y[c]>>>0,y[c]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");R=E,B++}for(var d=I-R;d!==I&&y[d]===0;)d++;for(var U=f.repeat(P);d<I;++d)U+=t.charAt(y[d]);return U}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var P=0;if(w[P]!==" "){for(var R=0,B=0;w[P]===f;)R++,P++;for(var S=(w.length-P)*h+1>>>0,I=new Uint8Array(S);w[P];){var y=r[w.charCodeAt(P)];if(y===255)return;for(var x=0,E=S-1;(y!==0||x<B)&&E!==-1;E--,x++)y+=a*I[E]>>>0,I[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=x,P++}if(w[P]!==" "){for(var c=S-B;c!==S&&I[c]===0;)c++;for(var d=new Uint8Array(R+(S-c)),U=R;c!==S;)d[U++]=I[c++];return d}}}function m(w){var P=v(w);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:v,decode:m}}var $v=Pv,Fv=$v;const Sc=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")},Mv=t=>new TextEncoder().encode(t),Uv=t=>new TextDecoder().decode(t);class jv{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 Bv{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 Oc(this,e)}}class zv{constructor(e){this.decoders=e}or(e){return Oc(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 Oc=(t,e)=>new zv(ht(ht({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Kv{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new jv(e,r,n),this.decoder=new Bv(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Tn=({name:t,prefix:e,encode:r,decode:n})=>new Kv(t,e,r,n),Jr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Fv(r,e);return Tn({prefix:t,name:e,encode:n,decode:s=>Sc(i(s))})},qv=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,a+=r,a>=8&&(a-=8,o[h++]=255&f>>a)}if(a>=r||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},Hv=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],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},ot=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Tn({prefix:e,name:t,encode(i){return Hv(i,n,r)},decode(i){return qv(i,n,r,t)}}),Vv=Tn({prefix:"\0",name:"identity",encode:t=>Uv(t),decode:t=>Mv(t)});var Gv=Object.freeze({__proto__:null,identity:Vv});const Wv=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kv=Object.freeze({__proto__:null,base2:Wv});const Yv=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Jv=Object.freeze({__proto__:null,base8:Yv});const Xv=Jr({prefix:"9",name:"base10",alphabet:"0123456789"});var Zv=Object.freeze({__proto__:null,base10:Xv});const Qv=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),e_=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var t_=Object.freeze({__proto__:null,base16:Qv,base16upper:e_});const r_=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),n_=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),i_=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),s_=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),o_=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),a_=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),c_=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),u_=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),f_=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var h_=Object.freeze({__proto__:null,base32:r_,base32upper:n_,base32pad:i_,base32padupper:s_,base32hex:o_,base32hexupper:a_,base32hexpad:c_,base32hexpadupper:u_,base32z:f_});const l_=Jr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),d_=Jr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var p_=Object.freeze({__proto__:null,base36:l_,base36upper:d_});const g_=Jr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),y_=Jr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var v_=Object.freeze({__proto__:null,base58btc:g_,base58flickr:y_});const __=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),b_=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),m_=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),w_=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var E_=Object.freeze({__proto__:null,base64:__,base64pad:b_,base64url:m_,base64urlpad:w_});const Lc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),D_=Lc.reduce((t,e,r)=>(t[r]=e,t),[]),x_=Lc.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function S_(t){return t.reduce((e,r)=>(e+=D_[r],e),"")}function O_(t){const e=[];for(const r of t){const n=x_[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const L_=Tn({prefix:"\u{1F680}",name:"base256emoji",encode:S_,decode:O_});var I_=Object.freeze({__proto__:null,base256emoji:L_}),A_=Ac,Ic=128,T_=127,C_=~T_,R_=Math.pow(2,31);function Ac(t,e,r){e=e||[],r=r||0;for(var n=r;t>=R_;)e[r++]=t&255|Ic,t/=128;for(;t&C_;)e[r++]=t&255|Ic,t>>>=7;return e[r]=t|0,Ac.bytes=r-n+1,e}var N_=ns,P_=128,Tc=127;function ns(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw ns.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Tc)<<i:(o&Tc)*Math.pow(2,i),i+=7}while(o>=P_);return ns.bytes=s-n,r}var $_=Math.pow(2,7),F_=Math.pow(2,14),M_=Math.pow(2,21),U_=Math.pow(2,28),j_=Math.pow(2,35),B_=Math.pow(2,42),z_=Math.pow(2,49),K_=Math.pow(2,56),q_=Math.pow(2,63),H_=function(t){return t<$_?1:t<F_?2:t<M_?3:t<U_?4:t<j_?5:t<B_?6:t<z_?7:t<K_?8:t<q_?9:10},V_={encode:A_,decode:N_,encodingLength:H_},Cc=V_;const Rc=(t,e,r=0)=>(Cc.encode(t,e,r),e),Nc=t=>Cc.encodingLength(t),is=(t,e)=>{const r=e.byteLength,n=Nc(t),i=n+Nc(r),s=new Uint8Array(i+r);return Rc(t,s,0),Rc(r,s,n),s.set(e,i),new G_(t,r,e,s)};class G_{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Pc=({name:t,code:e,encode:r})=>new W_(t,e,r);class W_{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?is(this.code,r):r.then(n=>is(this.code,n))}else throw Error("Unknown type, must be binary type")}}const $c=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),k_=Pc({name:"sha2-256",code:18,encode:$c("SHA-256")}),Y_=Pc({name:"sha2-512",code:19,encode:$c("SHA-512")});var J_=Object.freeze({__proto__:null,sha256:k_,sha512:Y_});const Fc=0,X_="identity",Mc=Sc;var Z_=Object.freeze({__proto__:null,identity:{code:Fc,name:X_,encode:Mc,digest:t=>is(Fc,Mc(t))}});new TextEncoder,new TextDecoder;const Uc=ht(ht(ht(ht(ht(ht(ht(ht(ht(ht({},Gv),kv),Jv),Zv),t_),h_),p_),v_),E_),I_);ht(ht({},J_),Z_);function Q_(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function jc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Bc=jc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ss=jc("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=Q_(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),e0=ht({utf8:Bc,"utf-8":Bc,hex:Uc.base16,latin1:ss,ascii:ss,binary:ss},Uc);function t0(t,e="utf8"){const r=e0[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}`)}const zc="wc",r0=2,os="core",Wt=`${zc}@${2}:${os}:`,n0={name:os,logger:"error"},i0={database:":memory:"},s0="crypto",Kc="client_ed25519_seed",o0=Z.ONE_DAY,a0="keychain",c0="0.3",u0="messages",f0="0.3",h0=Z.SIX_HOURS,l0="publisher",qc="irn",d0="error",p0="wss://relay.walletconnect.com",g0="relayer",lt={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},y0="_subscription",Cn={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Hc=Z.ONE_SECOND,v0="2.2.1",_0="0.3",Nt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},b0="subscription",m0="0.3",w0=Z.FIVE_SECONDS*1e3,E0="pairing",D0="0.3",Xr={wc_pairingDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:0},res:{ttl:Z.ONE_DAY,prompt:!1,tag:0}}},Pt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},x0="history",S0="0.3",O0="expirer",Et={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},L0="0.3";class I0{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=a0,this.version=c0,this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ta(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ra(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class A0{constructor(e,r,n){this.core=e,this.logger=r,this.name=s0,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=hc(i);return fc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=ep();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=hc(s),a=Ri();return await bv(a,i,o0,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const a=this.getPrivateKey(i),f=tp(a,s);return this.setSymKey(f,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||rp(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const a=Yo(o),f=Ir(s);if(Jo(a)){const v=a.senderPublicKey,m=a.receiverPublicKey;i=await this.generateSharedKey(v,m)}const h=this.getSymKey(i),{type:l,senderPublicKey:D}=a;return ip({type:l,symKey:h,message:f,senderPublicKey:D})},this.decode=async(i,s,o)=>{this.isInitialized();const a=ap(s,o);if(Jo(a)){const l=a.receiverPublicKey,D=a.senderPublicKey;i=await this.generateSharedKey(l,D)}const f=this.getSymKey(i),h=sp({symKey:f,encoded:s});return ni(h)},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.keychain=n||new I0(this.core,this.logger)}get context(){return Oe.getLoggerContext(this.logger)}getPayloadType(e){const r=Pi(e);return $r(r.type)}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(Kc)}catch{e=Ri(),await this.keychain.set(Kc,e)}return t0(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class T0 extends Zy{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=u0,this.version=f0,this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Ni(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=Ni(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Oe.generateChildLogger(e,this.name),this.core=r}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ta(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ra(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class C0 extends Qy{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new zt.exports.EventEmitter,this.name=l0,this.queue=new Map,this.publishTimeout=1e4,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const o=s?.ttl||h0,a=$i(s),f=s?.prompt||!1,h=s?.tag||0,l={topic:n,message:i,opts:{ttl:o,relay:a,prompt:f,tag:h}},D=Ni(i);this.queue.set(D,l);try{await await na(this.rpcPublish(n,i,o,a,f,h),this.publishTimeout),this.relayer.events.emit(lt.publish,l)}catch{this.logger.debug("Publishing Payload stalled"),this.relayer.events.emit(lt.connection_stalled);return}this.onPublish(D,l),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(o){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(o),o}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Oe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,o){var a,f,h,l;const D={method:Fi(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o}};return bt((a=D.params)==null?void 0:a.prompt)&&((f=D.params)==null||delete f.prompt),bt((h=D.params)==null?void 0:h.tag)&&((l=D.params)==null||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class R0{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),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)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var N0=Object.defineProperty,P0=Object.defineProperties,$0=Object.getOwnPropertyDescriptors,Vc=Object.getOwnPropertySymbols,F0=Object.prototype.hasOwnProperty,M0=Object.prototype.propertyIsEnumerable,Gc=(t,e,r)=>e in t?N0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rn=(t,e)=>{for(var r in e||(e={}))F0.call(e,r)&&Gc(t,r,e[r]);if(Vc)for(var r of Vc(e))M0.call(e,r)&&Gc(t,r,e[r]);return t},as=(t,e)=>P0(t,$0(e));class U0 extends rv{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new R0,this.events=new zt.exports.EventEmitter,this.name=b0,this.version=m0,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Wt,this.subscribeTimeout=1e4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable())},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=$i(i),o={topic:n,relay:s};this.pending.set(n,o);const a=await this.rpcSubscribe(n,s);return 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}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const o=new Z.Watch;o.start(this.pendingSubscriptionWatchLabel);const a=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(a),o.stop(this.pendingSubscriptionWatchLabel),i(!0)),o.elapsed(this.pendingSubscriptionWatchLabel)>=w0&&(clearInterval(a),o.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.restart=async()=>{await this.restore(),await this.reset()},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}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=$i(n);await this.rpcUnsubscribe(e,r,i);const s=Ge("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){const n={method:Fi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await na(this.relayer.provider.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(lt.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:Fi(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.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,as(Rn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,as(Rn({},r),{id:e})),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.subscriptions.has(e)||(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,Rn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Nt.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}=V("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(Nt.deleted,as(Rn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Nt.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(Nt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),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 resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.relayer.transportExplicitlyClosed||this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.on(lt.connect,async()=>{await this.onConnect()}),this.relayer.on(lt.disconnect,()=>{this.onDisconnect()}),this.events.on(Nt.created,async e=>{const r=Nt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Nt.deleted,async e=>{const r=Nt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var j0=Object.defineProperty,Wc=Object.getOwnPropertySymbols,B0=Object.prototype.hasOwnProperty,z0=Object.prototype.propertyIsEnumerable,kc=(t,e,r)=>e in t?j0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K0=(t,e)=>{for(var r in e||(e={}))B0.call(e,r)&&kc(t,r,e[r]);if(Wc)for(var r of Wc(e))z0.call(e,r)&&kc(t,r,e[r]);return t};class q0 extends ev{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new zt.exports.EventEmitter,this.name=g0,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Oe.generateChildLogger(e.logger,this.name):_n(Oe.getDefaultLoggerOptions({level:e.logger||d0})),this.messages=new T0(this.logger,e.core),this.subscriber=new U0(this,this.logger),this.publisher=new C0(this,this.logger),this.relayUrl=e?.relayUrl||p0,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.transportOpen(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Oe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){this.isInitialized();let n="";return await Promise.all([new Promise(i=>{this.subscriber.once(Nt.created,s=>{s.topic===e&&i()})}),new Promise(async i=>{n=await this.subscriber.subscribe(e,r),i()})]),n}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 transportClose(){this.transportExplicitlyClosed=!0,this.connected&&await this.provider.disconnect(),this.events.emit(lt.transport_closed)}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1;try{await Promise.all([new Promise(r=>{this.initialized||r(),this.subscriber.once(Nt.resubscribed,()=>{r()})}),await Promise.race([this.provider.connect(),new Promise((r,n)=>this.once(lt.transport_closed,()=>{n()}))])])}catch(r){const n=r;if(!/socket hang up/i.test(n.message))throw new Error(n.message);this.logger.error(n),this.events.emit(lt.transport_closed)}}async restartTransport(e){await this.transportClose(),await new Promise(r=>setTimeout(r,Hc)),await this.transportOpen(e)}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new ti(new Av(wp({sdkVersion:v0,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Qn(e)){if(!e.method.endsWith(y0))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(K0({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(lt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=on(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(Cn.payload,e=>this.onProviderPayload(e)),this.provider.on(Cn.connect,()=>{this.events.emit(lt.connect)}),this.provider.on(Cn.disconnect,()=>{this.events.emit(lt.disconnect),this.attemptToReconnect()}),this.provider.on(Cn.error,e=>this.events.emit(lt.error,e)),this.events.on(lt.connection_stalled,async()=>{await this.restartTransport()})}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.transportOpen()},Z.toMiliseconds(Hc))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var H0=Object.defineProperty,Yc=Object.getOwnPropertySymbols,V0=Object.prototype.hasOwnProperty,G0=Object.prototype.propertyIsEnumerable,Jc=(t,e,r)=>e in t?H0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xc=(t,e)=>{for(var r in e||(e={}))V0.call(e,r)&&Jc(t,r,e[r]);if(Yc)for(var r of Yc(e))G0.call(e,r)&&Jc(t,r,e[r]);return t};class Nn extends tv{constructor(e,r,n,i=Wt,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=_0,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{Kp(o)?this.map.set(o.id,o):qp(o)?this.map.set(o.topic,o):this.getKey&&o!==null&&!bt(o)&&this.map.set(this.getKey(o),o)}),this.cached=[],this.initialized=!0)},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())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(f=>Tv(a[f],o[f]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const f=Xc(Xc({},this.getData(o)),a);this.map.set(o,f),await this.persist()},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),await this.persist())},this.logger=Oe.generateChildLogger(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(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){const{message:n}=V("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}=V("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}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class W0{constructor(e,r){this.core=e,this.logger=r,this.name=E0,this.version=D0,this.events=new zt.exports,this.initialized=!1,this.storagePrefix=Wt,this.ignoredPayloadTypes=[rr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=Ri(),i=await this.core.crypto.setSymKey(n),s=Tt(Z.FIVE_MINUTES),o={protocol:qc},a={topic:i,expiry:s,relay:o,active:!1},f=Rp({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:o});return await this.pairings.set(i,a),await this.core.relayer.subscribe(i),this.core.expirer.set(i,s),{topic:i,uri:f}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:i,symKey:s,relay:o}=Tp(n.uri),a=Tt(Z.FIVE_MINUTES),f={topic:i,relay:o,expiry:a,active:!1};return await this.pairings.set(i,f),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:o}),this.core.expirer.set(i,a),n.activatePairing&&await this.activate({topic:i}),f},this.activate=async({topic:n})=>{this.isInitialized();const i=Tt(Z.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:i}),this.core.expirer.set(n,i)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=nr();this.events.once(je("pairing_ping",s),({error:h})=>{h?f(h):a()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),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",Ge("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const o=sn(i,s),a=await this.core.crypto.encode(n,o),f=Xr[i].req;return this.core.history.set(n,o),await this.core.relayer.publish(n,a,f),o.id},this.sendResult=async(n,i,s)=>{const o=on(n,s),a=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=Xr[f.request.method].res;await this.core.relayer.publish(i,a,h),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=Lr(n,s),a=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=Xr[f.request.method]?Xr[f.request.method].res:Xr.unregistered_method.res;await this.core.relayer.publish(i,a,h),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Ge("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>Gt(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n,o=s.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit("pairing_ping",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Bt(i)?this.events.emit(je("pairing_ping",s),{}):Ot(i)&&this.events.emit(je("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.sendResult(s,n,!0),await this.deletePairing(n),this.events.emit("pairing_delete",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Ge("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)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Ge("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!vt(n)){const{message:i}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!zp(n.uri)){const{message:i}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!vt(n)){const{message:s}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!vt(n)){const{message:s}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!st(n,!1)){const{message:i}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(Gt(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.pairings=new Nn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Oe.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(lt.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const i=await this.core.crypto.decode(r,n);Qn(i)?(this.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):ei(i)&&(await this.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.core.expirer.on(Et.expired,async e=>{const{topic:r}=sa(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class k0 extends Xy{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new zt.exports.EventEmitter,this.name=x0,this.version=S0,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,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};this.records.set(o.id,o),this.events.emit(Pt.created,o)},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=Ot(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Pt.updated,i))},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)),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(Pt.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:sn(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}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Pt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=V("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(Pt.created,e=>{const r=Pt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Pt.updated,e=>{const r=Pt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Pt.deleted,e=>{const r=Pt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Y0 extends nv{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new zt.exports.EventEmitter,this.name=O0,this.version=L0,this.cached=[],this.initialized=!1,this.storagePrefix=Wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},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(Et.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},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(Et.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Ep(e);if(typeof e=="number")return Dp(e);const{message:r}=V("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(Et.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=V("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}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Z.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Et.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Vr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Et.created,e=>{const r=Et.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Et.expired,e=>{const r=Et.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Et.deleted,e=>{const r=Et.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var J0=Object.defineProperty,Zc=Object.getOwnPropertySymbols,X0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,Qc=(t,e,r)=>e in t?J0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eu=(t,e)=>{for(var r in e||(e={}))X0.call(e,r)&&Qc(t,r,e[r]);if(Zc)for(var r of Zc(e))Z0.call(e,r)&&Qc(t,r,e[r]);return t};class cs extends Jy{constructor(e){super(e),this.protocol=zc,this.version=r0,this.name=os,this.events=new zt.exports.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:_n(Oe.getDefaultLoggerOptions({level:e?.logger||n0.logger}));this.logger=Oe.generateChildLogger(r,this.name),this.heartbeat=new Vr.HeartBeat,this.crypto=new A0(this,this.logger,e?.keychain),this.history=new k0(this,this.logger),this.expirer=new Y0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Jg(eu(eu({},i0),e?.storageOptions)),this.relayer=new q0({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new W0(this,this.logger)}static async init(e){const r=new cs(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Q0=cs;var Pn={exports:{}},wr=typeof Reflect=="object"?Reflect:null,tu=wr&&typeof wr.apply=="function"?wr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},$n;wr&&typeof wr.ownKeys=="function"?$n=wr.ownKeys:Object.getOwnPropertySymbols?$n=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:$n=function(e){return Object.getOwnPropertyNames(e)};function eb(t){console&&console.warn&&console.warn(t)}var ru=Number.isNaN||function(e){return e!==e};function Ae(){Ae.init.call(this)}Pn.exports=Ae,Pn.exports.once=ib,Ae.EventEmitter=Ae,Ae.prototype._events=void 0,Ae.prototype._eventsCount=0,Ae.prototype._maxListeners=void 0;var nu=10;function Fn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ae,"defaultMaxListeners",{enumerable:!0,get:function(){return nu},set:function(t){if(typeof t!="number"||t<0||ru(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");nu=t}}),Ae.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},Ae.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ru(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 iu(t){return t._maxListeners===void 0?Ae.defaultMaxListeners:t._maxListeners}Ae.prototype.getMaxListeners=function(){return iu(this)},Ae.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")tu(f,this,r);else for(var h=f.length,l=uu(f,h),n=0;n<h;++n)tu(l[n],this,r);return!0};function su(t,e,r,n){var i,s,o;if(Fn(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=iu(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,eb(a)}return t}Ae.prototype.addListener=function(e,r){return su(this,e,r,!1)},Ae.prototype.on=Ae.prototype.addListener,Ae.prototype.prependListener=function(e,r){return su(this,e,r,!0)};function tb(){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 ou(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=tb.bind(n);return i.listener=r,n.wrapFn=i,i}Ae.prototype.once=function(e,r){return Fn(r),this.on(e,ou(this,e,r)),this},Ae.prototype.prependOnceListener=function(e,r){return Fn(r),this.prependListener(e,ou(this,e,r)),this},Ae.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Fn(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():rb(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Ae.prototype.off=Ae.prototype.removeListener,Ae.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 au(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?nb(i):uu(i,i.length)}Ae.prototype.listeners=function(e){return au(this,e,!0)},Ae.prototype.rawListeners=function(e){return au(this,e,!1)},Ae.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):cu.call(t,e)},Ae.prototype.listenerCount=cu;function cu(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}Ae.prototype.eventNames=function(){return this._eventsCount>0?$n(this._events):[]};function uu(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function rb(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function nb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ib(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))}fu(t,e,s,{once:!0}),e!=="error"&&sb(t,i,{once:!0})})}function sb(t,e,r){typeof t.on=="function"&&fu(t,"error",e,r)}function fu(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)}const hu="wc",lu=2,du="client",us=`${hu}@${lu}:${du}:`,fs={name:du,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},ob="proposal",ab="session",Mn=Z.SEVEN_DAYS,cb="engine",Zr={wc_sessionPropose:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1115}}},hs={min:Z.FIVE_MINUTES,max:Z.SEVEN_DAYS},ub="request";var fb=Object.defineProperty,hb=Object.defineProperties,lb=Object.getOwnPropertyDescriptors,pu=Object.getOwnPropertySymbols,db=Object.prototype.hasOwnProperty,pb=Object.prototype.propertyIsEnumerable,gu=(t,e,r)=>e in t?fb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e)=>{for(var r in e||(e={}))db.call(e,r)&&gu(t,r,e[r]);if(pu)for(var r of pu(e))pb.call(e,r)&&gu(t,r,e[r]);return t},ls=(t,e)=>hb(t,lb(e));class gb extends sv{constructor(e){super(e),this.name=cb,this.events=new Pn.exports,this.initialized=!1,this.ignoredPayloadTypes=[rr],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Zr)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let o=n,a,f=!1;if(o&&(f=this.client.core.pairing.pairings.get(o).active),!o||!f){const{topic:R,uri:B}=await this.client.core.pairing.create();o=R,a=B}const h=await this.client.core.crypto.generateKeyPair(),l={requiredNamespaces:i,relays:s??[{protocol:qc}],proposer:{publicKey:h,metadata:this.client.metadata}},{reject:D,resolve:v,done:m}=nr();if(this.events.once(je("session_connect"),async({error:R,session:B})=>{if(R)D(R);else if(B){B.self.publicKey=h;const S=ls(Kt({},B),{requiredNamespaces:B.requiredNamespaces});await this.client.session.set(B.topic,S),await this.setExpiry(B.topic,B.expiry),o&&await this.client.core.pairing.updateMetadata({topic:o,metadata:B.peer.metadata}),v(S)}}),!o){const{message:R}=V("NO_MATCHING_KEY",`connect() pairing topic: ${o}`);throw new Error(R)}const w=await this.sendRequest(o,"wc_sessionPropose",l),P=Tt(Z.FIVE_MINUTES);return await this.setProposal(w,Kt({id:w,expiry:P},l)),{uri:a,approval:m}},this.pair=async r=>(this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,o=this.client.proposal.get(n);let{pairingTopic:a,proposer:f,requiredNamespaces:h}=o;yn(h)||(h=Fp(s,"approve()"),this.client.proposal.set(n,ls(Kt({},o),{requiredNamespaces:h})));const l=await this.client.core.crypto.generateKeyPair(),D=f.publicKey,v=await this.client.core.crypto.generateSharedKey(l,D),m={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:Tt(Mn)};await this.client.core.relayer.subscribe(v);const w=await this.sendRequest(v,"wc_sessionSettle",m),{done:P,resolve:R,reject:B}=nr();this.events.once(je("session_approve",w),({error:I})=>{I?B(I):R(this.client.session.get(v))});const S=ls(Kt({},m),{topic:v,acknowledged:!1,self:m.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:l});return await this.client.session.set(v,S),await this.setExpiry(v,Tt(Mn)),a&&await this.client.core.pairing.updateMetadata({topic:a,metadata:S.peer.metadata}),a&&n&&(await this.sendResult(n,a,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,Ge("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a})),{topic:v,acknowledged:P}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,Ge("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:o,resolve:a,reject:f}=nr();return this.events.once(je("session_update",s),({error:h})=>{h?f(h):a()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:o}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:o,reject:a}=nr();return this.events.once(je("session_extend",i),({error:f})=>{f?a(f):o()}),await this.setExpiry(n,Tt(Mn)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s,expiry:o}=r,a=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n},o),{done:f,resolve:h,reject:l}=nr(o);return this.events.once(je("session_request",a),({error:D,result:v})=>{D?l(D):h(v)}),await f()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Bt(i)?await this.sendResult(s,n,i.result):Ot(i)&&await this.sendError(s,n,i.error),this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0})},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:o,reject:a}=nr();this.events.once(je("session_ping",i),({error:f})=>{f?a(f):o()}),await s()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",Ge("USER_DISCONNECTED")),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>jp(n,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.deleteSession=async(r,n)=>{const{self:i}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await Promise.all([this.client.session.delete(r,Ge("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.deleteSymKey(r),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deleteProposal=async(r,n)=>{await Promise.all([this.client.proposal.delete(r,Ge("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)])},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.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.core.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.core.expirer.set(r,n.expiry)},this.setPendingSessionRequest=async r=>{const n=Zr.wc_sessionRequest.req.ttl,{id:i,topic:s,params:o}=r;await this.client.pendingRequest.set(i,{id:i,topic:s,params:o}),n&&this.client.core.expirer.set(i,Tt(n))},this.sendRequest=async(r,n,i,s)=>{const o=sn(n,i),a=await this.client.core.crypto.encode(r,o),f=Zr[n].req;return s&&(f.ttl=s),this.client.core.history.set(r,o),this.client.core.relayer.publish(r,a,f),o.id},this.sendResult=async(r,n,i)=>{const s=on(r,i),o=await this.client.core.crypto.encode(n,s),a=await this.client.core.history.get(n,r),f=Zr[a.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=Lr(r,i),o=await this.client.core.crypto.encode(n,s),a=await this.client.core.history.get(n,r),f=Zr[a.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{Gt(i.expiry)&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Gt(i.expiry)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession(i)),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.core.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);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);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Kt({},n.params));const o=Tt(Z.FIVE_MINUTES),a=Kt({id:s,pairingTopic:r,expiry:o},i);await this.setProposal(s,a),this.client.events.emit("session_proposal",{id:s,params:a})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Bt(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const o=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:o});const a=o.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:a});const f=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const h=await this.client.core.crypto.generateSharedKey(a,f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:h});const l=await this.client.core.relayer.subscribe(h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else Ot(n)&&(await this.client.proposal.delete(i,Ge("USER_DISCONNECTED")),this.events.emit(je("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:f,namespaces:h,requiredNamespaces:l}=n.params,D={topic:r,relay:o,expiry:f,namespaces:h,acknowledged:!0,requiredNamespaces:l,controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(je("session_connect"),{session:D})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Bt(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(je("session_approve",i),{})):Ot(n)&&(await this.client.session.delete(r,Ge("USER_DISCONNECTED")),this.events.emit(je("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Kt({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Bt(n)?this.events.emit(je("session_update",i),{}):Ot(n)&&this.events.emit(je("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Tt(Mn)),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Bt(n)?this.events.emit(je("session_extend",i),{}):Ot(n)&&this.events.emit(je("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;setTimeout(()=>{Bt(n)?this.events.emit(je("session_ping",i),{}):Ot(n)&&this.events.emit(je("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Kt({topic:r},s)),await this.setPendingSessionRequest({id:i,topic:r,params:s}),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Bt(n)?this.events.emit(je("session_request",i),{result:n.result}):Ot(n)&&this.events.emit(je("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Kt({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.isValidConnect=async r=>{if(!vt(r)){const{message:a}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(a)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;if(bt(n)||await this.isValidPairingTopic(n),!bt(i)&&yn(i)===0)return;const o=Wp(i,"connect()");if(o)throw new Error(o.message);if(!kp(s,!0)){const{message:a}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(a)}},this.isValidApprove=async r=>{if(!vt(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const o=this.client.proposal.get(n),a=vn(i,"approve()");if(a)throw new Error(a.message);const f=ga(o.requiredNamespaces,i,"update()");if(f)throw new Error(f.message);if(!st(s,!0)){const{message:h}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}},this.isValidReject=async r=>{if(!vt(r)){const{message:s}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!Jp(i)){const{message:s}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!vt(r)){const{message:h}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!da(n)){const{message:h}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const a=Hp(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const f=vn(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(Gt(o)){const{message:h}=V("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!vt(r)){const{message:f}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(f)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=vn(i,"update()");if(o)throw new Error(o.message);const a=ga(s.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!vt(r)){const{message:i}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!vt(r)){const{message:f}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(f)}const{topic:n,request:i,chainId:s,expiry:o}=r;await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!pa(a,s)){const{message:f}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Xp(i)){const{message:f}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(f)}if(!eg(a,s,i.method)){const{message:f}=V("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(f)}if(o&&!rg(o,hs)){const{message:f}=V("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${hs.min} and ${hs.max}`);throw new Error(f)}},this.isValidRespond=async r=>{if(!vt(r)){const{message:s}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!Zp(i)){const{message:s}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!vt(r)){const{message:i}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!vt(r)){const{message:a}=V("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(!pa(o,s)){const{message:a}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Qp(i)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!tg(o,s,i.name)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!vt(r)){const{message:i}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(lt.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const i=await this.client.core.crypto.decode(r,n);Qn(i)?(this.client.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):ei(i)&&(await this.client.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.core.expirer.on(Et.expired,async e=>{const{topic:r,id:n}=sa(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):n&&await this.deleteProposal(n,!0)})}isValidPairingTopic(e){if(!st(e,!1)){const{message:r}=V("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}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!st(e,!1)){const{message:r}=V("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=V("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(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(st(e,!1)){const{message:r}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Yp(e)){const{message:r}=V("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Gt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class yb extends Nn{constructor(e,r){super(e,r,ob,us),this.core=e,this.logger=r}}class vb extends Nn{constructor(e,r){super(e,r,ab,us),this.core=e,this.logger=r}}class _b extends Nn{constructor(e,r){super(e,r,ub,us),this.core=e,this.logger=r}}class ds extends iv{constructor(e){super(e),this.protocol=hu,this.version=lu,this.name=fs.name,this.events=new Pn.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||fs.name,this.metadata=e?.metadata||vp();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:_n(Oe.getDefaultLoggerOptions({level:e?.logger||fs.logger}));this.core=e?.core||new Q0(e),this.logger=Oe.generateChildLogger(r,this.name),this.session=new vb(this.core,this.logger),this.proposal=new yb(this.core,this.logger),this.pendingRequest=new _b(this.core,this.logger),this.engine=new gb(this)}static async init(e){const r=new ds(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var ps={exports:{}},Er=typeof Reflect=="object"?Reflect:null,yu=Er&&typeof Er.apply=="function"?Er.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Un;Er&&typeof Er.ownKeys=="function"?Un=Er.ownKeys:Object.getOwnPropertySymbols?Un=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Un=function(e){return Object.getOwnPropertyNames(e)};function bb(t){console&&console.warn&&console.warn(t)}var vu=Number.isNaN||function(e){return e!==e};function Te(){Te.init.call(this)}ps.exports=Te,ps.exports.once=Db,Te.EventEmitter=Te,Te.prototype._events=void 0,Te.prototype._eventsCount=0,Te.prototype._maxListeners=void 0;var _u=10;function jn(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Te,"defaultMaxListeners",{enumerable:!0,get:function(){return _u},set:function(t){if(typeof t!="number"||t<0||vu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");_u=t}}),Te.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},Te.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||vu(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 bu(t){return t._maxListeners===void 0?Te.defaultMaxListeners:t._maxListeners}Te.prototype.getMaxListeners=function(){return bu(this)},Te.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 f=s[e];if(f===void 0)return!1;if(typeof f=="function")yu(f,this,r);else for(var h=f.length,l=xu(f,h),n=0;n<h;++n)yu(l[n],this,r);return!0};function mu(t,e,r,n){var i,s,o;if(jn(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=bu(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,bb(a)}return t}Te.prototype.addListener=function(e,r){return mu(this,e,r,!1)},Te.prototype.on=Te.prototype.addListener,Te.prototype.prependListener=function(e,r){return mu(this,e,r,!0)};function mb(){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 wu(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=mb.bind(n);return i.listener=r,n.wrapFn=i,i}Te.prototype.once=function(e,r){return jn(r),this.on(e,wu(this,e,r)),this},Te.prototype.prependOnceListener=function(e,r){return jn(r),this.prependListener(e,wu(this,e,r)),this},Te.prototype.removeListener=function(e,r){var n,i,s,o,a;if(jn(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():wb(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Te.prototype.off=Te.prototype.removeListener,Te.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 Eu(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?Eb(i):xu(i,i.length)}Te.prototype.listeners=function(e){return Eu(this,e,!0)},Te.prototype.rawListeners=function(e){return Eu(this,e,!1)},Te.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Du.call(t,e)},Te.prototype.listenerCount=Du;function Du(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}Te.prototype.eventNames=function(){return this._eventsCount>0?Un(this._events):[]};function xu(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function wb(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Eb(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Db(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))}Su(t,e,s,{once:!0}),e!=="error"&&xb(t,i,{once:!0})})}function xb(t,e,r){typeof t.on=="function"&&Su(t,"error",e,r)}function Su(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)}function Sb(t){return typeof t<"u"&&typeof t.context<"u"}const $t={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class Ob extends Sf{constructor(e){super(),this.events=new ps.exports.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?Li(this.session.namespaces):Zd(this.requiredNamespaces)}get accounts(){return this.session?Oi(this.session.namespaces):[]}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(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit($t.uri,{uri:n}),this.session=await i(),this.events.emit($t.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:Ge("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",on(e.id,n))).catch(n=>this.events.emit("payload",Lr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once($t.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(Sb(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await ds.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit($t.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit($t.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit($t.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit($t.deleted,this.session),this.session=void 0)}))}}const Lb=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],Ib=["chainChanged","accountsChanged"];function Ou(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Lu(t,e){let r;return e.rpcMap&&(r=e.rpcMap[gs([t])]),r}function gs(t){return Number(t[0].split(":")[1])}class Ab{constructor(e){this.events=new Wn.exports.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Ou(e),this.signer=this.setSignerProvider(e?.client),this.chainId=gs(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}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}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on($t.created,e=>{const r=Li(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Oi(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on($t.updated,e=>{const r=Li(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Oi(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on($t.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new Ob({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new ti(r)}setHttpProvider(e){const r=Lu(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new ti(new Rf(r))}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)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}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)}}St.default=Ab,St.getEthereumChainId=gs,St.getRpcConfig=Ou,St.getRpcUrl=Lu,St.signerEvents=Ib,St.signerMethods=Lb,Object.defineProperty(St,"__esModule",{value:!0})});
66
+ ***************************************************************************** */var Si=function(t,e){return Si=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])},Si(t,e)};function qp(t,e){Si(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var xi=function(){return xi=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},xi.apply(this,arguments)};function Hp(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 Kp(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 Vp(t,e){return function(r,n){e(r,n,t)}}function Gp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Wp(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 c(l){try{h(n.next(l))}catch(D){o(D)}}function f(l){try{h(n.throw(l))}catch(D){o(D)}}function h(l){l.done?s(l.value):i(l.value).then(c,f)}h((n=n.apply(t,e||[])).next())})}function kp(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(l){return f([h,l])}}function f(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Yp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Jp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Oi(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 ra(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(c){o={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function Xp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ra(arguments[e]));return t}function Zp(){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,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Lr(t){return this instanceof Lr?(this.v=t,this):new Lr(t)}function Qp(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(w){n[w]&&(i[w]=function(m){return new Promise(function(E,F){s.push([w,m,E,F])>1||c(w,m)})})}function c(w,m){try{f(n[w](m))}catch(E){D(s[0][3],E)}}function f(w){w.value instanceof Lr?Promise.resolve(w.value.v).then(h,l):D(s[0][2],w)}function h(w){c("next",w)}function l(w){c("throw",w)}function D(w,m){w(m),s.shift(),s.length&&c(s[0][0],s[0][1])}}function eg(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:Lr(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function tg(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 Oi=="function"?Oi(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(c,f){o=t[s](o),i(c,f,o.done,o.value)})}}function i(s,o,c,f){Promise.resolve(f).then(function(h){s({value:h,done:c})},o)}}function rg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ng(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 ig(t){return t&&t.__esModule?t:{default:t}}function sg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function og(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var ag=Object.freeze({__proto__:null,__extends:qp,get __assign(){return xi},__rest:Hp,__decorate:Kp,__param:Vp,__metadata:Gp,__awaiter:Wp,__generator:kp,__createBinding:Yp,__exportStar:Jp,__values:Oi,__read:ra,__spread:Xp,__spreadArrays:Zp,__await:Lr,__asyncGenerator:Qp,__asyncDelegator:eg,__asyncValues:tg,__makeTemplateObject:rg,__importStar:ng,__importDefault:ig,__classPrivateFieldGet:sg,__classPrivateFieldSet:og}),cg=Kt(ag),Zt={},na;function ia(){return na||(na=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.PINO_CUSTOM_CONTEXT_KEY=Zt.PINO_LOGGER_DEFAULTS=void 0,Zt.PINO_LOGGER_DEFAULTS={level:"info"},Zt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Zt}var st={},sa;function ug(){if(sa)return st;sa=1,Object.defineProperty(st,"__esModule",{value:!0}),st.generateChildLogger=st.formatChildLoggerContext=st.getLoggerContext=st.setBrowserLoggerContext=st.getBrowserLoggerContext=st.getDefaultLoggerOptions=void 0;const t=ia();function e(c){return Object.assign(Object.assign({},c),{level:c?.level||t.PINO_LOGGER_DEFAULTS.level})}st.getDefaultLoggerOptions=e;function r(c,f=t.PINO_CUSTOM_CONTEXT_KEY){return c[f]||""}st.getBrowserLoggerContext=r;function n(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){return c[h]=f,c}st.setBrowserLoggerContext=n;function i(c,f=t.PINO_CUSTOM_CONTEXT_KEY){let h="";return typeof c.bindings>"u"?h=r(c,f):h=c.bindings().context||"",h}st.getLoggerContext=i;function s(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=i(c,h);return l.trim()?`${l}/${f}`:f}st.formatChildLoggerContext=s;function o(c,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=s(c,f,h),D=c.child({context:l});return n(D,l,h)}return st.generateChildLogger=o,st}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const e=cg,r=e.__importDefault(sn);Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(ia(),t),e.__exportStar(ug(),t)})(xe);class hg extends Jt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class fg extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class lg{constructor(e,r){this.logger=e,this.core=r}}class dg extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pg extends Jt{constructor(e){super()}}class gg{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class yg extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class _g extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}class bg{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class vg{constructor(e){this.client=e}}var Ii={},oa={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=lt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},c.prototype.update=function(f,h){if(h===void 0&&(h=f.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var l=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=f[l++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(l=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,f,l,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=f[l++],h--;return this},c.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,w=h<<3,m=h%128<112?128:256;this._buffer[l]=128;for(var E=l+1;E<m-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(w,this._buffer,m-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,m),this._finished=!0}for(var E=0;E<this.digestLength/8;E++)e.writeUint32BE(this._stateHi[E],f,E*8),e.writeUint32BE(this._stateLo[E],f,E*8+4);return this},c.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(f){return this._stateHi.set(f.stateHi),this._stateLo.set(f.stateLo),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(f){r.wipe(f.stateHi),r.wipe(f.stateLo),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},c}();t.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(c,f,h,l,D,w,m){for(var E=h[0],F=h[1],N=h[2],B=h[3],x=h[4],A=h[5],y=h[6],S=h[7],v=l[0],a=l[1],d=l[2],M=l[3],q=l[4],G=l[5],J=l[6],X=l[7],g,_,U,$,C,R,j,z;m>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+w;c[Q]=e.readUint32BE(D,H),f[Q]=e.readUint32BE(D,H+4)}for(var Q=0;Q<80;Q++){var ee=E,Y=F,ae=N,P=B,T=x,O=A,u=y,b=S,K=v,W=a,fe=d,_e=M,de=q,we=G,Le=J,Pe=X;if(g=S,_=X,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=(x>>>14|q<<32-14)^(x>>>18|q<<32-18)^(q>>>41-32|x<<32-(41-32)),_=(q>>>14|x<<32-14)^(q>>>18|x<<32-18)^(x>>>41-32|q<<32-(41-32)),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=x&A^~x&y,_=q&G^~q&J,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=i[Q*2],_=i[Q*2+1],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=c[Q%16],_=f[Q%16],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,U=j&65535|z<<16,$=C&65535|R<<16,g=U,_=$,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=(E>>>28|v<<32-28)^(v>>>34-32|E<<32-(34-32))^(v>>>39-32|E<<32-(39-32)),_=(v>>>28|E<<32-28)^(E>>>34-32|v<<32-(34-32))^(E>>>39-32|v<<32-(39-32)),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,g=E&F^E&N^F&N,_=v&a^v&d^a&d,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,b=j&65535|z<<16,Pe=C&65535|R<<16,g=P,_=_e,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=U,_=$,C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,P=j&65535|z<<16,_e=C&65535|R<<16,F=ee,N=Y,B=ae,x=P,A=T,y=O,S=u,E=b,a=K,d=W,M=fe,q=_e,G=de,J=we,X=Le,v=Pe,Q%16===15)for(var H=0;H<16;H++)g=c[H],_=f[H],C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=c[(H+9)%16],_=f[(H+9)%16],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,U=c[(H+1)%16],$=f[(H+1)%16],g=(U>>>1|$<<32-1)^(U>>>8|$<<32-8)^U>>>7,_=($>>>1|U<<32-1)^($>>>8|U<<32-8)^($>>>7|U<<32-7),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,U=c[(H+14)%16],$=f[(H+14)%16],g=(U>>>19|$<<32-19)^($>>>61-32|U<<32-(61-32))^U>>>6,_=($>>>19|U<<32-19)^(U>>>61-32|$<<32-(61-32))^($>>>6|U<<32-6),C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,c[H]=j&65535|z<<16,f[H]=C&65535|R<<16}g=E,_=v,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[0],_=l[0],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[0]=E=j&65535|z<<16,l[0]=v=C&65535|R<<16,g=F,_=a,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[1],_=l[1],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[1]=F=j&65535|z<<16,l[1]=a=C&65535|R<<16,g=N,_=d,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[2],_=l[2],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[2]=N=j&65535|z<<16,l[2]=d=C&65535|R<<16,g=B,_=M,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[3],_=l[3],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[3]=B=j&65535|z<<16,l[3]=M=C&65535|R<<16,g=x,_=q,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[4],_=l[4],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[4]=x=j&65535|z<<16,l[4]=q=C&65535|R<<16,g=A,_=G,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[5],_=l[5],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[5]=A=j&65535|z<<16,l[5]=G=C&65535|R<<16,g=y,_=J,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[6],_=l[6],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[6]=y=j&65535|z<<16,l[6]=J=C&65535|R<<16,g=S,_=X,C=_&65535,R=_>>>16,j=g&65535,z=g>>>16,g=h[7],_=l[7],C+=_&65535,R+=_>>>16,j+=g&65535,z+=g>>>16,R+=C>>>16,j+=R>>>16,z+=j>>>16,h[7]=S=j&65535|z<<16,l[7]=X=C&65535|R<<16,w+=128,m-=128}return w}function o(c){var f=new n;f.update(c);var h=f.digest();return f.clean(),h}t.hash=o})(oa),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=ir,r=oa,n=lt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(P){const T=new Float64Array(16);if(P)for(let O=0;O<P.length;O++)T[O]=P[O];return T}const s=new Uint8Array(32);s[0]=9;const o=i(),c=i([1]),f=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),w=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(P,T){for(let O=0;O<16;O++)P[O]=T[O]|0}function E(P){let T=1;for(let O=0;O<16;O++){let u=P[O]+T+65535;T=Math.floor(u/65536),P[O]=u-T*65536}P[0]+=T-1+37*(T-1)}function F(P,T,O){const u=~(O-1);for(let b=0;b<16;b++){const K=u&(P[b]^T[b]);P[b]^=K,T[b]^=K}}function N(P,T){const O=i(),u=i();for(let b=0;b<16;b++)u[b]=T[b];E(u),E(u),E(u);for(let b=0;b<2;b++){O[0]=u[0]-65517;for(let W=1;W<15;W++)O[W]=u[W]-65535-(O[W-1]>>16&1),O[W-1]&=65535;O[15]=u[15]-32767-(O[14]>>16&1);const K=O[15]>>16&1;O[14]&=65535,F(u,O,1-K)}for(let b=0;b<16;b++)P[2*b]=u[b]&255,P[2*b+1]=u[b]>>8}function B(P,T){let O=0;for(let u=0;u<32;u++)O|=P[u]^T[u];return(1&O-1>>>8)-1}function x(P,T){const O=new Uint8Array(32),u=new Uint8Array(32);return N(O,P),N(u,T),B(O,u)}function A(P){const T=new Uint8Array(32);return N(T,P),T[0]&1}function y(P,T){for(let O=0;O<16;O++)P[O]=T[2*O]+(T[2*O+1]<<8);P[15]&=32767}function S(P,T,O){for(let u=0;u<16;u++)P[u]=T[u]+O[u]}function v(P,T,O){for(let u=0;u<16;u++)P[u]=T[u]-O[u]}function a(P,T,O){let u,b,K=0,W=0,fe=0,_e=0,de=0,we=0,Le=0,Pe=0,ye=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,be=0,ve=0,Ee=0,De=0,me=0,mt=0,Tt=0,Bt=0,dt=0,Qt=0,jr=0,yn=0,Ue=O[0],Re=O[1],$e=O[2],Me=O[3],je=O[4],Ce=O[5],Ke=O[6],Ve=O[7],Ge=O[8],We=O[9],ke=O[10],qe=O[11],Be=O[12],Ae=O[13],Ye=O[14],Je=O[15];u=T[0],K+=u*Ue,W+=u*Re,fe+=u*$e,_e+=u*Me,de+=u*je,we+=u*Ce,Le+=u*Ke,Pe+=u*Ve,ye+=u*Ge,pe+=u*We,le+=u*ke,ue+=u*qe,ce+=u*Be,oe+=u*Ae,se+=u*Ye,te+=u*Je,u=T[1],W+=u*Ue,fe+=u*Re,_e+=u*$e,de+=u*Me,we+=u*je,Le+=u*Ce,Pe+=u*Ke,ye+=u*Ve,pe+=u*Ge,le+=u*We,ue+=u*ke,ce+=u*qe,oe+=u*Be,se+=u*Ae,te+=u*Ye,he+=u*Je,u=T[2],fe+=u*Ue,_e+=u*Re,de+=u*$e,we+=u*Me,Le+=u*je,Pe+=u*Ce,ye+=u*Ke,pe+=u*Ve,le+=u*Ge,ue+=u*We,ce+=u*ke,oe+=u*qe,se+=u*Be,te+=u*Ae,he+=u*Ye,ge+=u*Je,u=T[3],_e+=u*Ue,de+=u*Re,we+=u*$e,Le+=u*Me,Pe+=u*je,ye+=u*Ce,pe+=u*Ke,le+=u*Ve,ue+=u*Ge,ce+=u*We,oe+=u*ke,se+=u*qe,te+=u*Be,he+=u*Ae,ge+=u*Ye,ne+=u*Je,u=T[4],de+=u*Ue,we+=u*Re,Le+=u*$e,Pe+=u*Me,ye+=u*je,pe+=u*Ce,le+=u*Ke,ue+=u*Ve,ce+=u*Ge,oe+=u*We,se+=u*ke,te+=u*qe,he+=u*Be,ge+=u*Ae,ne+=u*Ye,be+=u*Je,u=T[5],we+=u*Ue,Le+=u*Re,Pe+=u*$e,ye+=u*Me,pe+=u*je,le+=u*Ce,ue+=u*Ke,ce+=u*Ve,oe+=u*Ge,se+=u*We,te+=u*ke,he+=u*qe,ge+=u*Be,ne+=u*Ae,be+=u*Ye,ve+=u*Je,u=T[6],Le+=u*Ue,Pe+=u*Re,ye+=u*$e,pe+=u*Me,le+=u*je,ue+=u*Ce,ce+=u*Ke,oe+=u*Ve,se+=u*Ge,te+=u*We,he+=u*ke,ge+=u*qe,ne+=u*Be,be+=u*Ae,ve+=u*Ye,Ee+=u*Je,u=T[7],Pe+=u*Ue,ye+=u*Re,pe+=u*$e,le+=u*Me,ue+=u*je,ce+=u*Ce,oe+=u*Ke,se+=u*Ve,te+=u*Ge,he+=u*We,ge+=u*ke,ne+=u*qe,be+=u*Be,ve+=u*Ae,Ee+=u*Ye,De+=u*Je,u=T[8],ye+=u*Ue,pe+=u*Re,le+=u*$e,ue+=u*Me,ce+=u*je,oe+=u*Ce,se+=u*Ke,te+=u*Ve,he+=u*Ge,ge+=u*We,ne+=u*ke,be+=u*qe,ve+=u*Be,Ee+=u*Ae,De+=u*Ye,me+=u*Je,u=T[9],pe+=u*Ue,le+=u*Re,ue+=u*$e,ce+=u*Me,oe+=u*je,se+=u*Ce,te+=u*Ke,he+=u*Ve,ge+=u*Ge,ne+=u*We,be+=u*ke,ve+=u*qe,Ee+=u*Be,De+=u*Ae,me+=u*Ye,mt+=u*Je,u=T[10],le+=u*Ue,ue+=u*Re,ce+=u*$e,oe+=u*Me,se+=u*je,te+=u*Ce,he+=u*Ke,ge+=u*Ve,ne+=u*Ge,be+=u*We,ve+=u*ke,Ee+=u*qe,De+=u*Be,me+=u*Ae,mt+=u*Ye,Tt+=u*Je,u=T[11],ue+=u*Ue,ce+=u*Re,oe+=u*$e,se+=u*Me,te+=u*je,he+=u*Ce,ge+=u*Ke,ne+=u*Ve,be+=u*Ge,ve+=u*We,Ee+=u*ke,De+=u*qe,me+=u*Be,mt+=u*Ae,Tt+=u*Ye,Bt+=u*Je,u=T[12],ce+=u*Ue,oe+=u*Re,se+=u*$e,te+=u*Me,he+=u*je,ge+=u*Ce,ne+=u*Ke,be+=u*Ve,ve+=u*Ge,Ee+=u*We,De+=u*ke,me+=u*qe,mt+=u*Be,Tt+=u*Ae,Bt+=u*Ye,dt+=u*Je,u=T[13],oe+=u*Ue,se+=u*Re,te+=u*$e,he+=u*Me,ge+=u*je,ne+=u*Ce,be+=u*Ke,ve+=u*Ve,Ee+=u*Ge,De+=u*We,me+=u*ke,mt+=u*qe,Tt+=u*Be,Bt+=u*Ae,dt+=u*Ye,Qt+=u*Je,u=T[14],se+=u*Ue,te+=u*Re,he+=u*$e,ge+=u*Me,ne+=u*je,be+=u*Ce,ve+=u*Ke,Ee+=u*Ve,De+=u*Ge,me+=u*We,mt+=u*ke,Tt+=u*qe,Bt+=u*Be,dt+=u*Ae,Qt+=u*Ye,jr+=u*Je,u=T[15],te+=u*Ue,he+=u*Re,ge+=u*$e,ne+=u*Me,be+=u*je,ve+=u*Ce,Ee+=u*Ke,De+=u*Ve,me+=u*Ge,mt+=u*We,Tt+=u*ke,Bt+=u*qe,dt+=u*Be,Qt+=u*Ae,jr+=u*Ye,yn+=u*Je,K+=38*he,W+=38*ge,fe+=38*ne,_e+=38*be,de+=38*ve,we+=38*Ee,Le+=38*De,Pe+=38*me,ye+=38*mt,pe+=38*Tt,le+=38*Bt,ue+=38*dt,ce+=38*Qt,oe+=38*jr,se+=38*yn,b=1,u=K+b+65535,b=Math.floor(u/65536),K=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=fe+b+65535,b=Math.floor(u/65536),fe=u-b*65536,u=_e+b+65535,b=Math.floor(u/65536),_e=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=we+b+65535,b=Math.floor(u/65536),we=u-b*65536,u=Le+b+65535,b=Math.floor(u/65536),Le=u-b*65536,u=Pe+b+65535,b=Math.floor(u/65536),Pe=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,K+=b-1+37*(b-1),b=1,u=K+b+65535,b=Math.floor(u/65536),K=u-b*65536,u=W+b+65535,b=Math.floor(u/65536),W=u-b*65536,u=fe+b+65535,b=Math.floor(u/65536),fe=u-b*65536,u=_e+b+65535,b=Math.floor(u/65536),_e=u-b*65536,u=de+b+65535,b=Math.floor(u/65536),de=u-b*65536,u=we+b+65535,b=Math.floor(u/65536),we=u-b*65536,u=Le+b+65535,b=Math.floor(u/65536),Le=u-b*65536,u=Pe+b+65535,b=Math.floor(u/65536),Pe=u-b*65536,u=ye+b+65535,b=Math.floor(u/65536),ye=u-b*65536,u=pe+b+65535,b=Math.floor(u/65536),pe=u-b*65536,u=le+b+65535,b=Math.floor(u/65536),le=u-b*65536,u=ue+b+65535,b=Math.floor(u/65536),ue=u-b*65536,u=ce+b+65535,b=Math.floor(u/65536),ce=u-b*65536,u=oe+b+65535,b=Math.floor(u/65536),oe=u-b*65536,u=se+b+65535,b=Math.floor(u/65536),se=u-b*65536,u=te+b+65535,b=Math.floor(u/65536),te=u-b*65536,K+=b-1+37*(b-1),P[0]=K,P[1]=W,P[2]=fe,P[3]=_e,P[4]=de,P[5]=we,P[6]=Le,P[7]=Pe,P[8]=ye,P[9]=pe,P[10]=le,P[11]=ue,P[12]=ce,P[13]=oe,P[14]=se,P[15]=te}function d(P,T){a(P,T,T)}function M(P,T){const O=i();let u;for(u=0;u<16;u++)O[u]=T[u];for(u=253;u>=0;u--)d(O,O),u!==2&&u!==4&&a(O,O,T);for(u=0;u<16;u++)P[u]=O[u]}function q(P,T){const O=i();let u;for(u=0;u<16;u++)O[u]=T[u];for(u=250;u>=0;u--)d(O,O),u!==1&&a(O,O,T);for(u=0;u<16;u++)P[u]=O[u]}function G(P,T){const O=i(),u=i(),b=i(),K=i(),W=i(),fe=i(),_e=i(),de=i(),we=i();v(O,P[1],P[0]),v(we,T[1],T[0]),a(O,O,we),S(u,P[0],P[1]),S(we,T[0],T[1]),a(u,u,we),a(b,P[3],T[3]),a(b,b,h),a(K,P[2],T[2]),S(K,K,K),v(W,u,O),v(fe,K,b),S(_e,K,b),S(de,u,O),a(P[0],W,fe),a(P[1],de,_e),a(P[2],_e,fe),a(P[3],W,de)}function J(P,T,O){for(let u=0;u<4;u++)F(P[u],T[u],O)}function X(P,T){const O=i(),u=i(),b=i();M(b,T[2]),a(O,T[0],b),a(u,T[1],b),N(P,u),P[31]^=A(O)<<7}function g(P,T,O){m(P[0],o),m(P[1],c),m(P[2],c),m(P[3],o);for(let u=255;u>=0;--u){const b=O[u/8|0]>>(u&7)&1;J(P,T,b),G(T,P),G(P,P),J(P,T,b)}}function _(P,T){const O=[i(),i(),i(),i()];m(O[0],l),m(O[1],D),m(O[2],c),a(O[3],l,D),g(P,O,T)}function U(P){if(P.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const T=(0,r.hash)(P);T[0]&=248,T[31]&=127,T[31]|=64;const O=new Uint8Array(32),u=[i(),i(),i(),i()];_(u,T),X(O,u);const b=new Uint8Array(64);return b.set(P),b.set(O,32),{publicKey:O,secretKey:b}}t.generateKeyPairFromSeed=U;function $(P){const T=(0,e.randomBytes)(32,P),O=U(T);return(0,n.wipe)(T),O}t.generateKeyPair=$;function C(P){if(P.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(P.subarray(32))}t.extractPublicKeyFromSecretKey=C;const R=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(P,T){let O,u,b,K;for(u=63;u>=32;--u){for(O=0,b=u-32,K=u-12;b<K;++b)T[b]+=O-16*T[u]*R[b-(u-32)],O=Math.floor((T[b]+128)/256),T[b]-=O*256;T[b]+=O,T[u]=0}for(O=0,b=0;b<32;b++)T[b]+=O-(T[31]>>4)*R[b],O=T[b]>>8,T[b]&=255;for(b=0;b<32;b++)T[b]-=O*R[b];for(u=0;u<32;u++)T[u+1]+=T[u]>>8,P[u]=T[u]&255}function z(P){const T=new Float64Array(64);for(let O=0;O<64;O++)T[O]=P[O];for(let O=0;O<64;O++)P[O]=0;j(P,T)}function Q(P,T){const O=new Float64Array(64),u=[i(),i(),i(),i()],b=(0,r.hash)(P.subarray(0,32));b[0]&=248,b[31]&=127,b[31]|=64;const K=new Uint8Array(64);K.set(b.subarray(32),32);const W=new r.SHA512;W.update(K.subarray(32)),W.update(T);const fe=W.digest();W.clean(),z(fe),_(u,fe),X(K,u),W.reset(),W.update(K.subarray(0,32)),W.update(P.subarray(32)),W.update(T);const _e=W.digest();z(_e);for(let de=0;de<32;de++)O[de]=fe[de];for(let de=0;de<32;de++)for(let we=0;we<32;we++)O[de+we]+=_e[de]*b[we];return j(K.subarray(32),O),K}t.sign=Q;function H(P,T){const O=i(),u=i(),b=i(),K=i(),W=i(),fe=i(),_e=i();return m(P[2],c),y(P[1],T),d(b,P[1]),a(K,b,f),v(b,b,P[2]),S(K,P[2],K),d(W,K),d(fe,W),a(_e,fe,W),a(O,_e,b),a(O,O,K),q(O,O),a(O,O,b),a(O,O,K),a(O,O,K),a(P[0],O,K),d(u,P[0]),a(u,u,K),x(u,b)&&a(P[0],P[0],w),d(u,P[0]),a(u,u,K),x(u,b)?-1:(A(P[0])===T[31]>>7&&v(P[0],o,P[0]),a(P[3],P[0],P[1]),0)}function ee(P,T,O){const u=new Uint8Array(32),b=[i(),i(),i(),i()],K=[i(),i(),i(),i()];if(O.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(H(K,P))return!1;const W=new r.SHA512;W.update(O.subarray(0,32)),W.update(P),W.update(T);const fe=W.digest();return z(fe),g(b,K,fe),_(K,O.subarray(32)),G(b,K),X(u,b),!B(O,u)}t.verify=ee;function Y(P){let T=[i(),i(),i(),i()];if(H(T,P))throw new Error("Ed25519: invalid public key");let O=i(),u=i(),b=T[1];S(O,c,b),v(u,c,b),M(u,u),a(O,O,u);let K=new Uint8Array(32);return N(K,O),K}t.convertPublicKeyToX25519=Y;function ae(P){const T=(0,r.hash)(P.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const O=new Uint8Array(T.subarray(0,32));return(0,n.wipe)(T),O}t.convertSecretKeyToX25519=ae}(Ii);const wg="EdDSA",mg="JWT",aa=".",ca="base64url",Eg="utf8",Dg="utf8",Sg=":",xg="did",Og="key",ua="base58btc",Ig="z",Ag="K36",Tg=32;function hn(t){return ut(ct(pr(t),Eg),ca)}function ha(t){const e=ct(Ag,ua),r=Ig+ut(Bn([e,t]),ua);return[xg,Og,r].join(Sg)}function Pg(t){return ut(t,ca)}function Rg(t){return ct([hn(t.header),hn(t.payload)].join(aa),Dg)}function Cg(t){return[hn(t.header),hn(t.payload),Pg(t.signature)].join(aa)}function fa(t=ir.randomBytes(Tg)){return Ii.generateKeyPairFromSeed(t)}async function Ng(t,e,r,n,i=Z.fromMiliseconds(Date.now())){const s={alg:wg,typ:mg},o=ha(n.publicKey),c=i+r,f={iss:o,sub:t,aud:e,iat:i,exp:c},h=Rg({header:s,payload:f}),l=Ii.sign(n.secretKey,h);return Cg({header:s,payload:f,signature:l})}const la=10,Fg=()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"),Lg=()=>typeof window<"u",Ug=Fg();class $g{constructor(e){if(this.url=e,this.events=new Ze.exports.EventEmitter,this.registering=!1,!us(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(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(pr(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!us(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=rs.isReactNative()?void 0:{rejectUnauthorized:!Qc(e)},s=new Ug(e,[],i);Lg()?s.onerror=o=>{const c=o;n(this.emitError(c.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=()=>this.onClose(),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Rn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=dr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ts(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>la&&this.events.setMaxListeners(la)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for URL: ${this.url}`));return this.events.emit("register_error",r),r}}var Ai={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,c="[object Arguments]",f="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",D="[object Date]",w="[object Error]",m="[object Function]",E="[object GeneratorFunction]",F="[object Map]",N="[object Number]",B="[object Null]",x="[object Object]",A="[object Promise]",y="[object Proxy]",S="[object RegExp]",v="[object Set]",a="[object String]",d="[object Symbol]",M="[object Undefined]",q="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",g="[object Float64Array]",_="[object Int8Array]",U="[object Int16Array]",$="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",j="[object Uint16Array]",z="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[g]=Y[_]=Y[U]=Y[$]=Y[C]=Y[R]=Y[j]=Y[z]=!0,Y[c]=Y[f]=Y[G]=Y[l]=Y[J]=Y[D]=Y[w]=Y[m]=Y[F]=Y[N]=Y[x]=Y[S]=Y[v]=Y[a]=Y[q]=!1;var ae=typeof He=="object"&&He&&He.Object===Object&&He,P=typeof self=="object"&&self&&self.Object===Object&&self,T=ae||P||Function("return this")(),O=e&&!e.nodeType&&e,u=O&&!0&&t&&!t.nodeType&&t,b=u&&u.exports===O,K=b&&ae.process,W=function(){try{return K&&K.binding&&K.binding("util")}catch{}}(),fe=W&&W.isTypedArray;function _e(p,I){for(var L=-1,k=p==null?0:p.length,Ie=0,ie=[];++L<k;){var Ne=p[L];I(Ne,L,p)&&(ie[Ie++]=Ne)}return ie}function de(p,I){for(var L=-1,k=I.length,Ie=p.length;++L<k;)p[Ie+L]=I[L];return p}function we(p,I){for(var L=-1,k=p==null?0:p.length;++L<k;)if(I(p[L],L,p))return!0;return!1}function Le(p,I){for(var L=-1,k=Array(p);++L<p;)k[L]=I(L);return k}function Pe(p){return function(I){return p(I)}}function ye(p,I){return p.has(I)}function pe(p,I){return p?.[I]}function le(p){var I=-1,L=Array(p.size);return p.forEach(function(k,Ie){L[++I]=[Ie,k]}),L}function ue(p,I){return function(L){return p(I(L))}}function ce(p){var I=-1,L=Array(p.size);return p.forEach(function(k){L[++I]=k}),L}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=T["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,be=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),ve=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=b?T.Buffer:void 0,me=T.Symbol,mt=T.Uint8Array,Tt=te.propertyIsEnumerable,Bt=oe.splice,dt=me?me.toStringTag:void 0,Qt=Object.getOwnPropertySymbols,jr=De?De.isBuffer:void 0,yn=ue(Object.keys,Object),Ue=hr(T,"DataView"),Re=hr(T,"Map"),$e=hr(T,"Promise"),Me=hr(T,"Set"),je=hr(T,"WeakMap"),Ce=hr(Object,"create"),Ke=tr(Ue),Ve=tr(Re),Ge=tr($e),We=tr(Me),ke=tr(je),qe=me?me.prototype:void 0,Be=qe?qe.valueOf:void 0;function Ae(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function Ye(){this.__data__=Ce?Ce(null):{},this.size=0}function Je(p){var I=this.has(p)&&delete this.__data__[p];return this.size-=I?1:0,I}function O_(p){var I=this.__data__;if(Ce){var L=I[p];return L===n?void 0:L}return ne.call(I,p)?I[p]:void 0}function I_(p){var I=this.__data__;return Ce?I[p]!==void 0:ne.call(I,p)}function A_(p,I){var L=this.__data__;return this.size+=this.has(p)?0:1,L[p]=Ce&&I===void 0?n:I,this}Ae.prototype.clear=Ye,Ae.prototype.delete=Je,Ae.prototype.get=O_,Ae.prototype.has=I_,Ae.prototype.set=A_;function Ft(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function T_(){this.__data__=[],this.size=0}function P_(p){var I=this.__data__,L=bn(I,p);if(L<0)return!1;var k=I.length-1;return L==k?I.pop():Bt.call(I,L,1),--this.size,!0}function R_(p){var I=this.__data__,L=bn(I,p);return L<0?void 0:I[L][1]}function C_(p){return bn(this.__data__,p)>-1}function N_(p,I){var L=this.__data__,k=bn(L,p);return k<0?(++this.size,L.push([p,I])):L[k][1]=I,this}Ft.prototype.clear=T_,Ft.prototype.delete=P_,Ft.prototype.get=R_,Ft.prototype.has=C_,Ft.prototype.set=N_;function er(p){var I=-1,L=p==null?0:p.length;for(this.clear();++I<L;){var k=p[I];this.set(k[0],k[1])}}function F_(){this.size=0,this.__data__={hash:new Ae,map:new(Re||Ft),string:new Ae}}function L_(p){var I=vn(this,p).delete(p);return this.size-=I?1:0,I}function U_(p){return vn(this,p).get(p)}function $_(p){return vn(this,p).has(p)}function M_(p,I){var L=vn(this,p),k=L.size;return L.set(p,I),this.size+=L.size==k?0:1,this}er.prototype.clear=F_,er.prototype.delete=L_,er.prototype.get=U_,er.prototype.has=$_,er.prototype.set=M_;function _n(p){var I=-1,L=p==null?0:p.length;for(this.__data__=new er;++I<L;)this.add(p[I])}function j_(p){return this.__data__.set(p,n),this}function B_(p){return this.__data__.has(p)}_n.prototype.add=_n.prototype.push=j_,_n.prototype.has=B_;function zt(p){var I=this.__data__=new Ft(p);this.size=I.size}function z_(){this.__data__=new Ft,this.size=0}function q_(p){var I=this.__data__,L=I.delete(p);return this.size=I.size,L}function H_(p){return this.__data__.get(p)}function K_(p){return this.__data__.has(p)}function V_(p,I){var L=this.__data__;if(L instanceof Ft){var k=L.__data__;if(!Re||k.length<r-1)return k.push([p,I]),this.size=++L.size,this;L=this.__data__=new er(k)}return L.set(p,I),this.size=L.size,this}zt.prototype.clear=z_,zt.prototype.delete=q_,zt.prototype.get=H_,zt.prototype.has=K_,zt.prototype.set=V_;function G_(p,I){var L=wn(p),k=!L&&a1(p),Ie=!L&&!k&&zi(p),ie=!L&&!k&&!Ie&&oc(p),Ne=L||k||Ie||ie,Xe=Ne?Le(p.length,String):[],rt=Xe.length;for(var Te in p)(I||ne.call(p,Te))&&!(Ne&&(Te=="length"||Ie&&(Te=="offset"||Te=="parent")||ie&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||r1(Te,rt)))&&Xe.push(Te);return Xe}function bn(p,I){for(var L=p.length;L--;)if(rc(p[L][0],I))return L;return-1}function W_(p,I,L){var k=I(p);return wn(p)?k:de(k,L(p))}function Br(p){return p==null?p===void 0?M:B:dt&&dt in Object(p)?e1(p):o1(p)}function Za(p){return zr(p)&&Br(p)==c}function Qa(p,I,L,k,Ie){return p===I?!0:p==null||I==null||!zr(p)&&!zr(I)?p!==p&&I!==I:k_(p,I,L,k,Qa,Ie)}function k_(p,I,L,k,Ie,ie){var Ne=wn(p),Xe=wn(I),rt=Ne?f:qt(p),Te=Xe?f:qt(I);rt=rt==c?x:rt,Te=Te==c?x:Te;var pt=rt==x,Et=Te==x,it=rt==Te;if(it&&zi(p)){if(!zi(I))return!1;Ne=!0,pt=!1}if(it&&!pt)return ie||(ie=new zt),Ne||oc(p)?ec(p,I,L,k,Ie,ie):Z_(p,I,rt,L,k,Ie,ie);if(!(L&i)){var _t=pt&&ne.call(p,"__wrapped__"),bt=Et&&ne.call(I,"__wrapped__");if(_t||bt){var Ht=_t?p.value():p,Lt=bt?I.value():I;return ie||(ie=new zt),Ie(Ht,Lt,L,k,ie)}}return it?(ie||(ie=new zt),Q_(p,I,L,k,Ie,ie)):!1}function Y_(p){if(!sc(p)||i1(p))return!1;var I=nc(p)?Ee:H;return I.test(tr(p))}function J_(p){return zr(p)&&ic(p.length)&&!!Y[Br(p)]}function X_(p){if(!s1(p))return yn(p);var I=[];for(var L in Object(p))ne.call(p,L)&&L!="constructor"&&I.push(L);return I}function ec(p,I,L,k,Ie,ie){var Ne=L&i,Xe=p.length,rt=I.length;if(Xe!=rt&&!(Ne&&rt>Xe))return!1;var Te=ie.get(p);if(Te&&ie.get(I))return Te==I;var pt=-1,Et=!0,it=L&s?new _n:void 0;for(ie.set(p,I),ie.set(I,p);++pt<Xe;){var _t=p[pt],bt=I[pt];if(k)var Ht=Ne?k(bt,_t,pt,I,p,ie):k(_t,bt,pt,p,I,ie);if(Ht!==void 0){if(Ht)continue;Et=!1;break}if(it){if(!we(I,function(Lt,rr){if(!ye(it,rr)&&(_t===Lt||Ie(_t,Lt,L,k,ie)))return it.push(rr)})){Et=!1;break}}else if(!(_t===bt||Ie(_t,bt,L,k,ie))){Et=!1;break}}return ie.delete(p),ie.delete(I),Et}function Z_(p,I,L,k,Ie,ie,Ne){switch(L){case J:if(p.byteLength!=I.byteLength||p.byteOffset!=I.byteOffset)return!1;p=p.buffer,I=I.buffer;case G:return!(p.byteLength!=I.byteLength||!ie(new mt(p),new mt(I)));case l:case D:case N:return rc(+p,+I);case w:return p.name==I.name&&p.message==I.message;case S:case a:return p==I+"";case F:var Xe=le;case v:var rt=k&i;if(Xe||(Xe=ce),p.size!=I.size&&!rt)return!1;var Te=Ne.get(p);if(Te)return Te==I;k|=s,Ne.set(p,I);var pt=ec(Xe(p),Xe(I),k,Ie,ie,Ne);return Ne.delete(p),pt;case d:if(Be)return Be.call(p)==Be.call(I)}return!1}function Q_(p,I,L,k,Ie,ie){var Ne=L&i,Xe=tc(p),rt=Xe.length,Te=tc(I),pt=Te.length;if(rt!=pt&&!Ne)return!1;for(var Et=rt;Et--;){var it=Xe[Et];if(!(Ne?it in I:ne.call(I,it)))return!1}var _t=ie.get(p);if(_t&&ie.get(I))return _t==I;var bt=!0;ie.set(p,I),ie.set(I,p);for(var Ht=Ne;++Et<rt;){it=Xe[Et];var Lt=p[it],rr=I[it];if(k)var ac=Ne?k(rr,Lt,it,I,p,ie):k(Lt,rr,it,p,I,ie);if(!(ac===void 0?Lt===rr||Ie(Lt,rr,L,k,ie):ac)){bt=!1;break}Ht||(Ht=it=="constructor")}if(bt&&!Ht){var mn=p.constructor,En=I.constructor;mn!=En&&"constructor"in p&&"constructor"in I&&!(typeof mn=="function"&&mn instanceof mn&&typeof En=="function"&&En instanceof En)&&(bt=!1)}return ie.delete(p),ie.delete(I),bt}function tc(p){return W_(p,h1,t1)}function vn(p,I){var L=p.__data__;return n1(I)?L[typeof I=="string"?"string":"hash"]:L.map}function hr(p,I){var L=pe(p,I);return Y_(L)?L:void 0}function e1(p){var I=ne.call(p,dt),L=p[dt];try{p[dt]=void 0;var k=!0}catch{}var Ie=ve.call(p);return k&&(I?p[dt]=L:delete p[dt]),Ie}var t1=Qt?function(p){return p==null?[]:(p=Object(p),_e(Qt(p),function(I){return Tt.call(p,I)}))}:f1,qt=Br;(Ue&&qt(new Ue(new ArrayBuffer(1)))!=J||Re&&qt(new Re)!=F||$e&&qt($e.resolve())!=A||Me&&qt(new Me)!=v||je&&qt(new je)!=q)&&(qt=function(p){var I=Br(p),L=I==x?p.constructor:void 0,k=L?tr(L):"";if(k)switch(k){case Ke:return J;case Ve:return F;case Ge:return A;case We:return v;case ke:return q}return I});function r1(p,I){return I=I??o,!!I&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<I}function n1(p){var I=typeof p;return I=="string"||I=="number"||I=="symbol"||I=="boolean"?p!=="__proto__":p===null}function i1(p){return!!be&&be in p}function s1(p){var I=p&&p.constructor,L=typeof I=="function"&&I.prototype||te;return p===L}function o1(p){return ve.call(p)}function tr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function rc(p,I){return p===I||p!==p&&I!==I}var a1=Za(function(){return arguments}())?Za:function(p){return zr(p)&&ne.call(p,"callee")&&!Tt.call(p,"callee")},wn=Array.isArray;function c1(p){return p!=null&&ic(p.length)&&!nc(p)}var zi=jr||l1;function u1(p,I){return Qa(p,I)}function nc(p){if(!sc(p))return!1;var I=Br(p);return I==m||I==E||I==h||I==y}function ic(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=o}function sc(p){var I=typeof p;return p!=null&&(I=="object"||I=="function")}function zr(p){return p!=null&&typeof p=="object"}var oc=fe?Pe(fe):J_;function h1(p){return c1(p)?G_(p):X_(p)}function f1(){return[]}function l1(){return!1}t.exports=u1})(Ai,Ai.exports);var Mg=Ai.exports,jg=Object.defineProperty,da=Object.getOwnPropertySymbols,Bg=Object.prototype.hasOwnProperty,zg=Object.prototype.propertyIsEnumerable,pa=(t,e,r)=>e in t?jg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ot=(t,e)=>{for(var r in e||(e={}))Bg.call(e,r)&&pa(t,r,e[r]);if(da)for(var r of da(e))zg.call(e,r)&&pa(t,r,e[r]);return t};function qg(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 c=t.length,f=t.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function D(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var F=0,N=0,B=0,x=E.length;B!==x&&E[B]===0;)B++,F++;for(var A=(x-B)*l+1>>>0,y=new Uint8Array(A);B!==x;){for(var S=E[B],v=0,a=A-1;(S!==0||v<N)&&a!==-1;a--,v++)S+=256*y[a]>>>0,y[a]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=v,B++}for(var d=A-N;d!==A&&y[d]===0;)d++;for(var M=f.repeat(F);d<A;++d)M+=t.charAt(y[d]);return M}function w(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var F=0;if(E[F]!==" "){for(var N=0,B=0;E[F]===f;)N++,F++;for(var x=(E.length-F)*h+1>>>0,A=new Uint8Array(x);E[F];){var y=r[E.charCodeAt(F)];if(y===255)return;for(var S=0,v=x-1;(y!==0||S<B)&&v!==-1;v--,S++)y+=c*A[v]>>>0,A[v]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");B=S,F++}if(E[F]!==" "){for(var a=x-B;a!==x&&A[a]===0;)a++;for(var d=new Uint8Array(N+(x-a)),M=N;a!==x;)d[M++]=A[a++];return d}}}function m(E){var F=w(E);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:w,decode:m}}var Hg=qg,Kg=Hg;const ga=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")},Vg=t=>new TextEncoder().encode(t),Gg=t=>new TextDecoder().decode(t);class Wg{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 kg{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 ya(this,e)}}class Yg{constructor(e){this.decoders=e}or(e){return ya(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 ya=(t,e)=>new Yg(ot(ot({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Jg{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Wg(e,r,n),this.decoder=new kg(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const fn=({name:t,prefix:e,encode:r,decode:n})=>new Jg(t,e,r,n),Ur=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Kg(r,e);return fn({prefix:t,name:e,encode:n,decode:s=>ga(i(s))})},Xg=(t,e,r,n)=>{const i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,f=0,h=0;for(let l=0;l<s;++l){const D=i[t[l]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|D,c+=r,c>=8&&(c-=8,o[h++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return o},Zg=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",o=0,c=0;for(let f=0;f<t.length;++f)for(c=c<<8|t[f],o+=8;o>r;)o-=r,s+=e[i&c>>o];if(o&&(s+=e[i&c<<r-o]),n)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>fn({prefix:e,name:t,encode(i){return Zg(i,n,r)},decode(i){return Xg(i,n,r,t)}}),Qg=fn({prefix:"\0",name:"identity",encode:t=>Gg(t),decode:t=>Vg(t)});var ey=Object.freeze({__proto__:null,identity:Qg});const ty=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ry=Object.freeze({__proto__:null,base2:ty});const ny=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var iy=Object.freeze({__proto__:null,base8:ny});const sy=Ur({prefix:"9",name:"base10",alphabet:"0123456789"});var oy=Object.freeze({__proto__:null,base10:sy});const ay=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),cy=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var uy=Object.freeze({__proto__:null,base16:ay,base16upper:cy});const hy=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fy=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ly=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),dy=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),py=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gy=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yy=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_y=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),by=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vy=Object.freeze({__proto__:null,base32:hy,base32upper:fy,base32pad:ly,base32padupper:dy,base32hex:py,base32hexupper:gy,base32hexpad:yy,base32hexpadupper:_y,base32z:by});const wy=Ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),my=Ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ey=Object.freeze({__proto__:null,base36:wy,base36upper:my});const Dy=Ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sy=Ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xy=Object.freeze({__proto__:null,base58btc:Dy,base58flickr:Sy});const Oy=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Iy=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ay=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ty=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Py=Object.freeze({__proto__:null,base64:Oy,base64pad:Iy,base64url:Ay,base64urlpad:Ty});const _a=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ry=_a.reduce((t,e,r)=>(t[r]=e,t),[]),Cy=_a.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ny(t){return t.reduce((e,r)=>(e+=Ry[r],e),"")}function Fy(t){const e=[];for(const r of t){const n=Cy[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Ly=fn({prefix:"\u{1F680}",name:"base256emoji",encode:Ny,decode:Fy});var Uy=Object.freeze({__proto__:null,base256emoji:Ly}),$y=va,ba=128,My=127,jy=~My,By=Math.pow(2,31);function va(t,e,r){e=e||[],r=r||0;for(var n=r;t>=By;)e[r++]=t&255|ba,t/=128;for(;t&jy;)e[r++]=t&255|ba,t>>>=7;return e[r]=t|0,va.bytes=r-n+1,e}var zy=Ti,qy=128,wa=127;function Ti(t,n){var r=0,n=n||0,i=0,s=n,o,c=t.length;do{if(s>=c)throw Ti.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&wa)<<i:(o&wa)*Math.pow(2,i),i+=7}while(o>=qy);return Ti.bytes=s-n,r}var Hy=Math.pow(2,7),Ky=Math.pow(2,14),Vy=Math.pow(2,21),Gy=Math.pow(2,28),Wy=Math.pow(2,35),ky=Math.pow(2,42),Yy=Math.pow(2,49),Jy=Math.pow(2,56),Xy=Math.pow(2,63),Zy=function(t){return t<Hy?1:t<Ky?2:t<Vy?3:t<Gy?4:t<Wy?5:t<ky?6:t<Yy?7:t<Jy?8:t<Xy?9:10},Qy={encode:$y,decode:zy,encodingLength:Zy},ma=Qy;const Ea=(t,e,r=0)=>(ma.encode(t,e,r),e),Da=t=>ma.encodingLength(t),Pi=(t,e)=>{const r=e.byteLength,n=Da(t),i=n+Da(r),s=new Uint8Array(i+r);return Ea(t,s,0),Ea(r,s,n),s.set(e,i),new e0(t,r,e,s)};class e0{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Sa=({name:t,code:e,encode:r})=>new t0(t,e,r);class t0{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?Pi(this.code,r):r.then(n=>Pi(this.code,n))}else throw Error("Unknown type, must be binary type")}}const xa=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),r0=Sa({name:"sha2-256",code:18,encode:xa("SHA-256")}),n0=Sa({name:"sha2-512",code:19,encode:xa("SHA-512")});var i0=Object.freeze({__proto__:null,sha256:r0,sha512:n0});const Oa=0,s0="identity",Ia=ga;var o0=Object.freeze({__proto__:null,identity:{code:Oa,name:s0,encode:Ia,digest:t=>Pi(Oa,Ia(t))}});new TextEncoder,new TextDecoder;const Aa=ot(ot(ot(ot(ot(ot(ot(ot(ot(ot({},ey),ry),iy),oy),uy),vy),Ey),xy),Py),Uy);ot(ot({},i0),o0);function a0(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ta(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Pa=Ta("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ri=Ta("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=a0(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),c0=ot({utf8:Pa,"utf-8":Pa,hex:Aa.base16,latin1:Ri,ascii:Ri,binary:Ri},Aa);function u0(t,e="utf8"){const r=c0[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}`)}const Ra="wc",h0=2,Ci="core",jt=`${Ra}@${2}:${Ci}:`,f0={name:Ci,logger:"error"},l0={database:":memory:"},d0="crypto",Ca="client_ed25519_seed",p0=Z.ONE_DAY,g0="keychain",y0="0.3",_0="messages",b0="0.3",v0=Z.SIX_HOURS,w0="publisher",Na="irn",m0="error",E0="wss://relay.walletconnect.com",D0="relayer",at={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},S0="_subscription",ln={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Fa=Z.ONE_SECOND,x0="2.3.0",O0="0.3",Ot={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},I0="subscription",A0="0.3",T0=Z.FIVE_SECONDS*1e3,P0="pairing",R0="0.3",$r={wc_pairingDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:0},res:{ttl:Z.ONE_DAY,prompt:!1,tag:0}}},It={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},C0="history",N0="0.3",F0="expirer",yt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},L0="0.3";class U0{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=g0,this.version=y0,this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,xo(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $0{constructor(e,r,n){this.core=e,this.logger=r,this.name=d0,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=fa(i);return ha(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=Dl();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=fa(s),c=oi();return await Ng(c,i,p0,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const c=this.getPrivateKey(i),f=Sl(c,s);return this.setSymKey(f,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||xl(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const c=vo(o),f=pr(s);if(wo(c)){const w=c.senderPublicKey,m=c.receiverPublicKey;i=await this.generateSharedKey(w,m)}const h=this.getSymKey(i),{type:l,senderPublicKey:D}=c;return Il({type:l,symKey:h,message:f,senderPublicKey:D})},this.decode=async(i,s,o)=>{this.isInitialized();const c=Pl(s,o);if(wo(c)){const l=c.receiverPublicKey,D=c.senderPublicKey;i=await this.generateSharedKey(l,D)}const f=this.getSymKey(i),h=Al({symKey:f,encoded:s});return Rn(h)},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.keychain=n||new U0(this.core,this.logger)}get context(){return xe.getLoggerContext(this.logger)}getPayloadType(e){const r=ci(e);return mr(r.type)}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(Ca)}catch{e=oi(),await this.keychain.set(Ca,e)}return u0(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class M0 extends lg{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=_0,this.version=b0,this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=ai(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=ai(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=xe.generateChildLogger(e,this.name),this.core=r}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,xo(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Oo(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class j0 extends dg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Ze.exports.EventEmitter,this.name=w0,this.queue=new Map,this.publishTimeout=1e4,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const o=s?.ttl||v0,c=ui(s),f=s?.prompt||!1,h=s?.tag||0,l={topic:n,message:i,opts:{ttl:o,relay:c,prompt:f,tag:h}},D=ai(i);this.queue.set(D,l);try{await await Io(this.rpcPublish(n,i,o,c,f,h),this.publishTimeout),this.relayer.events.emit(at.publish,l)}catch{this.logger.debug("Publishing Payload stalled"),this.relayer.events.emit(at.connection_stalled);return}this.onPublish(D,l),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(o){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(o),o}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=xe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return xe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,o){var c,f,h,l;const D={method:hi(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o}};return gt((c=D.params)==null?void 0:c.prompt)&&((f=D.params)==null||delete f.prompt),gt((h=D.params)==null?void 0:h.tag)&&((l=D.params)==null||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class B0{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),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)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var z0=Object.defineProperty,q0=Object.defineProperties,H0=Object.getOwnPropertyDescriptors,La=Object.getOwnPropertySymbols,K0=Object.prototype.hasOwnProperty,V0=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?z0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dn=(t,e)=>{for(var r in e||(e={}))K0.call(e,r)&&Ua(t,r,e[r]);if(La)for(var r of La(e))V0.call(e,r)&&Ua(t,r,e[r]);return t},Ni=(t,e)=>q0(t,H0(e));class G0 extends yg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new B0,this.events=new Ze.exports.EventEmitter,this.name=I0,this.version=A0,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=jt,this.subscribeTimeout=1e4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable())},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=ui(i),o={topic:n,relay:s};this.pending.set(n,o);const c=await this.rpcSubscribe(n,s);return this.onSubscribe(c,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),c}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const o=new Z.Watch;o.start(this.pendingSubscriptionWatchLabel);const c=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(c),o.stop(this.pendingSubscriptionWatchLabel),i(!0)),o.elapsed(this.pendingSubscriptionWatchLabel)>=T0&&(clearInterval(c),o.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.restart=async()=>{await this.restore(),await this.reset()},this.relayer=e,this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}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=ui(n);await this.rpcUnsubscribe(e,r,i);const s=ze("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){const n={method:hi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await Io(this.relayer.provider.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(at.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:hi(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.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,Ni(dn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Ni(dn({},r),{id:e})),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.subscriptions.has(e)||(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,dn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ot.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}=V("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(Ot.deleted,Ni(dn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ot.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(Ot.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),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 resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.relayer.transportExplicitlyClosed||this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.on(at.connect,async()=>{await this.onConnect()}),this.relayer.on(at.disconnect,()=>{this.onDisconnect()}),this.events.on(Ot.created,async e=>{const r=Ot.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Ot.deleted,async e=>{const r=Ot.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var W0=Object.defineProperty,$a=Object.getOwnPropertySymbols,k0=Object.prototype.hasOwnProperty,Y0=Object.prototype.propertyIsEnumerable,Ma=(t,e,r)=>e in t?W0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,J0=(t,e)=>{for(var r in e||(e={}))k0.call(e,r)&&Ma(t,r,e[r]);if($a)for(var r of $a(e))Y0.call(e,r)&&Ma(t,r,e[r]);return t};class X0 extends pg{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ze.exports.EventEmitter,this.name=D0,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?xe.generateChildLogger(e.logger,this.name):sn(xe.getDefaultLoggerOptions({level:e.logger||m0})),this.messages=new M0(this.logger,e.core),this.subscriber=new G0(this,this.logger),this.publisher=new j0(this,this.logger),this.relayUrl=e?.relayUrl||E0,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.transportOpen(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return xe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){this.isInitialized();let n="";return await Promise.all([new Promise(i=>{this.subscriber.once(Ot.created,s=>{s.topic===e&&i()})}),new Promise(async i=>{n=await this.subscriber.subscribe(e,r),i()})]),n}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 transportClose(){this.transportExplicitlyClosed=!0,this.connected&&await this.provider.disconnect(),this.events.emit(at.transport_closed)}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1;try{await Promise.all([new Promise(r=>{this.initialized||r(),this.subscriber.once(Ot.resubscribed,()=>{r()})}),await Promise.race([this.provider.connect(),new Promise((r,n)=>this.once(at.transport_closed,()=>{n(new Error("closeTransport called before connection was established"))}))])])}catch(r){const n=r;if(!/socket hang up/i.test(n.message))throw new Error(n.message);this.logger.error(n),this.events.emit(at.transport_closed)}}async restartTransport(e){await this.transportClose(),await new Promise(r=>setTimeout(r,Fa)),await this.transportOpen(e)}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new Tn(new $g(Kl({sdkVersion:x0,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),In(e)){if(!e.method.endsWith(S0))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(J0({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(at.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Vr(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(ln.payload,e=>this.onProviderPayload(e)),this.provider.on(ln.connect,()=>{this.events.emit(at.connect)}),this.provider.on(ln.disconnect,()=>{this.events.emit(at.disconnect),this.attemptToReconnect()}),this.provider.on(ln.error,e=>this.events.emit(at.error,e)),this.events.on(at.connection_stalled,async()=>{await this.restartTransport()})}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.transportOpen()},Z.toMiliseconds(Fa))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Z0=Object.defineProperty,ja=Object.getOwnPropertySymbols,Q0=Object.prototype.hasOwnProperty,e_=Object.prototype.propertyIsEnumerable,Ba=(t,e,r)=>e in t?Z0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,za=(t,e)=>{for(var r in e||(e={}))Q0.call(e,r)&&Ba(t,r,e[r]);if(ja)for(var r of ja(e))e_.call(e,r)&&Ba(t,r,e[r]);return t};class pn extends gg{constructor(e,r,n,i=jt,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=O0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{fd(o)?this.map.set(o.id,o):ld(o)?this.map.set(o.topic,o):this.getKey&&o!==null&&!gt(o)&&this.map.set(this.getKey(o),o)}),this.cached=[],this.initialized=!0)},this.set=async(o,c)=>{this.isInitialized(),this.map.has(o)?await this.update(o,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:c}),this.map.set(o,c),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(c=>Object.keys(o).every(f=>Mg(c[f],o[f]))):this.values),this.update=async(o,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:c});const f=za(za({},this.getData(o)),c);this.map.set(o,f),await this.persist()},this.delete=async(o,c)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:c}),this.map.delete(o),await this.persist())},this.logger=xe.generateChildLogger(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(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){const{message:n}=V("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}=V("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}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class t_{constructor(e,r){this.core=e,this.logger=r,this.name=P0,this.version=R0,this.events=new Ze.exports,this.initialized=!1,this.storagePrefix=jt,this.ignoredPayloadTypes=[kt],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=oi(),i=await this.core.crypto.setSymKey(n),s=St(Z.FIVE_MINUTES),o={protocol:Na},c={topic:i,expiry:s,relay:o,active:!1},f=td({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:o});return await this.pairings.set(i,c),await this.core.relayer.subscribe(i),this.core.expirer.set(i,s),{topic:i,uri:f}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:i,symKey:s,relay:o}=Ql(n.uri),c=St(Z.FIVE_MINUTES),f={topic:i,relay:o,expiry:c,active:!1};return await this.pairings.set(i,f),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:o}),this.core.expirer.set(i,c),n.activatePairing&&await this.activate({topic:i}),f},this.activate=async({topic:n})=>{this.isInitialized();const i=St(Z.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:i}),this.core.expirer.set(n,i)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:c,reject:f}=Yt();this.events.once(Fe("pairing_ping",s),({error:h})=>{h?f(h):c()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),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",ze("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const o=Kr(i,s),c=await this.core.crypto.encode(n,o),f=$r[i].req;return this.core.history.set(n,o),await this.core.relayer.publish(n,c,f),o.id},this.sendResult=async(n,i,s)=>{const o=Vr(n,s),c=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=$r[f.request.method].res;await this.core.relayer.publish(i,c,h),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=dr(n,s),c=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),h=$r[f.request.method]?$r[f.request.method].res:$r.unregistered_method.res;await this.core.relayer.publish(i,c,h),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,ze("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>Mt(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n,o=s.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;if(this.pairings.keys.includes(i))switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit("pairing_ping",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Ct(i)?this.events.emit(Fe("pairing_ping",s),{}):wt(i)&&this.events.emit(Fe("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.sendResult(s,n,!0),await this.deletePairing(n),this.events.emit("pairing_delete",{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const c=ze("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,c),this.logger.error(c)}catch(c){await this.sendError(s,n,c),this.logger.error(c)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(ze("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!ft(n)){const{message:i}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!hd(n.uri)){const{message:i}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!ft(n)){const{message:s}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!ft(n)){const{message:s}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!et(n,!1)){const{message:i}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(Mt(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.pairings=new pn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return xe.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(at.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const i=await this.core.crypto.decode(r,n);In(i)?(this.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):An(i)&&(await this.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.core.expirer.on(yt.expired,async e=>{const{topic:r}=To(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class r_ extends fg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Ze.exports.EventEmitter,this.name=C0,this.version=N0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,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};this.records.set(o.id,o),this.events.emit(It.created,o)},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=wt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(It.updated,i))},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)),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(It.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:Kr(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}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(It.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=V("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(It.created,e=>{const r=It.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(It.updated,e=>{const r=It.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(It.deleted,e=>{const r=It.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}class n_ extends _g{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Ze.exports.EventEmitter,this.name=F0,this.version=L0,this.cached=[],this.initialized=!1,this.storagePrefix=jt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},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(yt.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},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(yt.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=xe.generateChildLogger(r,this.name)}get context(){return xe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Vl(e);if(typeof e=="number")return Gl(e);const{message:r}=V("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(yt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=V("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}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Z.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(yt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Rr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(yt.created,e=>{const r=yt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(yt.expired,e=>{const r=yt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(yt.deleted,e=>{const r=yt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var i_=Object.defineProperty,qa=Object.getOwnPropertySymbols,s_=Object.prototype.hasOwnProperty,o_=Object.prototype.propertyIsEnumerable,Ha=(t,e,r)=>e in t?i_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ka=(t,e)=>{for(var r in e||(e={}))s_.call(e,r)&&Ha(t,r,e[r]);if(qa)for(var r of qa(e))o_.call(e,r)&&Ha(t,r,e[r]);return t};class Fi extends hg{constructor(e){super(e),this.protocol=Ra,this.version=h0,this.name=Ci,this.events=new Ze.exports.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(xe.getDefaultLoggerOptions({level:e?.logger||f0.logger}));this.logger=xe.generateChildLogger(r,this.name),this.heartbeat=new Rr.HeartBeat,this.crypto=new $0(this,this.logger,e?.keychain),this.history=new r_(this,this.logger),this.expirer=new n_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new yp(Ka(Ka({},l0),e?.storageOptions)),this.relayer=new X0({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new t_(this,this.logger)}static async init(e){const r=new Fi(e);return await r.initialize(),r}get context(){return xe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const a_=Fi,Va="wc",Ga=2,Wa="client",Li=`${Va}@${Ga}:${Wa}:`,Ui={name:Wa,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},c_="proposal",u_="session",gn=Z.SEVEN_DAYS,h_="engine",Mr={wc_sessionPropose:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1115}}},$i={min:Z.FIVE_MINUTES,max:Z.SEVEN_DAYS},f_="request";var l_=Object.defineProperty,d_=Object.defineProperties,p_=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,g_=Object.prototype.hasOwnProperty,y_=Object.prototype.propertyIsEnumerable,Ya=(t,e,r)=>e in t?l_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nt=(t,e)=>{for(var r in e||(e={}))g_.call(e,r)&&Ya(t,r,e[r]);if(ka)for(var r of ka(e))y_.call(e,r)&&Ya(t,r,e[r]);return t},Mi=(t,e)=>d_(t,p_(e));class __ extends vg{constructor(e){super(e),this.name=h_,this.events=new Ze.exports,this.initialized=!1,this.ignoredPayloadTypes=[kt],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Mr)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let o=n,c,f=!1;if(o&&(f=this.client.core.pairing.pairings.get(o).active),!o||!f){const{topic:N,uri:B}=await this.client.core.pairing.create();o=N,c=B}const h=await this.client.core.crypto.generateKeyPair(),l={requiredNamespaces:i,relays:s??[{protocol:Na}],proposer:{publicKey:h,metadata:this.client.metadata}},{reject:D,resolve:w,done:m}=Yt();if(this.events.once(Fe("session_connect"),async({error:N,session:B})=>{if(N)D(N);else if(B){B.self.publicKey=h;const x=Mi(Nt({},B),{requiredNamespaces:B.requiredNamespaces});await this.client.session.set(B.topic,x),await this.setExpiry(B.topic,B.expiry),o&&await this.client.core.pairing.updateMetadata({topic:o,metadata:B.peer.metadata}),w(x)}}),!o){const{message:N}=V("NO_MATCHING_KEY",`connect() pairing topic: ${o}`);throw new Error(N)}const E=await this.sendRequest(o,"wc_sessionPropose",l),F=St(Z.FIVE_MINUTES);return await this.setProposal(E,Nt({id:E,expiry:F},l)),{uri:c,approval:m}},this.pair=async r=>(this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,o=this.client.proposal.get(n);let{pairingTopic:c,proposer:f,requiredNamespaces:h}=o;rn(h)||(h=sd(s,"approve()"),this.client.proposal.set(n,Mi(Nt({},o),{requiredNamespaces:h})));const l=await this.client.core.crypto.generateKeyPair(),D=f.publicKey,w=await this.client.core.crypto.generateSharedKey(l,D),m={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:St(gn)};await this.client.core.relayer.subscribe(w);const E=await this.sendRequest(w,"wc_sessionSettle",m),{done:F,resolve:N,reject:B}=Yt();this.events.once(Fe("session_approve",E),({error:A})=>{A?B(A):N(this.client.session.get(w))});const x=Mi(Nt({},m),{topic:w,acknowledged:!1,self:m.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:l});return await this.client.session.set(w,x),await this.setExpiry(w,St(gn)),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:x.peer.metadata}),c&&n&&(await this.sendResult(n,c,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,ze("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:c})),{topic:w,acknowledged:F}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,ze("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:o,resolve:c,reject:f}=Yt();return this.events.once(Fe("session_update",s),({error:h})=>{h?f(h):c()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:o}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:o,reject:c}=Yt();return this.events.once(Fe("session_extend",i),({error:f})=>{f?c(f):o()}),await this.setExpiry(n,St(gn)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s,expiry:o}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n},o),{done:f,resolve:h,reject:l}=Yt(o);return this.events.once(Fe("session_request",c),({error:D,result:w})=>{D?l(D):h(w)}),await f()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Ct(i)?await this.sendResult(s,n,i.result):wt(i)&&await this.sendError(s,n,i.error),this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0})},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:o,reject:c}=Yt();this.events.once(Fe("session_ping",i),({error:f})=>{f?c(f):o()}),await s()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",ze("USER_DISCONNECTED")),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>cd(n,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.deleteSession=async(r,n)=>{const{self:i}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await Promise.all([this.client.session.delete(r,ze("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.deleteSymKey(r),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deleteProposal=async(r,n)=>{await Promise.all([this.client.proposal.delete(r,ze("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)])},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.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.core.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.core.expirer.set(r,n.expiry)},this.setPendingSessionRequest=async r=>{const n=Mr.wc_sessionRequest.req.ttl,{id:i,topic:s,params:o}=r;await this.client.pendingRequest.set(i,{id:i,topic:s,params:o}),n&&this.client.core.expirer.set(i,St(n))},this.sendRequest=async(r,n,i,s)=>{const o=Kr(n,i),c=await this.client.core.crypto.encode(r,o),f=Mr[n].req;return s&&(f.ttl=s),this.client.core.history.set(r,o),this.client.core.relayer.publish(r,c,f),o.id},this.sendResult=async(r,n,i)=>{const s=Vr(r,i),o=await this.client.core.crypto.encode(n,s),c=await this.client.core.history.get(n,r),f=Mr[c.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=dr(r,i),o=await this.client.core.crypto.encode(n,s),c=await this.client.core.history.get(n,r),f=Mr[c.request.method].res;this.client.core.relayer.publish(n,o,f),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{Mt(i.expiry)&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Mt(i.expiry)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession(i)),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.core.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);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);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Nt({},n.params));const o=St(Z.FIVE_MINUTES),c=Nt({id:s,pairingTopic:r,expiry:o},i);await this.setProposal(s,c),this.client.events.emit("session_proposal",{id:s,params:c})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Ct(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const o=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:o});const c=o.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const f=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const h=await this.client.core.crypto.generateSharedKey(c,f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:h});const l=await this.client.core.relayer.subscribe(h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else wt(n)&&(await this.client.proposal.delete(i,ze("USER_DISCONNECTED")),this.events.emit(Fe("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:c,expiry:f,namespaces:h,requiredNamespaces:l}=n.params,D={topic:r,relay:o,expiry:f,namespaces:h,acknowledged:!0,requiredNamespaces:l,controller:c.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:c.publicKey,metadata:c.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Fe("session_connect"),{session:D})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Ct(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Fe("session_approve",i),{})):wt(n)&&(await this.client.session.delete(r,ze("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Nt({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError(s,r,o),this.client.logger.error(o)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_update",i),{}):wt(n)&&this.events.emit(Fe("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,St(gn)),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_extend",i),{}):wt(n)&&this.events.emit(Fe("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;setTimeout(()=>{Ct(n)?this.events.emit(Fe("session_ping",i),{}):wt(n)&&this.events.emit(Fe("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Nt({topic:r},s)),await this.setPendingSessionRequest({id:i,topic:r,params:s}),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Ct(n)?this.events.emit(Fe("session_request",i),{result:n.result}):wt(n)&&this.events.emit(Fe("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Nt({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(o){await this.sendError(i,r,o),this.client.logger.error(o)}},this.isValidConnect=async r=>{if(!ft(r)){const{message:c}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;if(gt(n)||await this.isValidPairingTopic(n),!gt(i)&&rn(i)===0)return;const o=vd(i,"connect()");if(o)throw new Error(o.message);if(!wd(s,!0)){const{message:c}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(c)}},this.isValidApprove=async r=>{if(!ft(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const o=this.client.proposal.get(n),c=nn(i,"approve()");if(c)throw new Error(c.message);const f=Uo(o.requiredNamespaces,i,"update()");if(f)throw new Error(f.message);if(!et(s,!0)){const{message:h}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}},this.isValidReject=async r=>{if(!ft(r)){const{message:s}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!Ed(i)){const{message:s}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!ft(r)){const{message:h}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!Fo(n)){const{message:h}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const c=dd(i,"onSessionSettleRequest()");if(c)throw new Error(c.message);const f=nn(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(Mt(o)){const{message:h}=V("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!ft(r)){const{message:f}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(f)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=nn(i,"update()");if(o)throw new Error(o.message);const c=Uo(s.requiredNamespaces,i,"update()");if(c)throw new Error(c.message)},this.isValidExtend=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!ft(r)){const{message:f}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(f)}const{topic:n,request:i,chainId:s,expiry:o}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!Lo(c,s)){const{message:f}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Dd(i)){const{message:f}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(f)}if(!Od(c,s,i.method)){const{message:f}=V("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(f)}if(o&&!Ad(o,$i)){const{message:f}=V("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${$i.min} and ${$i.max}`);throw new Error(f)}},this.isValidRespond=async r=>{if(!ft(r)){const{message:s}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!Sd(i)){const{message:s}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!ft(r)){const{message:c}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(c)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!Lo(o,s)){const{message:c}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(c)}if(!xd(i)){const{message:c}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(c)}if(!Id(o,s,i.name)){const{message:c}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(c)}},this.isValidDisconnect=async r=>{if(!ft(r)){const{message:i}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(at.message,async e=>{const{topic:r,message:n}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const i=await this.client.core.crypto.decode(r,n);In(i)?(this.client.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):An(i)&&(await this.client.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.core.expirer.on(yt.expired,async e=>{const{topic:r,id:n}=To(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):n&&await this.deleteProposal(n,!0)})}isValidPairingTopic(e){if(!et(e,!1)){const{message:r}=V("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}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!et(e,!1)){const{message:r}=V("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=V("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(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(et(e,!1)){const{message:r}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!md(e)){const{message:r}=V("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class b_ extends pn{constructor(e,r){super(e,r,c_,Li),this.core=e,this.logger=r}}class v_ extends pn{constructor(e,r){super(e,r,u_,Li),this.core=e,this.logger=r}}class w_ extends pn{constructor(e,r){super(e,r,f_,Li),this.core=e,this.logger=r}}class ji extends bg{constructor(e){super(e),this.protocol=Va,this.version=Ga,this.name=Ui.name,this.events=new Ze.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||Ui.name,this.metadata=e?.metadata||Bl();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(xe.getDefaultLoggerOptions({level:e?.logger||Ui.logger}));this.core=e?.core||new a_(e),this.logger=xe.generateChildLogger(r,this.name),this.session=new v_(this.core,this.logger),this.proposal=new b_(this.core,this.logger),this.pendingRequest=new w_(this.core,this.logger),this.engine=new __(this)}static async init(e){const r=new ji(e);return await r.initialize(),r}get context(){return xe.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}function m_(t){return typeof t<"u"&&typeof t.context<"u"}const At={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class E_ extends Wc{constructor(e){super(),this.events=new Ze.exports.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?ti(this.session.namespaces):ml(this.requiredNamespaces)}get accounts(){return this.session?ei(this.session.namespaces):[]}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(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(At.uri,{uri:n}),this.session=await i(),this.events.emit(At.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:ze("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",Vr(e.id,n))).catch(n=>this.events.emit("payload",dr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(At.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(m_(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await ji.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(At.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(At.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(At.updated,this.session)))}),this.client.on("session_delete",e=>{var r;this.session&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(At.deleted,this.session),this.session=void 0))}))}}const D_=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],S_=["chainChanged","accountsChanged"];function Ja(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Xa(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Bi([t])]),r}function Bi(t){return Number(t[0].split(":")[1])}class x_{constructor(e){this.events=new Ze.exports.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Ja(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Bi(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}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}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(At.created,e=>{const r=ti(e.namespaces,[this.namespace]);this.setChainIds(r);const n=ei(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(At.updated,e=>{const r=ti(e.namespaces,[this.namespace]);this.setChainIds(r);const n=ei(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(At.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new E_({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new Tn(r)}setHttpProvider(e){const r=Xa(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new Tn(new eu(r))}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)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}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)}}vt.default=x_,vt.getEthereumChainId=Bi,vt.getRpcConfig=Ja,vt.getRpcUrl=Xa,vt.signerEvents=S_,vt.signerMethods=D_,Object.defineProperty(vt,"__esModule",{value:!0})});
67
67
  //# sourceMappingURL=index.umd.js.map