@walletconnect/ethereum-provider 2.1.2 → 2.1.3-1d7c9de6
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 +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -6
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 Ba(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function vi(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 gr=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!za(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||yr(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],Cn(r))return!1;if(Nt(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(yr(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(!Nt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Nt(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&&(Cn(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(!Nt(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(!Nt(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||Nt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(yr(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],Nt(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=[]:Nt(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(Nt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function za(t){return typeof t=="number"}function yr(t){return typeof t=="object"&&t!==null}function Cn(t){return t===void 0}const Ha="PARSE_ERROR",Ka="INVALID_REQUEST",qa="METHOD_NOT_FOUND",Va="INVALID_PARAMS",Nn="INTERNAL_ERROR",_i="SERVER_ERROR",Ga=[-32700,-32600,-32601,-32602,-32603],vr={[Ha]:{code:-32700,message:"Parse error"},[Ka]:{code:-32600,message:"Invalid Request"},[qa]:{code:-32601,message:"Method not found"},[Va]:{code:-32602,message:"Invalid params"},[Nn]:{code:-32603,message:"Internal error"},[_i]:{code:-32e3,message:"Server error"}},Ln=_i;function Wa(t){return Ga.includes(t)}function Rn(t){return Object.keys(vr).includes(t)?vr[t]:vr[Ln]}function ka(t){const e=Object.values(vr).find(r=>r.code===t);return e||vr[Ln]}function Pn(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Fn={},Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.isBrowserCryptoAvailable=Bt.getSubtleCrypto=Bt.getBrowerCrypto=void 0;function bi(){return Z?.crypto||Z?.msCrypto||{}}Bt.getBrowerCrypto=bi;function Un(){const t=bi();return t.subtle||t.webkitSubtle}Bt.getSubtleCrypto=Un;function Ya(){return!!bi()&&!!Un()}Bt.isBrowserCryptoAvailable=Ya;var zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.isBrowser=zt.isNode=zt.isReactNative=void 0;function Mn(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}zt.isReactNative=Mn;function jn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}zt.isNode=jn;function Ja(){return!Mn()&&!jn()}zt.isBrowser=Ja,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(Bt,t),r(zt,t)}(Fn);function Xa(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function Hr(t,e,r){return{id:r||Xa(),jsonrpc:"2.0",method:t,params:e}}function Kr(t,e){return{id:t,jsonrpc:"2.0",result:e}}function _r(t,e,r){return{id:t,jsonrpc:"2.0",error:Za(e,r)}}function Za(t,e){return typeof t>"u"?Rn(Nn):(typeof t=="string"&&(t=Object.assign(Object.assign({},Rn(_i)),{message:t})),typeof e<"u"&&(t.data=e),Wa(t.code)&&(t=ka(t.code)),t)}class $n{}class Qa extends $n{constructor(e){super()}}class ec extends $n{constructor(){super()}}class tc extends ec{constructor(e){super()}}const rc="^https?:",ic="^wss?:";function nc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Bn(t,e){const r=nc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function zn(t){return Bn(t,rc)}function Hn(t){return Bn(t,ic)}function sc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Kn(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function mi(t){return Kn(t)&&"method"in t}function wi(t){return Kn(t)&&(Lt(t)||Dt(t))}function Lt(t){return"result"in t}function Dt(t){return"error"in t}class Ei extends tc{constructor(e){super(e),this.events=new gr.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(Hr(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),wi(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 Di={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 l(u){return u&&DataView.prototype.isPrototypeOf(u)}if(h.arrayBuffer)var p=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],y=ArrayBuffer.isView||function(u){return u&&p.indexOf(Object.prototype.toString.call(u))>-1};function D(u){if(typeof u!="string"&&(u=String(u)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(u))throw new TypeError("Invalid character in header field name");return u.toLowerCase()}function A(u){return typeof u!="string"&&(u=String(u)),u}function S(u){var v={next:function(){var j=u.shift();return{done:j===void 0,value:j}}};return h.iterable&&(v[Symbol.iterator]=function(){return v}),v}function E(u){this.map={},u instanceof E?u.forEach(function(v,j){this.append(j,v)},this):Array.isArray(u)?u.forEach(function(v){this.append(v[0],v[1])},this):u&&Object.getOwnPropertyNames(u).forEach(function(v){this.append(v,u[v])},this)}E.prototype.append=function(u,v){u=D(u),v=A(v);var j=this.map[u];this.map[u]=j?j+", "+v:v},E.prototype.delete=function(u){delete this.map[D(u)]},E.prototype.get=function(u){return u=D(u),this.has(u)?this.map[u]:null},E.prototype.has=function(u){return this.map.hasOwnProperty(D(u))},E.prototype.set=function(u,v){this.map[D(u)]=A(v)},E.prototype.forEach=function(u,v){for(var j in this.map)this.map.hasOwnProperty(j)&&u.call(v,this.map[j],j,this)},E.prototype.keys=function(){var u=[];return this.forEach(function(v,j){u.push(j)}),S(u)},E.prototype.values=function(){var u=[];return this.forEach(function(v){u.push(v)}),S(u)},E.prototype.entries=function(){var u=[];return this.forEach(function(v,j){u.push([j,v])}),S(u)},h.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function N(u){if(u.bodyUsed)return Promise.reject(new TypeError("Already read"));u.bodyUsed=!0}function L(u){return new Promise(function(v,j){u.onload=function(){v(u.result)},u.onerror=function(){j(u.error)}})}function B(u){var v=new FileReader,j=L(v);return v.readAsArrayBuffer(u),j}function w(u){var v=new FileReader,j=L(v);return v.readAsText(u),j}function I(u){for(var v=new Uint8Array(u),j=new Array(v.length),q=0;q<v.length;q++)j[q]=String.fromCharCode(v[q]);return j.join("")}function _(u){if(u.slice)return u.slice(0);var v=new Uint8Array(u.byteLength);return v.set(new Uint8Array(u)),v.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(u){this._bodyInit=u,u?typeof u=="string"?this._bodyText=u:h.blob&&Blob.prototype.isPrototypeOf(u)?this._bodyBlob=u:h.formData&&FormData.prototype.isPrototypeOf(u)?this._bodyFormData=u:h.searchParams&&URLSearchParams.prototype.isPrototypeOf(u)?this._bodyText=u.toString():h.arrayBuffer&&h.blob&&l(u)?(this._bodyArrayBuffer=_(u.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):h.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(u)||y(u))?this._bodyArrayBuffer=_(u):this._bodyText=u=Object.prototype.toString.call(u):this._bodyText="",this.headers.get("content-type")||(typeof u=="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(u)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},h.blob&&(this.blob=function(){var u=N(this);if(u)return u;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?N(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var u=N(this);if(u)return u;if(this._bodyBlob)return w(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(P)}),this.json=function(){return this.text().then(JSON.parse)},this}var d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(u){var v=u.toUpperCase();return d.indexOf(v)>-1?v:u}function f(u,v){v=v||{};var j=v.body;if(u instanceof f){if(u.bodyUsed)throw new TypeError("Already read");this.url=u.url,this.credentials=u.credentials,v.headers||(this.headers=new E(u.headers)),this.method=u.method,this.mode=u.mode,this.signal=u.signal,!j&&u._bodyInit!=null&&(j=u._bodyInit,u.bodyUsed=!0)}else this.url=String(u);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new E(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")&&j)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(j)}f.prototype.clone=function(){return new f(this,{body:this._bodyInit})};function P(u){var v=new FormData;return u.trim().split("&").forEach(function(j){if(j){var q=j.split("="),F=q.shift().replace(/\+/g," "),R=q.join("=").replace(/\+/g," ");v.append(decodeURIComponent(F),decodeURIComponent(R))}}),v}function U(u){var v=new E,j=u.replace(/\r?\n[\t ]+/g," ");return j.split(/\r?\n/).forEach(function(q){var F=q.split(":"),R=F.shift().trim();if(R){var M=F.join(":").trim();v.append(R,M)}}),v}m.call(f.prototype);function H(u,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 E(v.headers),this.url=v.url||"",this._initBody(u)}m.call(H.prototype),H.prototype.clone=function(){return new H(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},H.error=function(){var u=new H(null,{status:0,statusText:""});return u.type="error",u};var G=[301,302,303,307,308];H.redirect=function(u,v){if(G.indexOf(v)===-1)throw new RangeError("Invalid status code");return new H(null,{status:v,headers:{location:u}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(v,j){this.message=v,this.name=j;var q=Error(v);this.stack=q.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Y(u,v){return new Promise(function(j,q){var F=new f(u,v);if(F.signal&&F.signal.aborted)return q(new c.DOMException("Aborted","AbortError"));var R=new XMLHttpRequest;function M(){R.abort()}R.onload=function(){var z={status:R.status,statusText:R.statusText,headers:U(R.getAllResponseHeaders()||"")};z.url="responseURL"in R?R.responseURL:z.headers.get("X-Request-URL");var Q="response"in R?R.response:R.responseText;j(new H(Q,z))},R.onerror=function(){q(new TypeError("Network request failed"))},R.ontimeout=function(){q(new TypeError("Network request failed"))},R.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},R.open(F.method,F.url,!0),F.credentials==="include"?R.withCredentials=!0:F.credentials==="omit"&&(R.withCredentials=!1),"responseType"in R&&h.blob&&(R.responseType="blob"),F.headers.forEach(function(z,Q){R.setRequestHeader(Q,z)}),F.signal&&(F.signal.addEventListener("abort",M),R.onreadystatechange=function(){R.readyState===4&&F.signal.removeEventListener("abort",M)}),R.send(typeof F._bodyInit>"u"?null:F._bodyInit)})}return Y.polyfill=!0,s.fetch||(s.fetch=Y,s.Headers=E,s.Request=f,s.Response=H),c.Headers=E,c.Request=f,c.Response=H,c.fetch=Y,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})(Di,Di.exports);var qn=Ba(Di.exports);function Si(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 br(t){return typeof t=="string"?t:JSON.stringify(t)}const Vn={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},Gn=10;class oc{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.isAvailable=!1,this.registering=!1,!zn(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=br(e),s=await(await qn(this.url,Object.assign(Object.assign({},Vn),{body:i}))).json();this.onPayload({data:s})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!zn(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=br({id:1,jsonrpc:"2.0",method:"test",params:[]});await qn(e,Object.assign(Object.assign({},Vn),{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"?Si(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=_r(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Pn(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Gn&&this.events.setMaxListeners(Gn)}}var xi={},qr={},ie={},Wn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(h,l){var p=h>>>16&65535,y=h&65535,D=l>>>16&65535,A=l&65535;return y*A+(p*A+y*D<<16>>>0)|0}t.mul=Math.imul||e;function r(h,l){return h+l|0}t.add=r;function i(h,l){return h-l|0}t.sub=i;function n(h,l){return h<<l|h>>>32-l}t.rotl=n;function s(h,l){return h<<32-l|h>>>l}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}})(Wn),Object.defineProperty(ie,"__esModule",{value:!0});var kn=Wn;function ac(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}ie.readInt16BE=ac;function cc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}ie.readUint16BE=cc;function hc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}ie.readInt16LE=hc;function uc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}ie.readUint16LE=uc;function Yn(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}ie.writeUint16BE=Yn,ie.writeInt16BE=Yn;function Jn(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}ie.writeUint16LE=Jn,ie.writeInt16LE=Jn;function Oi(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}ie.readInt32BE=Oi;function Ii(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}ie.readUint32BE=Ii;function Ai(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}ie.readInt32LE=Ai;function Ti(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}ie.readUint32LE=Ti;function Vr(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}ie.writeUint32BE=Vr,ie.writeInt32BE=Vr;function Gr(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}ie.writeUint32LE=Gr,ie.writeInt32LE=Gr;function fc(t,e){e===void 0&&(e=0);var r=Oi(t,e),i=Oi(t,e+4);return r*4294967296+i-(i>>31)*4294967296}ie.readInt64BE=fc;function lc(t,e){e===void 0&&(e=0);var r=Ii(t,e),i=Ii(t,e+4);return r*4294967296+i}ie.readUint64BE=lc;function dc(t,e){e===void 0&&(e=0);var r=Ai(t,e),i=Ai(t,e+4);return i*4294967296+r-(r>>31)*4294967296}ie.readInt64LE=dc;function pc(t,e){e===void 0&&(e=0);var r=Ti(t,e),i=Ti(t,e+4);return i*4294967296+r}ie.readUint64LE=pc;function Xn(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Vr(t/4294967296>>>0,e,r),Vr(t>>>0,e,r+4),e}ie.writeUint64BE=Xn,ie.writeInt64BE=Xn;function Zn(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Gr(t>>>0,e,r),Gr(t/4294967296>>>0,e,r+4),e}ie.writeUint64LE=Zn,ie.writeInt64LE=Zn;function gc(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}ie.readUintBE=gc;function yc(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}ie.readUintLE=yc;function vc(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(!kn.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}ie.writeUintBE=vc;function _c(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(!kn.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}ie.writeUintLE=_c;function bc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}ie.readFloat32BE=bc;function mc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}ie.readFloat32LE=mc;function wc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}ie.readFloat64BE=wc;function Ec(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}ie.readFloat64LE=Ec;function Dc(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}ie.writeFloat32BE=Dc;function Sc(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}ie.writeFloat32LE=Sc;function xc(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}ie.writeFloat64BE=xc;function Oc(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}ie.writeFloat64LE=Oc;var ct={};Object.defineProperty(ct,"__esModule",{value:!0});function Ic(t){for(var e=0;e<t.length;e++)t[e]=0;return t}ct.wipe=Ic,Object.defineProperty(qr,"__esModule",{value:!0});var ot=ie,Ci=ct,Ac=20;function Tc(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],l=r[7]<<24|r[6]<<16|r[5]<<8|r[4],p=r[11]<<24|r[10]<<16|r[9]<<8|r[8],y=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],A=r[23]<<24|r[22]<<16|r[21]<<8|r[20],S=r[27]<<24|r[26]<<16|r[25]<<8|r[24],E=r[31]<<24|r[30]<<16|r[29]<<8|r[28],N=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],w=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=i,_=n,m=s,d=c,o=h,f=l,P=p,U=y,H=D,G=A,Y=S,u=E,v=N,j=L,q=B,F=w,R=0;R<Ac;R+=2)I=I+o|0,v^=I,v=v>>>32-16|v<<16,H=H+v|0,o^=H,o=o>>>32-12|o<<12,_=_+f|0,j^=_,j=j>>>32-16|j<<16,G=G+j|0,f^=G,f=f>>>32-12|f<<12,m=m+P|0,q^=m,q=q>>>32-16|q<<16,Y=Y+q|0,P^=Y,P=P>>>32-12|P<<12,d=d+U|0,F^=d,F=F>>>32-16|F<<16,u=u+F|0,U^=u,U=U>>>32-12|U<<12,m=m+P|0,q^=m,q=q>>>32-8|q<<8,Y=Y+q|0,P^=Y,P=P>>>32-7|P<<7,d=d+U|0,F^=d,F=F>>>32-8|F<<8,u=u+F|0,U^=u,U=U>>>32-7|U<<7,_=_+f|0,j^=_,j=j>>>32-8|j<<8,G=G+j|0,f^=G,f=f>>>32-7|f<<7,I=I+o|0,v^=I,v=v>>>32-8|v<<8,H=H+v|0,o^=H,o=o>>>32-7|o<<7,I=I+f|0,F^=I,F=F>>>32-16|F<<16,Y=Y+F|0,f^=Y,f=f>>>32-12|f<<12,_=_+P|0,v^=_,v=v>>>32-16|v<<16,u=u+v|0,P^=u,P=P>>>32-12|P<<12,m=m+U|0,j^=m,j=j>>>32-16|j<<16,H=H+j|0,U^=H,U=U>>>32-12|U<<12,d=d+o|0,q^=d,q=q>>>32-16|q<<16,G=G+q|0,o^=G,o=o>>>32-12|o<<12,m=m+U|0,j^=m,j=j>>>32-8|j<<8,H=H+j|0,U^=H,U=U>>>32-7|U<<7,d=d+o|0,q^=d,q=q>>>32-8|q<<8,G=G+q|0,o^=G,o=o>>>32-7|o<<7,_=_+P|0,v^=_,v=v>>>32-8|v<<8,u=u+v|0,P^=u,P=P>>>32-7|P<<7,I=I+f|0,F^=I,F=F>>>32-8|F<<8,Y=Y+F|0,f^=Y,f=f>>>32-7|f<<7;ot.writeUint32LE(I+i|0,t,0),ot.writeUint32LE(_+n|0,t,4),ot.writeUint32LE(m+s|0,t,8),ot.writeUint32LE(d+c|0,t,12),ot.writeUint32LE(o+h|0,t,16),ot.writeUint32LE(f+l|0,t,20),ot.writeUint32LE(P+p|0,t,24),ot.writeUint32LE(U+y|0,t,28),ot.writeUint32LE(H+D|0,t,32),ot.writeUint32LE(G+A|0,t,36),ot.writeUint32LE(Y+S|0,t,40),ot.writeUint32LE(u+E|0,t,44),ot.writeUint32LE(v+N|0,t,48),ot.writeUint32LE(j+L|0,t,52),ot.writeUint32LE(q+B|0,t,56),ot.writeUint32LE(F+w|0,t,60)}function Qn(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),l=0;l<r.length;l+=64){Tc(h,s,t);for(var p=l;p<l+64&&p<r.length;p++)i[p]=r[p]^h[p-l];Nc(s,0,c)}return Ci.wipe(h),n===0&&Ci.wipe(s),i}qr.streamXOR=Qn;function Cc(t,e,r,i){return i===void 0&&(i=0),Ci.wipe(r),Qn(t,e,r,r,i)}qr.stream=Cc;function Nc(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 es={},Ht={};Object.defineProperty(Ht,"__esModule",{value:!0});function Lc(t,e,r){return~(t-1)&e|t-1&r}Ht.select=Lc;function Rc(t,e){return(t|0)-(e|0)-1>>>31&1}Ht.lessOrEqual=Rc;function ts(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}Ht.compare=ts;function Pc(t,e){return t.length===0||e.length===0?!1:ts(t,e)!==0}Ht.equal=Pc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ht,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 l=h[0]|h[1]<<8;this._r[0]=l&8191;var p=h[2]|h[3]<<8;this._r[1]=(l>>>13|p<<3)&8191;var y=h[4]|h[5]<<8;this._r[2]=(p>>>10|y<<6)&7939;var D=h[6]|h[7]<<8;this._r[3]=(y>>>7|D<<9)&8191;var A=h[8]|h[9]<<8;this._r[4]=(D>>>4|A<<12)&255,this._r[5]=A>>>1&8190;var S=h[10]|h[11]<<8;this._r[6]=(A>>>14|S<<2)&8191;var E=h[12]|h[13]<<8;this._r[7]=(S>>>11|E<<5)&8065;var N=h[14]|h[15]<<8;this._r[8]=(E>>>8|N<<8)&8191,this._r[9]=N>>>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,l,p){for(var y=this._fin?0:2048,D=this._h[0],A=this._h[1],S=this._h[2],E=this._h[3],N=this._h[4],L=this._h[5],B=this._h[6],w=this._h[7],I=this._h[8],_=this._h[9],m=this._r[0],d=this._r[1],o=this._r[2],f=this._r[3],P=this._r[4],U=this._r[5],H=this._r[6],G=this._r[7],Y=this._r[8],u=this._r[9];p>=16;){var v=h[l+0]|h[l+1]<<8;D+=v&8191;var j=h[l+2]|h[l+3]<<8;A+=(v>>>13|j<<3)&8191;var q=h[l+4]|h[l+5]<<8;S+=(j>>>10|q<<6)&8191;var F=h[l+6]|h[l+7]<<8;E+=(q>>>7|F<<9)&8191;var R=h[l+8]|h[l+9]<<8;N+=(F>>>4|R<<12)&8191,L+=R>>>1&8191;var M=h[l+10]|h[l+11]<<8;B+=(R>>>14|M<<2)&8191;var z=h[l+12]|h[l+13]<<8;w+=(M>>>11|z<<5)&8191;var Q=h[l+14]|h[l+15]<<8;I+=(z>>>8|Q<<8)&8191,_+=Q>>>5|y;var K=0,ee=K;ee+=D*m,ee+=A*(5*u),ee+=S*(5*Y),ee+=E*(5*G),ee+=N*(5*H),K=ee>>>13,ee&=8191,ee+=L*(5*U),ee+=B*(5*P),ee+=w*(5*f),ee+=I*(5*o),ee+=_*(5*d),K+=ee>>>13,ee&=8191;var J=K;J+=D*d,J+=A*m,J+=S*(5*u),J+=E*(5*Y),J+=N*(5*G),K=J>>>13,J&=8191,J+=L*(5*H),J+=B*(5*U),J+=w*(5*P),J+=I*(5*f),J+=_*(5*o),K+=J>>>13,J&=8191;var te=K;te+=D*o,te+=A*d,te+=S*m,te+=E*(5*u),te+=N*(5*Y),K=te>>>13,te&=8191,te+=L*(5*G),te+=B*(5*H),te+=w*(5*U),te+=I*(5*P),te+=_*(5*f),K+=te>>>13,te&=8191;var C=K;C+=D*f,C+=A*o,C+=S*d,C+=E*m,C+=N*(5*u),K=C>>>13,C&=8191,C+=L*(5*Y),C+=B*(5*G),C+=w*(5*H),C+=I*(5*U),C+=_*(5*P),K+=C>>>13,C&=8191;var T=K;T+=D*P,T+=A*f,T+=S*o,T+=E*d,T+=N*m,K=T>>>13,T&=8191,T+=L*(5*u),T+=B*(5*Y),T+=w*(5*G),T+=I*(5*H),T+=_*(5*U),K+=T>>>13,T&=8191;var x=K;x+=D*U,x+=A*P,x+=S*f,x+=E*o,x+=N*d,K=x>>>13,x&=8191,x+=L*m,x+=B*(5*u),x+=w*(5*Y),x+=I*(5*G),x+=_*(5*H),K+=x>>>13,x&=8191;var a=K;a+=D*H,a+=A*U,a+=S*P,a+=E*f,a+=N*o,K=a>>>13,a&=8191,a+=L*d,a+=B*m,a+=w*(5*u),a+=I*(5*Y),a+=_*(5*G),K+=a>>>13,a&=8191;var b=K;b+=D*G,b+=A*H,b+=S*U,b+=E*P,b+=N*f,K=b>>>13,b&=8191,b+=L*o,b+=B*d,b+=w*m,b+=I*(5*u),b+=_*(5*Y),K+=b>>>13,b&=8191;var V=K;V+=D*Y,V+=A*G,V+=S*H,V+=E*U,V+=N*P,K=V>>>13,V&=8191,V+=L*f,V+=B*o,V+=w*d,V+=I*m,V+=_*(5*u),K+=V>>>13,V&=8191;var k=K;k+=D*u,k+=A*Y,k+=S*G,k+=E*H,k+=N*U,K=k>>>13,k&=8191,k+=L*P,k+=B*f,k+=w*o,k+=I*d,k+=_*m,K+=k>>>13,k&=8191,K=(K<<2)+K|0,K=K+ee|0,ee=K&8191,K=K>>>13,J+=K,D=ee,A=J,S=te,E=C,N=T,L=x,B=a,w=b,I=V,_=k,l+=16,p-=16}this._h[0]=D,this._h[1]=A,this._h[2]=S,this._h[3]=E,this._h[4]=N,this._h[5]=L,this._h[6]=B,this._h[7]=w,this._h[8]=I,this._h[9]=_},c.prototype.finish=function(h,l){l===void 0&&(l=0);var p=new Uint16Array(10),y,D,A,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(y=this._h[1]>>>13,this._h[1]&=8191,S=2;S<10;S++)this._h[S]+=y,y=this._h[S]>>>13,this._h[S]&=8191;for(this._h[0]+=y*5,y=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=y,y=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=y,p[0]=this._h[0]+5,y=p[0]>>>13,p[0]&=8191,S=1;S<10;S++)p[S]=this._h[S]+y,y=p[S]>>>13,p[S]&=8191;for(p[9]-=1<<13,D=(y^1)-1,S=0;S<10;S++)p[S]&=D;for(D=~D,S=0;S<10;S++)this._h[S]=this._h[S]&D|p[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,A=this._h[0]+this._pad[0],this._h[0]=A&65535,S=1;S<8;S++)A=(this._h[S]+this._pad[S]|0)+(A>>>16)|0,this._h[S]=A&65535;return h[l+0]=this._h[0]>>>0,h[l+1]=this._h[0]>>>8,h[l+2]=this._h[1]>>>0,h[l+3]=this._h[1]>>>8,h[l+4]=this._h[2]>>>0,h[l+5]=this._h[2]>>>8,h[l+6]=this._h[3]>>>0,h[l+7]=this._h[3]>>>8,h[l+8]=this._h[4]>>>0,h[l+9]=this._h[4]>>>8,h[l+10]=this._h[5]>>>0,h[l+11]=this._h[5]>>>8,h[l+12]=this._h[6]>>>0,h[l+13]=this._h[6]>>>8,h[l+14]=this._h[7]>>>0,h[l+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(h){var l=0,p=h.length,y;if(this._leftover){y=16-this._leftover,y>p&&(y=p);for(var D=0;D<y;D++)this._buffer[this._leftover+D]=h[l+D];if(p-=y,l+=y,this._leftover+=y,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(p>=16&&(y=p-p%16,this._blocks(h,l,y),l+=y,p-=y),p){for(var D=0;D<p;D++)this._buffer[this._leftover+D]=h[l+D];this._leftover+=p}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 l=new i(c);l.update(h);var p=l.digest();return l.clean(),p}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}(es),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=qr,r=es,i=ct,n=ie,s=Ht;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),h=function(){function l(p){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,p.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(p)}return l.prototype.seal=function(p,y,D,A){if(p.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var S=new Uint8Array(16);S.set(p,S.length-p.length);var E=new Uint8Array(32);e.stream(this._key,S,E,4);var N=y.length+this.tagLength,L;if(A){if(A.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");L=A}else L=new Uint8Array(N);return e.streamXOR(this._key,S,y,L,4),this._authenticate(L.subarray(L.length-this.tagLength,L.length),E,L.subarray(0,L.length-this.tagLength),D),i.wipe(S),L},l.prototype.open=function(p,y,D,A){if(p.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(y.length<this.tagLength)return null;var S=new Uint8Array(16);S.set(p,S.length-p.length);var E=new Uint8Array(32);e.stream(this._key,S,E,4);var N=new Uint8Array(this.tagLength);if(this._authenticate(N,E,y.subarray(0,y.length-this.tagLength),D),!s.equal(N,y.subarray(y.length-this.tagLength,y.length)))return null;var L=y.length-this.tagLength,B;if(A){if(A.length!==L)throw new Error("ChaCha20Poly1305: incorrect destination length");B=A}else B=new Uint8Array(L);return e.streamXOR(this._key,S,y.subarray(0,y.length-this.tagLength),B,4),i.wipe(S),B},l.prototype.clean=function(){return i.wipe(this._key),this},l.prototype._authenticate=function(p,y,D,A){var S=new r.Poly1305(y);A&&(S.update(A),A.length%16>0&&S.update(c.subarray(A.length%16))),S.update(D),D.length%16>0&&S.update(c.subarray(D.length%16));var E=new Uint8Array(8);A&&n.writeUint64LE(A.length,E),S.update(E),n.writeUint64LE(D.length,E),S.update(E);for(var N=S.digest(),L=0;L<N.length;L++)p[L]=N[L];S.clean(),i.wipe(N),i.wipe(E)},l}();t.ChaCha20Poly1305=h}(xi);var rs={},mr={},Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});function Fc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Ni.isSerializableHash=Fc,Object.defineProperty(mr,"__esModule",{value:!0});var Ot=Ni,Uc=Ht,Mc=ct,is=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()),Mc.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}();mr.HMAC=is;function jc(t,e,r){var i=new is(t,e);i.update(r);var n=i.digest();return i.clean(),n}mr.hmac=jc,mr.equal=Uc.equal,Object.defineProperty(rs,"__esModule",{value:!0});var ns=mr,ss=ct,$c=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=ns.hmac(this._hash,i,r);this._hmac=new ns.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(),ss.wipe(this._buffer),ss.wipe(this._counter),this._bufpos=0},t}(),Bc=rs.HKDF=$c,wr={},Li={},Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});var os=65536,zc=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+=os)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,os)));return r},t}();Ri.BrowserRandomSource=zc;function as(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 Pi={},Hc={},Kc=Object.freeze({__proto__:null,default:Hc}),cs=vi(Kc);Object.defineProperty(Pi,"__esModule",{value:!0});var qc=ct,Vc=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof as<"u"){var e=cs;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}();Pi.NodeRandomSource=Vc,Object.defineProperty(Li,"__esModule",{value:!0});var Gc=Ri,Wc=Pi,kc=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new Gc.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Wc.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}();Li.SystemRandomSource=kc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Li,r=ie,i=ct;t.defaultRandomSource=new e.SystemRandomSource;function n(p,y){return y===void 0&&(y=t.defaultRandomSource),y.randomBytes(p)}t.randomBytes=n;function s(p){p===void 0&&(p=t.defaultRandomSource);var y=n(4,p),D=r.readUint32LE(y);return i.wipe(y),D}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(p,y,D){if(y===void 0&&(y=c),D===void 0&&(D=t.defaultRandomSource),y.length<2)throw new Error("randomString charset is too short");if(y.length>256)throw new Error("randomString charset is too long");for(var A="",S=y.length,E=256-256%S;p>0;){for(var N=n(Math.ceil(p*256/E),D),L=0;L<N.length&&p>0;L++){var B=N[L];B<E&&(A+=y.charAt(B%S),p--)}i.wipe(N)}return A}t.randomString=h;function l(p,y,D){y===void 0&&(y=c),D===void 0&&(D=t.defaultRandomSource);var A=Math.ceil(p/(Math.log(y.length)/Math.LN2));return h(A,y,D)}t.randomStringForEntropy=l}(wr);var Wr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=ie,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(l,p){if(p===void 0&&(p=l.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var y=0;if(this._bytesHashed+=p,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&p>0;)this._buffer[this._bufferLength++]=l[y++],p--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=s(this._temp,this._state,l,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=l[y++],p--;return this},h.prototype.finish=function(l){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,D=p/536870912|0,A=p<<3,S=p%64<56?64:128;this._buffer[y]=128;for(var E=y+1;E<S-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,S-8),e.writeUint32BE(A,this._buffer,S-4),s(this._temp,this._state,this._buffer,0,S),this._finished=!0}for(var E=0;E<this.digestLength/4;E++)e.writeUint32BE(this._state[E],l,E*4);return this},h.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},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(l){return this._state.set(l.state),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(l){r.wipe(l.state),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.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,l,p,y,D){for(;D>=64;){for(var A=l[0],S=l[1],E=l[2],N=l[3],L=l[4],B=l[5],w=l[6],I=l[7],_=0;_<16;_++){var m=y+_*4;h[_]=e.readUint32BE(p,m)}for(var _=16;_<64;_++){var d=h[_-2],o=(d>>>17|d<<32-17)^(d>>>19|d<<32-19)^d>>>10;d=h[_-15];var f=(d>>>7|d<<32-7)^(d>>>18|d<<32-18)^d>>>3;h[_]=(o+h[_-7]|0)+(f+h[_-16]|0)}for(var _=0;_<64;_++){var o=(((L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7))+(L&B^~L&w)|0)+(I+(n[_]+h[_]|0)|0)|0,f=((A>>>2|A<<32-2)^(A>>>13|A<<32-13)^(A>>>22|A<<32-22))+(A&S^A&E^S&E)|0;I=w,w=B,B=L,L=N+o|0,N=E,E=S,S=A,A=o+f|0}l[0]+=A,l[1]+=S,l[2]+=E,l[3]+=N,l[4]+=L,l[5]+=B,l[6]+=w,l[7]+=I,y+=64,D-=64}return y}function c(h){var l=new i;l.update(h);var p=l.digest();return l.clean(),p}t.hash=c})(Wr);var Fi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=wr,r=ct;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(_){var m=new Float64Array(16);if(_)for(var d=0;d<_.length;d++)m[d]=_[d];return m}var n=new Uint8Array(32);n[0]=9;var s=i([56129,1]);function c(_){for(var m=1,d=0;d<16;d++){var o=_[d]+m+65535;m=Math.floor(o/65536),_[d]=o-m*65536}_[0]+=m-1+37*(m-1)}function h(_,m,d){for(var o=~(d-1),f=0;f<16;f++){var P=o&(_[f]^m[f]);_[f]^=P,m[f]^=P}}function l(_,m){for(var d=i(),o=i(),f=0;f<16;f++)o[f]=m[f];c(o),c(o),c(o);for(var P=0;P<2;P++){d[0]=o[0]-65517;for(var f=1;f<15;f++)d[f]=o[f]-65535-(d[f-1]>>16&1),d[f-1]&=65535;d[15]=o[15]-32767-(d[14]>>16&1);var U=d[15]>>16&1;d[14]&=65535,h(o,d,1-U)}for(var f=0;f<16;f++)_[2*f]=o[f]&255,_[2*f+1]=o[f]>>8}function p(_,m){for(var d=0;d<16;d++)_[d]=m[2*d]+(m[2*d+1]<<8);_[15]&=32767}function y(_,m,d){for(var o=0;o<16;o++)_[o]=m[o]+d[o]}function D(_,m,d){for(var o=0;o<16;o++)_[o]=m[o]-d[o]}function A(_,m,d){var o,f,P=0,U=0,H=0,G=0,Y=0,u=0,v=0,j=0,q=0,F=0,R=0,M=0,z=0,Q=0,K=0,ee=0,J=0,te=0,C=0,T=0,x=0,a=0,b=0,V=0,k=0,le=0,_e=0,pe=0,Ee=0,Fe=0,Ce=0,ve=d[0],ge=d[1],de=d[2],ue=d[3],he=d[4],ce=d[5],ae=d[6],ne=d[7],fe=d[8],ye=d[9],se=d[10],be=d[11],me=d[12],Se=d[13],xe=d[14],De=d[15];o=m[0],P+=o*ve,U+=o*ge,H+=o*de,G+=o*ue,Y+=o*he,u+=o*ce,v+=o*ae,j+=o*ne,q+=o*fe,F+=o*ye,R+=o*se,M+=o*be,z+=o*me,Q+=o*Se,K+=o*xe,ee+=o*De,o=m[1],U+=o*ve,H+=o*ge,G+=o*de,Y+=o*ue,u+=o*he,v+=o*ce,j+=o*ae,q+=o*ne,F+=o*fe,R+=o*ye,M+=o*se,z+=o*be,Q+=o*me,K+=o*Se,ee+=o*xe,J+=o*De,o=m[2],H+=o*ve,G+=o*ge,Y+=o*de,u+=o*ue,v+=o*he,j+=o*ce,q+=o*ae,F+=o*ne,R+=o*fe,M+=o*ye,z+=o*se,Q+=o*be,K+=o*me,ee+=o*Se,J+=o*xe,te+=o*De,o=m[3],G+=o*ve,Y+=o*ge,u+=o*de,v+=o*ue,j+=o*he,q+=o*ce,F+=o*ae,R+=o*ne,M+=o*fe,z+=o*ye,Q+=o*se,K+=o*be,ee+=o*me,J+=o*Se,te+=o*xe,C+=o*De,o=m[4],Y+=o*ve,u+=o*ge,v+=o*de,j+=o*ue,q+=o*he,F+=o*ce,R+=o*ae,M+=o*ne,z+=o*fe,Q+=o*ye,K+=o*se,ee+=o*be,J+=o*me,te+=o*Se,C+=o*xe,T+=o*De,o=m[5],u+=o*ve,v+=o*ge,j+=o*de,q+=o*ue,F+=o*he,R+=o*ce,M+=o*ae,z+=o*ne,Q+=o*fe,K+=o*ye,ee+=o*se,J+=o*be,te+=o*me,C+=o*Se,T+=o*xe,x+=o*De,o=m[6],v+=o*ve,j+=o*ge,q+=o*de,F+=o*ue,R+=o*he,M+=o*ce,z+=o*ae,Q+=o*ne,K+=o*fe,ee+=o*ye,J+=o*se,te+=o*be,C+=o*me,T+=o*Se,x+=o*xe,a+=o*De,o=m[7],j+=o*ve,q+=o*ge,F+=o*de,R+=o*ue,M+=o*he,z+=o*ce,Q+=o*ae,K+=o*ne,ee+=o*fe,J+=o*ye,te+=o*se,C+=o*be,T+=o*me,x+=o*Se,a+=o*xe,b+=o*De,o=m[8],q+=o*ve,F+=o*ge,R+=o*de,M+=o*ue,z+=o*he,Q+=o*ce,K+=o*ae,ee+=o*ne,J+=o*fe,te+=o*ye,C+=o*se,T+=o*be,x+=o*me,a+=o*Se,b+=o*xe,V+=o*De,o=m[9],F+=o*ve,R+=o*ge,M+=o*de,z+=o*ue,Q+=o*he,K+=o*ce,ee+=o*ae,J+=o*ne,te+=o*fe,C+=o*ye,T+=o*se,x+=o*be,a+=o*me,b+=o*Se,V+=o*xe,k+=o*De,o=m[10],R+=o*ve,M+=o*ge,z+=o*de,Q+=o*ue,K+=o*he,ee+=o*ce,J+=o*ae,te+=o*ne,C+=o*fe,T+=o*ye,x+=o*se,a+=o*be,b+=o*me,V+=o*Se,k+=o*xe,le+=o*De,o=m[11],M+=o*ve,z+=o*ge,Q+=o*de,K+=o*ue,ee+=o*he,J+=o*ce,te+=o*ae,C+=o*ne,T+=o*fe,x+=o*ye,a+=o*se,b+=o*be,V+=o*me,k+=o*Se,le+=o*xe,_e+=o*De,o=m[12],z+=o*ve,Q+=o*ge,K+=o*de,ee+=o*ue,J+=o*he,te+=o*ce,C+=o*ae,T+=o*ne,x+=o*fe,a+=o*ye,b+=o*se,V+=o*be,k+=o*me,le+=o*Se,_e+=o*xe,pe+=o*De,o=m[13],Q+=o*ve,K+=o*ge,ee+=o*de,J+=o*ue,te+=o*he,C+=o*ce,T+=o*ae,x+=o*ne,a+=o*fe,b+=o*ye,V+=o*se,k+=o*be,le+=o*me,_e+=o*Se,pe+=o*xe,Ee+=o*De,o=m[14],K+=o*ve,ee+=o*ge,J+=o*de,te+=o*ue,C+=o*he,T+=o*ce,x+=o*ae,a+=o*ne,b+=o*fe,V+=o*ye,k+=o*se,le+=o*be,_e+=o*me,pe+=o*Se,Ee+=o*xe,Fe+=o*De,o=m[15],ee+=o*ve,J+=o*ge,te+=o*de,C+=o*ue,T+=o*he,x+=o*ce,a+=o*ae,b+=o*ne,V+=o*fe,k+=o*ye,le+=o*se,_e+=o*be,pe+=o*me,Ee+=o*Se,Fe+=o*xe,Ce+=o*De,P+=38*J,U+=38*te,H+=38*C,G+=38*T,Y+=38*x,u+=38*a,v+=38*b,j+=38*V,q+=38*k,F+=38*le,R+=38*_e,M+=38*pe,z+=38*Ee,Q+=38*Fe,K+=38*Ce,f=1,o=P+f+65535,f=Math.floor(o/65536),P=o-f*65536,o=U+f+65535,f=Math.floor(o/65536),U=o-f*65536,o=H+f+65535,f=Math.floor(o/65536),H=o-f*65536,o=G+f+65535,f=Math.floor(o/65536),G=o-f*65536,o=Y+f+65535,f=Math.floor(o/65536),Y=o-f*65536,o=u+f+65535,f=Math.floor(o/65536),u=o-f*65536,o=v+f+65535,f=Math.floor(o/65536),v=o-f*65536,o=j+f+65535,f=Math.floor(o/65536),j=o-f*65536,o=q+f+65535,f=Math.floor(o/65536),q=o-f*65536,o=F+f+65535,f=Math.floor(o/65536),F=o-f*65536,o=R+f+65535,f=Math.floor(o/65536),R=o-f*65536,o=M+f+65535,f=Math.floor(o/65536),M=o-f*65536,o=z+f+65535,f=Math.floor(o/65536),z=o-f*65536,o=Q+f+65535,f=Math.floor(o/65536),Q=o-f*65536,o=K+f+65535,f=Math.floor(o/65536),K=o-f*65536,o=ee+f+65535,f=Math.floor(o/65536),ee=o-f*65536,P+=f-1+37*(f-1),f=1,o=P+f+65535,f=Math.floor(o/65536),P=o-f*65536,o=U+f+65535,f=Math.floor(o/65536),U=o-f*65536,o=H+f+65535,f=Math.floor(o/65536),H=o-f*65536,o=G+f+65535,f=Math.floor(o/65536),G=o-f*65536,o=Y+f+65535,f=Math.floor(o/65536),Y=o-f*65536,o=u+f+65535,f=Math.floor(o/65536),u=o-f*65536,o=v+f+65535,f=Math.floor(o/65536),v=o-f*65536,o=j+f+65535,f=Math.floor(o/65536),j=o-f*65536,o=q+f+65535,f=Math.floor(o/65536),q=o-f*65536,o=F+f+65535,f=Math.floor(o/65536),F=o-f*65536,o=R+f+65535,f=Math.floor(o/65536),R=o-f*65536,o=M+f+65535,f=Math.floor(o/65536),M=o-f*65536,o=z+f+65535,f=Math.floor(o/65536),z=o-f*65536,o=Q+f+65535,f=Math.floor(o/65536),Q=o-f*65536,o=K+f+65535,f=Math.floor(o/65536),K=o-f*65536,o=ee+f+65535,f=Math.floor(o/65536),ee=o-f*65536,P+=f-1+37*(f-1),_[0]=P,_[1]=U,_[2]=H,_[3]=G,_[4]=Y,_[5]=u,_[6]=v,_[7]=j,_[8]=q,_[9]=F,_[10]=R,_[11]=M,_[12]=z,_[13]=Q,_[14]=K,_[15]=ee}function S(_,m){A(_,m,m)}function E(_,m){for(var d=i(),o=0;o<16;o++)d[o]=m[o];for(var o=253;o>=0;o--)S(d,d),o!==2&&o!==4&&A(d,d,m);for(var o=0;o<16;o++)_[o]=d[o]}function N(_,m){for(var d=new Uint8Array(32),o=new Float64Array(80),f=i(),P=i(),U=i(),H=i(),G=i(),Y=i(),u=0;u<31;u++)d[u]=_[u];d[31]=_[31]&127|64,d[0]&=248,p(o,m);for(var u=0;u<16;u++)P[u]=o[u];f[0]=H[0]=1;for(var u=254;u>=0;--u){var v=d[u>>>3]>>>(u&7)&1;h(f,P,v),h(U,H,v),y(G,f,U),D(f,f,U),y(U,P,H),D(P,P,H),S(H,G),S(Y,f),A(f,U,f),A(U,P,G),y(G,f,U),D(f,f,U),S(P,f),D(U,H,Y),A(f,U,s),y(f,f,H),A(U,U,f),A(f,H,Y),A(H,P,o),S(P,G),h(f,P,v),h(U,H,v)}for(var u=0;u<16;u++)o[u+16]=f[u],o[u+32]=U[u],o[u+48]=P[u],o[u+64]=H[u];var j=o.subarray(32),q=o.subarray(16);E(j,j),A(q,q,j);var F=new Uint8Array(32);return l(F,q),F}t.scalarMult=N;function L(_){return N(_,n)}t.scalarMultBase=L;function B(_){if(_.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var m=new Uint8Array(_),d=L(m);return{publicKey:d,secretKey:m}}t.generateKeyPairFromSeed=B;function w(_){var m=e.randomBytes(32,_),d=B(m);return r.wipe(m),d}t.generateKeyPair=w;function I(_,m,d){if(d===void 0&&(d=!1),_.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=N(_,m);if(d){for(var f=0,P=0;P<o.length;P++)f|=o[P];if(f===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=I})(Fi);function hs(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ui(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=hs(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function Yc(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,l=t.charAt(0),p=Math.log(h)/Math.log(256),y=Math.log(256)/Math.log(h);function D(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var N=0,L=0,B=0,w=E.length;B!==w&&E[B]===0;)B++,N++;for(var I=(w-B)*y+1>>>0,_=new Uint8Array(I);B!==w;){for(var m=E[B],d=0,o=I-1;(m!==0||d<L)&&o!==-1;o--,d++)m+=256*_[o]>>>0,_[o]=m%h>>>0,m=m/h>>>0;if(m!==0)throw new Error("Non-zero carry");L=d,B++}for(var f=I-L;f!==I&&_[f]===0;)f++;for(var P=l.repeat(N);f<I;++f)P+=t.charAt(_[f]);return P}function A(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var N=0;if(E[N]!==" "){for(var L=0,B=0;E[N]===l;)L++,N++;for(var w=(E.length-N)*p+1>>>0,I=new Uint8Array(w);E[N];){var _=r[E.charCodeAt(N)];if(_===255)return;for(var m=0,d=w-1;(_!==0||m<B)&&d!==-1;d--,m++)_+=h*I[d]>>>0,I[d]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");B=m,N++}if(E[N]!==" "){for(var o=w-B;o!==w&&I[o]===0;)o++;for(var f=new Uint8Array(L+(w-o)),P=L;o!==w;)f[P++]=I[o++];return f}}}function S(E){var N=A(E);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:A,decode:S}}var Jc=Yc,Xc=Jc;const us=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")},Zc=t=>new TextEncoder().encode(t),Qc=t=>new TextDecoder().decode(t);class eh{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 th{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 fs(this,e)}}class rh{constructor(e){this.decoders=e}or(e){return fs(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 fs=(t,e)=>new rh({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class ih{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,r,i),this.decoder=new th(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const kr=({name:t,prefix:e,encode:r,decode:i})=>new ih(t,e,r,i),Er=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Xc(r,e);return kr({prefix:t,name:e,encode:i,decode:s=>us(n(s))})},nh=(t,e,r,i)=>{const n={};for(let y=0;y<e.length;++y)n[e[y]]=y;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let h=0,l=0,p=0;for(let y=0;y<s;++y){const D=n[t[y]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|D,h+=r,h>=8&&(h-=8,c[p++]=255&l>>h)}if(h>=r||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return c},sh=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,h=0;for(let l=0;l<t.length;++l)for(h=h<<8|t[l],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})=>kr({prefix:e,name:t,encode(n){return sh(n,i,r)},decode(n){return nh(n,i,r,t)}}),oh=kr({prefix:"\0",name:"identity",encode:t=>Qc(t),decode:t=>Zc(t)});var ah=Object.freeze({__proto__:null,identity:oh});const ch=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hh=Object.freeze({__proto__:null,base2:ch});const uh=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fh=Object.freeze({__proto__:null,base8:uh});const lh=Er({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 yh=Object.freeze({__proto__:null,base16:ph,base16upper:gh});const vh=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_h=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:vh,base32upper:_h,base32pad:bh,base32padupper:mh,base32hex:wh,base32hexupper:Eh,base32hexpad:Dh,base32hexpadupper:Sh,base32z:xh});const Ih=Er({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ah=Er({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Th=Object.freeze({__proto__:null,base36:Ih,base36upper:Ah});const Ch=Er({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Nh=Er({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lh=Object.freeze({__proto__:null,base58btc:Ch,base58flickr:Nh});const Rh=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ph=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 Mh=Object.freeze({__proto__:null,base64:Rh,base64pad:Ph,base64url:Fh,base64urlpad:Uh});const ls=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}"),jh=ls.reduce((t,e,r)=>(t[r]=e,t),[]),$h=ls.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bh(t){return t.reduce((e,r)=>(e+=jh[r],e),"")}function zh(t){const e=[];for(const r of t){const i=$h[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Hh=kr({prefix:"\u{1F680}",name:"base256emoji",encode:Bh,decode:zh});var Kh=Object.freeze({__proto__:null,base256emoji:Hh}),qh=ps,ds=128,Vh=127,Gh=~Vh,Wh=Math.pow(2,31);function ps(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Wh;)e[r++]=t&255|ds,t/=128;for(;t&Gh;)e[r++]=t&255|ds,t>>>=7;return e[r]=t|0,ps.bytes=r-i+1,e}var kh=Mi,Yh=128,gs=127;function Mi(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw Mi.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&gs)<<n:(c&gs)*Math.pow(2,n),n+=7}while(c>=Yh);return Mi.bytes=s-i,r}var Jh=Math.pow(2,7),Xh=Math.pow(2,14),Zh=Math.pow(2,21),Qh=Math.pow(2,28),eu=Math.pow(2,35),tu=Math.pow(2,42),ru=Math.pow(2,49),iu=Math.pow(2,56),nu=Math.pow(2,63),su=function(t){return t<Jh?1:t<Xh?2:t<Zh?3:t<Qh?4:t<eu?5:t<tu?6:t<ru?7:t<iu?8:t<nu?9:10},ou={encode:qh,decode:kh,encodingLength:su},ys=ou;const vs=(t,e,r=0)=>(ys.encode(t,e,r),e),_s=t=>ys.encodingLength(t),ji=(t,e)=>{const r=e.byteLength,i=_s(t),n=i+_s(r),s=new Uint8Array(n+r);return vs(t,s,0),vs(r,s,i),s.set(e,n),new au(t,r,e,s)};class au{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const bs=({name:t,code:e,encode:r})=>new cu(t,e,r);class cu{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?ji(this.code,r):r.then(i=>ji(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ms=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),hu=bs({name:"sha2-256",code:18,encode:ms("SHA-256")}),uu=bs({name:"sha2-512",code:19,encode:ms("SHA-512")});var fu=Object.freeze({__proto__:null,sha256:hu,sha512:uu});const ws=0,lu="identity",Es=us;var du=Object.freeze({__proto__:null,identity:{code:ws,name:lu,encode:Es,digest:t=>ji(ws,Es(t))}});new TextEncoder,new TextDecoder;const Ds={...ah,...hh,...fh,...dh,...yh,...Oh,...Th,...Lh,...Mh,...Kh};({...fu,...du});function Ss(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const xs=Ss("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$i=Ss("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=hs(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Os={utf8:xs,"utf-8":xs,hex:Ds.base16,latin1:$i,ascii:$i,binary:$i,...Ds};function ft(t,e="utf8"){const r=Os[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=Os[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 Is=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))},pu=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),gu=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),yu=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}(),vu=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),_u=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),bu=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,mu=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,As=3,wu=[["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",bu]],Ts=[["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 Eu(t){return t?Cs(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new _u:typeof navigator<"u"?Cs(navigator.userAgent):xu()}function Du(t){return t!==""&&wu.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 Cs(t){var e=Du(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new vu;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<As&&(n=Is(Is([],n,!0),Ou(As-n.length),!0)):n=[];var s=n.join("."),c=Su(t),h=mu.exec(t);return h&&h[1]?new yu(r,s,c,h[1]):new pu(r,s,c)}function Su(t){for(var e=0,r=Ts.length;e<r;e++){var i=Ts[e],n=i[0],s=i[1],c=s.exec(t);if(c)return n}return null}function xu(){var t=typeof process<"u"&&process.version;return t?new gu(process.version.slice(1)):null}function Ou(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var re={},Ns={},Yr={};Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.delay=void 0;function Iu(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Yr.delay=Iu;var ar={},Bi={},cr={};Object.defineProperty(cr,"__esModule",{value:!0}),cr.ONE_THOUSAND=cr.ONE_HUNDRED=void 0,cr.ONE_HUNDRED=100,cr.ONE_THOUSAND=1e3;var Ls={};(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})(Ls),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(cr,t),r(Ls,t)}(Bi),Object.defineProperty(ar,"__esModule",{value:!0}),ar.fromMiliseconds=ar.toMiliseconds=void 0;const Rs=Bi;function Au(t){return t*Rs.ONE_THOUSAND}ar.toMiliseconds=Au;function Tu(t){return Math.floor(t/Rs.ONE_THOUSAND)}ar.fromMiliseconds=Tu,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(Yr,t),r(ar,t)}(Ns);var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.Watch=void 0;class Ps{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}}Dr.Watch=Ps,Dr.default=Ps;var Fs={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.IWatch=void 0;class Cu{}Jr.IWatch=Cu,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(Jr,t)}(Fs),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(Ns,t),r(Dr,t),r(Fs,t),r(Bi,t)}(re);var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.getLocalStorage=Oe.getLocalStorageOrThrow=Oe.getCrypto=Oe.getCryptoOrThrow=Ms=Oe.getLocation=Oe.getLocationOrThrow=zi=Oe.getNavigator=Oe.getNavigatorOrThrow=Us=Oe.getDocument=Oe.getDocumentOrThrow=Oe.getFromWindowOrThrow=Oe.getFromWindow=void 0;function Jt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Oe.getFromWindow=Jt;function hr(t){const e=Jt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Oe.getFromWindowOrThrow=hr;function Nu(){return hr("document")}Oe.getDocumentOrThrow=Nu;function Lu(){return Jt("document")}var Us=Oe.getDocument=Lu;function Ru(){return hr("navigator")}Oe.getNavigatorOrThrow=Ru;function Pu(){return Jt("navigator")}var zi=Oe.getNavigator=Pu;function Fu(){return hr("location")}Oe.getLocationOrThrow=Fu;function Uu(){return Jt("location")}var Ms=Oe.getLocation=Uu;function Mu(){return hr("crypto")}Oe.getCryptoOrThrow=Mu;function ju(){return Jt("crypto")}Oe.getCrypto=ju;function $u(){return hr("localStorage")}Oe.getLocalStorageOrThrow=$u;function Bu(){return Jt("localStorage")}Oe.getLocalStorage=Bu;var Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});var js=Hi.getWindowMetadata=void 0;const $s=Oe;function zu(){let t,e;try{t=$s.getDocumentOrThrow(),e=$s.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),A=[];for(let S=0;S<D.length;S++){const E=D[S],N=E.getAttribute("rel");if(N&&N.toLowerCase().indexOf("icon")>-1){const L=E.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 w=e.pathname.split("/");w.pop();const I=w.join("/");B+=I+"/"+L}A.push(B)}else if(L.indexOf("//")===0){const B=e.protocol+L;A.push(B)}else A.push(L)}}return A}function i(...D){const A=t.getElementsByTagName("meta");for(let S=0;S<A.length;S++){const E=A[S],N=["itemprop","property","name"].map(L=>E.getAttribute(L)).filter(L=>L?D.includes(L):!1);if(N.length&&N){const L=E.getAttribute("content");if(L)return L}}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(),l=e.origin,p=r();return{description:h,url:l,icons:p,name:c}}js=Hi.getWindowMetadata=zu;var Sr={},Hu=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Bs="%[a-f0-9]{2}",zs=new RegExp(Bs,"gi"),Hs=new RegExp("("+Bs+")+","gi");function Ki(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([],Ki(r),Ki(i))}function Ku(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(zs),r=1;r<e.length;r++)t=Ki(e,r).join(""),e=t.match(zs);return t}}function qu(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Hs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=Ku(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Hs.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 Vu=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)}},Gu=(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)]},Wu=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=Hu,r=Vu,i=Gu,n=Wu,s=w=>w==null,c=Symbol("encodeFragmentIdentifier");function h(w){switch(w.arrayFormat){case"index":return I=>(_,m)=>{const d=_.length;return m===void 0||w.skipNull&&m===null||w.skipEmptyString&&m===""?_:m===null?[..._,[y(I,w),"[",d,"]"].join("")]:[..._,[y(I,w),"[",y(d,w),"]=",y(m,w)].join("")]};case"bracket":return I=>(_,m)=>m===void 0||w.skipNull&&m===null||w.skipEmptyString&&m===""?_:m===null?[..._,[y(I,w),"[]"].join("")]:[..._,[y(I,w),"[]=",y(m,w)].join("")];case"colon-list-separator":return I=>(_,m)=>m===void 0||w.skipNull&&m===null||w.skipEmptyString&&m===""?_:m===null?[..._,[y(I,w),":list="].join("")]:[..._,[y(I,w),":list=",y(m,w)].join("")];case"comma":case"separator":case"bracket-separator":{const I=w.arrayFormat==="bracket-separator"?"[]=":"=";return _=>(m,d)=>d===void 0||w.skipNull&&d===null||w.skipEmptyString&&d===""?m:(d=d===null?"":d,m.length===0?[[y(_,w),I,y(d,w)].join("")]:[[m,y(d,w)].join(w.arrayFormatSeparator)])}default:return I=>(_,m)=>m===void 0||w.skipNull&&m===null||w.skipEmptyString&&m===""?_:m===null?[..._,y(I,w)]:[..._,[y(I,w),"=",y(m,w)].join("")]}}function l(w){let I;switch(w.arrayFormat){case"index":return(_,m,d)=>{if(I=/\[(\d*)\]$/.exec(_),_=_.replace(/\[\d*\]$/,""),!I){d[_]=m;return}d[_]===void 0&&(d[_]={}),d[_][I[1]]=m};case"bracket":return(_,m,d)=>{if(I=/(\[\])$/.exec(_),_=_.replace(/\[\]$/,""),!I){d[_]=m;return}if(d[_]===void 0){d[_]=[m];return}d[_]=[].concat(d[_],m)};case"colon-list-separator":return(_,m,d)=>{if(I=/(:list)$/.exec(_),_=_.replace(/:list$/,""),!I){d[_]=m;return}if(d[_]===void 0){d[_]=[m];return}d[_]=[].concat(d[_],m)};case"comma":case"separator":return(_,m,d)=>{const o=typeof m=="string"&&m.includes(w.arrayFormatSeparator),f=typeof m=="string"&&!o&&D(m,w).includes(w.arrayFormatSeparator);m=f?D(m,w):m;const P=o||f?m.split(w.arrayFormatSeparator).map(U=>D(U,w)):m===null?m:D(m,w);d[_]=P};case"bracket-separator":return(_,m,d)=>{const o=/(\[\])$/.test(_);if(_=_.replace(/\[\]$/,""),!o){d[_]=m&&D(m,w);return}const f=m===null?[]:m.split(w.arrayFormatSeparator).map(P=>D(P,w));if(d[_]===void 0){d[_]=f;return}d[_]=[].concat(d[_],f)};default:return(_,m,d)=>{if(d[_]===void 0){d[_]=m;return}d[_]=[].concat(d[_],m)}}}function p(w){if(typeof w!="string"||w.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function y(w,I){return I.encode?I.strict?e(w):encodeURIComponent(w):w}function D(w,I){return I.decode?r(w):w}function A(w){return Array.isArray(w)?w.sort():typeof w=="object"?A(Object.keys(w)).sort((I,_)=>Number(I)-Number(_)).map(I=>w[I]):w}function S(w){const I=w.indexOf("#");return I!==-1&&(w=w.slice(0,I)),w}function E(w){let I="";const _=w.indexOf("#");return _!==-1&&(I=w.slice(_)),I}function N(w){w=S(w);const I=w.indexOf("?");return I===-1?"":w.slice(I+1)}function L(w,I){return I.parseNumbers&&!Number.isNaN(Number(w))&&typeof w=="string"&&w.trim()!==""?w=Number(w):I.parseBooleans&&w!==null&&(w.toLowerCase()==="true"||w.toLowerCase()==="false")&&(w=w.toLowerCase()==="true"),w}function B(w,I){I=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},I),p(I.arrayFormatSeparator);const _=l(I),m=Object.create(null);if(typeof w!="string"||(w=w.trim().replace(/^[?#&]/,""),!w))return m;for(const d of w.split("&")){if(d==="")continue;let[o,f]=i(I.decode?d.replace(/\+/g," "):d,"=");f=f===void 0?null:["comma","separator","bracket-separator"].includes(I.arrayFormat)?f:D(f,I),_(D(o,I),f,m)}for(const d of Object.keys(m)){const o=m[d];if(typeof o=="object"&&o!==null)for(const f of Object.keys(o))o[f]=L(o[f],I);else m[d]=L(o,I)}return I.sort===!1?m:(I.sort===!0?Object.keys(m).sort():Object.keys(m).sort(I.sort)).reduce((d,o)=>{const f=m[o];return Boolean(f)&&typeof f=="object"&&!Array.isArray(f)?d[o]=A(f):d[o]=f,d},Object.create(null))}t.extract=N,t.parse=B,t.stringify=(w,I)=>{if(!w)return"";I=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},I),p(I.arrayFormatSeparator);const _=f=>I.skipNull&&s(w[f])||I.skipEmptyString&&w[f]==="",m=h(I),d={};for(const f of Object.keys(w))_(f)||(d[f]=w[f]);const o=Object.keys(d);return I.sort!==!1&&o.sort(I.sort),o.map(f=>{const P=w[f];return P===void 0?"":P===null?y(f,I):Array.isArray(P)?P.length===0&&I.arrayFormat==="bracket-separator"?y(f,I)+"[]":P.reduce(m(f),[]).join("&"):y(f,I)+"="+y(P,I)}).filter(f=>f.length>0).join("&")},t.parseUrl=(w,I)=>{I=Object.assign({decode:!0},I);const[_,m]=i(w,"#");return Object.assign({url:_.split("?")[0]||"",query:B(N(w),I)},I&&I.parseFragmentIdentifier&&m?{fragmentIdentifier:D(m,I)}:{})},t.stringifyUrl=(w,I)=>{I=Object.assign({encode:!0,strict:!0,[c]:!0},I);const _=S(w.url).split("?")[0]||"",m=t.extract(w.url),d=t.parse(m,{sort:!1}),o=Object.assign(d,w.query);let f=t.stringify(o,I);f&&(f=`?${f}`);let P=E(w.url);return w.fragmentIdentifier&&(P=`#${I[c]?y(w.fragmentIdentifier,I):w.fragmentIdentifier}`),`${_}${f}${P}`},t.pick=(w,I,_)=>{_=Object.assign({parseFragmentIdentifier:!0,[c]:!1},_);const{url:m,query:d,fragmentIdentifier:o}=t.parseUrl(w,_);return t.stringifyUrl({url:m,query:n(d,I),fragmentIdentifier:o},_)},t.exclude=(w,I,_)=>{const m=Array.isArray(I)?d=>!I.includes(d):(d,o)=>!I(d,o);return t.pick(w,m,_)}})(Sr);const ku={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"}},Ks=":";function Yu(t){const{namespace:e,reference:r}=t;return[e,r].join(Ks)}function Ju(t){const[e,r,i]=t.split(Ks);return{namespace:e,reference:r,address:i}}function Xu(t,e){const r=[];return t.forEach(i=>{const n=e(i);r.includes(n)||r.push(n)}),r}function Zu(t){const{namespace:e,reference:r}=Ju(t);return Yu({namespace:e,reference:r})}function Qu(t){return Xu(t,Zu)}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(...n.accounts)}),r}function Vi(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...Qu(n.accounts))}),r}function ef(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 qs="base10",dt="base16",Gi="base64pad",Wi="utf8",Vs=0,Xt=1,tf=0,Gs=1,ki=12,Yi=32;function rf(){const t=Fi.generateKeyPair();return{privateKey:lt(t.secretKey,dt),publicKey:lt(t.publicKey,dt)}}function Ji(){const t=wr.randomBytes(Yi);return lt(t,dt)}function nf(t,e){const r=Fi.sharedKey(ft(t,dt),ft(e,dt)),i=new Bc(Wr.SHA256,r).expand(Yi);return lt(i,dt)}function sf(t){const e=Wr.hash(ft(t,dt));return lt(e,dt)}function Xr(t){const e=Wr.hash(ft(t,Wi));return lt(e,dt)}function of(t){return ft(`${t}`,qs)}function xr(t){return Number(lt(t,qs))}function af(t){const e=of(typeof t.type<"u"?t.type:Vs);if(xr(e)===Xt&&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):wr.randomBytes(ki),n=new xi.ChaCha20Poly1305(ft(t.symKey,dt)).seal(i,ft(t.message,Wi));return hf({type:e,sealed:n,iv:i,senderPublicKey:r})}function cf(t){const e=new xi.ChaCha20Poly1305(ft(t.symKey,dt)),{sealed:r,iv:i}=Xi(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return lt(n,Wi)}function hf(t){if(xr(t.type)===Xt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return lt(Ui([t.type,t.senderPublicKey,t.iv,t.sealed]),Gi)}return lt(Ui([t.type,t.iv,t.sealed]),Gi)}function Xi(t){const e=ft(t,Gi),r=e.slice(tf,Gs),i=Gs;if(xr(r)===Xt){const h=i+Yi,l=h+ki,p=e.slice(i,h),y=e.slice(h,l),D=e.slice(l);return{type:r,sealed:D,iv:y,senderPublicKey:p}}const n=i+ki,s=e.slice(i,n),c=e.slice(n);return{type:r,sealed:c,iv:s}}function uf(t,e){const r=Xi(t);return Ws({type:xr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?lt(r.senderPublicKey,dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Ws(t){const e=t?.type||Vs;if(e===Xt){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 ks(t){return t.type===Xt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var ff=Object.defineProperty,Ys=Object.getOwnPropertySymbols,lf=Object.prototype.hasOwnProperty,df=Object.prototype.propertyIsEnumerable,Js=(t,e,r)=>e in t?ff(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xs=(t,e)=>{for(var r in e||(e={}))lf.call(e,r)&&Js(t,r,e[r]);if(Ys)for(var r of Ys(e))df.call(e,r)&&Js(t,r,e[r]);return t};const pf="ReactNative",Or={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},gf="js";function Zs(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function yf(){return!Us()&&!!zi()&&navigator.product===pf}function vf(){return!Zs()&&!!zi()}function _f(){return yf()?Or.reactNative:Zs()?Or.node:vf()?Or.browser:Or.unknown}function bf(t,e){let r=Sr.parse(t);return r=Xs(Xs({},r),e),t=Sr.stringify(r),t}function mf(){return js()||{name:"",description:"",url:"",icons:[""]}}function wf(){const t=Eu();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 Ef(){var t;const e=_f();return e===Or.browser?[e,((t=Ms())==null?void 0:t.host)||"unknown"].join(":"):e}function Df(t,e,r){const i=wf(),n=Ef();return[[t,e].join("-"),[gf,r].join("-"),i,n].join("/")}function Sf({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s}){const c=r.split("?"),h=Df(t,e,i),l={auth:n,ua:h,projectId:s},p=bf(c[1]||"",l);return c[0]+"?"+p}function pt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Qs(t){return Object.fromEntries(t.entries())}function eo(t){return new Map(Object.entries(t))}function Rt(t,e){return re.fromMiliseconds((e||Date.now())+re.toMiliseconds(t))}function Kt(t){return re.fromMiliseconds(Date.now())>=re.toMiliseconds(t)}function Zt(){const t=re.toMiliseconds(re.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 to(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 xf(t){return to("topic",t)}function Of(t){return to("id",t)}function ro(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 If="irn";function Zi(t){return t?.relay||{protocol:If}}function Qi(t){const e=ku[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Af=Object.defineProperty,io=Object.getOwnPropertySymbols,Tf=Object.prototype.hasOwnProperty,Cf=Object.prototype.propertyIsEnumerable,no=(t,e,r)=>e in t?Af(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nf=(t,e)=>{for(var r in e||(e={}))Tf.call(e,r)&&no(t,r,e[r]);if(io)for(var r of io(e))Cf.call(e,r)&&no(t,r,e[r]);return t};function Lf(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 Rf(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=Sr.parse(s);return{protocol:i,topic:n[0],version:parseInt(n[1],10),symKey:c.symKey,relay:Lf(c)}}function Pf(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 Ff(t){return`${t.protocol}:${t.topic}@${t.version}?`+Sr.stringify(Nf({symKey:t.symKey},Pf(t.relay)))}function It(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Uf(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 Mf(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 jf(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 $f={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}},Bf={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 W(t,e){const{message:r,code:i}=Bf[t];return{message:e?`${r} ${e}`:r,code:i}}function ze(t,e){const{message:r,code:i}=$f[t];return{message:e?`${r} ${e}`:r,code:i}}function Ir(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function so(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 oo(t,e){return e&&_t(t)?!0:typeof t=="number"&&!isNaN(t)}function zf(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:l,events:p,extension:y}=t.namespaces[c],D=It(h),A=r[c];(!pt(A.chains,D)||!pt(A.methods,l)||!pt(A.events,p))&&(s=!1),s&&y&&y.forEach(S=>{var E;const{accounts:N,methods:L,events:B}=S,w=It(N);(E=A.extension)!=null&&E.find(I=>pt(I.chains,w)&&pt(I.methods,L)&&pt(I.events,B))||(s=!1)})}),s):!1}function en(t){return it(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Hf(t){if(it(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&en(r)}}return!1}function Kf(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 Vf(t){return t?.topic}function Gf(t,e){let r=null;return it(t?.publicKey,!1)||(r=W("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function tn(t,e){let r=null;return _t(t?.extension)||(!Ir(t.extension)||!t.extension.length)&&(r=W("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function ao(t){let e=!0;return Ir(t)?t.length&&(e=t.every(r=>it(r,!1))):e=!1,e}function co(t,e,r){let i=null;return Ir(e)?e.forEach(n=>{i||(!en(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 Wf(t,e){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const s=co(i,n?.chains,`${e} requiredNamespace`),c=tn(n,e);s?r=s:c?r=c:n.extension&&n.extension.forEach(h=>{if(r)return;const l=co(i,h.chains,`${e} extension`);l&&(r=l)})}),r}function ho(t,e){let r=null;return Ir(t)?t.forEach(i=>{r||Hf(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 kf(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=ho(i?.accounts,`${e} namespace`),s=tn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=ho(c.accounts,`${e} extension`);h&&(r=h)})}),r}function uo(t,e){let r=null;return ao(t?.methods)?ao(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 fo(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=uo(i,`${e}, namespace`),s=tn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=uo(c,`${e}, extension`);h&&(r=h)})}),r}function Yf(t,e){let r=null;if(t&&so(t)){const i=fo(t,e);i&&(r=i);const n=Wf(t,e);n&&(r=n)}else r=W("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function rn(t,e){let r=null;if(t&&so(t)){const i=fo(t,e);i&&(r=i);const n=kf(t,e);n&&(r=n)}else r=W("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function lo(t){return it(t.protocol,!0)}function Jf(t,e){let r=!1;return e&&!t?r=!0:t&&Ir(t)&&t.length&&t.forEach(i=>{r=lo(i)}),r}function Xf(t){return typeof t=="number"}function gt(t){return typeof t<"u"&&typeof t!==null}function Zf(t){return!(!t||typeof t!="object"||!t.code||!oo(t.code,!1)||!t.message||!it(t.message,!1))}function Qf(t){return!(_t(t)||!it(t.method,!1))}function el(t){return!(_t(t)||_t(t.result)&&_t(t.error)||!oo(t.id,!1)||!it(t.jsonrpc,!1))}function tl(t){return!(_t(t)||!it(t.name,!1))}function po(t,e){return!(!en(e)||!Uf(t).includes(e))}function rl(t,e,r){return it(r,!1)?Mf(t,e).includes(r):!1}function il(t,e,r){return it(r,!1)?jf(t,e).includes(r):!1}function go(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 l=t[c].chains,p=It(e[c].accounts);pt(l,p)?pt(t[c].methods,e[c].methods)?pt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?i=W("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:y,events:D,chains:A})=>{var S;i||(S=e[c].extension)!=null&&S.find(E=>{const N=It(E.accounts);return pt(A,N)&&pt(D,E.events)&&pt(y,E.methods)})||(i=W("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):i=W("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):i=W("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):i=W("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):i=W("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),i}var Zr={},nn=function(t,e){return nn=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])},nn(t,e)};function nl(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");nn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var sn=function(){return sn=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},sn.apply(this,arguments)};function sl(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 ol(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 al(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 hl(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(y){try{p(i.next(y))}catch(D){c(D)}}function l(y){try{p(i.throw(y))}catch(D){c(D)}}function p(y){y.done?s(y.value):n(y.value).then(h,l)}p((i=i.apply(t,e||[])).next())})}function ul(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(p){return function(y){return l([p,y])}}function l(p){if(i)throw new TypeError("Generator is already executing.");for(;c&&(c=0,p[0]&&(r=0)),r;)try{if(i=1,n&&(s=p[0]&2?n.return:p[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,p[1])).done)return s;switch(n=0,s&&(p=[p[0]&2,s.value]),p[0]){case 0:case 1:s=p;break;case 4:return r.label++,{value:p[1],done:!1};case 5:r.label++,n=p[1],p=[0];continue;case 7:p=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(p[0]===6||p[0]===2)){r=0;continue}if(p[0]===3&&(!s||p[1]>s[0]&&p[1]<s[3])){r.label=p[1];break}if(p[0]===6&&r.label<s[1]){r.label=s[1],s=p;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(p);break}s[2]&&r.ops.pop(),r.trys.pop();continue}p=e.call(t,r)}catch(y){p=[6,y],n=0}finally{i=s=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}}var on=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 fl(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&on(e,t,r)}function an(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 yo(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 ll(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(yo(arguments[e]));return t}function dl(){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 pl(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 Ar(t){return this instanceof Ar?(this.v=t,this):new Ar(t)}function gl(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(A){i[A]&&(n[A]=function(S){return new Promise(function(E,N){s.push([A,S,E,N])>1||h(A,S)})})}function h(A,S){try{l(i[A](S))}catch(E){D(s[0][3],E)}}function l(A){A.value instanceof Ar?Promise.resolve(A.value.v).then(p,y):D(s[0][2],A)}function p(A){h("next",A)}function y(A){h("throw",A)}function D(A,S){A(S),s.shift(),s.length&&h(s[0][0],s[0][1])}}function yl(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:Ar(t[n](c)),done:n==="return"}:s?s(c):c}:s}}function vl(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 an=="function"?an(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,l){c=t[s](c),n(h,l,c.done,c.value)})}}function n(s,c,h,l){Promise.resolve(l).then(function(p){s({value:p,done:h})},c)}}function _l(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var bl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function ml(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)&&on(e,t,r);return bl(e,t),e}function wl(t){return t&&t.__esModule?t:{default:t}}function El(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 Dl(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 Sl(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 xl=Object.freeze({__proto__:null,__extends:nl,get __assign(){return sn},__rest:sl,__decorate:ol,__param:al,__metadata:cl,__awaiter:hl,__generator:ul,__createBinding:on,__exportStar:fl,__values:an,__read:yo,__spread:ll,__spreadArrays:dl,__spreadArray:pl,__await:Ar,__asyncGenerator:gl,__asyncDelegator:yl,__asyncValues:vl,__makeTemplateObject:_l,__importStar:ml,__importDefault:wl,__classPrivateFieldGet:El,__classPrivateFieldSet:Dl,__classPrivateFieldIn:Sl}),cn=vi(xl),Qr={exports:{}},vo;function Ol(){return vo||(vo=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?Qr.exports=localStorage:Qr.exports=new e}()),Qr.exports}var Tr={},_o;function bo(){if(_o)return Tr;_o=1,Object.defineProperty(Tr,"__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}}Tr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(i,n)=>typeof n>"u"?null:n)}return Tr.safeJsonStringify=e,Tr}var hn={},Cr={},mo;function Il(){if(mo)return Cr;mo=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.IKeyValueStorage=void 0;class t{}return Cr.IKeyValueStorage=t,Cr}var Nr={},wo;function Al(){if(wo)return Nr;wo=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.parseEntry=void 0;const t=bo();function e(r){var i;return[r[0],t.safeJsonParse((i=r[1])!==null&&i!==void 0?i:"")]}return Nr.parseEntry=e,Nr}var Eo;function Tl(){return Eo||(Eo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=cn;e.__exportStar(Il(),t),e.__exportStar(Al(),t)}(hn)),hn}Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.KeyValueStorage=void 0;const ur=cn,Cl=ur.__importDefault(Ol()),Do=bo(),Nl=Tl();class So{constructor(){this.localStorage=Cl.default}getKeys(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return ur.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Nl.parseEntry)})}getItem(e){return ur.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Do.safeJsonParse(r)})}setItem(e,r){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Do.safeJsonStringify(r))})}removeItem(e){return ur.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}Zr.KeyValueStorage=So;var Ll=Zr.default=So,Lr={},ei={},un={},ti={};class Qt{}var Rl=Object.freeze({__proto__:null,IEvents:Qt}),Pl=vi(Rl);Object.defineProperty(ti,"__esModule",{value:!0}),ti.IHeartBeat=void 0;const Fl=Pl;class Ul extends Fl.IEvents{constructor(e){super()}}ti.IHeartBeat=Ul,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)}(un);var fn={},fr={};Object.defineProperty(fr,"__esModule",{value:!0}),fr.HEARTBEAT_EVENTS=fr.HEARTBEAT_INTERVAL=void 0;const Ml=re;fr.HEARTBEAT_INTERVAL=Ml.FIVE_SECONDS,fr.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(fr,t)}(fn);var ln=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(y){try{p(i.next(y))}catch(D){c(D)}}function l(y){try{p(i.throw(y))}catch(D){c(D)}}function p(y){y.done?s(y.value):n(y.value).then(h,l)}p((i=i.apply(t,e||[])).next())})};Object.defineProperty(ei,"__esModule",{value:!0}),ei.HeartBeat=void 0;const jl=gr,$l=re,Bl=un,dn=fn;class pn extends Bl.IHeartBeat{constructor(e){super(e),this.events=new jl.EventEmitter,this.interval=dn.HEARTBEAT_INTERVAL,this.interval=e?.interval||dn.HEARTBEAT_INTERVAL}static init(e){return ln(this,void 0,void 0,function*(){const r=new pn(e);return yield r.init(),r})}init(){return ln(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 ln(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),$l.toMiliseconds(this.interval))})}pulse(){this.events.emit(dn.HEARTBEAT_EVENTS.pulse)}}ei.HeartBeat=pn,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(un,t),r(fn,t)}(Lr);var we={},er={},xo;function Oo(){return xo||(xo=1,Object.defineProperty(er,"__esModule",{value:!0}),er.PINO_CUSTOM_CONTEXT_KEY=er.PINO_LOGGER_DEFAULTS=void 0,er.PINO_LOGGER_DEFAULTS={level:"info"},er.PINO_CUSTOM_CONTEXT_KEY="custom_context"),er}var ht={},Io;function zl(){if(Io)return ht;Io=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.generateChildLogger=ht.formatChildLoggerContext=ht.getLoggerContext=ht.setBrowserLoggerContext=ht.getBrowserLoggerContext=ht.getDefaultLoggerOptions=void 0;const t=Oo();function e(h){return Object.assign(Object.assign({},h),{level:h?.level||t.PINO_LOGGER_DEFAULTS.level})}ht.getDefaultLoggerOptions=e;function r(h,l=t.PINO_CUSTOM_CONTEXT_KEY){return h[l]||""}ht.getBrowserLoggerContext=r;function i(h,l,p=t.PINO_CUSTOM_CONTEXT_KEY){return h[p]=l,h}ht.setBrowserLoggerContext=i;function n(h,l=t.PINO_CUSTOM_CONTEXT_KEY){let p="";return typeof h.bindings>"u"?p=r(h,l):p=h.bindings().context||"",p}ht.getLoggerContext=n;function s(h,l,p=t.PINO_CUSTOM_CONTEXT_KEY){const y=n(h,p);return y.trim()?`${y}/${l}`:l}ht.formatChildLoggerContext=s;function c(h,l,p=t.PINO_CUSTOM_CONTEXT_KEY){const y=s(h,l,p),D=h.child({context:y});return i(D,y,p)}return ht.generateChildLogger=c,ht}var gn,Ao;function Hl(){if(Ao)return gn;Ao=1;function t(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}gn=e;function e(r,i,n){var s=n&&n.stringify||t,c=1;if(typeof r=="object"&&r!==null){var h=i.length+c;if(h===1)return r;var l=new Array(h);l[0]=s(r);for(var p=1;p<h;p++)l[p]=s(i[p]);return l.join(" ")}if(typeof r!="string")return r;var y=i.length;if(y===0)return r;for(var D="",A=1-c,S=-1,E=r&&r.length||0,N=0;N<E;){if(r.charCodeAt(N)===37&&N+1<E){switch(S=S>-1?S:0,r.charCodeAt(N+1)){case 100:case 102:if(A>=y||i[A]==null)break;S<N&&(D+=r.slice(S,N)),D+=Number(i[A]),S=N+2,N++;break;case 105:if(A>=y||i[A]==null)break;S<N&&(D+=r.slice(S,N)),D+=Math.floor(Number(i[A])),S=N+2,N++;break;case 79:case 111:case 106:if(A>=y||i[A]===void 0)break;S<N&&(D+=r.slice(S,N));var L=typeof i[A];if(L==="string"){D+="'"+i[A]+"'",S=N+2,N++;break}if(L==="function"){D+=i[A].name||"<anonymous>",S=N+2,N++;break}D+=s(i[A]),S=N+2,N++;break;case 115:if(A>=y)break;S<N&&(D+=r.slice(S,N)),D+=String(i[A]),S=N+2,N++;break;case 37:S<N&&(D+=r.slice(S,N)),D+="%",S=N+2,N++,A--;break}++A}++N}return S===-1?r:(S<E&&(D+=r.slice(S)),D)}return gn}var yn,To;function Kl(){if(To)return yn;To=1;const t=Hl();yn=n;const e=m().console||{},r={mapHttpRequest:E,mapHttpResponse:E,wrapRequestSerializer:N,wrapResponseSerializer:N,wrapErrorSerializer:N,req:E,res:E,err:A};function i(d,o){return Array.isArray(d)?d.filter(function(P){return P!=="!stdSerializers.err"}):d===!0?Object.keys(o):!1}function n(d){d=d||{},d.browser=d.browser||{};const o=d.browser.transmit;if(o&&typeof o.send!="function")throw Error("pino: transmit option must have a send function");const f=d.browser.write||e;d.browser.write&&(d.browser.asObject=!0);const P=d.serializers||{},U=i(d.browser.serialize,P);let H=d.browser.serialize;Array.isArray(d.browser.serialize)&&d.browser.serialize.indexOf("!stdSerializers.err")>-1&&(H=!1);const G=["error","fatal","warn","info","debug","trace"];typeof f=="function"&&(f.error=f.fatal=f.warn=f.info=f.debug=f.trace=f),d.enabled===!1&&(d.level="silent");const Y=d.level||"info",u=Object.create(f);u.log||(u.log=L),Object.defineProperty(u,"levelVal",{get:j}),Object.defineProperty(u,"level",{get:q,set:F});const v={transmit:o,serialize:U,asObject:d.browser.asObject,levels:G,timestamp:S(d)};u.levels=n.levels,u.level=Y,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=L,u.serializers=P,u._serialize=U,u._stdErrSerialize=H,u.child=R,o&&(u._logEvent=D());function j(){return this.level==="silent"?1/0:this.levels.values[this.level]}function q(){return this._level}function F(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,s(v,u,"error","log"),s(v,u,"fatal","error"),s(v,u,"warn","error"),s(v,u,"info","log"),s(v,u,"debug","log"),s(v,u,"trace","log")}function R(M,z){if(!M)throw new Error("missing bindings for child Pino");z=z||{},U&&M.serializers&&(z.serializers=M.serializers);const Q=z.serializers;if(U&&Q){var K=Object.assign({},P,Q),ee=d.browser.serialize===!0?Object.keys(K):U;delete M.serializers,l([M],ee,K,this._stdErrSerialize)}function J(te){this._childLevel=(te._childLevel|0)+1,this.error=p(te,M,"error"),this.fatal=p(te,M,"fatal"),this.warn=p(te,M,"warn"),this.info=p(te,M,"info"),this.debug=p(te,M,"debug"),this.trace=p(te,M,"trace"),K&&(this.serializers=K,this._serialize=ee),o&&(this._logEvent=D([].concat(te._logEvent.bindings,M)))}return J.prototype=this,new J(this)}return u}n.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"}},n.stdSerializers=r,n.stdTimeFunctions=Object.assign({},{nullTime:B,epochTime:w,unixTime:I,isoTime:_});function s(d,o,f,P){const U=Object.getPrototypeOf(o);o[f]=o.levelVal>o.levels.values[f]?L:U[f]?U[f]:e[f]||e[P]||L,c(d,o,f)}function c(d,o,f){!d.transmit&&o[f]===L||(o[f]=function(P){return function(){const H=d.timestamp(),G=new Array(arguments.length),Y=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var u=0;u<G.length;u++)G[u]=arguments[u];if(d.serialize&&!d.asObject&&l(G,this._serialize,this.serializers,this._stdErrSerialize),d.asObject?P.call(Y,h(this,f,G,H)):P.apply(Y,G),d.transmit){const v=d.transmit.level||o.level,j=n.levels.values[v],q=n.levels.values[f];if(q<j)return;y(this,{ts:H,methodLevel:f,methodValue:q,transmitLevel:v,transmitValue:n.levels.values[d.transmit.level||o.level],send:d.transmit.send,val:o.levelVal},G)}}}(o[f]))}function h(d,o,f,P){d._serialize&&l(f,d._serialize,d.serializers,d._stdErrSerialize);const U=f.slice();let H=U[0];const G={};P&&(G.time=P),G.level=n.levels.values[o];let Y=(d._childLevel|0)+1;if(Y<1&&(Y=1),H!==null&&typeof H=="object"){for(;Y--&&typeof U[0]=="object";)Object.assign(G,U.shift());H=U.length?t(U.shift(),U):void 0}else typeof H=="string"&&(H=t(U.shift(),U));return H!==void 0&&(G.msg=H),G}function l(d,o,f,P){for(const U in d)if(P&&d[U]instanceof Error)d[U]=n.stdSerializers.err(d[U]);else if(typeof d[U]=="object"&&!Array.isArray(d[U]))for(const H in d[U])o&&o.indexOf(H)>-1&&H in f&&(d[U][H]=f[H](d[U][H]))}function p(d,o,f){return function(){const P=new Array(1+arguments.length);P[0]=o;for(var U=1;U<P.length;U++)P[U]=arguments[U-1];return d[f].apply(this,P)}}function y(d,o,f){const P=o.send,U=o.ts,H=o.methodLevel,G=o.methodValue,Y=o.val,u=d._logEvent.bindings;l(f,d._serialize||Object.keys(d.serializers),d.serializers,d._stdErrSerialize===void 0?!0:d._stdErrSerialize),d._logEvent.ts=U,d._logEvent.messages=f.filter(function(v){return u.indexOf(v)===-1}),d._logEvent.level.label=H,d._logEvent.level.value=G,P(H,d._logEvent,Y),d._logEvent=D(u)}function D(d){return{ts:0,messages:[],bindings:d||[],level:{label:"",value:0}}}function A(d){const o={type:d.constructor.name,msg:d.message,stack:d.stack};for(const f in d)o[f]===void 0&&(o[f]=d[f]);return o}function S(d){return typeof d.timestamp=="function"?d.timestamp:d.timestamp===!1?B:w}function E(){return{}}function N(d){return d}function L(){}function B(){return!1}function w(){return Date.now()}function I(){return Math.round(Date.now()/1e3)}function _(){return new Date(Date.now()).toISOString()}function m(){function d(o){return typeof o<"u"&&o}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 d(self)||d(window)||d(this)||{}}}return yn}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=cn;e.__exportStar(Oo(),t),e.__exportStar(zl(),t),e.__exportStar(Kl(),t)})(we);class ql extends Qt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Vl extends Qt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class Gl{constructor(e,r){this.logger=e,this.core=r}}class Wl extends Qt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class kl extends Qt{constructor(e){super()}}class Yl{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Jl extends Qt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Xl extends Qt{constructor(e,r){super(),this.core=e,this.logger=r}}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Zl=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!Ql(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||Rr(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],Co(r))return!1;if(Pt(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(Rr(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(!Pt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Pt(e.listener)?e.listener:e),this._events[t]?Rr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Rr(this._events[t])&&!this._events[t].warned&&(Co(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(!Pt(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(!Pt(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||Pt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Rr(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],Pt(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=[]:Pt(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(Pt(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Pt(t){return typeof t=="function"}function Ql(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function Co(t){return t===void 0}class ed{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class oy extends Zl.EventEmitter{constructor(){super()}}class td{constructor(e){this.client=e}}var vn={},No={},ri={},ii={};Object.defineProperty(ii,"__esModule",{value:!0}),ii.BrowserRandomSource=void 0;const Lo=65536;class rd{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+=Lo)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,Lo)));return r}}ii.BrowserRandomSource=rd;var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.NodeRandomSource=void 0;const id=ct;class nd{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof as<"u"){const e=cs;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,id.wipe)(r),i}}ni.NodeRandomSource=nd,Object.defineProperty(ri,"__esModule",{value:!0}),ri.SystemRandomSource=void 0;const sd=ii,od=ni;class ad{constructor(){if(this.isAvailable=!1,this.name="",this._source=new sd.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)}}ri.SystemRandomSource=ad,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=ri,r=ie,i=ct;t.defaultRandomSource=new e.SystemRandomSource;function n(p,y=t.defaultRandomSource){return y.randomBytes(p)}t.randomBytes=n;function s(p=t.defaultRandomSource){const y=n(4,p),D=(0,r.readUint32LE)(y);return(0,i.wipe)(y),D}t.randomUint32=s;const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(p,y=c,D=t.defaultRandomSource){if(y.length<2)throw new Error("randomString charset is too short");if(y.length>256)throw new Error("randomString charset is too long");let A="";const S=y.length,E=256-256%S;for(;p>0;){const N=n(Math.ceil(p*256/E),D);for(let L=0;L<N.length&&p>0;L++){const B=N[L];B<E&&(A+=y.charAt(B%S),p--)}(0,i.wipe)(N)}return A}t.randomString=h;function l(p,y=c,D=t.defaultRandomSource){const A=Math.ceil(p/(Math.log(y.length)/Math.LN2));return h(A,y,D)}t.randomStringForEntropy=l}(No);var Ro={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=ie,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(l,p){if(p===void 0&&(p=l.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var y=0;if(this._bytesHashed+=p,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&p>0;)this._buffer[this._bufferLength++]=l[y++],p--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(p>=this.blockSize&&(y=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,l,y,p),p%=this.blockSize);p>0;)this._buffer[this._bufferLength++]=l[y++],p--;return this},h.prototype.finish=function(l){if(!this._finished){var p=this._bytesHashed,y=this._bufferLength,D=p/536870912|0,A=p<<3,S=p%128<112?128:256;this._buffer[y]=128;for(var E=y+1;E<S-8;E++)this._buffer[E]=0;e.writeUint32BE(D,this._buffer,S-8),e.writeUint32BE(A,this._buffer,S-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,S),this._finished=!0}for(var E=0;E<this.digestLength/8;E++)e.writeUint32BE(this._stateHi[E],l,E*8),e.writeUint32BE(this._stateLo[E],l,E*8+4);return this},h.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},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(l){return this._stateHi.set(l.stateHi),this._stateLo.set(l.stateLo),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},h.prototype.cleanSavedState=function(l){r.wipe(l.stateHi),r.wipe(l.stateLo),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.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,l,p,y,D,A,S){for(var E=p[0],N=p[1],L=p[2],B=p[3],w=p[4],I=p[5],_=p[6],m=p[7],d=y[0],o=y[1],f=y[2],P=y[3],U=y[4],H=y[5],G=y[6],Y=y[7],u,v,j,q,F,R,M,z;S>=128;){for(var Q=0;Q<16;Q++){var K=8*Q+A;h[Q]=e.readUint32BE(D,K),l[Q]=e.readUint32BE(D,K+4)}for(var Q=0;Q<80;Q++){var ee=E,J=N,te=L,C=B,T=w,x=I,a=_,b=m,V=d,k=o,le=f,_e=P,pe=U,Ee=H,Fe=G,Ce=Y;if(u=m,v=Y,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=(w>>>14|U<<32-14)^(w>>>18|U<<32-18)^(U>>>41-32|w<<32-(41-32)),v=(U>>>14|w<<32-14)^(U>>>18|w<<32-18)^(w>>>41-32|U<<32-(41-32)),F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,u=w&I^~w&_,v=U&H^~U&G,F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,u=n[Q*2],v=n[Q*2+1],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,u=h[Q%16],v=l[Q%16],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,j=M&65535|z<<16,q=F&65535|R<<16,u=j,v=q,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=(E>>>28|d<<32-28)^(d>>>34-32|E<<32-(34-32))^(d>>>39-32|E<<32-(39-32)),v=(d>>>28|E<<32-28)^(E>>>34-32|d<<32-(34-32))^(E>>>39-32|d<<32-(39-32)),F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,u=E&N^E&L^N&L,v=d&o^d&f^o&f,F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,b=M&65535|z<<16,Ce=F&65535|R<<16,u=C,v=_e,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=j,v=q,F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,C=M&65535|z<<16,_e=F&65535|R<<16,N=ee,L=J,B=te,w=C,I=T,_=x,m=a,E=b,o=V,f=k,P=le,U=_e,H=pe,G=Ee,Y=Fe,d=Ce,Q%16===15)for(var K=0;K<16;K++)u=h[K],v=l[K],F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=h[(K+9)%16],v=l[(K+9)%16],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,j=h[(K+1)%16],q=l[(K+1)%16],u=(j>>>1|q<<32-1)^(j>>>8|q<<32-8)^j>>>7,v=(q>>>1|j<<32-1)^(q>>>8|j<<32-8)^(q>>>7|j<<32-7),F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,j=h[(K+14)%16],q=l[(K+14)%16],u=(j>>>19|q<<32-19)^(q>>>61-32|j<<32-(61-32))^j>>>6,v=(q>>>19|j<<32-19)^(j>>>61-32|q<<32-(61-32))^(q>>>6|j<<32-6),F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,h[K]=M&65535|z<<16,l[K]=F&65535|R<<16}u=E,v=d,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[0],v=y[0],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[0]=E=M&65535|z<<16,y[0]=d=F&65535|R<<16,u=N,v=o,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[1],v=y[1],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[1]=N=M&65535|z<<16,y[1]=o=F&65535|R<<16,u=L,v=f,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[2],v=y[2],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[2]=L=M&65535|z<<16,y[2]=f=F&65535|R<<16,u=B,v=P,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[3],v=y[3],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[3]=B=M&65535|z<<16,y[3]=P=F&65535|R<<16,u=w,v=U,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[4],v=y[4],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[4]=w=M&65535|z<<16,y[4]=U=F&65535|R<<16,u=I,v=H,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[5],v=y[5],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[5]=I=M&65535|z<<16,y[5]=H=F&65535|R<<16,u=_,v=G,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[6],v=y[6],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[6]=_=M&65535|z<<16,y[6]=G=F&65535|R<<16,u=m,v=Y,F=v&65535,R=v>>>16,M=u&65535,z=u>>>16,u=p[7],v=y[7],F+=v&65535,R+=v>>>16,M+=u&65535,z+=u>>>16,R+=F>>>16,M+=R>>>16,z+=M>>>16,p[7]=m=M&65535|z<<16,y[7]=Y=F&65535|R<<16,A+=128,S-=128}return A}function c(h){var l=new i;l.update(h);var p=l.digest();return l.clean(),p}t.hash=c})(Ro),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=No,r=Ro,i=ct;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(C){const T=new Float64Array(16);if(C)for(let x=0;x<C.length;x++)T[x]=C[x];return T}const s=new Uint8Array(32);s[0]=9;const c=n(),h=n([1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),p=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),y=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]),A=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function S(C,T){for(let x=0;x<16;x++)C[x]=T[x]|0}function E(C){let T=1;for(let x=0;x<16;x++){let a=C[x]+T+65535;T=Math.floor(a/65536),C[x]=a-T*65536}C[0]+=T-1+37*(T-1)}function N(C,T,x){const a=~(x-1);for(let b=0;b<16;b++){const V=a&(C[b]^T[b]);C[b]^=V,T[b]^=V}}function L(C,T){const x=n(),a=n();for(let b=0;b<16;b++)a[b]=T[b];E(a),E(a),E(a);for(let b=0;b<2;b++){x[0]=a[0]-65517;for(let k=1;k<15;k++)x[k]=a[k]-65535-(x[k-1]>>16&1),x[k-1]&=65535;x[15]=a[15]-32767-(x[14]>>16&1);const V=x[15]>>16&1;x[14]&=65535,N(a,x,1-V)}for(let b=0;b<16;b++)C[2*b]=a[b]&255,C[2*b+1]=a[b]>>8}function B(C,T){let x=0;for(let a=0;a<32;a++)x|=C[a]^T[a];return(1&x-1>>>8)-1}function w(C,T){const x=new Uint8Array(32),a=new Uint8Array(32);return L(x,C),L(a,T),B(x,a)}function I(C){const T=new Uint8Array(32);return L(T,C),T[0]&1}function _(C,T){for(let x=0;x<16;x++)C[x]=T[2*x]+(T[2*x+1]<<8);C[15]&=32767}function m(C,T,x){for(let a=0;a<16;a++)C[a]=T[a]+x[a]}function d(C,T,x){for(let a=0;a<16;a++)C[a]=T[a]-x[a]}function o(C,T,x){let a,b,V=0,k=0,le=0,_e=0,pe=0,Ee=0,Fe=0,Ce=0,ve=0,ge=0,de=0,ue=0,he=0,ce=0,ae=0,ne=0,fe=0,ye=0,se=0,be=0,me=0,Se=0,xe=0,De=0,St=0,Ct=0,Gt=0,yt=0,ir=0,$r=0,ui=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=T[0],V+=a*Ue,k+=a*Ne,le+=a*Me,_e+=a*je,pe+=a*$e,Ee+=a*Le,Fe+=a*ke,Ce+=a*Ye,ve+=a*Je,ge+=a*Xe,de+=a*Ze,ue+=a*He,he+=a*Be,ce+=a*Ae,ae+=a*Qe,ne+=a*et,a=T[1],k+=a*Ue,le+=a*Ne,_e+=a*Me,pe+=a*je,Ee+=a*$e,Fe+=a*Le,Ce+=a*ke,ve+=a*Ye,ge+=a*Je,de+=a*Xe,ue+=a*Ze,he+=a*He,ce+=a*Be,ae+=a*Ae,ne+=a*Qe,fe+=a*et,a=T[2],le+=a*Ue,_e+=a*Ne,pe+=a*Me,Ee+=a*je,Fe+=a*$e,Ce+=a*Le,ve+=a*ke,ge+=a*Ye,de+=a*Je,ue+=a*Xe,he+=a*Ze,ce+=a*He,ae+=a*Be,ne+=a*Ae,fe+=a*Qe,ye+=a*et,a=T[3],_e+=a*Ue,pe+=a*Ne,Ee+=a*Me,Fe+=a*je,Ce+=a*$e,ve+=a*Le,ge+=a*ke,de+=a*Ye,ue+=a*Je,he+=a*Xe,ce+=a*Ze,ae+=a*He,ne+=a*Be,fe+=a*Ae,ye+=a*Qe,se+=a*et,a=T[4],pe+=a*Ue,Ee+=a*Ne,Fe+=a*Me,Ce+=a*je,ve+=a*$e,ge+=a*Le,de+=a*ke,ue+=a*Ye,he+=a*Je,ce+=a*Xe,ae+=a*Ze,ne+=a*He,fe+=a*Be,ye+=a*Ae,se+=a*Qe,be+=a*et,a=T[5],Ee+=a*Ue,Fe+=a*Ne,Ce+=a*Me,ve+=a*je,ge+=a*$e,de+=a*Le,ue+=a*ke,he+=a*Ye,ce+=a*Je,ae+=a*Xe,ne+=a*Ze,fe+=a*He,ye+=a*Be,se+=a*Ae,be+=a*Qe,me+=a*et,a=T[6],Fe+=a*Ue,Ce+=a*Ne,ve+=a*Me,ge+=a*je,de+=a*$e,ue+=a*Le,he+=a*ke,ce+=a*Ye,ae+=a*Je,ne+=a*Xe,fe+=a*Ze,ye+=a*He,se+=a*Be,be+=a*Ae,me+=a*Qe,Se+=a*et,a=T[7],Ce+=a*Ue,ve+=a*Ne,ge+=a*Me,de+=a*je,ue+=a*$e,he+=a*Le,ce+=a*ke,ae+=a*Ye,ne+=a*Je,fe+=a*Xe,ye+=a*Ze,se+=a*He,be+=a*Be,me+=a*Ae,Se+=a*Qe,xe+=a*et,a=T[8],ve+=a*Ue,ge+=a*Ne,de+=a*Me,ue+=a*je,he+=a*$e,ce+=a*Le,ae+=a*ke,ne+=a*Ye,fe+=a*Je,ye+=a*Xe,se+=a*Ze,be+=a*He,me+=a*Be,Se+=a*Ae,xe+=a*Qe,De+=a*et,a=T[9],ge+=a*Ue,de+=a*Ne,ue+=a*Me,he+=a*je,ce+=a*$e,ae+=a*Le,ne+=a*ke,fe+=a*Ye,ye+=a*Je,se+=a*Xe,be+=a*Ze,me+=a*He,Se+=a*Be,xe+=a*Ae,De+=a*Qe,St+=a*et,a=T[10],de+=a*Ue,ue+=a*Ne,he+=a*Me,ce+=a*je,ae+=a*$e,ne+=a*Le,fe+=a*ke,ye+=a*Ye,se+=a*Je,be+=a*Xe,me+=a*Ze,Se+=a*He,xe+=a*Be,De+=a*Ae,St+=a*Qe,Ct+=a*et,a=T[11],ue+=a*Ue,he+=a*Ne,ce+=a*Me,ae+=a*je,ne+=a*$e,fe+=a*Le,ye+=a*ke,se+=a*Ye,be+=a*Je,me+=a*Xe,Se+=a*Ze,xe+=a*He,De+=a*Be,St+=a*Ae,Ct+=a*Qe,Gt+=a*et,a=T[12],he+=a*Ue,ce+=a*Ne,ae+=a*Me,ne+=a*je,fe+=a*$e,ye+=a*Le,se+=a*ke,be+=a*Ye,me+=a*Je,Se+=a*Xe,xe+=a*Ze,De+=a*He,St+=a*Be,Ct+=a*Ae,Gt+=a*Qe,yt+=a*et,a=T[13],ce+=a*Ue,ae+=a*Ne,ne+=a*Me,fe+=a*je,ye+=a*$e,se+=a*Le,be+=a*ke,me+=a*Ye,Se+=a*Je,xe+=a*Xe,De+=a*Ze,St+=a*He,Ct+=a*Be,Gt+=a*Ae,yt+=a*Qe,ir+=a*et,a=T[14],ae+=a*Ue,ne+=a*Ne,fe+=a*Me,ye+=a*je,se+=a*$e,be+=a*Le,me+=a*ke,Se+=a*Ye,xe+=a*Je,De+=a*Xe,St+=a*Ze,Ct+=a*He,Gt+=a*Be,yt+=a*Ae,ir+=a*Qe,$r+=a*et,a=T[15],ne+=a*Ue,fe+=a*Ne,ye+=a*Me,se+=a*je,be+=a*$e,me+=a*Le,Se+=a*ke,xe+=a*Ye,De+=a*Je,St+=a*Xe,Ct+=a*Ze,Gt+=a*He,yt+=a*Be,ir+=a*Ae,$r+=a*Qe,ui+=a*et,V+=38*fe,k+=38*ye,le+=38*se,_e+=38*be,pe+=38*me,Ee+=38*Se,Fe+=38*xe,Ce+=38*De,ve+=38*St,ge+=38*Ct,de+=38*Gt,ue+=38*yt,he+=38*ir,ce+=38*$r,ae+=38*ui,b=1,a=V+b+65535,b=Math.floor(a/65536),V=a-b*65536,a=k+b+65535,b=Math.floor(a/65536),k=a-b*65536,a=le+b+65535,b=Math.floor(a/65536),le=a-b*65536,a=_e+b+65535,b=Math.floor(a/65536),_e=a-b*65536,a=pe+b+65535,b=Math.floor(a/65536),pe=a-b*65536,a=Ee+b+65535,b=Math.floor(a/65536),Ee=a-b*65536,a=Fe+b+65535,b=Math.floor(a/65536),Fe=a-b*65536,a=Ce+b+65535,b=Math.floor(a/65536),Ce=a-b*65536,a=ve+b+65535,b=Math.floor(a/65536),ve=a-b*65536,a=ge+b+65535,b=Math.floor(a/65536),ge=a-b*65536,a=de+b+65535,b=Math.floor(a/65536),de=a-b*65536,a=ue+b+65535,b=Math.floor(a/65536),ue=a-b*65536,a=he+b+65535,b=Math.floor(a/65536),he=a-b*65536,a=ce+b+65535,b=Math.floor(a/65536),ce=a-b*65536,a=ae+b+65535,b=Math.floor(a/65536),ae=a-b*65536,a=ne+b+65535,b=Math.floor(a/65536),ne=a-b*65536,V+=b-1+37*(b-1),b=1,a=V+b+65535,b=Math.floor(a/65536),V=a-b*65536,a=k+b+65535,b=Math.floor(a/65536),k=a-b*65536,a=le+b+65535,b=Math.floor(a/65536),le=a-b*65536,a=_e+b+65535,b=Math.floor(a/65536),_e=a-b*65536,a=pe+b+65535,b=Math.floor(a/65536),pe=a-b*65536,a=Ee+b+65535,b=Math.floor(a/65536),Ee=a-b*65536,a=Fe+b+65535,b=Math.floor(a/65536),Fe=a-b*65536,a=Ce+b+65535,b=Math.floor(a/65536),Ce=a-b*65536,a=ve+b+65535,b=Math.floor(a/65536),ve=a-b*65536,a=ge+b+65535,b=Math.floor(a/65536),ge=a-b*65536,a=de+b+65535,b=Math.floor(a/65536),de=a-b*65536,a=ue+b+65535,b=Math.floor(a/65536),ue=a-b*65536,a=he+b+65535,b=Math.floor(a/65536),he=a-b*65536,a=ce+b+65535,b=Math.floor(a/65536),ce=a-b*65536,a=ae+b+65535,b=Math.floor(a/65536),ae=a-b*65536,a=ne+b+65535,b=Math.floor(a/65536),ne=a-b*65536,V+=b-1+37*(b-1),C[0]=V,C[1]=k,C[2]=le,C[3]=_e,C[4]=pe,C[5]=Ee,C[6]=Fe,C[7]=Ce,C[8]=ve,C[9]=ge,C[10]=de,C[11]=ue,C[12]=he,C[13]=ce,C[14]=ae,C[15]=ne}function f(C,T){o(C,T,T)}function P(C,T){const x=n();let a;for(a=0;a<16;a++)x[a]=T[a];for(a=253;a>=0;a--)f(x,x),a!==2&&a!==4&&o(x,x,T);for(a=0;a<16;a++)C[a]=x[a]}function U(C,T){const x=n();let a;for(a=0;a<16;a++)x[a]=T[a];for(a=250;a>=0;a--)f(x,x),a!==1&&o(x,x,T);for(a=0;a<16;a++)C[a]=x[a]}function H(C,T){const x=n(),a=n(),b=n(),V=n(),k=n(),le=n(),_e=n(),pe=n(),Ee=n();d(x,C[1],C[0]),d(Ee,T[1],T[0]),o(x,x,Ee),m(a,C[0],C[1]),m(Ee,T[0],T[1]),o(a,a,Ee),o(b,C[3],T[3]),o(b,b,p),o(V,C[2],T[2]),m(V,V,V),d(k,a,x),d(le,V,b),m(_e,V,b),m(pe,a,x),o(C[0],k,le),o(C[1],pe,_e),o(C[2],_e,le),o(C[3],k,pe)}function G(C,T,x){for(let a=0;a<4;a++)N(C[a],T[a],x)}function Y(C,T){const x=n(),a=n(),b=n();P(b,T[2]),o(x,T[0],b),o(a,T[1],b),L(C,a),C[31]^=I(x)<<7}function u(C,T,x){S(C[0],c),S(C[1],h),S(C[2],h),S(C[3],c);for(let a=255;a>=0;--a){const b=x[a/8|0]>>(a&7)&1;G(C,T,b),H(T,C),H(C,C),G(C,T,b)}}function v(C,T){const x=[n(),n(),n(),n()];S(x[0],y),S(x[1],D),S(x[2],h),o(x[3],y,D),u(C,x,T)}function j(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 x=new Uint8Array(32),a=[n(),n(),n(),n()];v(a,T),Y(x,a);const b=new Uint8Array(64);return b.set(C),b.set(x,32),{publicKey:x,secretKey:b}}t.generateKeyPairFromSeed=j;function q(C){const T=(0,e.randomBytes)(32,C),x=j(T);return(0,i.wipe)(T),x}t.generateKeyPair=q;function F(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=F;const R=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function M(C,T){let x,a,b,V;for(a=63;a>=32;--a){for(x=0,b=a-32,V=a-12;b<V;++b)T[b]+=x-16*T[a]*R[b-(a-32)],x=Math.floor((T[b]+128)/256),T[b]-=x*256;T[b]+=x,T[a]=0}for(x=0,b=0;b<32;b++)T[b]+=x-(T[31]>>4)*R[b],x=T[b]>>8,T[b]&=255;for(b=0;b<32;b++)T[b]-=x*R[b];for(a=0;a<32;a++)T[a+1]+=T[a]>>8,C[a]=T[a]&255}function z(C){const T=new Float64Array(64);for(let x=0;x<64;x++)T[x]=C[x];for(let x=0;x<64;x++)C[x]=0;M(C,T)}function Q(C,T){const x=new Float64Array(64),a=[n(),n(),n(),n()],b=(0,r.hash)(C.subarray(0,32));b[0]&=248,b[31]&=127,b[31]|=64;const V=new Uint8Array(64);V.set(b.subarray(32),32);const k=new r.SHA512;k.update(V.subarray(32)),k.update(T);const le=k.digest();k.clean(),z(le),v(a,le),Y(V,a),k.reset(),k.update(V.subarray(0,32)),k.update(C.subarray(32)),k.update(T);const _e=k.digest();z(_e);for(let pe=0;pe<32;pe++)x[pe]=le[pe];for(let pe=0;pe<32;pe++)for(let Ee=0;Ee<32;Ee++)x[pe+Ee]+=_e[pe]*b[Ee];return M(V.subarray(32),x),V}t.sign=Q;function K(C,T){const x=n(),a=n(),b=n(),V=n(),k=n(),le=n(),_e=n();return S(C[2],h),_(C[1],T),f(b,C[1]),o(V,b,l),d(b,b,C[2]),m(V,C[2],V),f(k,V),f(le,k),o(_e,le,k),o(x,_e,b),o(x,x,V),U(x,x),o(x,x,b),o(x,x,V),o(x,x,V),o(C[0],x,V),f(a,C[0]),o(a,a,V),w(a,b)&&o(C[0],C[0],A),f(a,C[0]),o(a,a,V),w(a,b)?-1:(I(C[0])===T[31]>>7&&d(C[0],c,C[0]),o(C[3],C[0],C[1]),0)}function ee(C,T,x){const a=new Uint8Array(32),b=[n(),n(),n(),n()],V=[n(),n(),n(),n()];if(x.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(K(V,C))return!1;const k=new r.SHA512;k.update(x.subarray(0,32)),k.update(C),k.update(T);const le=k.digest();return z(le),u(b,V,le),v(V,x.subarray(32)),H(b,V),Y(a,b),!B(x,a)}t.verify=ee;function J(C){let T=[n(),n(),n(),n()];if(K(T,C))throw new Error("Ed25519: invalid public key");let x=n(),a=n(),b=T[1];m(x,h,b),d(a,h,b),P(a,a),o(x,x,a);let V=new Uint8Array(32);return L(V,x),V}t.convertPublicKeyToX25519=J;function te(C){const T=(0,r.hash)(C.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const x=new Uint8Array(T.subarray(0,32));return(0,i.wipe)(T),x}t.convertSecretKeyToX25519=te}(vn);const cd="EdDSA",hd="JWT",Po=".",Fo="base64url",ud="utf8",fd="utf8",ld=":",dd="did",pd="key",Uo="base58btc",gd="z",yd="K36",vd=32;function si(t){return lt(ft(br(t),ud),Fo)}function Mo(t){const e=ft(yd,Uo),r=gd+lt(Ui([e,t]),Uo);return[dd,pd,r].join(ld)}function _d(t){return lt(t,Fo)}function bd(t){return ft([si(t.header),si(t.payload)].join(Po),fd)}function md(t){return[si(t.header),si(t.payload),_d(t.signature)].join(Po)}function jo(t=wr.randomBytes(vd)){return vn.generateKeyPairFromSeed(t)}async function wd(t,e,r,i,n=re.fromMiliseconds(Date.now())){const s={alg:cd,typ:hd},c=Mo(i.publicKey),h=n+r,l={iss:c,sub:t,aud:e,iat:n,exp:h},p=bd({header:s,payload:l}),y=vn.sign(i.secretKey,p);return md({header:s,payload:l,signature:y})}const $o=10,Ed=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class Dd{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.registering=!1,!Hn(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(br(e))}catch(i){this.onError(e.id,i)}}register(e=this.url){if(!Hn(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=Fn.isReactNative()?void 0:{rejectUnauthorized:!sc(e)},s=new Ed(e,[],n);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const h=this.parseError(c.error);this.events.emit("register_error",h),this.onClose(),i(h)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const i=this.parseError(r.error);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"?Si(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=_r(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Pn(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>$o&&this.events.setMaxListeners($o)}}var _n={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,c=9007199254740991,h="[object Arguments]",l="[object Array]",p="[object AsyncFunction]",y="[object Boolean]",D="[object Date]",A="[object Error]",S="[object Function]",E="[object GeneratorFunction]",N="[object Map]",L="[object Number]",B="[object Null]",w="[object Object]",I="[object Promise]",_="[object Proxy]",m="[object RegExp]",d="[object Set]",o="[object String]",f="[object Symbol]",P="[object Undefined]",U="[object WeakMap]",H="[object ArrayBuffer]",G="[object DataView]",Y="[object Float32Array]",u="[object Float64Array]",v="[object Int8Array]",j="[object Int16Array]",q="[object Int32Array]",F="[object Uint8Array]",R="[object Uint8ClampedArray]",M="[object Uint16Array]",z="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,K=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,J={};J[Y]=J[u]=J[v]=J[j]=J[q]=J[F]=J[R]=J[M]=J[z]=!0,J[h]=J[l]=J[H]=J[y]=J[G]=J[D]=J[A]=J[S]=J[N]=J[L]=J[w]=J[m]=J[d]=J[o]=J[U]=!1;var te=typeof Z=="object"&&Z&&Z.Object===Object&&Z,C=typeof self=="object"&&self&&self.Object===Object&&self,T=te||C||Function("return this")(),x=e&&!e.nodeType&&e,a=x&&!0&&t&&!t.nodeType&&t,b=a&&a.exports===x,V=b&&te.process,k=function(){try{return V&&V.binding&&V.binding("util")}catch{}}(),le=k&&k.isTypedArray;function _e(g,O){for(var $=-1,X=g==null?0:g.length,Ie=0,oe=[];++$<X;){var Re=g[$];O(Re,$,g)&&(oe[Ie++]=Re)}return oe}function pe(g,O){for(var $=-1,X=O.length,Ie=g.length;++$<X;)g[Ie+$]=O[$];return g}function Ee(g,O){for(var $=-1,X=g==null?0:g.length;++$<X;)if(O(g[$],$,g))return!0;return!1}function Fe(g,O){for(var $=-1,X=Array(g);++$<g;)X[$]=O($);return X}function Ce(g){return function(O){return g(O)}}function ve(g,O){return g.has(O)}function ge(g,O){return g?.[O]}function de(g){var O=-1,$=Array(g.size);return g.forEach(function(X,Ie){$[++O]=[Ie,X]}),$}function ue(g,O){return function($){return g(O($))}}function he(g){var O=-1,$=Array(g.size);return g.forEach(function(X){$[++O]=X}),$}var ce=Array.prototype,ae=Function.prototype,ne=Object.prototype,fe=T["__core-js_shared__"],ye=ae.toString,se=ne.hasOwnProperty,be=function(){var g=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||"");return g?"Symbol(src)_1."+g:""}(),me=ne.toString,Se=RegExp("^"+ye.call(se).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xe=b?T.Buffer:void 0,De=T.Symbol,St=T.Uint8Array,Ct=ne.propertyIsEnumerable,Gt=ce.splice,yt=De?De.toStringTag:void 0,ir=Object.getOwnPropertySymbols,$r=xe?xe.isBuffer:void 0,ui=ue(Object.keys,Object),Ue=pr(T,"DataView"),Ne=pr(T,"Map"),Me=pr(T,"Promise"),je=pr(T,"Set"),$e=pr(T,"WeakMap"),Le=pr(Object,"create"),ke=sr(Ue),Ye=sr(Ne),Je=sr(Me),Xe=sr(je),Ze=sr($e),He=De?De.prototype:void 0,Be=He?He.valueOf:void 0;function Ae(g){var O=-1,$=g==null?0:g.length;for(this.clear();++O<$;){var X=g[O];this.set(X[0],X[1])}}function Qe(){this.__data__=Le?Le(null):{},this.size=0}function et(g){var O=this.has(g)&&delete this.__data__[g];return this.size-=O?1:0,O}function g0(g){var O=this.__data__;if(Le){var $=O[g];return $===i?void 0:$}return se.call(O,g)?O[g]:void 0}function y0(g){var O=this.__data__;return Le?O[g]!==void 0:se.call(O,g)}function v0(g,O){var $=this.__data__;return this.size+=this.has(g)?0:1,$[g]=Le&&O===void 0?i:O,this}Ae.prototype.clear=Qe,Ae.prototype.delete=et,Ae.prototype.get=g0,Ae.prototype.has=y0,Ae.prototype.set=v0;function jt(g){var O=-1,$=g==null?0:g.length;for(this.clear();++O<$;){var X=g[O];this.set(X[0],X[1])}}function _0(){this.__data__=[],this.size=0}function b0(g){var O=this.__data__,$=li(O,g);if($<0)return!1;var X=O.length-1;return $==X?O.pop():Gt.call(O,$,1),--this.size,!0}function m0(g){var O=this.__data__,$=li(O,g);return $<0?void 0:O[$][1]}function w0(g){return li(this.__data__,g)>-1}function E0(g,O){var $=this.__data__,X=li($,g);return X<0?(++this.size,$.push([g,O])):$[X][1]=O,this}jt.prototype.clear=_0,jt.prototype.delete=b0,jt.prototype.get=m0,jt.prototype.has=w0,jt.prototype.set=E0;function nr(g){var O=-1,$=g==null?0:g.length;for(this.clear();++O<$;){var X=g[O];this.set(X[0],X[1])}}function D0(){this.size=0,this.__data__={hash:new Ae,map:new(Ne||jt),string:new Ae}}function S0(g){var O=di(this,g).delete(g);return this.size-=O?1:0,O}function x0(g){return di(this,g).get(g)}function O0(g){return di(this,g).has(g)}function I0(g,O){var $=di(this,g),X=$.size;return $.set(g,O),this.size+=$.size==X?0:1,this}nr.prototype.clear=D0,nr.prototype.delete=S0,nr.prototype.get=x0,nr.prototype.has=O0,nr.prototype.set=I0;function fi(g){var O=-1,$=g==null?0:g.length;for(this.__data__=new nr;++O<$;)this.add(g[O])}function A0(g){return this.__data__.set(g,i),this}function T0(g){return this.__data__.has(g)}fi.prototype.add=fi.prototype.push=A0,fi.prototype.has=T0;function Wt(g){var O=this.__data__=new jt(g);this.size=O.size}function C0(){this.__data__=new jt,this.size=0}function N0(g){var O=this.__data__,$=O.delete(g);return this.size=O.size,$}function L0(g){return this.__data__.get(g)}function R0(g){return this.__data__.has(g)}function P0(g,O){var $=this.__data__;if($ instanceof jt){var X=$.__data__;if(!Ne||X.length<r-1)return X.push([g,O]),this.size=++$.size,this;$=this.__data__=new nr(X)}return $.set(g,O),this.size=$.size,this}Wt.prototype.clear=C0,Wt.prototype.delete=N0,Wt.prototype.get=L0,Wt.prototype.has=R0,Wt.prototype.set=P0;function F0(g,O){var $=pi(g),X=!$&&J0(g),Ie=!$&&!X&&Tn(g),oe=!$&&!X&&!Ie&&ja(g),Re=$||X||Ie||oe,tt=Re?Fe(g.length,String):[],st=tt.length;for(var Te in g)(O||se.call(g,Te))&&!(Re&&(Te=="length"||Ie&&(Te=="offset"||Te=="parent")||oe&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||V0(Te,st)))&&tt.push(Te);return tt}function li(g,O){for(var $=g.length;$--;)if(Pa(g[$][0],O))return $;return-1}function U0(g,O,$){var X=O(g);return pi(g)?X:pe(X,$(g))}function Br(g){return g==null?g===void 0?P:B:yt&&yt in Object(g)?K0(g):Y0(g)}function Ca(g){return zr(g)&&Br(g)==h}function Na(g,O,$,X,Ie){return g===O?!0:g==null||O==null||!zr(g)&&!zr(O)?g!==g&&O!==O:M0(g,O,$,X,Na,Ie)}function M0(g,O,$,X,Ie,oe){var Re=pi(g),tt=pi(O),st=Re?l:kt(g),Te=tt?l:kt(O);st=st==h?w:st,Te=Te==h?w:Te;var vt=st==w,xt=Te==w,at=st==Te;if(at&&Tn(g)){if(!Tn(O))return!1;Re=!0,vt=!1}if(at&&!vt)return oe||(oe=new Wt),Re||ja(g)?La(g,O,$,X,Ie,oe):z0(g,O,st,$,X,Ie,oe);if(!($&n)){var mt=vt&&se.call(g,"__wrapped__"),wt=xt&&se.call(O,"__wrapped__");if(mt||wt){var Yt=mt?g.value():g,$t=wt?O.value():O;return oe||(oe=new Wt),Ie(Yt,$t,$,X,oe)}}return at?(oe||(oe=new Wt),H0(g,O,$,X,Ie,oe)):!1}function j0(g){if(!Ma(g)||W0(g))return!1;var O=Fa(g)?Se:K;return O.test(sr(g))}function $0(g){return zr(g)&&Ua(g.length)&&!!J[Br(g)]}function B0(g){if(!k0(g))return ui(g);var O=[];for(var $ in Object(g))se.call(g,$)&&$!="constructor"&&O.push($);return O}function La(g,O,$,X,Ie,oe){var Re=$&n,tt=g.length,st=O.length;if(tt!=st&&!(Re&&st>tt))return!1;var Te=oe.get(g);if(Te&&oe.get(O))return Te==O;var vt=-1,xt=!0,at=$&s?new fi:void 0;for(oe.set(g,O),oe.set(O,g);++vt<tt;){var mt=g[vt],wt=O[vt];if(X)var Yt=Re?X(wt,mt,vt,O,g,oe):X(mt,wt,vt,g,O,oe);if(Yt!==void 0){if(Yt)continue;xt=!1;break}if(at){if(!Ee(O,function($t,or){if(!ve(at,or)&&(mt===$t||Ie(mt,$t,$,X,oe)))return at.push(or)})){xt=!1;break}}else if(!(mt===wt||Ie(mt,wt,$,X,oe))){xt=!1;break}}return oe.delete(g),oe.delete(O),xt}function z0(g,O,$,X,Ie,oe,Re){switch($){case G:if(g.byteLength!=O.byteLength||g.byteOffset!=O.byteOffset)return!1;g=g.buffer,O=O.buffer;case H:return!(g.byteLength!=O.byteLength||!oe(new St(g),new St(O)));case y:case D:case L:return Pa(+g,+O);case A:return g.name==O.name&&g.message==O.message;case m:case o:return g==O+"";case N:var tt=de;case d:var st=X&n;if(tt||(tt=he),g.size!=O.size&&!st)return!1;var Te=Re.get(g);if(Te)return Te==O;X|=s,Re.set(g,O);var vt=La(tt(g),tt(O),X,Ie,oe,Re);return Re.delete(g),vt;case f:if(Be)return Be.call(g)==Be.call(O)}return!1}function H0(g,O,$,X,Ie,oe){var Re=$&n,tt=Ra(g),st=tt.length,Te=Ra(O),vt=Te.length;if(st!=vt&&!Re)return!1;for(var xt=st;xt--;){var at=tt[xt];if(!(Re?at in O:se.call(O,at)))return!1}var mt=oe.get(g);if(mt&&oe.get(O))return mt==O;var wt=!0;oe.set(g,O),oe.set(O,g);for(var Yt=Re;++xt<st;){at=tt[xt];var $t=g[at],or=O[at];if(X)var $a=Re?X(or,$t,at,O,g,oe):X($t,or,at,g,O,oe);if(!($a===void 0?$t===or||Ie($t,or,$,X,oe):$a)){wt=!1;break}Yt||(Yt=at=="constructor")}if(wt&&!Yt){var gi=g.constructor,yi=O.constructor;gi!=yi&&"constructor"in g&&"constructor"in O&&!(typeof gi=="function"&&gi instanceof gi&&typeof yi=="function"&&yi instanceof yi)&&(wt=!1)}return oe.delete(g),oe.delete(O),wt}function Ra(g){return U0(g,Q0,q0)}function di(g,O){var $=g.__data__;return G0(O)?$[typeof O=="string"?"string":"hash"]:$.map}function pr(g,O){var $=ge(g,O);return j0($)?$:void 0}function K0(g){var O=se.call(g,yt),$=g[yt];try{g[yt]=void 0;var X=!0}catch{}var Ie=me.call(g);return X&&(O?g[yt]=$:delete g[yt]),Ie}var q0=ir?function(g){return g==null?[]:(g=Object(g),_e(ir(g),function(O){return Ct.call(g,O)}))}:ey,kt=Br;(Ue&&kt(new Ue(new ArrayBuffer(1)))!=G||Ne&&kt(new Ne)!=N||Me&&kt(Me.resolve())!=I||je&&kt(new je)!=d||$e&&kt(new $e)!=U)&&(kt=function(g){var O=Br(g),$=O==w?g.constructor:void 0,X=$?sr($):"";if(X)switch(X){case ke:return G;case Ye:return N;case Je:return I;case Xe:return d;case Ze:return U}return O});function V0(g,O){return O=O??c,!!O&&(typeof g=="number"||ee.test(g))&&g>-1&&g%1==0&&g<O}function G0(g){var O=typeof g;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?g!=="__proto__":g===null}function W0(g){return!!be&&be in g}function k0(g){var O=g&&g.constructor,$=typeof O=="function"&&O.prototype||ne;return g===$}function Y0(g){return me.call(g)}function sr(g){if(g!=null){try{return ye.call(g)}catch{}try{return g+""}catch{}}return""}function Pa(g,O){return g===O||g!==g&&O!==O}var J0=Ca(function(){return arguments}())?Ca:function(g){return zr(g)&&se.call(g,"callee")&&!Ct.call(g,"callee")},pi=Array.isArray;function X0(g){return g!=null&&Ua(g.length)&&!Fa(g)}var Tn=$r||ty;function Z0(g,O){return Na(g,O)}function Fa(g){if(!Ma(g))return!1;var O=Br(g);return O==S||O==E||O==p||O==_}function Ua(g){return typeof g=="number"&&g>-1&&g%1==0&&g<=c}function Ma(g){var O=typeof g;return g!=null&&(O=="object"||O=="function")}function zr(g){return g!=null&&typeof g=="object"}var ja=le?Ce(le):$0;function Q0(g){return X0(g)?F0(g):B0(g)}function ey(){return[]}function ty(){return!1}t.exports=Z0})(_n,_n.exports);var Sd=_n.exports,xd=Object.defineProperty,Bo=Object.getOwnPropertySymbols,Od=Object.prototype.hasOwnProperty,Id=Object.prototype.propertyIsEnumerable,zo=(t,e,r)=>e in t?xd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Od.call(e,r)&&zo(t,r,e[r]);if(Bo)for(var r of Bo(e))Id.call(e,r)&&zo(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var tr=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!Ad(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||Pr(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],Ho(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(Pr(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(!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]?Pr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Pr(this._events[t])&&!this._events[t].warned&&(Ho(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(!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},Ve.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(Pr(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],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},Ve.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},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function Ad(t){return typeof t=="number"}function Pr(t){return typeof t=="object"&&t!==null}function Ho(t){return t===void 0}function Td(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,l=t.charAt(0),p=Math.log(h)/Math.log(256),y=Math.log(256)/Math.log(h);function D(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var N=0,L=0,B=0,w=E.length;B!==w&&E[B]===0;)B++,N++;for(var I=(w-B)*y+1>>>0,_=new Uint8Array(I);B!==w;){for(var m=E[B],d=0,o=I-1;(m!==0||d<L)&&o!==-1;o--,d++)m+=256*_[o]>>>0,_[o]=m%h>>>0,m=m/h>>>0;if(m!==0)throw new Error("Non-zero carry");L=d,B++}for(var f=I-L;f!==I&&_[f]===0;)f++;for(var P=l.repeat(N);f<I;++f)P+=t.charAt(_[f]);return P}function A(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var N=0;if(E[N]!==" "){for(var L=0,B=0;E[N]===l;)L++,N++;for(var w=(E.length-N)*p+1>>>0,I=new Uint8Array(w);E[N];){var _=r[E.charCodeAt(N)];if(_===255)return;for(var m=0,d=w-1;(_!==0||m<B)&&d!==-1;d--,m++)_+=h*I[d]>>>0,I[d]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");B=m,N++}if(E[N]!==" "){for(var o=w-B;o!==w&&I[o]===0;)o++;for(var f=new Uint8Array(L+(w-o)),P=L;o!==w;)f[P++]=I[o++];return f}}}function S(E){var N=A(E);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:A,decode:S}}var Cd=Td,Nd=Cd;const Ko=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")},Ld=t=>new TextEncoder().encode(t),Rd=t=>new TextDecoder().decode(t);class Pd{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 Fd{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 Ud{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 Ud(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Md{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Pd(e,r,i),this.decoder=new Fd(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const oi=({name:t,prefix:e,encode:r,decode:i})=>new Md(t,e,r,i),Fr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Nd(r,e);return oi({prefix:t,name:e,encode:i,decode:s=>Ko(n(s))})},jd=(t,e,r,i)=>{const n={};for(let y=0;y<e.length;++y)n[e[y]]=y;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let h=0,l=0,p=0;for(let y=0;y<s;++y){const D=n[t[y]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|D,h+=r,h>=8&&(h-=8,c[p++]=255&l>>h)}if(h>=r||255&l<<8-h)throw new SyntaxError("Unexpected end of data");return c},$d=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,h=0;for(let l=0;l<t.length;++l)for(h=h<<8|t[l],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})=>oi({prefix:e,name:t,encode(n){return $d(n,i,r)},decode(n){return jd(n,i,r,t)}}),Bd=oi({prefix:"\0",name:"identity",encode:t=>Rd(t),decode:t=>Ld(t)});var zd=Object.freeze({__proto__:null,identity:Bd});const Hd=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Kd=Object.freeze({__proto__:null,base2:Hd});const qd=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vd=Object.freeze({__proto__:null,base8:qd});const Gd=Fr({prefix:"9",name:"base10",alphabet:"0123456789"});var Wd=Object.freeze({__proto__:null,base10:Gd});const kd=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yd=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Jd=Object.freeze({__proto__:null,base16:kd,base16upper:Yd});const Xd=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zd=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qd=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ep=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tp=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rp=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ip=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),np=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sp=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var op=Object.freeze({__proto__:null,base32:Xd,base32upper:Zd,base32pad:Qd,base32padupper:ep,base32hex:tp,base32hexupper:rp,base32hexpad:ip,base32hexpadupper:np,base32z:sp});const ap=Fr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cp=Fr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var hp=Object.freeze({__proto__:null,base36:ap,base36upper:cp});const up=Fr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fp=Fr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lp=Object.freeze({__proto__:null,base58btc:up,base58flickr:fp});const dp=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pp=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gp=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yp=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vp=Object.freeze({__proto__:null,base64:dp,base64pad:pp,base64url:gp,base64urlpad:yp});const Vo=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=Vo.reduce((t,e,r)=>(t[r]=e,t),[]),bp=Vo.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function mp(t){return t.reduce((e,r)=>(e+=_p[r],e),"")}function wp(t){const e=[];for(const r of t){const i=bp[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Ep=oi({prefix:"\u{1F680}",name:"base256emoji",encode:mp,decode:wp});var Dp=Object.freeze({__proto__:null,base256emoji:Ep}),Sp=Wo,Go=128,xp=127,Op=~xp,Ip=Math.pow(2,31);function Wo(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Ip;)e[r++]=t&255|Go,t/=128;for(;t&Op;)e[r++]=t&255|Go,t>>>=7;return e[r]=t|0,Wo.bytes=r-i+1,e}var Ap=bn,Tp=128,ko=127;function bn(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw bn.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&ko)<<n:(c&ko)*Math.pow(2,n),n+=7}while(c>=Tp);return bn.bytes=s-i,r}var Cp=Math.pow(2,7),Np=Math.pow(2,14),Lp=Math.pow(2,21),Rp=Math.pow(2,28),Pp=Math.pow(2,35),Fp=Math.pow(2,42),Up=Math.pow(2,49),Mp=Math.pow(2,56),jp=Math.pow(2,63),$p=function(t){return t<Cp?1:t<Np?2:t<Lp?3:t<Rp?4:t<Pp?5:t<Fp?6:t<Up?7:t<Mp?8:t<jp?9:10},Bp={encode:Sp,decode:Ap,encodingLength:$p},Yo=Bp;const Jo=(t,e,r=0)=>(Yo.encode(t,e,r),e),Xo=t=>Yo.encodingLength(t),mn=(t,e)=>{const r=e.byteLength,i=Xo(t),n=i+Xo(r),s=new Uint8Array(n+r);return Jo(t,s,0),Jo(r,s,i),s.set(e,n),new zp(t,r,e,s)};class zp{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Zo=({name:t,code:e,encode:r})=>new Hp(t,e,r);class Hp{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?mn(this.code,r):r.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Qo=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Kp=Zo({name:"sha2-256",code:18,encode:Qo("SHA-256")}),qp=Zo({name:"sha2-512",code:19,encode:Qo("SHA-512")});var Vp=Object.freeze({__proto__:null,sha256:Kp,sha512:qp});const ea=0,Gp="identity",ta=Ko;var Wp=Object.freeze({__proto__:null,identity:{code:ea,name:Gp,encode:ta,digest:t=>mn(ea,ta(t))}});new TextEncoder,new TextDecoder;const ra=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},zd),Kd),Vd),Wd),Jd),op),hp),lp),vp),Dp);ut(ut({},Vp),Wp);function kp(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ia(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const na=ia("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),wn=ia("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=kp(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Yp=ut({utf8:na,"utf-8":na,hex:ra.base16,latin1:wn,ascii:wn,binary:wn},ra);function Jp(t,e="utf8"){const r=Yp[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 sa="wc",Xp=2,En="core",qt=`${sa}@${2}:${En}:`,Zp={name:En,logger:"error"},Qp={database:":memory:"},eg="crypto",oa="client_ed25519_seed",tg=re.ONE_DAY,rg="keychain",ig="0.3",ng="messages",sg="0.3",og=re.SIX_HOURS,ag="publisher",aa="irn",cg="error",hg="wss://relay.walletconnect.com",ug="relayer",lr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},fg="_subscription",dr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},lg=re.ONE_SECOND,dg="2.1.1",pg="0.3",rr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},gg="subscription",yg="0.3",vg=re.FIVE_SECONDS*1e3,_g="pairing",bg="0.3",Ur={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},At={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},mg="history",wg="0.3",Eg="expirer",bt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Dg="0.3";class Sg{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=rg,this.version=ig,this.initialized=!1,this.storagePrefix=qt,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}=W("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=we.generateChildLogger(r,this.name)}get context(){return we.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Qs(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?eo(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xg{constructor(e,r,i){this.core=e,this.logger=r,this.name=eg,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=jo(n);return Mo(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=rf();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),c=jo(s),h=Ji();return await wd(h,n,tg,c)},this.generateSharedKey=(n,s,c)=>{this.isInitialized();const h=this.getPrivateKey(n),l=nf(h,s);return this.setSymKey(l,c)},this.setSymKey=async(n,s)=>{this.isInitialized();const c=s||sf(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=Ws(c),l=br(s);if(ks(h)){const A=h.senderPublicKey,S=h.receiverPublicKey;n=await this.generateSharedKey(A,S)}const p=this.getSymKey(n),{type:y,senderPublicKey:D}=h;return af({type:y,symKey:p,message:l,senderPublicKey:D})},this.decode=async(n,s,c)=>{this.isInitialized();const h=uf(s,c);if(ks(h)){const y=h.receiverPublicKey,D=h.senderPublicKey;n=await this.generateSharedKey(y,D)}const l=this.getSymKey(n),p=cf({symKey:l,encoded:s});return Si(p)},this.core=e,this.logger=we.generateChildLogger(r,this.name),this.keychain=i||new Sg(this.core,this.logger)}get context(){return we.getLoggerContext(this.logger)}getPayloadType(e){const r=Xi(e);return xr(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(oa)}catch{e=Ji(),await this.keychain.set(oa,e)}return Jp(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Og extends Gl{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=ng,this.version=sg,this.initialized=!1,this.storagePrefix=qt,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=Xr(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=Xr(n);return typeof s[c]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=we.generateChildLogger(e,this.name),this.core=r}get context(){return we.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Qs(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?eo(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Ig extends Wl{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new tr.EventEmitter,this.name=ag,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=Zi(s),l=s?.prompt||!1,p=s?.tag||0,y={topic:i,message:n,opts:{ttl:c,relay:h,prompt:l,tag:p}},D=Xr(n);this.queue.set(D,y),await this.rpcPublish(i,n,c,h,l,p),this.onPublish(D,y),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=we.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return we.getLoggerContext(this.logger)}rpcPublish(e,r,i,n,s,c){var h,l,p,y;const D={method:Qi(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:c}};return _t((h=D.params)==null?void 0:h.prompt)&&((l=D.params)==null||delete l.prompt),_t((p=D.params)==null?void 0:p.tag)&&((y=D.params)==null||delete y.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,l=Xr(i);await this.rpcPublish(r,i,n,s,c,h),this.onPublish(l,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Lr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Ag{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 Tg=Object.defineProperty,Cg=Object.defineProperties,Ng=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,Lg=Object.prototype.hasOwnProperty,Rg=Object.prototype.propertyIsEnumerable,ha=(t,e,r)=>e in t?Tg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ai=(t,e)=>{for(var r in e||(e={}))Lg.call(e,r)&&ha(t,r,e[r]);if(ca)for(var r of ca(e))Rg.call(e,r)&&ha(t,r,e[r]);return t},Dn=(t,e)=>Cg(t,Ng(e));class Pg extends Jl{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Ag,this.events=new tr.EventEmitter,this.name=gg,this.version=yg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=qt,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=Zi(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 re.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)>=vg&&(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=we.generateChildLogger(r,this.name)}get context(){return we.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=Zi(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:Qi(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:Qi(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,Dn(ai({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Dn(ai({},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,ai({},r)),this.topicMap.set(r.topic,e),this.events.emit(rr.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}=W("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(rr.deleted,Dn(ai({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(rr.sync)}async reset(){!this.cached.length||await Promise.all(this.cached.map(async e=>await this.resubscribe(e)))}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=W("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(Lr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(dr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(dr.disconnect,()=>{this.onDisconnect()}),this.events.on(rr.created,async e=>{const r=rr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(rr.deleted,async e=>{const r=rr.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}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Fg=Object.defineProperty,ua=Object.getOwnPropertySymbols,Ug=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable,fa=(t,e,r)=>e in t?Fg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jg=(t,e)=>{for(var r in e||(e={}))Ug.call(e,r)&&fa(t,r,e[r]);if(ua)for(var r of ua(e))Mg.call(e,r)&&fa(t,r,e[r]);return t};class $g extends kl{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new tr.EventEmitter,this.name=ug,this.transportExplicitlyClosed=!1,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?we.generateChildLogger(e.logger,this.name):we.pino(we.getDefaultLoggerOptions({level:e.logger||cg})),this.messages=new Og(this.logger,e.core),this.subscriber=new Pg(this,this.logger),this.publisher=new Ig(this,this.logger),this.relayUrl=e?.relayUrl||hg,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 we.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()}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new Ei(new Dd(Sf({sdkVersion:dg,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}),mi(e)){if(!e.method.endsWith(fg))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(jg({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(lr.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(dr.payload,e=>this.onProviderPayload(e)),this.provider.on(dr.connect,()=>{this.events.emit(lr.connect)}),this.provider.on(dr.disconnect,()=>{this.events.emit(lr.disconnect),this.attemptToReconnect()}),this.provider.on(dr.error,e=>this.events.emit(lr.error,e))}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(()=>{this.provider.connect()},re.toMiliseconds(lg))}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bg=Object.defineProperty,la=Object.getOwnPropertySymbols,zg=Object.prototype.hasOwnProperty,Hg=Object.prototype.propertyIsEnumerable,da=(t,e,r)=>e in t?Bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pa=(t,e)=>{for(var r in e||(e={}))zg.call(e,r)&&da(t,r,e[r]);if(la)for(var r of la(e))Hg.call(e,r)&&da(t,r,e[r]);return t};class Sn extends Yl{constructor(e,r,i,n=qt,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=qt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(c=>{qf(c)?this.map.set(c.id,c):Vf(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(l=>Sd(h[l],c[l]))):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 l=pa(pa({},this.getData(c)),h);this.map.set(c,l),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=we.generateChildLogger(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return we.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}=W("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}=W("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}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Kg{constructor(e,r){this.core=e,this.logger=r,this.name=_g,this.version=bg,this.events=new tr,this.initialized=!1,this.storagePrefix=qt,this.ignoredPayloadTypes=[Xt],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=Ji(),n=await this.core.crypto.setSymKey(i),s=Rt(re.FIVE_MINUTES),c={protocol:aa},h={topic:n,expiry:s,relay:c,active:!1},l=Ff({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:l}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:n,symKey:s,relay:c}=Rf(i.uri),h=Rt(re.FIVE_MINUTES),l={topic:n,relay:c,expiry:h,active:!1};return await this.pairings.set(n,l),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}),l},this.activate=async({topic:i})=>{this.isInitialized();const n=Rt(re.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:l}=Zt();this.events.once(Pe("pairing_ping",s),({error:p})=>{p?l(p):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=Hr(n,s),h=await this.core.crypto.encode(i,c),l=Ur[n].req;return this.core.history.set(i,c),await this.core.relayer.publish(i,h,l),c.id},this.sendResult=async(i,n,s)=>{const c=Kr(i,s),h=await this.core.crypto.encode(n,c),l=await this.core.history.get(n,i),p=Ur[l.request.method].res;await this.core.relayer.publish(n,h,p),await this.core.history.resolve(c)},this.sendError=async(i,n,s)=>{const c=_r(i,s),h=await this.core.crypto.encode(n,c),l=await this.core.history.get(n,i),p=Ur[l.request.method]?Ur[l.request.method].res:Ur.unregistered_method.res;await this.core.relayer.publish(n,h,p),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=>Kt(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(()=>{Lt(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}=W("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(n)}if(!Kf(i.uri)){const{message:n}=W("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(n)}},this.isValidPing=async i=>{if(!gt(i)){const{message:s}=W("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}=W("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}=W("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=W("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Kt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=W("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=we.generateChildLogger(r,this.name),this.pairings=new Sn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return we.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(lr.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);mi(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):wi(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}=ro(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class qg extends Vl{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new tr.EventEmitter,this.name=mg,this.version=wg,this.cached=[],this.initialized=!1,this.storagePrefix=qt,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(At.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(At.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(At.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=we.generateChildLogger(r,this.name)}get context(){return we.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:Hr(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}=W("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(At.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=W("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(At.created,e=>{const r=At.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(At.updated,e=>{const r=At.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(At.deleted,e=>{const r=At.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Vg extends Xl{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new tr.EventEmitter,this.name=Eg,this.version=Dg,this.cached=[],this.initialized=!1,this.storagePrefix=qt,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=we.generateChildLogger(r,this.name)}get context(){return we.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 xf(e);if(typeof e=="number")return Of(e);const{message:r}=W("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}=W("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}=W("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;re.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(Lr.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}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Gg=Object.defineProperty,ga=Object.getOwnPropertySymbols,Wg=Object.prototype.hasOwnProperty,kg=Object.prototype.propertyIsEnumerable,ya=(t,e,r)=>e in t?Gg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,va=(t,e)=>{for(var r in e||(e={}))Wg.call(e,r)&&ya(t,r,e[r]);if(ga)for(var r of ga(e))kg.call(e,r)&&ya(t,r,e[r]);return t};class xn extends ql{constructor(e){super(e),this.protocol=sa,this.version=Xp,this.name=En,this.events=new tr.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:we.pino(we.getDefaultLoggerOptions({level:e?.logger||Zp.logger}));this.logger=we.generateChildLogger(r,this.name),this.heartbeat=new Lr.HeartBeat,this.crypto=new xg(this,this.logger,e?.keychain),this.history=new qg(this,this.logger),this.expirer=new Vg(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Ll(va(va({},Qp),e?.storageOptions)),this.relayer=new $g({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new Kg(this,this.logger)}static async init(e){const r=new xn(e);return await r.initialize(),r}get context(){return we.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 Yg=xn;function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var _a=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!Jg(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||Mr(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],ba(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(Mr(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(!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]?Mr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Mr(this._events[t])&&!this._events[t].warned&&(ba(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(!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},Ge.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(Mr(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],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},Ge.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},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ut(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Ut(t){return typeof t=="function"}function Jg(t){return typeof t=="number"}function Mr(t){return typeof t=="object"&&t!==null}function ba(t){return t===void 0}const ma="wc",wa=2,Ea="client",Da=`${ma}@${wa}:${Ea}:`,On={name:Ea,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Xg="proposal",Zg="session",ci=re.SEVEN_DAYS,Qg="engine",hi={wc_sessionPropose:{req:{ttl:re.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:re.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:re.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:re.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1104},res:{ttl:re.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1106},res:{ttl:re.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:re.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:re.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:re.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:re.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1112},res:{ttl:re.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1115}}};var e0=Object.defineProperty,t0=Object.defineProperties,r0=Object.getOwnPropertyDescriptors,Sa=Object.getOwnPropertySymbols,i0=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable,xa=(t,e,r)=>e in t?e0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vt=(t,e)=>{for(var r in e||(e={}))i0.call(e,r)&&xa(t,r,e[r]);if(Sa)for(var r of Sa(e))n0.call(e,r)&&xa(t,r,e[r]);return t},Oa=(t,e)=>t0(t,r0(e));class s0 extends td{constructor(e){super(e),this.name=Qg,this.events=new _a,this.initialized=!1,this.ignoredPayloadTypes=[Xt],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(hi)}),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,l=!1;if(c&&(l=this.client.core.pairing.pairings.get(c).active),!c||!l){const{topic:L,uri:B}=await this.client.core.pairing.create();c=L,h=B}const p=await this.client.core.crypto.generateKeyPair(),y={requiredNamespaces:n,relays:s??[{protocol:aa}],proposer:{publicKey:p,metadata:this.client.metadata}},{reject:D,resolve:A,done:S}=Zt();if(this.events.once(Pe("session_connect"),async({error:L,session:B})=>{if(L)D(L);else if(B){B.self.publicKey=p;const w=Oa(Vt({},B),{requiredNamespaces:n});await this.client.session.set(B.topic,w),await this.setExpiry(B.topic,B.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:B.peer.metadata}),A(w)}}),!c){const{message:L}=W("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(L)}const E=await this.sendRequest(c,"wc_sessionPropose",y),N=Rt(re.FIVE_MINUTES);return await this.setProposal(E,Vt({id:E,expiry:N},y)),{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:l}=this.client.proposal.get(i),p=await this.client.core.crypto.generateKeyPair(),y=h.publicKey,D=await this.client.core.crypto.generateSharedKey(p,y),A={relay:{protocol:n??"irn"},namespaces:s,requiredNamespaces:l,controller:{publicKey:p,metadata:this.client.metadata},expiry:Rt(ci)};await this.client.core.relayer.subscribe(D);const S=await this.sendRequest(D,"wc_sessionSettle",A),{done:E,resolve:N,reject:L}=Zt();this.events.once(Pe("session_approve",S),({error:w})=>{w?L(w):N(this.client.session.get(D))});const B=Oa(Vt({},A),{topic:D,acknowledged:!1,self:A.controller,peer:{publicKey:h.publicKey,metadata:h.metadata},controller:p});return await this.client.session.set(D,B),await this.setExpiry(D,Rt(ci)),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:B.peer.metadata}),c&&i&&(await this.sendResult(i,c,{relay:{protocol:n??"irn"},responderPublicKey:p}),await this.client.proposal.delete(i,ze("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:c})),{topic:D,acknowledged:E}},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:l}=Zt();return this.events.once(Pe("session_update",s),({error:p})=>{p?l(p):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}=Zt();return this.events.once(Pe("session_extend",n),({error:l})=>{l?h(l):c()}),await this.setExpiry(i,Rt(ci)),{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:l,reject:p}=Zt();return this.events.once(Pe("session_request",c),({error:y,result:D})=>{y?p(y):l(D)}),await h()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n;Lt(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}=Zt();this.events.once(Pe("session_ping",n),({error:l})=>{l?h(l):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=>zf(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=Hr(i,n),c=await this.client.core.crypto.encode(r,s),h=hi[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),l=hi[h.request.method].res;await this.client.core.relayer.publish(i,c,l),await this.client.core.history.resolve(s)},this.sendError=async(r,i,n)=>{const s=_r(r,n),c=await this.client.core.crypto.encode(i,s),h=await this.client.core.history.get(i,r),l=hi[h.request.method].res;await this.client.core.relayer.publish(i,c,l),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{Kt(n.expiry)&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Kt(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(Vt({},i.params));const c=Rt(re.FIVE_MINUTES),h=Vt({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(Lt(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 l=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const p=await this.client.core.crypto.generateSharedKey(h,l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:p});const y=await this.client.core.relayer.subscribe(p);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),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:l,namespaces:p}=i.params,y={topic:r,relay:c,expiry:l,namespaces:p,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:y})}catch(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;Lt(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(Vt({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;Lt(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,Rt(ci)),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;Lt(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(()=>{Lt(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(Vt({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;Lt(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(Vt({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}=W("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=Yf(n,"connect()");if(c)throw new Error(c.message);if(!Jf(s,!0)){const{message:h}=W("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(h)}},this.isValidApprove=async r=>{if(!gt(r))throw new Error(W("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=rn(n,"approve()");if(h)throw new Error(h.message);const l=go(c.requiredNamespaces,n,"update()");if(l)throw new Error(l.message);if(!it(s,!0)){const{message:p}=W("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(p)}},this.isValidReject=async r=>{if(!gt(r)){const{message:s}=W("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(await this.isValidProposalId(i),!Zf(n)){const{message:s}=W("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!gt(r)){const{message:p}=W("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(p)}const{relay:i,controller:n,namespaces:s,expiry:c}=r;if(!lo(i)){const{message:p}=W("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(p)}const h=Gf(n,"onSessionSettleRequest()");if(h)throw new Error(h.message);const l=rn(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(Kt(c)){const{message:p}=W("EXPIRED","onSessionSettleRequest()");throw new Error(p)}},this.isValidUpdate=async r=>{if(!gt(r)){const{message:l}=W("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(l)}const{topic:i,namespaces:n}=r;await this.isValidSessionTopic(i);const s=this.client.session.get(i),c=rn(n,"update()");if(c)throw new Error(c.message);const h=go(s.requiredNamespaces,n,"update()");if(h)throw new Error(h.message)},this.isValidExtend=async r=>{if(!gt(r)){const{message:n}=W("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}=W("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(!po(c,s)){const{message:h}=W("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(h)}if(!Qf(n)){const{message:h}=W("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(h)}if(!rl(c,s,n.method)){const{message:h}=W("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(h)}},this.isValidRespond=async r=>{if(!gt(r)){const{message:s}=W("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:i,response:n}=r;if(await this.isValidSessionTopic(i),!el(n)){const{message:s}=W("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!gt(r)){const{message:n}=W("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}=W("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(!po(c,s)){const{message:h}=W("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(h)}if(!tl(n)){const{message:h}=W("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}if(!il(c,s,n.name)){const{message:h}=W("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(h)}},this.isValidDisconnect=async r=>{if(!gt(r)){const{message:n}=W("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}=W("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(lr.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);mi(n)?(this.client.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):wi(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}=ro(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}=W("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}=W("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=W("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!it(e,!1)){const{message:r}=W("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=W("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=W("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}=W("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=W("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Xf(e)){const{message:r}=W("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=W("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Kt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=W("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class o0 extends Sn{constructor(e,r){super(e,r,Xg,Da),this.core=e,this.logger=r}}class a0 extends Sn{constructor(e,r){super(e,r,Zg,Da),this.core=e,this.logger=r}}class In extends ed{constructor(e){super(e),this.protocol=ma,this.version=wa,this.name=On.name,this.events=new _a.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||On.name,this.metadata=e?.metadata||mf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:we.pino(we.getDefaultLoggerOptions({level:e?.logger||On.logger}));this.core=e?.core||new Yg(e),this.logger=we.generateChildLogger(r,this.name),this.session=new a0(this.core,this.logger),this.proposal=new o0(this.core,this.logger),this.engine=new s0(this)}static async init(e){const r=new In(e);return await r.initialize(),r}get context(){return we.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 c0=We;We.EventEmitter=We,We.prototype._events=void 0,We.prototype._maxListeners=void 0,We.defaultMaxListeners=10,We.prototype.setMaxListeners=function(t){if(!h0(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||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],Ia(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: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},We.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]?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&&(Ia(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(!Mt(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(!Mt(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||Mt(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},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],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},We.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},We.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Mt(e))return 1;if(e)return e.length}return 0},We.listenerCount=function(t,e){return t.listenerCount(e)};function Mt(t){return typeof t=="function"}function h0(t){return typeof t=="number"}function jr(t){return typeof t=="object"&&t!==null}function Ia(t){return t===void 0}function u0(t){return typeof t<"u"&&typeof t.context<"u"}const Tt={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class f0 extends Qa{constructor(e){super(),this.events=new c0.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?Vi(this.session.namespaces):ef(this.requiredNamespaces)}get accounts(){return this.session?qi(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(Tt.uri,{uri:i}),this.session=await n(),this.events.emit(Tt.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",_r(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(Tt.init,()=>{if(typeof this.client>"u")return i(new Error("Sign Client not initialized"));r(this.client)})});if(u0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await In.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Tt.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(Tt.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(Tt.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(Tt.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"],d0=["chainChanged","accountsChanged"];function Aa(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Ta(t,e){let r;return e.rpcMap&&(r=e.rpcMap[An([t])]),r}function An(t){return Number(t[0].split(":")[1])}class p0{constructor(e){this.events=new gr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Aa(e),this.signer=this.setSignerProvider(e?.client),this.chainId=An(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(Tt.created,e=>{const r=Vi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=qi(e.namespaces,[this.namespace]);this.setAccounts(i)}),this.signer.connection.on(Tt.updated,e=>{const r=Vi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=qi(e.namespaces,[this.namespace]);i!==this.accounts&&this.setAccounts(i)}),this.signer.connection.on(Tt.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 f0({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new Ei(r)}setHttpProvider(e){const r=Ta(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new Ei(new oc(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=An,Et.getRpcConfig=Aa,Et.getRpcUrl=Ta,Et.signerEvents=d0,Et.signerMethods=l0,Object.defineProperty(Et,"__esModule",{value:!0})});
|
|
1
|
+
(function(Dt,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(Dt=typeof globalThis<"u"?globalThis:Dt||self,Z(Dt["@walletconnect/ethereum-provider"]={}))})(this,function(Dt){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ja(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Oi(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 cr=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!Xa(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],Mn(r))return!1;if(Nt(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(!Nt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Nt(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&&(Mn(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(!Nt(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(!Nt(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||Nt(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],Nt(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=[]:Nt(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(Nt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function Xa(t){return typeof t=="number"}function br(t){return typeof t=="object"&&t!==null}function Mn(t){return t===void 0}const Za="PARSE_ERROR",Qa="INVALID_REQUEST",ec="METHOD_NOT_FOUND",tc="INVALID_PARAMS",jn="INTERNAL_ERROR",Ii="SERVER_ERROR",rc=[-32700,-32600,-32601,-32602,-32603],mr={[Za]:{code:-32700,message:"Parse error"},[Qa]:{code:-32600,message:"Invalid Request"},[ec]:{code:-32601,message:"Method not found"},[tc]:{code:-32602,message:"Invalid params"},[jn]:{code:-32603,message:"Internal error"},[Ii]:{code:-32e3,message:"Server error"}},$n=Ii;function ic(t){return rc.includes(t)}function Bn(t){return Object.keys(mr).includes(t)?mr[t]:mr[$n]}function nc(t){const e=Object.values(mr).find(r=>r.code===t);return e||mr[$n]}function zn(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Hn={},zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.isBrowserCryptoAvailable=zt.getSubtleCrypto=zt.getBrowerCrypto=void 0;function Ai(){return Z?.crypto||Z?.msCrypto||{}}zt.getBrowerCrypto=Ai;function Kn(){const t=Ai();return t.subtle||t.webkitSubtle}zt.getSubtleCrypto=Kn;function sc(){return!!Ai()&&!!Kn()}zt.isBrowserCryptoAvailable=sc;var Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.isBrowser=Ht.isNode=Ht.isReactNative=void 0;function qn(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Ht.isReactNative=qn;function Vn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Ht.isNode=Vn;function oc(){return!qn()&&!Vn()}Ht.isBrowser=oc,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(zt,t),r(Ht,t)}(Hn);function ac(){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||ac(),jsonrpc:"2.0",method:t,params:e}}function kr(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Er(t,e,r){return{id:t,jsonrpc:"2.0",error:cc(e,r)}}function cc(t,e){return typeof t>"u"?Bn(jn):(typeof t=="string"&&(t=Object.assign(Object.assign({},Bn(Ii)),{message:t})),typeof e<"u"&&(t.data=e),ic(t.code)&&(t=nc(t.code)),t)}class Gn{}class hc extends Gn{constructor(e){super()}}class uc extends Gn{constructor(){super()}}class Wn extends uc{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 Ti(t){return Xn(t)&&"method"in t}function Yr(t){return Xn(t)&&(Rt(t)||_t(t))}function Rt(t){return"result"in t}function _t(t){return"error"in t}class Zn extends Wn{constructor(e){super(e),this.events=new cr.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=>{_t(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),Yr(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 Ci={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 L(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=L(v);return v.readAsArrayBuffer(l),U}function E(l){var v=new FileReader,U=L(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," "),N=q.join("=").replace(/\+/g," ");v.append(decodeURIComponent(R),decodeURIComponent(N))}}),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(":"),N=R.shift().trim();if(N){var $=R.join(":").trim();v.append(N,$)}}),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 N=new XMLHttpRequest;function $(){N.abort()}N.onload=function(){var B={status:N.status,statusText:N.statusText,headers:K(N.getAllResponseHeaders()||"")};B.url="responseURL"in N?N.responseURL:B.headers.get("X-Request-URL");var ee="response"in N?N.response:N.responseText;U(new G(ee,B))},N.onerror=function(){q(new TypeError("Network request failed"))},N.ontimeout=function(){q(new TypeError("Network request failed"))},N.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},N.open(R.method,R.url,!0),R.credentials==="include"?N.withCredentials=!0:R.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&h.blob&&(N.responseType="blob"),R.headers.forEach(function(B,ee){N.setRequestHeader(ee,B)}),R.signal&&(R.signal.addEventListener("abort",$),N.onreadystatechange=function(){N.readyState===4&&R.signal.removeEventListener("abort",$)}),N.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})(Ci,Ci.exports);var Qn=Ja(Ci.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 Dr(t){return typeof t=="string"?t:JSON.stringify(t)}const es={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},ts=10;class gc{constructor(e){if(this.url=e,this.events=new cr.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=Dr(e),s=await(await Qn(this.url,Object.assign(Object.assign({},es),{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=Dr({id:1,jsonrpc:"2.0",method:"test",params:[]});await Qn(e,Object.assign(Object.assign({},es),{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=Er(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return zn(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>ts&&this.events.setMaxListeners(ts)}}var Ni={},Jr={},re={},rs={};(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}})(rs),Object.defineProperty(re,"__esModule",{value:!0});var is=rs;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 ns(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=ns,re.writeInt16BE=ns;function ss(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=ss,re.writeInt16LE=ss;function Ri(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Ri;function Pi(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=Pi;function Fi(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=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])>>>0}re.readUint32LE=Ui;function Xr(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=Xr,re.writeInt32BE=Xr;function Zr(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=Zr,re.writeInt32LE=Zr;function mc(t,e){e===void 0&&(e=0);var r=Ri(t,e),i=Ri(t,e+4);return r*4294967296+i-(i>>31)*4294967296}re.readInt64BE=mc;function wc(t,e){e===void 0&&(e=0);var r=Pi(t,e),i=Pi(t,e+4);return r*4294967296+i}re.readUint64BE=wc;function Ec(t,e){e===void 0&&(e=0);var r=Fi(t,e),i=Fi(t,e+4);return i*4294967296+r-(r>>31)*4294967296}re.readInt64LE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=Ui(t,e),i=Ui(t,e+4);return i*4294967296+r}re.readUint64LE=Dc;function os(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Xr(t/4294967296>>>0,e,r),Xr(t>>>0,e,r+4),e}re.writeUint64BE=os,re.writeInt64BE=os;function as(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Zr(t>>>0,e,r),Zr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=as,re.writeInt64LE=as;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(!is.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(!is.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 Lc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Lc;function Nc(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=Nc;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(Jr,"__esModule",{value:!0});var ot=re,Mi=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],L=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=L,q=M,R=E,N=0;N<Mc;N+=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+L|0,t,52),ot.writeUint32LE(q+M|0,t,56),ot.writeUint32LE(R+E|0,t,60)}function cs(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 Mi.wipe(h),n===0&&Mi.wipe(s),i}Jr.streamXOR=cs;function $c(t,e,r,i){return i===void 0&&(i=0),Mi.wipe(r),cs(t,e,r,r,i)}Jr.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 hs={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0});function zc(t,e,r){return~(t-1)&e|t-1&r}Kt.select=zc;function Hc(t,e){return(t|0)-(e|0)-1>>>31&1}Kt.lessOrEqual=Hc;function us(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}Kt.compare=us;function Kc(t,e){return t.length===0||e.length===0?!1:us(t,e)!==0}Kt.equal=Kc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Kt,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],L=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 N=h[u+8]|h[u+9]<<8;P+=(R>>>4|N<<12)&8191,L+=N>>>1&8191;var $=h[u+10]|h[u+11]<<8;M+=(N>>>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+=L*(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+=L*(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+=L*(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+=L*(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+=L*(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+=L*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+=L*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,_+=L*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+=L*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+=L*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,L=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]=L,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}(hs),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Jr,r=hs,i=ct,n=re,s=Kt;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,L;if(C){if(C.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");L=C}else L=new Uint8Array(P);return e.streamXOR(this._key,S,g,L,4),this._authenticate(L.subarray(L.length-this.tagLength,L.length),w,L.subarray(0,L.length-this.tagLength),D),i.wipe(S),L},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 L=g.length-this.tagLength,M;if(C){if(C.length!==L)throw new Error("ChaCha20Poly1305: incorrect destination length");M=C}else M=new Uint8Array(L);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(),L=0;L<P.length;L++)f[L]=P[L];S.clean(),i.wipe(P),i.wipe(w)},u}();t.ChaCha20Poly1305=h}(Ni);var fs={},Sr={},ji={};Object.defineProperty(ji,"__esModule",{value:!0});function qc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}ji.isSerializableHash=qc,Object.defineProperty(Sr,"__esModule",{value:!0});var Ot=ji,Vc=Kt,Gc=ct,ls=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}();Sr.HMAC=ls;function Wc(t,e,r){var i=new ls(t,e);i.update(r);var n=i.digest();return i.clean(),n}Sr.hmac=Wc,Sr.equal=Vc.equal,Object.defineProperty(fs,"__esModule",{value:!0});var ds=Sr,ps=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=ds.hmac(this._hash,i,r);this._hmac=new ds.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(),ps.wipe(this._buffer),ps.wipe(this._counter),this._bufpos=0},t}(),Yc=fs.HKDF=kc,xr={},$i={},Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});var gs=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+=gs)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,gs)));return r},t}();Bi.BrowserRandomSource=Jc;function ys(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 zi={},Xc={},Zc=Object.freeze({__proto__:null,default:Xc}),vs=Oi(Zc);Object.defineProperty(zi,"__esModule",{value:!0});var Qc=ct,eh=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ys<"u"){var e=vs;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}();zi.NodeRandomSource=eh,Object.defineProperty($i,"__esModule",{value:!0});var th=Bi,rh=zi,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}();$i.SystemRandomSource=ih,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=$i,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),L=0;L<P.length&&f>0;L++){var M=P[L];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}(xr);var Qr={};(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],L=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=(((L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7))+(L&M^~L&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=L,L=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]+=L,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})(Qr);var Hi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=xr,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,N=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,N+=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,N+=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,N+=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,N+=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,N+=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,N+=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,N+=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,N+=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,N+=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,N+=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],N+=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,N+=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=N+d+65535,d=Math.floor(o/65536),N=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=N+d+65535,d=Math.floor(o/65536),N=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]=N,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 L(y){return P(y,n)}t.scalarMultBase=L;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=L(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})(Hi);function _s(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ki(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=_s(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,L=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<L)&&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");L=b,M++}for(var d=I-L;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 L=0,M=0;w[P]===u;)L++,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(L+(E-o)),j=L;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 bs=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 ms(this,e)}}class fh{constructor(e){this.decoders=e}or(e){return ms(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 ms=(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 ei=({name:t,prefix:e,encode:r,decode:i})=>new lh(t,e,r,i),Or=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=oh(r,e);return ei({prefix:t,name:e,encode:i,decode:s=>bs(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})=>ei({prefix:e,name:t,encode(n){return ph(n,i,r)},decode(n){return dh(n,i,r,t)}}),gh=ei({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=Or({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}),Lh=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nh=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:Lh,base32hexpad:Nh,base32hexpadupper:Rh,base32z:Ph});const Uh=Or({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mh=Or({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jh=Object.freeze({__proto__:null,base36:Uh,base36upper:Mh});const $h=Or({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bh=Or({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 ws=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=ws.reduce((t,e,r)=>(t[r]=e,t),[]),kh=ws.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=ei({prefix:"\u{1F680}",name:"base256emoji",encode:Yh,decode:Jh});var Zh=Object.freeze({__proto__:null,base256emoji:Xh}),Qh=Ds,Es=128,eu=127,tu=~eu,ru=Math.pow(2,31);function Ds(t,e,r){e=e||[],r=r||0;for(var i=r;t>=ru;)e[r++]=t&255|Es,t/=128;for(;t&tu;)e[r++]=t&255|Es,t>>>=7;return e[r]=t|0,Ds.bytes=r-i+1,e}var iu=qi,nu=128,Ss=127;function qi(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw qi.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&Ss)<<n:(c&Ss)*Math.pow(2,n),n+=7}while(c>=nu);return qi.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},xs=gu;const Os=(t,e,r=0)=>(xs.encode(t,e,r),e),Is=t=>xs.encodingLength(t),Vi=(t,e)=>{const r=e.byteLength,i=Is(t),n=i+Is(r),s=new Uint8Array(n+r);return Os(t,s,0),Os(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 As=({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?Vi(this.code,r):r.then(i=>Vi(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Ts=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),_u=As({name:"sha2-256",code:18,encode:Ts("SHA-256")}),bu=As({name:"sha2-512",code:19,encode:Ts("SHA-512")});var mu=Object.freeze({__proto__:null,sha256:_u,sha512:bu});const Cs=0,wu="identity",Ls=bs;var Eu=Object.freeze({__proto__:null,identity:{code:Cs,name:wu,encode:Ls,digest:t=>Vi(Cs,Ls(t))}});new TextEncoder,new TextDecoder;const Ns={...yh,..._h,...mh,...Eh,...xh,...Fh,...jh,...zh,...Gh,...Zh};({...mu,...Eu});function Rs(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Ps=Rs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Gi=Rs("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=_s(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Fs={utf8:Ps,"utf-8":Ps,hex:Ns.base16,latin1:Gi,ascii:Gi,binary:Gi,...Ns};function ft(t,e="utf8"){const r=Fs[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=Fs[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 Us=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)/,Ms=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]],js=[["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 Lu(t){return t?$s(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Iu:typeof navigator<"u"?$s(navigator.userAgent):Pu()}function Nu(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 $s(t){var e=Nu(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<Ms&&(n=Us(Us([],n,!0),Fu(Ms-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=js.length;e<r;e++){var i=js[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={},Bs={},ti={};Object.defineProperty(ti,"__esModule",{value:!0}),ti.delay=void 0;function Uu(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}ti.delay=Uu;var hr={},Wi={},ur={};Object.defineProperty(ur,"__esModule",{value:!0}),ur.ONE_THOUSAND=ur.ONE_HUNDRED=void 0,ur.ONE_HUNDRED=100,ur.ONE_THOUSAND=1e3;var zs={};(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})(zs),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(ur,t),r(zs,t)}(Wi),Object.defineProperty(hr,"__esModule",{value:!0}),hr.fromMiliseconds=hr.toMiliseconds=void 0;const Hs=Wi;function Mu(t){return t*Hs.ONE_THOUSAND}hr.toMiliseconds=Mu;function ju(t){return Math.floor(t/Hs.ONE_THOUSAND)}hr.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(ti,t),r(hr,t)}(Bs);var Ir={};Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.Watch=void 0;class Ks{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}}Ir.Watch=Ks,Ir.default=Ks;var qs={},ri={};Object.defineProperty(ri,"__esModule",{value:!0}),ri.IWatch=void 0;class $u{}ri.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(ri,t)}(qs),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(Bs,t),r(Ir,t),r(qs,t),r(Wi,t)}(Q);var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.getLocalStorage=Oe.getLocalStorageOrThrow=Oe.getCrypto=Oe.getCryptoOrThrow=Gs=Oe.getLocation=Oe.getLocationOrThrow=ki=Oe.getNavigator=Oe.getNavigatorOrThrow=Vs=Oe.getDocument=Oe.getDocumentOrThrow=Oe.getFromWindowOrThrow=Oe.getFromWindow=void 0;function Xt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Oe.getFromWindow=Xt;function fr(t){const e=Xt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Oe.getFromWindowOrThrow=fr;function Bu(){return fr("document")}Oe.getDocumentOrThrow=Bu;function zu(){return Xt("document")}var Vs=Oe.getDocument=zu;function Hu(){return fr("navigator")}Oe.getNavigatorOrThrow=Hu;function Ku(){return Xt("navigator")}var ki=Oe.getNavigator=Ku;function qu(){return fr("location")}Oe.getLocationOrThrow=qu;function Vu(){return Xt("location")}var Gs=Oe.getLocation=Vu;function Gu(){return fr("crypto")}Oe.getCryptoOrThrow=Gu;function Wu(){return Xt("crypto")}Oe.getCrypto=Wu;function ku(){return fr("localStorage")}Oe.getLocalStorageOrThrow=ku;function Yu(){return Xt("localStorage")}Oe.getLocalStorage=Yu;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});var Ws=Yi.getWindowMetadata=void 0;const ks=Oe;function Ju(){let t,e;try{t=ks.getDocumentOrThrow(),e=ks.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 L=w.getAttribute("href");if(L)if(L.toLowerCase().indexOf("https:")===-1&&L.toLowerCase().indexOf("http:")===-1&&L.indexOf("//")!==0){let M=e.protocol+"//"+e.host;if(L.indexOf("/")===0)M+=L;else{const E=e.pathname.split("/");E.pop();const I=E.join("/");M+=I+"/"+L}C.push(M)}else if(L.indexOf("//")===0){const M=e.protocol+L;C.push(M)}else C.push(L)}}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(L=>w.getAttribute(L)).filter(L=>L?D.includes(L):!1);if(P.length&&P){const L=w.getAttribute("content");if(L)return L}}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}}Ws=Yi.getWindowMetadata=Ju;var Ar={},Xu=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ys="%[a-f0-9]{2}",Js=new RegExp(Ys,"gi"),Xs=new RegExp("("+Ys+")+","gi");function Ji(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([],Ji(r),Ji(i))}function Zu(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Js),r=1;r<e.length;r++)t=Ji(e,r).join(""),e=t.match(Js);return t}}function Qu(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Xs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=Zu(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Xs.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 L(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]=L(o[d],I);else m[b]=L(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)}})(Ar);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"}},Zs=":";function sf(t){const{namespace:e,reference:r}=t;return[e,r].join(Zs)}function of(t){const[e,r,i]=t.split(Zs);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 Xi(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 Zi(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 Qs="base10",dt="base16",Qi="base64pad",en="utf8",eo=0,Zt=1,ff=0,to=1,tn=12,rn=32;function lf(){const t=Hi.generateKeyPair();return{privateKey:lt(t.secretKey,dt),publicKey:lt(t.publicKey,dt)}}function nn(){const t=xr.randomBytes(rn);return lt(t,dt)}function df(t,e){const r=Hi.sharedKey(ft(t,dt),ft(e,dt)),i=new Yc(Qr.SHA256,r).expand(rn);return lt(i,dt)}function pf(t){const e=Qr.hash(ft(t,dt));return lt(e,dt)}function ii(t){const e=Qr.hash(ft(t,en));return lt(e,dt)}function gf(t){return ft(`${t}`,Qs)}function Tr(t){return Number(lt(t,Qs))}function yf(t){const e=gf(typeof t.type<"u"?t.type:eo);if(Tr(e)===Zt&&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):xr.randomBytes(tn),n=new Ni.ChaCha20Poly1305(ft(t.symKey,dt)).seal(i,ft(t.message,en));return _f({type:e,sealed:n,iv:i,senderPublicKey:r})}function vf(t){const e=new Ni.ChaCha20Poly1305(ft(t.symKey,dt)),{sealed:r,iv:i}=sn(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return lt(n,en)}function _f(t){if(Tr(t.type)===Zt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return lt(Ki([t.type,t.senderPublicKey,t.iv,t.sealed]),Qi)}return lt(Ki([t.type,t.iv,t.sealed]),Qi)}function sn(t){const e=ft(t,Qi),r=e.slice(ff,to),i=to;if(Tr(r)===Zt){const h=i+rn,u=h+tn,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+tn,s=e.slice(i,n),c=e.slice(n);return{type:r,sealed:c,iv:s}}function bf(t,e){const r=sn(t);return ro({type:Tr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?lt(r.senderPublicKey,dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function ro(t){const e=t?.type||eo;if(e===Zt){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 io(t){return t.type===Zt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var mf=Object.defineProperty,no=Object.getOwnPropertySymbols,wf=Object.prototype.hasOwnProperty,Ef=Object.prototype.propertyIsEnumerable,so=(t,e,r)=>e in t?mf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oo=(t,e)=>{for(var r in e||(e={}))wf.call(e,r)&&so(t,r,e[r]);if(no)for(var r of no(e))Ef.call(e,r)&&so(t,r,e[r]);return t};const Df="ReactNative",Cr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Sf="js";function ao(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function xf(){return!Vs()&&!!ki()&&navigator.product===Df}function Of(){return!ao()&&!!ki()}function If(){return xf()?Cr.reactNative:ao()?Cr.node:Of()?Cr.browser:Cr.unknown}function Af(t,e){let r=Ar.parse(t);return r=oo(oo({},r),e),t=Ar.stringify(r),t}function Tf(){return Ws()||{name:"",description:"",url:"",icons:[""]}}function Cf(){const t=Lu();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 Lf(){var t;const e=If();return e===Cr.browser?[e,((t=Gs())==null?void 0:t.host)||"unknown"].join(":"):e}function Nf(t,e,r){const i=Cf(),n=Lf();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=Nf(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 co(t){return Object.fromEntries(t.entries())}function ho(t){return new Map(Object.entries(t))}function Pt(t,e){return Q.fromMiliseconds((e||Date.now())+Q.toMiliseconds(t))}function qt(t){return Q.fromMiliseconds(Date.now())>=Q.toMiliseconds(t)}function Qt(){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 uo(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 uo("topic",t)}function Ff(t){return uo("id",t)}function fo(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 on(t){return t?.relay||{protocol:Uf}}function an(t){const e=nf[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Mf=Object.defineProperty,lo=Object.getOwnPropertySymbols,jf=Object.prototype.hasOwnProperty,$f=Object.prototype.propertyIsEnumerable,po=(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)&&po(t,r,e[r]);if(lo)for(var r of lo(e))$f.call(e,r)&&po(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=Ar.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}?`+Ar.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 Lr(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function go(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function bt(t){return typeof t>"u"}function it(t,e){return e&&bt(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function yo(t,e){return e&&bt(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:L,events:M}=S,E=It(P);(w=C.extension)!=null&&w.find(I=>pt(I.chains,E)&&pt(I.methods,L)&&pt(I.events,M))||(s=!1)})}),s):!1}function cn(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]&&cn(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 hn(t,e){let r=null;return bt(t?.extension)||(!Lr(t.extension)||!t.extension.length)&&(r=V("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function vo(t){let e=!0;return Lr(t)?t.length&&(e=t.every(r=>it(r,!1))):e=!1,e}function _o(t,e,r){let i=null;return Lr(e)?e.forEach(n=>{i||(!cn(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=_o(i,n?.chains,`${e} requiredNamespace`),c=hn(n,e);s?r=s:c?r=c:n.extension&&n.extension.forEach(h=>{if(r)return;const u=_o(i,h.chains,`${e} extension`);u&&(r=u)})}),r}function bo(t,e){let r=null;return Lr(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=bo(i?.accounts,`${e} namespace`),s=hn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=bo(c.accounts,`${e} extension`);h&&(r=h)})}),r}function mo(t,e){let r=null;return vo(t?.methods)?vo(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 wo(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=mo(i,`${e}, namespace`),s=hn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const h=mo(c,`${e}, extension`);h&&(r=h)})}),r}function nl(t,e){let r=null;if(t&&go(t)){const i=wo(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 un(t,e){let r=null;if(t&&go(t)){const i=wo(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 Eo(t){return it(t.protocol,!0)}function sl(t,e){let r=!1;return e&&!t?r=!0:t&&Lr(t)&&t.length&&t.forEach(i=>{r=Eo(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||!yo(t.code,!1)||!t.message||!it(t.message,!1))}function cl(t){return!(bt(t)||!it(t.method,!1))}function hl(t){return!(bt(t)||bt(t.result)&&bt(t.error)||!yo(t.id,!1)||!it(t.jsonrpc,!1))}function ul(t){return!(bt(t)||!it(t.name,!1))}function Do(t,e){return!(!cn(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 So(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 xo=pl;var ni=At;const Nr=xl().console||{},yl={mapHttpRequest:oi,mapHttpResponse:oi,wrapRequestSerializer:ln,wrapResponseSerializer:ln,wrapErrorSerializer:ln,req:oi,res:oi,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=Rr),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=Rr,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=S,e&&(u._logEvent=fn());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,lr(f,u,"error","log"),lr(f,u,"fatal","error"),lr(f,u,"warn","error"),lr(f,u,"info","log"),lr(f,u,"debug","log"),lr(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 L=P.serializers;if(n&&L){var M=Object.assign({},i,L),E=t.browser.serialize===!0?Object.keys(M):n;delete w.serializers,si([w],E,M,this._stdErrSerialize)}function I(y){this._childLevel=(y._childLevel|0)+1,this.error=dr(y,w,"error"),this.fatal=dr(y,w,"fatal"),this.warn=dr(y,w,"warn"),this.info=dr(y,w,"info"),this.debug=dr(y,w,"debug"),this.trace=dr(y,w,"trace"),M&&(this.serializers=M,this._serialize=E),e&&(this._logEvent=fn([].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:Oo,epochTime:Io,unixTime:Dl,isoTime:Sl});function lr(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Rr:n[r]?n[r]:Nr[r]||Nr[i]||Rr,_l(t,e,r)}function _l(t,e,r){!t.transmit&&e[r]===Rr||(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&&si(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&&si(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?xo(n.shift(),n):void 0}else typeof s=="string"&&(s=xo(n.shift(),n));return s!==void 0&&(c.msg=s),c}function si(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 dr(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;si(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=fn(u)}function fn(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?Oo:Io}function oi(){return{}}function ln(t){return t}function Rr(){}function Oo(){return!1}function Io(){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 ai={},dn=function(t,e){return dn=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])},dn(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");dn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var pn=function(){return pn=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},pn.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 Ll(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 Nl(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 gn=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)&&gn(e,t,r)}function yn(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 Ao(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(Ao(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 Pr(t){return this instanceof Pr?(this.v=t,this):new Pr(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 Pr?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:Pr(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 yn=="function"?yn(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)&&gn(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 pn},__rest:Il,__decorate:Al,__param:Tl,__metadata:Cl,__awaiter:Ll,__generator:Nl,__createBinding:gn,__exportStar:Rl,__values:yn,__read:Ao,__spread:Pl,__spreadArrays:Fl,__spreadArray:Ul,__await:Pr,__asyncGenerator:Ml,__asyncDelegator:jl,__asyncValues:$l,__makeTemplateObject:Bl,__importStar:Hl,__importDefault:Kl,__classPrivateFieldGet:ql,__classPrivateFieldSet:Vl,__classPrivateFieldIn:Gl}),vn=Oi(Wl),ci={exports:{}},To;function kl(){return To||(To=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?ci.exports=localStorage:ci.exports=new e}()),ci.exports}var Fr={},Co;function Lo(){if(Co)return Fr;Co=1,Object.defineProperty(Fr,"__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}}Fr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(i,n)=>typeof n>"u"?null:n)}return Fr.safeJsonStringify=e,Fr}var _n={},Ur={},No;function Yl(){if(No)return Ur;No=1,Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.IKeyValueStorage=void 0;class t{}return Ur.IKeyValueStorage=t,Ur}var Mr={},Ro;function Jl(){if(Ro)return Mr;Ro=1,Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.parseEntry=void 0;const t=Lo();function e(r){var i;return[r[0],t.safeJsonParse((i=r[1])!==null&&i!==void 0?i:"")]}return Mr.parseEntry=e,Mr}var Po;function Xl(){return Po||(Po=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=vn;e.__exportStar(Yl(),t),e.__exportStar(Jl(),t)}(_n)),_n}Object.defineProperty(ai,"__esModule",{value:!0}),ai.KeyValueStorage=void 0;const pr=vn,Zl=pr.__importDefault(kl()),Fo=Lo(),Ql=Xl();class Uo{constructor(){this.localStorage=Zl.default}getKeys(){return pr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return pr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Ql.parseEntry)})}getItem(e){return pr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Fo.safeJsonParse(r)})}setItem(e,r){return pr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Fo.safeJsonStringify(r))})}removeItem(e){return pr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}ai.KeyValueStorage=Uo;var ed=ai.default=Uo,jr={},hi={},bn={},ui={};class er{}var td=Object.freeze({__proto__:null,IEvents:er}),rd=Oi(td);Object.defineProperty(ui,"__esModule",{value:!0}),ui.IHeartBeat=void 0;const id=rd;class nd extends id.IEvents{constructor(e){super()}}ui.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(ui,t)}(bn);var mn={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.HEARTBEAT_EVENTS=gr.HEARTBEAT_INTERVAL=void 0;const sd=Q;gr.HEARTBEAT_INTERVAL=sd.FIVE_SECONDS,gr.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(gr,t)}(mn);var wn=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(hi,"__esModule",{value:!0}),hi.HeartBeat=void 0;const od=cr,ad=Q,cd=bn,En=mn;class Dn extends cd.IHeartBeat{constructor(e){super(e),this.events=new od.EventEmitter,this.interval=En.HEARTBEAT_INTERVAL,this.interval=e?.interval||En.HEARTBEAT_INTERVAL}static init(e){return wn(this,void 0,void 0,function*(){const r=new Dn(e);return yield r.init(),r})}init(){return wn(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 wn(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),ad.toMiliseconds(this.interval))})}pulse(){this.events.emit(En.HEARTBEAT_EVENTS.pulse)}}hi.HeartBeat=Dn,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),r(bn,t),r(mn,t)}(jr);var xe={},tr={},Mo;function jo(){return Mo||(Mo=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.PINO_CUSTOM_CONTEXT_KEY=tr.PINO_LOGGER_DEFAULTS=void 0,tr.PINO_LOGGER_DEFAULTS={level:"info"},tr.PINO_CUSTOM_CONTEXT_KEY="custom_context"),tr}var ht={},$o;function hd(){if($o)return ht;$o=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.generateChildLogger=ht.formatChildLoggerContext=ht.getLoggerContext=ht.setBrowserLoggerContext=ht.getBrowserLoggerContext=ht.getDefaultLoggerOptions=void 0;const t=jo();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=vn;e.__exportStar(jo(),t),e.__exportStar(hd(),t),e.__exportStar(ni,t)})(xe);class ud extends er{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class fd extends er{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 er{constructor(e,r){super(),this.relayer=e,this.logger=r}}class pd extends er{constructor(e){super()}}class gd{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class yd extends er{constructor(e,r){super(),this.relayer=e,this.logger=r}}class vd extends er{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||$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],Bo(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($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},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]?$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&&(Bo(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($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},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 $r(t){return typeof t=="object"&&t!==null}function Bo(t){return t===void 0}class md{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Iy extends _d.EventEmitter{constructor(){super()}}class wd{constructor(e){this.client=e}}var Sn={},zo={},fi={},li={};Object.defineProperty(li,"__esModule",{value:!0}),li.BrowserRandomSource=void 0;const Ho=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+=Ho)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,Ho)));return r}}li.BrowserRandomSource=Ed;var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.NodeRandomSource=void 0;const Dd=ct;class Sd{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ys<"u"){const e=vs;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}}di.NodeRandomSource=Sd,Object.defineProperty(fi,"__esModule",{value:!0}),fi.SystemRandomSource=void 0;const xd=li,Od=di;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)}}fi.SystemRandomSource=Id,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=fi,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 L=0;L<P.length&&f>0;L++){const M=P[L];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}(zo);var Ko={};(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],L=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,N,$,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=L,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,N=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,N+=v>>>16,$+=l&65535,B+=l>>>16,l=E&I^~E&y,v=K&G^~K&J,R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,l=n[ee*2],v=n[ee*2+1],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,l=h[ee%16],v=u[ee%16],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,U=$&65535|B<<16,q=R&65535|N<<16,l=U,v=q,R=v&65535,N=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,N+=v>>>16,$+=l&65535,B+=l>>>16,l=w&P^w&L^P&L,v=b&o^b&d^o&d,R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,_=$&65535|B<<16,Ce=R&65535|N<<16,l=T,v=_e,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=U,v=q,R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,T=$&65535|B<<16,_e=R&65535|N<<16,P=te,L=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,N=v>>>16,$=l&65535,B=l>>>16,l=h[(z+9)%16],v=u[(z+9)%16],R+=v&65535,N+=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,N+=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,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,h[z]=$&65535|B<<16,u[z]=R&65535|N<<16}l=w,v=b,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[0],v=g[0],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[0]=w=$&65535|B<<16,g[0]=b=R&65535|N<<16,l=P,v=o,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[1],v=g[1],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[1]=P=$&65535|B<<16,g[1]=o=R&65535|N<<16,l=L,v=d,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[2],v=g[2],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[2]=L=$&65535|B<<16,g[2]=d=R&65535|N<<16,l=M,v=j,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[3],v=g[3],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[3]=M=$&65535|B<<16,g[3]=j=R&65535|N<<16,l=E,v=K,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[4],v=g[4],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[4]=E=$&65535|B<<16,g[4]=K=R&65535|N<<16,l=I,v=G,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[5],v=g[5],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[5]=I=$&65535|B<<16,g[5]=G=R&65535|N<<16,l=y,v=J,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[6],v=g[6],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[6]=y=$&65535|B<<16,g[6]=J=R&65535|N<<16,l=m,v=X,R=v&65535,N=v>>>16,$=l&65535,B=l>>>16,l=f[7],v=g[7],R+=v&65535,N+=v>>>16,$+=l&65535,B+=l>>>16,N+=R>>>16,$+=N>>>16,B+=$>>>16,f[7]=m=$&65535|B<<16,g[7]=X=R&65535|N<<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})(Ko),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=zo,r=Ko,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 L(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 L(x,T),L(a,A),M(x,a)}function I(T){const A=new Uint8Array(32);return L(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,Lt=0,Wt=0,yt=0,nr=0,Vr=0,bi=0,Ue=x[0],Le=x[1],Me=x[2],je=x[3],$e=x[4],Ne=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*Le,le+=a*Me,_e+=a*je,pe+=a*$e,we+=a*Ne,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*Le,_e+=a*Me,pe+=a*je,we+=a*$e,Fe+=a*Ne,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*Le,pe+=a*Me,we+=a*je,Fe+=a*$e,Ce+=a*Ne,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*Le,we+=a*Me,Fe+=a*je,Ce+=a*$e,ve+=a*Ne,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*Le,Fe+=a*Me,Ce+=a*je,ve+=a*$e,ge+=a*Ne,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*Le,Ce+=a*Me,ve+=a*je,ge+=a*$e,de+=a*Ne,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*Le,ve+=a*Me,ge+=a*je,de+=a*$e,ue+=a*Ne,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*Le,ge+=a*Me,de+=a*je,ue+=a*$e,he+=a*Ne,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*Le,de+=a*Me,ue+=a*je,he+=a*$e,ae+=a*Ne,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*Le,ue+=a*Me,he+=a*je,ae+=a*$e,oe+=a*Ne,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*Le,he+=a*Me,ae+=a*je,oe+=a*$e,ie+=a*Ne,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,Lt+=a*et,a=A[11],ue+=a*Ue,he+=a*Le,ae+=a*Me,oe+=a*je,ie+=a*$e,fe+=a*Ne,ye+=a*ke,ne+=a*Ye,be+=a*Je,me+=a*Xe,De+=a*Ze,Se+=a*He,Ee+=a*Be,St+=a*Ae,Lt+=a*Qe,Wt+=a*et,a=A[12],he+=a*Ue,ae+=a*Le,oe+=a*Me,ie+=a*je,fe+=a*$e,ye+=a*Ne,ne+=a*ke,be+=a*Ye,me+=a*Je,De+=a*Xe,Se+=a*Ze,Ee+=a*He,St+=a*Be,Lt+=a*Ae,Wt+=a*Qe,yt+=a*et,a=A[13],ae+=a*Ue,oe+=a*Le,ie+=a*Me,fe+=a*je,ye+=a*$e,ne+=a*Ne,be+=a*ke,me+=a*Ye,De+=a*Je,Se+=a*Xe,Ee+=a*Ze,St+=a*He,Lt+=a*Be,Wt+=a*Ae,yt+=a*Qe,nr+=a*et,a=A[14],oe+=a*Ue,ie+=a*Le,fe+=a*Me,ye+=a*je,ne+=a*$e,be+=a*Ne,me+=a*ke,De+=a*Ye,Se+=a*Je,Ee+=a*Xe,St+=a*Ze,Lt+=a*He,Wt+=a*Be,yt+=a*Ae,nr+=a*Qe,Vr+=a*et,a=A[15],ie+=a*Ue,fe+=a*Le,ye+=a*Me,ne+=a*je,be+=a*$e,me+=a*Ne,De+=a*ke,Se+=a*Ye,Ee+=a*Je,St+=a*Xe,Lt+=a*Ze,Wt+=a*He,yt+=a*Be,nr+=a*Ae,Vr+=a*Qe,bi+=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*Lt,de+=38*Wt,ue+=38*yt,he+=38*nr,ae+=38*Vr,oe+=38*bi,_=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],_),L(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 N=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]*N[_-(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)*N[_],x=A[_]>>8,A[_]&=255;for(_=0;_<32;_++)A[_]-=x*N[_];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 L(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}(Sn);const Ad="EdDSA",Td="JWT",qo=".",Vo="base64url",Cd="utf8",Ld="utf8",Nd=":",Rd="did",Pd="key",Go="base58btc",Fd="z",Ud="K36",Md=32;function pi(t){return lt(ft(Dr(t),Cd),Vo)}function Wo(t){const e=ft(Ud,Go),r=Fd+lt(Ki([e,t]),Go);return[Rd,Pd,r].join(Nd)}function jd(t){return lt(t,Vo)}function $d(t){return ft([pi(t.header),pi(t.payload)].join(qo),Ld)}function Bd(t){return[pi(t.header),pi(t.payload),jd(t.signature)].join(qo)}function ko(t=xr.randomBytes(Md)){return Sn.generateKeyPairFromSeed(t)}async function zd(t,e,r,i,n=Q.fromMiliseconds(Date.now())){const s={alg:Ad,typ:Td},c=Wo(i.publicKey),h=n+r,u={iss:c,sub:t,aud:e,iat:n,exp:h},f=$d({header:s,payload:u}),g=Sn.sign(i.secretKey,f);return Bd({header:s,payload:u,signature:g})}class Hd extends Wn{constructor(e){super(e),this.events=new cr.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=>{_t(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),Yr(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)}}const Yo=10,Kd=(()=>typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:require("ws"))();class qd{constructor(e){if(this.url=e,this.events=new cr.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(Dr(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=Hn.isReactNative()?void 0:{rejectUnauthorized:!pc(e)},s=new Kd(e,[],n);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const h=this.parseError(c.error);this.events.emit("register_error",h),this.onClose(),i(h)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const i=this.parseError(r.error);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"?Li(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Er(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return zn(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>Yo&&this.events.setMaxListeners(Yo)}}var xn={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]",L="[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]",N="[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[N]=Y[$]=Y[B]=!0,Y[h]=Y[u]=Y[G]=Y[g]=Y[J]=Y[D]=Y[C]=Y[S]=Y[P]=Y[L]=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,Lt=ie.propertyIsEnumerable,Wt=ae.splice,yt=Ee?Ee.toStringTag:void 0,nr=Object.getOwnPropertySymbols,Vr=Se?Se.isBuffer:void 0,bi=ue(Object.keys,Object),Ue=_r(A,"DataView"),Le=_r(A,"Map"),Me=_r(A,"Promise"),je=_r(A,"Set"),$e=_r(A,"WeakMap"),Ne=_r(Object,"create"),ke=or(Ue),Ye=or(Le),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__=Ne?Ne(null):{},this.size=0}function et(p){var O=this.has(p)&&delete this.__data__[p];return this.size-=O?1:0,O}function U0(p){var O=this.__data__;if(Ne){var F=O[p];return F===i?void 0:F}return ne.call(O,p)?O[p]:void 0}function M0(p){var O=this.__data__;return Ne?O[p]!==void 0:ne.call(O,p)}function j0(p,O){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Ne&&O===void 0?i:O,this}Ae.prototype.clear=Qe,Ae.prototype.delete=et,Ae.prototype.get=U0,Ae.prototype.has=M0,Ae.prototype.set=j0;function $t(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 $0(){this.__data__=[],this.size=0}function B0(p){var O=this.__data__,F=wi(O,p);if(F<0)return!1;var k=O.length-1;return F==k?O.pop():Wt.call(O,F,1),--this.size,!0}function z0(p){var O=this.__data__,F=wi(O,p);return F<0?void 0:O[F][1]}function H0(p){return wi(this.__data__,p)>-1}function K0(p,O){var F=this.__data__,k=wi(F,p);return k<0?(++this.size,F.push([p,O])):F[k][1]=O,this}$t.prototype.clear=$0,$t.prototype.delete=B0,$t.prototype.get=z0,$t.prototype.has=H0,$t.prototype.set=K0;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 q0(){this.size=0,this.__data__={hash:new Ae,map:new(Le||$t),string:new Ae}}function V0(p){var O=Ei(this,p).delete(p);return this.size-=O?1:0,O}function G0(p){return Ei(this,p).get(p)}function W0(p){return Ei(this,p).has(p)}function k0(p,O){var F=Ei(this,p),k=F.size;return F.set(p,O),this.size+=F.size==k?0:1,this}sr.prototype.clear=q0,sr.prototype.delete=V0,sr.prototype.get=G0,sr.prototype.has=W0,sr.prototype.set=k0;function mi(p){var O=-1,F=p==null?0:p.length;for(this.__data__=new sr;++O<F;)this.add(p[O])}function Y0(p){return this.__data__.set(p,i),this}function J0(p){return this.__data__.has(p)}mi.prototype.add=mi.prototype.push=Y0,mi.prototype.has=J0;function kt(p){var O=this.__data__=new $t(p);this.size=O.size}function X0(){this.__data__=new $t,this.size=0}function Z0(p){var O=this.__data__,F=O.delete(p);return this.size=O.size,F}function Q0(p){return this.__data__.get(p)}function ey(p){return this.__data__.has(p)}function ty(p,O){var F=this.__data__;if(F instanceof $t){var k=F.__data__;if(!Le||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}kt.prototype.clear=X0,kt.prototype.delete=Z0,kt.prototype.get=Q0,kt.prototype.has=ey,kt.prototype.set=ty;function ry(p,O){var F=Di(p),k=!F&&vy(p),Ie=!F&&!k&&Un(p),se=!F&&!k&&!Ie&&ka(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")||ly(Te,st)))&&tt.push(Te);return tt}function wi(p,O){for(var F=p.length;F--;)if(qa(p[F][0],O))return F;return-1}function iy(p,O,F){var k=O(p);return Di(p)?k:pe(k,F(p))}function Gr(p){return p==null?p===void 0?j:M:yt&&yt in Object(p)?uy(p):yy(p)}function Ba(p){return Wr(p)&&Gr(p)==h}function za(p,O,F,k,Ie){return p===O?!0:p==null||O==null||!Wr(p)&&!Wr(O)?p!==p&&O!==O:ny(p,O,F,k,za,Ie)}function ny(p,O,F,k,Ie,se){var Re=Di(p),tt=Di(O),st=Re?u:Yt(p),Te=tt?u:Yt(O);st=st==h?E:st,Te=Te==h?E:Te;var vt=st==E,xt=Te==E,at=st==Te;if(at&&Un(p)){if(!Un(O))return!1;Re=!0,vt=!1}if(at&&!vt)return se||(se=new kt),Re||ka(p)?Ha(p,O,F,k,Ie,se):cy(p,O,st,F,k,Ie,se);if(!(F&n)){var wt=vt&&ne.call(p,"__wrapped__"),Et=xt&&ne.call(O,"__wrapped__");if(wt||Et){var Jt=wt?p.value():p,Bt=Et?O.value():O;return se||(se=new kt),Ie(Jt,Bt,F,k,se)}}return at?(se||(se=new kt),hy(p,O,F,k,Ie,se)):!1}function sy(p){if(!Wa(p)||py(p))return!1;var O=Va(p)?De:z;return O.test(or(p))}function oy(p){return Wr(p)&&Ga(p.length)&&!!Y[Gr(p)]}function ay(p){if(!gy(p))return bi(p);var O=[];for(var F in Object(p))ne.call(p,F)&&F!="constructor"&&O.push(F);return O}function Ha(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 mi:void 0;for(se.set(p,O),se.set(O,p);++vt<tt;){var wt=p[vt],Et=O[vt];if(k)var Jt=Re?k(Et,wt,vt,O,p,se):k(wt,Et,vt,p,O,se);if(Jt!==void 0){if(Jt)continue;xt=!1;break}if(at){if(!we(O,function(Bt,ar){if(!ve(at,ar)&&(wt===Bt||Ie(wt,Bt,F,k,se)))return at.push(ar)})){xt=!1;break}}else if(!(wt===Et||Ie(wt,Et,F,k,se))){xt=!1;break}}return se.delete(p),se.delete(O),xt}function cy(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 L:return qa(+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=Ha(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 hy(p,O,F,k,Ie,se){var Re=F&n,tt=Ka(p),st=tt.length,Te=Ka(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 wt=se.get(p);if(wt&&se.get(O))return wt==O;var Et=!0;se.set(p,O),se.set(O,p);for(var Jt=Re;++xt<st;){at=tt[xt];var Bt=p[at],ar=O[at];if(k)var Ya=Re?k(ar,Bt,at,O,p,se):k(Bt,ar,at,p,O,se);if(!(Ya===void 0?Bt===ar||Ie(Bt,ar,F,k,se):Ya)){Et=!1;break}Jt||(Jt=at=="constructor")}if(Et&&!Jt){var Si=p.constructor,xi=O.constructor;Si!=xi&&"constructor"in p&&"constructor"in O&&!(typeof Si=="function"&&Si instanceof Si&&typeof xi=="function"&&xi instanceof xi)&&(Et=!1)}return se.delete(p),se.delete(O),Et}function Ka(p){return iy(p,my,fy)}function Ei(p,O){var F=p.__data__;return dy(O)?F[typeof O=="string"?"string":"hash"]:F.map}function _r(p,O){var F=ge(p,O);return sy(F)?F:void 0}function uy(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 fy=nr?function(p){return p==null?[]:(p=Object(p),_e(nr(p),function(O){return Lt.call(p,O)}))}:wy,Yt=Gr;(Ue&&Yt(new Ue(new ArrayBuffer(1)))!=J||Le&&Yt(new Le)!=P||Me&&Yt(Me.resolve())!=I||je&&Yt(new je)!=b||$e&&Yt(new $e)!=K)&&(Yt=function(p){var O=Gr(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 ly(p,O){return O=O??c,!!O&&(typeof p=="number"||te.test(p))&&p>-1&&p%1==0&&p<O}function dy(p){var O=typeof p;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?p!=="__proto__":p===null}function py(p){return!!be&&be in p}function gy(p){var O=p&&p.constructor,F=typeof O=="function"&&O.prototype||ie;return p===F}function yy(p){return me.call(p)}function or(p){if(p!=null){try{return ye.call(p)}catch{}try{return p+""}catch{}}return""}function qa(p,O){return p===O||p!==p&&O!==O}var vy=Ba(function(){return arguments}())?Ba:function(p){return Wr(p)&&ne.call(p,"callee")&&!Lt.call(p,"callee")},Di=Array.isArray;function _y(p){return p!=null&&Ga(p.length)&&!Va(p)}var Un=Vr||Ey;function by(p,O){return za(p,O)}function Va(p){if(!Wa(p))return!1;var O=Gr(p);return O==S||O==w||O==f||O==y}function Ga(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=c}function Wa(p){var O=typeof p;return p!=null&&(O=="object"||O=="function")}function Wr(p){return p!=null&&typeof p=="object"}var ka=le?Ce(le):oy;function my(p){return _y(p)?ry(p):ay(p)}function wy(){return[]}function Ey(){return!1}t.exports=by})(xn,xn.exports);var Vd=xn.exports,Gd=Object.defineProperty,Jo=Object.getOwnPropertySymbols,Wd=Object.prototype.hasOwnProperty,kd=Object.prototype.propertyIsEnumerable,Xo=(t,e,r)=>e in t?Gd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Wd.call(e,r)&&Xo(t,r,e[r]);if(Jo)for(var r of Jo(e))kd.call(e,r)&&Xo(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var rr=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!Yd(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||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],Zo(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(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},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]?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&&(Zo(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(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},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 Yd(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function Zo(t){return t===void 0}function Jd(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,L=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<L)&&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");L=b,M++}for(var d=I-L;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 L=0,M=0;w[P]===u;)L++,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(L+(E-o)),j=L;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 Xd=Jd,Zd=Xd;const Qo=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")},Qd=t=>new TextEncoder().encode(t),ep=t=>new TextDecoder().decode(t);class tp{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 rp{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 ea(this,e)}}class ip{constructor(e){this.decoders=e}or(e){return ea(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 ea=(t,e)=>new ip(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class np{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new tp(e,r,i),this.decoder=new rp(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const gi=({name:t,prefix:e,encode:r,decode:i})=>new np(t,e,r,i),zr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Zd(r,e);return gi({prefix:t,name:e,encode:i,decode:s=>Qo(n(s))})},sp=(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},op=(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})=>gi({prefix:e,name:t,encode(n){return op(n,i,r)},decode(n){return sp(n,i,r,t)}}),ap=gi({prefix:"\0",name:"identity",encode:t=>ep(t),decode:t=>Qd(t)});var cp=Object.freeze({__proto__:null,identity:ap});const hp=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var up=Object.freeze({__proto__:null,base2:hp});const fp=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var lp=Object.freeze({__proto__:null,base8:fp});const dp=zr({prefix:"9",name:"base10",alphabet:"0123456789"});var pp=Object.freeze({__proto__:null,base10:dp});const gp=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),yp=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vp=Object.freeze({__proto__:null,base16:gp,base16upper:yp});const _p=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bp=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mp=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wp=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ep=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Dp=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sp=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xp=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Op=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ip=Object.freeze({__proto__:null,base32:_p,base32upper:bp,base32pad:mp,base32padupper:wp,base32hex:Ep,base32hexupper:Dp,base32hexpad:Sp,base32hexpadupper:xp,base32z:Op});const Ap=zr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tp=zr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Cp=Object.freeze({__proto__:null,base36:Ap,base36upper:Tp});const Lp=zr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Np=zr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rp=Object.freeze({__proto__:null,base58btc:Lp,base58flickr:Np});const Pp=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fp=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Up=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mp=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jp=Object.freeze({__proto__:null,base64:Pp,base64pad:Fp,base64url:Up,base64urlpad:Mp});const ta=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=ta.reduce((t,e,r)=>(t[r]=e,t),[]),Bp=ta.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function zp(t){return t.reduce((e,r)=>(e+=$p[r],e),"")}function Hp(t){const e=[];for(const r of t){const i=Bp[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Kp=gi({prefix:"\u{1F680}",name:"base256emoji",encode:zp,decode:Hp});var qp=Object.freeze({__proto__:null,base256emoji:Kp}),Vp=ia,ra=128,Gp=127,Wp=~Gp,kp=Math.pow(2,31);function ia(t,e,r){e=e||[],r=r||0;for(var i=r;t>=kp;)e[r++]=t&255|ra,t/=128;for(;t&Wp;)e[r++]=t&255|ra,t>>>=7;return e[r]=t|0,ia.bytes=r-i+1,e}var Yp=On,Jp=128,na=127;function On(t,i){var r=0,i=i||0,n=0,s=i,c,h=t.length;do{if(s>=h)throw On.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&na)<<n:(c&na)*Math.pow(2,n),n+=7}while(c>=Jp);return On.bytes=s-i,r}var Xp=Math.pow(2,7),Zp=Math.pow(2,14),Qp=Math.pow(2,21),eg=Math.pow(2,28),tg=Math.pow(2,35),rg=Math.pow(2,42),ig=Math.pow(2,49),ng=Math.pow(2,56),sg=Math.pow(2,63),og=function(t){return t<Xp?1:t<Zp?2:t<Qp?3:t<eg?4:t<tg?5:t<rg?6:t<ig?7:t<ng?8:t<sg?9:10},ag={encode:Vp,decode:Yp,encodingLength:og},sa=ag;const oa=(t,e,r=0)=>(sa.encode(t,e,r),e),aa=t=>sa.encodingLength(t),In=(t,e)=>{const r=e.byteLength,i=aa(t),n=i+aa(r),s=new Uint8Array(n+r);return oa(t,s,0),oa(r,s,i),s.set(e,n),new cg(t,r,e,s)};class cg{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const ca=({name:t,code:e,encode:r})=>new hg(t,e,r);class hg{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?In(this.code,r):r.then(i=>In(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ha=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ug=ca({name:"sha2-256",code:18,encode:ha("SHA-256")}),fg=ca({name:"sha2-512",code:19,encode:ha("SHA-512")});var lg=Object.freeze({__proto__:null,sha256:ug,sha512:fg});const ua=0,dg="identity",fa=Qo;var pg=Object.freeze({__proto__:null,identity:{code:ua,name:dg,encode:fa,digest:t=>In(ua,fa(t))}});new TextEncoder,new TextDecoder;const la=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},cp),up),lp),pp),vp),Ip),Cp),Rp),jp),qp);ut(ut({},lg),pg);function gg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function da(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const pa=da("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),An=da("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=gg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),yg=ut({utf8:pa,"utf-8":pa,hex:la.base16,latin1:An,ascii:An,binary:An},la);function vg(t,e="utf8"){const r=yg[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 ga="wc",_g=2,Tn="core",Vt=`${ga}@${2}:${Tn}:`,bg={name:Tn,logger:"error"},mg={database:":memory:"},wg="crypto",ya="client_ed25519_seed",Eg=Q.ONE_DAY,Dg="keychain",Sg="0.3",xg="messages",Og="0.3",Ig=Q.SIX_HOURS,Ag="publisher",va="irn",Tg="error",Cg="wss://relay.walletconnect.com",Lg="relayer",yr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Ng="_subscription",vr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Rg=Q.ONE_SECOND,Pg="2.1.3",Fg="0.3",ir={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},Ug="subscription",Mg="0.3",jg=Q.FIVE_SECONDS*1e3,$g="pairing",Bg="0.3",Hr={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"},zg="history",Hg="0.3",Kg="expirer",mt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},qg="0.3";class Vg{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=Dg,this.version=Sg,this.initialized=!1,this.storagePrefix=Vt,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,co(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ho(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 Gg{constructor(e,r,i){this.core=e,this.logger=r,this.name=wg,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=ko(n);return Wo(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=ko(s),h=nn();return await zd(h,n,Eg,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=ro(c),u=Dr(s);if(io(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(io(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 Vg(this.core,this.logger)}get context(){return xe.getLoggerContext(this.logger)}getPayloadType(e){const r=sn(e);return Tr(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(ya)}catch{e=nn(),await this.keychain.set(ya,e)}return vg(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 Wg extends ld{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=xg,this.version=Og,this.initialized=!1,this.storagePrefix=Vt,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=ii(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=ii(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,co(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ho(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 kg extends dd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new rr.EventEmitter,this.name=Ag,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||Ig,h=on(s),u=s?.prompt||!1,f=s?.tag||0,g={topic:i,message:n,opts:{ttl:c,relay:h,prompt:u,tag:f}},D=ii(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:an(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:c}};return bt((h=D.params)==null?void 0:h.prompt)&&((u=D.params)==null||delete u.prompt),bt((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=ii(i);await this.rpcPublish(r,i,n,s,c,h),this.onPublish(u,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(jr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Yg{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 Jg=Object.defineProperty,Xg=Object.defineProperties,Zg=Object.getOwnPropertyDescriptors,_a=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,e0=Object.prototype.propertyIsEnumerable,ba=(t,e,r)=>e in t?Jg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yi=(t,e)=>{for(var r in e||(e={}))Qg.call(e,r)&&ba(t,r,e[r]);if(_a)for(var r of _a(e))e0.call(e,r)&&ba(t,r,e[r]);return t},Cn=(t,e)=>Xg(t,Zg(e));class t0 extends yd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Yg,this.events=new rr.EventEmitter,this.name=Ug,this.version=Mg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Vt,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=on(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)>=jg&&(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=on(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:an(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:an(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,Cn(yi({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Cn(yi({},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,yi({},r)),this.topicMap.set(r.topic,e),this.events.emit(ir.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(ir.deleted,Cn(yi({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ir.sync)}async reset(){!this.cached.length||await Promise.all(this.cached.map(async e=>await this.resubscribe(e)))}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(jr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(vr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(vr.disconnect,()=>{this.onDisconnect()}),this.events.on(ir.created,async e=>{const r=ir.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(ir.deleted,async e=>{const r=ir.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 r0=Object.defineProperty,ma=Object.getOwnPropertySymbols,i0=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable,wa=(t,e,r)=>e in t?r0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s0=(t,e)=>{for(var r in e||(e={}))i0.call(e,r)&&wa(t,r,e[r]);if(ma)for(var r of ma(e))n0.call(e,r)&&wa(t,r,e[r]);return t};class o0 extends pd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new rr.EventEmitter,this.name=Lg,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):ni(xe.getDefaultLoggerOptions({level:e.logger||Tg})),this.messages=new Wg(this.logger,e.core),this.subscriber=new t0(this,this.logger),this.publisher=new kg(this,this.logger),this.relayUrl=e?.relayUrl||Cg,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()}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);return new Hd(new qd(Rf({sdkVersion:Pg,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}),Ti(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(s0({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(yr.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(vr.payload,e=>this.onProviderPayload(e)),this.provider.on(vr.connect,()=>{this.events.emit(yr.connect)}),this.provider.on(vr.disconnect,()=>{this.events.emit(yr.disconnect),this.attemptToReconnect()}),this.provider.on(vr.error,e=>this.events.emit(yr.error,e))}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(()=>{this.provider.connect()},Q.toMiliseconds(Rg))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var a0=Object.defineProperty,Ea=Object.getOwnPropertySymbols,c0=Object.prototype.hasOwnProperty,h0=Object.prototype.propertyIsEnumerable,Da=(t,e,r)=>e in t?a0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sa=(t,e)=>{for(var r in e||(e={}))c0.call(e,r)&&Da(t,r,e[r]);if(Ea)for(var r of Ea(e))h0.call(e,r)&&Da(t,r,e[r]);return t};class Ln extends gd{constructor(e,r,i,n=Vt,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=Fg,this.cached=[],this.initialized=!1,this.storagePrefix=Vt,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&&!bt(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=>Vd(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=Sa(Sa({},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 u0{constructor(e,r){this.core=e,this.logger=r,this.name=$g,this.version=Bg,this.events=new rr,this.initialized=!1,this.storagePrefix=Vt,this.ignoredPayloadTypes=[Zt],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=nn(),n=await this.core.crypto.setSymKey(i),s=Pt(Q.FIVE_MINUTES),c={protocol:va},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}=Qt();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=Hr[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=Hr[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=Er(i,s),h=await this.core.crypto.encode(n,c),u=await this.core.history.get(n,i),f=Hr[u.request.method]?Hr[u.request.method].res:Hr.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=>qt(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),{}):_t(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(qt(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(yr.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);Ti(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Yr(n)&&(await this.core.history.resolve(n),this.onRelayEventResponse({topic:r,payload:n}))})}registerExpirerEvents(){this.core.expirer.on(mt.expired,async e=>{const{topic:r}=fo(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class f0 extends fd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new rr.EventEmitter,this.name=zg,this.version=Hg,this.cached=[],this.initialized=!1,this.storagePrefix=Vt,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=_t(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 l0 extends vd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new rr.EventEmitter,this.name=Kg,this.version=qg,this.cached=[],this.initialized=!1,this.storagePrefix=Vt,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(mt.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(mt.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(mt.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(mt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(jr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(mt.created,e=>{const r=mt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(mt.expired,e=>{const r=mt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(mt.deleted,e=>{const r=mt.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 d0=Object.defineProperty,xa=Object.getOwnPropertySymbols,p0=Object.prototype.hasOwnProperty,g0=Object.prototype.propertyIsEnumerable,Oa=(t,e,r)=>e in t?d0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ia=(t,e)=>{for(var r in e||(e={}))p0.call(e,r)&&Oa(t,r,e[r]);if(xa)for(var r of xa(e))g0.call(e,r)&&Oa(t,r,e[r]);return t};class Nn extends ud{constructor(e){super(e),this.protocol=ga,this.version=_g,this.name=Tn,this.events=new rr.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:ni(xe.getDefaultLoggerOptions({level:e?.logger||bg.logger}));this.logger=xe.generateChildLogger(r,this.name),this.heartbeat=new jr.HeartBeat,this.crypto=new Gg(this,this.logger,e?.keychain),this.history=new f0(this,this.logger),this.expirer=new l0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new ed(Ia(Ia({},mg),e?.storageOptions)),this.relayer=new o0({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId}),this.pairing=new u0(this,this.logger)}static async init(e){const r=new Nn(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 y0=Nn;function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Aa=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!v0(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||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],Ta(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: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},Ge.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]?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&&(Ta(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(!Mt(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(!Mt(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||Mt(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},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],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},Ge.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},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Mt(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Mt(t){return typeof t=="function"}function v0(t){return typeof t=="number"}function Kr(t){return typeof t=="object"&&t!==null}function Ta(t){return t===void 0}const Ca="wc",La=2,Na="client",Ra=`${Ca}@${La}:${Na}:`,Rn={name:Na,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},_0="proposal",b0="session",vi=Q.SEVEN_DAYS,m0="engine",_i={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 w0=Object.defineProperty,E0=Object.defineProperties,D0=Object.getOwnPropertyDescriptors,Pa=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,x0=Object.prototype.propertyIsEnumerable,Fa=(t,e,r)=>e in t?w0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gt=(t,e)=>{for(var r in e||(e={}))S0.call(e,r)&&Fa(t,r,e[r]);if(Pa)for(var r of Pa(e))x0.call(e,r)&&Fa(t,r,e[r]);return t},Ua=(t,e)=>E0(t,D0(e));class O0 extends wd{constructor(e){super(e),this.name=m0,this.events=new Aa,this.initialized=!1,this.ignoredPayloadTypes=[Zt],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(_i)}),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:L,uri:M}=await this.client.core.pairing.create();c=L,h=M}const f=await this.client.core.crypto.generateKeyPair(),g={requiredNamespaces:n,relays:s??[{protocol:va}],proposer:{publicKey:f,metadata:this.client.metadata}},{reject:D,resolve:C,done:S}=Qt();if(this.events.once(Pe("session_connect"),async({error:L,session:M})=>{if(L)D(L);else if(M){M.self.publicKey=f;const E=Ua(Gt({},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:L}=V("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(L)}const w=await this.sendRequest(c,"wc_sessionPropose",g),P=Pt(Q.FIVE_MINUTES);return await this.setProposal(w,Gt({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(vi)};await this.client.core.relayer.subscribe(D);const S=await this.sendRequest(D,"wc_sessionSettle",C),{done:w,resolve:P,reject:L}=Qt();this.events.once(Pe("session_approve",S),({error:E})=>{E?L(E):P(this.client.session.get(D))});const M=Ua(Gt({},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(vi)),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}=Qt();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}=Qt();return this.events.once(Pe("session_extend",n),({error:u})=>{u?h(u):c()}),await this.setExpiry(i,Pt(vi)),{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}=Qt();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):_t(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}=Qt();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=_i[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=_i[h.request.method].res;await this.client.core.relayer.publish(i,c,u),await this.client.core.history.resolve(s)},this.sendError=async(r,i,n)=>{const s=Er(r,n),c=await this.client.core.crypto.encode(i,s),h=await this.client.core.history.get(i,r),u=_i[h.request.method].res;await 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=>{qt(n.expiry)&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{qt(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(Gt({},i.params));const c=Pt(Q.FIVE_MINUTES),h=Gt({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 _t(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),{})):_t(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(Gt({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),{}):_t(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(vi)),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),{}):_t(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),{}):_t(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(Gt({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}):_t(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(Gt({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;bt(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=un(n,"approve()");if(h)throw new Error(h.message);const u=So(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(!Eo(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=un(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(qt(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=un(n,"update()");if(c)throw new Error(c.message);const h=So(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(!Do(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(!Do(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(yr.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);Ti(n)?(this.client.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Yr(n)&&(await this.client.core.history.resolve(n),this.onRelayEventResponse({topic:r,payload:n}))})}registerExpirerEvents(){this.client.core.expirer.on(mt.expired,async e=>{const{topic:r,id:i}=fo(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(qt(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(qt(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(qt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=V("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class I0 extends Ln{constructor(e,r){super(e,r,_0,Ra),this.core=e,this.logger=r}}class A0 extends Ln{constructor(e,r){super(e,r,b0,Ra),this.core=e,this.logger=r}}class Pn extends md{constructor(e){super(e),this.protocol=Ca,this.version=La,this.name=Rn.name,this.events=new Aa.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||Rn.name,this.metadata=e?.metadata||Tf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ni(xe.getDefaultLoggerOptions({level:e?.logger||Rn.logger}));this.core=e?.core||new y0(e),this.logger=xe.generateChildLogger(r,this.name),this.session=new A0(this.core,this.logger),this.proposal=new I0(this.core,this.logger),this.engine=new O0(this)}static async init(e){const r=new Pn(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 T0=We;We.EventEmitter=We,We.prototype._events=void 0,We.prototype._maxListeners=void 0,We.defaultMaxListeners=10,We.prototype.setMaxListeners=function(t){if(!C0(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||qr(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],Ma(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(qr(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(!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]?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&&(Ma(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(!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},We.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(qr(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],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},We.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},We.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(jt(e))return 1;if(e)return e.length}return 0},We.listenerCount=function(t,e){return t.listenerCount(e)};function jt(t){return typeof t=="function"}function C0(t){return typeof t=="number"}function qr(t){return typeof t=="object"&&t!==null}function Ma(t){return t===void 0}function L0(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 hc{constructor(e){super(),this.events=new T0.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?Zi(this.session.namespaces):uf(this.requiredNamespaces)}get accounts(){return this.session?Xi(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",Er(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(L0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Pn.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 R0=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],P0=["chainChanged","accountsChanged"];function ja(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function $a(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Fn([t])]),r}function Fn(t){return Number(t[0].split(":")[1])}class F0{constructor(e){this.events=new cr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=ja(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Fn(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=Zi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Xi(e.namespaces,[this.namespace]);this.setAccounts(i)}),this.signer.connection.on(Ct.updated,e=>{const r=Zi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Xi(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 Zn(r)}setHttpProvider(e){const r=$a(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new Zn(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)}}Dt.default=F0,Dt.getEthereumChainId=Fn,Dt.getRpcConfig=ja,Dt.getRpcUrl=$a,Dt.signerEvents=P0,Dt.signerMethods=R0,Object.defineProperty(Dt,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|