@walletconnect/ethereum-provider 2.1.3-1edb9cd9 → 2.1.3-c6047312
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 +66 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -9
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,67 @@
|
|
|
1
|
-
(function(Et,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(Et=typeof globalThis<"u"?globalThis:Et||self,Z(Et["@walletconnect/ethereum-provider"]={}))})(this,function(Et){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ya(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xi(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(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var _r=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!Ja(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||br(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],jn(r))return!1;if(Lt(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:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(br(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},Ke.prototype.addListener=function(t,e){var r;if(!Lt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Lt(e.listener)?e.listener:e),this._events[t]?br(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,br(this._events[t])&&!this._events[t].warned&&(jn(this._maxListeners)?r=Ke.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},Ke.prototype.on=Ke.prototype.addListener,Ke.prototype.once=function(t,e){if(!Lt(e))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(t,i),r||(r=!0,e.apply(this,arguments))}return i.listener=e,this.on(t,i),this},Ke.prototype.removeListener=function(t,e){var r,i,n,s;if(!Lt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],n=r.length,i=-1,r===e||Lt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(br(r)){for(s=n;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(i<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ke.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],Lt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Lt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Lt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Lt(t){return typeof t=="function"}function Ja(t){return typeof t=="number"}function br(t){return typeof t=="object"&&t!==null}function jn(t){return t===void 0}const Xa="PARSE_ERROR",Za="INVALID_REQUEST",Qa="METHOD_NOT_FOUND",ec="INVALID_PARAMS",$n="INTERNAL_ERROR",Oi="SERVER_ERROR",tc=[-32700,-32600,-32601,-32602,-32603],mr={[Xa]:{code:-32700,message:"Parse error"},[Za]:{code:-32600,message:"Invalid Request"},[Qa]:{code:-32601,message:"Method not found"},[ec]:{code:-32602,message:"Invalid params"},[$n]:{code:-32603,message:"Internal error"},[Oi]:{code:-32e3,message:"Server error"}},Bn=Oi;function rc(t){return tc.includes(t)}function zn(t){return Object.keys(mr).includes(t)?mr[t]:mr[Bn]}function ic(t){const e=Object.values(mr).find(r=>r.code===t);return e||mr[Bn]}function Hn(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Kn={},Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.isBrowserCryptoAvailable=Ht.getSubtleCrypto=Ht.getBrowerCrypto=void 0;function Ii(){return Z?.crypto||Z?.msCrypto||{}}Ht.getBrowerCrypto=Ii;function qn(){const t=Ii();return t.subtle||t.webkitSubtle}Ht.getSubtleCrypto=qn;function nc(){return!!Ii()&&!!qn()}Ht.isBrowserCryptoAvailable=nc;var Kt={};Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.isBrowser=Kt.isNode=Kt.isReactNative=void 0;function Vn(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Kt.isReactNative=Vn;function Gn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Kt.isNode=Gn;function sc(){return!Vn()&&!Gn()}Kt.isBrowser=sc,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Ht,t),r(Kt,t)}(Kn);function oc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function Wr(t,e,r){return{id:r||oc(),jsonrpc:"2.0",method:t,params:e}}function kr(t,e){return{id:t,jsonrpc:"2.0",result:e}}function wr(t,e,r){return{id:t,jsonrpc:"2.0",error:ac(e,r)}}function ac(t,e){return typeof t>"u"?zn($n):(typeof t=="string"&&(t=Object.assign(Object.assign({},zn(Oi)),{message:t})),typeof e<"u"&&(t.data=e),rc(t.code)&&(t=ic(t.code)),t)}class Wn{}class cc extends Wn{constructor(e){super()}}class hc extends Wn{constructor(){super()}}class uc extends hc{constructor(e){super()}}const fc="^https?:",lc="^wss?:";function dc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function kn(t,e){const r=dc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Yn(t){return kn(t,fc)}function Jn(t){return kn(t,lc)}function pc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Xn(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Ai(t){return Xn(t)&&"method"in t}function Ti(t){return Xn(t)&&(Rt(t)||Dt(t))}function Rt(t){return"result"in t}function Dt(t){return"error"in t}class Ci extends uc{constructor(e){super(e),this.events=new _r.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(Wr(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Dt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ti(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 Ni={exports:{}};(function(t,e){var r=typeof self<"u"?self:Z,i=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(c){var h={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 u(l){return l&&DataView.prototype.isPrototypeOf(l)}if(h.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(l){return l&&f.indexOf(Object.prototype.toString.call(l))>-1};function D(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))throw new TypeError("Invalid character in header field name");return l.toLowerCase()}function C(l){return typeof l!="string"&&(l=String(l)),l}function S(l){var v={next:function(){var U=l.shift();return{done:U===void 0,value:U}}};return h.iterable&&(v[Symbol.iterator]=function(){return v}),v}function w(l){this.map={},l instanceof w?l.forEach(function(v,U){this.append(U,v)},this):Array.isArray(l)?l.forEach(function(v){this.append(v[0],v[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(v){this.append(v,l[v])},this)}w.prototype.append=function(l,v){l=D(l),v=C(v);var U=this.map[l];this.map[l]=U?U+", "+v:v},w.prototype.delete=function(l){delete this.map[D(l)]},w.prototype.get=function(l){return l=D(l),this.has(l)?this.map[l]:null},w.prototype.has=function(l){return this.map.hasOwnProperty(D(l))},w.prototype.set=function(l,v){this.map[D(l)]=C(v)},w.prototype.forEach=function(l,v){for(var U in this.map)this.map.hasOwnProperty(U)&&l.call(v,this.map[U],U,this)},w.prototype.keys=function(){var l=[];return this.forEach(function(v,U){l.push(U)}),S(l)},w.prototype.values=function(){var l=[];return this.forEach(function(v){l.push(v)}),S(l)},w.prototype.entries=function(){var l=[];return this.forEach(function(v,U){l.push([U,v])}),S(l)},h.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function P(l){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}function N(l){return new Promise(function(v,U){l.onload=function(){v(l.result)},l.onerror=function(){U(l.error)}})}function M(l){var v=new FileReader,U=N(v);return v.readAsArrayBuffer(l),U}function E(l){var v=new FileReader,U=N(v);return v.readAsText(l),U}function I(l){for(var v=new Uint8Array(l),U=new Array(v.length),q=0;q<v.length;q++)U[q]=String.fromCharCode(v[q]);return U.join("")}function y(l){if(l.slice)return l.slice(0);var v=new Uint8Array(l.byteLength);return v.set(new Uint8Array(l)),v.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(l){this._bodyInit=l,l?typeof l=="string"?this._bodyText=l:h.blob&&Blob.prototype.isPrototypeOf(l)?this._bodyBlob=l:h.formData&&FormData.prototype.isPrototypeOf(l)?this._bodyFormData=l:h.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)?this._bodyText=l.toString():h.arrayBuffer&&h.blob&&u(l)?(this._bodyArrayBuffer=y(l.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):h.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(l)||g(l))?this._bodyArrayBuffer=y(l):this._bodyText=l=Object.prototype.toString.call(l):this._bodyText="",this.headers.get("content-type")||(typeof l=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):h.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},h.blob&&(this.blob=function(){var l=P(this);if(l)return l;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(M)}),this.text=function(){var l=P(this);if(l)return l;if(this._bodyBlob)return E(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)},h.formData&&(this.formData=function(){return this.text().then(j)}),this.json=function(){return this.text().then(JSON.parse)},this}var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(l){var v=l.toUpperCase();return b.indexOf(v)>-1?v:l}function d(l,v){v=v||{};var U=v.body;if(l instanceof d){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,v.headers||(this.headers=new w(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!U&&l._bodyInit!=null&&(U=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new w(v.headers)),this.method=o(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.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 j(l){var v=new FormData;return l.trim().split("&").forEach(function(U){if(U){var q=U.split("="),R=q.shift().replace(/\+/g," "),L=q.join("=").replace(/\+/g," ");v.append(decodeURIComponent(R),decodeURIComponent(L))}}),v}function K(l){var v=new w,U=l.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function(q){var R=q.split(":"),L=R.shift().trim();if(L){var $=R.join(":").trim();v.append(L,$)}}),v}m.call(d.prototype);function G(l,v){v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in v?v.statusText:"OK",this.headers=new w(v.headers),this.url=v.url||"",this._initBody(l)}m.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 l=new G(null,{status:0,statusText:""});return l.type="error",l};var J=[301,302,303,307,308];G.redirect=function(l,v){if(J.indexOf(v)===-1)throw new RangeError("Invalid status code");return new G(null,{status:v,headers:{location:l}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(v,U){this.message=v,this.name=U;var q=Error(v);this.stack=q.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function X(l,v){return new Promise(function(U,q){var R=new d(l,v);if(R.signal&&R.signal.aborted)return q(new c.DOMException("Aborted","AbortError"));var L=new XMLHttpRequest;function $(){L.abort()}L.onload=function(){var B={status:L.status,statusText:L.statusText,headers:K(L.getAllResponseHeaders()||"")};B.url="responseURL"in L?L.responseURL:B.headers.get("X-Request-URL");var ee="response"in L?L.response:L.responseText;U(new G(ee,B))},L.onerror=function(){q(new TypeError("Network request failed"))},L.ontimeout=function(){q(new TypeError("Network request failed"))},L.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},L.open(R.method,R.url,!0),R.credentials==="include"?L.withCredentials=!0:R.credentials==="omit"&&(L.withCredentials=!1),"responseType"in L&&h.blob&&(L.responseType="blob"),R.headers.forEach(function(B,ee){L.setRequestHeader(ee,B)}),R.signal&&(R.signal.addEventListener("abort",$),L.onreadystatechange=function(){L.readyState===4&&R.signal.removeEventListener("abort",$)}),L.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=w,s.Request=d,s.Response=G),c.Headers=w,c.Request=d,c.Response=G,c.fetch=X,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e})(Ni,Ni.exports);var Zn=Ya(Ni.exports);function Li(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 Er(t){return typeof t=="string"?t:JSON.stringify(t)}const Qn={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},es=10;class gc{constructor(e){if(this.url=e,this.events=new _r.EventEmitter,this.isAvailable=!1,this.registering=!1,!Yn(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 i=Er(e),s=await(await Zn(this.url,Object.assign(Object.assign({},Qn),{body:i}))).json();this.onPayload({data:s})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!Yn(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((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{const r=Er({id:1,jsonrpc:"2.0",method:"test",params:[]});await Zn(e,Object.assign(Object.assign({},Qn),{body:r})),this.onOpen()}catch(r){const i=this.parseError(r);throw this.events.emit("register_error",i),this.onClose(),i}}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"?Li(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=wr(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Hn(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>es&&this.events.setMaxListeners(es)}}var Ri={},Yr={},re={},ts={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(h,u){var f=h>>>16&65535,g=h&65535,D=u>>>16&65535,C=u&65535;return g*C+(f*C+g*D<<16>>>0)|0}t.mul=Math.imul||e;function r(h,u){return h+u|0}t.add=r;function i(h,u){return h-u|0}t.sub=i;function n(h,u){return h<<u|h>>>32-u}t.rotl=n;function s(h,u){return h<<32-u|h>>>u}t.rotr=s;function c(h){return typeof h=="number"&&isFinite(h)&&Math.floor(h)===h}t.isInteger=Number.isInteger||c,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(h){return t.isInteger(h)&&h>=-t.MAX_SAFE_INTEGER&&h<=t.MAX_SAFE_INTEGER}})(ts),Object.defineProperty(re,"__esModule",{value:!0});var rs=ts;function yc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=yc;function vc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=vc;function _c(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=_c;function bc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=bc;function is(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=is,re.writeInt16BE=is;function ns(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=ns,re.writeInt16LE=ns;function Pi(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Pi;function Fi(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=Fi;function Ui(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Ui;function Mi(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=Mi;function Jr(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=Jr,re.writeInt32BE=Jr;function Xr(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=Xr,re.writeInt32LE=Xr;function mc(t,e){e===void 0&&(e=0);var r=Pi(t,e),i=Pi(t,e+4);return r*4294967296+i-(i>>31)*4294967296}re.readInt64BE=mc;function wc(t,e){e===void 0&&(e=0);var r=Fi(t,e),i=Fi(t,e+4);return r*4294967296+i}re.readUint64BE=wc;function Ec(t,e){e===void 0&&(e=0);var r=Ui(t,e),i=Ui(t,e+4);return i*4294967296+r-(r>>31)*4294967296}re.readInt64LE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=Mi(t,e),i=Mi(t,e+4);return i*4294967296+r}re.readUint64LE=Dc;function ss(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Jr(t/4294967296>>>0,e,r),Jr(t>>>0,e,r+4),e}re.writeUint64BE=ss,re.writeInt64BE=ss;function os(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Xr(t>>>0,e,r),Xr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=os,re.writeInt64LE=os;function Sc(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 i=0,n=1,s=t/8+r-1;s>=r;s--)i+=e[s]*n,n*=256;return i}re.readUintBE=Sc;function xc(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 i=0,n=1,s=r;s<r+t/8;s++)i+=e[s]*n,n*=256;return i}re.readUintLE=xc;function Oc(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!rs.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=t/8+i-1;s>=i;s--)r[s]=e/n&255,n*=256;return r}re.writeUintBE=Oc;function Ic(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!rs.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+t/8;s++)r[s]=e/n&255,n*=256;return r}re.writeUintLE=Ic;function Ac(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Ac;function Tc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Tc;function Cc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Cc;function Nc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Nc;function Lc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t),e}re.writeFloat32BE=Lc;function Rc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t,!0),e}re.writeFloat32LE=Rc;function Pc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t),e}re.writeFloat64BE=Pc;function Fc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t,!0),e}re.writeFloat64LE=Fc;var ct={};Object.defineProperty(ct,"__esModule",{value:!0});function Uc(t){for(var e=0;e<t.length;e++)t[e]=0;return t}ct.wipe=Uc,Object.defineProperty(Yr,"__esModule",{value:!0});var ot=re,ji=ct,Mc=20;function jc(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,c=1797285236,h=r[3]<<24|r[2]<<16|r[1]<<8|r[0],u=r[7]<<24|r[6]<<16|r[5]<<8|r[4],f=r[11]<<24|r[10]<<16|r[9]<<8|r[8],g=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],C=r[23]<<24|r[22]<<16|r[21]<<8|r[20],S=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],N=e[7]<<24|e[6]<<16|e[5]<<8|e[4],M=e[11]<<24|e[10]<<16|e[9]<<8|e[8],E=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=i,y=n,m=s,b=c,o=h,d=u,j=f,K=g,G=D,J=C,X=S,l=w,v=P,U=N,q=M,R=E,L=0;L<Mc;L+=2)I=I+o|0,v^=I,v=v>>>32-16|v<<16,G=G+v|0,o^=G,o=o>>>32-12|o<<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,m=m+j|0,q^=m,q=q>>>32-16|q<<16,X=X+q|0,j^=X,j=j>>>32-12|j<<12,b=b+K|0,R^=b,R=R>>>32-16|R<<16,l=l+R|0,K^=l,K=K>>>32-12|K<<12,m=m+j|0,q^=m,q=q>>>32-8|q<<8,X=X+q|0,j^=X,j=j>>>32-7|j<<7,b=b+K|0,R^=b,R=R>>>32-8|R<<8,l=l+R|0,K^=l,K=K>>>32-7|K<<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,I=I+o|0,v^=I,v=v>>>32-8|v<<8,G=G+v|0,o^=G,o=o>>>32-7|o<<7,I=I+d|0,R^=I,R=R>>>32-16|R<<16,X=X+R|0,d^=X,d=d>>>32-12|d<<12,y=y+j|0,v^=y,v=v>>>32-16|v<<16,l=l+v|0,j^=l,j=j>>>32-12|j<<12,m=m+K|0,U^=m,U=U>>>32-16|U<<16,G=G+U|0,K^=G,K=K>>>32-12|K<<12,b=b+o|0,q^=b,q=q>>>32-16|q<<16,J=J+q|0,o^=J,o=o>>>32-12|o<<12,m=m+K|0,U^=m,U=U>>>32-8|U<<8,G=G+U|0,K^=G,K=K>>>32-7|K<<7,b=b+o|0,q^=b,q=q>>>32-8|q<<8,J=J+q|0,o^=J,o=o>>>32-7|o<<7,y=y+j|0,v^=y,v=v>>>32-8|v<<8,l=l+v|0,j^=l,j=j>>>32-7|j<<7,I=I+d|0,R^=I,R=R>>>32-8|R<<8,X=X+R|0,d^=X,d=d>>>32-7|d<<7;ot.writeUint32LE(I+i|0,t,0),ot.writeUint32LE(y+n|0,t,4),ot.writeUint32LE(m+s|0,t,8),ot.writeUint32LE(b+c|0,t,12),ot.writeUint32LE(o+h|0,t,16),ot.writeUint32LE(d+u|0,t,20),ot.writeUint32LE(j+f|0,t,24),ot.writeUint32LE(K+g|0,t,28),ot.writeUint32LE(G+D|0,t,32),ot.writeUint32LE(J+C|0,t,36),ot.writeUint32LE(X+S|0,t,40),ot.writeUint32LE(l+w|0,t,44),ot.writeUint32LE(v+P|0,t,48),ot.writeUint32LE(U+N|0,t,52),ot.writeUint32LE(q+M|0,t,56),ot.writeUint32LE(R+E|0,t,60)}function as(t,e,r,i,n){if(n===void 0&&(n=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,c;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),c=s.length-e.length,s.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,c=n}for(var h=new Uint8Array(64),u=0;u<r.length;u+=64){jc(h,s,t);for(var f=u;f<u+64&&f<r.length;f++)i[f]=r[f]^h[f-u];Bc(s,0,c)}return ji.wipe(h),n===0&&ji.wipe(s),i}Yr.streamXOR=as;function $c(t,e,r,i){return i===void 0&&(i=0),ji.wipe(r),as(t,e,r,r,i)}Yr.stream=$c;function Bc(t,e,r){for(var i=1;r--;)i=i+(t[e]&255)|0,t[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var cs={},qt={};Object.defineProperty(qt,"__esModule",{value:!0});function zc(t,e,r){return~(t-1)&e|t-1&r}qt.select=zc;function Hc(t,e){return(t|0)-(e|0)-1>>>31&1}qt.lessOrEqual=Hc;function hs(t,e){if(t.length!==e.length)return 0;for(var r=0,i=0;i<t.length;i++)r|=t[i]^e[i];return 1&r-1>>>8}qt.compare=hs;function Kc(t,e){return t.length===0||e.length===0?!1:hs(t,e)!==0}qt.equal=Kc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=qt,r=ct;t.DIGEST_LENGTH=16;var i=function(){function c(h){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 u=h[0]|h[1]<<8;this._r[0]=u&8191;var f=h[2]|h[3]<<8;this._r[1]=(u>>>13|f<<3)&8191;var g=h[4]|h[5]<<8;this._r[2]=(f>>>10|g<<6)&7939;var D=h[6]|h[7]<<8;this._r[3]=(g>>>7|D<<9)&8191;var C=h[8]|h[9]<<8;this._r[4]=(D>>>4|C<<12)&255,this._r[5]=C>>>1&8190;var S=h[10]|h[11]<<8;this._r[6]=(C>>>14|S<<2)&8191;var w=h[12]|h[13]<<8;this._r[7]=(S>>>11|w<<5)&8065;var P=h[14]|h[15]<<8;this._r[8]=(w>>>8|P<<8)&8191,this._r[9]=P>>>5&127,this._pad[0]=h[16]|h[17]<<8,this._pad[1]=h[18]|h[19]<<8,this._pad[2]=h[20]|h[21]<<8,this._pad[3]=h[22]|h[23]<<8,this._pad[4]=h[24]|h[25]<<8,this._pad[5]=h[26]|h[27]<<8,this._pad[6]=h[28]|h[29]<<8,this._pad[7]=h[30]|h[31]<<8}return c.prototype._blocks=function(h,u,f){for(var g=this._fin?0:2048,D=this._h[0],C=this._h[1],S=this._h[2],w=this._h[3],P=this._h[4],N=this._h[5],M=this._h[6],E=this._h[7],I=this._h[8],y=this._h[9],m=this._r[0],b=this._r[1],o=this._r[2],d=this._r[3],j=this._r[4],K=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],l=this._r[9];f>=16;){var v=h[u+0]|h[u+1]<<8;D+=v&8191;var U=h[u+2]|h[u+3]<<8;C+=(v>>>13|U<<3)&8191;var q=h[u+4]|h[u+5]<<8;S+=(U>>>10|q<<6)&8191;var R=h[u+6]|h[u+7]<<8;w+=(q>>>7|R<<9)&8191;var L=h[u+8]|h[u+9]<<8;P+=(R>>>4|L<<12)&8191,N+=L>>>1&8191;var $=h[u+10]|h[u+11]<<8;M+=(L>>>14|$<<2)&8191;var B=h[u+12]|h[u+13]<<8;E+=($>>>11|B<<5)&8191;var ee=h[u+14]|h[u+15]<<8;I+=(B>>>8|ee<<8)&8191,y+=ee>>>5|g;var z=0,te=z;te+=D*m,te+=C*(5*l),te+=S*(5*X),te+=w*(5*J),te+=P*(5*G),z=te>>>13,te&=8191,te+=N*(5*K),te+=M*(5*j),te+=E*(5*d),te+=I*(5*o),te+=y*(5*b),z+=te>>>13,te&=8191;var Y=z;Y+=D*b,Y+=C*m,Y+=S*(5*l),Y+=w*(5*X),Y+=P*(5*J),z=Y>>>13,Y&=8191,Y+=N*(5*G),Y+=M*(5*K),Y+=E*(5*j),Y+=I*(5*d),Y+=y*(5*o),z+=Y>>>13,Y&=8191;var ce=z;ce+=D*o,ce+=C*b,ce+=S*m,ce+=w*(5*l),ce+=P*(5*X),z=ce>>>13,ce&=8191,ce+=N*(5*J),ce+=M*(5*G),ce+=E*(5*K),ce+=I*(5*j),ce+=y*(5*d),z+=ce>>>13,ce&=8191;var T=z;T+=D*d,T+=C*o,T+=S*b,T+=w*m,T+=P*(5*l),z=T>>>13,T&=8191,T+=N*(5*X),T+=M*(5*J),T+=E*(5*G),T+=I*(5*K),T+=y*(5*j),z+=T>>>13,T&=8191;var A=z;A+=D*j,A+=C*d,A+=S*o,A+=w*b,A+=P*m,z=A>>>13,A&=8191,A+=N*(5*l),A+=M*(5*X),A+=E*(5*J),A+=I*(5*G),A+=y*(5*K),z+=A>>>13,A&=8191;var x=z;x+=D*K,x+=C*j,x+=S*d,x+=w*o,x+=P*b,z=x>>>13,x&=8191,x+=N*m,x+=M*(5*l),x+=E*(5*X),x+=I*(5*J),x+=y*(5*G),z+=x>>>13,x&=8191;var a=z;a+=D*G,a+=C*K,a+=S*j,a+=w*d,a+=P*o,z=a>>>13,a&=8191,a+=N*b,a+=M*m,a+=E*(5*l),a+=I*(5*X),a+=y*(5*J),z+=a>>>13,a&=8191;var _=z;_+=D*J,_+=C*G,_+=S*K,_+=w*j,_+=P*d,z=_>>>13,_&=8191,_+=N*o,_+=M*b,_+=E*m,_+=I*(5*l),_+=y*(5*X),z+=_>>>13,_&=8191;var H=z;H+=D*X,H+=C*J,H+=S*G,H+=w*K,H+=P*j,z=H>>>13,H&=8191,H+=N*d,H+=M*o,H+=E*b,H+=I*m,H+=y*(5*l),z+=H>>>13,H&=8191;var W=z;W+=D*l,W+=C*X,W+=S*J,W+=w*G,W+=P*K,z=W>>>13,W&=8191,W+=N*j,W+=M*d,W+=E*o,W+=I*b,W+=y*m,z+=W>>>13,W&=8191,z=(z<<2)+z|0,z=z+te|0,te=z&8191,z=z>>>13,Y+=z,D=te,C=Y,S=ce,w=T,P=A,N=x,M=a,E=_,I=H,y=W,u+=16,f-=16}this._h[0]=D,this._h[1]=C,this._h[2]=S,this._h[3]=w,this._h[4]=P,this._h[5]=N,this._h[6]=M,this._h[7]=E,this._h[8]=I,this._h[9]=y},c.prototype.finish=function(h,u){u===void 0&&(u=0);var f=new Uint16Array(10),g,D,C,S;if(this._leftover){for(S=this._leftover,this._buffer[S++]=1;S<16;S++)this._buffer[S]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,S=2;S<10;S++)this._h[S]+=g,g=this._h[S]>>>13,this._h[S]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,f[0]=this._h[0]+5,g=f[0]>>>13,f[0]&=8191,S=1;S<10;S++)f[S]=this._h[S]+g,g=f[S]>>>13,f[S]&=8191;for(f[9]-=1<<13,D=(g^1)-1,S=0;S<10;S++)f[S]&=D;for(D=~D,S=0;S<10;S++)this._h[S]=this._h[S]&D|f[S];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,C=this._h[0]+this._pad[0],this._h[0]=C&65535,S=1;S<8;S++)C=(this._h[S]+this._pad[S]|0)+(C>>>16)|0,this._h[S]=C&65535;return h[u+0]=this._h[0]>>>0,h[u+1]=this._h[0]>>>8,h[u+2]=this._h[1]>>>0,h[u+3]=this._h[1]>>>8,h[u+4]=this._h[2]>>>0,h[u+5]=this._h[2]>>>8,h[u+6]=this._h[3]>>>0,h[u+7]=this._h[3]>>>8,h[u+8]=this._h[4]>>>0,h[u+9]=this._h[4]>>>8,h[u+10]=this._h[5]>>>0,h[u+11]=this._h[5]>>>8,h[u+12]=this._h[6]>>>0,h[u+13]=this._h[6]>>>8,h[u+14]=this._h[7]>>>0,h[u+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(h){var u=0,f=h.length,g;if(this._leftover){g=16-this._leftover,g>f&&(g=f);for(var D=0;D<g;D++)this._buffer[this._leftover+D]=h[u+D];if(f-=g,u+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(g=f-f%16,this._blocks(h,u,g),u+=g,f-=g),f){for(var D=0;D<f;D++)this._buffer[this._leftover+D]=h[u+D];this._leftover+=f}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var h=new Uint8Array(16);return this.finish(h),h},c.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},c}();t.Poly1305=i;function n(c,h){var u=new i(c);u.update(h);var f=u.digest();return u.clean(),f}t.oneTimeAuth=n;function s(c,h){return c.length!==t.DIGEST_LENGTH||h.length!==t.DIGEST_LENGTH?!1:e.equal(c,h)}t.equal=s}(cs),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Yr,r=cs,i=ct,n=re,s=qt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),h=function(){function u(f){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,f.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return u.prototype.seal=function(f,g,D,C){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var S=new Uint8Array(16);S.set(f,S.length-f.length);var w=new Uint8Array(32);e.stream(this._key,S,w,4);var P=g.length+this.tagLength,N;if(C){if(C.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");N=C}else N=new Uint8Array(P);return e.streamXOR(this._key,S,g,N,4),this._authenticate(N.subarray(N.length-this.tagLength,N.length),w,N.subarray(0,N.length-this.tagLength),D),i.wipe(S),N},u.prototype.open=function(f,g,D,C){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var S=new Uint8Array(16);S.set(f,S.length-f.length);var w=new Uint8Array(32);e.stream(this._key,S,w,4);var P=new Uint8Array(this.tagLength);if(this._authenticate(P,w,g.subarray(0,g.length-this.tagLength),D),!s.equal(P,g.subarray(g.length-this.tagLength,g.length)))return null;var N=g.length-this.tagLength,M;if(C){if(C.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");M=C}else M=new Uint8Array(N);return e.streamXOR(this._key,S,g.subarray(0,g.length-this.tagLength),M,4),i.wipe(S),M},u.prototype.clean=function(){return i.wipe(this._key),this},u.prototype._authenticate=function(f,g,D,C){var S=new r.Poly1305(g);C&&(S.update(C),C.length%16>0&&S.update(c.subarray(C.length%16))),S.update(D),D.length%16>0&&S.update(c.subarray(D.length%16));var w=new Uint8Array(8);C&&n.writeUint64LE(C.length,w),S.update(w),n.writeUint64LE(D.length,w),S.update(w);for(var P=S.digest(),N=0;N<P.length;N++)f[N]=P[N];S.clean(),i.wipe(P),i.wipe(w)},u}();t.ChaCha20Poly1305=h}(Ri);var us={},Dr={},$i={};Object.defineProperty($i,"__esModule",{value:!0});function qc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}$i.isSerializableHash=qc,Object.defineProperty(Dr,"__esModule",{value:!0});var Ot=$i,Vc=qt,Gc=ct,fs=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 i=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(i).clean():i.set(r);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),Ot.isSerializableHash(this._inner)&&Ot.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Gc.wipe(i)}return t.prototype.reset=function(){if(!Ot.isSerializableHash(this._inner)||!Ot.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(){Ot.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ot.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(!Ot.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(!Ot.isSerializableHash(this._inner)||!Ot.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(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();Dr.HMAC=fs;function Wc(t,e,r){var i=new fs(t,e);i.update(r);var n=i.digest();return i.clean(),n}Dr.hmac=Wc,Dr.equal=Vc.equal,Object.defineProperty(us,"__esModule",{value:!0});var ls=Dr,ds=ct,kc=function(){function t(e,r,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ls.hmac(this._hash,i,r);this._hmac=new ls.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),i=0;i<r.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[i]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),ds.wipe(this._buffer),ds.wipe(this._counter),this._bufpos=0},t}(),Yc=us.HKDF=kc,Sr={},Bi={},zi={};Object.defineProperty(zi,"__esModule",{value:!0});var ps=65536,Jc=function(){function t(){this.isAvailable=!1,this.isInstantiated=!1;var e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var r=new Uint8Array(e),i=0;i<r.length;i+=ps)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,ps)));return r},t}();zi.BrowserRandomSource=Jc;function gs(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 Hi={},Xc={},Zc=Object.freeze({__proto__:null,default:Xc}),ys=xi(Zc);Object.defineProperty(Hi,"__esModule",{value:!0});var Qc=ct,eh=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof gs<"u"){var e=ys;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var i=new Uint8Array(e),n=0;n<i.length;n++)i[n]=r[n];return Qc.wipe(r),i},t}();Hi.NodeRandomSource=eh,Object.defineProperty(Bi,"__esModule",{value:!0});var th=zi,rh=Hi,ih=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new th.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new rh.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}return t.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},t}();Bi.SystemRandomSource=ih,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Bi,r=re,i=ct;t.defaultRandomSource=new e.SystemRandomSource;function n(f,g){return g===void 0&&(g=t.defaultRandomSource),g.randomBytes(f)}t.randomBytes=n;function s(f){f===void 0&&(f=t.defaultRandomSource);var g=n(4,f),D=r.readUint32LE(g);return i.wipe(g),D}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(f,g,D){if(g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource),g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");for(var C="",S=g.length,w=256-256%S;f>0;){for(var P=n(Math.ceil(f*256/w),D),N=0;N<P.length&&f>0;N++){var M=P[N];M<w&&(C+=g.charAt(M%S),f--)}i.wipe(P)}return C}t.randomString=h;function u(f,g,D){g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource);var C=Math.ceil(f/(Math.log(g.length)/Math.LN2));return h(C,g,D)}t.randomStringForEntropy=u}(Sr);var Zr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=ct;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var i=function(){function h(){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 h.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},h.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},h.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},h.prototype.update=function(u,f){if(f===void 0&&(f=u.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=u[g++],f--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(g=s(this._temp,this._state,u,g,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=u[g++],f--;return this},h.prototype.finish=function(u){if(!this._finished){var f=this._bytesHashed,g=this._bufferLength,D=f/536870912|0,C=f<<3,S=f%64<56?64:128;this._buffer[g]=128;for(var w=g+1;w<S-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,S-8),e.writeUint32BE(C,this._buffer,S-4),s(this._temp,this._state,this._buffer,0,S),this._finished=!0}for(var w=0;w<this.digestLength/4;w++)e.writeUint32BE(this._state[w],u,w*4);return this},h.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},h.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}},h.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(u){r.wipe(u.state),u.buffer&&r.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},h}();t.SHA256=i;var n=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(h,u,f,g,D){for(;D>=64;){for(var C=u[0],S=u[1],w=u[2],P=u[3],N=u[4],M=u[5],E=u[6],I=u[7],y=0;y<16;y++){var m=g+y*4;h[y]=e.readUint32BE(f,m)}for(var y=16;y<64;y++){var b=h[y-2],o=(b>>>17|b<<32-17)^(b>>>19|b<<32-19)^b>>>10;b=h[y-15];var d=(b>>>7|b<<32-7)^(b>>>18|b<<32-18)^b>>>3;h[y]=(o+h[y-7]|0)+(d+h[y-16]|0)}for(var y=0;y<64;y++){var o=(((N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7))+(N&M^~N&E)|0)+(I+(n[y]+h[y]|0)|0)|0,d=((C>>>2|C<<32-2)^(C>>>13|C<<32-13)^(C>>>22|C<<32-22))+(C&S^C&w^S&w)|0;I=E,E=M,M=N,N=P+o|0,P=w,w=S,S=C,C=o+d|0}u[0]+=C,u[1]+=S,u[2]+=w,u[3]+=P,u[4]+=N,u[5]+=M,u[6]+=E,u[7]+=I,g+=64,D-=64}return g}function c(h){var u=new i;u.update(h);var f=u.digest();return u.clean(),f}t.hash=c})(Zr);var Ki={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Sr,r=ct;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(y){var m=new Float64Array(16);if(y)for(var b=0;b<y.length;b++)m[b]=y[b];return m}var n=new Uint8Array(32);n[0]=9;var s=i([56129,1]);function c(y){for(var m=1,b=0;b<16;b++){var o=y[b]+m+65535;m=Math.floor(o/65536),y[b]=o-m*65536}y[0]+=m-1+37*(m-1)}function h(y,m,b){for(var o=~(b-1),d=0;d<16;d++){var j=o&(y[d]^m[d]);y[d]^=j,m[d]^=j}}function u(y,m){for(var b=i(),o=i(),d=0;d<16;d++)o[d]=m[d];c(o),c(o),c(o);for(var j=0;j<2;j++){b[0]=o[0]-65517;for(var d=1;d<15;d++)b[d]=o[d]-65535-(b[d-1]>>16&1),b[d-1]&=65535;b[15]=o[15]-32767-(b[14]>>16&1);var K=b[15]>>16&1;b[14]&=65535,h(o,b,1-K)}for(var d=0;d<16;d++)y[2*d]=o[d]&255,y[2*d+1]=o[d]>>8}function f(y,m){for(var b=0;b<16;b++)y[b]=m[2*b]+(m[2*b+1]<<8);y[15]&=32767}function g(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]+b[o]}function D(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]-b[o]}function C(y,m,b){var o,d,j=0,K=0,G=0,J=0,X=0,l=0,v=0,U=0,q=0,R=0,L=0,$=0,B=0,ee=0,z=0,te=0,Y=0,ce=0,T=0,A=0,x=0,a=0,_=0,H=0,W=0,le=0,_e=0,pe=0,we=0,Fe=0,Ce=0,ve=b[0],ge=b[1],de=b[2],ue=b[3],he=b[4],ae=b[5],oe=b[6],ie=b[7],fe=b[8],ye=b[9],ne=b[10],be=b[11],me=b[12],De=b[13],Se=b[14],Ee=b[15];o=m[0],j+=o*ve,K+=o*ge,G+=o*de,J+=o*ue,X+=o*he,l+=o*ae,v+=o*oe,U+=o*ie,q+=o*fe,R+=o*ye,L+=o*ne,$+=o*be,B+=o*me,ee+=o*De,z+=o*Se,te+=o*Ee,o=m[1],K+=o*ve,G+=o*ge,J+=o*de,X+=o*ue,l+=o*he,v+=o*ae,U+=o*oe,q+=o*ie,R+=o*fe,L+=o*ye,$+=o*ne,B+=o*be,ee+=o*me,z+=o*De,te+=o*Se,Y+=o*Ee,o=m[2],G+=o*ve,J+=o*ge,X+=o*de,l+=o*ue,v+=o*he,U+=o*ae,q+=o*oe,R+=o*ie,L+=o*fe,$+=o*ye,B+=o*ne,ee+=o*be,z+=o*me,te+=o*De,Y+=o*Se,ce+=o*Ee,o=m[3],J+=o*ve,X+=o*ge,l+=o*de,v+=o*ue,U+=o*he,q+=o*ae,R+=o*oe,L+=o*ie,$+=o*fe,B+=o*ye,ee+=o*ne,z+=o*be,te+=o*me,Y+=o*De,ce+=o*Se,T+=o*Ee,o=m[4],X+=o*ve,l+=o*ge,v+=o*de,U+=o*ue,q+=o*he,R+=o*ae,L+=o*oe,$+=o*ie,B+=o*fe,ee+=o*ye,z+=o*ne,te+=o*be,Y+=o*me,ce+=o*De,T+=o*Se,A+=o*Ee,o=m[5],l+=o*ve,v+=o*ge,U+=o*de,q+=o*ue,R+=o*he,L+=o*ae,$+=o*oe,B+=o*ie,ee+=o*fe,z+=o*ye,te+=o*ne,Y+=o*be,ce+=o*me,T+=o*De,A+=o*Se,x+=o*Ee,o=m[6],v+=o*ve,U+=o*ge,q+=o*de,R+=o*ue,L+=o*he,$+=o*ae,B+=o*oe,ee+=o*ie,z+=o*fe,te+=o*ye,Y+=o*ne,ce+=o*be,T+=o*me,A+=o*De,x+=o*Se,a+=o*Ee,o=m[7],U+=o*ve,q+=o*ge,R+=o*de,L+=o*ue,$+=o*he,B+=o*ae,ee+=o*oe,z+=o*ie,te+=o*fe,Y+=o*ye,ce+=o*ne,T+=o*be,A+=o*me,x+=o*De,a+=o*Se,_+=o*Ee,o=m[8],q+=o*ve,R+=o*ge,L+=o*de,$+=o*ue,B+=o*he,ee+=o*ae,z+=o*oe,te+=o*ie,Y+=o*fe,ce+=o*ye,T+=o*ne,A+=o*be,x+=o*me,a+=o*De,_+=o*Se,H+=o*Ee,o=m[9],R+=o*ve,L+=o*ge,$+=o*de,B+=o*ue,ee+=o*he,z+=o*ae,te+=o*oe,Y+=o*ie,ce+=o*fe,T+=o*ye,A+=o*ne,x+=o*be,a+=o*me,_+=o*De,H+=o*Se,W+=o*Ee,o=m[10],L+=o*ve,$+=o*ge,B+=o*de,ee+=o*ue,z+=o*he,te+=o*ae,Y+=o*oe,ce+=o*ie,T+=o*fe,A+=o*ye,x+=o*ne,a+=o*be,_+=o*me,H+=o*De,W+=o*Se,le+=o*Ee,o=m[11],$+=o*ve,B+=o*ge,ee+=o*de,z+=o*ue,te+=o*he,Y+=o*ae,ce+=o*oe,T+=o*ie,A+=o*fe,x+=o*ye,a+=o*ne,_+=o*be,H+=o*me,W+=o*De,le+=o*Se,_e+=o*Ee,o=m[12],B+=o*ve,ee+=o*ge,z+=o*de,te+=o*ue,Y+=o*he,ce+=o*ae,T+=o*oe,A+=o*ie,x+=o*fe,a+=o*ye,_+=o*ne,H+=o*be,W+=o*me,le+=o*De,_e+=o*Se,pe+=o*Ee,o=m[13],ee+=o*ve,z+=o*ge,te+=o*de,Y+=o*ue,ce+=o*he,T+=o*ae,A+=o*oe,x+=o*ie,a+=o*fe,_+=o*ye,H+=o*ne,W+=o*be,le+=o*me,_e+=o*De,pe+=o*Se,we+=o*Ee,o=m[14],z+=o*ve,te+=o*ge,Y+=o*de,ce+=o*ue,T+=o*he,A+=o*ae,x+=o*oe,a+=o*ie,_+=o*fe,H+=o*ye,W+=o*ne,le+=o*be,_e+=o*me,pe+=o*De,we+=o*Se,Fe+=o*Ee,o=m[15],te+=o*ve,Y+=o*ge,ce+=o*de,T+=o*ue,A+=o*he,x+=o*ae,a+=o*oe,_+=o*ie,H+=o*fe,W+=o*ye,le+=o*ne,_e+=o*be,pe+=o*me,we+=o*De,Fe+=o*Se,Ce+=o*Ee,j+=38*Y,K+=38*ce,G+=38*T,J+=38*A,X+=38*x,l+=38*a,v+=38*_,U+=38*H,q+=38*W,R+=38*le,L+=38*_e,$+=38*pe,B+=38*we,ee+=38*Fe,z+=38*Ce,d=1,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=G+d+65535,d=Math.floor(o/65536),G=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=l+d+65535,d=Math.floor(o/65536),l=o-d*65536,o=v+d+65535,d=Math.floor(o/65536),v=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=R+d+65535,d=Math.floor(o/65536),R=o-d*65536,o=L+d+65535,d=Math.floor(o/65536),L=o-d*65536,o=$+d+65535,d=Math.floor(o/65536),$=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,o=z+d+65535,d=Math.floor(o/65536),z=o-d*65536,o=te+d+65535,d=Math.floor(o/65536),te=o-d*65536,j+=d-1+37*(d-1),d=1,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=G+d+65535,d=Math.floor(o/65536),G=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=l+d+65535,d=Math.floor(o/65536),l=o-d*65536,o=v+d+65535,d=Math.floor(o/65536),v=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=R+d+65535,d=Math.floor(o/65536),R=o-d*65536,o=L+d+65535,d=Math.floor(o/65536),L=o-d*65536,o=$+d+65535,d=Math.floor(o/65536),$=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,o=z+d+65535,d=Math.floor(o/65536),z=o-d*65536,o=te+d+65535,d=Math.floor(o/65536),te=o-d*65536,j+=d-1+37*(d-1),y[0]=j,y[1]=K,y[2]=G,y[3]=J,y[4]=X,y[5]=l,y[6]=v,y[7]=U,y[8]=q,y[9]=R,y[10]=L,y[11]=$,y[12]=B,y[13]=ee,y[14]=z,y[15]=te}function S(y,m){C(y,m,m)}function w(y,m){for(var b=i(),o=0;o<16;o++)b[o]=m[o];for(var o=253;o>=0;o--)S(b,b),o!==2&&o!==4&&C(b,b,m);for(var o=0;o<16;o++)y[o]=b[o]}function P(y,m){for(var b=new Uint8Array(32),o=new Float64Array(80),d=i(),j=i(),K=i(),G=i(),J=i(),X=i(),l=0;l<31;l++)b[l]=y[l];b[31]=y[31]&127|64,b[0]&=248,f(o,m);for(var l=0;l<16;l++)j[l]=o[l];d[0]=G[0]=1;for(var l=254;l>=0;--l){var v=b[l>>>3]>>>(l&7)&1;h(d,j,v),h(K,G,v),g(J,d,K),D(d,d,K),g(K,j,G),D(j,j,G),S(G,J),S(X,d),C(d,K,d),C(K,j,J),g(J,d,K),D(d,d,K),S(j,d),D(K,G,X),C(d,K,s),g(d,d,G),C(K,K,d),C(d,G,X),C(G,j,o),S(j,J),h(d,j,v),h(K,G,v)}for(var l=0;l<16;l++)o[l+16]=d[l],o[l+32]=K[l],o[l+48]=j[l],o[l+64]=G[l];var U=o.subarray(32),q=o.subarray(16);w(U,U),C(q,q,U);var R=new Uint8Array(32);return u(R,q),R}t.scalarMult=P;function N(y){return P(y,n)}t.scalarMultBase=N;function M(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var m=new Uint8Array(y),b=N(m);return{publicKey:b,secretKey:m}}t.generateKeyPairFromSeed=M;function E(y){var m=e.randomBytes(32,y),b=M(m);return r.wipe(m),b}t.generateKeyPair=E;function I(y,m,b){if(b===void 0&&(b=!1),y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(m.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=P(y,m);if(b){for(var d=0,j=0;j<o.length;j++)d|=o[j];if(d===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=I})(Ki);function vs(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function qi(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=vs(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function nh(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=n}var h=t.length,u=t.charAt(0),f=Math.log(h)/Math.log(256),g=Math.log(256)/Math.log(h);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,N=0,M=0,E=w.length;M!==E&&w[M]===0;)M++,P++;for(var I=(E-M)*g+1>>>0,y=new Uint8Array(I);M!==E;){for(var m=w[M],b=0,o=I-1;(m!==0||b<N)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%h>>>0,m=m/h>>>0;if(m!==0)throw new Error("Non-zero carry");N=b,M++}for(var d=I-N;d!==I&&y[d]===0;)d++;for(var j=u.repeat(P);d<I;++d)j+=t.charAt(y[d]);return j}function C(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 N=0,M=0;w[P]===u;)N++,P++;for(var E=(w.length-P)*f+1>>>0,I=new Uint8Array(E);w[P];){var y=r[w.charCodeAt(P)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<M)&&b!==-1;b--,m++)y+=h*I[b]>>>0,I[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");M=m,P++}if(w[P]!==" "){for(var o=E-M;o!==E&&I[o]===0;)o++;for(var d=new Uint8Array(N+(E-o)),j=N;o!==E;)d[j++]=I[o++];return d}}}function S(w){var P=C(w);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:S}}var sh=nh,oh=sh;const _s=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")},ah=t=>new TextEncoder().encode(t),ch=t=>new TextDecoder().decode(t);class hh{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class uh{constructor(e,r,i){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=i}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 bs(this,e)}}class fh{constructor(e){this.decoders=e}or(e){return bs(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const bs=(t,e)=>new fh({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class lh{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new hh(e,r,i),this.decoder=new uh(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qr=({name:t,prefix:e,encode:r,decode:i})=>new lh(t,e,r,i),xr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=oh(r,e);return Qr({prefix:t,name:e,encode:i,decode:s=>_s(n(s))})},dh=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let h=0,u=0,f=0;for(let g=0;g<s;++g){const D=n[t[g]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|D,h+=r,h>=8&&(h-=8,c[f++]=255&u>>h)}if(h>=r||255&u<<8-h)throw new SyntaxError("Unexpected end of data");return c},ph=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,h=0;for(let u=0;u<t.length;++u)for(h=h<<8|t[u],c+=8;c>r;)c-=r,s+=e[n&h>>c];if(c&&(s+=e[n&h<<r-c]),i)for(;s.length*r&7;)s+="=";return s},rt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Qr({prefix:e,name:t,encode(n){return ph(n,i,r)},decode(n){return dh(n,i,r,t)}}),gh=Qr({prefix:"\0",name:"identity",encode:t=>ch(t),decode:t=>ah(t)});var yh=Object.freeze({__proto__:null,identity:gh});const vh=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _h=Object.freeze({__proto__:null,base2:vh});const bh=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mh=Object.freeze({__proto__:null,base8:bh});const wh=xr({prefix:"9",name:"base10",alphabet:"0123456789"});var Eh=Object.freeze({__proto__:null,base10:wh});const Dh=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sh=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var xh=Object.freeze({__proto__:null,base16:Dh,base16upper:Sh});const Oh=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ih=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ah=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Th=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ch=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Nh=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lh=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rh=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ph=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fh=Object.freeze({__proto__:null,base32:Oh,base32upper:Ih,base32pad:Ah,base32padupper:Th,base32hex:Ch,base32hexupper:Nh,base32hexpad:Lh,base32hexpadupper:Rh,base32z:Ph});const Uh=xr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mh=xr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jh=Object.freeze({__proto__:null,base36:Uh,base36upper:Mh});const $h=xr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bh=xr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zh=Object.freeze({__proto__:null,base58btc:$h,base58flickr:Bh});const Hh=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Kh=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qh=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vh=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gh=Object.freeze({__proto__:null,base64:Hh,base64pad:Kh,base64url:qh,base64urlpad:Vh});const ms=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}"),Wh=ms.reduce((t,e,r)=>(t[r]=e,t),[]),kh=ms.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Yh(t){return t.reduce((e,r)=>(e+=Wh[r],e),"")}function Jh(t){const e=[];for(const r of t){const i=kh[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Xh=Qr({prefix:"\u{1F680}",name:"base256emoji",encode:Yh,decode:Jh});var Zh=Object.freeze({__proto__:null,base256emoji:Xh}),Qh=Es,ws=128,eu=127,tu=~eu,ru=Math.pow(2,31);function Es(t,e,r){e=e||[],r=r||0;for(var i=r;t>=ru;)e[r++]=t&255|ws,t/=128;for(;t&tu;)e[r++]=t&255|ws,t>>>=7;return e[r]=t|0,Es.bytes=r-i+1,e}var iu=Vi,nu=128,Ds=127;function Vi(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw Vi.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&Ds)<<n:(c&Ds)*Math.pow(2,n),n+=7}while(c>=nu);return Vi.bytes=s-i,r}var su=Math.pow(2,7),ou=Math.pow(2,14),au=Math.pow(2,21),cu=Math.pow(2,28),hu=Math.pow(2,35),uu=Math.pow(2,42),fu=Math.pow(2,49),lu=Math.pow(2,56),du=Math.pow(2,63),pu=function(t){return t<su?1:t<ou?2:t<au?3:t<cu?4:t<hu?5:t<uu?6:t<fu?7:t<lu?8:t<du?9:10},gu={encode:Qh,decode:iu,encodingLength:pu},Ss=gu;const xs=(t,e,r=0)=>(Ss.encode(t,e,r),e),Os=t=>Ss.encodingLength(t),Gi=(t,e)=>{const r=e.byteLength,i=Os(t),n=i+Os(r),s=new Uint8Array(n+r);return xs(t,s,0),xs(r,s,i),s.set(e,n),new yu(t,r,e,s)};class yu{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Is=({name:t,code:e,encode:r})=>new vu(t,e,r);class vu{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Gi(this.code,r):r.then(i=>Gi(this.code,i))}else throw Error("Unknown type, must be binary type")}}const As=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),_u=Is({name:"sha2-256",code:18,encode:As("SHA-256")}),bu=Is({name:"sha2-512",code:19,encode:As("SHA-512")});var mu=Object.freeze({__proto__:null,sha256:_u,sha512:bu});const Ts=0,wu="identity",Cs=_s;var Eu=Object.freeze({__proto__:null,identity:{code:Ts,name:wu,encode:Cs,digest:t=>Gi(Ts,Cs(t))}});new TextEncoder,new TextDecoder;const Ns={...yh,..._h,...mh,...Eh,...xh,...Fh,...jh,...zh,...Gh,...Zh};({...mu,...Eu});function Ls(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Rs=Ls("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Wi=Ls("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=vs(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ps={utf8:Rs,"utf-8":Rs,hex:Ns.base16,latin1:Wi,ascii:Wi,binary:Wi,...Ns};function ft(t,e="utf8"){const r=Ps[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 lt(t,e="utf8"){const r=Ps[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 Fs=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},Du=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Su=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),xu=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),Ou=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Iu=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Au=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Tu=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Us=3,Cu=[["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",Au]],Ms=[["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 Nu(t){return t?js(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Iu:typeof navigator<"u"?js(navigator.userAgent):Pu()}function Lu(t){return t!==""&&Cu.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function js(t){var e=Lu(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Ou;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Us&&(n=Fs(Fs([],n,!0),Fu(Us-n.length),!0)):n=[];var s=n.join("."),c=Ru(t),h=Tu.exec(t);return h&&h[1]?new xu(r,s,c,h[1]):new Du(r,s,c)}function Ru(t){for(var e=0,r=Ms.length;e<r;e++){var i=Ms[e],n=i[0],s=i[1],c=s.exec(t);if(c)return n}return null}function Pu(){var t=typeof process<"u"&&process.version;return t?new Su(process.version.slice(1)):null}function Fu(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Q={},$s={},ei={};Object.defineProperty(ei,"__esModule",{value:!0}),ei.delay=void 0;function Uu(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}ei.delay=Uu;var cr={},ki={},hr={};Object.defineProperty(hr,"__esModule",{value:!0}),hr.ONE_THOUSAND=hr.ONE_HUNDRED=void 0,hr.ONE_HUNDRED=100,hr.ONE_THOUSAND=1e3;var Bs={};(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})(Bs),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(hr,t),r(Bs,t)}(ki),Object.defineProperty(cr,"__esModule",{value:!0}),cr.fromMiliseconds=cr.toMiliseconds=void 0;const zs=ki;function Mu(t){return t*zs.ONE_THOUSAND}cr.toMiliseconds=Mu;function ju(t){return Math.floor(t/zs.ONE_THOUSAND)}cr.fromMiliseconds=ju,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(ei,t),r(cr,t)}($s);var Or={};Object.defineProperty(Or,"__esModule",{value:!0}),Or.Watch=void 0;class Hs{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const r=this.get(e);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const i=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:i})}get(e){const r=this.timestamps.get(e);if(typeof r>"u")throw new Error(`No timestamp found for label: ${e}`);return r}elapsed(e){const r=this.get(e);return r.elapsed||Date.now()-r.started}}Or.Watch=Hs,Or.default=Hs;var Ks={},ti={};Object.defineProperty(ti,"__esModule",{value:!0}),ti.IWatch=void 0;class $u{}ti.IWatch=$u,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(ti,t)}(Ks),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r($s,t),r(Or,t),r(Ks,t),r(ki,t)}(Q);var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.getLocalStorage=Oe.getLocalStorageOrThrow=Oe.getCrypto=Oe.getCryptoOrThrow=Vs=Oe.getLocation=Oe.getLocationOrThrow=Yi=Oe.getNavigator=Oe.getNavigatorOrThrow=qs=Oe.getDocument=Oe.getDocumentOrThrow=Oe.getFromWindowOrThrow=Oe.getFromWindow=void 0;function Zt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Oe.getFromWindow=Zt;function ur(t){const e=Zt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Oe.getFromWindowOrThrow=ur;function Bu(){return ur("document")}Oe.getDocumentOrThrow=Bu;function zu(){return Zt("document")}var qs=Oe.getDocument=zu;function Hu(){return ur("navigator")}Oe.getNavigatorOrThrow=Hu;function Ku(){return Zt("navigator")}var Yi=Oe.getNavigator=Ku;function qu(){return ur("location")}Oe.getLocationOrThrow=qu;function Vu(){return Zt("location")}var Vs=Oe.getLocation=Vu;function Gu(){return ur("crypto")}Oe.getCryptoOrThrow=Gu;function Wu(){return Zt("crypto")}Oe.getCrypto=Wu;function ku(){return ur("localStorage")}Oe.getLocalStorageOrThrow=ku;function Yu(){return Zt("localStorage")}Oe.getLocalStorage=Yu;var Ji={};Object.defineProperty(Ji,"__esModule",{value:!0});var Gs=Ji.getWindowMetadata=void 0;const Ws=Oe;function Ju(){let t,e;try{t=Ws.getDocumentOrThrow(),e=Ws.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),C=[];for(let S=0;S<D.length;S++){const w=D[S],P=w.getAttribute("rel");if(P&&P.toLowerCase().indexOf("icon")>-1){const N=w.getAttribute("href");if(N)if(N.toLowerCase().indexOf("https:")===-1&&N.toLowerCase().indexOf("http:")===-1&&N.indexOf("//")!==0){let M=e.protocol+"//"+e.host;if(N.indexOf("/")===0)M+=N;else{const E=e.pathname.split("/");E.pop();const I=E.join("/");M+=I+"/"+N}C.push(M)}else if(N.indexOf("//")===0){const M=e.protocol+N;C.push(M)}else C.push(N)}}return C}function i(...D){const C=t.getElementsByTagName("meta");for(let S=0;S<C.length;S++){const w=C[S],P=["itemprop","property","name"].map(N=>w.getAttribute(N)).filter(N=>N?D.includes(N):!1);if(P.length&&P){const N=w.getAttribute("content");if(N)return N}}return""}function n(){let D=i("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return i("description","og:description","twitter:description","keywords")}const c=n(),h=s(),u=e.origin,f=r();return{description:h,url:u,icons:f,name:c}}Gs=Ji.getWindowMetadata=Ju;var Ir={},Xu=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ks="%[a-f0-9]{2}",Ys=new RegExp(ks,"gi"),Js=new RegExp("("+ks+")+","gi");function Xi(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],Xi(r),Xi(i))}function Zu(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Ys),r=1;r<e.length;r++)t=Xi(e,r).join(""),e=t.match(Ys);return t}}function Qu(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Js.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=Zu(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Js.exec(t)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var c=n[s];t=t.replace(new RegExp(c,"g"),e[c])}return t}var ef=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 Qu(t)}},tf=(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)]},rf=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var c=i[s],h=t[c];(n?e.indexOf(c)!==-1:e(c,h,t))&&(r[c]=h)}return r};(function(t){const e=Xu,r=ef,i=tf,n=rf,s=E=>E==null,c=Symbol("encodeFragmentIdentifier");function h(E){switch(E.arrayFormat){case"index":return I=>(y,m)=>{const b=y.length;return m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(I,E),"[",b,"]"].join("")]:[...y,[g(I,E),"[",g(b,E),"]=",g(m,E)].join("")]};case"bracket":return I=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(I,E),"[]"].join("")]:[...y,[g(I,E),"[]=",g(m,E)].join("")];case"colon-list-separator":return I=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(I,E),":list="].join("")]:[...y,[g(I,E),":list=",g(m,E)].join("")];case"comma":case"separator":case"bracket-separator":{const I=E.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(m,b)=>b===void 0||E.skipNull&&b===null||E.skipEmptyString&&b===""?m:(b=b===null?"":b,m.length===0?[[g(y,E),I,g(b,E)].join("")]:[[m,g(b,E)].join(E.arrayFormatSeparator)])}default:return I=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,g(I,E)]:[...y,[g(I,E),"=",g(m,E)].join("")]}}function u(E){let I;switch(E.arrayFormat){case"index":return(y,m,b)=>{if(I=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!I){b[y]=m;return}b[y]===void 0&&(b[y]={}),b[y][I[1]]=m};case"bracket":return(y,m,b)=>{if(I=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!I){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"colon-list-separator":return(y,m,b)=>{if(I=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!I){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"comma":case"separator":return(y,m,b)=>{const o=typeof m=="string"&&m.includes(E.arrayFormatSeparator),d=typeof m=="string"&&!o&&D(m,E).includes(E.arrayFormatSeparator);m=d?D(m,E):m;const j=o||d?m.split(E.arrayFormatSeparator).map(K=>D(K,E)):m===null?m:D(m,E);b[y]=j};case"bracket-separator":return(y,m,b)=>{const o=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!o){b[y]=m&&D(m,E);return}const d=m===null?[]:m.split(E.arrayFormatSeparator).map(j=>D(j,E));if(b[y]===void 0){b[y]=d;return}b[y]=[].concat(b[y],d)};default:return(y,m,b)=>{if(b[y]===void 0){b[y]=m;return}b[y]=[].concat(b[y],m)}}}function f(E){if(typeof E!="string"||E.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(E,I){return I.encode?I.strict?e(E):encodeURIComponent(E):E}function D(E,I){return I.decode?r(E):E}function C(E){return Array.isArray(E)?E.sort():typeof E=="object"?C(Object.keys(E)).sort((I,y)=>Number(I)-Number(y)).map(I=>E[I]):E}function S(E){const I=E.indexOf("#");return I!==-1&&(E=E.slice(0,I)),E}function w(E){let I="";const y=E.indexOf("#");return y!==-1&&(I=E.slice(y)),I}function P(E){E=S(E);const I=E.indexOf("?");return I===-1?"":E.slice(I+1)}function N(E,I){return I.parseNumbers&&!Number.isNaN(Number(E))&&typeof E=="string"&&E.trim()!==""?E=Number(E):I.parseBooleans&&E!==null&&(E.toLowerCase()==="true"||E.toLowerCase()==="false")&&(E=E.toLowerCase()==="true"),E}function M(E,I){I=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},I),f(I.arrayFormatSeparator);const y=u(I),m=Object.create(null);if(typeof E!="string"||(E=E.trim().replace(/^[?#&]/,""),!E))return m;for(const b of E.split("&")){if(b==="")continue;let[o,d]=i(I.decode?b.replace(/\+/g," "):b,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(I.arrayFormat)?d:D(d,I),y(D(o,I),d,m)}for(const b of Object.keys(m)){const o=m[b];if(typeof o=="object"&&o!==null)for(const d of Object.keys(o))o[d]=N(o[d],I);else m[b]=N(o,I)}return I.sort===!1?m:(I.sort===!0?Object.keys(m).sort():Object.keys(m).sort(I.sort)).reduce((b,o)=>{const d=m[o];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?b[o]=C(d):b[o]=d,b},Object.create(null))}t.extract=P,t.parse=M,t.stringify=(E,I)=>{if(!E)return"";I=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},I),f(I.arrayFormatSeparator);const y=d=>I.skipNull&&s(E[d])||I.skipEmptyString&&E[d]==="",m=h(I),b={};for(const d of Object.keys(E))y(d)||(b[d]=E[d]);const o=Object.keys(b);return I.sort!==!1&&o.sort(I.sort),o.map(d=>{const j=E[d];return j===void 0?"":j===null?g(d,I):Array.isArray(j)?j.length===0&&I.arrayFormat==="bracket-separator"?g(d,I)+"[]":j.reduce(m(d),[]).join("&"):g(d,I)+"="+g(j,I)}).filter(d=>d.length>0).join("&")},t.parseUrl=(E,I)=>{I=Object.assign({decode:!0},I);const[y,m]=i(E,"#");return Object.assign({url:y.split("?")[0]||"",query:M(P(E),I)},I&&I.parseFragmentIdentifier&&m?{fragmentIdentifier:D(m,I)}:{})},t.stringifyUrl=(E,I)=>{I=Object.assign({encode:!0,strict:!0,[c]:!0},I);const y=S(E.url).split("?")[0]||"",m=t.extract(E.url),b=t.parse(m,{sort:!1}),o=Object.assign(b,E.query);let d=t.stringify(o,I);d&&(d=`?${d}`);let j=w(E.url);return E.fragmentIdentifier&&(j=`#${I[c]?g(E.fragmentIdentifier,I):E.fragmentIdentifier}`),`${y}${d}${j}`},t.pick=(E,I,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[c]:!1},y);const{url:m,query:b,fragmentIdentifier:o}=t.parseUrl(E,y);return t.stringifyUrl({url:m,query:n(b,I),fragmentIdentifier:o},y)},t.exclude=(E,I,y)=>{const m=Array.isArray(I)?b=>!I.includes(b):(b,o)=>!I(b,o);return t.pick(E,m,y)}})(Ir);const nf={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"}},Xs=":";function sf(t){const{namespace:e,reference:r}=t;return[e,r].join(Xs)}function of(t){const[e,r,i]=t.split(Xs);return{namespace:e,reference:r,address:i}}function af(t,e){const r=[];return t.forEach(i=>{const n=e(i);r.includes(n)||r.push(n)}),r}function cf(t){const{namespace:e,reference:r}=of(t);return sf({namespace:e,reference:r})}function hf(t){return af(t,cf)}function Zi(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.accounts)}),r}function Qi(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...hf(n.accounts))}),r}function uf(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.chains)}),r}const Zs="base10",dt="base16",en="base64pad",tn="utf8",Qs=0,Qt=1,ff=0,eo=1,rn=12,nn=32;function lf(){const t=Ki.generateKeyPair();return{privateKey:lt(t.secretKey,dt),publicKey:lt(t.publicKey,dt)}}function sn(){const t=Sr.randomBytes(nn);return lt(t,dt)}function df(t,e){const r=Ki.sharedKey(ft(t,dt),ft(e,dt)),i=new Yc(Zr.SHA256,r).expand(nn);return lt(i,dt)}function pf(t){const e=Zr.hash(ft(t,dt));return lt(e,dt)}function ri(t){const e=Zr.hash(ft(t,tn));return lt(e,dt)}function gf(t){return ft(`${t}`,Zs)}function Ar(t){return Number(lt(t,Zs))}function yf(t){const e=gf(typeof t.type<"u"?t.type:Qs);if(Ar(e)===Qt&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ft(t.senderPublicKey,dt):void 0,i=typeof t.iv<"u"?ft(t.iv,dt):Sr.randomBytes(rn),n=new Ri.ChaCha20Poly1305(ft(t.symKey,dt)).seal(i,ft(t.message,tn));return _f({type:e,sealed:n,iv:i,senderPublicKey:r})}function vf(t){const e=new Ri.ChaCha20Poly1305(ft(t.symKey,dt)),{sealed:r,iv:i}=on(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return lt(n,tn)}function _f(t){if(Ar(t.type)===Qt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return lt(qi([t.type,t.senderPublicKey,t.iv,t.sealed]),en)}return lt(qi([t.type,t.iv,t.sealed]),en)}function on(t){const e=ft(t,en),r=e.slice(ff,eo),i=eo;if(Ar(r)===Qt){const h=i+nn,u=h+rn,f=e.slice(i,h),g=e.slice(h,u),D=e.slice(u);return{type:r,sealed:D,iv:g,senderPublicKey:f}}const n=i+rn,s=e.slice(i,n),c=e.slice(n);return{type:r,sealed:c,iv:s}}function bf(t,e){const r=on(t);return to({type:Ar(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?lt(r.senderPublicKey,dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function to(t){const e=t?.type||Qs;if(e===Qt){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 ro(t){return t.type===Qt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var mf=Object.defineProperty,io=Object.getOwnPropertySymbols,wf=Object.prototype.hasOwnProperty,Ef=Object.prototype.propertyIsEnumerable,no=(t,e,r)=>e in t?mf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,so=(t,e)=>{for(var r in e||(e={}))wf.call(e,r)&&no(t,r,e[r]);if(io)for(var r of io(e))Ef.call(e,r)&&no(t,r,e[r]);return t};const Df="ReactNative",Tr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Sf="js";function oo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function xf(){return!qs()&&!!Yi()&&navigator.product===Df}function Of(){return!oo()&&!!Yi()}function If(){return xf()?Tr.reactNative:oo()?Tr.node:Of()?Tr.browser:Tr.unknown}function Af(t,e){let r=Ir.parse(t);return r=so(so({},r),e),t=Ir.stringify(r),t}function Tf(){return Gs()||{name:"",description:"",url:"",icons:[""]}}function Cf(){const t=Nu();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 Nf(){var t;const e=If();return e===Tr.browser?[e,((t=Vs())==null?void 0:t.host)||"unknown"].join(":"):e}function Lf(t,e,r){const i=Cf(),n=Nf();return[[t,e].join("-"),[Sf,r].join("-"),i,n].join("/")}function Rf({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s}){const c=r.split("?"),h=Lf(t,e,i),u={auth:n,ua:h,projectId:s},f=Af(c[1]||"",u);return c[0]+"?"+f}function pt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function ao(t){return Object.fromEntries(t.entries())}function co(t){return new Map(Object.entries(t))}function Pt(t,e){return Q.fromMiliseconds((e||Date.now())+Q.toMiliseconds(t))}function Vt(t){return Q.fromMiliseconds(Date.now())>=Q.toMiliseconds(t)}function er(){const t=Q.toMiliseconds(Q.FIVE_MINUTES);let e,r,i;return{resolve:n=>{i&&e&&(clearTimeout(i),e(n))},reject:n=>{i&&r&&(clearTimeout(i),r(n))},done:()=>new Promise((n,s)=>{i=setTimeout(s,t),e=n,r=s})}}function ho(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 Pf(t){return ho("topic",t)}function Ff(t){return ho("id",t)}function uo(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function Pe(t,e){return`${t}${e?`:${e}`:""}`}const Uf="irn";function an(t){return t?.relay||{protocol:Uf}}function cn(t){const e=nf[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Mf=Object.defineProperty,fo=Object.getOwnPropertySymbols,jf=Object.prototype.hasOwnProperty,$f=Object.prototype.propertyIsEnumerable,lo=(t,e,r)=>e in t?Mf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bf=(t,e)=>{for(var r in e||(e={}))jf.call(e,r)&&lo(t,r,e[r]);if(fo)for(var r of fo(e))$f.call(e,r)&&lo(t,r,e[r]);return t};function zf(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),c=t[n];r[s]=c}}),r}function Hf(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",c=Ir.parse(s);return{protocol:i,topic:n[0],version:parseInt(n[1],10),symKey:c.symKey,relay:zf(c)}}function Kf(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=r+e+n;t[n]&&(i[s]=t[n])}),i}function qf(t){return`${t.protocol}:${t.topic}@${t.version}?`+Ir.stringify(Bf({symKey:t.symKey},Kf(t.relay)))}function It(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Vf(t){const e=[];return Object.values(t).forEach(r=>{e.push(...It(r.accounts)),r.extension&&r.extension.forEach(i=>{e.push(...It(i.accounts))})}),e}function Gf(t,e){const r=[];return Object.values(t).forEach(i=>{It(i.accounts).includes(e)&&r.push(...i.methods),i.extension&&i.extension.forEach(n=>{It(n.accounts).includes(e)&&r.push(...n.methods)})}),r}function Wf(t,e){const r=[];return Object.values(t).forEach(i=>{It(i.accounts).includes(e)&&r.push(...i.events),i.extension&&i.extension.forEach(n=>{It(n.accounts).includes(e)&&r.push(...n.events)})}),r}const kf={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}},Yf={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:i}=Yf[t];return{message:e?`${r} ${e}`:r,code:i}}function ze(t,e){const{message:r,code:i}=kf[t];return{message:e?`${r} ${e}`:r,code:i}}function Cr(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function po(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function _t(t){return typeof t>"u"}function it(t,e){return e&&_t(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function go(t,e){return e&&_t(t)?!0:typeof t=="number"&&!isNaN(t)}function Jf(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return pt(n,i)?(i.forEach(c=>{const{accounts:h,methods:u,events:f,extension:g}=t.namespaces[c],D=It(h),C=r[c];(!pt(C.chains,D)||!pt(C.methods,u)||!pt(C.events,f))&&(s=!1),s&&g&&g.forEach(S=>{var w;const{accounts:P,methods:N,events:M}=S,E=It(P);(w=C.extension)!=null&&w.find(I=>pt(I.chains,E)&&pt(I.methods,N)&&pt(I.events,M))||(s=!1)})}),s):!1}function hn(t){return it(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Xf(t){if(it(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&hn(r)}}return!1}function Zf(t){if(it(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function Qf(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function el(t){return t?.topic}function tl(t,e){let r=null;return it(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function un(t,e){let r=null;return _t(t?.extension)||(!Cr(t.extension)||!t.extension.length)&&(r=V("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function yo(t){let e=!0;return Cr(t)?t.length&&(e=t.every(r=>it(r,!1))):e=!1,e}function vo(t,e,r){let i=null;return Cr(e)?e.forEach(n=>{i||(!hn(n)||!n.includes(t))&&(i=ze("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):i=ze("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),i}function rl(t,e){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const s=vo(i,n?.chains,`${e} requiredNamespace`),c=un(n,e);s?r=s:c?r=c:n.extension&&n.extension.forEach(h=>{if(r)return;const u=vo(i,h.chains,`${e} extension`);u&&(r=u)})}),r}function _o(t,e){let r=null;return Cr(t)?t.forEach(i=>{r||Xf(i)||(r=ze("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} 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 il(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=_o(i?.accounts,`${e} namespace`),s=un(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=_o(c.accounts,`${e} extension`);h&&(r=h)})}),r}function bo(t,e){let r=null;return yo(t?.methods)?yo(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 mo(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=bo(i,`${e}, namespace`),s=un(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=bo(c,`${e}, extension`);h&&(r=h)})}),r}function nl(t,e){let r=null;if(t&&po(t)){const i=mo(t,e);i&&(r=i);const n=rl(t,e);n&&(r=n)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function fn(t,e){let r=null;if(t&&po(t)){const i=mo(t,e);i&&(r=i);const n=il(t,e);n&&(r=n)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function wo(t){return it(t.protocol,!0)}function sl(t,e){let r=!1;return e&&!t?r=!0:t&&Cr(t)&&t.length&&t.forEach(i=>{r=wo(i)}),r}function ol(t){return typeof t=="number"}function gt(t){return typeof t<"u"&&typeof t!==null}function al(t){return!(!t||typeof t!="object"||!t.code||!go(t.code,!1)||!t.message||!it(t.message,!1))}function cl(t){return!(_t(t)||!it(t.method,!1))}function hl(t){return!(_t(t)||_t(t.result)&&_t(t.error)||!go(t.id,!1)||!it(t.jsonrpc,!1))}function ul(t){return!(_t(t)||!it(t.name,!1))}function Eo(t,e){return!(!hn(e)||!Vf(t).includes(e))}function fl(t,e,r){return it(r,!1)?Gf(t,e).includes(r):!1}function ll(t,e,r){return it(r,!1)?Wf(t,e).includes(r):!1}function Do(t,e,r){let i=null;const n=Object.keys(t),s=Object.keys(e);return pt(n,s)?n.forEach(c=>{var h;if(i)return;const u=t[c].chains,f=It(e[c].accounts);pt(u,f)?pt(t[c].methods,e[c].methods)?pt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`):t[c].extension&&e[c].extension&&((h=t[c].extension)==null||h.forEach(({methods:g,events:D,chains:C})=>{var S;i||(S=e[c].extension)!=null&&S.find(w=>{const P=It(w.accounts);return pt(C,P)&&pt(D,w.events)&&pt(g,w.methods)})||(i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):i=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),i}function dl(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var pl=gl;function gl(t,e,r){var i=r&&r.stringify||dl,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var c=new Array(s);c[0]=i(t);for(var h=1;h<s;h++)c[h]=i(e[h]);return c.join(" ")}if(typeof t!="string")return t;var u=e.length;if(u===0)return t;for(var f="",g=1-n,D=-1,C=t&&t.length||0,S=0;S<C;){if(t.charCodeAt(S)===37&&S+1<C){switch(D=D>-1?D:0,t.charCodeAt(S+1)){case 100:case 102:if(g>=u||e[g]==null)break;D<S&&(f+=t.slice(D,S)),f+=Number(e[g]),D=S+2,S++;break;case 105:if(g>=u||e[g]==null)break;D<S&&(f+=t.slice(D,S)),f+=Math.floor(Number(e[g])),D=S+2,S++;break;case 79:case 111:case 106:if(g>=u||e[g]===void 0)break;D<S&&(f+=t.slice(D,S));var w=typeof e[g];if(w==="string"){f+="'"+e[g]+"'",D=S+2,S++;break}if(w==="function"){f+=e[g].name||"<anonymous>",D=S+2,S++;break}f+=i(e[g]),D=S+2,S++;break;case 115:if(g>=u)break;D<S&&(f+=t.slice(D,S)),f+=String(e[g]),D=S+2,S++;break;case 37:D<S&&(f+=t.slice(D,S)),f+="%",D=S+2,S++,g--;break}++g}++S}return D===-1?t:(D<C&&(f+=t.slice(D)),f)}const So=pl;var ii=At;const Nr=xl().console||{},yl={mapHttpRequest:si,mapHttpResponse:si,wrapRequestSerializer:dn,wrapResponseSerializer:dn,wrapErrorSerializer:dn,req:si,res:si,err:wl};function vl(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function At(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||Nr;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=vl(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const c=["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 h=t.level||"info",u=Object.create(r);u.log||(u.log=Lr),Object.defineProperty(u,"levelVal",{get:g}),Object.defineProperty(u,"level",{get:D,set:C});const f={transmit:e,serialize:n,asObject:t.browser.asObject,levels:c,timestamp:El(t)};u.levels=At.levels,u.level=h,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=Lr,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=S,e&&(u._logEvent=ln());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function C(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,fr(f,u,"error","log"),fr(f,u,"fatal","error"),fr(f,u,"warn","error"),fr(f,u,"info","log"),fr(f,u,"debug","log"),fr(f,u,"trace","log")}function S(w,P){if(!w)throw new Error("missing bindings for child Pino");P=P||{},n&&w.serializers&&(P.serializers=w.serializers);const N=P.serializers;if(n&&N){var M=Object.assign({},i,N),E=t.browser.serialize===!0?Object.keys(M):n;delete w.serializers,ni([w],E,M,this._stdErrSerialize)}function I(y){this._childLevel=(y._childLevel|0)+1,this.error=lr(y,w,"error"),this.fatal=lr(y,w,"fatal"),this.warn=lr(y,w,"warn"),this.info=lr(y,w,"info"),this.debug=lr(y,w,"debug"),this.trace=lr(y,w,"trace"),M&&(this.serializers=M,this._serialize=E),e&&(this._logEvent=ln([].concat(y._logEvent.bindings,w)))}return I.prototype=this,new I(this)}return u}At.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"}},At.stdSerializers=yl,At.stdTimeFunctions=Object.assign({},{nullTime:xo,epochTime:Oo,unixTime:Dl,isoTime:Sl});function fr(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Lr:n[r]?n[r]:Nr[r]||Nr[i]||Lr,_l(t,e,r)}function _l(t,e,r){!t.transmit&&e[r]===Lr||(e[r]=function(i){return function(){const s=t.timestamp(),c=new Array(arguments.length),h=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Nr?Nr:this;for(var u=0;u<c.length;u++)c[u]=arguments[u];if(t.serialize&&!t.asObject&&ni(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(h,bl(this,r,c,s)):i.apply(h,c),t.transmit){const f=t.transmit.level||e.level,g=At.levels.values[f],D=At.levels.values[r];if(D<g)return;ml(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:f,transmitValue:At.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},c)}}}(e[r]))}function bl(t,e,r,i){t._serialize&&ni(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const c={};i&&(c.time=i),c.level=At.levels.values[e];let h=(t._childLevel|0)+1;if(h<1&&(h=1),s!==null&&typeof s=="object"){for(;h--&&typeof n[0]=="object";)Object.assign(c,n.shift());s=n.length?So(n.shift(),n):void 0}else typeof s=="string"&&(s=So(n.shift(),n));return s!==void 0&&(c.msg=s),c}function ni(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=At.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function lr(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function ml(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,c=e.methodValue,h=e.val,u=t._logEvent.bindings;ni(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(f){return u.indexOf(f)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=c,i(s,t._logEvent,h),t._logEvent=ln(u)}function ln(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function wl(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 El(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?xo:Oo}function si(){return{}}function dn(t){return t}function Lr(){}function xo(){return!1}function Oo(){return Date.now()}function Dl(){return Math.round(Date.now()/1e3)}function Sl(){return new Date(Date.now()).toISOString()}function xl(){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 oi={},pn=function(t,e){return pn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r[n]=i[n])},pn(t,e)};function Ol(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");pn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var gn=function(){return gn=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},gn.apply(this,arguments)};function Il(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Al(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var h=t.length-1;h>=0;h--)(c=t[h])&&(s=(n<3?c(s):n>3?c(e,r,s):c(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Tl(t,e){return function(r,i){e(r,i,t)}}function Cl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Nl(t,e,r,i){function n(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function h(g){try{f(i.next(g))}catch(D){c(D)}}function u(g){try{f(i.throw(g))}catch(D){c(D)}}function f(g){g.done?s(g.value):n(g.value).then(h,u)}f((i=i.apply(t,e||[])).next())})}function Ll(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,c;return c={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function h(f){return function(g){return u([f,g])}}function u(f){if(i)throw new TypeError("Generator is already executing.");for(;c&&(c=0,f[0]&&(r=0)),r;)try{if(i=1,n&&(s=f[0]&2?n.return:f[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,f[1])).done)return s;switch(n=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,n=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(g){f=[6,g],n=0}finally{i=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}var yn=Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]};function Rl(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&yn(e,t,r)}function vn(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Io(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],c;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(h){c={error:h}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(c)throw c.error}}return s}function Pl(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Io(arguments[e]));return t}function Fl(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],c=0,h=s.length;c<h;c++,n++)i[n]=s[c];return i}function Ul(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}function Rr(t){return this instanceof Rr?(this.v=t,this):new Rr(t)}function Ml(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},c("next"),c("throw"),c("return"),n[Symbol.asyncIterator]=function(){return this},n;function c(C){i[C]&&(n[C]=function(S){return new Promise(function(w,P){s.push([C,S,w,P])>1||h(C,S)})})}function h(C,S){try{u(i[C](S))}catch(w){D(s[0][3],w)}}function u(C){C.value instanceof Rr?Promise.resolve(C.value.v).then(f,g):D(s[0][2],C)}function f(C){h("next",C)}function g(C){h("throw",C)}function D(C,S){C(S),s.shift(),s.length&&h(s[0][0],s[0][1])}}function jl(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(c){return(r=!r)?{value:Rr(t[n](c)),done:n==="return"}:s?s(c):c}:s}}function $l(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 vn=="function"?vn(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(c){return new Promise(function(h,u){c=t[s](c),n(h,u,c.done,c.value)})}}function n(s,c,h,u){Promise.resolve(u).then(function(f){s({value:f,done:h})},c)}}function Bl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var zl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function Hl(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&yn(e,t,r);return zl(e,t),e}function Kl(t){return t&&t.__esModule?t:{default:t}}function ql(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)}function Vl(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r}function Gl(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}var Wl=Object.freeze({__proto__:null,__extends:Ol,get __assign(){return gn},__rest:Il,__decorate:Al,__param:Tl,__metadata:Cl,__awaiter:Nl,__generator:Ll,__createBinding:yn,__exportStar:Rl,__values:vn,__read:Io,__spread:Pl,__spreadArrays:Fl,__spreadArray:Ul,__await:Rr,__asyncGenerator:Ml,__asyncDelegator:jl,__asyncValues:$l,__makeTemplateObject:Bl,__importStar:Hl,__importDefault:Kl,__classPrivateFieldGet:ql,__classPrivateFieldSet:Vl,__classPrivateFieldIn:Gl}),_n=xi(Wl),ai={exports:{}},Ao;function kl(){return Ao||(Ao=1,function(){var t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){var r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),Z.localStorage?ai.exports=localStorage:ai.exports=new e}()),ai.exports}var Pr={},To;function Co(){if(To)return Pr;To=1,Object.defineProperty(Pr,"__esModule",{value:!0});function t(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}Pr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(i,n)=>typeof n>"u"?null:n)}return Pr.safeJsonStringify=e,Pr}var bn={},Fr={},No;function Yl(){if(No)return Fr;No=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.IKeyValueStorage=void 0;class t{}return Fr.IKeyValueStorage=t,Fr}var Ur={},Lo;function Jl(){if(Lo)return Ur;Lo=1,Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.parseEntry=void 0;const t=Co();function e(r){var i;return[r[0],t.safeJsonParse((i=r[1])!==null&&i!==void 0?i:"")]}return Ur.parseEntry=e,Ur}var Ro;function Xl(){return Ro||(Ro=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=_n;e.__exportStar(Yl(),t),e.__exportStar(Jl(),t)}(bn)),bn}Object.defineProperty(oi,"__esModule",{value:!0}),oi.KeyValueStorage=void 0;const dr=_n,Zl=dr.__importDefault(kl()),Po=Co(),Ql=Xl();class Fo{constructor(){this.localStorage=Zl.default}getKeys(){return dr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return dr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Ql.parseEntry)})}getItem(e){return dr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Po.safeJsonParse(r)})}setItem(e,r){return dr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Po.safeJsonStringify(r))})}removeItem(e){return dr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}oi.KeyValueStorage=Fo;var ed=oi.default=Fo,Mr={},ci={},mn={},hi={};class tr{}var td=Object.freeze({__proto__:null,IEvents:tr}),rd=xi(td);Object.defineProperty(hi,"__esModule",{value:!0}),hi.IHeartBeat=void 0;const id=rd;class nd extends id.IEvents{constructor(e){super()}}hi.IHeartBeat=nd,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(hi,t)}(mn);var wn={},pr={};Object.defineProperty(pr,"__esModule",{value:!0}),pr.HEARTBEAT_EVENTS=pr.HEARTBEAT_INTERVAL=void 0;const sd=Q;pr.HEARTBEAT_INTERVAL=sd.FIVE_SECONDS,pr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(pr,t)}(wn);var En=Z&&Z.__awaiter||function(t,e,r,i){function n(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function h(g){try{f(i.next(g))}catch(D){c(D)}}function u(g){try{f(i.throw(g))}catch(D){c(D)}}function f(g){g.done?s(g.value):n(g.value).then(h,u)}f((i=i.apply(t,e||[])).next())})};Object.defineProperty(ci,"__esModule",{value:!0}),ci.HeartBeat=void 0;const od=_r,ad=Q,cd=mn,Dn=wn;class Sn extends cd.IHeartBeat{constructor(e){super(e),this.events=new od.EventEmitter,this.interval=Dn.HEARTBEAT_INTERVAL,this.interval=e?.interval||Dn.HEARTBEAT_INTERVAL}static init(e){return En(this,void 0,void 0,function*(){const r=new Sn(e);return yield r.init(),r})}init(){return En(this,void 0,void 0,function*(){yield this.initialize()})}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)}initialize(){return En(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),ad.toMiliseconds(this.interval))})}pulse(){this.events.emit(Dn.HEARTBEAT_EVENTS.pulse)}}ci.HeartBeat=Sn,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(ci,t),r(mn,t),r(wn,t)}(Mr);var xe={},rr={},Uo;function Mo(){return Uo||(Uo=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.PINO_CUSTOM_CONTEXT_KEY=rr.PINO_LOGGER_DEFAULTS=void 0,rr.PINO_LOGGER_DEFAULTS={level:"info"},rr.PINO_CUSTOM_CONTEXT_KEY="custom_context"),rr}var ht={},jo;function hd(){if(jo)return ht;jo=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.generateChildLogger=ht.formatChildLoggerContext=ht.getLoggerContext=ht.setBrowserLoggerContext=ht.getBrowserLoggerContext=ht.getDefaultLoggerOptions=void 0;const t=Mo();function e(h){return Object.assign(Object.assign({},h),{level:h?.level||t.PINO_LOGGER_DEFAULTS.level})}ht.getDefaultLoggerOptions=e;function r(h,u=t.PINO_CUSTOM_CONTEXT_KEY){return h[u]||""}ht.getBrowserLoggerContext=r;function i(h,u,f=t.PINO_CUSTOM_CONTEXT_KEY){return h[f]=u,h}ht.setBrowserLoggerContext=i;function n(h,u=t.PINO_CUSTOM_CONTEXT_KEY){let f="";return typeof h.bindings>"u"?f=r(h,u):f=h.bindings().context||"",f}ht.getLoggerContext=n;function s(h,u,f=t.PINO_CUSTOM_CONTEXT_KEY){const g=n(h,f);return g.trim()?`${g}/${u}`:u}ht.formatChildLoggerContext=s;function c(h,u,f=t.PINO_CUSTOM_CONTEXT_KEY){const g=s(h,u,f),D=h.child({context:g});return i(D,g,f)}return ht.generateChildLogger=c,ht}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=_n;e.__exportStar(Mo(),t),e.__exportStar(hd(),t),e.__exportStar(ii,t)})(xe);class ud extends tr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class fd extends tr{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class ld{constructor(e,r){this.logger=e,this.core=r}}class dd extends tr{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pd extends tr{constructor(e){super()}}class gd{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class yd extends tr{constructor(e,r){super(),this.relayer=e,this.logger=r}}class vd extends tr{constructor(e,r){super(),this.core=e,this.logger=r}}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var _d=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!bd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||jr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],$o(r))return!1;if(Ft(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:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(jr(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},qe.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?jr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,jr(this._events[t])&&!this._events[t].warned&&($o(this._maxListeners)?r=qe.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},qe.prototype.on=qe.prototype.addListener,qe.prototype.once=function(t,e){if(!Ft(e))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(t,i),r||(r=!0,e.apply(this,arguments))}return i.listener=e,this.on(t,i),this},qe.prototype.removeListener=function(t,e){var r,i,n,s;if(!Ft(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],n=r.length,i=-1,r===e||Ft(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(jr(r)){for(s=n;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(i<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},qe.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],Ft(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},qe.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ft(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},qe.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function bd(t){return typeof t=="number"}function jr(t){return typeof t=="object"&&t!==null}function $o(t){return t===void 0}class md{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Oy extends _d.EventEmitter{constructor(){super()}}class wd{constructor(e){this.client=e}}var xn={},Bo={},ui={},fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.BrowserRandomSource=void 0;const zo=65536;class Ed{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 i=0;i<r.length;i+=zo)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,zo)));return r}}fi.BrowserRandomSource=Ed;var li={};Object.defineProperty(li,"__esModule",{value:!0}),li.NodeRandomSource=void 0;const Dd=ct;class Sd{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof gs<"u"){const e=ys;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 i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=r[n];return(0,Dd.wipe)(r),i}}li.NodeRandomSource=Sd,Object.defineProperty(ui,"__esModule",{value:!0}),ui.SystemRandomSource=void 0;const xd=fi,Od=li;class Id{constructor(){if(this.isAvailable=!1,this.name="",this._source=new xd.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Od.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)}}ui.SystemRandomSource=Id,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=ui,r=re,i=ct;t.defaultRandomSource=new e.SystemRandomSource;function n(f,g=t.defaultRandomSource){return g.randomBytes(f)}t.randomBytes=n;function s(f=t.defaultRandomSource){const g=n(4,f),D=(0,r.readUint32LE)(g);return(0,i.wipe)(g),D}t.randomUint32=s;const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(f,g=c,D=t.defaultRandomSource){if(g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");let C="";const S=g.length,w=256-256%S;for(;f>0;){const P=n(Math.ceil(f*256/w),D);for(let N=0;N<P.length&&f>0;N++){const M=P[N];M<w&&(C+=g.charAt(M%S),f--)}(0,i.wipe)(P)}return C}t.randomString=h;function u(f,g=c,D=t.defaultRandomSource){const C=Math.ceil(f/(Math.log(g.length)/Math.LN2));return h(C,g,D)}t.randomStringForEntropy=u}(Bo);var Ho={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=ct;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var i=function(){function h(){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 h.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},h.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},h.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},h.prototype.update=function(u,f){if(f===void 0&&(f=u.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=u[g++],f--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,g,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=u[g++],f--;return this},h.prototype.finish=function(u){if(!this._finished){var f=this._bytesHashed,g=this._bufferLength,D=f/536870912|0,C=f<<3,S=f%128<112?128:256;this._buffer[g]=128;for(var w=g+1;w<S-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,S-8),e.writeUint32BE(C,this._buffer,S-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,S),this._finished=!0}for(var w=0;w<this.digestLength/8;w++)e.writeUint32BE(this._stateHi[w],u,w*8),e.writeUint32BE(this._stateLo[w],u,w*8+4);return this},h.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},h.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}},h.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(u){r.wipe(u.stateHi),r.wipe(u.stateLo),u.buffer&&r.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},h}();t.SHA512=i;var n=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(h,u,f,g,D,C,S){for(var w=f[0],P=f[1],N=f[2],M=f[3],E=f[4],I=f[5],y=f[6],m=f[7],b=g[0],o=g[1],d=g[2],j=g[3],K=g[4],G=g[5],J=g[6],X=g[7],l,v,U,q,R,L,$,B;S>=128;){for(var ee=0;ee<16;ee++){var z=8*ee+C;h[ee]=e.readUint32BE(D,z),u[ee]=e.readUint32BE(D,z+4)}for(var ee=0;ee<80;ee++){var te=w,Y=P,ce=N,T=M,A=E,x=I,a=y,_=m,H=b,W=o,le=d,_e=j,pe=K,we=G,Fe=J,Ce=X;if(l=m,v=X,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=(E>>>14|K<<32-14)^(E>>>18|K<<32-18)^(K>>>41-32|E<<32-(41-32)),v=(K>>>14|E<<32-14)^(K>>>18|E<<32-18)^(E>>>41-32|K<<32-(41-32)),R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,l=E&I^~E&y,v=K&G^~K&J,R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,l=n[ee*2],v=n[ee*2+1],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,l=h[ee%16],v=u[ee%16],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,U=$&65535|B<<16,q=R&65535|L<<16,l=U,v=q,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=(w>>>28|b<<32-28)^(b>>>34-32|w<<32-(34-32))^(b>>>39-32|w<<32-(39-32)),v=(b>>>28|w<<32-28)^(w>>>34-32|b<<32-(34-32))^(w>>>39-32|b<<32-(39-32)),R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,l=w&P^w&N^P&N,v=b&o^b&d^o&d,R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,_=$&65535|B<<16,Ce=R&65535|L<<16,l=T,v=_e,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=U,v=q,R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,T=$&65535|B<<16,_e=R&65535|L<<16,P=te,N=Y,M=ce,E=T,I=A,y=x,m=a,w=_,o=H,d=W,j=le,K=_e,G=pe,J=we,X=Fe,b=Ce,ee%16===15)for(var z=0;z<16;z++)l=h[z],v=u[z],R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=h[(z+9)%16],v=u[(z+9)%16],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,U=h[(z+1)%16],q=u[(z+1)%16],l=(U>>>1|q<<32-1)^(U>>>8|q<<32-8)^U>>>7,v=(q>>>1|U<<32-1)^(q>>>8|U<<32-8)^(q>>>7|U<<32-7),R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,U=h[(z+14)%16],q=u[(z+14)%16],l=(U>>>19|q<<32-19)^(q>>>61-32|U<<32-(61-32))^U>>>6,v=(q>>>19|U<<32-19)^(U>>>61-32|q<<32-(61-32))^(q>>>6|U<<32-6),R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,h[z]=$&65535|B<<16,u[z]=R&65535|L<<16}l=w,v=b,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[0],v=g[0],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[0]=w=$&65535|B<<16,g[0]=b=R&65535|L<<16,l=P,v=o,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[1],v=g[1],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[1]=P=$&65535|B<<16,g[1]=o=R&65535|L<<16,l=N,v=d,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[2],v=g[2],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[2]=N=$&65535|B<<16,g[2]=d=R&65535|L<<16,l=M,v=j,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[3],v=g[3],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[3]=M=$&65535|B<<16,g[3]=j=R&65535|L<<16,l=E,v=K,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[4],v=g[4],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[4]=E=$&65535|B<<16,g[4]=K=R&65535|L<<16,l=I,v=G,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[5],v=g[5],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[5]=I=$&65535|B<<16,g[5]=G=R&65535|L<<16,l=y,v=J,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[6],v=g[6],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[6]=y=$&65535|B<<16,g[6]=J=R&65535|L<<16,l=m,v=X,R=v&65535,L=v>>>16,$=l&65535,B=l>>>16,l=f[7],v=g[7],R+=v&65535,L+=v>>>16,$+=l&65535,B+=l>>>16,L+=R>>>16,$+=L>>>16,B+=$>>>16,f[7]=m=$&65535|B<<16,g[7]=X=R&65535|L<<16,C+=128,S-=128}return C}function c(h){var u=new i;u.update(h);var f=u.digest();return u.clean(),f}t.hash=c})(Ho),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=Bo,r=Ho,i=ct;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(T){const A=new Float64Array(16);if(T)for(let x=0;x<T.length;x++)A[x]=T[x];return A}const s=new Uint8Array(32);s[0]=9;const c=n(),h=n([1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function S(T,A){for(let x=0;x<16;x++)T[x]=A[x]|0}function w(T){let A=1;for(let x=0;x<16;x++){let a=T[x]+A+65535;A=Math.floor(a/65536),T[x]=a-A*65536}T[0]+=A-1+37*(A-1)}function P(T,A,x){const a=~(x-1);for(let _=0;_<16;_++){const H=a&(T[_]^A[_]);T[_]^=H,A[_]^=H}}function N(T,A){const x=n(),a=n();for(let _=0;_<16;_++)a[_]=A[_];w(a),w(a),w(a);for(let _=0;_<2;_++){x[0]=a[0]-65517;for(let W=1;W<15;W++)x[W]=a[W]-65535-(x[W-1]>>16&1),x[W-1]&=65535;x[15]=a[15]-32767-(x[14]>>16&1);const H=x[15]>>16&1;x[14]&=65535,P(a,x,1-H)}for(let _=0;_<16;_++)T[2*_]=a[_]&255,T[2*_+1]=a[_]>>8}function M(T,A){let x=0;for(let a=0;a<32;a++)x|=T[a]^A[a];return(1&x-1>>>8)-1}function E(T,A){const x=new Uint8Array(32),a=new Uint8Array(32);return N(x,T),N(a,A),M(x,a)}function I(T){const A=new Uint8Array(32);return N(A,T),A[0]&1}function y(T,A){for(let x=0;x<16;x++)T[x]=A[2*x]+(A[2*x+1]<<8);T[15]&=32767}function m(T,A,x){for(let a=0;a<16;a++)T[a]=A[a]+x[a]}function b(T,A,x){for(let a=0;a<16;a++)T[a]=A[a]-x[a]}function o(T,A,x){let a,_,H=0,W=0,le=0,_e=0,pe=0,we=0,Fe=0,Ce=0,ve=0,ge=0,de=0,ue=0,he=0,ae=0,oe=0,ie=0,fe=0,ye=0,ne=0,be=0,me=0,De=0,Se=0,Ee=0,St=0,Nt=0,kt=0,yt=0,nr=0,qr=0,_i=0,Ue=x[0],Ne=x[1],Me=x[2],je=x[3],$e=x[4],Le=x[5],ke=x[6],Ye=x[7],Je=x[8],Xe=x[9],Ze=x[10],He=x[11],Be=x[12],Ae=x[13],Qe=x[14],et=x[15];a=A[0],H+=a*Ue,W+=a*Ne,le+=a*Me,_e+=a*je,pe+=a*$e,we+=a*Le,Fe+=a*ke,Ce+=a*Ye,ve+=a*Je,ge+=a*Xe,de+=a*Ze,ue+=a*He,he+=a*Be,ae+=a*Ae,oe+=a*Qe,ie+=a*et,a=A[1],W+=a*Ue,le+=a*Ne,_e+=a*Me,pe+=a*je,we+=a*$e,Fe+=a*Le,Ce+=a*ke,ve+=a*Ye,ge+=a*Je,de+=a*Xe,ue+=a*Ze,he+=a*He,ae+=a*Be,oe+=a*Ae,ie+=a*Qe,fe+=a*et,a=A[2],le+=a*Ue,_e+=a*Ne,pe+=a*Me,we+=a*je,Fe+=a*$e,Ce+=a*Le,ve+=a*ke,ge+=a*Ye,de+=a*Je,ue+=a*Xe,he+=a*Ze,ae+=a*He,oe+=a*Be,ie+=a*Ae,fe+=a*Qe,ye+=a*et,a=A[3],_e+=a*Ue,pe+=a*Ne,we+=a*Me,Fe+=a*je,Ce+=a*$e,ve+=a*Le,ge+=a*ke,de+=a*Ye,ue+=a*Je,he+=a*Xe,ae+=a*Ze,oe+=a*He,ie+=a*Be,fe+=a*Ae,ye+=a*Qe,ne+=a*et,a=A[4],pe+=a*Ue,we+=a*Ne,Fe+=a*Me,Ce+=a*je,ve+=a*$e,ge+=a*Le,de+=a*ke,ue+=a*Ye,he+=a*Je,ae+=a*Xe,oe+=a*Ze,ie+=a*He,fe+=a*Be,ye+=a*Ae,ne+=a*Qe,be+=a*et,a=A[5],we+=a*Ue,Fe+=a*Ne,Ce+=a*Me,ve+=a*je,ge+=a*$e,de+=a*Le,ue+=a*ke,he+=a*Ye,ae+=a*Je,oe+=a*Xe,ie+=a*Ze,fe+=a*He,ye+=a*Be,ne+=a*Ae,be+=a*Qe,me+=a*et,a=A[6],Fe+=a*Ue,Ce+=a*Ne,ve+=a*Me,ge+=a*je,de+=a*$e,ue+=a*Le,he+=a*ke,ae+=a*Ye,oe+=a*Je,ie+=a*Xe,fe+=a*Ze,ye+=a*He,ne+=a*Be,be+=a*Ae,me+=a*Qe,De+=a*et,a=A[7],Ce+=a*Ue,ve+=a*Ne,ge+=a*Me,de+=a*je,ue+=a*$e,he+=a*Le,ae+=a*ke,oe+=a*Ye,ie+=a*Je,fe+=a*Xe,ye+=a*Ze,ne+=a*He,be+=a*Be,me+=a*Ae,De+=a*Qe,Se+=a*et,a=A[8],ve+=a*Ue,ge+=a*Ne,de+=a*Me,ue+=a*je,he+=a*$e,ae+=a*Le,oe+=a*ke,ie+=a*Ye,fe+=a*Je,ye+=a*Xe,ne+=a*Ze,be+=a*He,me+=a*Be,De+=a*Ae,Se+=a*Qe,Ee+=a*et,a=A[9],ge+=a*Ue,de+=a*Ne,ue+=a*Me,he+=a*je,ae+=a*$e,oe+=a*Le,ie+=a*ke,fe+=a*Ye,ye+=a*Je,ne+=a*Xe,be+=a*Ze,me+=a*He,De+=a*Be,Se+=a*Ae,Ee+=a*Qe,St+=a*et,a=A[10],de+=a*Ue,ue+=a*Ne,he+=a*Me,ae+=a*je,oe+=a*$e,ie+=a*Le,fe+=a*ke,ye+=a*Ye,ne+=a*Je,be+=a*Xe,me+=a*Ze,De+=a*He,Se+=a*Be,Ee+=a*Ae,St+=a*Qe,Nt+=a*et,a=A[11],ue+=a*Ue,he+=a*Ne,ae+=a*Me,oe+=a*je,ie+=a*$e,fe+=a*Le,ye+=a*ke,ne+=a*Ye,be+=a*Je,me+=a*Xe,De+=a*Ze,Se+=a*He,Ee+=a*Be,St+=a*Ae,Nt+=a*Qe,kt+=a*et,a=A[12],he+=a*Ue,ae+=a*Ne,oe+=a*Me,ie+=a*je,fe+=a*$e,ye+=a*Le,ne+=a*ke,be+=a*Ye,me+=a*Je,De+=a*Xe,Se+=a*Ze,Ee+=a*He,St+=a*Be,Nt+=a*Ae,kt+=a*Qe,yt+=a*et,a=A[13],ae+=a*Ue,oe+=a*Ne,ie+=a*Me,fe+=a*je,ye+=a*$e,ne+=a*Le,be+=a*ke,me+=a*Ye,De+=a*Je,Se+=a*Xe,Ee+=a*Ze,St+=a*He,Nt+=a*Be,kt+=a*Ae,yt+=a*Qe,nr+=a*et,a=A[14],oe+=a*Ue,ie+=a*Ne,fe+=a*Me,ye+=a*je,ne+=a*$e,be+=a*Le,me+=a*ke,De+=a*Ye,Se+=a*Je,Ee+=a*Xe,St+=a*Ze,Nt+=a*He,kt+=a*Be,yt+=a*Ae,nr+=a*Qe,qr+=a*et,a=A[15],ie+=a*Ue,fe+=a*Ne,ye+=a*Me,ne+=a*je,be+=a*$e,me+=a*Le,De+=a*ke,Se+=a*Ye,Ee+=a*Je,St+=a*Xe,Nt+=a*Ze,kt+=a*He,yt+=a*Be,nr+=a*Ae,qr+=a*Qe,_i+=a*et,H+=38*fe,W+=38*ye,le+=38*ne,_e+=38*be,pe+=38*me,we+=38*De,Fe+=38*Se,Ce+=38*Ee,ve+=38*St,ge+=38*Nt,de+=38*kt,ue+=38*yt,he+=38*nr,ae+=38*qr,oe+=38*_i,_=1,a=H+_+65535,_=Math.floor(a/65536),H=a-_*65536,a=W+_+65535,_=Math.floor(a/65536),W=a-_*65536,a=le+_+65535,_=Math.floor(a/65536),le=a-_*65536,a=_e+_+65535,_=Math.floor(a/65536),_e=a-_*65536,a=pe+_+65535,_=Math.floor(a/65536),pe=a-_*65536,a=we+_+65535,_=Math.floor(a/65536),we=a-_*65536,a=Fe+_+65535,_=Math.floor(a/65536),Fe=a-_*65536,a=Ce+_+65535,_=Math.floor(a/65536),Ce=a-_*65536,a=ve+_+65535,_=Math.floor(a/65536),ve=a-_*65536,a=ge+_+65535,_=Math.floor(a/65536),ge=a-_*65536,a=de+_+65535,_=Math.floor(a/65536),de=a-_*65536,a=ue+_+65535,_=Math.floor(a/65536),ue=a-_*65536,a=he+_+65535,_=Math.floor(a/65536),he=a-_*65536,a=ae+_+65535,_=Math.floor(a/65536),ae=a-_*65536,a=oe+_+65535,_=Math.floor(a/65536),oe=a-_*65536,a=ie+_+65535,_=Math.floor(a/65536),ie=a-_*65536,H+=_-1+37*(_-1),_=1,a=H+_+65535,_=Math.floor(a/65536),H=a-_*65536,a=W+_+65535,_=Math.floor(a/65536),W=a-_*65536,a=le+_+65535,_=Math.floor(a/65536),le=a-_*65536,a=_e+_+65535,_=Math.floor(a/65536),_e=a-_*65536,a=pe+_+65535,_=Math.floor(a/65536),pe=a-_*65536,a=we+_+65535,_=Math.floor(a/65536),we=a-_*65536,a=Fe+_+65535,_=Math.floor(a/65536),Fe=a-_*65536,a=Ce+_+65535,_=Math.floor(a/65536),Ce=a-_*65536,a=ve+_+65535,_=Math.floor(a/65536),ve=a-_*65536,a=ge+_+65535,_=Math.floor(a/65536),ge=a-_*65536,a=de+_+65535,_=Math.floor(a/65536),de=a-_*65536,a=ue+_+65535,_=Math.floor(a/65536),ue=a-_*65536,a=he+_+65535,_=Math.floor(a/65536),he=a-_*65536,a=ae+_+65535,_=Math.floor(a/65536),ae=a-_*65536,a=oe+_+65535,_=Math.floor(a/65536),oe=a-_*65536,a=ie+_+65535,_=Math.floor(a/65536),ie=a-_*65536,H+=_-1+37*(_-1),T[0]=H,T[1]=W,T[2]=le,T[3]=_e,T[4]=pe,T[5]=we,T[6]=Fe,T[7]=Ce,T[8]=ve,T[9]=ge,T[10]=de,T[11]=ue,T[12]=he,T[13]=ae,T[14]=oe,T[15]=ie}function d(T,A){o(T,A,A)}function j(T,A){const x=n();let a;for(a=0;a<16;a++)x[a]=A[a];for(a=253;a>=0;a--)d(x,x),a!==2&&a!==4&&o(x,x,A);for(a=0;a<16;a++)T[a]=x[a]}function K(T,A){const x=n();let a;for(a=0;a<16;a++)x[a]=A[a];for(a=250;a>=0;a--)d(x,x),a!==1&&o(x,x,A);for(a=0;a<16;a++)T[a]=x[a]}function G(T,A){const x=n(),a=n(),_=n(),H=n(),W=n(),le=n(),_e=n(),pe=n(),we=n();b(x,T[1],T[0]),b(we,A[1],A[0]),o(x,x,we),m(a,T[0],T[1]),m(we,A[0],A[1]),o(a,a,we),o(_,T[3],A[3]),o(_,_,f),o(H,T[2],A[2]),m(H,H,H),b(W,a,x),b(le,H,_),m(_e,H,_),m(pe,a,x),o(T[0],W,le),o(T[1],pe,_e),o(T[2],_e,le),o(T[3],W,pe)}function J(T,A,x){for(let a=0;a<4;a++)P(T[a],A[a],x)}function X(T,A){const x=n(),a=n(),_=n();j(_,A[2]),o(x,A[0],_),o(a,A[1],_),N(T,a),T[31]^=I(x)<<7}function l(T,A,x){S(T[0],c),S(T[1],h),S(T[2],h),S(T[3],c);for(let a=255;a>=0;--a){const _=x[a/8|0]>>(a&7)&1;J(T,A,_),G(A,T),G(T,T),J(T,A,_)}}function v(T,A){const x=[n(),n(),n(),n()];S(x[0],g),S(x[1],D),S(x[2],h),o(x[3],g,D),l(T,x,A)}function U(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 x=new Uint8Array(32),a=[n(),n(),n(),n()];v(a,A),X(x,a);const _=new Uint8Array(64);return _.set(T),_.set(x,32),{publicKey:x,secretKey:_}}t.generateKeyPairFromSeed=U;function q(T){const A=(0,e.randomBytes)(32,T),x=U(A);return(0,i.wipe)(A),x}t.generateKeyPair=q;function R(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=R;const L=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 $(T,A){let x,a,_,H;for(a=63;a>=32;--a){for(x=0,_=a-32,H=a-12;_<H;++_)A[_]+=x-16*A[a]*L[_-(a-32)],x=Math.floor((A[_]+128)/256),A[_]-=x*256;A[_]+=x,A[a]=0}for(x=0,_=0;_<32;_++)A[_]+=x-(A[31]>>4)*L[_],x=A[_]>>8,A[_]&=255;for(_=0;_<32;_++)A[_]-=x*L[_];for(a=0;a<32;a++)A[a+1]+=A[a]>>8,T[a]=A[a]&255}function B(T){const A=new Float64Array(64);for(let x=0;x<64;x++)A[x]=T[x];for(let x=0;x<64;x++)T[x]=0;$(T,A)}function ee(T,A){const x=new Float64Array(64),a=[n(),n(),n(),n()],_=(0,r.hash)(T.subarray(0,32));_[0]&=248,_[31]&=127,_[31]|=64;const H=new Uint8Array(64);H.set(_.subarray(32),32);const W=new r.SHA512;W.update(H.subarray(32)),W.update(A);const le=W.digest();W.clean(),B(le),v(a,le),X(H,a),W.reset(),W.update(H.subarray(0,32)),W.update(T.subarray(32)),W.update(A);const _e=W.digest();B(_e);for(let pe=0;pe<32;pe++)x[pe]=le[pe];for(let pe=0;pe<32;pe++)for(let we=0;we<32;we++)x[pe+we]+=_e[pe]*_[we];return $(H.subarray(32),x),H}t.sign=ee;function z(T,A){const x=n(),a=n(),_=n(),H=n(),W=n(),le=n(),_e=n();return S(T[2],h),y(T[1],A),d(_,T[1]),o(H,_,u),b(_,_,T[2]),m(H,T[2],H),d(W,H),d(le,W),o(_e,le,W),o(x,_e,_),o(x,x,H),K(x,x),o(x,x,_),o(x,x,H),o(x,x,H),o(T[0],x,H),d(a,T[0]),o(a,a,H),E(a,_)&&o(T[0],T[0],C),d(a,T[0]),o(a,a,H),E(a,_)?-1:(I(T[0])===A[31]>>7&&b(T[0],c,T[0]),o(T[3],T[0],T[1]),0)}function te(T,A,x){const a=new Uint8Array(32),_=[n(),n(),n(),n()],H=[n(),n(),n(),n()];if(x.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(z(H,T))return!1;const W=new r.SHA512;W.update(x.subarray(0,32)),W.update(T),W.update(A);const le=W.digest();return B(le),l(_,H,le),v(H,x.subarray(32)),G(_,H),X(a,_),!M(x,a)}t.verify=te;function Y(T){let A=[n(),n(),n(),n()];if(z(A,T))throw new Error("Ed25519: invalid public key");let x=n(),a=n(),_=A[1];m(x,h,_),b(a,h,_),j(a,a),o(x,x,a);let H=new Uint8Array(32);return N(H,x),H}t.convertPublicKeyToX25519=Y;function ce(T){const A=(0,r.hash)(T.subarray(0,32));A[0]&=248,A[31]&=127,A[31]|=64;const x=new Uint8Array(A.subarray(0,32));return(0,i.wipe)(A),x}t.convertSecretKeyToX25519=ce}(xn);const Ad="EdDSA",Td="JWT",Ko=".",qo="base64url",Cd="utf8",Nd="utf8",Ld=":",Rd="did",Pd="key",Vo="base58btc",Fd="z",Ud="K36",Md=32;function di(t){return lt(ft(Er(t),Cd),qo)}function Go(t){const e=ft(Ud,Vo),r=Fd+lt(qi([e,t]),Vo);return[Rd,Pd,r].join(Ld)}function jd(t){return lt(t,qo)}function $d(t){return ft([di(t.header),di(t.payload)].join(Ko),Nd)}function Bd(t){return[di(t.header),di(t.payload),jd(t.signature)].join(Ko)}function Wo(t=Sr.randomBytes(Md)){return xn.generateKeyPairFromSeed(t)}async function zd(t,e,r,i,n=Q.fromMiliseconds(Date.now())){const s={alg:Ad,typ:Td},c=Go(i.publicKey),h=n+r,u={iss:c,sub:t,aud:e,iat:n,exp:h},f=$d({header:s,payload:u}),g=xn.sign(i.secretKey,f);return Bd({header:s,payload:u,signature:g})}const ko=10,Hd=(()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"))();class Kd{constructor(e){if(this.url=e,this.events=new _r.EventEmitter,this.registering=!1,!Jn(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(Er(e))}catch(i){this.onError(e.id,i)}}register(e=this.url){if(!Jn(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((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=Kn.isReactNative()?void 0:{rejectUnauthorized:!pc(e)},s=new Hd(e,[],n);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const h=c,u=this.parseError(h.error||new Error(`WebSocket connection failed for URL: ${e}`));this.events.emit("register_error",u),this.onClose(),i(u)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const i=r,n=this.parseError(i.error||new Error(`WebSocket connection failed for URL: ${this.url}`));this.events.emit("error",n)},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"?Li(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=wr(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Hn(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>ko&&this.events.setMaxListeners(ko)}}var On={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,c=9007199254740991,h="[object Arguments]",u="[object Array]",f="[object AsyncFunction]",g="[object Boolean]",D="[object Date]",C="[object Error]",S="[object Function]",w="[object GeneratorFunction]",P="[object Map]",N="[object Number]",M="[object Null]",E="[object Object]",I="[object Promise]",y="[object Proxy]",m="[object RegExp]",b="[object Set]",o="[object String]",d="[object Symbol]",j="[object Undefined]",K="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",l="[object Float64Array]",v="[object Int8Array]",U="[object Int16Array]",q="[object Int32Array]",R="[object Uint8Array]",L="[object Uint8ClampedArray]",$="[object Uint16Array]",B="[object Uint32Array]",ee=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,te=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[l]=Y[v]=Y[U]=Y[q]=Y[R]=Y[L]=Y[$]=Y[B]=!0,Y[h]=Y[u]=Y[G]=Y[g]=Y[J]=Y[D]=Y[C]=Y[S]=Y[P]=Y[N]=Y[E]=Y[m]=Y[b]=Y[o]=Y[K]=!1;var ce=typeof Z=="object"&&Z&&Z.Object===Object&&Z,T=typeof self=="object"&&self&&self.Object===Object&&self,A=ce||T||Function("return this")(),x=e&&!e.nodeType&&e,a=x&&!0&&t&&!t.nodeType&&t,_=a&&a.exports===x,H=_&&ce.process,W=function(){try{return H&&H.binding&&H.binding("util")}catch{}}(),le=W&&W.isTypedArray;function _e(p,O){for(var F=-1,k=p==null?0:p.length,Ie=0,se=[];++F<k;){var Re=p[F];O(Re,F,p)&&(se[Ie++]=Re)}return se}function pe(p,O){for(var F=-1,k=O.length,Ie=p.length;++F<k;)p[Ie+F]=O[F];return p}function we(p,O){for(var F=-1,k=p==null?0:p.length;++F<k;)if(O(p[F],F,p))return!0;return!1}function Fe(p,O){for(var F=-1,k=Array(p);++F<p;)k[F]=O(F);return k}function Ce(p){return function(O){return p(O)}}function ve(p,O){return p.has(O)}function ge(p,O){return p?.[O]}function de(p){var O=-1,F=Array(p.size);return p.forEach(function(k,Ie){F[++O]=[Ie,k]}),F}function ue(p,O){return function(F){return p(O(F))}}function he(p){var O=-1,F=Array(p.size);return p.forEach(function(k){F[++O]=k}),F}var ae=Array.prototype,oe=Function.prototype,ie=Object.prototype,fe=A["__core-js_shared__"],ye=oe.toString,ne=ie.hasOwnProperty,be=function(){var p=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),me=ie.toString,De=RegExp("^"+ye.call(ne).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Se=_?A.Buffer:void 0,Ee=A.Symbol,St=A.Uint8Array,Nt=ie.propertyIsEnumerable,kt=ae.splice,yt=Ee?Ee.toStringTag:void 0,nr=Object.getOwnPropertySymbols,qr=Se?Se.isBuffer:void 0,_i=ue(Object.keys,Object),Ue=vr(A,"DataView"),Ne=vr(A,"Map"),Me=vr(A,"Promise"),je=vr(A,"Set"),$e=vr(A,"WeakMap"),Le=vr(Object,"create"),ke=or(Ue),Ye=or(Ne),Je=or(Me),Xe=or(je),Ze=or($e),He=Ee?Ee.prototype:void 0,Be=He?He.valueOf:void 0;function Ae(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var k=p[O];this.set(k[0],k[1])}}function Qe(){this.__data__=Le?Le(null):{},this.size=0}function et(p){var O=this.has(p)&&delete this.__data__[p];return this.size-=O?1:0,O}function F0(p){var O=this.__data__;if(Le){var F=O[p];return F===i?void 0:F}return ne.call(O,p)?O[p]:void 0}function U0(p){var O=this.__data__;return Le?O[p]!==void 0:ne.call(O,p)}function M0(p,O){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Le&&O===void 0?i:O,this}Ae.prototype.clear=Qe,Ae.prototype.delete=et,Ae.prototype.get=F0,Ae.prototype.has=U0,Ae.prototype.set=M0;function Bt(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var k=p[O];this.set(k[0],k[1])}}function j0(){this.__data__=[],this.size=0}function $0(p){var O=this.__data__,F=mi(O,p);if(F<0)return!1;var k=O.length-1;return F==k?O.pop():kt.call(O,F,1),--this.size,!0}function B0(p){var O=this.__data__,F=mi(O,p);return F<0?void 0:O[F][1]}function z0(p){return mi(this.__data__,p)>-1}function H0(p,O){var F=this.__data__,k=mi(F,p);return k<0?(++this.size,F.push([p,O])):F[k][1]=O,this}Bt.prototype.clear=j0,Bt.prototype.delete=$0,Bt.prototype.get=B0,Bt.prototype.has=z0,Bt.prototype.set=H0;function sr(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var k=p[O];this.set(k[0],k[1])}}function K0(){this.size=0,this.__data__={hash:new Ae,map:new(Ne||Bt),string:new Ae}}function q0(p){var O=wi(this,p).delete(p);return this.size-=O?1:0,O}function V0(p){return wi(this,p).get(p)}function G0(p){return wi(this,p).has(p)}function W0(p,O){var F=wi(this,p),k=F.size;return F.set(p,O),this.size+=F.size==k?0:1,this}sr.prototype.clear=K0,sr.prototype.delete=q0,sr.prototype.get=V0,sr.prototype.has=G0,sr.prototype.set=W0;function bi(p){var O=-1,F=p==null?0:p.length;for(this.__data__=new sr;++O<F;)this.add(p[O])}function k0(p){return this.__data__.set(p,i),this}function Y0(p){return this.__data__.has(p)}bi.prototype.add=bi.prototype.push=k0,bi.prototype.has=Y0;function Yt(p){var O=this.__data__=new Bt(p);this.size=O.size}function J0(){this.__data__=new Bt,this.size=0}function X0(p){var O=this.__data__,F=O.delete(p);return this.size=O.size,F}function Z0(p){return this.__data__.get(p)}function Q0(p){return this.__data__.has(p)}function ey(p,O){var F=this.__data__;if(F instanceof Bt){var k=F.__data__;if(!Ne||k.length<r-1)return k.push([p,O]),this.size=++F.size,this;F=this.__data__=new sr(k)}return F.set(p,O),this.size=F.size,this}Yt.prototype.clear=J0,Yt.prototype.delete=X0,Yt.prototype.get=Z0,Yt.prototype.has=Q0,Yt.prototype.set=ey;function ty(p,O){var F=Ei(p),k=!F&&yy(p),Ie=!F&&!k&&Mn(p),se=!F&&!k&&!Ie&&Wa(p),Re=F||k||Ie||se,tt=Re?Fe(p.length,String):[],st=tt.length;for(var Te in p)(O||ne.call(p,Te))&&!(Re&&(Te=="length"||Ie&&(Te=="offset"||Te=="parent")||se&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||fy(Te,st)))&&tt.push(Te);return tt}function mi(p,O){for(var F=p.length;F--;)if(Ka(p[F][0],O))return F;return-1}function ry(p,O,F){var k=O(p);return Ei(p)?k:pe(k,F(p))}function Vr(p){return p==null?p===void 0?j:M:yt&&yt in Object(p)?hy(p):gy(p)}function $a(p){return Gr(p)&&Vr(p)==h}function Ba(p,O,F,k,Ie){return p===O?!0:p==null||O==null||!Gr(p)&&!Gr(O)?p!==p&&O!==O:iy(p,O,F,k,Ba,Ie)}function iy(p,O,F,k,Ie,se){var Re=Ei(p),tt=Ei(O),st=Re?u:Jt(p),Te=tt?u:Jt(O);st=st==h?E:st,Te=Te==h?E:Te;var vt=st==E,xt=Te==E,at=st==Te;if(at&&Mn(p)){if(!Mn(O))return!1;Re=!0,vt=!1}if(at&&!vt)return se||(se=new Yt),Re||Wa(p)?za(p,O,F,k,Ie,se):ay(p,O,st,F,k,Ie,se);if(!(F&n)){var mt=vt&&ne.call(p,"__wrapped__"),wt=xt&&ne.call(O,"__wrapped__");if(mt||wt){var Xt=mt?p.value():p,zt=wt?O.value():O;return se||(se=new Yt),Ie(Xt,zt,F,k,se)}}return at?(se||(se=new Yt),cy(p,O,F,k,Ie,se)):!1}function ny(p){if(!Ga(p)||dy(p))return!1;var O=qa(p)?De:z;return O.test(or(p))}function sy(p){return Gr(p)&&Va(p.length)&&!!Y[Vr(p)]}function oy(p){if(!py(p))return _i(p);var O=[];for(var F in Object(p))ne.call(p,F)&&F!="constructor"&&O.push(F);return O}function za(p,O,F,k,Ie,se){var Re=F&n,tt=p.length,st=O.length;if(tt!=st&&!(Re&&st>tt))return!1;var Te=se.get(p);if(Te&&se.get(O))return Te==O;var vt=-1,xt=!0,at=F&s?new bi:void 0;for(se.set(p,O),se.set(O,p);++vt<tt;){var mt=p[vt],wt=O[vt];if(k)var Xt=Re?k(wt,mt,vt,O,p,se):k(mt,wt,vt,p,O,se);if(Xt!==void 0){if(Xt)continue;xt=!1;break}if(at){if(!we(O,function(zt,ar){if(!ve(at,ar)&&(mt===zt||Ie(mt,zt,F,k,se)))return at.push(ar)})){xt=!1;break}}else if(!(mt===wt||Ie(mt,wt,F,k,se))){xt=!1;break}}return se.delete(p),se.delete(O),xt}function ay(p,O,F,k,Ie,se,Re){switch(F){case J:if(p.byteLength!=O.byteLength||p.byteOffset!=O.byteOffset)return!1;p=p.buffer,O=O.buffer;case G:return!(p.byteLength!=O.byteLength||!se(new St(p),new St(O)));case g:case D:case N:return Ka(+p,+O);case C:return p.name==O.name&&p.message==O.message;case m:case o:return p==O+"";case P:var tt=de;case b:var st=k&n;if(tt||(tt=he),p.size!=O.size&&!st)return!1;var Te=Re.get(p);if(Te)return Te==O;k|=s,Re.set(p,O);var vt=za(tt(p),tt(O),k,Ie,se,Re);return Re.delete(p),vt;case d:if(Be)return Be.call(p)==Be.call(O)}return!1}function cy(p,O,F,k,Ie,se){var Re=F&n,tt=Ha(p),st=tt.length,Te=Ha(O),vt=Te.length;if(st!=vt&&!Re)return!1;for(var xt=st;xt--;){var at=tt[xt];if(!(Re?at in O:ne.call(O,at)))return!1}var mt=se.get(p);if(mt&&se.get(O))return mt==O;var wt=!0;se.set(p,O),se.set(O,p);for(var Xt=Re;++xt<st;){at=tt[xt];var zt=p[at],ar=O[at];if(k)var ka=Re?k(ar,zt,at,O,p,se):k(zt,ar,at,p,O,se);if(!(ka===void 0?zt===ar||Ie(zt,ar,F,k,se):ka)){wt=!1;break}Xt||(Xt=at=="constructor")}if(wt&&!Xt){var Di=p.constructor,Si=O.constructor;Di!=Si&&"constructor"in p&&"constructor"in O&&!(typeof Di=="function"&&Di instanceof Di&&typeof Si=="function"&&Si instanceof Si)&&(wt=!1)}return se.delete(p),se.delete(O),wt}function Ha(p){return ry(p,by,uy)}function wi(p,O){var F=p.__data__;return ly(O)?F[typeof O=="string"?"string":"hash"]:F.map}function vr(p,O){var F=ge(p,O);return ny(F)?F:void 0}function hy(p){var O=ne.call(p,yt),F=p[yt];try{p[yt]=void 0;var k=!0}catch{}var Ie=me.call(p);return k&&(O?p[yt]=F:delete p[yt]),Ie}var uy=nr?function(p){return p==null?[]:(p=Object(p),_e(nr(p),function(O){return Nt.call(p,O)}))}:my,Jt=Vr;(Ue&&Jt(new Ue(new ArrayBuffer(1)))!=J||Ne&&Jt(new Ne)!=P||Me&&Jt(Me.resolve())!=I||je&&Jt(new je)!=b||$e&&Jt(new $e)!=K)&&(Jt=function(p){var O=Vr(p),F=O==E?p.constructor:void 0,k=F?or(F):"";if(k)switch(k){case ke:return J;case Ye:return P;case Je:return I;case Xe:return b;case Ze:return K}return O});function fy(p,O){return O=O??c,!!O&&(typeof p=="number"||te.test(p))&&p>-1&&p%1==0&&p<O}function ly(p){var O=typeof p;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?p!=="__proto__":p===null}function dy(p){return!!be&&be in p}function py(p){var O=p&&p.constructor,F=typeof O=="function"&&O.prototype||ie;return p===F}function gy(p){return me.call(p)}function or(p){if(p!=null){try{return ye.call(p)}catch{}try{return p+""}catch{}}return""}function Ka(p,O){return p===O||p!==p&&O!==O}var yy=$a(function(){return arguments}())?$a:function(p){return Gr(p)&&ne.call(p,"callee")&&!Nt.call(p,"callee")},Ei=Array.isArray;function vy(p){return p!=null&&Va(p.length)&&!qa(p)}var Mn=qr||wy;function _y(p,O){return Ba(p,O)}function qa(p){if(!Ga(p))return!1;var O=Vr(p);return O==S||O==w||O==f||O==y}function Va(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=c}function Ga(p){var O=typeof p;return p!=null&&(O=="object"||O=="function")}function Gr(p){return p!=null&&typeof p=="object"}var Wa=le?Ce(le):sy;function by(p){return vy(p)?ty(p):oy(p)}function my(){return[]}function wy(){return!1}t.exports=_y})(On,On.exports);var qd=On.exports,Vd=Object.defineProperty,Yo=Object.getOwnPropertySymbols,Gd=Object.prototype.hasOwnProperty,Wd=Object.prototype.propertyIsEnumerable,Jo=(t,e,r)=>e in t?Vd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Gd.call(e,r)&&Jo(t,r,e[r]);if(Yo)for(var r of Yo(e))Wd.call(e,r)&&Jo(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var ir=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!kd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||$r(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],Xo(r))return!1;if(Ut(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:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if($r(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},Ve.prototype.addListener=function(t,e){var r;if(!Ut(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ut(e.listener)?e.listener:e),this._events[t]?$r(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,$r(this._events[t])&&!this._events[t].warned&&(Xo(this._maxListeners)?r=Ve.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},Ve.prototype.on=Ve.prototype.addListener,Ve.prototype.once=function(t,e){if(!Ut(e))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(t,i),r||(r=!0,e.apply(this,arguments))}return i.listener=e,this.on(t,i),this},Ve.prototype.removeListener=function(t,e){var r,i,n,s;if(!Ut(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],n=r.length,i=-1,r===e||Ut(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if($r(r)){for(s=n;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(i<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ve.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],Ut(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ve.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ut(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ut(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Ut(t){return typeof t=="function"}function kd(t){return typeof t=="number"}function $r(t){return typeof t=="object"&&t!==null}function Xo(t){return t===void 0}function Yd(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=n}var h=t.length,u=t.charAt(0),f=Math.log(h)/Math.log(256),g=Math.log(256)/Math.log(h);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,N=0,M=0,E=w.length;M!==E&&w[M]===0;)M++,P++;for(var I=(E-M)*g+1>>>0,y=new Uint8Array(I);M!==E;){for(var m=w[M],b=0,o=I-1;(m!==0||b<N)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%h>>>0,m=m/h>>>0;if(m!==0)throw new Error("Non-zero carry");N=b,M++}for(var d=I-N;d!==I&&y[d]===0;)d++;for(var j=u.repeat(P);d<I;++d)j+=t.charAt(y[d]);return j}function C(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 N=0,M=0;w[P]===u;)N++,P++;for(var E=(w.length-P)*f+1>>>0,I=new Uint8Array(E);w[P];){var y=r[w.charCodeAt(P)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<M)&&b!==-1;b--,m++)y+=h*I[b]>>>0,I[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");M=m,P++}if(w[P]!==" "){for(var o=E-M;o!==E&&I[o]===0;)o++;for(var d=new Uint8Array(N+(E-o)),j=N;o!==E;)d[j++]=I[o++];return d}}}function S(w){var P=C(w);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:S}}var Jd=Yd,Xd=Jd;const Zo=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")},Zd=t=>new TextEncoder().encode(t),Qd=t=>new TextDecoder().decode(t);class ep{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class tp{constructor(e,r,i){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=i}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 Qo(this,e)}}class rp{constructor(e){this.decoders=e}or(e){return Qo(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Qo=(t,e)=>new rp(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class ip{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new ep(e,r,i),this.decoder=new tp(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pi=({name:t,prefix:e,encode:r,decode:i})=>new ip(t,e,r,i),Br=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Xd(r,e);return pi({prefix:t,name:e,encode:i,decode:s=>Zo(n(s))})},np=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let h=0,u=0,f=0;for(let g=0;g<s;++g){const D=n[t[g]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|D,h+=r,h>=8&&(h-=8,c[f++]=255&u>>h)}if(h>=r||255&u<<8-h)throw new SyntaxError("Unexpected end of data");return c},sp=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,h=0;for(let u=0;u<t.length;++u)for(h=h<<8|t[u],c+=8;c>r;)c-=r,s+=e[n&h>>c];if(c&&(s+=e[n&h<<r-c]),i)for(;s.length*r&7;)s+="=";return s},nt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>pi({prefix:e,name:t,encode(n){return sp(n,i,r)},decode(n){return np(n,i,r,t)}}),op=pi({prefix:"\0",name:"identity",encode:t=>Qd(t),decode:t=>Zd(t)});var ap=Object.freeze({__proto__:null,identity:op});const cp=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hp=Object.freeze({__proto__:null,base2:cp});const up=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fp=Object.freeze({__proto__:null,base8:up});const lp=Br({prefix:"9",name:"base10",alphabet:"0123456789"});var dp=Object.freeze({__proto__:null,base10:lp});const pp=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gp=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yp=Object.freeze({__proto__:null,base16:pp,base16upper:gp});const vp=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_p=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bp=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mp=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wp=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ep=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Dp=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sp=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xp=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Op=Object.freeze({__proto__:null,base32:vp,base32upper:_p,base32pad:bp,base32padupper:mp,base32hex:wp,base32hexupper:Ep,base32hexpad:Dp,base32hexpadupper:Sp,base32z:xp});const Ip=Br({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ap=Br({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Tp=Object.freeze({__proto__:null,base36:Ip,base36upper:Ap});const Cp=Br({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Np=Br({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lp=Object.freeze({__proto__:null,base58btc:Cp,base58flickr:Np});const Rp=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pp=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fp=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Up=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mp=Object.freeze({__proto__:null,base64:Rp,base64pad:Pp,base64url:Fp,base64urlpad:Up});const ea=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}"),jp=ea.reduce((t,e,r)=>(t[r]=e,t),[]),$p=ea.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bp(t){return t.reduce((e,r)=>(e+=jp[r],e),"")}function zp(t){const e=[];for(const r of t){const i=$p[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Hp=pi({prefix:"\u{1F680}",name:"base256emoji",encode:Bp,decode:zp});var Kp=Object.freeze({__proto__:null,base256emoji:Hp}),qp=ra,ta=128,Vp=127,Gp=~Vp,Wp=Math.pow(2,31);function ra(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Wp;)e[r++]=t&255|ta,t/=128;for(;t&Gp;)e[r++]=t&255|ta,t>>>=7;return e[r]=t|0,ra.bytes=r-i+1,e}var kp=In,Yp=128,ia=127;function In(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw In.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&ia)<<n:(c&ia)*Math.pow(2,n),n+=7}while(c>=Yp);return In.bytes=s-i,r}var Jp=Math.pow(2,7),Xp=Math.pow(2,14),Zp=Math.pow(2,21),Qp=Math.pow(2,28),eg=Math.pow(2,35),tg=Math.pow(2,42),rg=Math.pow(2,49),ig=Math.pow(2,56),ng=Math.pow(2,63),sg=function(t){return t<Jp?1:t<Xp?2:t<Zp?3:t<Qp?4:t<eg?5:t<tg?6:t<rg?7:t<ig?8:t<ng?9:10},og={encode:qp,decode:kp,encodingLength:sg},na=og;const sa=(t,e,r=0)=>(na.encode(t,e,r),e),oa=t=>na.encodingLength(t),An=(t,e)=>{const r=e.byteLength,i=oa(t),n=i+oa(r),s=new Uint8Array(n+r);return sa(t,s,0),sa(r,s,i),s.set(e,n),new ag(t,r,e,s)};class ag{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const aa=({name:t,code:e,encode:r})=>new cg(t,e,r);class cg{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?An(this.code,r):r.then(i=>An(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ca=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),hg=aa({name:"sha2-256",code:18,encode:ca("SHA-256")}),ug=aa({name:"sha2-512",code:19,encode:ca("SHA-512")});var fg=Object.freeze({__proto__:null,sha256:hg,sha512:ug});const ha=0,lg="identity",ua=Zo;var dg=Object.freeze({__proto__:null,identity:{code:ha,name:lg,encode:ua,digest:t=>An(ha,ua(t))}});new TextEncoder,new TextDecoder;const fa=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},ap),hp),fp),dp),yp),Op),Tp),Lp),Mp),Kp);ut(ut({},fg),dg);function pg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function la(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const da=la("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Tn=la("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=pg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),gg=ut({utf8:da,"utf-8":da,hex:fa.base16,latin1:Tn,ascii:Tn,binary:Tn},fa);function yg(t,e="utf8"){const r=gg[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 pa="wc",vg=2,Cn="core",Gt=`${pa}@${2}:${Cn}:`,_g={name:Cn,logger:"error"},bg={database:":memory:"},mg="crypto",ga="client_ed25519_seed",wg=Q.ONE_DAY,Eg="keychain",Dg="0.3",Sg="messages",xg="0.3",Og=Q.SIX_HOURS,Ig="publisher",ya="irn",Ag="error",Tg="wss://relay.walletconnect.com",Cg="relayer",gr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Ng="_subscription",yr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Lg=Q.ONE_SECOND,Rg="2.1.3",Pg="0.3",Mt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Fg="subscription",Ug="0.3",Mg=Q.FIVE_SECONDS*1e3,jg="pairing",$g="0.3",zr={wc_pairingDelete:{req:{ttl:Q.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Q.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Q.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Q.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Q.ONE_DAY,prompt:!1,tag:0},res:{ttl:Q.ONE_DAY,prompt:!1,tag:0}}},Tt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Bg="history",zg="0.3",Hg="expirer",bt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Kg="0.3";class qg{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=Eg,this.version=Dg,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=V("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),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,ao(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?co(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 Vg{constructor(e,r,i){this.core=e,this.logger=r,this.name=mg,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Wo(n);return Go(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=lf();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),c=Wo(s),h=sn();return await zd(h,n,wg,c)},this.generateSharedKey=(n,s,c)=>{this.isInitialized();const h=this.getPrivateKey(n),u=df(h,s);return this.setSymKey(u,c)},this.setSymKey=async(n,s)=>{this.isInitialized();const c=s||pf(n);return await this.keychain.set(c,n),c},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,c)=>{this.isInitialized();const h=to(c),u=Er(s);if(ro(h)){const C=h.senderPublicKey,S=h.receiverPublicKey;n=await this.generateSharedKey(C,S)}const f=this.getSymKey(n),{type:g,senderPublicKey:D}=h;return yf({type:g,symKey:f,message:u,senderPublicKey:D})},this.decode=async(n,s,c)=>{this.isInitialized();const h=bf(s,c);if(ro(h)){const g=h.receiverPublicKey,D=h.senderPublicKey;n=await this.generateSharedKey(g,D)}const u=this.getSymKey(n),f=vf({symKey:u,encoded:s});return Li(f)},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.keychain=i||new qg(this.core,this.logger)}get context(){return xe.getLoggerContext(this.logger)}getPayloadType(e){const r=on(e);return Ar(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(ga)}catch{e=sn(),await this.keychain.set(ga,e)}return yg(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 Gg extends ld{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Sg,this.version=xg,this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=ri(n);let c=this.messages.get(i);return typeof c>"u"&&(c={}),typeof c[s]<"u"||(c[s]=n,this.messages.set(i,c),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),c=ri(n);return typeof s[c]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),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,ao(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?co(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 Wg extends dd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new ir.EventEmitter,this.name=Ig,this.queue=new Map,this.publish=async(i,n,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});try{const c=s?.ttl||Og,h=an(s),u=s?.prompt||!1,f=s?.tag||0,g={topic:i,message:n,opts:{ttl:c,relay:h,prompt:u,tag:f}},D=ri(n);this.queue.set(D,g),await this.rpcPublish(i,n,c,h,u,f),this.onPublish(D,g),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}})}catch(c){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(c),c}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=xe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return xe.getLoggerContext(this.logger)}rpcPublish(e,r,i,n,s,c){var h,u,f,g;const D={method:cn(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:c}};return _t((h=D.params)==null?void 0:h.prompt)&&((u=D.params)==null||delete u.prompt),_t((f=D.params)==null?void 0:f.tag)&&((g=D.params)==null||delete g.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:i,opts:{ttl:n,relay:s,prompt:c,tag:h}}=e,u=ri(i);await this.rpcPublish(r,i,n,s,c,h),this.onPublish(u,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Mr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class kg{constructor(){this.map=new Map,this.set=(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,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 i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Yg=Object.defineProperty,Jg=Object.defineProperties,Xg=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertySymbols,Zg=Object.prototype.hasOwnProperty,Qg=Object.prototype.propertyIsEnumerable,_a=(t,e,r)=>e in t?Yg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gi=(t,e)=>{for(var r in e||(e={}))Zg.call(e,r)&&_a(t,r,e[r]);if(va)for(var r of va(e))Qg.call(e,r)&&_a(t,r,e[r]);return t},Nn=(t,e)=>Jg(t,Xg(e));class e0 extends yd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new kg,this.events=new ir.EventEmitter,this.name=Fg,this.version=Ug,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=an(n),c={topic:i,relay:s};this.pending.set(i,c);const h=await this.rpcSubscribe(i,s);return this.onSubscribe(h,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}}),h}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>this.topics.includes(i)?!0:await new Promise((n,s)=>{const c=new Q.Watch;c.start(this.pendingSubscriptionWatchLabel);const h=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(h),c.stop(this.pendingSubscriptionWatchLabel),n(!0)),c.elapsed(this.pendingSubscriptionWatchLabel)>=Mg&&(clearInterval(h),c.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},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 i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}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 i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=an(i);await this.rpcUnsubscribe(e,r,n);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:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r){const i={method:cn(r.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),await this.relayer.provider.request(i)}rpcUnsubscribe(e,r,i){const n={method:cn(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.provider.request(n)}onSubscribe(e,r){this.setSubscription(e,Nn(gi({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Nn(gi({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),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,gi({},r)),this.topicMap.set(r.topic,e),this.events.emit(Mt.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:i}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Mt.deleted,Nn(gi({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Mt.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(Mt.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:i}=e,n={topic:r,relay:i};this.pending.set(n.topic,n);const s=await this.rpcSubscribe(n.topic,n.relay);this.onResubscribe(s,n)}}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(Mr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(yr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(yr.disconnect,()=>{this.onDisconnect()}),this.events.on(Mt.created,async e=>{const r=Mt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Mt.deleted,async e=>{const r=Mt.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 t0=Object.defineProperty,ba=Object.getOwnPropertySymbols,r0=Object.prototype.hasOwnProperty,i0=Object.prototype.propertyIsEnumerable,ma=(t,e,r)=>e in t?t0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,n0=(t,e)=>{for(var r in e||(e={}))r0.call(e,r)&&ma(t,r,e[r]);if(ba)for(var r of ba(e))i0.call(e,r)&&ma(t,r,e[r]);return t};class s0 extends pd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new ir.EventEmitter,this.name=Cg,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):ii(xe.getDefaultLoggerOptions({level:e.logger||Ag})),this.messages=new Gg(this.logger,e.core),this.subscriber=new e0(this,this.logger),this.publisher=new Wg(this,this.logger),this.relayUrl=e?.relayUrl||Tg,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.provider.connect(),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,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){return this.isInitialized(),await this.subscriber.subscribe(e,r)}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,await this.provider.disconnect()}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1,await this.provider.connect(),await new Promise(r=>{this.subscriber.once(Mt.resubscribed,()=>{r()})})}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new Ci(new Kd(Rf({sdkVersion:Rg,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,i):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ai(e)){if(!e.method.endsWith(Ng))return;const r=e.params,{topic:i,message:n}=r.data,s={topic:i,message:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(n0({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(gr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=kr(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(yr.payload,e=>this.onProviderPayload(e)),this.provider.on(yr.connect,()=>{this.events.emit(gr.connect)}),this.provider.on(yr.disconnect,()=>{this.events.emit(gr.disconnect),this.attemptToReconnect()}),this.provider.on(yr.error,e=>this.events.emit(gr.error,e))}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(()=>{this.provider.connect()},Q.toMiliseconds(Lg))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var o0=Object.defineProperty,wa=Object.getOwnPropertySymbols,a0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable,Ea=(t,e,r)=>e in t?o0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Da=(t,e)=>{for(var r in e||(e={}))a0.call(e,r)&&Ea(t,r,e[r]);if(wa)for(var r of wa(e))c0.call(e,r)&&Ea(t,r,e[r]);return t};class Ln extends gd{constructor(e,r,i,n=Gt,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=Pg,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(c=>{Qf(c)?this.map.set(c.id,c):el(c)?this.map.set(c.topic,c):this.getKey&&c!==null&&!_t(c)&&this.map.set(this.getKey(c),c)}),this.cached=[],this.initialized=!0)},this.set=async(c,h)=>{this.isInitialized(),this.map.has(c)?await this.update(c,h):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:c,value:h}),this.map.set(c,h),await this.persist())},this.get=c=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:c}),this.getData(c)),this.getAll=c=>(this.isInitialized(),c?this.values.filter(h=>Object.keys(c).every(u=>qd(h[u],c[u]))):this.values),this.update=async(c,h)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:c,update:h});const u=Da(Da({},this.getData(c)),h);this.map.set(c,u),await this.persist()},this.delete=async(c,h)=>{this.isInitialized(),this.map.has(c)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:c,reason:h}),this.map.delete(c),await this.persist())},this.logger=xe.generateChildLogger(r,this.name),this.storagePrefix=n,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:i}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}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 h0{constructor(e,r){this.core=e,this.logger=r,this.name=jg,this.version=$g,this.events=new ir,this.initialized=!1,this.storagePrefix=Gt,this.ignoredPayloadTypes=[Qt],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:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async()=>{this.isInitialized();const i=sn(),n=await this.core.crypto.setSymKey(i),s=Pt(Q.FIVE_MINUTES),c={protocol:ya},h={topic:n,expiry:s,relay:c,active:!1},u=qf({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:i,relay:c});return await this.pairings.set(n,h),await this.core.relayer.subscribe(n),this.core.expirer.set(n,s),{topic:n,uri:u}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:n,symKey:s,relay:c}=Hf(i.uri),h=Pt(Q.FIVE_MINUTES),u={topic:n,relay:c,expiry:h,active:!1};return await this.pairings.set(n,u),await this.core.crypto.setSymKey(s,n),await this.core.relayer.subscribe(n,{relay:c}),this.core.expirer.set(n,h),i.activatePairing&&await this.activate({topic:n}),u},this.activate=async({topic:i})=>{this.isInitialized();const n=Pt(Q.THIRTY_DAYS);await this.pairings.update(i,{active:!0,expiry:n}),this.core.expirer.set(i,n)},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:c,resolve:h,reject:u}=er();this.events.once(Pe("pairing_ping",s),({error:f})=>{f?u(f):h()}),await c()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ze("USER_DISCONNECTED")),await this.deletePairing(n))},this.sendRequest=async(i,n,s)=>{const c=Wr(n,s),h=await this.core.crypto.encode(i,c),u=zr[n].req;return this.core.history.set(i,c),await this.core.relayer.publish(i,h,u),c.id},this.sendResult=async(i,n,s)=>{const c=kr(i,s),h=await this.core.crypto.encode(n,c),u=await this.core.history.get(n,i),f=zr[u.request.method].res;await this.core.relayer.publish(n,h,f),await this.core.history.resolve(c)},this.sendError=async(i,n,s)=>{const c=wr(i,s),h=await this.core.crypto.encode(n,c),u=await this.core.history.get(n,i),f=zr[u.request.method]?zr[u.request.method].res:zr.unregistered_method.res;await this.core.relayer.publish(n,h,f),await this.core.history.resolve(c)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ze("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Vt(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,c=(await this.core.history.get(n,s.id)).request.method;switch(c){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(c)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit("pairing_ping",{id:s,topic:i})}catch(c){await this.sendError(s,i,c),this.logger.error(c)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Rt(n)?this.events.emit(Pe("pairing_ping",s),{}):Dt(n)&&this.events.emit(Pe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.sendResult(s,i,!0),await this.deletePairing(i),this.events.emit("pairing_delete",{id:s,topic:i})}catch(c){await this.sendError(s,i,c),this.logger.error(c)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:c}=n;try{if(this.registeredMethods.includes(c))return;const h=ze("WC_METHOD_UNSUPPORTED",c);await this.sendError(s,i,h),this.logger.error(h)}catch(h){await this.sendError(s,i,h),this.logger.error(h)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ze("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=i=>{if(!gt(i)){const{message:n}=V("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(n)}if(!Zf(i.uri)){const{message:n}=V("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(n)}},this.isValidPing=async i=>{if(!gt(i)){const{message:s}=V("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!gt(i)){const{message:s}=V("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!it(i,!1)){const{message:n}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Vt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=V("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=xe.generateChildLogger(r,this.name),this.pairings=new Ln(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(gr.message,async e=>{const{topic:r,message:i}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const n=await this.core.crypto.decode(r,i);Ai(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Ti(n)&&(await this.core.history.resolve(n),this.onRelayEventResponse({topic:r,payload:n}))})}registerExpirerEvents(){this.core.expirer.on(bt.expired,async e=>{const{topic:r}=uo(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class u0 extends fd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new ir.EventEmitter,this.name=Bg,this.version=zg,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const c={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s};this.records.set(c.id,c),this.events.emit(Tt.created,c)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Dt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.events.emit(Tt.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Tt.deleted,s)}})},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},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 i={topic:r.topic,request:Wr(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),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:i}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Tt.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(Tt.created,e=>{const r=Tt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.updated,e=>{const r=Tt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.deleted,e=>{const r=Tt.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 f0 extends vd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new ir.EventEmitter,this.name=Hg,this.version=Kg,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),c={target:s,expiry:n};this.expirations.set(s,c),this.checkExpiry(s,c),this.events.emit(bt.created,{target:s,expiration:c})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{this.isInitialized();const n=this.formatTarget(i);if(this.has(n)){const s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(bt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},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 Pf(e);if(typeof e=="number")return Ff(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(bt.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:i}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;Q.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(bt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Mr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(bt.created,e=>{const r=bt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(bt.expired,e=>{const r=bt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(bt.deleted,e=>{const r=bt.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 l0=Object.defineProperty,Sa=Object.getOwnPropertySymbols,d0=Object.prototype.hasOwnProperty,p0=Object.prototype.propertyIsEnumerable,xa=(t,e,r)=>e in t?l0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Oa=(t,e)=>{for(var r in e||(e={}))d0.call(e,r)&&xa(t,r,e[r]);if(Sa)for(var r of Sa(e))p0.call(e,r)&&xa(t,r,e[r]);return t};class Rn extends ud{constructor(e){super(e),this.protocol=pa,this.version=vg,this.name=Cn,this.events=new ir.EventEmitter,this.initialized=!1,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ii(xe.getDefaultLoggerOptions({level:e?.logger||_g.logger}));this.logger=xe.generateChildLogger(r,this.name),this.heartbeat=new Mr.HeartBeat,this.crypto=new Vg(this,this.logger,e?.keychain),this.history=new u0(this,this.logger),this.expirer=new f0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new ed(Oa(Oa({},bg),e?.storageOptions)),this.relayer=new s0({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new h0(this,this.logger)}static async init(e){const r=new Rn(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 Initilization Success")}catch(e){throw this.logger.warn(`Core Initilization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const g0=Rn;function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Ia=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!y0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Hr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],Aa(r))return!1;if(jt(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:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(Hr(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},Ge.prototype.addListener=function(t,e){var r;if(!jt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,jt(e.listener)?e.listener:e),this._events[t]?Hr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Hr(this._events[t])&&!this._events[t].warned&&(Aa(this._maxListeners)?r=Ge.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},Ge.prototype.on=Ge.prototype.addListener,Ge.prototype.once=function(t,e){if(!jt(e))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(t,i),r||(r=!0,e.apply(this,arguments))}return i.listener=e,this.on(t,i),this},Ge.prototype.removeListener=function(t,e){var r,i,n,s;if(!jt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],n=r.length,i=-1,r===e||jt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Hr(r)){for(s=n;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(i<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ge.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],jt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ge.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:jt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(jt(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function jt(t){return typeof t=="function"}function y0(t){return typeof t=="number"}function Hr(t){return typeof t=="object"&&t!==null}function Aa(t){return t===void 0}const Ta="wc",Ca=2,Na="client",La=`${Ta}@${Ca}:${Na}:`,Pn={name:Na,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},v0="proposal",_0="session",yi=Q.SEVEN_DAYS,b0="engine",vi={wc_sessionPropose:{req:{ttl:Q.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Q.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Q.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Q.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Q.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Q.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Q.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Q.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Q.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Q.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Q.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Q.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Q.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Q.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Q.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:Q.THIRTY_SECONDS,prompt:!1,tag:1115}}};var m0=Object.defineProperty,w0=Object.defineProperties,E0=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,D0=Object.prototype.hasOwnProperty,S0=Object.prototype.propertyIsEnumerable,Pa=(t,e,r)=>e in t?m0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wt=(t,e)=>{for(var r in e||(e={}))D0.call(e,r)&&Pa(t,r,e[r]);if(Ra)for(var r of Ra(e))S0.call(e,r)&&Pa(t,r,e[r]);return t},Fa=(t,e)=>w0(t,E0(e));class x0 extends wd{constructor(e){super(e),this.name=b0,this.events=new Ia,this.initialized=!1,this.ignoredPayloadTypes=[Qt],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(vi)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:i,requiredNamespaces:n,relays:s}=r;let c=i,h,u=!1;if(c&&(u=this.client.core.pairing.pairings.get(c).active),!c||!u){const{topic:N,uri:M}=await this.client.core.pairing.create();c=N,h=M}const f=await this.client.core.crypto.generateKeyPair(),g={requiredNamespaces:n,relays:s??[{protocol:ya}],proposer:{publicKey:f,metadata:this.client.metadata}},{reject:D,resolve:C,done:S}=er();if(this.events.once(Pe("session_connect"),async({error:N,session:M})=>{if(N)D(N);else if(M){M.self.publicKey=f;const E=Fa(Wt({},M),{requiredNamespaces:n});await this.client.session.set(M.topic,E),await this.setExpiry(M.topic,M.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:M.peer.metadata}),C(E)}}),!c){const{message:N}=V("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(N)}const w=await this.sendRequest(c,"wc_sessionPropose",g),P=Pt(Q.FIVE_MINUTES);return await this.setProposal(w,Wt({id:w,expiry:P},g)),{uri:h,approval:S}},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:i,relayProtocol:n,namespaces:s}=r,{pairingTopic:c,proposer:h,requiredNamespaces:u}=this.client.proposal.get(i),f=await this.client.core.crypto.generateKeyPair(),g=h.publicKey,D=await this.client.core.crypto.generateSharedKey(f,g),C={relay:{protocol:n??"irn"},namespaces:s,requiredNamespaces:u,controller:{publicKey:f,metadata:this.client.metadata},expiry:Pt(yi)};await this.client.core.relayer.subscribe(D);const S=await this.sendRequest(D,"wc_sessionSettle",C),{done:w,resolve:P,reject:N}=er();this.events.once(Pe("session_approve",S),({error:E})=>{E?N(E):P(this.client.session.get(D))});const M=Fa(Wt({},C),{topic:D,acknowledged:!1,self:C.controller,peer:{publicKey:h.publicKey,metadata:h.metadata},controller:f});return await this.client.session.set(D,M),await this.setExpiry(D,Pt(yi)),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:M.peer.metadata}),c&&i&&(await this.sendResult(i,c,{relay:{protocol:n??"irn"},responderPublicKey:f}),await this.client.proposal.delete(i,ze("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:c})),{topic:D,acknowledged:w}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:i,reason:n}=r,{pairingTopic:s}=this.client.proposal.get(i);s&&(await this.sendError(i,s,n),await this.client.proposal.delete(i,ze("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:i,namespaces:n}=r,s=await this.sendRequest(i,"wc_sessionUpdate",{namespaces:n}),{done:c,resolve:h,reject:u}=er();return this.events.once(Pe("session_update",s),({error:f})=>{f?u(f):h()}),await this.client.session.update(i,{namespaces:n}),{acknowledged:c}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:i}=r,n=await this.sendRequest(i,"wc_sessionExtend",{}),{done:s,resolve:c,reject:h}=er();return this.events.once(Pe("session_extend",n),({error:u})=>{u?h(u):c()}),await this.setExpiry(i,Pt(yi)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:i,request:n,topic:s}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:n,chainId:i}),{done:h,resolve:u,reject:f}=er();return this.events.once(Pe("session_request",c),({error:g,result:D})=>{g?f(g):u(D)}),await h()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n;Rt(n)?await this.sendResult(s,i,n.result):Dt(n)&&await this.sendError(s,i,n.error)},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=await this.sendRequest(i,"wc_sessionPing",{}),{done:s,resolve:c,reject:h}=er();this.events.once(Pe("session_ping",n),({error:u})=>{u?h(u):c()}),await s()}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r;await this.sendRequest(i,"wc_sessionEvent",{event:n,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:i}=r;this.client.session.keys.includes(i)?(await this.sendRequest(i,"wc_sessionDelete",ze("USER_DISCONNECTED")),await this.deleteSession(i)):await this.client.core.pairing.disconnect({topic:i})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>Jf(i,r))),this.deleteSession=async(r,i)=>{const{self:n}=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(n.publicKey),this.client.core.crypto.deleteSymKey(r),i?Promise.resolve():this.client.core.expirer.del(r)])},this.deleteProposal=async(r,i)=>{await Promise.all([this.client.proposal.delete(r,ze("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,i)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:i}),this.client.core.expirer.set(r,i)},this.setProposal=async(r,i)=>{await this.client.proposal.set(r,i),this.client.core.expirer.set(r,i.expiry)},this.sendRequest=async(r,i,n)=>{const s=Wr(i,n),c=await this.client.core.crypto.encode(r,s),h=vi[i].req;return this.client.core.history.set(r,s),this.client.core.relayer.publish(r,c,h),s.id},this.sendResult=async(r,i,n)=>{const s=kr(r,n),c=await this.client.core.crypto.encode(i,s),h=await this.client.core.history.get(i,r),u=vi[h.request.method].res;this.client.core.relayer.publish(i,c,u),await this.client.core.history.resolve(s)},this.sendError=async(r,i,n)=>{const s=wr(r,n),c=await this.client.core.crypto.encode(i,s),h=await this.client.core.history.get(i,r),u=vi[h.request.method].res;this.client.core.relayer.publish(i,c,u),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{Vt(n.expiry)&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Vt(n.expiry)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession(n)),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=r=>{const{topic:i,payload:n}=r,s=n.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(i,n);case"wc_sessionSettle":return this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return this.onSessionExtendRequest(i,n);case"wc_sessionPing":return this.onSessionPingRequest(i,n);case"wc_sessionDelete":return this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return this.onSessionRequest(i,n);case"wc_sessionEvent":return this.onSessionEventRequest(i,n);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:i,payload:n}=r,s=(await this.client.core.history.get(i,n.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,i)=>{const{params:n,id:s}=i;try{this.isValidConnect(Wt({},i.params));const c=Pt(Q.FIVE_MINUTES),h=Wt({id:s,pairingTopic:r,expiry:c},n);await this.setProposal(s,h),this.client.events.emit("session_proposal",{id:s,params:h})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionProposeResponse=async(r,i)=>{const{id:n}=i;if(Rt(i)){const{result:s}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const c=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const h=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:h});const u=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const f=await this.client.core.crypto.generateSharedKey(h,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const g=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.client.core.pairing.activate({topic:r})}else Dt(i)&&(await this.client.proposal.delete(n,ze("USER_DISCONNECTED")),this.events.emit(Pe("session_connect"),{error:i.error}))},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:c,controller:h,expiry:u,namespaces:f}=i.params,g={topic:r,relay:c,expiry:u,namespaces:f,acknowledged:!0,controller:h.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:h.publicKey,metadata:h.metadata}};await this.sendResult(i.id,r,!0),this.events.emit(Pe("session_connect"),{session:g})}catch(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;Rt(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Pe("session_approve",n),{})):Dt(i)&&(await this.client.session.delete(r,ze("USER_DISCONNECTED")),this.events.emit(Pe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{this.isValidUpdate(Wt({topic:r},n)),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i;Rt(i)?this.events.emit(Pe("session_update",n),{}):Dt(i)&&this.events.emit(Pe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Pt(yi)),await this.sendResult(n,r,!0),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError(n,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,i)=>{const{id:n}=i;Rt(i)?this.events.emit(Pe("session_extend",n),{}):Dt(i)&&this.events.emit(Pe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError(n,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,i)=>{const{id:n}=i;setTimeout(()=>{Rt(i)?this.events.emit(Pe("session_ping",n),{}):Dt(i)&&this.events.emit(Pe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),await this.sendResult(n,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:n,topic:r})}catch(s){await this.sendError(n,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidRequest(Wt({topic:r},s)),this.client.events.emit("session_request",{id:n,topic:r,params:s})}catch(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i;Rt(i)?this.events.emit(Pe("session_request",n),{result:i.result}):Dt(i)&&this.events.emit(Pe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidEmit(Wt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s})}catch(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.isValidConnect=async r=>{if(!gt(r)){const{message:h}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(h)}const{pairingTopic:i,requiredNamespaces:n,relays:s}=r;_t(i)||await this.isValidPairingTopic(i);const c=nl(n,"connect()");if(c)throw new Error(c.message);if(!sl(s,!0)){const{message:h}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(h)}},this.isValidApprove=async r=>{if(!gt(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s}=r;await this.isValidProposalId(i);const c=this.client.proposal.get(i),h=fn(n,"approve()");if(h)throw new Error(h.message);const u=Do(c.requiredNamespaces,n,"update()");if(u)throw new Error(u.message);if(!it(s,!0)){const{message:f}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(f)}},this.isValidReject=async r=>{if(!gt(r)){const{message:s}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(await this.isValidProposalId(i),!al(n)){const{message:s}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!gt(r)){const{message:f}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(f)}const{relay:i,controller:n,namespaces:s,expiry:c}=r;if(!wo(i)){const{message:f}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const h=tl(n,"onSessionSettleRequest()");if(h)throw new Error(h.message);const u=fn(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Vt(c)){const{message:f}=V("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async r=>{if(!gt(r)){const{message:u}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(u)}const{topic:i,namespaces:n}=r;await this.isValidSessionTopic(i);const s=this.client.session.get(i),c=fn(n,"update()");if(c)throw new Error(c.message);const h=Do(s.requiredNamespaces,n,"update()");if(h)throw new Error(h.message)},this.isValidExtend=async r=>{if(!gt(r)){const{message:n}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionTopic(i)},this.isValidRequest=async r=>{if(!gt(r)){const{message:h}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(h)}const{topic:i,request:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!Eo(c,s)){const{message:h}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(h)}if(!cl(n)){const{message:h}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(h)}if(!fl(c,s,n.method)){const{message:h}=V("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(h)}},this.isValidRespond=async r=>{if(!gt(r)){const{message:s}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:i,response:n}=r;if(await this.isValidSessionTopic(i),!hl(n)){const{message:s}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!gt(r)){const{message:n}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!gt(r)){const{message:h}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(h)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!Eo(c,s)){const{message:h}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(h)}if(!ul(n)){const{message:h}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}if(!ll(c,s,n.name)){const{message:h}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}},this.isValidDisconnect=async r=>{if(!gt(r)){const{message:n}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(gr.message,async e=>{const{topic:r,message:i}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(i)))return;const n=await this.client.core.crypto.decode(r,i);Ai(n)?(this.client.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Ti(n)&&(await this.client.core.history.resolve(n),this.onRelayEventResponse({topic:r,payload:n}))})}registerExpirerEvents(){this.client.core.expirer.on(bt.expired,async e=>{const{topic:r,id:i}=uo(e.target);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):i&&await this.deleteProposal(i,!0)})}isValidPairingTopic(e){if(!it(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(Vt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!it(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(Vt(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(it(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(!ol(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(Vt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class O0 extends Ln{constructor(e,r){super(e,r,v0,La),this.core=e,this.logger=r}}class I0 extends Ln{constructor(e,r){super(e,r,_0,La),this.core=e,this.logger=r}}class Fn extends md{constructor(e){super(e),this.protocol=Ta,this.version=Ca,this.name=Pn.name,this.events=new Ia.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||Pn.name,this.metadata=e?.metadata||Tf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ii(xe.getDefaultLoggerOptions({level:e?.logger||Pn.logger}));this.core=e?.core||new g0(e),this.logger=xe.generateChildLogger(r,this.name),this.session=new I0(this.core,this.logger),this.proposal=new O0(this.core,this.logger),this.engine=new x0(this)}static async init(e){const r=new Fn(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.engine.init(),this.logger.info("SignClient Initilization Success")}catch(e){throw this.logger.info("SignClient Initilization Failure"),this.logger.error(e.message),e}}}function We(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var A0=We;We.EventEmitter=We,We.prototype._events=void 0,We.prototype._maxListeners=void 0,We.defaultMaxListeners=10,We.prototype.setMaxListeners=function(t){if(!T0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},We.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Kr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],Ua(r))return!1;if($t(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:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(Kr(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},We.prototype.addListener=function(t,e){var r;if(!$t(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,$t(e.listener)?e.listener:e),this._events[t]?Kr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Kr(this._events[t])&&!this._events[t].warned&&(Ua(this._maxListeners)?r=We.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},We.prototype.on=We.prototype.addListener,We.prototype.once=function(t,e){if(!$t(e))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(t,i),r||(r=!0,e.apply(this,arguments))}return i.listener=e,this.on(t,i),this},We.prototype.removeListener=function(t,e){var r,i,n,s;if(!$t(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],n=r.length,i=-1,r===e||$t(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Kr(r)){for(s=n;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(i<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},We.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],$t(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},We.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:$t(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},We.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if($t(e))return 1;if(e)return e.length}return 0},We.listenerCount=function(t,e){return t.listenerCount(e)};function $t(t){return typeof t=="function"}function T0(t){return typeof t=="number"}function Kr(t){return typeof t=="object"&&t!==null}function Ua(t){return t===void 0}function C0(t){return typeof t<"u"&&typeof t.context<"u"}const Ct={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class N0 extends cc{constructor(e){super(),this.events=new A0.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?Qi(this.session.namespaces):uf(this.requiredNamespaces)}get accounts(){return this.session?Zi(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",i=>{r(i)}),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:i,approval:n}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(Ct.uri,{uri:i}),this.session=await n(),this.events.emit(Ct.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(i=>this.events.emit("payload",kr(e.id,i))).catch(i=>this.events.emit("payload",wr(e.id,i.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,i)=>{this.events.once("register_error",n=>{i(n)}),this.events.once(Ct.init,()=>{if(typeof this.client>"u")return i(new Error("Sign Client not initialized"));r(this.client)})});if(C0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Fn.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Ct.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(Ct.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(Ct.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(Ct.deleted,this.session),this.session=void 0)}))}}const L0=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],R0=["chainChanged","accountsChanged"];function Ma(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function ja(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Un([t])]),r}function Un(t){return Number(t[0].split(":")[1])}class P0{constructor(e){this.events=new _r.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Ma(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Un(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(i=>r(null,i)).catch(i=>r(i,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(Ct.created,e=>{const r=Qi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Zi(e.namespaces,[this.namespace]);this.setAccounts(i)}),this.signer.connection.on(Ct.updated,e=>{const r=Qi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Zi(e.namespaces,[this.namespace]);i!==this.accounts&&this.setAccounts(i)}),this.signer.connection.on(Ct.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 N0({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new Ci(r)}setHttpProvider(e){const r=ja(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new Ci(new gc(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(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i)).filter(i=>i!==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,i,n]=e.split(":");return{chainId:`${r}:${i}`,address:n}}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)}}Et.default=P0,Et.getEthereumChainId=Un,Et.getRpcConfig=Ma,Et.getRpcUrl=ja,Et.signerEvents=R0,Et.signerMethods=L0,Object.defineProperty(Et,"__esModule",{value:!0})});
|
|
1
|
+
(function(Et,He){typeof exports=="object"&&typeof module<"u"?He(exports):typeof define=="function"&&define.amd?define(["exports"],He):(Et=typeof globalThis<"u"?globalThis:Et||self,He(Et["@walletconnect/ethereum-provider"]={}))})(this,function(Et){"use strict";var He=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yc(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}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var wr=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!vc(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,n,i,s,a;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Er(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var o=new Error('Uncaught, unspecified "error" event. ('+e+")");throw o.context=e,o}if(r=this._events[t],Ji(r))return!1;if(Lt(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(Er(r))for(i=Array.prototype.slice.call(arguments,1),a=r.slice(),n=a.length,s=0;s<n;s++)a[s].apply(this,i);return!0},qe.prototype.addListener=function(t,e){var r;if(!Lt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Lt(e.listener)?e.listener:e),this._events[t]?Er(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Er(this._events[t])&&!this._events[t].warned&&(Ji(this._maxListeners)?r=qe.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},qe.prototype.on=qe.prototype.addListener,qe.prototype.once=function(t,e){if(!Lt(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},qe.prototype.removeListener=function(t,e){var r,n,i,s;if(!Lt(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||Lt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Er(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},qe.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],Lt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},qe.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Lt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},qe.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Lt(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Lt(t){return typeof t=="function"}function vc(t){return typeof t=="number"}function Er(t){return typeof t=="object"&&t!==null}function Ji(t){return t===void 0}const bc="PARSE_ERROR",mc="INVALID_REQUEST",wc="METHOD_NOT_FOUND",Ec="INVALID_PARAMS",Xi="INTERNAL_ERROR",Nn="SERVER_ERROR",Dc=[-32700,-32600,-32601,-32602,-32603],Dr={[bc]:{code:-32700,message:"Parse error"},[mc]:{code:-32600,message:"Invalid Request"},[wc]:{code:-32601,message:"Method not found"},[Ec]:{code:-32602,message:"Invalid params"},[Xi]:{code:-32603,message:"Internal error"},[Nn]:{code:-32e3,message:"Server error"}},Zi=Nn;function Sc(t){return Dc.includes(t)}function Qi(t){return Object.keys(Dr).includes(t)?Dr[t]:Dr[Zi]}function xc(t){const e=Object.values(Dr).find(r=>r.code===t);return e||Dr[Zi]}function es(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var ts={};/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */var Rn=function(t,e){return Rn=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])},Rn(t,e)};function Oc(t,e){Rn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Fn=function(){return Fn=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},Fn.apply(this,arguments)};function Ic(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 Ac(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Tc(t,e){return function(r,n){e(r,n,t)}}function Cc(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Pc(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{h(n.next(l))}catch(D){a(D)}}function f(l){try{h(n.throw(l))}catch(D){a(D)}}function h(l){l.done?s(l.value):i(l.value).then(o,f)}h((n=n.apply(t,e||[])).next())})}function Lc(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(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 Nc(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Rc(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Un(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 rs(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function Fc(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(rs(arguments[e]));return t}function Uc(){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],a=0,o=s.length;a<o;a++,i++)n[i]=s[a];return n}function Sr(t){return this instanceof Sr?(this.v=t,this):new Sr(t)}function $c(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(E){n[E]&&(i[E]=function(m){return new Promise(function(b,R){s.push([E,m,b,R])>1||o(E,m)})})}function o(E,m){try{f(n[E](m))}catch(b){D(s[0][3],b)}}function f(E){E.value instanceof Sr?Promise.resolve(E.value.v).then(h,l):D(s[0][2],E)}function h(E){o("next",E)}function l(E){o("throw",E)}function D(E,m){E(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Mc(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(a){return(r=!r)?{value:Sr(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function jc(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 Un=="function"?Un(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(a){return new Promise(function(o,f){a=t[s](a),i(o,f,a.done,a.value)})}}function i(s,a,o,f){Promise.resolve(f).then(function(h){s({value:h,done:o})},a)}}function Bc(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function zc(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 Hc(t){return t&&t.__esModule?t:{default:t}}function qc(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Kc(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 Vc=Object.freeze({__proto__:null,__extends:Oc,get __assign(){return Fn},__rest:Ic,__decorate:Ac,__param:Tc,__metadata:Cc,__awaiter:Pc,__generator:Lc,__createBinding:Nc,__exportStar:Rc,__values:Un,__read:rs,__spread:Fc,__spreadArrays:Uc,__await:Sr,__asyncGenerator:$c,__asyncDelegator:Mc,__asyncValues:jc,__makeTemplateObject:Bc,__importStar:zc,__importDefault:Hc,__classPrivateFieldGet:qc,__classPrivateFieldSet:Kc}),Gc=Zt(Vc),Nt={},ns;function kc(){if(ns)return Nt;ns=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.isBrowserCryptoAvailable=Nt.getSubtleCrypto=Nt.getBrowerCrypto=void 0;function t(){return He?.crypto||He?.msCrypto||{}}Nt.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Nt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Nt.isBrowserCryptoAvailable=r,Nt}var Rt={},is;function Wc(){if(is)return Rt;is=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=Gc;e.__exportStar(kc(),t),e.__exportStar(Wc(),t)})(ts);function Yc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function nn(t,e,r){return{id:r||Yc(),jsonrpc:"2.0",method:t,params:e}}function sn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function xr(t,e,r){return{id:t,jsonrpc:"2.0",error:Jc(e,r)}}function Jc(t,e){return typeof t>"u"?Qi(Xi):(typeof t=="string"&&(t=Object.assign(Object.assign({},Qi(Nn)),{message:t})),typeof e<"u"&&(t.data=e),Sc(t.code)&&(t=xc(t.code)),t)}class ss{}class Xc extends ss{constructor(e){super()}}class Zc extends ss{constructor(){super()}}class Qc extends Zc{constructor(e){super()}}const eu="^https?:",tu="^wss?:";function ru(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function os(t,e){const r=ru(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function as(t){return os(t,eu)}function cs(t){return os(t,tu)}function nu(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function us(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function $n(t){return us(t)&&"method"in t}function Mn(t){return us(t)&&(Ft(t)||Dt(t))}function Ft(t){return"result"in t}function Dt(t){return"error"in t}class jn extends Qc{constructor(e){super(e),this.events=new wr.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(nn(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=>{Dt(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),Mn(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 Bn={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(a){var o={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(o.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 E(g){return typeof g!="string"&&(g=String(g)),g}function m(g){var y={next:function(){var U=g.shift();return{done:U===void 0,value:U}}};return o.iterable&&(y[Symbol.iterator]=function(){return y}),y}function b(g){this.map={},g instanceof b?g.forEach(function(y,U){this.append(U,y)},this):Array.isArray(g)?g.forEach(function(y){this.append(y[0],y[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(y){this.append(y,g[y])},this)}b.prototype.append=function(g,y){g=D(g),y=E(y);var U=this.map[g];this.map[g]=U?U+", "+y:y},b.prototype.delete=function(g){delete this.map[D(g)]},b.prototype.get=function(g){return g=D(g),this.has(g)?this.map[g]:null},b.prototype.has=function(g){return this.map.hasOwnProperty(D(g))},b.prototype.set=function(g,y){this.map[D(g)]=E(y)},b.prototype.forEach=function(g,y){for(var U in this.map)this.map.hasOwnProperty(U)&&g.call(y,this.map[U],U,this)},b.prototype.keys=function(){var g=[];return this.forEach(function(y,U){g.push(U)}),m(g)},b.prototype.values=function(){var g=[];return this.forEach(function(y){g.push(y)}),m(g)},b.prototype.entries=function(){var g=[];return this.forEach(function(y,U){g.push([U,y])}),m(g)},o.iterable&&(b.prototype[Symbol.iterator]=b.prototype.entries);function R(g){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}function L(g){return new Promise(function(y,U){g.onload=function(){y(g.result)},g.onerror=function(){U(g.error)}})}function B(g){var y=new FileReader,U=L(y);return y.readAsArrayBuffer(g),U}function x(g){var y=new FileReader,U=L(y);return y.readAsText(g),U}function A(g){for(var y=new Uint8Array(g),U=new Array(y.length),$=0;$<y.length;$++)U[$]=String.fromCharCode(y[$]);return U.join("")}function _(g){if(g.slice)return g.slice(0);var y=new Uint8Array(g.byteLength);return y.set(new Uint8Array(g)),y.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(g){this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:o.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:o.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():o.arrayBuffer&&o.blob&&f(g)?(this._bodyArrayBuffer=_(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=_(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):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.blob&&(this.blob=function(){var g=R(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?R(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var g=R(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)},o.formData&&(this.formData=function(){return this.text().then(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function c(g){var y=g.toUpperCase();return w.indexOf(y)>-1?y:g}function d(g,y){y=y||{};var U=y.body;if(g instanceof d){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,y.headers||(this.headers=new b(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=y.credentials||this.credentials||"same-origin",(y.headers||!this.headers)&&(this.headers=new b(y.headers)),this.method=c(y.method||this.method||"GET"),this.mode=y.mode||this.mode||null,this.signal=y.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 y=new FormData;return g.trim().split("&").forEach(function(U){if(U){var $=U.split("="),N=$.shift().replace(/\+/g," "),P=$.join("=").replace(/\+/g," ");y.append(decodeURIComponent(N),decodeURIComponent(P))}}),y}function H(g){var y=new b,U=g.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function($){var N=$.split(":"),P=N.shift().trim();if(P){var j=N.join(":").trim();y.append(P,j)}}),y}S.call(d.prototype);function G(g,y){y||(y={}),this.type="default",this.status=y.status===void 0?200:y.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in y?y.statusText:"OK",this.headers=new b(y.headers),this.url=y.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 b(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,y){if(J.indexOf(y)===-1)throw new RangeError("Invalid status code");return new G(null,{status:y,headers:{location:g}})},a.DOMException=s.DOMException;try{new a.DOMException}catch{a.DOMException=function(y,U){this.message=y,this.name=U;var $=Error(y);this.stack=$.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function X(g,y){return new Promise(function(U,$){var N=new d(g,y);if(N.signal&&N.signal.aborted)return $(new a.DOMException("Aborted","AbortError"));var P=new XMLHttpRequest;function j(){P.abort()}P.onload=function(){var z={status:P.status,statusText:P.statusText,headers:H(P.getAllResponseHeaders()||"")};z.url="responseURL"in P?P.responseURL:z.headers.get("X-Request-URL");var Q="response"in P?P.response:P.responseText;U(new G(Q,z))},P.onerror=function(){$(new TypeError("Network request failed"))},P.ontimeout=function(){$(new TypeError("Network request failed"))},P.onabort=function(){$(new a.DOMException("Aborted","AbortError"))},P.open(N.method,N.url,!0),N.credentials==="include"?P.withCredentials=!0:N.credentials==="omit"&&(P.withCredentials=!1),"responseType"in P&&o.blob&&(P.responseType="blob"),N.headers.forEach(function(z,Q){P.setRequestHeader(Q,z)}),N.signal&&(N.signal.addEventListener("abort",j),P.onreadystatechange=function(){P.readyState===4&&N.signal.removeEventListener("abort",j)}),P.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=b,s.Request=d,s.Response=G),a.Headers=b,a.Request=d,a.Response=G,a.fetch=X,Object.defineProperty(a,"__esModule",{value:!0}),a})({})})(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})(Bn,Bn.exports);var hs=yc(Bn.exports);function zn(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 Or(t){return typeof t=="string"?t:JSON.stringify(t)}const fs={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},ls=10;class iu{constructor(e){if(this.url=e,this.events=new wr.EventEmitter,this.isAvailable=!1,this.registering=!1,!as(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=Or(e),s=await(await hs(this.url,Object.assign(Object.assign({},fs),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!as(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=Or({id:1,jsonrpc:"2.0",method:"test",params:[]});await hs(e,Object.assign(Object.assign({},fs),{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"?zn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=xr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return es(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ls&&this.events.setMaxListeners(ls)}}var Hn={},on={},re={},ds={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(o,f){var h=o>>>16&65535,l=o&65535,D=f>>>16&65535,E=f&65535;return l*E+(h*E+l*D<<16>>>0)|0}t.mul=Math.imul||e;function r(o,f){return o+f|0}t.add=r;function n(o,f){return o-f|0}t.sub=n;function i(o,f){return o<<f|o>>>32-f}t.rotl=i;function s(o,f){return o<<32-f|o>>>f}t.rotr=s;function a(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o}t.isInteger=Number.isInteger||a,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(o){return t.isInteger(o)&&o>=-t.MAX_SAFE_INTEGER&&o<=t.MAX_SAFE_INTEGER}})(ds),Object.defineProperty(re,"__esModule",{value:!0});var ps=ds;function su(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=su;function ou(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=ou;function au(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=au;function cu(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=cu;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 _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 qn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=qn;function Kn(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=Kn;function Vn(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Vn;function Gn(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=Gn;function an(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=an,re.writeInt32BE=an;function cn(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=cn,re.writeInt32LE=cn;function uu(t,e){e===void 0&&(e=0);var r=qn(t,e),n=qn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=uu;function hu(t,e){e===void 0&&(e=0);var r=Kn(t,e),n=Kn(t,e+4);return r*4294967296+n}re.readUint64BE=hu;function fu(t,e){e===void 0&&(e=0);var r=Vn(t,e),n=Vn(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=fu;function lu(t,e){e===void 0&&(e=0);var r=Gn(t,e),n=Gn(t,e+4);return n*4294967296+r}re.readUint64LE=lu;function ys(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),an(t/4294967296>>>0,e,r),an(t>>>0,e,r+4),e}re.writeUint64BE=ys,re.writeInt64BE=ys;function vs(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),cn(t>>>0,e,r),cn(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=vs,re.writeInt64LE=vs;function du(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=du;function pu(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=pu;function gu(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(!ps.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=gu;function _u(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(!ps.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=_u;function yu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=yu;function vu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=vu;function bu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=bu;function mu(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=mu;function wu(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=wu;function Eu(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=Eu;function Du(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=Du;function Su(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=Su;var gt={};Object.defineProperty(gt,"__esModule",{value:!0});function xu(t){for(var e=0;e<t.length;e++)t[e]=0;return t}gt.wipe=xu,Object.defineProperty(on,"__esModule",{value:!0});var ot=re,kn=gt,Ou=20;function Iu(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,a=1797285236,o=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],E=r[23]<<24|r[22]<<16|r[21]<<8|r[20],m=r[27]<<24|r[26]<<16|r[25]<<8|r[24],b=r[31]<<24|r[30]<<16|r[29]<<8|r[28],R=e[3]<<24|e[2]<<16|e[1]<<8|e[0],L=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,_=i,S=s,w=a,c=o,d=f,M=h,H=l,G=D,J=E,X=m,g=b,y=R,U=L,$=B,N=x,P=0;P<Ou;P+=2)A=A+c|0,y^=A,y=y>>>32-16|y<<16,G=G+y|0,c^=G,c=c>>>32-12|c<<12,_=_+d|0,U^=_,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,w=w+H|0,N^=w,N=N>>>32-16|N<<16,g=g+N|0,H^=g,H=H>>>32-12|H<<12,S=S+M|0,$^=S,$=$>>>32-8|$<<8,X=X+$|0,M^=X,M=M>>>32-7|M<<7,w=w+H|0,N^=w,N=N>>>32-8|N<<8,g=g+N|0,H^=g,H=H>>>32-7|H<<7,_=_+d|0,U^=_,U=U>>>32-8|U<<8,J=J+U|0,d^=J,d=d>>>32-7|d<<7,A=A+c|0,y^=A,y=y>>>32-8|y<<8,G=G+y|0,c^=G,c=c>>>32-7|c<<7,A=A+d|0,N^=A,N=N>>>32-16|N<<16,X=X+N|0,d^=X,d=d>>>32-12|d<<12,_=_+M|0,y^=_,y=y>>>32-16|y<<16,g=g+y|0,M^=g,M=M>>>32-12|M<<12,S=S+H|0,U^=S,U=U>>>32-16|U<<16,G=G+U|0,H^=G,H=H>>>32-12|H<<12,w=w+c|0,$^=w,$=$>>>32-16|$<<16,J=J+$|0,c^=J,c=c>>>32-12|c<<12,S=S+H|0,U^=S,U=U>>>32-8|U<<8,G=G+U|0,H^=G,H=H>>>32-7|H<<7,w=w+c|0,$^=w,$=$>>>32-8|$<<8,J=J+$|0,c^=J,c=c>>>32-7|c<<7,_=_+M|0,y^=_,y=y>>>32-8|y<<8,g=g+y|0,M^=g,M=M>>>32-7|M<<7,A=A+d|0,N^=A,N=N>>>32-8|N<<8,X=X+N|0,d^=X,d=d>>>32-7|d<<7;ot.writeUint32LE(A+n|0,t,0),ot.writeUint32LE(_+i|0,t,4),ot.writeUint32LE(S+s|0,t,8),ot.writeUint32LE(w+a|0,t,12),ot.writeUint32LE(c+o|0,t,16),ot.writeUint32LE(d+f|0,t,20),ot.writeUint32LE(M+h|0,t,24),ot.writeUint32LE(H+l|0,t,28),ot.writeUint32LE(G+D|0,t,32),ot.writeUint32LE(J+E|0,t,36),ot.writeUint32LE(X+m|0,t,40),ot.writeUint32LE(g+b|0,t,44),ot.writeUint32LE(y+R|0,t,48),ot.writeUint32LE(U+L|0,t,52),ot.writeUint32LE($+B|0,t,56),ot.writeUint32LE(N+x|0,t,60)}function bs(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,a;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),a=s.length-e.length,s.set(e,a)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,a=i}for(var o=new Uint8Array(64),f=0;f<r.length;f+=64){Iu(o,s,t);for(var h=f;h<f+64&&h<r.length;h++)n[h]=r[h]^o[h-f];Tu(s,0,a)}return kn.wipe(o),i===0&&kn.wipe(s),n}on.streamXOR=bs;function Au(t,e,r,n){return n===void 0&&(n=0),kn.wipe(r),bs(t,e,r,r,n)}on.stream=Au;function Tu(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={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0});function Cu(t,e,r){return~(t-1)&e|t-1&r}Kt.select=Cu;function Pu(t,e){return(t|0)-(e|0)-1>>>31&1}Kt.lessOrEqual=Pu;function ws(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}Kt.compare=ws;function Lu(t,e){return t.length===0||e.length===0?!1:ws(t,e)!==0}Kt.equal=Lu,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Kt,r=gt;t.DIGEST_LENGTH=16;var n=function(){function a(o){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=o[0]|o[1]<<8;this._r[0]=f&8191;var h=o[2]|o[3]<<8;this._r[1]=(f>>>13|h<<3)&8191;var l=o[4]|o[5]<<8;this._r[2]=(h>>>10|l<<6)&7939;var D=o[6]|o[7]<<8;this._r[3]=(l>>>7|D<<9)&8191;var E=o[8]|o[9]<<8;this._r[4]=(D>>>4|E<<12)&255,this._r[5]=E>>>1&8190;var m=o[10]|o[11]<<8;this._r[6]=(E>>>14|m<<2)&8191;var b=o[12]|o[13]<<8;this._r[7]=(m>>>11|b<<5)&8065;var R=o[14]|o[15]<<8;this._r[8]=(b>>>8|R<<8)&8191,this._r[9]=R>>>5&127,this._pad[0]=o[16]|o[17]<<8,this._pad[1]=o[18]|o[19]<<8,this._pad[2]=o[20]|o[21]<<8,this._pad[3]=o[22]|o[23]<<8,this._pad[4]=o[24]|o[25]<<8,this._pad[5]=o[26]|o[27]<<8,this._pad[6]=o[28]|o[29]<<8,this._pad[7]=o[30]|o[31]<<8}return a.prototype._blocks=function(o,f,h){for(var l=this._fin?0:2048,D=this._h[0],E=this._h[1],m=this._h[2],b=this._h[3],R=this._h[4],L=this._h[5],B=this._h[6],x=this._h[7],A=this._h[8],_=this._h[9],S=this._r[0],w=this._r[1],c=this._r[2],d=this._r[3],M=this._r[4],H=this._r[5],G=this._r[6],J=this._r[7],X=this._r[8],g=this._r[9];h>=16;){var y=o[f+0]|o[f+1]<<8;D+=y&8191;var U=o[f+2]|o[f+3]<<8;E+=(y>>>13|U<<3)&8191;var $=o[f+4]|o[f+5]<<8;m+=(U>>>10|$<<6)&8191;var N=o[f+6]|o[f+7]<<8;b+=($>>>7|N<<9)&8191;var P=o[f+8]|o[f+9]<<8;R+=(N>>>4|P<<12)&8191,L+=P>>>1&8191;var j=o[f+10]|o[f+11]<<8;B+=(P>>>14|j<<2)&8191;var z=o[f+12]|o[f+13]<<8;x+=(j>>>11|z<<5)&8191;var Q=o[f+14]|o[f+15]<<8;A+=(z>>>8|Q<<8)&8191,_+=Q>>>5|l;var q=0,ee=q;ee+=D*S,ee+=E*(5*g),ee+=m*(5*X),ee+=b*(5*J),ee+=R*(5*G),q=ee>>>13,ee&=8191,ee+=L*(5*H),ee+=B*(5*M),ee+=x*(5*d),ee+=A*(5*c),ee+=_*(5*w),q+=ee>>>13,ee&=8191;var Y=q;Y+=D*w,Y+=E*S,Y+=m*(5*g),Y+=b*(5*X),Y+=R*(5*J),q=Y>>>13,Y&=8191,Y+=L*(5*G),Y+=B*(5*H),Y+=x*(5*M),Y+=A*(5*d),Y+=_*(5*c),q+=Y>>>13,Y&=8191;var ae=q;ae+=D*c,ae+=E*w,ae+=m*S,ae+=b*(5*g),ae+=R*(5*X),q=ae>>>13,ae&=8191,ae+=L*(5*J),ae+=B*(5*G),ae+=x*(5*H),ae+=A*(5*M),ae+=_*(5*d),q+=ae>>>13,ae&=8191;var C=q;C+=D*d,C+=E*c,C+=m*w,C+=b*S,C+=R*(5*g),q=C>>>13,C&=8191,C+=L*(5*X),C+=B*(5*J),C+=x*(5*G),C+=A*(5*H),C+=_*(5*M),q+=C>>>13,C&=8191;var T=q;T+=D*M,T+=E*d,T+=m*c,T+=b*w,T+=R*S,q=T>>>13,T&=8191,T+=L*(5*g),T+=B*(5*X),T+=x*(5*J),T+=A*(5*G),T+=_*(5*H),q+=T>>>13,T&=8191;var O=q;O+=D*H,O+=E*M,O+=m*d,O+=b*c,O+=R*w,q=O>>>13,O&=8191,O+=L*S,O+=B*(5*g),O+=x*(5*X),O+=A*(5*J),O+=_*(5*G),q+=O>>>13,O&=8191;var u=q;u+=D*G,u+=E*H,u+=m*M,u+=b*d,u+=R*c,q=u>>>13,u&=8191,u+=L*w,u+=B*S,u+=x*(5*g),u+=A*(5*X),u+=_*(5*J),q+=u>>>13,u&=8191;var v=q;v+=D*J,v+=E*G,v+=m*H,v+=b*M,v+=R*d,q=v>>>13,v&=8191,v+=L*c,v+=B*w,v+=x*S,v+=A*(5*g),v+=_*(5*X),q+=v>>>13,v&=8191;var K=q;K+=D*X,K+=E*J,K+=m*G,K+=b*H,K+=R*M,q=K>>>13,K&=8191,K+=L*d,K+=B*c,K+=x*w,K+=A*S,K+=_*(5*g),q+=K>>>13,K&=8191;var k=q;k+=D*g,k+=E*X,k+=m*J,k+=b*G,k+=R*H,q=k>>>13,k&=8191,k+=L*M,k+=B*d,k+=x*c,k+=A*w,k+=_*S,q+=k>>>13,k&=8191,q=(q<<2)+q|0,q=q+ee|0,ee=q&8191,q=q>>>13,Y+=q,D=ee,E=Y,m=ae,b=C,R=T,L=O,B=u,x=v,A=K,_=k,f+=16,h-=16}this._h[0]=D,this._h[1]=E,this._h[2]=m,this._h[3]=b,this._h[4]=R,this._h[5]=L,this._h[6]=B,this._h[7]=x,this._h[8]=A,this._h[9]=_},a.prototype.finish=function(o,f){f===void 0&&(f=0);var h=new Uint16Array(10),l,D,E,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,E=this._h[0]+this._pad[0],this._h[0]=E&65535,m=1;m<8;m++)E=(this._h[m]+this._pad[m]|0)+(E>>>16)|0,this._h[m]=E&65535;return o[f+0]=this._h[0]>>>0,o[f+1]=this._h[0]>>>8,o[f+2]=this._h[1]>>>0,o[f+3]=this._h[1]>>>8,o[f+4]=this._h[2]>>>0,o[f+5]=this._h[2]>>>8,o[f+6]=this._h[3]>>>0,o[f+7]=this._h[3]>>>8,o[f+8]=this._h[4]>>>0,o[f+9]=this._h[4]>>>8,o[f+10]=this._h[5]>>>0,o[f+11]=this._h[5]>>>8,o[f+12]=this._h[6]>>>0,o[f+13]=this._h[6]>>>8,o[f+14]=this._h[7]>>>0,o[f+15]=this._h[7]>>>8,this._finished=!0,this},a.prototype.update=function(o){var f=0,h=o.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]=o[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(o,f,l),f+=l,h-=l),h){for(var D=0;D<h;D++)this._buffer[this._leftover+D]=o[f+D];this._leftover+=h}return this},a.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var o=new Uint8Array(16);return this.finish(o),o},a.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},a}();t.Poly1305=n;function i(a,o){var f=new n(a);f.update(o);var h=f.digest();return f.clean(),h}t.oneTimeAuth=i;function s(a,o){return a.length!==t.DIGEST_LENGTH||o.length!==t.DIGEST_LENGTH?!1:e.equal(a,o)}t.equal=s}(ms),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=on,r=ms,n=gt,i=re,s=Kt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var a=new Uint8Array(16),o=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,E){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var m=new Uint8Array(16);m.set(h,m.length-h.length);var b=new Uint8Array(32);e.stream(this._key,m,b,4);var R=l.length+this.tagLength,L;if(E){if(E.length!==R)throw new Error("ChaCha20Poly1305: incorrect destination length");L=E}else L=new Uint8Array(R);return e.streamXOR(this._key,m,l,L,4),this._authenticate(L.subarray(L.length-this.tagLength,L.length),b,L.subarray(0,L.length-this.tagLength),D),n.wipe(m),L},f.prototype.open=function(h,l,D,E){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 b=new Uint8Array(32);e.stream(this._key,m,b,4);var R=new Uint8Array(this.tagLength);if(this._authenticate(R,b,l.subarray(0,l.length-this.tagLength),D),!s.equal(R,l.subarray(l.length-this.tagLength,l.length)))return null;var L=l.length-this.tagLength,B;if(E){if(E.length!==L)throw new Error("ChaCha20Poly1305: incorrect destination length");B=E}else B=new Uint8Array(L);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,E){var m=new r.Poly1305(l);E&&(m.update(E),E.length%16>0&&m.update(a.subarray(E.length%16))),m.update(D),D.length%16>0&&m.update(a.subarray(D.length%16));var b=new Uint8Array(8);E&&i.writeUint64LE(E.length,b),m.update(b),i.writeUint64LE(D.length,b),m.update(b);for(var R=m.digest(),L=0;L<R.length;L++)h[L]=R[L];m.clean(),n.wipe(R),n.wipe(b)},f}();t.ChaCha20Poly1305=o}(Hn);var Es={},Ir={},Wn={};Object.defineProperty(Wn,"__esModule",{value:!0});function Nu(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Wn.isSerializableHash=Nu,Object.defineProperty(Ir,"__esModule",{value:!0});var Ot=Wn,Ru=Kt,Fu=gt,Ds=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),Ot.isSerializableHash(this._inner)&&Ot.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Fu.wipe(n)}return t.prototype.reset=function(){if(!Ot.isSerializableHash(this._inner)||!Ot.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(){Ot.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ot.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(!Ot.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(!Ot.isSerializableHash(this._inner)||!Ot.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(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();Ir.HMAC=Ds;function Uu(t,e,r){var n=new Ds(t,e);n.update(r);var i=n.digest();return n.clean(),i}Ir.hmac=Uu,Ir.equal=Ru.equal,Object.defineProperty(Es,"__esModule",{value:!0});var Ss=Ir,xs=gt,$u=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=Ss.hmac(this._hash,n,r);this._hmac=new Ss.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(),xs.wipe(this._buffer),xs.wipe(this._counter),this._bufpos=0},t}(),Mu=Es.HKDF=$u,lr={},un={},hn={};Object.defineProperty(hn,"__esModule",{value:!0}),hn.BrowserRandomSource=void 0;const Os=65536;class ju{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+=Os)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,Os)));return r}}hn.BrowserRandomSource=ju;function Bu(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 fn={},zu={},Hu=Object.freeze({__proto__:null,default:zu}),qu=Zt(Hu);Object.defineProperty(fn,"__esModule",{value:!0}),fn.NodeRandomSource=void 0;const Ku=gt;class Vu{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Bu<"u"){const e=qu;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,Ku.wipe)(r),n}}fn.NodeRandomSource=Vu,Object.defineProperty(un,"__esModule",{value:!0}),un.SystemRandomSource=void 0;const Gu=hn,ku=fn;class Wu{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Gu.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new ku.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)}}un.SystemRandomSource=Wu,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=un,r=re,n=gt;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 a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function o(h,l=a,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 E="";const m=l.length,b=256-256%m;for(;h>0;){const R=i(Math.ceil(h*256/b),D);for(let L=0;L<R.length&&h>0;L++){const B=R[L];B<b&&(E+=l.charAt(B%m),h--)}(0,n.wipe)(R)}return E}t.randomString=o;function f(h,l=a,D=t.defaultRandomSource){const E=Math.ceil(h/(Math.log(l.length)/Math.LN2));return o(E,l,D)}t.randomStringForEntropy=f}(lr);var ln={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=gt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function o(){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 o.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},o.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},o.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},o.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},o.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,E=h<<3,m=h%64<56?64:128;this._buffer[l]=128;for(var b=l+1;b<m-8;b++)this._buffer[b]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(E,this._buffer,m-4),s(this._temp,this._state,this._buffer,0,m),this._finished=!0}for(var b=0;b<this.digestLength/4;b++)e.writeUint32BE(this._state[b],f,b*4);return this},o.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},o.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}},o.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},o.prototype.cleanSavedState=function(f){r.wipe(f.state),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},o}();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(o,f,h,l,D){for(;D>=64;){for(var E=f[0],m=f[1],b=f[2],R=f[3],L=f[4],B=f[5],x=f[6],A=f[7],_=0;_<16;_++){var S=l+_*4;o[_]=e.readUint32BE(h,S)}for(var _=16;_<64;_++){var w=o[_-2],c=(w>>>17|w<<32-17)^(w>>>19|w<<32-19)^w>>>10;w=o[_-15];var d=(w>>>7|w<<32-7)^(w>>>18|w<<32-18)^w>>>3;o[_]=(c+o[_-7]|0)+(d+o[_-16]|0)}for(var _=0;_<64;_++){var c=(((L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7))+(L&B^~L&x)|0)+(A+(i[_]+o[_]|0)|0)|0,d=((E>>>2|E<<32-2)^(E>>>13|E<<32-13)^(E>>>22|E<<32-22))+(E&m^E&b^m&b)|0;A=x,x=B,B=L,L=R+c|0,R=b,b=m,m=E,E=c+d|0}f[0]+=E,f[1]+=m,f[2]+=b,f[3]+=R,f[4]+=L,f[5]+=B,f[6]+=x,f[7]+=A,l+=64,D-=64}return l}function a(o){var f=new n;f.update(o);var h=f.digest();return f.clean(),h}t.hash=a})(ln);var Yn={};(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=gt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(_){const S=new Float64Array(16);if(_)for(let w=0;w<_.length;w++)S[w]=_[w];return S}const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function a(_){let S=1;for(let w=0;w<16;w++){let c=_[w]+S+65535;S=Math.floor(c/65536),_[w]=c-S*65536}_[0]+=S-1+37*(S-1)}function o(_,S,w){const c=~(w-1);for(let d=0;d<16;d++){const M=c&(_[d]^S[d]);_[d]^=M,S[d]^=M}}function f(_,S){const w=n(),c=n();for(let d=0;d<16;d++)c[d]=S[d];a(c),a(c),a(c);for(let d=0;d<2;d++){w[0]=c[0]-65517;for(let H=1;H<15;H++)w[H]=c[H]-65535-(w[H-1]>>16&1),w[H-1]&=65535;w[15]=c[15]-32767-(w[14]>>16&1);const M=w[15]>>16&1;w[14]&=65535,o(c,w,1-M)}for(let d=0;d<16;d++)_[2*d]=c[d]&255,_[2*d+1]=c[d]>>8}function h(_,S){for(let w=0;w<16;w++)_[w]=S[2*w]+(S[2*w+1]<<8);_[15]&=32767}function l(_,S,w){for(let c=0;c<16;c++)_[c]=S[c]+w[c]}function D(_,S,w){for(let c=0;c<16;c++)_[c]=S[c]-w[c]}function E(_,S,w){let c,d,M=0,H=0,G=0,J=0,X=0,g=0,y=0,U=0,$=0,N=0,P=0,j=0,z=0,Q=0,q=0,ee=0,Y=0,ae=0,C=0,T=0,O=0,u=0,v=0,K=0,k=0,fe=0,ye=0,de=0,me=0,Re=0,Te=0,_e=w[0],pe=w[1],le=w[2],ue=w[3],ce=w[4],oe=w[5],se=w[6],te=w[7],he=w[8],ge=w[9],ne=w[10],ve=w[11],be=w[12],Ee=w[13],De=w[14],we=w[15];c=S[0],M+=c*_e,H+=c*pe,G+=c*le,J+=c*ue,X+=c*ce,g+=c*oe,y+=c*se,U+=c*te,$+=c*he,N+=c*ge,P+=c*ne,j+=c*ve,z+=c*be,Q+=c*Ee,q+=c*De,ee+=c*we,c=S[1],H+=c*_e,G+=c*pe,J+=c*le,X+=c*ue,g+=c*ce,y+=c*oe,U+=c*se,$+=c*te,N+=c*he,P+=c*ge,j+=c*ne,z+=c*ve,Q+=c*be,q+=c*Ee,ee+=c*De,Y+=c*we,c=S[2],G+=c*_e,J+=c*pe,X+=c*le,g+=c*ue,y+=c*ce,U+=c*oe,$+=c*se,N+=c*te,P+=c*he,j+=c*ge,z+=c*ne,Q+=c*ve,q+=c*be,ee+=c*Ee,Y+=c*De,ae+=c*we,c=S[3],J+=c*_e,X+=c*pe,g+=c*le,y+=c*ue,U+=c*ce,$+=c*oe,N+=c*se,P+=c*te,j+=c*he,z+=c*ge,Q+=c*ne,q+=c*ve,ee+=c*be,Y+=c*Ee,ae+=c*De,C+=c*we,c=S[4],X+=c*_e,g+=c*pe,y+=c*le,U+=c*ue,$+=c*ce,N+=c*oe,P+=c*se,j+=c*te,z+=c*he,Q+=c*ge,q+=c*ne,ee+=c*ve,Y+=c*be,ae+=c*Ee,C+=c*De,T+=c*we,c=S[5],g+=c*_e,y+=c*pe,U+=c*le,$+=c*ue,N+=c*ce,P+=c*oe,j+=c*se,z+=c*te,Q+=c*he,q+=c*ge,ee+=c*ne,Y+=c*ve,ae+=c*be,C+=c*Ee,T+=c*De,O+=c*we,c=S[6],y+=c*_e,U+=c*pe,$+=c*le,N+=c*ue,P+=c*ce,j+=c*oe,z+=c*se,Q+=c*te,q+=c*he,ee+=c*ge,Y+=c*ne,ae+=c*ve,C+=c*be,T+=c*Ee,O+=c*De,u+=c*we,c=S[7],U+=c*_e,$+=c*pe,N+=c*le,P+=c*ue,j+=c*ce,z+=c*oe,Q+=c*se,q+=c*te,ee+=c*he,Y+=c*ge,ae+=c*ne,C+=c*ve,T+=c*be,O+=c*Ee,u+=c*De,v+=c*we,c=S[8],$+=c*_e,N+=c*pe,P+=c*le,j+=c*ue,z+=c*ce,Q+=c*oe,q+=c*se,ee+=c*te,Y+=c*he,ae+=c*ge,C+=c*ne,T+=c*ve,O+=c*be,u+=c*Ee,v+=c*De,K+=c*we,c=S[9],N+=c*_e,P+=c*pe,j+=c*le,z+=c*ue,Q+=c*ce,q+=c*oe,ee+=c*se,Y+=c*te,ae+=c*he,C+=c*ge,T+=c*ne,O+=c*ve,u+=c*be,v+=c*Ee,K+=c*De,k+=c*we,c=S[10],P+=c*_e,j+=c*pe,z+=c*le,Q+=c*ue,q+=c*ce,ee+=c*oe,Y+=c*se,ae+=c*te,C+=c*he,T+=c*ge,O+=c*ne,u+=c*ve,v+=c*be,K+=c*Ee,k+=c*De,fe+=c*we,c=S[11],j+=c*_e,z+=c*pe,Q+=c*le,q+=c*ue,ee+=c*ce,Y+=c*oe,ae+=c*se,C+=c*te,T+=c*he,O+=c*ge,u+=c*ne,v+=c*ve,K+=c*be,k+=c*Ee,fe+=c*De,ye+=c*we,c=S[12],z+=c*_e,Q+=c*pe,q+=c*le,ee+=c*ue,Y+=c*ce,ae+=c*oe,C+=c*se,T+=c*te,O+=c*he,u+=c*ge,v+=c*ne,K+=c*ve,k+=c*be,fe+=c*Ee,ye+=c*De,de+=c*we,c=S[13],Q+=c*_e,q+=c*pe,ee+=c*le,Y+=c*ue,ae+=c*ce,C+=c*oe,T+=c*se,O+=c*te,u+=c*he,v+=c*ge,K+=c*ne,k+=c*ve,fe+=c*be,ye+=c*Ee,de+=c*De,me+=c*we,c=S[14],q+=c*_e,ee+=c*pe,Y+=c*le,ae+=c*ue,C+=c*ce,T+=c*oe,O+=c*se,u+=c*te,v+=c*he,K+=c*ge,k+=c*ne,fe+=c*ve,ye+=c*be,de+=c*Ee,me+=c*De,Re+=c*we,c=S[15],ee+=c*_e,Y+=c*pe,ae+=c*le,C+=c*ue,T+=c*ce,O+=c*oe,u+=c*se,v+=c*te,K+=c*he,k+=c*ge,fe+=c*ne,ye+=c*ve,de+=c*be,me+=c*Ee,Re+=c*De,Te+=c*we,M+=38*Y,H+=38*ae,G+=38*C,J+=38*T,X+=38*O,g+=38*u,y+=38*v,U+=38*K,$+=38*k,N+=38*fe,P+=38*ye,j+=38*de,z+=38*me,Q+=38*Re,q+=38*Te,d=1,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=H+d+65535,d=Math.floor(c/65536),H=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=y+d+65535,d=Math.floor(c/65536),y=c-d*65536,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=$+d+65535,d=Math.floor(c/65536),$=c-d*65536,c=N+d+65535,d=Math.floor(c/65536),N=c-d*65536,c=P+d+65535,d=Math.floor(c/65536),P=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,M+=d-1+37*(d-1),d=1,c=M+d+65535,d=Math.floor(c/65536),M=c-d*65536,c=H+d+65535,d=Math.floor(c/65536),H=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=y+d+65535,d=Math.floor(c/65536),y=c-d*65536,c=U+d+65535,d=Math.floor(c/65536),U=c-d*65536,c=$+d+65535,d=Math.floor(c/65536),$=c-d*65536,c=N+d+65535,d=Math.floor(c/65536),N=c-d*65536,c=P+d+65535,d=Math.floor(c/65536),P=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,M+=d-1+37*(d-1),_[0]=M,_[1]=H,_[2]=G,_[3]=J,_[4]=X,_[5]=g,_[6]=y,_[7]=U,_[8]=$,_[9]=N,_[10]=P,_[11]=j,_[12]=z,_[13]=Q,_[14]=q,_[15]=ee}function m(_,S){E(_,S,S)}function b(_,S){const w=n();for(let c=0;c<16;c++)w[c]=S[c];for(let c=253;c>=0;c--)m(w,w),c!==2&&c!==4&&E(w,w,S);for(let c=0;c<16;c++)_[c]=w[c]}function R(_,S){const w=new Uint8Array(32),c=new Float64Array(80),d=n(),M=n(),H=n(),G=n(),J=n(),X=n();for(let $=0;$<31;$++)w[$]=_[$];w[31]=_[31]&127|64,w[0]&=248,h(c,S);for(let $=0;$<16;$++)M[$]=c[$];d[0]=G[0]=1;for(let $=254;$>=0;--$){const N=w[$>>>3]>>>($&7)&1;o(d,M,N),o(H,G,N),l(J,d,H),D(d,d,H),l(H,M,G),D(M,M,G),m(G,J),m(X,d),E(d,H,d),E(H,M,J),l(J,d,H),D(d,d,H),m(M,d),D(H,G,X),E(d,H,s),l(d,d,G),E(H,H,d),E(d,G,X),E(G,M,c),m(M,J),o(d,M,N),o(H,G,N)}for(let $=0;$<16;$++)c[$+16]=d[$],c[$+32]=H[$],c[$+48]=M[$],c[$+64]=G[$];const g=c.subarray(32),y=c.subarray(16);b(g,g),E(y,y,g);const U=new Uint8Array(32);return f(U,y),U}t.scalarMult=R;function L(_){return R(_,i)}t.scalarMultBase=L;function B(_){if(_.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const S=new Uint8Array(_);return{publicKey:L(S),secretKey:S}}t.generateKeyPairFromSeed=B;function x(_){const S=(0,e.randomBytes)(32,_),w=B(S);return(0,r.wipe)(S),w}t.generateKeyPair=x;function A(_,S,w=!1){if(_.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 c=R(_,S);if(w){let d=0;for(let M=0;M<c.length;M++)d|=c[M];if(d===0)throw new Error("X25519: invalid shared key")}return c}t.sharedKey=A})(Yn);function Is(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Jn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=Is(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Yu(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),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=i}var o=t.length,f=t.charAt(0),h=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function D(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var R=0,L=0,B=0,x=b.length;B!==x&&b[B]===0;)B++,R++;for(var A=(x-B)*l+1>>>0,_=new Uint8Array(A);B!==x;){for(var S=b[B],w=0,c=A-1;(S!==0||w<L)&&c!==-1;c--,w++)S+=256*_[c]>>>0,_[c]=S%o>>>0,S=S/o>>>0;if(S!==0)throw new Error("Non-zero carry");L=w,B++}for(var d=A-L;d!==A&&_[d]===0;)d++;for(var M=f.repeat(R);d<A;++d)M+=t.charAt(_[d]);return M}function E(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var R=0;if(b[R]!==" "){for(var L=0,B=0;b[R]===f;)L++,R++;for(var x=(b.length-R)*h+1>>>0,A=new Uint8Array(x);b[R];){var _=r[b.charCodeAt(R)];if(_===255)return;for(var S=0,w=x-1;(_!==0||S<B)&&w!==-1;w--,S++)_+=o*A[w]>>>0,A[w]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");B=S,R++}if(b[R]!==" "){for(var c=x-B;c!==x&&A[c]===0;)c++;for(var d=new Uint8Array(L+(x-c)),M=L;c!==x;)d[M++]=A[c++];return d}}}function m(b){var R=E(b);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:E,decode:m}}var Ju=Yu,Xu=Ju;const As=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")},Zu=t=>new TextEncoder().encode(t),Qu=t=>new TextDecoder().decode(t);class eh{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 th{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 Ts(this,e)}}class rh{constructor(e){this.decoders=e}or(e){return Ts(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 Ts=(t,e)=>new rh({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class nh{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new eh(e,r,n),this.decoder=new th(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const dn=({name:t,prefix:e,encode:r,decode:n})=>new nh(t,e,r,n),Ar=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Xu(r,e);return dn({prefix:t,name:e,encode:n,decode:s=>As(i(s))})},ih=(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 a=new Uint8Array(s*r/8|0);let o=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,o+=r,o>=8&&(o-=8,a[h++]=255&f>>o)}if(o>=r||255&f<<8-o)throw new SyntaxError("Unexpected end of data");return a},sh=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",a=0,o=0;for(let f=0;f<t.length;++f)for(o=o<<8|t[f],a+=8;a>r;)a-=r,s+=e[i&o>>a];if(a&&(s+=e[i&o<<r-a]),n)for(;s.length*r&7;)s+="=";return s},rt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>dn({prefix:e,name:t,encode(i){return sh(i,n,r)},decode(i){return ih(i,n,r,t)}}),oh=dn({prefix:"\0",name:"identity",encode:t=>Qu(t),decode:t=>Zu(t)});var ah=Object.freeze({__proto__:null,identity:oh});const ch=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var uh=Object.freeze({__proto__:null,base2:ch});const hh=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fh=Object.freeze({__proto__:null,base8:hh});const lh=Ar({prefix:"9",name:"base10",alphabet:"0123456789"});var dh=Object.freeze({__proto__:null,base10:lh});const ph=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gh=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _h=Object.freeze({__proto__:null,base16:ph,base16upper:gh});const yh=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vh=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bh=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mh=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wh=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Eh=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Dh=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sh=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xh=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oh=Object.freeze({__proto__:null,base32:yh,base32upper:vh,base32pad:bh,base32padupper:mh,base32hex:wh,base32hexupper:Eh,base32hexpad:Dh,base32hexpadupper:Sh,base32z:xh});const Ih=Ar({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ah=Ar({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Th=Object.freeze({__proto__:null,base36:Ih,base36upper:Ah});const Ch=Ar({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ph=Ar({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lh=Object.freeze({__proto__:null,base58btc:Ch,base58flickr:Ph});const Nh=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Rh=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fh=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Uh=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $h=Object.freeze({__proto__:null,base64:Nh,base64pad:Rh,base64url:Fh,base64urlpad:Uh});const Cs=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}"),Mh=Cs.reduce((t,e,r)=>(t[r]=e,t),[]),jh=Cs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bh(t){return t.reduce((e,r)=>(e+=Mh[r],e),"")}function zh(t){const e=[];for(const r of t){const n=jh[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Hh=dn({prefix:"\u{1F680}",name:"base256emoji",encode:Bh,decode:zh});var qh=Object.freeze({__proto__:null,base256emoji:Hh}),Kh=Ls,Ps=128,Vh=127,Gh=~Vh,kh=Math.pow(2,31);function Ls(t,e,r){e=e||[],r=r||0;for(var n=r;t>=kh;)e[r++]=t&255|Ps,t/=128;for(;t&Gh;)e[r++]=t&255|Ps,t>>>=7;return e[r]=t|0,Ls.bytes=r-n+1,e}var Wh=Xn,Yh=128,Ns=127;function Xn(t,n){var r=0,n=n||0,i=0,s=n,a,o=t.length;do{if(s>=o)throw Xn.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=i<28?(a&Ns)<<i:(a&Ns)*Math.pow(2,i),i+=7}while(a>=Yh);return Xn.bytes=s-n,r}var Jh=Math.pow(2,7),Xh=Math.pow(2,14),Zh=Math.pow(2,21),Qh=Math.pow(2,28),ef=Math.pow(2,35),tf=Math.pow(2,42),rf=Math.pow(2,49),nf=Math.pow(2,56),sf=Math.pow(2,63),of=function(t){return t<Jh?1:t<Xh?2:t<Zh?3:t<Qh?4:t<ef?5:t<tf?6:t<rf?7:t<nf?8:t<sf?9:10},af={encode:Kh,decode:Wh,encodingLength:of},Rs=af;const Fs=(t,e,r=0)=>(Rs.encode(t,e,r),e),Us=t=>Rs.encodingLength(t),Zn=(t,e)=>{const r=e.byteLength,n=Us(t),i=n+Us(r),s=new Uint8Array(i+r);return Fs(t,s,0),Fs(r,s,n),s.set(e,i),new cf(t,r,e,s)};class cf{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const $s=({name:t,code:e,encode:r})=>new uf(t,e,r);class uf{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?Zn(this.code,r):r.then(n=>Zn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const Ms=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),hf=$s({name:"sha2-256",code:18,encode:Ms("SHA-256")}),ff=$s({name:"sha2-512",code:19,encode:Ms("SHA-512")});var lf=Object.freeze({__proto__:null,sha256:hf,sha512:ff});const js=0,df="identity",Bs=As;var pf=Object.freeze({__proto__:null,identity:{code:js,name:df,encode:Bs,digest:t=>Zn(js,Bs(t))}});new TextEncoder,new TextDecoder;const zs={...ah,...uh,...fh,...dh,..._h,...Oh,...Th,...Lh,...$h,...qh};({...lf,...pf});function Hs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const qs=Hs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Qn=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=Is(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ks={utf8:qs,"utf-8":qs,hex:zs.base16,latin1:Qn,ascii:Qn,binary:Qn,...zs};function ht(t,e="utf8"){const r=Ks[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 ft(t,e="utf8"){const r=Ks[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 Vs=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))},gf=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),_f=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),yf=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}(),vf=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),bf=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),mf=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,wf=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Gs=3,Ef=[["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",mf]],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 Df(t){return t?Ws(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new bf:typeof navigator<"u"?Ws(navigator.userAgent):Of()}function Sf(t){return t!==""&&Ef.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 Ws(t){var e=Sf(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new vf;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Gs&&(i=Vs(Vs([],i,!0),If(Gs-i.length),!0)):i=[];var s=i.join("."),a=xf(t),o=wf.exec(t);return o&&o[1]?new yf(r,s,a,o[1]):new gf(r,s,a)}function xf(t){for(var e=0,r=ks.length;e<r;e++){var n=ks[e],i=n[0],s=n[1],a=s.exec(t);if(a)return i}return null}function Of(){var t=typeof process<"u"&&process.version;return t?new _f(process.version.slice(1)):null}function If(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Z={};/*! *****************************************************************************
|
|
15
|
+
Copyright (c) Microsoft Corporation.
|
|
16
|
+
|
|
17
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
18
|
+
purpose with or without fee is hereby granted.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
21
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
22
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
23
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
24
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
25
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
26
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
27
|
+
***************************************************************************** */var ei=function(t,e){return ei=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])},ei(t,e)};function Af(t,e){ei(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var ti=function(){return ti=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},ti.apply(this,arguments)};function Tf(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 Cf(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Pf(t,e){return function(r,n){e(r,n,t)}}function Lf(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Nf(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{h(n.next(l))}catch(D){a(D)}}function f(l){try{h(n.throw(l))}catch(D){a(D)}}function h(l){l.done?s(l.value):i(l.value).then(o,f)}h((n=n.apply(t,e||[])).next())})}function Rf(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(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 Ff(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Uf(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ri(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 Ys(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function $f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ys(arguments[e]));return t}function Mf(){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],a=0,o=s.length;a<o;a++,i++)n[i]=s[a];return n}function Tr(t){return this instanceof Tr?(this.v=t,this):new Tr(t)}function jf(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(E){n[E]&&(i[E]=function(m){return new Promise(function(b,R){s.push([E,m,b,R])>1||o(E,m)})})}function o(E,m){try{f(n[E](m))}catch(b){D(s[0][3],b)}}function f(E){E.value instanceof Tr?Promise.resolve(E.value.v).then(h,l):D(s[0][2],E)}function h(E){o("next",E)}function l(E){o("throw",E)}function D(E,m){E(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Bf(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(a){return(r=!r)?{value:Tr(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function zf(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 ri=="function"?ri(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(a){return new Promise(function(o,f){a=t[s](a),i(o,f,a.done,a.value)})}}function i(s,a,o,f){Promise.resolve(f).then(function(h){s({value:h,done:o})},a)}}function Hf(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function qf(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 Kf(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 Gf(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 kf=Object.freeze({__proto__:null,__extends:Af,get __assign(){return ti},__rest:Tf,__decorate:Cf,__param:Pf,__metadata:Lf,__awaiter:Nf,__generator:Rf,__createBinding:Ff,__exportStar:Uf,__values:ri,__read:Ys,__spread:$f,__spreadArrays:Mf,__await:Tr,__asyncGenerator:jf,__asyncDelegator:Bf,__asyncValues:zf,__makeTemplateObject:Hf,__importStar:qf,__importDefault:Kf,__classPrivateFieldGet:Vf,__classPrivateFieldSet:Gf}),pn=Zt(kf),ni={},Cr={},Js;function Wf(){if(Js)return Cr;Js=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Cr.delay=t,Cr}var Qt={},ii={},er={},Xs;function Yf(){return Xs||(Xs=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 si={},Zs;function Jf(){return Zs||(Zs=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}(si)),si}var Qs;function eo(){return Qs||(Qs=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=pn;e.__exportStar(Yf(),t),e.__exportStar(Jf(),t)}(ii)),ii}var to;function Xf(){if(to)return Qt;to=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.fromMiliseconds=Qt.toMiliseconds=void 0;const t=eo();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 ro;function Zf(){return ro||(ro=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=pn;e.__exportStar(Wf(),t),e.__exportStar(Xf(),t)}(ni)),ni}var dr={},no;function Qf(){if(no)return dr;no=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 oi={},Pr={},io;function el(){if(io)return Pr;io=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.IWatch=void 0;class t{}return Pr.IWatch=t,Pr}var so;function tl(){return so||(so=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),pn.__exportStar(el(),t)}(oi)),oi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=pn;e.__exportStar(Zf(),t),e.__exportStar(Qf(),t),e.__exportStar(tl(),t),e.__exportStar(eo(),t)})(Z);var xe={};Object.defineProperty(xe,"__esModule",{value:!0}),xe.getLocalStorage=xe.getLocalStorageOrThrow=xe.getCrypto=xe.getCryptoOrThrow=ao=xe.getLocation=xe.getLocationOrThrow=ai=xe.getNavigator=xe.getNavigatorOrThrow=oo=xe.getDocument=xe.getDocumentOrThrow=xe.getFromWindowOrThrow=xe.getFromWindow=void 0;function tr(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}xe.getFromWindow=tr;function pr(t){const e=tr(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}xe.getFromWindowOrThrow=pr;function rl(){return pr("document")}xe.getDocumentOrThrow=rl;function nl(){return tr("document")}var oo=xe.getDocument=nl;function il(){return pr("navigator")}xe.getNavigatorOrThrow=il;function sl(){return tr("navigator")}var ai=xe.getNavigator=sl;function ol(){return pr("location")}xe.getLocationOrThrow=ol;function al(){return tr("location")}var ao=xe.getLocation=al;function cl(){return pr("crypto")}xe.getCryptoOrThrow=cl;function ul(){return tr("crypto")}xe.getCrypto=ul;function hl(){return pr("localStorage")}xe.getLocalStorageOrThrow=hl;function fl(){return tr("localStorage")}xe.getLocalStorage=fl;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});var co=ci.getWindowMetadata=void 0;const uo=xe;function ll(){let t,e;try{t=uo.getDocumentOrThrow(),e=uo.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),E=[];for(let m=0;m<D.length;m++){const b=D[m],R=b.getAttribute("rel");if(R&&R.toLowerCase().indexOf("icon")>-1){const L=b.getAttribute("href");if(L)if(L.toLowerCase().indexOf("https:")===-1&&L.toLowerCase().indexOf("http:")===-1&&L.indexOf("//")!==0){let B=e.protocol+"//"+e.host;if(L.indexOf("/")===0)B+=L;else{const x=e.pathname.split("/");x.pop();const A=x.join("/");B+=A+"/"+L}E.push(B)}else if(L.indexOf("//")===0){const B=e.protocol+L;E.push(B)}else E.push(L)}}return E}function n(...D){const E=t.getElementsByTagName("meta");for(let m=0;m<E.length;m++){const b=E[m],R=["itemprop","property","name"].map(L=>b.getAttribute(L)).filter(L=>L?D.includes(L):!1);if(R.length&&R){const L=b.getAttribute("content");if(L)return L}}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 a=i(),o=s(),f=e.origin,h=r();return{description:o,url:f,icons:h,name:a}}co=ci.getWindowMetadata=ll;var Lr={},dl=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ho="%[a-f0-9]{2}",fo=new RegExp(ho,"gi"),lo=new RegExp("("+ho+")+","gi");function ui(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([],ui(r),ui(n))}function pl(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(fo),r=1;r<e.length;r++)t=ui(e,r).join(""),e=t.match(fo);return t}}function gl(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=lo.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=pl(r[0]);n!==r[0]&&(e[r[0]]=n)}r=lo.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var a=i[s];t=t.replace(new RegExp(a,"g"),e[a])}return t}var _l=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 gl(t)}},yl=(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)]},vl=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var a=n[s],o=t[a];(i?e.indexOf(a)!==-1:e(a,o,t))&&(r[a]=o)}return r};(function(t){const e=dl,r=_l,n=yl,i=vl,s=x=>x==null,a=Symbol("encodeFragmentIdentifier");function o(x){switch(x.arrayFormat){case"index":return A=>(_,S)=>{const w=_.length;return S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?_:S===null?[..._,[l(A,x),"[",w,"]"].join("")]:[..._,[l(A,x),"[",l(w,x),"]=",l(S,x)].join("")]};case"bracket":return A=>(_,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?_:S===null?[..._,[l(A,x),"[]"].join("")]:[..._,[l(A,x),"[]=",l(S,x)].join("")];case"colon-list-separator":return A=>(_,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?_:S===null?[..._,[l(A,x),":list="].join("")]:[..._,[l(A,x),":list=",l(S,x)].join("")];case"comma":case"separator":case"bracket-separator":{const A=x.arrayFormat==="bracket-separator"?"[]=":"=";return _=>(S,w)=>w===void 0||x.skipNull&&w===null||x.skipEmptyString&&w===""?S:(w=w===null?"":w,S.length===0?[[l(_,x),A,l(w,x)].join("")]:[[S,l(w,x)].join(x.arrayFormatSeparator)])}default:return A=>(_,S)=>S===void 0||x.skipNull&&S===null||x.skipEmptyString&&S===""?_:S===null?[..._,l(A,x)]:[..._,[l(A,x),"=",l(S,x)].join("")]}}function f(x){let A;switch(x.arrayFormat){case"index":return(_,S,w)=>{if(A=/\[(\d*)\]$/.exec(_),_=_.replace(/\[\d*\]$/,""),!A){w[_]=S;return}w[_]===void 0&&(w[_]={}),w[_][A[1]]=S};case"bracket":return(_,S,w)=>{if(A=/(\[\])$/.exec(_),_=_.replace(/\[\]$/,""),!A){w[_]=S;return}if(w[_]===void 0){w[_]=[S];return}w[_]=[].concat(w[_],S)};case"colon-list-separator":return(_,S,w)=>{if(A=/(:list)$/.exec(_),_=_.replace(/:list$/,""),!A){w[_]=S;return}if(w[_]===void 0){w[_]=[S];return}w[_]=[].concat(w[_],S)};case"comma":case"separator":return(_,S,w)=>{const c=typeof S=="string"&&S.includes(x.arrayFormatSeparator),d=typeof S=="string"&&!c&&D(S,x).includes(x.arrayFormatSeparator);S=d?D(S,x):S;const M=c||d?S.split(x.arrayFormatSeparator).map(H=>D(H,x)):S===null?S:D(S,x);w[_]=M};case"bracket-separator":return(_,S,w)=>{const c=/(\[\])$/.test(_);if(_=_.replace(/\[\]$/,""),!c){w[_]=S&&D(S,x);return}const d=S===null?[]:S.split(x.arrayFormatSeparator).map(M=>D(M,x));if(w[_]===void 0){w[_]=d;return}w[_]=[].concat(w[_],d)};default:return(_,S,w)=>{if(w[_]===void 0){w[_]=S;return}w[_]=[].concat(w[_],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 E(x){return Array.isArray(x)?x.sort():typeof x=="object"?E(Object.keys(x)).sort((A,_)=>Number(A)-Number(_)).map(A=>x[A]):x}function m(x){const A=x.indexOf("#");return A!==-1&&(x=x.slice(0,A)),x}function b(x){let A="";const _=x.indexOf("#");return _!==-1&&(A=x.slice(_)),A}function R(x){x=m(x);const A=x.indexOf("?");return A===-1?"":x.slice(A+1)}function L(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 _=f(A),S=Object.create(null);if(typeof x!="string"||(x=x.trim().replace(/^[?#&]/,""),!x))return S;for(const w of x.split("&")){if(w==="")continue;let[c,d]=n(A.decode?w.replace(/\+/g," "):w,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?d:D(d,A),_(D(c,A),d,S)}for(const w of Object.keys(S)){const c=S[w];if(typeof c=="object"&&c!==null)for(const d of Object.keys(c))c[d]=L(c[d],A);else S[w]=L(c,A)}return A.sort===!1?S:(A.sort===!0?Object.keys(S).sort():Object.keys(S).sort(A.sort)).reduce((w,c)=>{const d=S[c];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?w[c]=E(d):w[c]=d,w},Object.create(null))}t.extract=R,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 _=d=>A.skipNull&&s(x[d])||A.skipEmptyString&&x[d]==="",S=o(A),w={};for(const d of Object.keys(x))_(d)||(w[d]=x[d]);const c=Object.keys(w);return A.sort!==!1&&c.sort(A.sort),c.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[_,S]=n(x,"#");return Object.assign({url:_.split("?")[0]||"",query:B(R(x),A)},A&&A.parseFragmentIdentifier&&S?{fragmentIdentifier:D(S,A)}:{})},t.stringifyUrl=(x,A)=>{A=Object.assign({encode:!0,strict:!0,[a]:!0},A);const _=m(x.url).split("?")[0]||"",S=t.extract(x.url),w=t.parse(S,{sort:!1}),c=Object.assign(w,x.query);let d=t.stringify(c,A);d&&(d=`?${d}`);let M=b(x.url);return x.fragmentIdentifier&&(M=`#${A[a]?l(x.fragmentIdentifier,A):x.fragmentIdentifier}`),`${_}${d}${M}`},t.pick=(x,A,_)=>{_=Object.assign({parseFragmentIdentifier:!0,[a]:!1},_);const{url:S,query:w,fragmentIdentifier:c}=t.parseUrl(x,_);return t.stringifyUrl({url:S,query:i(w,A),fragmentIdentifier:c},_)},t.exclude=(x,A,_)=>{const S=Array.isArray(A)?w=>!A.includes(w):(w,c)=>!A(w,c);return t.pick(x,S,_)}})(Lr);const bl={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"}},po=":";function ml(t){const{namespace:e,reference:r}=t;return[e,r].join(po)}function wl(t){const[e,r,n]=t.split(po);return{namespace:e,reference:r,address:n}}function El(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function Dl(t){const{namespace:e,reference:r}=wl(t);return ml({namespace:e,reference:r})}function Sl(t){return El(t,Dl)}function hi(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 fi(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...Sl(i.accounts))}),r}function xl(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",lt="base16",li="base64pad",di="utf8",_o=0,rr=1,Ol=0,yo=1,pi=12,gi=32;function Il(){const t=Yn.generateKeyPair();return{privateKey:ft(t.secretKey,lt),publicKey:ft(t.publicKey,lt)}}function _i(){const t=lr.randomBytes(gi);return ft(t,lt)}function Al(t,e){const r=Yn.sharedKey(ht(t,lt),ht(e,lt)),n=new Mu(ln.SHA256,r).expand(gi);return ft(n,lt)}function Tl(t){const e=ln.hash(ht(t,lt));return ft(e,lt)}function gn(t){const e=ln.hash(ht(t,di));return ft(e,lt)}function Cl(t){return ht(`${t}`,go)}function Nr(t){return Number(ft(t,go))}function Pl(t){const e=Cl(typeof t.type<"u"?t.type:_o);if(Nr(e)===rr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ht(t.senderPublicKey,lt):void 0,n=typeof t.iv<"u"?ht(t.iv,lt):lr.randomBytes(pi),i=new Hn.ChaCha20Poly1305(ht(t.symKey,lt)).seal(n,ht(t.message,di));return Nl({type:e,sealed:i,iv:n,senderPublicKey:r})}function Ll(t){const e=new Hn.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:n}=yi(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ft(i,di)}function Nl(t){if(Nr(t.type)===rr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(Jn([t.type,t.senderPublicKey,t.iv,t.sealed]),li)}return ft(Jn([t.type,t.iv,t.sealed]),li)}function yi(t){const e=ht(t,li),r=e.slice(Ol,yo),n=yo;if(Nr(r)===rr){const o=n+gi,f=o+pi,h=e.slice(n,o),l=e.slice(o,f),D=e.slice(f);return{type:r,sealed:D,iv:l,senderPublicKey:h}}const i=n+pi,s=e.slice(n,i),a=e.slice(i);return{type:r,sealed:a,iv:s}}function Rl(t,e){const r=yi(t);return vo({type:Nr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function vo(t){const e=t?.type||_o;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 bo(t){return t.type===rr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var Fl=Object.defineProperty,mo=Object.getOwnPropertySymbols,Ul=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,wo=(t,e,r)=>e in t?Fl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Eo=(t,e)=>{for(var r in e||(e={}))Ul.call(e,r)&&wo(t,r,e[r]);if(mo)for(var r of mo(e))$l.call(e,r)&&wo(t,r,e[r]);return t};const Ml="ReactNative",Rr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},jl="js";function Do(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Bl(){return!oo()&&!!ai()&&navigator.product===Ml}function zl(){return!Do()&&!!ai()}function Hl(){return Bl()?Rr.reactNative:Do()?Rr.node:zl()?Rr.browser:Rr.unknown}function ql(t,e){let r=Lr.parse(t);return r=Eo(Eo({},r),e),t=Lr.stringify(r),t}function Kl(){return co()||{name:"",description:"",url:"",icons:[""]}}function Vl(){const t=Df();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 Gl(){var t;const e=Hl();return e===Rr.browser?[e,((t=ao())==null?void 0:t.host)||"unknown"].join(":"):e}function kl(t,e,r){const n=Vl(),i=Gl();return[[t,e].join("-"),[jl,r].join("-"),n,i].join("/")}function Wl({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const a=r.split("?"),o=kl(t,e,n),f={auth:i,ua:o,projectId:s},h=ql(a[1]||"",f);return a[0]+"?"+h}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function So(t){return Object.fromEntries(t.entries())}function xo(t){return new Map(Object.entries(t))}function Ut(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function Vt(t){return Z.fromMiliseconds(Date.now())>=Z.toMiliseconds(t)}function nr(){const t=Z.toMiliseconds(Z.FIVE_MINUTES);let e,r,n;return{resolve:i=>{n&&e&&(clearTimeout(n),e(i))},reject:i=>{n&&r&&(clearTimeout(n),r(i))},done:()=>new Promise((i,s)=>{n=setTimeout(s,t),e=i,r=s})}}function Oo(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 Yl(t){return Oo("topic",t)}function Jl(t){return Oo("id",t)}function Io(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 Ne(t,e){return`${t}${e?`:${e}`:""}`}const Xl="irn";function vi(t){return t?.relay||{protocol:Xl}}function bi(t){const e=bl[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Zl=Object.defineProperty,Ao=Object.getOwnPropertySymbols,Ql=Object.prototype.hasOwnProperty,ed=Object.prototype.propertyIsEnumerable,To=(t,e,r)=>e in t?Zl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,td=(t,e)=>{for(var r in e||(e={}))Ql.call(e,r)&&To(t,r,e[r]);if(Ao)for(var r of Ao(e))ed.call(e,r)&&To(t,r,e[r]);return t};function rd(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),a=t[i];r[s]=a}}),r}function nd(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):"",a=Lr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:a.symKey,relay:rd(a)}}function id(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 sd(t){return`${t.protocol}:${t.topic}@${t.version}?`+Lr.stringify(td({symKey:t.symKey},id(t.relay)))}function It(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function od(t){const e=[];return Object.values(t).forEach(r=>{e.push(...It(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...It(n.accounts))})}),e}function ad(t,e){const r=[];return Object.values(t).forEach(n=>{It(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{It(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function cd(t,e){const r=[];return Object.values(t).forEach(n=>{It(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{It(i.accounts).includes(e)&&r.push(...i.events)})}),r}const ud={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}},hd={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}=hd[t];return{message:e?`${r} ${e}`:r,code:n}}function Be(t,e){const{message:r,code:n}=ud[t];return{message:e?`${r} ${e}`:r,code:n}}function Fr(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Co(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function vt(t){return typeof t>"u"}function nt(t,e){return e&&vt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function Po(t,e){return e&&vt(t)?!0:typeof t=="number"&&!isNaN(t)}function fd(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return dt(i,n)?(n.forEach(a=>{const{accounts:o,methods:f,events:h,extension:l}=t.namespaces[a],D=It(o),E=r[a];(!dt(E.chains,D)||!dt(E.methods,f)||!dt(E.events,h))&&(s=!1),s&&l&&l.forEach(m=>{var b;const{accounts:R,methods:L,events:B}=m,x=It(R);(b=E.extension)!=null&&b.find(A=>dt(A.chains,x)&&dt(A.methods,L)&&dt(A.events,B))||(s=!1)})}),s):!1}function mi(t){return nt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function ld(t){if(nt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&mi(r)}}return!1}function dd(t){if(nt(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function pd(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function gd(t){return t?.topic}function _d(t,e){let r=null;return nt(t?.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function wi(t,e){let r=null;return vt(t?.extension)||(!Fr(t.extension)||!t.extension.length)&&(r=V("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function Lo(t){let e=!0;return Fr(t)?t.length&&(e=t.every(r=>nt(r,!1))):e=!1,e}function No(t,e,r){let n=null;return Fr(e)?e.forEach(i=>{n||(!mi(i)||!i.includes(t))&&(n=Be("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=Be("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function yd(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=No(n,i?.chains,`${e} requiredNamespace`),a=wi(i,e);s?r=s:a?r=a:i.extension&&i.extension.forEach(o=>{if(r)return;const f=No(n,o.chains,`${e} extension`);f&&(r=f)})}),r}function Ro(t,e){let r=null;return Fr(t)?t.forEach(n=>{r||ld(n)||(r=Be("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Be("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function vd(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=Ro(n?.accounts,`${e} namespace`),s=wi(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(a=>{if(r)return;const o=Ro(a.accounts,`${e} extension`);o&&(r=o)})}),r}function Fo(t,e){let r=null;return Lo(t?.methods)?Lo(t?.events)||(r=Be("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Be("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Uo(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=Fo(n,`${e}, namespace`),s=wi(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(a=>{if(r)return;const o=Fo(a,`${e}, extension`);o&&(r=o)})}),r}function bd(t,e){let r=null;if(t&&Co(t)){const n=Uo(t,e);n&&(r=n);const i=yd(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function Ei(t,e){let r=null;if(t&&Co(t)){const n=Uo(t,e);n&&(r=n);const i=vd(t,e);i&&(r=i)}else r=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function $o(t){return nt(t.protocol,!0)}function md(t,e){let r=!1;return e&&!t?r=!0:t&&Fr(t)&&t.length&&t.forEach(n=>{r=$o(n)}),r}function wd(t){return typeof t=="number"}function pt(t){return typeof t<"u"&&typeof t!==null}function Ed(t){return!(!t||typeof t!="object"||!t.code||!Po(t.code,!1)||!t.message||!nt(t.message,!1))}function Dd(t){return!(vt(t)||!nt(t.method,!1))}function Sd(t){return!(vt(t)||vt(t.result)&&vt(t.error)||!Po(t.id,!1)||!nt(t.jsonrpc,!1))}function xd(t){return!(vt(t)||!nt(t.name,!1))}function Mo(t,e){return!(!mi(e)||!od(t).includes(e))}function Od(t,e,r){return nt(r,!1)?ad(t,e).includes(r):!1}function Id(t,e,r){return nt(r,!1)?cd(t,e).includes(r):!1}function jo(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return dt(i,s)?i.forEach(a=>{var o;if(n)return;const f=t[a].chains,h=It(e[a].accounts);dt(f,h)?dt(t[a].methods,e[a].methods)?dt(t[a].events,e[a].events)?t[a].extension&&!e[a].extension?n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${a}`):t[a].extension&&e[a].extension&&((o=t[a].extension)==null||o.forEach(({methods:l,events:D,chains:E})=>{var m;n||(m=e[a].extension)!=null&&m.find(b=>{const R=It(b.accounts);return dt(E,R)&&dt(D,b.events)&&dt(l,b.methods)})||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${a}`))})):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${a}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${a}`):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${a}`)}):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function Ad(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Td=Cd;function Cd(t,e,r){var n=r&&r.stringify||Ad,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var a=new Array(s);a[0]=n(t);for(var o=1;o<s;o++)a[o]=n(e[o]);return a.join(" ")}if(typeof t!="string")return t;var f=e.length;if(f===0)return t;for(var h="",l=1-i,D=-1,E=t&&t.length||0,m=0;m<E;){if(t.charCodeAt(m)===37&&m+1<E){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 b=typeof e[l];if(b==="string"){h+="'"+e[l]+"'",D=m+2,m++;break}if(b==="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<E&&(h+=t.slice(D)),h)}const Bo=Td;var _n=At;const Ur=Bd().console||{},Pd={mapHttpRequest:vn,mapHttpResponse:vn,wrapRequestSerializer:Si,wrapResponseSerializer:Si,wrapErrorSerializer:Si,req:vn,res:vn,err:Ud};function Ld(t,e){return Array.isArray(t)?t.filter(function(n){return n!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function At(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=Ld(t.browser.serialize,n);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const a=["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 o=t.level||"info",f=Object.create(r);f.log||(f.log=$r),Object.defineProperty(f,"levelVal",{get:l}),Object.defineProperty(f,"level",{get:D,set:E});const h={transmit:e,serialize:i,asObject:t.browser.asObject,levels:a,timestamp:$d(t)};f.levels=At.levels,f.level=o,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=$r,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 E(b){if(b!=="silent"&&!this.levels.values[b])throw Error("unknown level "+b);this._level=b,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(b,R){if(!b)throw new Error("missing bindings for child Pino");R=R||{},i&&b.serializers&&(R.serializers=b.serializers);const L=R.serializers;if(i&&L){var B=Object.assign({},n,L),x=t.browser.serialize===!0?Object.keys(B):i;delete b.serializers,yn([b],x,B,this._stdErrSerialize)}function A(_){this._childLevel=(_._childLevel|0)+1,this.error=_r(_,b,"error"),this.fatal=_r(_,b,"fatal"),this.warn=_r(_,b,"warn"),this.info=_r(_,b,"info"),this.debug=_r(_,b,"debug"),this.trace=_r(_,b,"trace"),B&&(this.serializers=B,this._serialize=x),e&&(this._logEvent=Di([].concat(_._logEvent.bindings,b)))}return A.prototype=this,new A(this)}return f}At.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"}},At.stdSerializers=Pd,At.stdTimeFunctions=Object.assign({},{nullTime:zo,epochTime:Ho,unixTime:Md,isoTime:jd});function gr(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?$r:i[r]?i[r]:Ur[r]||Ur[n]||$r,Nd(t,e,r)}function Nd(t,e,r){!t.transmit&&e[r]===$r||(e[r]=function(n){return function(){const s=t.timestamp(),a=new Array(arguments.length),o=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ur?Ur:this;for(var f=0;f<a.length;f++)a[f]=arguments[f];if(t.serialize&&!t.asObject&&yn(a,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(o,Rd(this,r,a,s)):n.apply(o,a),t.transmit){const h=t.transmit.level||e.level,l=At.levels.values[h],D=At.levels.values[r];if(D<l)return;Fd(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:h,transmitValue:At.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},a)}}}(e[r]))}function Rd(t,e,r,n){t._serialize&&yn(r,t._serialize,t.serializers,t._stdErrSerialize);const i=r.slice();let s=i[0];const a={};n&&(a.time=n),a.level=At.levels.values[e];let o=(t._childLevel|0)+1;if(o<1&&(o=1),s!==null&&typeof s=="object"){for(;o--&&typeof i[0]=="object";)Object.assign(a,i.shift());s=i.length?Bo(i.shift(),i):void 0}else typeof s=="string"&&(s=Bo(i.shift(),i));return s!==void 0&&(a.msg=s),a}function yn(t,e,r,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=At.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 _r(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 Fd(t,e,r){const n=e.send,i=e.ts,s=e.methodLevel,a=e.methodValue,o=e.val,f=t._logEvent.bindings;yn(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=a,n(s,t._logEvent,o),t._logEvent=Di(f)}function Di(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Ud(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 $d(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?zo:Ho}function vn(){return{}}function Si(t){return t}function $r(){}function zo(){return!1}function Ho(){return Date.now()}function Md(){return Math.round(Date.now()/1e3)}function jd(){return new Date(Date.now()).toISOString()}function Bd(){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 bn={};/*! *****************************************************************************
|
|
28
|
+
Copyright (c) Microsoft Corporation.
|
|
29
|
+
|
|
30
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
+
purpose with or without fee is hereby granted.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
+
***************************************************************************** */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 zd(t,e){xi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Oi=function(){return Oi=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},Oi.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 qd(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Kd(t,e){return function(r,n){e(r,n,t)}}function Vd(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Gd(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{h(n.next(l))}catch(D){a(D)}}function f(l){try{h(n.throw(l))}catch(D){a(D)}}function h(l){l.done?s(l.value):i(l.value).then(o,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,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(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 Wd(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Yd(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Ii(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 qo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function Jd(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(qo(arguments[e]));return t}function Xd(){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],a=0,o=s.length;a<o;a++,i++)n[i]=s[a];return n}function Mr(t){return this instanceof Mr?(this.v=t,this):new Mr(t)}function Zd(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(E){n[E]&&(i[E]=function(m){return new Promise(function(b,R){s.push([E,m,b,R])>1||o(E,m)})})}function o(E,m){try{f(n[E](m))}catch(b){D(s[0][3],b)}}function f(E){E.value instanceof Mr?Promise.resolve(E.value.v).then(h,l):D(s[0][2],E)}function h(E){o("next",E)}function l(E){o("throw",E)}function D(E,m){E(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Qd(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(a){return(r=!r)?{value:Mr(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function ep(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 Ii=="function"?Ii(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(a){return new Promise(function(o,f){a=t[s](a),i(o,f,a.done,a.value)})}}function i(s,a,o,f){Promise.resolve(f).then(function(h){s({value:h,done:o})},a)}}function tp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function rp(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 ip(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function sp(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 op=Object.freeze({__proto__:null,__extends:zd,get __assign(){return Oi},__rest:Hd,__decorate:qd,__param:Kd,__metadata:Vd,__awaiter:Gd,__generator:kd,__createBinding:Wd,__exportStar:Yd,__values:Ii,__read:qo,__spread:Jd,__spreadArrays:Xd,__await:Mr,__asyncGenerator:Zd,__asyncDelegator:Qd,__asyncValues:ep,__makeTemplateObject:tp,__importStar:rp,__importDefault:np,__classPrivateFieldGet:ip,__classPrivateFieldSet:sp}),Ko=Zt(op),jr={};Object.defineProperty(jr,"__esModule",{value:!0});function ap(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}}jr.safeJsonParse=ap;function cp(t){return typeof t=="string"?t:JSON.stringify(t,(e,r)=>typeof r>"u"?null:r)}jr.safeJsonStringify=cp;var Br={exports:{}},Vo;function up(){return Vo||(Vo=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?Br.exports=He.localStorage:typeof window<"u"&&window.localStorage?Br.exports=window.localStorage:Br.exports=new e}()),Br.exports}var Ai={},zr={},Go;function hp(){if(Go)return zr;Go=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.IKeyValueStorage=void 0;class t{}return zr.IKeyValueStorage=t,zr}var Hr={},ko;function fp(){if(ko)return Hr;ko=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.parseEntry=void 0;const t=jr;function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Hr.parseEntry=e,Hr}var Wo;function lp(){return Wo||(Wo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Ko;e.__exportStar(hp(),t),e.__exportStar(fp(),t)}(Ai)),Ai}Object.defineProperty(bn,"__esModule",{value:!0}),bn.KeyValueStorage=void 0;const yr=Ko,Yo=jr,dp=yr.__importDefault(up()),pp=lp();class Jo{constructor(){this.localStorage=dp.default}getKeys(){return yr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return yr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(pp.parseEntry)})}getItem(e){return yr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Yo.safeJsonParse(r)})}setItem(e,r){return yr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Yo.safeJsonStringify(r))})}removeItem(e){return yr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}bn.KeyValueStorage=Jo;var gp=bn.default=Jo,qr={};/*! *****************************************************************************
|
|
41
|
+
Copyright (c) Microsoft Corporation.
|
|
42
|
+
|
|
43
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
44
|
+
purpose with or without fee is hereby granted.
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
47
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
48
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
49
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
50
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
51
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
52
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
53
|
+
***************************************************************************** */var Ti=function(t,e){return Ti=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])},Ti(t,e)};function _p(t,e){Ti(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Ci=function(){return Ci=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},Ci.apply(this,arguments)};function yp(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,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function bp(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 wp(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{h(n.next(l))}catch(D){a(D)}}function f(l){try{h(n.throw(l))}catch(D){a(D)}}function h(l){l.done?s(l.value):i(l.value).then(o,f)}h((n=n.apply(t,e||[])).next())})}function Ep(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(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 Dp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Sp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Pi(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 Xo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function xp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Xo(arguments[e]));return t}function Op(){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],a=0,o=s.length;a<o;a++,i++)n[i]=s[a];return n}function Kr(t){return this instanceof Kr?(this.v=t,this):new Kr(t)}function Ip(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(E){n[E]&&(i[E]=function(m){return new Promise(function(b,R){s.push([E,m,b,R])>1||o(E,m)})})}function o(E,m){try{f(n[E](m))}catch(b){D(s[0][3],b)}}function f(E){E.value instanceof Kr?Promise.resolve(E.value.v).then(h,l):D(s[0][2],E)}function h(E){o("next",E)}function l(E){o("throw",E)}function D(E,m){E(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Ap(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(a){return(r=!r)?{value:Kr(t[i](a)),done:i==="return"}:s?s(a):a}: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 Pi=="function"?Pi(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(a){return new Promise(function(o,f){a=t[s](a),i(o,f,a.done,a.value)})}}function i(s,a,o,f){Promise.resolve(f).then(function(h){s({value:h,done:o})},a)}}function Cp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Pp(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 Lp(t){return t&&t.__esModule?t:{default:t}}function Np(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Rp(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 Fp=Object.freeze({__proto__:null,__extends:_p,get __assign(){return Ci},__rest:yp,__decorate:vp,__param:bp,__metadata:mp,__awaiter:wp,__generator:Ep,__createBinding:Dp,__exportStar:Sp,__values:Pi,__read:Xo,__spread:xp,__spreadArrays:Op,__await:Kr,__asyncGenerator:Ip,__asyncDelegator:Ap,__asyncValues:Tp,__makeTemplateObject:Cp,__importStar:Pp,__importDefault:Lp,__classPrivateFieldGet:Np,__classPrivateFieldSet:Rp}),mn=Zt(Fp),Vr={},Li={},Gr={};class ir{}var Up=Object.freeze({__proto__:null,IEvents:ir}),$p=Zt(Up),Zo;function Mp(){if(Zo)return Gr;Zo=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.IHeartBeat=void 0;const t=$p;class e extends t.IEvents{constructor(n){super()}}return Gr.IHeartBeat=e,Gr}var Qo;function ea(){return Qo||(Qo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),mn.__exportStar(Mp(),t)}(Li)),Li}var Ni={},sr={},ta;function jp(){if(ta)return sr;ta=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 ra;function na(){return ra||(ra=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),mn.__exportStar(jp(),t)}(Ni)),Ni}var ia;function Bp(){if(ia)return Vr;ia=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.HeartBeat=void 0;const t=mn,e=wr,r=Z,n=ea(),i=na();class s extends n.IHeartBeat{constructor(o){super(o),this.events=new e.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=o?.interval||i.HEARTBEAT_INTERVAL}static init(o){return t.__awaiter(this,void 0,void 0,function*(){const f=new s(o);return yield f.init(),f})}init(){return t.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}on(o,f){this.events.on(o,f)}once(o,f){this.events.once(o,f)}off(o,f){this.events.off(o,f)}removeListener(o,f){this.events.removeListener(o,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 Vr.HeartBeat=s,Vr}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=mn;e.__exportStar(Bp(),t),e.__exportStar(ea(),t),e.__exportStar(na(),t)})(qr);var Se={};/*! *****************************************************************************
|
|
54
|
+
Copyright (c) Microsoft Corporation.
|
|
55
|
+
|
|
56
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
57
|
+
purpose with or without fee is hereby granted.
|
|
58
|
+
|
|
59
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
60
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
61
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
62
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
63
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
64
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
65
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
66
|
+
***************************************************************************** */var Ri=function(t,e){return Ri=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])},Ri(t,e)};function zp(t,e){Ri(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Fi=function(){return Fi=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},Fi.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 qp(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Kp(t,e){return function(r,n){e(r,n,t)}}function Vp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Gp(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{h(n.next(l))}catch(D){a(D)}}function f(l){try{h(n.throw(l))}catch(D){a(D)}}function h(l){l.done?s(l.value):i(l.value).then(o,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,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(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 Wp(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function Yp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Ui(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 sa(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function Jp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(sa(arguments[e]));return t}function Xp(){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],a=0,o=s.length;a<o;a++,i++)n[i]=s[a];return n}function kr(t){return this instanceof kr?(this.v=t,this):new kr(t)}function Zp(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(E){n[E]&&(i[E]=function(m){return new Promise(function(b,R){s.push([E,m,b,R])>1||o(E,m)})})}function o(E,m){try{f(n[E](m))}catch(b){D(s[0][3],b)}}function f(E){E.value instanceof kr?Promise.resolve(E.value.v).then(h,l):D(s[0][2],E)}function h(E){o("next",E)}function l(E){o("throw",E)}function D(E,m){E(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Qp(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(a){return(r=!r)?{value:kr(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function eg(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 Ui=="function"?Ui(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(a){return new Promise(function(o,f){a=t[s](a),i(o,f,a.done,a.value)})}}function i(s,a,o,f){Promise.resolve(f).then(function(h){s({value:h,done:o})},a)}}function tg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function rg(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 ng(t){return t&&t.__esModule?t:{default:t}}function ig(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function sg(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 og=Object.freeze({__proto__:null,__extends:zp,get __assign(){return Fi},__rest:Hp,__decorate:qp,__param:Kp,__metadata:Vp,__awaiter:Gp,__generator:kp,__createBinding:Wp,__exportStar:Yp,__values:Ui,__read:sa,__spread:Jp,__spreadArrays:Xp,__await:kr,__asyncGenerator:Zp,__asyncDelegator:Qp,__asyncValues:eg,__makeTemplateObject:tg,__importStar:rg,__importDefault:ng,__classPrivateFieldGet:ig,__classPrivateFieldSet:sg}),ag=Zt(og),or={},oa;function aa(){return oa||(oa=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 ct={},ca;function cg(){if(ca)return ct;ca=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=aa();function e(o){return Object.assign(Object.assign({},o),{level:o?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(o,f=t.PINO_CUSTOM_CONTEXT_KEY){return o[f]||""}ct.getBrowserLoggerContext=r;function n(o,f,h=t.PINO_CUSTOM_CONTEXT_KEY){return o[h]=f,o}ct.setBrowserLoggerContext=n;function i(o,f=t.PINO_CUSTOM_CONTEXT_KEY){let h="";return typeof o.bindings>"u"?h=r(o,f):h=o.bindings().context||"",h}ct.getLoggerContext=i;function s(o,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=i(o,h);return l.trim()?`${l}/${f}`:f}ct.formatChildLoggerContext=s;function a(o,f,h=t.PINO_CUSTOM_CONTEXT_KEY){const l=s(o,f,h),D=o.child({context:l});return n(D,l,h)}return ct.generateChildLogger=a,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const e=ag,r=e.__importDefault(_n);Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(aa(),t),e.__exportStar(cg(),t)})(Se);class ug extends ir{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class hg extends ir{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class fg{constructor(e,r){this.logger=e,this.core=r}}class lg extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class dg extends ir{constructor(e){super()}}class pg{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class gg extends ir{constructor(e,r){super(),this.relayer=e,this.logger=r}}class _g extends ir{constructor(e,r){super(),this.core=e,this.logger=r}}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var yg=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!vg(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,n,i,s,a;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Wr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var o=new Error('Uncaught, unspecified "error" event. ('+e+")");throw o.context=e,o}if(r=this._events[t],ua(r))return!1;if($t(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(Wr(r))for(i=Array.prototype.slice.call(arguments,1),a=r.slice(),n=a.length,s=0;s<n;s++)a[s].apply(this,i);return!0},Ke.prototype.addListener=function(t,e){var r;if(!$t(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,$t(e.listener)?e.listener:e),this._events[t]?Wr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Wr(this._events[t])&&!this._events[t].warned&&(ua(this._maxListeners)?r=Ke.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},Ke.prototype.on=Ke.prototype.addListener,Ke.prototype.once=function(t,e){if(!$t(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},Ke.prototype.removeListener=function(t,e){var r,n,i,s;if(!$t(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||$t(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Wr(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},Ke.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],$t(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:$t(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if($t(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function $t(t){return typeof t=="function"}function vg(t){return typeof t=="number"}function Wr(t){return typeof t=="object"&&t!==null}function ua(t){return t===void 0}class bg{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class bv extends yg.EventEmitter{constructor(){super()}}class mg{constructor(e){this.client=e}}var $i={},ha={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=gt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function o(){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 o.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},o.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},o.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},o.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},o.prototype.finish=function(f){if(!this._finished){var h=this._bytesHashed,l=this._bufferLength,D=h/536870912|0,E=h<<3,m=h%128<112?128:256;this._buffer[l]=128;for(var b=l+1;b<m-8;b++)this._buffer[b]=0;e.writeUint32BE(D,this._buffer,m-8),e.writeUint32BE(E,this._buffer,m-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,m),this._finished=!0}for(var b=0;b<this.digestLength/8;b++)e.writeUint32BE(this._stateHi[b],f,b*8),e.writeUint32BE(this._stateLo[b],f,b*8+4);return this},o.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},o.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}},o.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},o.prototype.cleanSavedState=function(f){r.wipe(f.stateHi),r.wipe(f.stateLo),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},o}();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(o,f,h,l,D,E,m){for(var b=h[0],R=h[1],L=h[2],B=h[3],x=h[4],A=h[5],_=h[6],S=h[7],w=l[0],c=l[1],d=l[2],M=l[3],H=l[4],G=l[5],J=l[6],X=l[7],g,y,U,$,N,P,j,z;m>=128;){for(var Q=0;Q<16;Q++){var q=8*Q+E;o[Q]=e.readUint32BE(D,q),f[Q]=e.readUint32BE(D,q+4)}for(var Q=0;Q<80;Q++){var ee=b,Y=R,ae=L,C=B,T=x,O=A,u=_,v=S,K=w,k=c,fe=d,ye=M,de=H,me=G,Re=J,Te=X;if(g=S,y=X,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=(x>>>14|H<<32-14)^(x>>>18|H<<32-18)^(H>>>41-32|x<<32-(41-32)),y=(H>>>14|x<<32-14)^(H>>>18|x<<32-18)^(x>>>41-32|H<<32-(41-32)),N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,g=x&A^~x&_,y=H&G^~H&J,N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,g=i[Q*2],y=i[Q*2+1],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,g=o[Q%16],y=f[Q%16],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,U=j&65535|z<<16,$=N&65535|P<<16,g=U,y=$,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=(b>>>28|w<<32-28)^(w>>>34-32|b<<32-(34-32))^(w>>>39-32|b<<32-(39-32)),y=(w>>>28|b<<32-28)^(b>>>34-32|w<<32-(34-32))^(b>>>39-32|w<<32-(39-32)),N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,g=b&R^b&L^R&L,y=w&c^w&d^c&d,N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,v=j&65535|z<<16,Te=N&65535|P<<16,g=C,y=ye,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=U,y=$,N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,C=j&65535|z<<16,ye=N&65535|P<<16,R=ee,L=Y,B=ae,x=C,A=T,_=O,S=u,b=v,c=K,d=k,M=fe,H=ye,G=de,J=me,X=Re,w=Te,Q%16===15)for(var q=0;q<16;q++)g=o[q],y=f[q],N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=o[(q+9)%16],y=f[(q+9)%16],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,U=o[(q+1)%16],$=f[(q+1)%16],g=(U>>>1|$<<32-1)^(U>>>8|$<<32-8)^U>>>7,y=($>>>1|U<<32-1)^($>>>8|U<<32-8)^($>>>7|U<<32-7),N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,U=o[(q+14)%16],$=f[(q+14)%16],g=(U>>>19|$<<32-19)^($>>>61-32|U<<32-(61-32))^U>>>6,y=($>>>19|U<<32-19)^(U>>>61-32|$<<32-(61-32))^($>>>6|U<<32-6),N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,o[q]=j&65535|z<<16,f[q]=N&65535|P<<16}g=b,y=w,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[0],y=l[0],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[0]=b=j&65535|z<<16,l[0]=w=N&65535|P<<16,g=R,y=c,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[1],y=l[1],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[1]=R=j&65535|z<<16,l[1]=c=N&65535|P<<16,g=L,y=d,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[2],y=l[2],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[2]=L=j&65535|z<<16,l[2]=d=N&65535|P<<16,g=B,y=M,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[3],y=l[3],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[3]=B=j&65535|z<<16,l[3]=M=N&65535|P<<16,g=x,y=H,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[4],y=l[4],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[4]=x=j&65535|z<<16,l[4]=H=N&65535|P<<16,g=A,y=G,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[5],y=l[5],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[5]=A=j&65535|z<<16,l[5]=G=N&65535|P<<16,g=_,y=J,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[6],y=l[6],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[6]=_=j&65535|z<<16,l[6]=J=N&65535|P<<16,g=S,y=X,N=y&65535,P=y>>>16,j=g&65535,z=g>>>16,g=h[7],y=l[7],N+=y&65535,P+=y>>>16,j+=g&65535,z+=g>>>16,P+=N>>>16,j+=P>>>16,z+=j>>>16,h[7]=S=j&65535|z<<16,l[7]=X=N&65535|P<<16,E+=128,m-=128}return E}function a(o){var f=new n;f.update(o);var h=f.digest();return f.clean(),h}t.hash=a})(ha),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=ha,n=gt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(C){const T=new Float64Array(16);if(C)for(let O=0;O<C.length;O++)T[O]=C[O];return T}const s=new Uint8Array(32);s[0]=9;const a=i(),o=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]),E=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(C,T){for(let O=0;O<16;O++)C[O]=T[O]|0}function b(C){let T=1;for(let O=0;O<16;O++){let u=C[O]+T+65535;T=Math.floor(u/65536),C[O]=u-T*65536}C[0]+=T-1+37*(T-1)}function R(C,T,O){const u=~(O-1);for(let v=0;v<16;v++){const K=u&(C[v]^T[v]);C[v]^=K,T[v]^=K}}function L(C,T){const O=i(),u=i();for(let v=0;v<16;v++)u[v]=T[v];b(u),b(u),b(u);for(let v=0;v<2;v++){O[0]=u[0]-65517;for(let k=1;k<15;k++)O[k]=u[k]-65535-(O[k-1]>>16&1),O[k-1]&=65535;O[15]=u[15]-32767-(O[14]>>16&1);const K=O[15]>>16&1;O[14]&=65535,R(u,O,1-K)}for(let v=0;v<16;v++)C[2*v]=u[v]&255,C[2*v+1]=u[v]>>8}function B(C,T){let O=0;for(let u=0;u<32;u++)O|=C[u]^T[u];return(1&O-1>>>8)-1}function x(C,T){const O=new Uint8Array(32),u=new Uint8Array(32);return L(O,C),L(u,T),B(O,u)}function A(C){const T=new Uint8Array(32);return L(T,C),T[0]&1}function _(C,T){for(let O=0;O<16;O++)C[O]=T[2*O]+(T[2*O+1]<<8);C[15]&=32767}function S(C,T,O){for(let u=0;u<16;u++)C[u]=T[u]+O[u]}function w(C,T,O){for(let u=0;u<16;u++)C[u]=T[u]-O[u]}function c(C,T,O){let u,v,K=0,k=0,fe=0,ye=0,de=0,me=0,Re=0,Te=0,_e=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,ve=0,be=0,Ee=0,De=0,we=0,St=0,Pt=0,Wt=0,_t=0,cr=0,en=0,On=0,Fe=O[0],Ce=O[1],Ue=O[2],$e=O[3],Me=O[4],Pe=O[5],We=O[6],Ye=O[7],Je=O[8],Xe=O[9],Ze=O[10],ze=O[11],je=O[12],Ie=O[13],Qe=O[14],et=O[15];u=T[0],K+=u*Fe,k+=u*Ce,fe+=u*Ue,ye+=u*$e,de+=u*Me,me+=u*Pe,Re+=u*We,Te+=u*Ye,_e+=u*Je,pe+=u*Xe,le+=u*Ze,ue+=u*ze,ce+=u*je,oe+=u*Ie,se+=u*Qe,te+=u*et,u=T[1],k+=u*Fe,fe+=u*Ce,ye+=u*Ue,de+=u*$e,me+=u*Me,Re+=u*Pe,Te+=u*We,_e+=u*Ye,pe+=u*Je,le+=u*Xe,ue+=u*Ze,ce+=u*ze,oe+=u*je,se+=u*Ie,te+=u*Qe,he+=u*et,u=T[2],fe+=u*Fe,ye+=u*Ce,de+=u*Ue,me+=u*$e,Re+=u*Me,Te+=u*Pe,_e+=u*We,pe+=u*Ye,le+=u*Je,ue+=u*Xe,ce+=u*Ze,oe+=u*ze,se+=u*je,te+=u*Ie,he+=u*Qe,ge+=u*et,u=T[3],ye+=u*Fe,de+=u*Ce,me+=u*Ue,Re+=u*$e,Te+=u*Me,_e+=u*Pe,pe+=u*We,le+=u*Ye,ue+=u*Je,ce+=u*Xe,oe+=u*Ze,se+=u*ze,te+=u*je,he+=u*Ie,ge+=u*Qe,ne+=u*et,u=T[4],de+=u*Fe,me+=u*Ce,Re+=u*Ue,Te+=u*$e,_e+=u*Me,pe+=u*Pe,le+=u*We,ue+=u*Ye,ce+=u*Je,oe+=u*Xe,se+=u*Ze,te+=u*ze,he+=u*je,ge+=u*Ie,ne+=u*Qe,ve+=u*et,u=T[5],me+=u*Fe,Re+=u*Ce,Te+=u*Ue,_e+=u*$e,pe+=u*Me,le+=u*Pe,ue+=u*We,ce+=u*Ye,oe+=u*Je,se+=u*Xe,te+=u*Ze,he+=u*ze,ge+=u*je,ne+=u*Ie,ve+=u*Qe,be+=u*et,u=T[6],Re+=u*Fe,Te+=u*Ce,_e+=u*Ue,pe+=u*$e,le+=u*Me,ue+=u*Pe,ce+=u*We,oe+=u*Ye,se+=u*Je,te+=u*Xe,he+=u*Ze,ge+=u*ze,ne+=u*je,ve+=u*Ie,be+=u*Qe,Ee+=u*et,u=T[7],Te+=u*Fe,_e+=u*Ce,pe+=u*Ue,le+=u*$e,ue+=u*Me,ce+=u*Pe,oe+=u*We,se+=u*Ye,te+=u*Je,he+=u*Xe,ge+=u*Ze,ne+=u*ze,ve+=u*je,be+=u*Ie,Ee+=u*Qe,De+=u*et,u=T[8],_e+=u*Fe,pe+=u*Ce,le+=u*Ue,ue+=u*$e,ce+=u*Me,oe+=u*Pe,se+=u*We,te+=u*Ye,he+=u*Je,ge+=u*Xe,ne+=u*Ze,ve+=u*ze,be+=u*je,Ee+=u*Ie,De+=u*Qe,we+=u*et,u=T[9],pe+=u*Fe,le+=u*Ce,ue+=u*Ue,ce+=u*$e,oe+=u*Me,se+=u*Pe,te+=u*We,he+=u*Ye,ge+=u*Je,ne+=u*Xe,ve+=u*Ze,be+=u*ze,Ee+=u*je,De+=u*Ie,we+=u*Qe,St+=u*et,u=T[10],le+=u*Fe,ue+=u*Ce,ce+=u*Ue,oe+=u*$e,se+=u*Me,te+=u*Pe,he+=u*We,ge+=u*Ye,ne+=u*Je,ve+=u*Xe,be+=u*Ze,Ee+=u*ze,De+=u*je,we+=u*Ie,St+=u*Qe,Pt+=u*et,u=T[11],ue+=u*Fe,ce+=u*Ce,oe+=u*Ue,se+=u*$e,te+=u*Me,he+=u*Pe,ge+=u*We,ne+=u*Ye,ve+=u*Je,be+=u*Xe,Ee+=u*Ze,De+=u*ze,we+=u*je,St+=u*Ie,Pt+=u*Qe,Wt+=u*et,u=T[12],ce+=u*Fe,oe+=u*Ce,se+=u*Ue,te+=u*$e,he+=u*Me,ge+=u*Pe,ne+=u*We,ve+=u*Ye,be+=u*Je,Ee+=u*Xe,De+=u*Ze,we+=u*ze,St+=u*je,Pt+=u*Ie,Wt+=u*Qe,_t+=u*et,u=T[13],oe+=u*Fe,se+=u*Ce,te+=u*Ue,he+=u*$e,ge+=u*Me,ne+=u*Pe,ve+=u*We,be+=u*Ye,Ee+=u*Je,De+=u*Xe,we+=u*Ze,St+=u*ze,Pt+=u*je,Wt+=u*Ie,_t+=u*Qe,cr+=u*et,u=T[14],se+=u*Fe,te+=u*Ce,he+=u*Ue,ge+=u*$e,ne+=u*Me,ve+=u*Pe,be+=u*We,Ee+=u*Ye,De+=u*Je,we+=u*Xe,St+=u*Ze,Pt+=u*ze,Wt+=u*je,_t+=u*Ie,cr+=u*Qe,en+=u*et,u=T[15],te+=u*Fe,he+=u*Ce,ge+=u*Ue,ne+=u*$e,ve+=u*Me,be+=u*Pe,Ee+=u*We,De+=u*Ye,we+=u*Je,St+=u*Xe,Pt+=u*Ze,Wt+=u*ze,_t+=u*je,cr+=u*Ie,en+=u*Qe,On+=u*et,K+=38*he,k+=38*ge,fe+=38*ne,ye+=38*ve,de+=38*be,me+=38*Ee,Re+=38*De,Te+=38*we,_e+=38*St,pe+=38*Pt,le+=38*Wt,ue+=38*_t,ce+=38*cr,oe+=38*en,se+=38*On,v=1,u=K+v+65535,v=Math.floor(u/65536),K=u-v*65536,u=k+v+65535,v=Math.floor(u/65536),k=u-v*65536,u=fe+v+65535,v=Math.floor(u/65536),fe=u-v*65536,u=ye+v+65535,v=Math.floor(u/65536),ye=u-v*65536,u=de+v+65535,v=Math.floor(u/65536),de=u-v*65536,u=me+v+65535,v=Math.floor(u/65536),me=u-v*65536,u=Re+v+65535,v=Math.floor(u/65536),Re=u-v*65536,u=Te+v+65535,v=Math.floor(u/65536),Te=u-v*65536,u=_e+v+65535,v=Math.floor(u/65536),_e=u-v*65536,u=pe+v+65535,v=Math.floor(u/65536),pe=u-v*65536,u=le+v+65535,v=Math.floor(u/65536),le=u-v*65536,u=ue+v+65535,v=Math.floor(u/65536),ue=u-v*65536,u=ce+v+65535,v=Math.floor(u/65536),ce=u-v*65536,u=oe+v+65535,v=Math.floor(u/65536),oe=u-v*65536,u=se+v+65535,v=Math.floor(u/65536),se=u-v*65536,u=te+v+65535,v=Math.floor(u/65536),te=u-v*65536,K+=v-1+37*(v-1),v=1,u=K+v+65535,v=Math.floor(u/65536),K=u-v*65536,u=k+v+65535,v=Math.floor(u/65536),k=u-v*65536,u=fe+v+65535,v=Math.floor(u/65536),fe=u-v*65536,u=ye+v+65535,v=Math.floor(u/65536),ye=u-v*65536,u=de+v+65535,v=Math.floor(u/65536),de=u-v*65536,u=me+v+65535,v=Math.floor(u/65536),me=u-v*65536,u=Re+v+65535,v=Math.floor(u/65536),Re=u-v*65536,u=Te+v+65535,v=Math.floor(u/65536),Te=u-v*65536,u=_e+v+65535,v=Math.floor(u/65536),_e=u-v*65536,u=pe+v+65535,v=Math.floor(u/65536),pe=u-v*65536,u=le+v+65535,v=Math.floor(u/65536),le=u-v*65536,u=ue+v+65535,v=Math.floor(u/65536),ue=u-v*65536,u=ce+v+65535,v=Math.floor(u/65536),ce=u-v*65536,u=oe+v+65535,v=Math.floor(u/65536),oe=u-v*65536,u=se+v+65535,v=Math.floor(u/65536),se=u-v*65536,u=te+v+65535,v=Math.floor(u/65536),te=u-v*65536,K+=v-1+37*(v-1),C[0]=K,C[1]=k,C[2]=fe,C[3]=ye,C[4]=de,C[5]=me,C[6]=Re,C[7]=Te,C[8]=_e,C[9]=pe,C[10]=le,C[11]=ue,C[12]=ce,C[13]=oe,C[14]=se,C[15]=te}function d(C,T){c(C,T,T)}function M(C,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&&c(O,O,T);for(u=0;u<16;u++)C[u]=O[u]}function H(C,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&&c(O,O,T);for(u=0;u<16;u++)C[u]=O[u]}function G(C,T){const O=i(),u=i(),v=i(),K=i(),k=i(),fe=i(),ye=i(),de=i(),me=i();w(O,C[1],C[0]),w(me,T[1],T[0]),c(O,O,me),S(u,C[0],C[1]),S(me,T[0],T[1]),c(u,u,me),c(v,C[3],T[3]),c(v,v,h),c(K,C[2],T[2]),S(K,K,K),w(k,u,O),w(fe,K,v),S(ye,K,v),S(de,u,O),c(C[0],k,fe),c(C[1],de,ye),c(C[2],ye,fe),c(C[3],k,de)}function J(C,T,O){for(let u=0;u<4;u++)R(C[u],T[u],O)}function X(C,T){const O=i(),u=i(),v=i();M(v,T[2]),c(O,T[0],v),c(u,T[1],v),L(C,u),C[31]^=A(O)<<7}function g(C,T,O){m(C[0],a),m(C[1],o),m(C[2],o),m(C[3],a);for(let u=255;u>=0;--u){const v=O[u/8|0]>>(u&7)&1;J(C,T,v),G(T,C),G(C,C),J(C,T,v)}}function y(C,T){const O=[i(),i(),i(),i()];m(O[0],l),m(O[1],D),m(O[2],o),c(O[3],l,D),g(C,O,T)}function U(C){if(C.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const T=(0,r.hash)(C);T[0]&=248,T[31]&=127,T[31]|=64;const O=new Uint8Array(32),u=[i(),i(),i(),i()];y(u,T),X(O,u);const v=new Uint8Array(64);return v.set(C),v.set(O,32),{publicKey:O,secretKey:v}}t.generateKeyPairFromSeed=U;function $(C){const T=(0,e.randomBytes)(32,C),O=U(T);return(0,n.wipe)(T),O}t.generateKeyPair=$;function N(C){if(C.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(C.subarray(32))}t.extractPublicKeyFromSecretKey=N;const P=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(C,T){let O,u,v,K;for(u=63;u>=32;--u){for(O=0,v=u-32,K=u-12;v<K;++v)T[v]+=O-16*T[u]*P[v-(u-32)],O=Math.floor((T[v]+128)/256),T[v]-=O*256;T[v]+=O,T[u]=0}for(O=0,v=0;v<32;v++)T[v]+=O-(T[31]>>4)*P[v],O=T[v]>>8,T[v]&=255;for(v=0;v<32;v++)T[v]-=O*P[v];for(u=0;u<32;u++)T[u+1]+=T[u]>>8,C[u]=T[u]&255}function z(C){const T=new Float64Array(64);for(let O=0;O<64;O++)T[O]=C[O];for(let O=0;O<64;O++)C[O]=0;j(C,T)}function Q(C,T){const O=new Float64Array(64),u=[i(),i(),i(),i()],v=(0,r.hash)(C.subarray(0,32));v[0]&=248,v[31]&=127,v[31]|=64;const K=new Uint8Array(64);K.set(v.subarray(32),32);const k=new r.SHA512;k.update(K.subarray(32)),k.update(T);const fe=k.digest();k.clean(),z(fe),y(u,fe),X(K,u),k.reset(),k.update(K.subarray(0,32)),k.update(C.subarray(32)),k.update(T);const ye=k.digest();z(ye);for(let de=0;de<32;de++)O[de]=fe[de];for(let de=0;de<32;de++)for(let me=0;me<32;me++)O[de+me]+=ye[de]*v[me];return j(K.subarray(32),O),K}t.sign=Q;function q(C,T){const O=i(),u=i(),v=i(),K=i(),k=i(),fe=i(),ye=i();return m(C[2],o),_(C[1],T),d(v,C[1]),c(K,v,f),w(v,v,C[2]),S(K,C[2],K),d(k,K),d(fe,k),c(ye,fe,k),c(O,ye,v),c(O,O,K),H(O,O),c(O,O,v),c(O,O,K),c(O,O,K),c(C[0],O,K),d(u,C[0]),c(u,u,K),x(u,v)&&c(C[0],C[0],E),d(u,C[0]),c(u,u,K),x(u,v)?-1:(A(C[0])===T[31]>>7&&w(C[0],a,C[0]),c(C[3],C[0],C[1]),0)}function ee(C,T,O){const u=new Uint8Array(32),v=[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(q(K,C))return!1;const k=new r.SHA512;k.update(O.subarray(0,32)),k.update(C),k.update(T);const fe=k.digest();return z(fe),g(v,K,fe),y(K,O.subarray(32)),G(v,K),X(u,v),!B(O,u)}t.verify=ee;function Y(C){let T=[i(),i(),i(),i()];if(q(T,C))throw new Error("Ed25519: invalid public key");let O=i(),u=i(),v=T[1];S(O,o,v),w(u,o,v),M(u,u),c(O,O,u);let K=new Uint8Array(32);return L(K,O),K}t.convertPublicKeyToX25519=Y;function ae(C){const T=(0,r.hash)(C.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}($i);const wg="EdDSA",Eg="JWT",fa=".",la="base64url",Dg="utf8",Sg="utf8",xg=":",Og="did",Ig="key",da="base58btc",Ag="z",Tg="K36",Cg=32;function wn(t){return ft(ht(Or(t),Dg),la)}function pa(t){const e=ht(Tg,da),r=Ag+ft(Jn([e,t]),da);return[Og,Ig,r].join(xg)}function Pg(t){return ft(t,la)}function Lg(t){return ht([wn(t.header),wn(t.payload)].join(fa),Sg)}function Ng(t){return[wn(t.header),wn(t.payload),Pg(t.signature)].join(fa)}function ga(t=lr.randomBytes(Cg)){return $i.generateKeyPairFromSeed(t)}async function Rg(t,e,r,n,i=Z.fromMiliseconds(Date.now())){const s={alg:wg,typ:Eg},a=pa(n.publicKey),o=i+r,f={iss:a,sub:t,aud:e,iat:i,exp:o},h=Lg({header:s,payload:f}),l=$i.sign(n.secretKey,h);return Ng({header:s,payload:f,signature:l})}const _a=10,Fg=(()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"))();class Ug{constructor(e){if(this.url=e,this.events=new wr.EventEmitter,this.registering=!1,!cs(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(Or(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!cs(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=ts.isReactNative()?void 0:{rejectUnauthorized:!nu(e)},s=new Fg(e,[],i);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=a=>{const o=a,f=this.parseError(o.error||new Error(`WebSocket connection failed for URL: ${e}`));this.events.emit("register_error",f),this.onClose(),n(f)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const n=r,i=this.parseError(n.error||new Error(`WebSocket connection failed for URL: ${this.url}`));this.events.emit("error",i)},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"?zn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=xr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return es(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>_a&&this.events.setMaxListeners(_a)}}var Mi={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,a=9007199254740991,o="[object Arguments]",f="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",D="[object Date]",E="[object Error]",m="[object Function]",b="[object GeneratorFunction]",R="[object Map]",L="[object Number]",B="[object Null]",x="[object Object]",A="[object Promise]",_="[object Proxy]",S="[object RegExp]",w="[object Set]",c="[object String]",d="[object Symbol]",M="[object Undefined]",H="[object WeakMap]",G="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",g="[object Float64Array]",y="[object Int8Array]",U="[object Int16Array]",$="[object Int32Array]",N="[object Uint8Array]",P="[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]=Y[U]=Y[$]=Y[N]=Y[P]=Y[j]=Y[z]=!0,Y[o]=Y[f]=Y[G]=Y[l]=Y[J]=Y[D]=Y[E]=Y[m]=Y[R]=Y[L]=Y[x]=Y[S]=Y[w]=Y[c]=Y[H]=!1;var ae=typeof He=="object"&&He&&He.Object===Object&&He,C=typeof self=="object"&&self&&self.Object===Object&&self,T=ae||C||Function("return this")(),O=e&&!e.nodeType&&e,u=O&&!0&&t&&!t.nodeType&&t,v=u&&u.exports===O,K=v&&ae.process,k=function(){try{return K&&K.binding&&K.binding("util")}catch{}}(),fe=k&&k.isTypedArray;function ye(p,I){for(var F=-1,W=p==null?0:p.length,Oe=0,ie=[];++F<W;){var Le=p[F];I(Le,F,p)&&(ie[Oe++]=Le)}return ie}function de(p,I){for(var F=-1,W=I.length,Oe=p.length;++F<W;)p[Oe+F]=I[F];return p}function me(p,I){for(var F=-1,W=p==null?0:p.length;++F<W;)if(I(p[F],F,p))return!0;return!1}function Re(p,I){for(var F=-1,W=Array(p);++F<p;)W[F]=I(F);return W}function Te(p){return function(I){return p(I)}}function _e(p,I){return p.has(I)}function pe(p,I){return p?.[I]}function le(p){var I=-1,F=Array(p.size);return p.forEach(function(W,Oe){F[++I]=[Oe,W]}),F}function ue(p,I){return function(F){return p(I(F))}}function ce(p){var I=-1,F=Array(p.size);return p.forEach(function(W){F[++I]=W}),F}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=T["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,ve=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.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=v?T.Buffer:void 0,we=T.Symbol,St=T.Uint8Array,Pt=te.propertyIsEnumerable,Wt=oe.splice,_t=we?we.toStringTag:void 0,cr=Object.getOwnPropertySymbols,en=De?De.isBuffer:void 0,On=ue(Object.keys,Object),Fe=mr(T,"DataView"),Ce=mr(T,"Map"),Ue=mr(T,"Promise"),$e=mr(T,"Set"),Me=mr(T,"WeakMap"),Pe=mr(Object,"create"),We=hr(Fe),Ye=hr(Ce),Je=hr(Ue),Xe=hr($e),Ze=hr(Me),ze=we?we.prototype:void 0,je=ze?ze.valueOf:void 0;function Ie(p){var I=-1,F=p==null?0:p.length;for(this.clear();++I<F;){var W=p[I];this.set(W[0],W[1])}}function Qe(){this.__data__=Pe?Pe(null):{},this.size=0}function et(p){var I=this.has(p)&&delete this.__data__[p];return this.size-=I?1:0,I}function A0(p){var I=this.__data__;if(Pe){var F=I[p];return F===n?void 0:F}return ne.call(I,p)?I[p]:void 0}function T0(p){var I=this.__data__;return Pe?I[p]!==void 0:ne.call(I,p)}function C0(p,I){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Pe&&I===void 0?n:I,this}Ie.prototype.clear=Qe,Ie.prototype.delete=et,Ie.prototype.get=A0,Ie.prototype.has=T0,Ie.prototype.set=C0;function Ht(p){var I=-1,F=p==null?0:p.length;for(this.clear();++I<F;){var W=p[I];this.set(W[0],W[1])}}function P0(){this.__data__=[],this.size=0}function L0(p){var I=this.__data__,F=An(I,p);if(F<0)return!1;var W=I.length-1;return F==W?I.pop():Wt.call(I,F,1),--this.size,!0}function N0(p){var I=this.__data__,F=An(I,p);return F<0?void 0:I[F][1]}function R0(p){return An(this.__data__,p)>-1}function F0(p,I){var F=this.__data__,W=An(F,p);return W<0?(++this.size,F.push([p,I])):F[W][1]=I,this}Ht.prototype.clear=P0,Ht.prototype.delete=L0,Ht.prototype.get=N0,Ht.prototype.has=R0,Ht.prototype.set=F0;function ur(p){var I=-1,F=p==null?0:p.length;for(this.clear();++I<F;){var W=p[I];this.set(W[0],W[1])}}function U0(){this.size=0,this.__data__={hash:new Ie,map:new(Ce||Ht),string:new Ie}}function $0(p){var I=Tn(this,p).delete(p);return this.size-=I?1:0,I}function M0(p){return Tn(this,p).get(p)}function j0(p){return Tn(this,p).has(p)}function B0(p,I){var F=Tn(this,p),W=F.size;return F.set(p,I),this.size+=F.size==W?0:1,this}ur.prototype.clear=U0,ur.prototype.delete=$0,ur.prototype.get=M0,ur.prototype.has=j0,ur.prototype.set=B0;function In(p){var I=-1,F=p==null?0:p.length;for(this.__data__=new ur;++I<F;)this.add(p[I])}function z0(p){return this.__data__.set(p,n),this}function H0(p){return this.__data__.has(p)}In.prototype.add=In.prototype.push=z0,In.prototype.has=H0;function Yt(p){var I=this.__data__=new Ht(p);this.size=I.size}function q0(){this.__data__=new Ht,this.size=0}function K0(p){var I=this.__data__,F=I.delete(p);return this.size=I.size,F}function V0(p){return this.__data__.get(p)}function G0(p){return this.__data__.has(p)}function k0(p,I){var F=this.__data__;if(F instanceof Ht){var W=F.__data__;if(!Ce||W.length<r-1)return W.push([p,I]),this.size=++F.size,this;F=this.__data__=new ur(W)}return F.set(p,I),this.size=F.size,this}Yt.prototype.clear=q0,Yt.prototype.delete=K0,Yt.prototype.get=V0,Yt.prototype.has=G0,Yt.prototype.set=k0;function W0(p,I){var F=Cn(p),W=!F&&uv(p),Oe=!F&&!W&&Yi(p),ie=!F&&!W&&!Oe&&gc(p),Le=F||W||Oe||ie,tt=Le?Re(p.length,String):[],st=tt.length;for(var Ae in p)(I||ne.call(p,Ae))&&!(Le&&(Ae=="length"||Oe&&(Ae=="offset"||Ae=="parent")||ie&&(Ae=="buffer"||Ae=="byteLength"||Ae=="byteOffset")||iv(Ae,st)))&&tt.push(Ae);return tt}function An(p,I){for(var F=p.length;F--;)if(fc(p[F][0],I))return F;return-1}function Y0(p,I,F){var W=I(p);return Cn(p)?W:de(W,F(p))}function tn(p){return p==null?p===void 0?M:B:_t&&_t in Object(p)?rv(p):cv(p)}function ac(p){return rn(p)&&tn(p)==o}function cc(p,I,F,W,Oe){return p===I?!0:p==null||I==null||!rn(p)&&!rn(I)?p!==p&&I!==I:J0(p,I,F,W,cc,Oe)}function J0(p,I,F,W,Oe,ie){var Le=Cn(p),tt=Cn(I),st=Le?f:Jt(p),Ae=tt?f:Jt(I);st=st==o?x:st,Ae=Ae==o?x:Ae;var yt=st==x,xt=Ae==x,at=st==Ae;if(at&&Yi(p)){if(!Yi(I))return!1;Le=!0,yt=!1}if(at&&!yt)return ie||(ie=new Yt),Le||gc(p)?uc(p,I,F,W,Oe,ie):ev(p,I,st,F,W,Oe,ie);if(!(F&i)){var mt=yt&&ne.call(p,"__wrapped__"),wt=xt&&ne.call(I,"__wrapped__");if(mt||wt){var Xt=mt?p.value():p,qt=wt?I.value():I;return ie||(ie=new Yt),Oe(Xt,qt,F,W,ie)}}return at?(ie||(ie=new Yt),tv(p,I,F,W,Oe,ie)):!1}function X0(p){if(!pc(p)||ov(p))return!1;var I=lc(p)?Ee:q;return I.test(hr(p))}function Z0(p){return rn(p)&&dc(p.length)&&!!Y[tn(p)]}function Q0(p){if(!av(p))return On(p);var I=[];for(var F in Object(p))ne.call(p,F)&&F!="constructor"&&I.push(F);return I}function uc(p,I,F,W,Oe,ie){var Le=F&i,tt=p.length,st=I.length;if(tt!=st&&!(Le&&st>tt))return!1;var Ae=ie.get(p);if(Ae&&ie.get(I))return Ae==I;var yt=-1,xt=!0,at=F&s?new In:void 0;for(ie.set(p,I),ie.set(I,p);++yt<tt;){var mt=p[yt],wt=I[yt];if(W)var Xt=Le?W(wt,mt,yt,I,p,ie):W(mt,wt,yt,p,I,ie);if(Xt!==void 0){if(Xt)continue;xt=!1;break}if(at){if(!me(I,function(qt,fr){if(!_e(at,fr)&&(mt===qt||Oe(mt,qt,F,W,ie)))return at.push(fr)})){xt=!1;break}}else if(!(mt===wt||Oe(mt,wt,F,W,ie))){xt=!1;break}}return ie.delete(p),ie.delete(I),xt}function ev(p,I,F,W,Oe,ie,Le){switch(F){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 St(p),new St(I)));case l:case D:case L:return fc(+p,+I);case E:return p.name==I.name&&p.message==I.message;case S:case c:return p==I+"";case R:var tt=le;case w:var st=W&i;if(tt||(tt=ce),p.size!=I.size&&!st)return!1;var Ae=Le.get(p);if(Ae)return Ae==I;W|=s,Le.set(p,I);var yt=uc(tt(p),tt(I),W,Oe,ie,Le);return Le.delete(p),yt;case d:if(je)return je.call(p)==je.call(I)}return!1}function tv(p,I,F,W,Oe,ie){var Le=F&i,tt=hc(p),st=tt.length,Ae=hc(I),yt=Ae.length;if(st!=yt&&!Le)return!1;for(var xt=st;xt--;){var at=tt[xt];if(!(Le?at in I:ne.call(I,at)))return!1}var mt=ie.get(p);if(mt&&ie.get(I))return mt==I;var wt=!0;ie.set(p,I),ie.set(I,p);for(var Xt=Le;++xt<st;){at=tt[xt];var qt=p[at],fr=I[at];if(W)var _c=Le?W(fr,qt,at,I,p,ie):W(qt,fr,at,p,I,ie);if(!(_c===void 0?qt===fr||Oe(qt,fr,F,W,ie):_c)){wt=!1;break}Xt||(Xt=at=="constructor")}if(wt&&!Xt){var Pn=p.constructor,Ln=I.constructor;Pn!=Ln&&"constructor"in p&&"constructor"in I&&!(typeof Pn=="function"&&Pn instanceof Pn&&typeof Ln=="function"&&Ln instanceof Ln)&&(wt=!1)}return ie.delete(p),ie.delete(I),wt}function hc(p){return Y0(p,lv,nv)}function Tn(p,I){var F=p.__data__;return sv(I)?F[typeof I=="string"?"string":"hash"]:F.map}function mr(p,I){var F=pe(p,I);return X0(F)?F:void 0}function rv(p){var I=ne.call(p,_t),F=p[_t];try{p[_t]=void 0;var W=!0}catch{}var Oe=be.call(p);return W&&(I?p[_t]=F:delete p[_t]),Oe}var nv=cr?function(p){return p==null?[]:(p=Object(p),ye(cr(p),function(I){return Pt.call(p,I)}))}:dv,Jt=tn;(Fe&&Jt(new Fe(new ArrayBuffer(1)))!=J||Ce&&Jt(new Ce)!=R||Ue&&Jt(Ue.resolve())!=A||$e&&Jt(new $e)!=w||Me&&Jt(new Me)!=H)&&(Jt=function(p){var I=tn(p),F=I==x?p.constructor:void 0,W=F?hr(F):"";if(W)switch(W){case We:return J;case Ye:return R;case Je:return A;case Xe:return w;case Ze:return H}return I});function iv(p,I){return I=I??a,!!I&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<I}function sv(p){var I=typeof p;return I=="string"||I=="number"||I=="symbol"||I=="boolean"?p!=="__proto__":p===null}function ov(p){return!!ve&&ve in p}function av(p){var I=p&&p.constructor,F=typeof I=="function"&&I.prototype||te;return p===F}function cv(p){return be.call(p)}function hr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function fc(p,I){return p===I||p!==p&&I!==I}var uv=ac(function(){return arguments}())?ac:function(p){return rn(p)&&ne.call(p,"callee")&&!Pt.call(p,"callee")},Cn=Array.isArray;function hv(p){return p!=null&&dc(p.length)&&!lc(p)}var Yi=en||pv;function fv(p,I){return cc(p,I)}function lc(p){if(!pc(p))return!1;var I=tn(p);return I==m||I==b||I==h||I==_}function dc(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=a}function pc(p){var I=typeof p;return p!=null&&(I=="object"||I=="function")}function rn(p){return p!=null&&typeof p=="object"}var gc=fe?Te(fe):Z0;function lv(p){return hv(p)?W0(p):Q0(p)}function dv(){return[]}function pv(){return!1}t.exports=fv})(Mi,Mi.exports);var $g=Mi.exports,Mg=Object.defineProperty,ya=Object.getOwnPropertySymbols,jg=Object.prototype.hasOwnProperty,Bg=Object.prototype.propertyIsEnumerable,va=(t,e,r)=>e in t?Mg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))jg.call(e,r)&&va(t,r,e[r]);if(ya)for(var r of ya(e))Bg.call(e,r)&&va(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var ar=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!zg(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,n,i,s,a;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Yr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var o=new Error('Uncaught, unspecified "error" event. ('+e+")");throw o.context=e,o}if(r=this._events[t],ba(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(Yr(r))for(i=Array.prototype.slice.call(arguments,1),a=r.slice(),n=a.length,s=0;s<n;s++)a[s].apply(this,i);return!0},Ve.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]?Yr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Yr(this._events[t])&&!this._events[t].warned&&(ba(this._maxListeners)?r=Ve.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},Ve.prototype.on=Ve.prototype.addListener,Ve.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},Ve.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(Yr(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},Ve.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},Ve.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},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Mt(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Mt(t){return typeof t=="function"}function zg(t){return typeof t=="number"}function Yr(t){return typeof t=="object"&&t!==null}function ba(t){return t===void 0}function Hg(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),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=i}var o=t.length,f=t.charAt(0),h=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function D(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var R=0,L=0,B=0,x=b.length;B!==x&&b[B]===0;)B++,R++;for(var A=(x-B)*l+1>>>0,_=new Uint8Array(A);B!==x;){for(var S=b[B],w=0,c=A-1;(S!==0||w<L)&&c!==-1;c--,w++)S+=256*_[c]>>>0,_[c]=S%o>>>0,S=S/o>>>0;if(S!==0)throw new Error("Non-zero carry");L=w,B++}for(var d=A-L;d!==A&&_[d]===0;)d++;for(var M=f.repeat(R);d<A;++d)M+=t.charAt(_[d]);return M}function E(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var R=0;if(b[R]!==" "){for(var L=0,B=0;b[R]===f;)L++,R++;for(var x=(b.length-R)*h+1>>>0,A=new Uint8Array(x);b[R];){var _=r[b.charCodeAt(R)];if(_===255)return;for(var S=0,w=x-1;(_!==0||S<B)&&w!==-1;w--,S++)_+=o*A[w]>>>0,A[w]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");B=S,R++}if(b[R]!==" "){for(var c=x-B;c!==x&&A[c]===0;)c++;for(var d=new Uint8Array(L+(x-c)),M=L;c!==x;)d[M++]=A[c++];return d}}}function m(b){var R=E(b);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:E,decode:m}}var qg=Hg,Kg=qg;const ma=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 kg{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 Wg{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 wa(this,e)}}class Yg{constructor(e){this.decoders=e}or(e){return wa(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 wa=(t,e)=>new Yg(ut(ut({},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 kg(e,r,n),this.decoder=new Wg(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const En=({name:t,prefix:e,encode:r,decode:n})=>new Jg(t,e,r,n),Jr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Kg(r,e);return En({prefix:t,name:e,encode:n,decode:s=>ma(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 a=new Uint8Array(s*r/8|0);let o=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,o+=r,o>=8&&(o-=8,a[h++]=255&f>>o)}if(o>=r||255&f<<8-o)throw new SyntaxError("Unexpected end of data");return a},Zg=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",a=0,o=0;for(let f=0;f<t.length;++f)for(o=o<<8|t[f],a+=8;a>r;)a-=r,s+=e[i&o>>a];if(a&&(s+=e[i&o<<r-a]),n)for(;s.length*r&7;)s+="=";return s},it=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>En({prefix:e,name:t,encode(i){return Zg(i,n,r)},decode(i){return Xg(i,n,r,t)}}),Qg=En({prefix:"\0",name:"identity",encode:t=>Gg(t),decode:t=>Vg(t)});var e_=Object.freeze({__proto__:null,identity:Qg});const t_=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var r_=Object.freeze({__proto__:null,base2:t_});const n_=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var i_=Object.freeze({__proto__:null,base8:n_});const s_=Jr({prefix:"9",name:"base10",alphabet:"0123456789"});var o_=Object.freeze({__proto__:null,base10:s_});const a_=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),c_=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var u_=Object.freeze({__proto__:null,base16:a_,base16upper:c_});const h_=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),f_=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),l_=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),d_=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),p_=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),g_=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),__=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),y_=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),v_=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var b_=Object.freeze({__proto__:null,base32:h_,base32upper:f_,base32pad:l_,base32padupper:d_,base32hex:p_,base32hexupper:g_,base32hexpad:__,base32hexpadupper:y_,base32z:v_});const m_=Jr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),w_=Jr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var E_=Object.freeze({__proto__:null,base36:m_,base36upper:w_});const D_=Jr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),S_=Jr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var x_=Object.freeze({__proto__:null,base58btc:D_,base58flickr:S_});const O_=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),I_=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),A_=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),T_=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var C_=Object.freeze({__proto__:null,base64:O_,base64pad:I_,base64url:A_,base64urlpad:T_});const Ea=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}"),P_=Ea.reduce((t,e,r)=>(t[r]=e,t),[]),L_=Ea.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function N_(t){return t.reduce((e,r)=>(e+=P_[r],e),"")}function R_(t){const e=[];for(const r of t){const n=L_[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const F_=En({prefix:"\u{1F680}",name:"base256emoji",encode:N_,decode:R_});var U_=Object.freeze({__proto__:null,base256emoji:F_}),$_=Sa,Da=128,M_=127,j_=~M_,B_=Math.pow(2,31);function Sa(t,e,r){e=e||[],r=r||0;for(var n=r;t>=B_;)e[r++]=t&255|Da,t/=128;for(;t&j_;)e[r++]=t&255|Da,t>>>=7;return e[r]=t|0,Sa.bytes=r-n+1,e}var z_=ji,H_=128,xa=127;function ji(t,n){var r=0,n=n||0,i=0,s=n,a,o=t.length;do{if(s>=o)throw ji.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=i<28?(a&xa)<<i:(a&xa)*Math.pow(2,i),i+=7}while(a>=H_);return ji.bytes=s-n,r}var q_=Math.pow(2,7),K_=Math.pow(2,14),V_=Math.pow(2,21),G_=Math.pow(2,28),k_=Math.pow(2,35),W_=Math.pow(2,42),Y_=Math.pow(2,49),J_=Math.pow(2,56),X_=Math.pow(2,63),Z_=function(t){return t<q_?1:t<K_?2:t<V_?3:t<G_?4:t<k_?5:t<W_?6:t<Y_?7:t<J_?8:t<X_?9:10},Q_={encode:$_,decode:z_,encodingLength:Z_},Oa=Q_;const Ia=(t,e,r=0)=>(Oa.encode(t,e,r),e),Aa=t=>Oa.encodingLength(t),Bi=(t,e)=>{const r=e.byteLength,n=Aa(t),i=n+Aa(r),s=new Uint8Array(i+r);return Ia(t,s,0),Ia(r,s,n),s.set(e,i),new ey(t,r,e,s)};class ey{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Ta=({name:t,code:e,encode:r})=>new ty(t,e,r);class ty{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?Bi(this.code,r):r.then(n=>Bi(this.code,n))}else throw Error("Unknown type, must be binary type")}}const Ca=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ry=Ta({name:"sha2-256",code:18,encode:Ca("SHA-256")}),ny=Ta({name:"sha2-512",code:19,encode:Ca("SHA-512")});var iy=Object.freeze({__proto__:null,sha256:ry,sha512:ny});const Pa=0,sy="identity",La=ma;var oy=Object.freeze({__proto__:null,identity:{code:Pa,name:sy,encode:La,digest:t=>Bi(Pa,La(t))}});new TextEncoder,new TextDecoder;const Na=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},e_),r_),i_),o_),u_),b_),E_),x_),C_),U_);ut(ut({},iy),oy);function ay(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ra(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Fa=Ra("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),zi=Ra("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=ay(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),cy=ut({utf8:Fa,"utf-8":Fa,hex:Na.base16,latin1:zi,ascii:zi,binary:zi},Na);function uy(t,e="utf8"){const r=cy[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 Ua="wc",hy=2,Hi="core",Gt=`${Ua}@${2}:${Hi}:`,fy={name:Hi,logger:"error"},ly={database:":memory:"},dy="crypto",$a="client_ed25519_seed",py=Z.ONE_DAY,gy="keychain",_y="0.3",yy="messages",vy="0.3",by=Z.SIX_HOURS,my="publisher",Ma="irn",wy="error",Ey="wss://relay.walletconnect.com",Dy="relayer",vr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Sy="_subscription",br={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},xy=Z.ONE_SECOND,Oy="2.1.3",Iy="0.3",jt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Ay="subscription",Ty="0.3",Cy=Z.FIVE_SECONDS*1e3,Py="pairing",Ly="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}}},Tt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Ny="history",Ry="0.3",Fy="expirer",bt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Uy="0.3";class $y{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=gy,this.version=_y,this.initialized=!1,this.storagePrefix=Gt,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=Se.generateChildLogger(r,this.name)}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,So(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?xo(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 My{constructor(e,r,n){this.core=e,this.logger=r,this.name=dy,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=ga(i);return pa(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=Il();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),a=ga(s),o=_i();return await Rg(o,i,py,a)},this.generateSharedKey=(i,s,a)=>{this.isInitialized();const o=this.getPrivateKey(i),f=Al(o,s);return this.setSymKey(f,a)},this.setSymKey=async(i,s)=>{this.isInitialized();const a=s||Tl(i);return await this.keychain.set(a,i),a},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,a)=>{this.isInitialized();const o=vo(a),f=Or(s);if(bo(o)){const E=o.senderPublicKey,m=o.receiverPublicKey;i=await this.generateSharedKey(E,m)}const h=this.getSymKey(i),{type:l,senderPublicKey:D}=o;return Pl({type:l,symKey:h,message:f,senderPublicKey:D})},this.decode=async(i,s,a)=>{this.isInitialized();const o=Rl(s,a);if(bo(o)){const l=o.receiverPublicKey,D=o.senderPublicKey;i=await this.generateSharedKey(l,D)}const f=this.getSymKey(i),h=Ll({symKey:f,encoded:s});return zn(h)},this.core=e,this.logger=Se.generateChildLogger(r,this.name),this.keychain=n||new $y(this.core,this.logger)}get context(){return Se.getLoggerContext(this.logger)}getPayloadType(e){const r=yi(e);return Nr(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($a)}catch{e=_i(),await this.keychain.set($a,e)}return uy(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 jy extends fg{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=yy,this.version=vy,this.initialized=!1,this.storagePrefix=Gt,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=gn(i);let a=this.messages.get(n);return typeof a>"u"&&(a={}),typeof a[s]<"u"||(a[s]=i,this.messages.set(n,a),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),a=gn(i);return typeof s[a]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Se.generateChildLogger(e,this.name),this.core=r}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,So(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?xo(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 By extends lg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new ar.EventEmitter,this.name=my,this.queue=new Map,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 a=s?.ttl||by,o=vi(s),f=s?.prompt||!1,h=s?.tag||0,l={topic:n,message:i,opts:{ttl:a,relay:o,prompt:f,tag:h}},D=gn(i);this.queue.set(D,l),await this.rpcPublish(n,i,a,o,f,h),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(a){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(a),a}},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=Se.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Se.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,a){var o,f,h,l;const D={method:bi(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:a}};return vt((o=D.params)==null?void 0:o.prompt)&&((f=D.params)==null||delete f.prompt),vt((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:{ttl:i,relay:s,prompt:a,tag:o}}=e,f=gn(n);await this.rpcPublish(r,n,i,s,a,o),this.onPublish(f,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(qr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class zy{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 Hy=Object.defineProperty,qy=Object.defineProperties,Ky=Object.getOwnPropertyDescriptors,ja=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Gy=Object.prototype.propertyIsEnumerable,Ba=(t,e,r)=>e in t?Hy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dn=(t,e)=>{for(var r in e||(e={}))Vy.call(e,r)&&Ba(t,r,e[r]);if(ja)for(var r of ja(e))Gy.call(e,r)&&Ba(t,r,e[r]);return t},qi=(t,e)=>qy(t,Ky(e));class ky extends gg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new zy,this.events=new ar.EventEmitter,this.name=Ay,this.version=Ty,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Gt,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=vi(i),a={topic:n,relay:s};this.pending.set(n,a);const o=await this.rpcSubscribe(n,s);return this.onSubscribe(o,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),o}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 a=new Z.Watch;a.start(this.pendingSubscriptionWatchLabel);const o=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(o),a.stop(this.pendingSubscriptionWatchLabel),i(!0)),a.elapsed(this.pendingSubscriptionWatchLabel)>=Cy&&(clearInterval(o),a.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=Se.generateChildLogger(r,this.name)}get context(){return Se.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=vi(n);await this.rpcUnsubscribe(e,r,i);const s=Be("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:bi(r.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),await this.relayer.provider.request(n)}rpcUnsubscribe(e,r,n){const i={method:bi(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,qi(Dn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,qi(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(jt.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(jt.deleted,qi(Dn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(jt.sync)}async reset(){this.cached.length&&await Promise.all(this.cached.map(async e=>await this.resubscribe(e))),this.events.emit(jt.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(qr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(br.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(br.disconnect,()=>{this.onDisconnect()}),this.events.on(jt.created,async e=>{const r=jt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(jt.deleted,async e=>{const r=jt.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 Wy=Object.defineProperty,za=Object.getOwnPropertySymbols,Yy=Object.prototype.hasOwnProperty,Jy=Object.prototype.propertyIsEnumerable,Ha=(t,e,r)=>e in t?Wy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xy=(t,e)=>{for(var r in e||(e={}))Yy.call(e,r)&&Ha(t,r,e[r]);if(za)for(var r of za(e))Jy.call(e,r)&&Ha(t,r,e[r]);return t};class Zy extends dg{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new ar.EventEmitter,this.name=Dy,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Se.generateChildLogger(e.logger,this.name):_n(Se.getDefaultLoggerOptions({level:e.logger||wy})),this.messages=new jy(this.logger,e.core),this.subscriber=new ky(this,this.logger),this.publisher=new By(this,this.logger),this.relayUrl=e?.relayUrl||Ey,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.provider=await this.createProvider(),await Promise.all([this.messages.init(),this.provider.connect(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Se.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){return this.isInitialized(),await this.subscriber.subscribe(e,r)}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,await this.provider.disconnect()}async transportOpen(e){this.relayUrl=e||this.relayUrl,this.transportExplicitlyClosed=!1,await this.provider.connect(),await new Promise(r=>{this.subscriber.once(jt.resubscribed,()=>{r()})})}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new jn(new Ug(Wl({sdkVersion:Oy,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}),$n(e)){if(!e.method.endsWith(Sy))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(Xy({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(vr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=sn(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(br.payload,e=>this.onProviderPayload(e)),this.provider.on(br.connect,()=>{this.events.emit(vr.connect)}),this.provider.on(br.disconnect,()=>{this.events.emit(vr.disconnect),this.attemptToReconnect()}),this.provider.on(br.error,e=>this.events.emit(vr.error,e))}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(()=>{this.provider.connect()},Z.toMiliseconds(xy))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qy=Object.defineProperty,qa=Object.getOwnPropertySymbols,e0=Object.prototype.hasOwnProperty,t0=Object.prototype.propertyIsEnumerable,Ka=(t,e,r)=>e in t?Qy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Va=(t,e)=>{for(var r in e||(e={}))e0.call(e,r)&&Ka(t,r,e[r]);if(qa)for(var r of qa(e))t0.call(e,r)&&Ka(t,r,e[r]);return t};class Ki extends pg{constructor(e,r,n,i=Gt,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=Iy,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(a=>{pd(a)?this.map.set(a.id,a):gd(a)?this.map.set(a.topic,a):this.getKey&&a!==null&&!vt(a)&&this.map.set(this.getKey(a),a)}),this.cached=[],this.initialized=!0)},this.set=async(a,o)=>{this.isInitialized(),this.map.has(a)?await this.update(a,o):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:a,value:o}),this.map.set(a,o),await this.persist())},this.get=a=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:a}),this.getData(a)),this.getAll=a=>(this.isInitialized(),a?this.values.filter(o=>Object.keys(a).every(f=>$g(o[f],a[f]))):this.values),this.update=async(a,o)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:a,update:o});const f=Va(Va({},this.getData(a)),o);this.map.set(a,f),await this.persist()},this.delete=async(a,o)=>{this.isInitialized(),this.map.has(a)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:a,reason:o}),this.map.delete(a),await this.persist())},this.logger=Se.generateChildLogger(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return Se.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 r0{constructor(e,r){this.core=e,this.logger=r,this.name=Py,this.version=Ly,this.events=new ar,this.initialized=!1,this.storagePrefix=Gt,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=_i(),i=await this.core.crypto.setSymKey(n),s=Ut(Z.FIVE_MINUTES),a={protocol:Ma},o={topic:i,expiry:s,relay:a,active:!1},f=sd({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:a});return await this.pairings.set(i,o),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:a}=nd(n.uri),o=Ut(Z.FIVE_MINUTES),f={topic:i,relay:a,expiry:o,active:!1};return await this.pairings.set(i,f),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:a}),this.core.expirer.set(i,o),n.activatePairing&&await this.activate({topic:i}),f},this.activate=async({topic:n})=>{this.isInitialized();const i=Ut(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:a,resolve:o,reject:f}=nr();this.events.once(Ne("pairing_ping",s),({error:h})=>{h?f(h):o()}),await a()}},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",Be("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const a=nn(i,s),o=await this.core.crypto.encode(n,a),f=Xr[i].req;return this.core.history.set(n,a),await this.core.relayer.publish(n,o,f),a.id},this.sendResult=async(n,i,s)=>{const a=sn(n,s),o=await this.core.crypto.encode(i,a),f=await this.core.history.get(i,n),h=Xr[f.request.method].res;await this.core.relayer.publish(i,o,h),await this.core.history.resolve(a)},this.sendError=async(n,i,s)=>{const a=xr(n,s),o=await this.core.crypto.encode(i,a),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,o,h),await this.core.history.resolve(a)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Be("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=>Vt(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n;switch(s.method){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,a=(await this.core.history.get(i,s.id)).request.method;switch(a){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(a)}},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(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Ft(i)?this.events.emit(Ne("pairing_ping",s),{}):Dt(i)&&this.events.emit(Ne("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(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:a}=i;try{if(this.registeredMethods.includes(a))return;const o=Be("WC_METHOD_UNSUPPORTED",a);await this.sendError(s,n,o),this.logger.error(o)}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Be("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!pt(n)){const{message:i}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!dd(n.uri)){const{message:i}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!pt(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(!pt(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(!nt(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(Vt(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=Se.generateChildLogger(r,this.name),this.pairings=new Ki(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Se.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(vr.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);$n(i)?(this.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):Mn(i)&&(await this.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.core.expirer.on(bt.expired,async e=>{const{topic:r}=Io(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class n0 extends hg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new ar.EventEmitter,this.name=Ny,this.version=Ry,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,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 a={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(a.id,a),this.events.emit(Tt.created,a)},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=Dt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Tt.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(Tt.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=Se.generateChildLogger(r,this.name)}get context(){return Se.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:nn(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(Tt.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(Tt.created,e=>{const r=Tt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.updated,e=>{const r=Tt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.deleted,e=>{const r=Tt.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 i0 extends _g{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new ar.EventEmitter,this.name=Fy,this.version=Uy,this.cached=[],this.initialized=!1,this.storagePrefix=Gt,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),a={target:s,expiry:i};this.expirations.set(s,a),this.checkExpiry(s,a),this.events.emit(bt.created,{target:s,expiration:a})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{this.isInitialized();const i=this.formatTarget(n);if(this.has(i)){const s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(bt.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=Se.generateChildLogger(r,this.name)}get context(){return Se.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 Yl(e);if(typeof e=="number")return Jl(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(bt.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(bt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(qr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(bt.created,e=>{const r=bt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(bt.expired,e=>{const r=bt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(bt.deleted,e=>{const r=bt.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 s0=Object.defineProperty,Ga=Object.getOwnPropertySymbols,o0=Object.prototype.hasOwnProperty,a0=Object.prototype.propertyIsEnumerable,ka=(t,e,r)=>e in t?s0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wa=(t,e)=>{for(var r in e||(e={}))o0.call(e,r)&&ka(t,r,e[r]);if(Ga)for(var r of Ga(e))a0.call(e,r)&&ka(t,r,e[r]);return t};class Vi extends ug{constructor(e){super(e),this.protocol=Ua,this.version=hy,this.name=Hi,this.events=new ar.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(Se.getDefaultLoggerOptions({level:e?.logger||fy.logger}));this.logger=Se.generateChildLogger(r,this.name),this.heartbeat=new qr.HeartBeat,this.crypto=new My(this,this.logger,e?.keychain),this.history=new n0(this,this.logger),this.expirer=new i0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new gp(Wa(Wa({},ly),e?.storageOptions)),this.relayer=new Zy({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new r0(this,this.logger)}static async init(e){const r=new Vi(e);return await r.initialize(),r}get context(){return Se.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 Initilization Success")}catch(e){throw this.logger.warn(`Core Initilization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const c0=Vi;function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Ya=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!u0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,n,i,s,a;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Zr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var o=new Error('Uncaught, unspecified "error" event. ('+e+")");throw o.context=e,o}if(r=this._events[t],Ja(r))return!1;if(Bt(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(Zr(r))for(i=Array.prototype.slice.call(arguments,1),a=r.slice(),n=a.length,s=0;s<n;s++)a[s].apply(this,i);return!0},Ge.prototype.addListener=function(t,e){var r;if(!Bt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Bt(e.listener)?e.listener:e),this._events[t]?Zr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Zr(this._events[t])&&!this._events[t].warned&&(Ja(this._maxListeners)?r=Ge.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},Ge.prototype.on=Ge.prototype.addListener,Ge.prototype.once=function(t,e){if(!Bt(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},Ge.prototype.removeListener=function(t,e){var r,n,i,s;if(!Bt(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||Bt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Zr(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},Ge.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],Bt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ge.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Bt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Bt(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Bt(t){return typeof t=="function"}function u0(t){return typeof t=="number"}function Zr(t){return typeof t=="object"&&t!==null}function Ja(t){return t===void 0}const Xa="wc",Za=2,Qa="client",ec=`${Xa}@${Za}:${Qa}:`,Gi={name:Qa,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},h0="proposal",f0="session",Sn=Z.SEVEN_DAYS,l0="engine",xn={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}}};var d0=Object.defineProperty,p0=Object.defineProperties,g0=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,_0=Object.prototype.hasOwnProperty,y0=Object.prototype.propertyIsEnumerable,rc=(t,e,r)=>e in t?d0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e)=>{for(var r in e||(e={}))_0.call(e,r)&&rc(t,r,e[r]);if(tc)for(var r of tc(e))y0.call(e,r)&&rc(t,r,e[r]);return t},nc=(t,e)=>p0(t,g0(e));class v0 extends mg{constructor(e){super(e),this.name=l0,this.events=new Ya,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(xn)}),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let a=n,o,f=!1;if(a&&(f=this.client.core.pairing.pairings.get(a).active),!a||!f){const{topic:L,uri:B}=await this.client.core.pairing.create();a=L,o=B}const h=await this.client.core.crypto.generateKeyPair(),l={requiredNamespaces:i,relays:s??[{protocol:Ma}],proposer:{publicKey:h,metadata:this.client.metadata}},{reject:D,resolve:E,done:m}=nr();if(this.events.once(Ne("session_connect"),async({error:L,session:B})=>{if(L)D(L);else if(B){B.self.publicKey=h;const x=nc(kt({},B),{requiredNamespaces:i});await this.client.session.set(B.topic,x),await this.setExpiry(B.topic,B.expiry),a&&await this.client.core.pairing.updateMetadata({topic:a,metadata:B.peer.metadata}),E(x)}}),!a){const{message:L}=V("NO_MATCHING_KEY",`connect() pairing topic: ${a}`);throw new Error(L)}const b=await this.sendRequest(a,"wc_sessionPropose",l),R=Ut(Z.FIVE_MINUTES);return await this.setProposal(b,kt({id:b,expiry:R},l)),{uri:o,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,{pairingTopic:a,proposer:o,requiredNamespaces:f}=this.client.proposal.get(n),h=await this.client.core.crypto.generateKeyPair(),l=o.publicKey,D=await this.client.core.crypto.generateSharedKey(h,l),E={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:f,controller:{publicKey:h,metadata:this.client.metadata},expiry:Ut(Sn)};await this.client.core.relayer.subscribe(D);const m=await this.sendRequest(D,"wc_sessionSettle",E),{done:b,resolve:R,reject:L}=nr();this.events.once(Ne("session_approve",m),({error:x})=>{x?L(x):R(this.client.session.get(D))});const B=nc(kt({},E),{topic:D,acknowledged:!1,self:E.controller,peer:{publicKey:o.publicKey,metadata:o.metadata},controller:h});return await this.client.session.set(D,B),await this.setExpiry(D,Ut(Sn)),a&&await this.client.core.pairing.updateMetadata({topic:a,metadata:B.peer.metadata}),a&&n&&(await this.sendResult(n,a,{relay:{protocol:i??"irn"},responderPublicKey:h}),await this.client.proposal.delete(n,Be("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a})),{topic:D,acknowledged:b}},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,Be("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:a,resolve:o,reject:f}=nr();return this.events.once(Ne("session_update",s),({error:h})=>{h?f(h):o()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:a}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:a,reject:o}=nr();return this.events.once(Ne("session_extend",i),({error:f})=>{f?o(f):a()}),await this.setExpiry(n,Ut(Sn)),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s}=r,a=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n}),{done:o,resolve:f,reject:h}=nr();return this.events.once(Ne("session_request",a),({error:l,result:D})=>{l?h(l):f(D)}),await o()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Ft(i)?await this.sendResult(s,n,i.result):Dt(i)&&await this.sendError(s,n,i.error)},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:a,reject:o}=nr();this.events.once(Ne("session_ping",i),({error:f})=>{f?o(f):a()}),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",Be("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=>fd(n,r))),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,Be("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,Be("USER_DISCONNECTED")),n?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.sendRequest=async(r,n,i)=>{const s=nn(n,i),a=await this.client.core.crypto.encode(r,s),o=xn[n].req;return this.client.core.history.set(r,s),this.client.core.relayer.publish(r,a,o),s.id},this.sendResult=async(r,n,i)=>{const s=sn(r,i),a=await this.client.core.crypto.encode(n,s),o=await this.client.core.history.get(n,r),f=xn[o.request.method].res;this.client.core.relayer.publish(n,a,f),await this.client.core.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=xr(r,i),a=await this.client.core.crypto.encode(n,s),o=await this.client.core.history.get(n,r),f=xn[o.request.method].res;this.client.core.relayer.publish(n,a,f),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{Vt(i.expiry)&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{Vt(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 a=Ut(Z.FIVE_MINUTES),o=kt({id:s,pairingTopic:r,expiry:a},i);await this.setProposal(s,o),this.client.events.emit("session_proposal",{id:s,params:o})}catch(a){await this.sendError(s,r,a),this.client.logger.error(a)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Ft(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const a=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const o=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const f=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const h=await this.client.core.crypto.generateSharedKey(o,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 Dt(n)&&(await this.client.proposal.delete(i,Be("USER_DISCONNECTED")),this.events.emit(Ne("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:a,controller:o,expiry:f,namespaces:h}=n.params,l={topic:r,relay:a,expiry:f,namespaces:h,acknowledged:!0,controller:o.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Ne("session_connect"),{session:l})}catch(a){await this.sendError(i,r,a),this.client.logger.error(a)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Ft(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Ne("session_approve",i),{})):Dt(n)&&(await this.client.session.delete(r,Be("USER_DISCONNECTED")),this.events.emit(Ne("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(a){await this.sendError(s,r,a),this.client.logger.error(a)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Ft(n)?this.events.emit(Ne("session_update",i),{}):Dt(n)&&this.events.emit(Ne("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Ut(Sn)),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;Ft(n)?this.events.emit(Ne("session_extend",i),{}):Dt(n)&&this.events.emit(Ne("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(()=>{Ft(n)?this.events.emit(Ne("session_ping",i),{}):Dt(n)&&this.events.emit(Ne("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)),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(a){await this.sendError(i,r,a),this.client.logger.error(a)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Ft(n)?this.events.emit(Ne("session_request",i),{result:n.result}):Dt(n)&&this.events.emit(Ne("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(a){await this.sendError(i,r,a),this.client.logger.error(a)}},this.isValidConnect=async r=>{if(!pt(r)){const{message:o}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(o)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;vt(n)||await this.isValidPairingTopic(n);const a=bd(i,"connect()");if(a)throw new Error(a.message);if(!md(s,!0)){const{message:o}=V("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(o)}},this.isValidApprove=async r=>{if(!pt(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 a=this.client.proposal.get(n),o=Ei(i,"approve()");if(o)throw new Error(o.message);const f=jo(a.requiredNamespaces,i,"update()");if(f)throw new Error(f.message);if(!nt(s,!0)){const{message:h}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}},this.isValidReject=async r=>{if(!pt(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(!pt(r)){const{message:h}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:n,controller:i,namespaces:s,expiry:a}=r;if(!$o(n)){const{message:h}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const o=_d(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);const f=Ei(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(Vt(a)){const{message:h}=V("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!pt(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),a=Ei(i,"update()");if(a)throw new Error(a.message);const o=jo(s.requiredNamespaces,i,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async r=>{if(!pt(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(!pt(r)){const{message:o}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(o)}const{topic:n,request:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!Mo(a,s)){const{message:o}=V("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(o)}if(!Dd(i)){const{message:o}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(o)}if(!Od(a,s,i.method)){const{message:o}=V("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(o)}},this.isValidRespond=async r=>{if(!pt(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(!pt(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(!pt(r)){const{message:o}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(o)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!Mo(a,s)){const{message:o}=V("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(o)}if(!xd(i)){const{message:o}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(o)}if(!Id(a,s,i.name)){const{message:o}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(o)}},this.isValidDisconnect=async r=>{if(!pt(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(vr.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);$n(i)?(this.client.core.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):Mn(i)&&(await this.client.core.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.core.expirer.on(bt.expired,async e=>{const{topic:r,id:n}=Io(e.target);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(!nt(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(Vt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!nt(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(Vt(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(nt(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(!wd(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(Vt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class b0 extends Ki{constructor(e,r){super(e,r,h0,ec),this.core=e,this.logger=r}}class m0 extends Ki{constructor(e,r){super(e,r,f0,ec),this.core=e,this.logger=r}}class ki extends bg{constructor(e){super(e),this.protocol=Xa,this.version=Za,this.name=Gi.name,this.events=new Ya.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.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.name=e?.name||Gi.name,this.metadata=e?.metadata||Kl();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:_n(Se.getDefaultLoggerOptions({level:e?.logger||Gi.logger}));this.core=e?.core||new c0(e),this.logger=Se.generateChildLogger(r,this.name),this.session=new m0(this.core,this.logger),this.proposal=new b0(this.core,this.logger),this.engine=new v0(this)}static async init(e){const r=new ki(e);return await r.initialize(),r}get context(){return Se.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.engine.init(),this.logger.info("SignClient Initilization Success")}catch(e){throw this.logger.info("SignClient Initilization Failure"),this.logger.error(e.message),e}}}function ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var w0=ke;ke.EventEmitter=ke,ke.prototype._events=void 0,ke.prototype._maxListeners=void 0,ke.defaultMaxListeners=10,ke.prototype.setMaxListeners=function(t){if(!E0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},ke.prototype.emit=function(t){var e,r,n,i,s,a;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Qr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var o=new Error('Uncaught, unspecified "error" event. ('+e+")");throw o.context=e,o}if(r=this._events[t],ic(r))return!1;if(zt(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(Qr(r))for(i=Array.prototype.slice.call(arguments,1),a=r.slice(),n=a.length,s=0;s<n;s++)a[s].apply(this,i);return!0},ke.prototype.addListener=function(t,e){var r;if(!zt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,zt(e.listener)?e.listener:e),this._events[t]?Qr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Qr(this._events[t])&&!this._events[t].warned&&(ic(this._maxListeners)?r=ke.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},ke.prototype.on=ke.prototype.addListener,ke.prototype.once=function(t,e){if(!zt(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},ke.prototype.removeListener=function(t,e){var r,n,i,s;if(!zt(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||zt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Qr(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},ke.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],zt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:zt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(zt(e))return 1;if(e)return e.length}return 0},ke.listenerCount=function(t,e){return t.listenerCount(e)};function zt(t){return typeof t=="function"}function E0(t){return typeof t=="number"}function Qr(t){return typeof t=="object"&&t!==null}function ic(t){return t===void 0}function D0(t){return typeof t<"u"&&typeof t.context<"u"}const Ct={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class S0 extends Xc{constructor(e){super(),this.events=new w0.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?fi(this.session.namespaces):xl(this.requiredNamespaces)}get accounts(){return this.session?hi(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(Ct.uri,{uri:n}),this.session=await i(),this.events.emit(Ct.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:Be("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",sn(e.id,n))).catch(n=>this.events.emit("payload",xr(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(Ct.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(D0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await ki.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Ct.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(Ct.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(Ct.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(Ct.deleted,this.session),this.session=void 0)}))}}const x0=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],O0=["chainChanged","accountsChanged"];function sc(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function oc(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Wi([t])]),r}function Wi(t){return Number(t[0].split(":")[1])}class I0{constructor(e){this.events=new wr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=sc(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Wi(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(Ct.created,e=>{const r=fi(e.namespaces,[this.namespace]);this.setChainIds(r);const n=hi(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(Ct.updated,e=>{const r=fi(e.namespaces,[this.namespace]);this.setChainIds(r);const n=hi(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(Ct.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 S0({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new jn(r)}setHttpProvider(e){const r=oc(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new jn(new iu(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)}}Et.default=I0,Et.getEthereumChainId=Wi,Et.getRpcConfig=sc,Et.getRpcUrl=oc,Et.signerEvents=O0,Et.signerMethods=x0,Object.defineProperty(Et,"__esModule",{value:!0})});
|
|
2
67
|
//# sourceMappingURL=index.umd.js.map
|