@walletconnect/ethereum-provider 1.7.8 → 2.0.0-15eadf7
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/LICENSE +190 -0
- package/README.md +2 -172
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +2 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +15 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/index.d.ts +58 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +42 -65
- package/dist/cjs/index.d.ts +0 -28
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -117
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -28
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -106
- package/dist/esm/index.js.map +0 -1
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/umd/index.min.js +0 -33
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
(function(mt,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(mt=typeof globalThis<"u"?globalThis:mt||self,Z(mt["@walletconnect/ethereum-provider"]={}))})(this,function(mt){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ma(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function bi(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 He(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var gr=He;He.EventEmitter=He,He.prototype._events=void 0,He.prototype._maxListeners=void 0,He.defaultMaxListeners=10,He.prototype.setMaxListeners=function(t){if(!ja(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},He.prototype.emit=function(t){var e,r,i,n,s,u;if(this._events||(this._events={}),t==="error"&&(!this._events.error||vr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(r=this._events[t],Nn(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(vr(r))for(n=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,s=0;s<i;s++)u[s].apply(this,n);return!0},He.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]?vr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,vr(this._events[t])&&!this._events[t].warned&&(Nn(this._maxListeners)?r=He.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},He.prototype.on=He.prototype.addListener,He.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},He.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(vr(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},He.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},He.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},He.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Nt(e))return 1;if(e)return e.length}return 0},He.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function ja(t){return typeof t=="number"}function vr(t){return typeof t=="object"&&t!==null}function Nn(t){return t===void 0}const $a="PARSE_ERROR",Ba="INVALID_REQUEST",za="METHOD_NOT_FOUND",Ha="INVALID_PARAMS",Pn="INTERNAL_ERROR",mi="SERVER_ERROR",Ka=[-32700,-32600,-32601,-32602,-32603],yr={[$a]:{code:-32700,message:"Parse error"},[Ba]:{code:-32600,message:"Invalid Request"},[za]:{code:-32601,message:"Method not found"},[Ha]:{code:-32602,message:"Invalid params"},[Pn]:{code:-32603,message:"Internal error"},[mi]:{code:-32e3,message:"Server error"}},Rn=mi;function qa(t){return Ka.includes(t)}function Fn(t){return Object.keys(yr).includes(t)?yr[t]:yr[Rn]}function Va(t){const e=Object.values(yr).find(r=>r.code===t);return e||yr[Rn]}function Un(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Mn={},Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.isBrowserCryptoAvailable=Bt.getSubtleCrypto=Bt.getBrowerCrypto=void 0;function wi(){return Z?.crypto||Z?.msCrypto||{}}Bt.getBrowerCrypto=wi;function jn(){const t=wi();return t.subtle||t.webkitSubtle}Bt.getSubtleCrypto=jn;function Ga(){return!!wi()&&!!jn()}Bt.isBrowserCryptoAvailable=Ga;var zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.isBrowser=zt.isNode=zt.isReactNative=void 0;function $n(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}zt.isReactNative=$n;function Bn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}zt.isNode=Bn;function Wa(){return!$n()&&!Bn()}zt.isBrowser=Wa,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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)}(Mn);function ka(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function Ei(t,e,r){return{id:r||ka(),jsonrpc:"2.0",method:t,params:e}}function Di(t,e){return{id:t,jsonrpc:"2.0",result:e}}function qr(t,e,r){return{id:t,jsonrpc:"2.0",error:Ya(e,r)}}function Ya(t,e){return typeof t>"u"?Fn(Pn):(typeof t=="string"&&(t=Object.assign(Object.assign({},Fn(mi)),{message:t})),typeof e<"u"&&(t.data=e),qa(t.code)&&(t=Va(t.code)),t)}class zn{}class Ja extends zn{constructor(e){super()}}class Xa extends zn{constructor(){super()}}class Za extends Xa{constructor(e){super()}}const Qa="^https?:",ec="^wss?:";function tc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Hn(t,e){const r=tc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Kn(t){return Hn(t,Qa)}function qn(t){return Hn(t,ec)}function rc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Vn(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Gn(t){return Vn(t)&&"method"in t}function Wn(t){return Vn(t)&&(Pt(t)||wt(t))}function Pt(t){return"result"in t}function wt(t){return"error"in t}class xi extends Za{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(Ei(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=>{wt(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),Wn(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 Si={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(u){var c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function h(f){return f&&DataView.prototype.isPrototypeOf(f)}if(c.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],p=ArrayBuffer.isView||function(f){return f&&l.indexOf(Object.prototype.toString.call(f))>-1};function E(f){if(typeof f!="string"&&(f=String(f)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(f))throw new TypeError("Invalid character in header field name");return f.toLowerCase()}function L(f){return typeof f!="string"&&(f=String(f)),f}function w(f){var _={next:function(){var M=f.shift();return{done:M===void 0,value:M}}};return c.iterable&&(_[Symbol.iterator]=function(){return _}),_}function b(f){this.map={},f instanceof b?f.forEach(function(_,M){this.append(M,_)},this):Array.isArray(f)?f.forEach(function(_){this.append(_[0],_[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(_){this.append(_,f[_])},this)}b.prototype.append=function(f,_){f=E(f),_=L(_);var M=this.map[f];this.map[f]=M?M+", "+_:_},b.prototype.delete=function(f){delete this.map[E(f)]},b.prototype.get=function(f){return f=E(f),this.has(f)?this.map[f]:null},b.prototype.has=function(f){return this.map.hasOwnProperty(E(f))},b.prototype.set=function(f,_){this.map[E(f)]=L(_)},b.prototype.forEach=function(f,_){for(var M in this.map)this.map.hasOwnProperty(M)&&f.call(_,this.map[M],M,this)},b.prototype.keys=function(){var f=[];return this.forEach(function(_,M){f.push(M)}),w(f)},b.prototype.values=function(){var f=[];return this.forEach(function(_){f.push(_)}),w(f)},b.prototype.entries=function(){var f=[];return this.forEach(function(_,M){f.push([M,_])}),w(f)},c.iterable&&(b.prototype[Symbol.iterator]=b.prototype.entries);function F(f){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}function y(f){return new Promise(function(_,M){f.onload=function(){_(f.result)},f.onerror=function(){M(f.error)}})}function O(f){var _=new FileReader,M=y(_);return _.readAsArrayBuffer(f),M}function N(f){var _=new FileReader,M=y(_);return _.readAsText(f),M}function C(f){for(var _=new Uint8Array(f),M=new Array(_.length),K=0;K<_.length;K++)M[K]=String.fromCharCode(_[K]);return M.join("")}function S(f){if(f.slice)return f.slice(0);var _=new Uint8Array(f.byteLength);return _.set(new Uint8Array(f)),_.buffer}function T(){return this.bodyUsed=!1,this._initBody=function(f){this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:c.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:c.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():c.arrayBuffer&&c.blob&&h(f)?(this._bodyArrayBuffer=S(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||p(f))?this._bodyArrayBuffer=S(f):this._bodyText=f=Object.prototype.toString.call(f):this._bodyText="",this.headers.get("content-type")||(typeof f=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var f=F(this);if(f)return f;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?F(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(O)}),this.text=function(){var f=F(this);if(f)return f;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(B)}),this.json=function(){return this.text().then(JSON.parse)},this}var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(f){var _=f.toUpperCase();return m.indexOf(_)>-1?_:f}function g(f,_){_=_||{};var M=_.body;if(f instanceof g){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,_.headers||(this.headers=new b(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!M&&f._bodyInit!=null&&(M=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new b(_.headers)),this.method=o(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&M)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(M)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})};function B(f){var _=new FormData;return f.trim().split("&").forEach(function(M){if(M){var K=M.split("="),R=K.shift().replace(/\+/g," "),P=K.join("=").replace(/\+/g," ");_.append(decodeURIComponent(R),decodeURIComponent(P))}}),_}function q(f){var _=new b,M=f.replace(/\r?\n[\t ]+/g," ");return M.split(/\r?\n/).forEach(function(K){var R=K.split(":"),P=R.shift().trim();if(P){var j=R.join(":").trim();_.append(P,j)}}),_}T.call(g.prototype);function V(f,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new b(_.headers),this.url=_.url||"",this._initBody(f)}T.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new b(this.headers),url:this.url})},V.error=function(){var f=new V(null,{status:0,statusText:""});return f.type="error",f};var J=[301,302,303,307,308];V.redirect=function(f,_){if(J.indexOf(_)===-1)throw new RangeError("Invalid status code");return new V(null,{status:_,headers:{location:f}})},u.DOMException=s.DOMException;try{new u.DOMException}catch{u.DOMException=function(_,M){this.message=_,this.name=M;var K=Error(_);this.stack=K.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function X(f,_){return new Promise(function(M,K){var R=new g(f,_);if(R.signal&&R.signal.aborted)return K(new u.DOMException("Aborted","AbortError"));var P=new XMLHttpRequest;function j(){P.abort()}P.onload=function(){var $={status:P.status,statusText:P.statusText,headers:q(P.getAllResponseHeaders()||"")};$.url="responseURL"in P?P.responseURL:$.headers.get("X-Request-URL");var Q="response"in P?P.response:P.responseText;M(new V(Q,$))},P.onerror=function(){K(new TypeError("Network request failed"))},P.ontimeout=function(){K(new TypeError("Network request failed"))},P.onabort=function(){K(new u.DOMException("Aborted","AbortError"))},P.open(R.method,R.url,!0),R.credentials==="include"?P.withCredentials=!0:R.credentials==="omit"&&(P.withCredentials=!1),"responseType"in P&&c.blob&&(P.responseType="blob"),R.headers.forEach(function($,Q){P.setRequestHeader(Q,$)}),R.signal&&(R.signal.addEventListener("abort",j),P.onreadystatechange=function(){P.readyState===4&&R.signal.removeEventListener("abort",j)}),P.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=b,s.Request=g,s.Response=V),u.Headers=b,u.Request=g,u.Response=V,u.fetch=X,Object.defineProperty(u,"__esModule",{value:!0}),u})({})})(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})(Si,Si.exports);var kn=Ma(Si.exports);function Oi(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 _r(t){return typeof t=="string"?t:JSON.stringify(t)}const Yn={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class ic{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Kn(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=_r(e),s=await(await kn(this.url,Object.assign(Object.assign({},Yn),{body:i}))).json();this.onPayload({data:s})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!Kn(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering)return new Promise((r,i)=>{this.events.once("register_error",n=>{i(n)}),this.events.once("open",()=>{if(typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));r()})});this.url=e,this.registering=!0;try{const r=_r({id:1,jsonrpc:"2.0",method:"test",params:[]});await kn(e,Object.assign(Object.assign({},Yn),{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"?Oi(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=qr(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Un(e,r,"HTTP")}}var Ai={},Vr={},re={},Jn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(c,h){var l=c>>>16&65535,p=c&65535,E=h>>>16&65535,L=h&65535;return p*L+(l*L+p*E<<16>>>0)|0}t.mul=Math.imul||e;function r(c,h){return c+h|0}t.add=r;function i(c,h){return c-h|0}t.sub=i;function n(c,h){return c<<h|c>>>32-h}t.rotl=n;function s(c,h){return c<<32-h|c>>>h}t.rotr=s;function u(c){return typeof c=="number"&&isFinite(c)&&Math.floor(c)===c}t.isInteger=Number.isInteger||u,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(c){return t.isInteger(c)&&c>=-t.MAX_SAFE_INTEGER&&c<=t.MAX_SAFE_INTEGER}})(Jn),Object.defineProperty(re,"__esModule",{value:!0});var Xn=Jn;function nc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=nc;function sc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=sc;function oc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=oc;function ac(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=ac;function Zn(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=Zn,re.writeInt16BE=Zn;function Qn(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=Qn,re.writeInt16LE=Qn;function Ii(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Ii;function Ci(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=Ci;function Ti(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Ti;function Li(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=Li;function Gr(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=Gr,re.writeInt32BE=Gr;function Wr(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=Wr,re.writeInt32LE=Wr;function cc(t,e){e===void 0&&(e=0);var r=Ii(t,e),i=Ii(t,e+4);return r*4294967296+i-(i>>31)*4294967296}re.readInt64BE=cc;function uc(t,e){e===void 0&&(e=0);var r=Ci(t,e),i=Ci(t,e+4);return r*4294967296+i}re.readUint64BE=uc;function hc(t,e){e===void 0&&(e=0);var r=Ti(t,e),i=Ti(t,e+4);return i*4294967296+r-(r>>31)*4294967296}re.readInt64LE=hc;function fc(t,e){e===void 0&&(e=0);var r=Li(t,e),i=Li(t,e+4);return i*4294967296+r}re.readUint64LE=fc;function es(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Gr(t/4294967296>>>0,e,r),Gr(t>>>0,e,r+4),e}re.writeUint64BE=es,re.writeInt64BE=es;function ts(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Wr(t>>>0,e,r),Wr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=ts,re.writeInt64LE=ts;function lc(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=lc;function dc(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=dc;function pc(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(!Xn.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=pc;function gc(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(!Xn.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=gc;function vc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=vc;function yc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=yc;function _c(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=_c;function bc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=bc;function mc(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=mc;function wc(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=wc;function Ec(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=Ec;function Dc(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=Dc;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});function xc(t){for(var e=0;e<t.length;e++)t[e]=0;return t}pt.wipe=xc,Object.defineProperty(Vr,"__esModule",{value:!0});var st=re,Ni=pt,Sc=20;function Oc(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,u=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],h=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],p=r[15]<<24|r[14]<<16|r[13]<<8|r[12],E=r[19]<<24|r[18]<<16|r[17]<<8|r[16],L=r[23]<<24|r[22]<<16|r[21]<<8|r[20],w=r[27]<<24|r[26]<<16|r[25]<<8|r[24],b=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],y=e[7]<<24|e[6]<<16|e[5]<<8|e[4],O=e[11]<<24|e[10]<<16|e[9]<<8|e[8],N=e[15]<<24|e[14]<<16|e[13]<<8|e[12],C=i,S=n,T=s,m=u,o=c,g=h,B=l,q=p,V=E,J=L,X=w,f=b,_=F,M=y,K=O,R=N,P=0;P<Sc;P+=2)C=C+o|0,_^=C,_=_>>>32-16|_<<16,V=V+_|0,o^=V,o=o>>>32-12|o<<12,S=S+g|0,M^=S,M=M>>>32-16|M<<16,J=J+M|0,g^=J,g=g>>>32-12|g<<12,T=T+B|0,K^=T,K=K>>>32-16|K<<16,X=X+K|0,B^=X,B=B>>>32-12|B<<12,m=m+q|0,R^=m,R=R>>>32-16|R<<16,f=f+R|0,q^=f,q=q>>>32-12|q<<12,T=T+B|0,K^=T,K=K>>>32-8|K<<8,X=X+K|0,B^=X,B=B>>>32-7|B<<7,m=m+q|0,R^=m,R=R>>>32-8|R<<8,f=f+R|0,q^=f,q=q>>>32-7|q<<7,S=S+g|0,M^=S,M=M>>>32-8|M<<8,J=J+M|0,g^=J,g=g>>>32-7|g<<7,C=C+o|0,_^=C,_=_>>>32-8|_<<8,V=V+_|0,o^=V,o=o>>>32-7|o<<7,C=C+g|0,R^=C,R=R>>>32-16|R<<16,X=X+R|0,g^=X,g=g>>>32-12|g<<12,S=S+B|0,_^=S,_=_>>>32-16|_<<16,f=f+_|0,B^=f,B=B>>>32-12|B<<12,T=T+q|0,M^=T,M=M>>>32-16|M<<16,V=V+M|0,q^=V,q=q>>>32-12|q<<12,m=m+o|0,K^=m,K=K>>>32-16|K<<16,J=J+K|0,o^=J,o=o>>>32-12|o<<12,T=T+q|0,M^=T,M=M>>>32-8|M<<8,V=V+M|0,q^=V,q=q>>>32-7|q<<7,m=m+o|0,K^=m,K=K>>>32-8|K<<8,J=J+K|0,o^=J,o=o>>>32-7|o<<7,S=S+B|0,_^=S,_=_>>>32-8|_<<8,f=f+_|0,B^=f,B=B>>>32-7|B<<7,C=C+g|0,R^=C,R=R>>>32-8|R<<8,X=X+R|0,g^=X,g=g>>>32-7|g<<7;st.writeUint32LE(C+i|0,t,0),st.writeUint32LE(S+n|0,t,4),st.writeUint32LE(T+s|0,t,8),st.writeUint32LE(m+u|0,t,12),st.writeUint32LE(o+c|0,t,16),st.writeUint32LE(g+h|0,t,20),st.writeUint32LE(B+l|0,t,24),st.writeUint32LE(q+p|0,t,28),st.writeUint32LE(V+E|0,t,32),st.writeUint32LE(J+L|0,t,36),st.writeUint32LE(X+w|0,t,40),st.writeUint32LE(f+b|0,t,44),st.writeUint32LE(_+F|0,t,48),st.writeUint32LE(M+y|0,t,52),st.writeUint32LE(K+O|0,t,56),st.writeUint32LE(R+N|0,t,60)}function rs(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,u;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),u=s.length-e.length,s.set(e,u)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,u=n}for(var c=new Uint8Array(64),h=0;h<r.length;h+=64){Oc(c,s,t);for(var l=h;l<h+64&&l<r.length;l++)i[l]=r[l]^c[l-h];Ic(s,0,u)}return Ni.wipe(c),n===0&&Ni.wipe(s),i}Vr.streamXOR=rs;function Ac(t,e,r,i){return i===void 0&&(i=0),Ni.wipe(r),rs(t,e,r,r,i)}Vr.stream=Ac;function Ic(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 is={},Ht={};Object.defineProperty(Ht,"__esModule",{value:!0});function Cc(t,e,r){return~(t-1)&e|t-1&r}Ht.select=Cc;function Tc(t,e){return(t|0)-(e|0)-1>>>31&1}Ht.lessOrEqual=Tc;function ns(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=ns;function Lc(t,e){return t.length===0||e.length===0?!1:ns(t,e)!==0}Ht.equal=Lc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ht,r=pt;t.DIGEST_LENGTH=16;var i=function(){function u(c){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var h=c[0]|c[1]<<8;this._r[0]=h&8191;var l=c[2]|c[3]<<8;this._r[1]=(h>>>13|l<<3)&8191;var p=c[4]|c[5]<<8;this._r[2]=(l>>>10|p<<6)&7939;var E=c[6]|c[7]<<8;this._r[3]=(p>>>7|E<<9)&8191;var L=c[8]|c[9]<<8;this._r[4]=(E>>>4|L<<12)&255,this._r[5]=L>>>1&8190;var w=c[10]|c[11]<<8;this._r[6]=(L>>>14|w<<2)&8191;var b=c[12]|c[13]<<8;this._r[7]=(w>>>11|b<<5)&8065;var F=c[14]|c[15]<<8;this._r[8]=(b>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return u.prototype._blocks=function(c,h,l){for(var p=this._fin?0:2048,E=this._h[0],L=this._h[1],w=this._h[2],b=this._h[3],F=this._h[4],y=this._h[5],O=this._h[6],N=this._h[7],C=this._h[8],S=this._h[9],T=this._r[0],m=this._r[1],o=this._r[2],g=this._r[3],B=this._r[4],q=this._r[5],V=this._r[6],J=this._r[7],X=this._r[8],f=this._r[9];l>=16;){var _=c[h+0]|c[h+1]<<8;E+=_&8191;var M=c[h+2]|c[h+3]<<8;L+=(_>>>13|M<<3)&8191;var K=c[h+4]|c[h+5]<<8;w+=(M>>>10|K<<6)&8191;var R=c[h+6]|c[h+7]<<8;b+=(K>>>7|R<<9)&8191;var P=c[h+8]|c[h+9]<<8;F+=(R>>>4|P<<12)&8191,y+=P>>>1&8191;var j=c[h+10]|c[h+11]<<8;O+=(P>>>14|j<<2)&8191;var $=c[h+12]|c[h+13]<<8;N+=(j>>>11|$<<5)&8191;var Q=c[h+14]|c[h+15]<<8;C+=($>>>8|Q<<8)&8191,S+=Q>>>5|p;var H=0,ee=H;ee+=E*T,ee+=L*(5*f),ee+=w*(5*X),ee+=b*(5*J),ee+=F*(5*V),H=ee>>>13,ee&=8191,ee+=y*(5*q),ee+=O*(5*B),ee+=N*(5*g),ee+=C*(5*o),ee+=S*(5*m),H+=ee>>>13,ee&=8191;var k=H;k+=E*m,k+=L*T,k+=w*(5*f),k+=b*(5*X),k+=F*(5*J),H=k>>>13,k&=8191,k+=y*(5*V),k+=O*(5*q),k+=N*(5*B),k+=C*(5*g),k+=S*(5*o),H+=k>>>13,k&=8191;var ae=H;ae+=E*o,ae+=L*m,ae+=w*T,ae+=b*(5*f),ae+=F*(5*X),H=ae>>>13,ae&=8191,ae+=y*(5*J),ae+=O*(5*V),ae+=N*(5*q),ae+=C*(5*B),ae+=S*(5*g),H+=ae>>>13,ae&=8191;var I=H;I+=E*g,I+=L*o,I+=w*m,I+=b*T,I+=F*(5*f),H=I>>>13,I&=8191,I+=y*(5*X),I+=O*(5*J),I+=N*(5*V),I+=C*(5*q),I+=S*(5*B),H+=I>>>13,I&=8191;var A=H;A+=E*B,A+=L*g,A+=w*o,A+=b*m,A+=F*T,H=A>>>13,A&=8191,A+=y*(5*f),A+=O*(5*X),A+=N*(5*J),A+=C*(5*V),A+=S*(5*q),H+=A>>>13,A&=8191;var D=H;D+=E*q,D+=L*B,D+=w*g,D+=b*o,D+=F*m,H=D>>>13,D&=8191,D+=y*T,D+=O*(5*f),D+=N*(5*X),D+=C*(5*J),D+=S*(5*V),H+=D>>>13,D&=8191;var a=H;a+=E*V,a+=L*q,a+=w*B,a+=b*g,a+=F*o,H=a>>>13,a&=8191,a+=y*m,a+=O*T,a+=N*(5*f),a+=C*(5*X),a+=S*(5*J),H+=a>>>13,a&=8191;var v=H;v+=E*J,v+=L*V,v+=w*q,v+=b*B,v+=F*g,H=v>>>13,v&=8191,v+=y*o,v+=O*m,v+=N*T,v+=C*(5*f),v+=S*(5*X),H+=v>>>13,v&=8191;var z=H;z+=E*X,z+=L*J,z+=w*V,z+=b*q,z+=F*B,H=z>>>13,z&=8191,z+=y*g,z+=O*o,z+=N*m,z+=C*T,z+=S*(5*f),H+=z>>>13,z&=8191;var Y=H;Y+=E*f,Y+=L*X,Y+=w*J,Y+=b*V,Y+=F*q,H=Y>>>13,Y&=8191,Y+=y*B,Y+=O*g,Y+=N*o,Y+=C*m,Y+=S*T,H+=Y>>>13,Y&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,k+=H,E=ee,L=k,w=ae,b=I,F=A,y=D,O=a,N=v,C=z,S=Y,h+=16,l-=16}this._h[0]=E,this._h[1]=L,this._h[2]=w,this._h[3]=b,this._h[4]=F,this._h[5]=y,this._h[6]=O,this._h[7]=N,this._h[8]=C,this._h[9]=S},u.prototype.finish=function(c,h){h===void 0&&(h=0);var l=new Uint16Array(10),p,E,L,w;if(this._leftover){for(w=this._leftover,this._buffer[w++]=1;w<16;w++)this._buffer[w]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(p=this._h[1]>>>13,this._h[1]&=8191,w=2;w<10;w++)this._h[w]+=p,p=this._h[w]>>>13,this._h[w]&=8191;for(this._h[0]+=p*5,p=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=p,p=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=p,l[0]=this._h[0]+5,p=l[0]>>>13,l[0]&=8191,w=1;w<10;w++)l[w]=this._h[w]+p,p=l[w]>>>13,l[w]&=8191;for(l[9]-=1<<13,E=(p^1)-1,w=0;w<10;w++)l[w]&=E;for(E=~E,w=0;w<10;w++)this._h[w]=this._h[w]&E|l[w];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,L=this._h[0]+this._pad[0],this._h[0]=L&65535,w=1;w<8;w++)L=(this._h[w]+this._pad[w]|0)+(L>>>16)|0,this._h[w]=L&65535;return c[h+0]=this._h[0]>>>0,c[h+1]=this._h[0]>>>8,c[h+2]=this._h[1]>>>0,c[h+3]=this._h[1]>>>8,c[h+4]=this._h[2]>>>0,c[h+5]=this._h[2]>>>8,c[h+6]=this._h[3]>>>0,c[h+7]=this._h[3]>>>8,c[h+8]=this._h[4]>>>0,c[h+9]=this._h[4]>>>8,c[h+10]=this._h[5]>>>0,c[h+11]=this._h[5]>>>8,c[h+12]=this._h[6]>>>0,c[h+13]=this._h[6]>>>8,c[h+14]=this._h[7]>>>0,c[h+15]=this._h[7]>>>8,this._finished=!0,this},u.prototype.update=function(c){var h=0,l=c.length,p;if(this._leftover){p=16-this._leftover,p>l&&(p=l);for(var E=0;E<p;E++)this._buffer[this._leftover+E]=c[h+E];if(l-=p,h+=p,this._leftover+=p,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(l>=16&&(p=l-l%16,this._blocks(c,h,p),h+=p,l-=p),l){for(var E=0;E<l;E++)this._buffer[this._leftover+E]=c[h+E];this._leftover+=l}return this},u.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},u.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},u}();t.Poly1305=i;function n(u,c){var h=new i(u);h.update(c);var l=h.digest();return h.clean(),l}t.oneTimeAuth=n;function s(u,c){return u.length!==t.DIGEST_LENGTH||c.length!==t.DIGEST_LENGTH?!1:e.equal(u,c)}t.equal=s}(is),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vr,r=is,i=pt,n=re,s=Ht;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var u=new Uint8Array(16),c=function(){function h(l){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,l.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(l)}return h.prototype.seal=function(l,p,E,L){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var w=new Uint8Array(16);w.set(l,w.length-l.length);var b=new Uint8Array(32);e.stream(this._key,w,b,4);var F=p.length+this.tagLength,y;if(L){if(L.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");y=L}else y=new Uint8Array(F);return e.streamXOR(this._key,w,p,y,4),this._authenticate(y.subarray(y.length-this.tagLength,y.length),b,y.subarray(0,y.length-this.tagLength),E),i.wipe(w),y},h.prototype.open=function(l,p,E,L){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(p.length<this.tagLength)return null;var w=new Uint8Array(16);w.set(l,w.length-l.length);var b=new Uint8Array(32);e.stream(this._key,w,b,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,b,p.subarray(0,p.length-this.tagLength),E),!s.equal(F,p.subarray(p.length-this.tagLength,p.length)))return null;var y=p.length-this.tagLength,O;if(L){if(L.length!==y)throw new Error("ChaCha20Poly1305: incorrect destination length");O=L}else O=new Uint8Array(y);return e.streamXOR(this._key,w,p.subarray(0,p.length-this.tagLength),O,4),i.wipe(w),O},h.prototype.clean=function(){return i.wipe(this._key),this},h.prototype._authenticate=function(l,p,E,L){var w=new r.Poly1305(p);L&&(w.update(L),L.length%16>0&&w.update(u.subarray(L.length%16))),w.update(E),E.length%16>0&&w.update(u.subarray(E.length%16));var b=new Uint8Array(8);L&&n.writeUint64LE(L.length,b),w.update(b),n.writeUint64LE(E.length,b),w.update(b);for(var F=w.digest(),y=0;y<F.length;y++)l[y]=F[y];w.clean(),i.wipe(F),i.wipe(b)},h}();t.ChaCha20Poly1305=c}(Ai);var ss={},br={},Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});function Nc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Pi.isSerializableHash=Nc,Object.defineProperty(br,"__esModule",{value:!0});var Ot=Pi,Pc=Ht,Rc=pt,os=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()),Rc.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}();br.HMAC=os;function Fc(t,e,r){var i=new os(t,e);i.update(r);var n=i.digest();return i.clean(),n}br.hmac=Fc,br.equal=Pc.equal,Object.defineProperty(ss,"__esModule",{value:!0});var as=br,cs=pt,Uc=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=as.hmac(this._hash,i,r);this._hmac=new as.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(),cs.wipe(this._buffer),cs.wipe(this._counter),this._bufpos=0},t}(),Mc=ss.HKDF=Uc,nr={},Ri={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});var us=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+=us)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,us)));return r},t}();Fi.BrowserRandomSource=jc;function $c(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 Ui={},Bc={},zc=Object.freeze({__proto__:null,default:Bc}),Hc=bi(zc);Object.defineProperty(Ui,"__esModule",{value:!0});var Kc=pt,qc=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof $c<"u"){var e=Hc;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 Kc.wipe(r),i},t}();Ui.NodeRandomSource=qc,Object.defineProperty(Ri,"__esModule",{value:!0});var Vc=Fi,Gc=Ui,Wc=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new Vc.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Gc.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}();Ri.SystemRandomSource=Wc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ri,r=re,i=pt;t.defaultRandomSource=new e.SystemRandomSource;function n(l,p){return p===void 0&&(p=t.defaultRandomSource),p.randomBytes(l)}t.randomBytes=n;function s(l){l===void 0&&(l=t.defaultRandomSource);var p=n(4,l),E=r.readUint32LE(p);return i.wipe(p),E}t.randomUint32=s;var u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(l,p,E){if(p===void 0&&(p=u),E===void 0&&(E=t.defaultRandomSource),p.length<2)throw new Error("randomString charset is too short");if(p.length>256)throw new Error("randomString charset is too long");for(var L="",w=p.length,b=256-256%w;l>0;){for(var F=n(Math.ceil(l*256/b),E),y=0;y<F.length&&l>0;y++){var O=F[y];O<b&&(L+=p.charAt(O%w),l--)}i.wipe(F)}return L}t.randomString=c;function h(l,p,E){p===void 0&&(p=u),E===void 0&&(E=t.defaultRandomSource);var L=Math.ceil(l/(Math.log(p.length)/Math.LN2));return c(L,p,E)}t.randomStringForEntropy=h}(nr);var kr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},c.prototype.update=function(h,l){if(l===void 0&&(l=h.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var p=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&l>0;)this._buffer[this._bufferLength++]=h[p++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(p=s(this._temp,this._state,h,p,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[p++],l--;return this},c.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,p=this._bufferLength,E=l/536870912|0,L=l<<3,w=l%64<56?64:128;this._buffer[p]=128;for(var b=p+1;b<w-8;b++)this._buffer[b]=0;e.writeUint32BE(E,this._buffer,w-8),e.writeUint32BE(L,this._buffer,w-4),s(this._temp,this._state,this._buffer,0,w),this._finished=!0}for(var b=0;b<this.digestLength/4;b++)e.writeUint32BE(this._state[b],h,b*4);return this},c.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(h){return this._state.set(h.state),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},c}();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(c,h,l,p,E){for(;E>=64;){for(var L=h[0],w=h[1],b=h[2],F=h[3],y=h[4],O=h[5],N=h[6],C=h[7],S=0;S<16;S++){var T=p+S*4;c[S]=e.readUint32BE(l,T)}for(var S=16;S<64;S++){var m=c[S-2],o=(m>>>17|m<<32-17)^(m>>>19|m<<32-19)^m>>>10;m=c[S-15];var g=(m>>>7|m<<32-7)^(m>>>18|m<<32-18)^m>>>3;c[S]=(o+c[S-7]|0)+(g+c[S-16]|0)}for(var S=0;S<64;S++){var o=(((y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&O^~y&N)|0)+(C+(n[S]+c[S]|0)|0)|0,g=((L>>>2|L<<32-2)^(L>>>13|L<<32-13)^(L>>>22|L<<32-22))+(L&w^L&b^w&b)|0;C=N,N=O,O=y,y=F+o|0,F=b,b=w,w=L,L=o+g|0}h[0]+=L,h[1]+=w,h[2]+=b,h[3]+=F,h[4]+=y,h[5]+=O,h[6]+=N,h[7]+=C,p+=64,E-=64}return p}function u(c){var h=new i;h.update(c);var l=h.digest();return h.clean(),l}t.hash=u})(kr);var Mi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=pt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(S){var T=new Float64Array(16);if(S)for(var m=0;m<S.length;m++)T[m]=S[m];return T}var n=new Uint8Array(32);n[0]=9;var s=i([56129,1]);function u(S){for(var T=1,m=0;m<16;m++){var o=S[m]+T+65535;T=Math.floor(o/65536),S[m]=o-T*65536}S[0]+=T-1+37*(T-1)}function c(S,T,m){for(var o=~(m-1),g=0;g<16;g++){var B=o&(S[g]^T[g]);S[g]^=B,T[g]^=B}}function h(S,T){for(var m=i(),o=i(),g=0;g<16;g++)o[g]=T[g];u(o),u(o),u(o);for(var B=0;B<2;B++){m[0]=o[0]-65517;for(var g=1;g<15;g++)m[g]=o[g]-65535-(m[g-1]>>16&1),m[g-1]&=65535;m[15]=o[15]-32767-(m[14]>>16&1);var q=m[15]>>16&1;m[14]&=65535,c(o,m,1-q)}for(var g=0;g<16;g++)S[2*g]=o[g]&255,S[2*g+1]=o[g]>>8}function l(S,T){for(var m=0;m<16;m++)S[m]=T[2*m]+(T[2*m+1]<<8);S[15]&=32767}function p(S,T,m){for(var o=0;o<16;o++)S[o]=T[o]+m[o]}function E(S,T,m){for(var o=0;o<16;o++)S[o]=T[o]-m[o]}function L(S,T,m){var o,g,B=0,q=0,V=0,J=0,X=0,f=0,_=0,M=0,K=0,R=0,P=0,j=0,$=0,Q=0,H=0,ee=0,k=0,ae=0,I=0,A=0,D=0,a=0,v=0,z=0,Y=0,fe=0,ye=0,de=0,me=0,Fe=0,Te=0,ve=m[0],pe=m[1],le=m[2],ue=m[3],ce=m[4],oe=m[5],se=m[6],te=m[7],he=m[8],ge=m[9],ie=m[10],_e=m[11],be=m[12],Ee=m[13],De=m[14],we=m[15];o=T[0],B+=o*ve,q+=o*pe,V+=o*le,J+=o*ue,X+=o*ce,f+=o*oe,_+=o*se,M+=o*te,K+=o*he,R+=o*ge,P+=o*ie,j+=o*_e,$+=o*be,Q+=o*Ee,H+=o*De,ee+=o*we,o=T[1],q+=o*ve,V+=o*pe,J+=o*le,X+=o*ue,f+=o*ce,_+=o*oe,M+=o*se,K+=o*te,R+=o*he,P+=o*ge,j+=o*ie,$+=o*_e,Q+=o*be,H+=o*Ee,ee+=o*De,k+=o*we,o=T[2],V+=o*ve,J+=o*pe,X+=o*le,f+=o*ue,_+=o*ce,M+=o*oe,K+=o*se,R+=o*te,P+=o*he,j+=o*ge,$+=o*ie,Q+=o*_e,H+=o*be,ee+=o*Ee,k+=o*De,ae+=o*we,o=T[3],J+=o*ve,X+=o*pe,f+=o*le,_+=o*ue,M+=o*ce,K+=o*oe,R+=o*se,P+=o*te,j+=o*he,$+=o*ge,Q+=o*ie,H+=o*_e,ee+=o*be,k+=o*Ee,ae+=o*De,I+=o*we,o=T[4],X+=o*ve,f+=o*pe,_+=o*le,M+=o*ue,K+=o*ce,R+=o*oe,P+=o*se,j+=o*te,$+=o*he,Q+=o*ge,H+=o*ie,ee+=o*_e,k+=o*be,ae+=o*Ee,I+=o*De,A+=o*we,o=T[5],f+=o*ve,_+=o*pe,M+=o*le,K+=o*ue,R+=o*ce,P+=o*oe,j+=o*se,$+=o*te,Q+=o*he,H+=o*ge,ee+=o*ie,k+=o*_e,ae+=o*be,I+=o*Ee,A+=o*De,D+=o*we,o=T[6],_+=o*ve,M+=o*pe,K+=o*le,R+=o*ue,P+=o*ce,j+=o*oe,$+=o*se,Q+=o*te,H+=o*he,ee+=o*ge,k+=o*ie,ae+=o*_e,I+=o*be,A+=o*Ee,D+=o*De,a+=o*we,o=T[7],M+=o*ve,K+=o*pe,R+=o*le,P+=o*ue,j+=o*ce,$+=o*oe,Q+=o*se,H+=o*te,ee+=o*he,k+=o*ge,ae+=o*ie,I+=o*_e,A+=o*be,D+=o*Ee,a+=o*De,v+=o*we,o=T[8],K+=o*ve,R+=o*pe,P+=o*le,j+=o*ue,$+=o*ce,Q+=o*oe,H+=o*se,ee+=o*te,k+=o*he,ae+=o*ge,I+=o*ie,A+=o*_e,D+=o*be,a+=o*Ee,v+=o*De,z+=o*we,o=T[9],R+=o*ve,P+=o*pe,j+=o*le,$+=o*ue,Q+=o*ce,H+=o*oe,ee+=o*se,k+=o*te,ae+=o*he,I+=o*ge,A+=o*ie,D+=o*_e,a+=o*be,v+=o*Ee,z+=o*De,Y+=o*we,o=T[10],P+=o*ve,j+=o*pe,$+=o*le,Q+=o*ue,H+=o*ce,ee+=o*oe,k+=o*se,ae+=o*te,I+=o*he,A+=o*ge,D+=o*ie,a+=o*_e,v+=o*be,z+=o*Ee,Y+=o*De,fe+=o*we,o=T[11],j+=o*ve,$+=o*pe,Q+=o*le,H+=o*ue,ee+=o*ce,k+=o*oe,ae+=o*se,I+=o*te,A+=o*he,D+=o*ge,a+=o*ie,v+=o*_e,z+=o*be,Y+=o*Ee,fe+=o*De,ye+=o*we,o=T[12],$+=o*ve,Q+=o*pe,H+=o*le,ee+=o*ue,k+=o*ce,ae+=o*oe,I+=o*se,A+=o*te,D+=o*he,a+=o*ge,v+=o*ie,z+=o*_e,Y+=o*be,fe+=o*Ee,ye+=o*De,de+=o*we,o=T[13],Q+=o*ve,H+=o*pe,ee+=o*le,k+=o*ue,ae+=o*ce,I+=o*oe,A+=o*se,D+=o*te,a+=o*he,v+=o*ge,z+=o*ie,Y+=o*_e,fe+=o*be,ye+=o*Ee,de+=o*De,me+=o*we,o=T[14],H+=o*ve,ee+=o*pe,k+=o*le,ae+=o*ue,I+=o*ce,A+=o*oe,D+=o*se,a+=o*te,v+=o*he,z+=o*ge,Y+=o*ie,fe+=o*_e,ye+=o*be,de+=o*Ee,me+=o*De,Fe+=o*we,o=T[15],ee+=o*ve,k+=o*pe,ae+=o*le,I+=o*ue,A+=o*ce,D+=o*oe,a+=o*se,v+=o*te,z+=o*he,Y+=o*ge,fe+=o*ie,ye+=o*_e,de+=o*be,me+=o*Ee,Fe+=o*De,Te+=o*we,B+=38*k,q+=38*ae,V+=38*I,J+=38*A,X+=38*D,f+=38*a,_+=38*v,M+=38*z,K+=38*Y,R+=38*fe,P+=38*ye,j+=38*de,$+=38*me,Q+=38*Fe,H+=38*Te,g=1,o=B+g+65535,g=Math.floor(o/65536),B=o-g*65536,o=q+g+65535,g=Math.floor(o/65536),q=o-g*65536,o=V+g+65535,g=Math.floor(o/65536),V=o-g*65536,o=J+g+65535,g=Math.floor(o/65536),J=o-g*65536,o=X+g+65535,g=Math.floor(o/65536),X=o-g*65536,o=f+g+65535,g=Math.floor(o/65536),f=o-g*65536,o=_+g+65535,g=Math.floor(o/65536),_=o-g*65536,o=M+g+65535,g=Math.floor(o/65536),M=o-g*65536,o=K+g+65535,g=Math.floor(o/65536),K=o-g*65536,o=R+g+65535,g=Math.floor(o/65536),R=o-g*65536,o=P+g+65535,g=Math.floor(o/65536),P=o-g*65536,o=j+g+65535,g=Math.floor(o/65536),j=o-g*65536,o=$+g+65535,g=Math.floor(o/65536),$=o-g*65536,o=Q+g+65535,g=Math.floor(o/65536),Q=o-g*65536,o=H+g+65535,g=Math.floor(o/65536),H=o-g*65536,o=ee+g+65535,g=Math.floor(o/65536),ee=o-g*65536,B+=g-1+37*(g-1),g=1,o=B+g+65535,g=Math.floor(o/65536),B=o-g*65536,o=q+g+65535,g=Math.floor(o/65536),q=o-g*65536,o=V+g+65535,g=Math.floor(o/65536),V=o-g*65536,o=J+g+65535,g=Math.floor(o/65536),J=o-g*65536,o=X+g+65535,g=Math.floor(o/65536),X=o-g*65536,o=f+g+65535,g=Math.floor(o/65536),f=o-g*65536,o=_+g+65535,g=Math.floor(o/65536),_=o-g*65536,o=M+g+65535,g=Math.floor(o/65536),M=o-g*65536,o=K+g+65535,g=Math.floor(o/65536),K=o-g*65536,o=R+g+65535,g=Math.floor(o/65536),R=o-g*65536,o=P+g+65535,g=Math.floor(o/65536),P=o-g*65536,o=j+g+65535,g=Math.floor(o/65536),j=o-g*65536,o=$+g+65535,g=Math.floor(o/65536),$=o-g*65536,o=Q+g+65535,g=Math.floor(o/65536),Q=o-g*65536,o=H+g+65535,g=Math.floor(o/65536),H=o-g*65536,o=ee+g+65535,g=Math.floor(o/65536),ee=o-g*65536,B+=g-1+37*(g-1),S[0]=B,S[1]=q,S[2]=V,S[3]=J,S[4]=X,S[5]=f,S[6]=_,S[7]=M,S[8]=K,S[9]=R,S[10]=P,S[11]=j,S[12]=$,S[13]=Q,S[14]=H,S[15]=ee}function w(S,T){L(S,T,T)}function b(S,T){for(var m=i(),o=0;o<16;o++)m[o]=T[o];for(var o=253;o>=0;o--)w(m,m),o!==2&&o!==4&&L(m,m,T);for(var o=0;o<16;o++)S[o]=m[o]}function F(S,T){for(var m=new Uint8Array(32),o=new Float64Array(80),g=i(),B=i(),q=i(),V=i(),J=i(),X=i(),f=0;f<31;f++)m[f]=S[f];m[31]=S[31]&127|64,m[0]&=248,l(o,T);for(var f=0;f<16;f++)B[f]=o[f];g[0]=V[0]=1;for(var f=254;f>=0;--f){var _=m[f>>>3]>>>(f&7)&1;c(g,B,_),c(q,V,_),p(J,g,q),E(g,g,q),p(q,B,V),E(B,B,V),w(V,J),w(X,g),L(g,q,g),L(q,B,J),p(J,g,q),E(g,g,q),w(B,g),E(q,V,X),L(g,q,s),p(g,g,V),L(q,q,g),L(g,V,X),L(V,B,o),w(B,J),c(g,B,_),c(q,V,_)}for(var f=0;f<16;f++)o[f+16]=g[f],o[f+32]=q[f],o[f+48]=B[f],o[f+64]=V[f];var M=o.subarray(32),K=o.subarray(16);b(M,M),L(K,K,M);var R=new Uint8Array(32);return h(R,K),R}t.scalarMult=F;function y(S){return F(S,n)}t.scalarMultBase=y;function O(S){if(S.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var T=new Uint8Array(S),m=y(T);return{publicKey:m,secretKey:T}}t.generateKeyPairFromSeed=O;function N(S){var T=e.randomBytes(32,S),m=O(T);return r.wipe(T),m}t.generateKeyPair=N;function C(S,T,m){if(m===void 0&&(m=!1),S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(T.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=F(S,T);if(m){for(var g=0,B=0;B<o.length;B++)g|=o[B];if(g===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=C})(Mi);function ji(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=new Uint8Array(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function kc(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),u=s.charCodeAt(0);if(r[u]!==255)throw new TypeError(s+" is ambiguous");r[u]=n}var c=t.length,h=t.charAt(0),l=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function E(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var F=0,y=0,O=0,N=b.length;O!==N&&b[O]===0;)O++,F++;for(var C=(N-O)*p+1>>>0,S=new Uint8Array(C);O!==N;){for(var T=b[O],m=0,o=C-1;(T!==0||m<y)&&o!==-1;o--,m++)T+=256*S[o]>>>0,S[o]=T%c>>>0,T=T/c>>>0;if(T!==0)throw new Error("Non-zero carry");y=m,O++}for(var g=C-y;g!==C&&S[g]===0;)g++;for(var B=h.repeat(F);g<C;++g)B+=t.charAt(S[g]);return B}function L(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var F=0;if(b[F]!==" "){for(var y=0,O=0;b[F]===h;)y++,F++;for(var N=(b.length-F)*l+1>>>0,C=new Uint8Array(N);b[F];){var S=r[b.charCodeAt(F)];if(S===255)return;for(var T=0,m=N-1;(S!==0||T<O)&&m!==-1;m--,T++)S+=c*C[m]>>>0,C[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");O=T,F++}if(b[F]!==" "){for(var o=N-O;o!==N&&C[o]===0;)o++;for(var g=new Uint8Array(y+(N-o)),B=y;o!==N;)g[B++]=C[o++];return g}}}function w(b){var F=L(b);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:L,decode:w}}var Yc=kc,Jc=Yc;const hs=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")},Xc=t=>new TextEncoder().encode(t),Zc=t=>new TextDecoder().decode(t);class Qc{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 eu{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 tu{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 tu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class ru{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Qc(e,r,i),this.decoder=new eu(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Yr=({name:t,prefix:e,encode:r,decode:i})=>new ru(t,e,r,i),mr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Jc(r,e);return Yr({prefix:t,name:e,encode:i,decode:s=>hs(n(s))})},iu=(t,e,r,i)=>{const n={};for(let p=0;p<e.length;++p)n[e[p]]=p;let s=t.length;for(;t[s-1]==="=";)--s;const u=new Uint8Array(s*r/8|0);let c=0,h=0,l=0;for(let p=0;p<s;++p){const E=n[t[p]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<r|E,c+=r,c>=8&&(c-=8,u[l++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return u},nu=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",u=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],u+=8;u>r;)u-=r,s+=e[n&c>>u];if(u&&(s+=e[n&c<<r-u]),i)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Yr({prefix:e,name:t,encode(n){return nu(n,i,r)},decode(n){return iu(n,i,r,t)}}),su=Yr({prefix:"\0",name:"identity",encode:t=>Zc(t),decode:t=>Xc(t)});var ou=Object.freeze({__proto__:null,identity:su});const au=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cu=Object.freeze({__proto__:null,base2:au});const uu=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var hu=Object.freeze({__proto__:null,base8:uu});const fu=mr({prefix:"9",name:"base10",alphabet:"0123456789"});var lu=Object.freeze({__proto__:null,base10:fu});const du=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pu=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gu=Object.freeze({__proto__:null,base16:du,base16upper:pu});const vu=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_u=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Eu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Du=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xu=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Su=Object.freeze({__proto__:null,base32:vu,base32upper:yu,base32pad:_u,base32padupper:bu,base32hex:mu,base32hexupper:wu,base32hexpad:Eu,base32hexpadupper:Du,base32z:xu});const Ou=mr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Au=mr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Iu=Object.freeze({__proto__:null,base36:Ou,base36upper:Au});const Cu=mr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tu=mr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lu=Object.freeze({__proto__:null,base58btc:Cu,base58flickr:Tu});const Nu=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ru=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Uu=Object.freeze({__proto__:null,base64:Nu,base64pad:Pu,base64url:Ru,base64urlpad:Fu});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}"),Mu=ls.reduce((t,e,r)=>(t[r]=e,t),[]),ju=ls.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $u(t){return t.reduce((e,r)=>(e+=Mu[r],e),"")}function Bu(t){const e=[];for(const r of t){const i=ju[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const zu=Yr({prefix:"\u{1F680}",name:"base256emoji",encode:$u,decode:Bu});var Hu=Object.freeze({__proto__:null,base256emoji:zu}),Ku=ps,ds=128,qu=127,Vu=~qu,Gu=Math.pow(2,31);function ps(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Gu;)e[r++]=t&255|ds,t/=128;for(;t&Vu;)e[r++]=t&255|ds,t>>>=7;return e[r]=t|0,ps.bytes=r-i+1,e}var Wu=$i,ku=128,gs=127;function $i(t,i){var r=0,i=i||0,n=0,s=i,u,c=t.length;do{if(s>=c)throw $i.bytes=0,new RangeError("Could not decode varint");u=t[s++],r+=n<28?(u&gs)<<n:(u&gs)*Math.pow(2,n),n+=7}while(u>=ku);return $i.bytes=s-i,r}var Yu=Math.pow(2,7),Ju=Math.pow(2,14),Xu=Math.pow(2,21),Zu=Math.pow(2,28),Qu=Math.pow(2,35),eh=Math.pow(2,42),th=Math.pow(2,49),rh=Math.pow(2,56),ih=Math.pow(2,63),nh=function(t){return t<Yu?1:t<Ju?2:t<Xu?3:t<Zu?4:t<Qu?5:t<eh?6:t<th?7:t<rh?8:t<ih?9:10},sh={encode:Ku,decode:Wu,encodingLength:nh},vs=sh;const ys=(t,e,r=0)=>(vs.encode(t,e,r),e),_s=t=>vs.encodingLength(t),Bi=(t,e)=>{const r=e.byteLength,i=_s(t),n=i+_s(r),s=new Uint8Array(n+r);return ys(t,s,0),ys(r,s,i),s.set(e,n),new oh(t,r,e,s)};class oh{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 ah(t,e,r);class ah{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?Bi(this.code,r):r.then(i=>Bi(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)),ch=bs({name:"sha2-256",code:18,encode:ms("SHA-256")}),uh=bs({name:"sha2-512",code:19,encode:ms("SHA-512")});var hh=Object.freeze({__proto__:null,sha256:ch,sha512:uh});const ws=0,fh="identity",Es=hs;var lh=Object.freeze({__proto__:null,identity:{code:ws,name:fh,encode:Es,digest:t=>Bi(ws,Es(t))}});new TextEncoder,new TextDecoder;const Ds={...ou,...cu,...hu,...lu,...gu,...Su,...Iu,...Lu,...Uu,...Hu};({...hh,...lh});function xs(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Ss=xs("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),zi=xs("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=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Os={utf8:Ss,"utf-8":Ss,hex:Ds.base16,latin1:zi,ascii:zi,binary:zi,...Ds};function ht(t,e="utf8"){const r=Os[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function ft(t,e="utf8"){const r=Os[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var As=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))},dh=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),ph=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),gh=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}(),vh=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),yh=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),_h=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,bh=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Is=3,mh=[["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",_h]],Cs=[["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 wh(t){return t?Ts(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new yh:typeof navigator<"u"?Ts(navigator.userAgent):xh()}function Eh(t){return t!==""&&mh.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 Ts(t){var e=Eh(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new vh;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Is&&(n=As(As([],n,!0),Sh(Is-n.length),!0)):n=[];var s=n.join("."),u=Dh(t),c=bh.exec(t);return c&&c[1]?new gh(r,s,u,c[1]):new dh(r,s,u)}function Dh(t){for(var e=0,r=Cs.length;e<r;e++){var i=Cs[e],n=i[0],s=i[1],u=s.exec(t);if(u)return n}return null}function xh(){var t=typeof process<"u"&&process.version;return t?new ph(process.version.slice(1)):null}function Sh(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Ie={},Ls={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.delay=void 0;function Oh(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Jr.delay=Oh;var sr={},Hi={},or={};Object.defineProperty(or,"__esModule",{value:!0}),or.ONE_THOUSAND=or.ONE_HUNDRED=void 0,or.ONE_HUNDRED=100,or.ONE_THOUSAND=1e3;var Ns={};(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})(Ns),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(or,t),r(Ns,t)}(Hi),Object.defineProperty(sr,"__esModule",{value:!0}),sr.fromMiliseconds=sr.toMiliseconds=void 0;const Ps=Hi;function Ah(t){return t*Ps.ONE_THOUSAND}sr.toMiliseconds=Ah;function Ih(t){return Math.floor(t/Ps.ONE_THOUSAND)}sr.fromMiliseconds=Ih,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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),r(sr,t)}(Ls);var wr={};Object.defineProperty(wr,"__esModule",{value:!0}),wr.Watch=void 0;class Rs{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}}wr.Watch=Rs,wr.default=Rs;var Fs={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.IWatch=void 0;class Ch{}Xr.IWatch=Ch,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(Xr,t)}(Fs),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(Ls,t),r(wr,t),r(Fs,t),r(Hi,t)}(Ie);var xe={};Object.defineProperty(xe,"__esModule",{value:!0}),xe.getLocalStorage=xe.getLocalStorageOrThrow=xe.getCrypto=xe.getCryptoOrThrow=Ms=xe.getLocation=xe.getLocationOrThrow=Ki=xe.getNavigator=xe.getNavigatorOrThrow=Us=xe.getDocument=xe.getDocumentOrThrow=xe.getFromWindowOrThrow=xe.getFromWindow=void 0;function kt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}xe.getFromWindow=kt;function ar(t){const e=kt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}xe.getFromWindowOrThrow=ar;function Th(){return ar("document")}xe.getDocumentOrThrow=Th;function Lh(){return kt("document")}var Us=xe.getDocument=Lh;function Nh(){return ar("navigator")}xe.getNavigatorOrThrow=Nh;function Ph(){return kt("navigator")}var Ki=xe.getNavigator=Ph;function Rh(){return ar("location")}xe.getLocationOrThrow=Rh;function Fh(){return kt("location")}var Ms=xe.getLocation=Fh;function Uh(){return ar("crypto")}xe.getCryptoOrThrow=Uh;function Mh(){return kt("crypto")}xe.getCrypto=Mh;function jh(){return ar("localStorage")}xe.getLocalStorageOrThrow=jh;function $h(){return kt("localStorage")}xe.getLocalStorage=$h;var qi={};Object.defineProperty(qi,"__esModule",{value:!0});var js=qi.getWindowMetadata=void 0;const $s=xe;function Bh(){let t,e;try{t=$s.getDocumentOrThrow(),e=$s.getLocationOrThrow()}catch{return null}function r(){const E=t.getElementsByTagName("link"),L=[];for(let w=0;w<E.length;w++){const b=E[w],F=b.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let O=e.protocol+"//"+e.host;if(y.indexOf("/")===0)O+=y;else{const N=e.pathname.split("/");N.pop(),O+=N.join("/")+"/"+y}L.push(O)}else if(y.indexOf("//")===0){const O=e.protocol+y;L.push(O)}else L.push(y)}}return L}function i(...E){const L=t.getElementsByTagName("meta");for(let w=0;w<L.length;w++){const b=L[w],F=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?E.includes(y):!1);if(F.length&&F){const y=b.getAttribute("content");if(y)return y}}return""}function n(){let E=i("name","og:site_name","og:title","twitter:title");return E||(E=t.title),E}function s(){return i("description","og:description","twitter:description","keywords")}const u=n(),c=s(),h=e.origin,l=r();return{description:c,url:h,icons:l,name:u}}js=qi.getWindowMetadata=Bh;var Er={},zh=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 Vi(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([],Vi(r),Vi(i))}function Hh(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(zs),r=1;r<e.length;r++)t=Vi(e,r).join(""),e=t.match(zs);return t}}function Kh(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=Hh(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 u=n[s];t=t.replace(new RegExp(u,"g"),e[u])}return t}var qh=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 Kh(t)}},Vh=(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)]};(function(t){const e=zh,r=qh,i=Vh,n=y=>y==null;function s(y){switch(y.arrayFormat){case"index":return O=>(N,C)=>{const S=N.length;return C===void 0||y.skipNull&&C===null||y.skipEmptyString&&C===""?N:C===null?[...N,[h(O,y),"[",S,"]"].join("")]:[...N,[h(O,y),"[",h(S,y),"]=",h(C,y)].join("")]};case"bracket":return O=>(N,C)=>C===void 0||y.skipNull&&C===null||y.skipEmptyString&&C===""?N:C===null?[...N,[h(O,y),"[]"].join("")]:[...N,[h(O,y),"[]=",h(C,y)].join("")];case"comma":case"separator":return O=>(N,C)=>C==null||C.length===0?N:N.length===0?[[h(O,y),"=",h(C,y)].join("")]:[[N,h(C,y)].join(y.arrayFormatSeparator)];default:return O=>(N,C)=>C===void 0||y.skipNull&&C===null||y.skipEmptyString&&C===""?N:C===null?[...N,h(O,y)]:[...N,[h(O,y),"=",h(C,y)].join("")]}}function u(y){let O;switch(y.arrayFormat){case"index":return(N,C,S)=>{if(O=/\[(\d*)\]$/.exec(N),N=N.replace(/\[\d*\]$/,""),!O){S[N]=C;return}S[N]===void 0&&(S[N]={}),S[N][O[1]]=C};case"bracket":return(N,C,S)=>{if(O=/(\[\])$/.exec(N),N=N.replace(/\[\]$/,""),!O){S[N]=C;return}if(S[N]===void 0){S[N]=[C];return}S[N]=[].concat(S[N],C)};case"comma":case"separator":return(N,C,S)=>{const m=typeof C=="string"&&C.split("").indexOf(y.arrayFormatSeparator)>-1?C.split(y.arrayFormatSeparator).map(o=>l(o,y)):C===null?C:l(C,y);S[N]=m};default:return(N,C,S)=>{if(S[N]===void 0){S[N]=C;return}S[N]=[].concat(S[N],C)}}}function c(y){if(typeof y!="string"||y.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function h(y,O){return O.encode?O.strict?e(y):encodeURIComponent(y):y}function l(y,O){return O.decode?r(y):y}function p(y){return Array.isArray(y)?y.sort():typeof y=="object"?p(Object.keys(y)).sort((O,N)=>Number(O)-Number(N)).map(O=>y[O]):y}function E(y){const O=y.indexOf("#");return O!==-1&&(y=y.slice(0,O)),y}function L(y){let O="";const N=y.indexOf("#");return N!==-1&&(O=y.slice(N)),O}function w(y){y=E(y);const O=y.indexOf("?");return O===-1?"":y.slice(O+1)}function b(y,O){return O.parseNumbers&&!Number.isNaN(Number(y))&&typeof y=="string"&&y.trim()!==""?y=Number(y):O.parseBooleans&&y!==null&&(y.toLowerCase()==="true"||y.toLowerCase()==="false")&&(y=y.toLowerCase()==="true"),y}function F(y,O){O=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},O),c(O.arrayFormatSeparator);const N=u(O),C=Object.create(null);if(typeof y!="string"||(y=y.trim().replace(/^[?#&]/,""),!y))return C;for(const S of y.split("&")){let[T,m]=i(O.decode?S.replace(/\+/g," "):S,"=");m=m===void 0?null:["comma","separator"].includes(O.arrayFormat)?m:l(m,O),N(l(T,O),m,C)}for(const S of Object.keys(C)){const T=C[S];if(typeof T=="object"&&T!==null)for(const m of Object.keys(T))T[m]=b(T[m],O);else C[S]=b(T,O)}return O.sort===!1?C:(O.sort===!0?Object.keys(C).sort():Object.keys(C).sort(O.sort)).reduce((S,T)=>{const m=C[T];return Boolean(m)&&typeof m=="object"&&!Array.isArray(m)?S[T]=p(m):S[T]=m,S},Object.create(null))}t.extract=w,t.parse=F,t.stringify=(y,O)=>{if(!y)return"";O=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},O),c(O.arrayFormatSeparator);const N=m=>O.skipNull&&n(y[m])||O.skipEmptyString&&y[m]==="",C=s(O),S={};for(const m of Object.keys(y))N(m)||(S[m]=y[m]);const T=Object.keys(S);return O.sort!==!1&&T.sort(O.sort),T.map(m=>{const o=y[m];return o===void 0?"":o===null?h(m,O):Array.isArray(o)?o.reduce(C(m),[]).join("&"):h(m,O)+"="+h(o,O)}).filter(m=>m.length>0).join("&")},t.parseUrl=(y,O)=>{O=Object.assign({decode:!0},O);const[N,C]=i(y,"#");return Object.assign({url:N.split("?")[0]||"",query:F(w(y),O)},O&&O.parseFragmentIdentifier&&C?{fragmentIdentifier:l(C,O)}:{})},t.stringifyUrl=(y,O)=>{O=Object.assign({encode:!0,strict:!0},O);const N=E(y.url).split("?")[0]||"",C=t.extract(y.url),S=t.parse(C,{sort:!1}),T=Object.assign(S,y.query);let m=t.stringify(T,O);m&&(m=`?${m}`);let o=L(y.url);return y.fragmentIdentifier&&(o=`#${h(y.fragmentIdentifier,O)}`),`${N}${m}${o}`}})(Er);const Gh={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Ks=":";function Wh(t){const{namespace:e,reference:r}=t;return[e,r].join(Ks)}function kh(t){const[e,r,i]=t.split(Ks);return{namespace:e,reference:r,address:i}}function Yh(t,e){const r=[];return t.forEach(i=>{const n=e(i);r.includes(n)||r.push(n)}),r}function Jh(t){const{namespace:e,reference:r}=kh(t);return Wh({namespace:e,reference:r})}function Xh(t){return Yh(t,Jh)}function Gi(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 Wi(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...Xh(n.accounts))}),r}function Zh(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",lt="base16",ki="base64pad",Yi="utf8",Vs=0,Dr=1,Qh=0,Gs=1,Ji=12,Xi=32;function ef(){const t=Mi.generateKeyPair();return{privateKey:ft(t.secretKey,lt),publicKey:ft(t.publicKey,lt)}}function Zi(){const t=nr.randomBytes(Xi);return ft(t,lt)}function tf(t,e){const r=Mi.sharedKey(ht(t,lt),ht(e,lt)),i=new Mc(kr.SHA256,r).expand(Xi);return ft(i,lt)}function rf(t){const e=kr.hash(ht(t,lt));return ft(e,lt)}function Zr(t){const e=kr.hash(ht(t,Yi));return ft(e,lt)}function nf(t){return ht(`${t}`,qs)}function Qr(t){return Number(ft(t,qs))}function sf(t){const e=nf(typeof t.type<"u"?t.type:Vs);if(Qr(e)===Dr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ht(t.senderPublicKey,lt):void 0,i=typeof t.iv<"u"?ht(t.iv,lt):nr.randomBytes(Ji),n=new Ai.ChaCha20Poly1305(ht(t.symKey,lt)).seal(i,ht(t.message,Yi));return af({type:e,sealed:n,iv:i,senderPublicKey:r})}function of(t){const e=new Ai.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:i}=Ws(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return ft(n,Yi)}function af(t){if(Qr(t.type)===Dr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(ji([t.type,t.senderPublicKey,t.iv,t.sealed]),ki)}return ft(ji([t.type,t.iv,t.sealed]),ki)}function Ws(t){const e=ht(t,ki),r=e.slice(Qh,Gs),i=Gs;if(Qr(r)===Dr){const c=i+Xi,h=c+Ji,l=e.slice(i,c),p=e.slice(c,h),E=e.slice(h);return{type:r,sealed:E,iv:p,senderPublicKey:l}}const n=i+Ji,s=e.slice(i,n),u=e.slice(n);return{type:r,sealed:u,iv:s}}function cf(t,e){const r=Ws(t);return ks({type:Qr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function ks(t){const e=t?.type||Vs;if(e===Dr){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 Ys(t){return t.type===Dr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var uf=Object.defineProperty,Js=Object.getOwnPropertySymbols,hf=Object.prototype.hasOwnProperty,ff=Object.prototype.propertyIsEnumerable,Xs=(t,e,r)=>e in t?uf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zs=(t,e)=>{for(var r in e||(e={}))hf.call(e,r)&&Xs(t,r,e[r]);if(Js)for(var r of Js(e))ff.call(e,r)&&Xs(t,r,e[r]);return t};const lf="ReactNative",xr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},df="js";function Qs(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function pf(){return!Us()&&!!Ki()&&navigator.product===lf}function gf(){return!Qs()&&!!Ki()}function vf(){return pf()?xr.reactNative:Qs()?xr.node:gf()?xr.browser:xr.unknown}function yf(t,e){let r=Er.parse(t);return r=Zs(Zs({},r),e),t=Er.stringify(r),t}function _f(){return js()||{name:"",description:"",url:"",icons:[""]}}function bf(){const t=wh();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 mf(){var t;const e=vf();return e===xr.browser?[e,((t=Ms())==null?void 0:t.host)||"unknown"].join(":"):e}function wf(t,e,r){const i=bf(),n=mf();return[[t,e].join("-"),[df,r].join("-"),i,n].join("/")}function Ef({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s}){const u=r.split("?"),c=wf(t,e,i),h={auth:n,ua:c,projectId:s},l=yf(u[1]||"",h);return u[0]+"?"+l}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function eo(t){return Object.fromEntries(t.entries())}function to(t){return new Map(Object.entries(t))}function cr(t,e){return Ie.fromMiliseconds((e||Date.now())+Ie.toMiliseconds(t))}function Yt(t){return Ie.fromMiliseconds(Date.now())>=Ie.toMiliseconds(t)}function Jt(){const t=Ie.toMiliseconds(Ie.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 ro(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 Df(t){return ro("topic",t)}function xf(t){return ro("id",t)}function Sf(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 Re(t,e){return`${t}${e?`:${e}`:""}`}const Of="iridium";function Qi(t){return t?.relay||{protocol:Of}}function en(t){const e=Gh[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Af=Object.defineProperty,io=Object.getOwnPropertySymbols,If=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,Tf=(t,e)=>{for(var r in e||(e={}))If.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,""),u=t[n];r[s]=u}}),r}function Nf(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):"",u=Er.parse(s);return{protocol:i,topic:n[0],version:parseInt(n[1],10),symKey:u.symKey,relay:Lf(u)}}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 Rf(t){return`${t.protocol}:${t.topic}@${t.version}?`+Er.stringify(Tf({symKey:t.symKey},Pf(t.relay)))}function At(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Ff(t){const e=[];return Object.values(t).forEach(r=>{e.push(...At(r.accounts)),r.extension&&r.extension.forEach(i=>{e.push(...At(i.accounts))})}),e}function Uf(t,e){const r=[];return Object.values(t).forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.methods),i.extension&&i.extension.forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.methods)})}),r}function Mf(t,e){const r=[];return Object.values(t).forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.events),i.extension&&i.extension.forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.events)})}),r}const jf={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}},$f={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function G(t,e){const{message:r,code:i}=$f[t];return{message:e?`${r} ${e}`:r,code:i}}function rt(t,e){const{message:r,code:i}=jf[t];return{message:e?`${r} ${e}`:r,code:i}}function Sr(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 Et(t){return typeof t>"u"}function ot(t,e){return e&&Et(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function oo(t,e){return e&&Et(t)?!0:typeof t=="number"&&!isNaN(t)}function Bf(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return dt(n,i)?(i.forEach(u=>{const{accounts:c,methods:h,events:l,extension:p}=t.namespaces[u],E=At(c),L=r[u];(!dt(L.chains,E)||!dt(L.methods,h)||!dt(L.events,l))&&(s=!1),s&&p&&p.forEach(w=>{var b;const{accounts:F,methods:y,events:O}=w,N=At(F);(b=L.extension)!=null&&b.find(C=>dt(C.chains,N)&&dt(C.methods,y)&&dt(C.events,O))||(s=!1)})}),s):!1}function tn(t){return ot(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function zf(t){if(ot(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&tn(r)}}return!1}function Hf(t){if(ot(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function Kf(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function qf(t){return t?.topic}function Vf(t,e){let r=null;return ot(t?.publicKey,!1)||(r=G("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function rn(t,e){let r=null;return Et(t?.extension)||(!Sr(t.extension)||!t.extension.length)&&(r=G("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function ao(t){let e=!0;return Sr(t)?t.length&&(e=t.every(r=>ot(r,!1))):e=!1,e}function co(t,e,r){let i=null;return Sr(e)?e.forEach(n=>{i||(!tn(n)||!n.includes(t))&&(i=rt("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):i=rt("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),i}function Gf(t,e){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const s=co(i,n?.chains,`${e} requiredNamespace`),u=rn(n,e);s?r=s:u?r=u:n.extension&&n.extension.forEach(c=>{if(r)return;const h=co(i,c.chains,`${e} extension`);h&&(r=h)})}),r}function uo(t,e){let r=null;return Sr(t)?t.forEach(i=>{r||zf(i)||(r=rt("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=rt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Wf(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=uo(i?.accounts,`${e} namespace`),s=rn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(u=>{if(r)return;const c=uo(u.accounts,`${e} extension`);c&&(r=c)})}),r}function ho(t,e){let r=null;return ao(t?.methods)?ao(t?.events)||(r=rt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=rt("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=ho(i,`${e}, namespace`),s=rn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(u=>{if(r)return;const c=ho(u,`${e}, extension`);c&&(r=c)})}),r}function kf(t,e){let r=null;if(t&&so(t)){const i=fo(t,e);i&&(r=i);const n=Gf(t,e);n&&(r=n)}else r=G("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function nn(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=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function lo(t){return ot(t.protocol,!0)}function Yf(t,e){let r=!1;return e&&!t?r=!0:t&&Sr(t)&&t.length&&t.forEach(i=>{r=lo(i)}),r}function Jf(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function Xf(t){return!(!t||typeof t!="object"||!t.code||!oo(t.code,!1)||!t.message||!ot(t.message,!1))}function Zf(t){return!(Et(t)||!ot(t.method,!1))}function Qf(t){return!(Et(t)||Et(t.result)&&Et(t.error)||!oo(t.id,!1)||!ot(t.jsonrpc,!1))}function el(t){return!(Et(t)||!ot(t.name,!1))}function po(t,e){return!(!tn(e)||!Ff(t).includes(e))}function tl(t,e,r){return ot(r,!1)?Uf(t,e).includes(r):!1}function rl(t,e,r){return ot(r,!1)?Mf(t,e).includes(r):!1}function go(t,e,r){let i=null;const n=Object.keys(t),s=Object.keys(e);return dt(n,s)?n.forEach(u=>{var c;if(i)return;const h=t[u].chains,l=At(e[u].accounts);dt(h,l)?dt(t[u].methods,e[u].methods)?dt(t[u].events,e[u].events)?t[u].extension&&!e[u].extension?i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${u}`):t[u].extension&&e[u].extension&&((c=t[u].extension)==null||c.forEach(({methods:p,events:E,chains:L})=>{var w;i||(w=e[u].extension)!=null&&w.find(b=>{const F=At(b.accounts);return dt(L,F)&&dt(E,b.events)&&dt(p,b.methods)})||(i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${u}`))})):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${u}`):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${u}`):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${u}`)}):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),i}function il(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var nl=sl;function sl(t,e,r){var i=r&&r.stringify||il,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var u=new Array(s);u[0]=i(t);for(var c=1;c<s;c++)u[c]=i(e[c]);return u.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var l="",p=1-n,E=-1,L=t&&t.length||0,w=0;w<L;){if(t.charCodeAt(w)===37&&w+1<L){switch(E=E>-1?E:0,t.charCodeAt(w+1)){case 100:case 102:if(p>=h||e[p]==null)break;E<w&&(l+=t.slice(E,w)),l+=Number(e[p]),E=w+2,w++;break;case 105:if(p>=h||e[p]==null)break;E<w&&(l+=t.slice(E,w)),l+=Math.floor(Number(e[p])),E=w+2,w++;break;case 79:case 111:case 106:if(p>=h||e[p]===void 0)break;E<w&&(l+=t.slice(E,w));var b=typeof e[p];if(b==="string"){l+="'"+e[p]+"'",E=w+2,w++;break}if(b==="function"){l+=e[p].name||"<anonymous>",E=w+2,w++;break}l+=i(e[p]),E=w+2,w++;break;case 115:if(p>=h)break;E<w&&(l+=t.slice(E,w)),l+=String(e[p]),E=w+2,w++;break;case 37:E<w&&(l+=t.slice(E,w)),l+="%",E=w+2,w++,p--;break}++p}++w}return E===-1?t:(E<L&&(l+=t.slice(E)),l)}var vo=nl,sn=It,Or=pl().console||{},ol={mapHttpRequest:ti,mapHttpResponse:ti,wrapRequestSerializer:an,wrapResponseSerializer:an,wrapErrorSerializer:an,req:ti,res:ti,err:hl};function It(t){t=t||{},t.browser=t.browser||{};var e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");var r=t.browser.write||Or;t.browser.write&&(t.browser.asObject=!0);var i=t.serializers||{},n=Array.isArray(t.browser.serialize)?t.browser.serialize.filter(function(b){return b!=="!stdSerializers.err"}):t.browser.serialize===!0?Object.keys(i):!1,s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);var u=["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");var c=t.level||"info",h=Object.create(r);h.log||(h.log=Ar),Object.defineProperty(h,"levelVal",{get:p}),Object.defineProperty(h,"level",{get:E,set:L});var l={transmit:e,serialize:n,asObject:t.browser.asObject,levels:u,timestamp:fl(t)};h.levels=It.levels,h.level=c,h.setMaxListeners=h.getMaxListeners=h.emit=h.addListener=h.on=h.prependListener=h.once=h.prependOnceListener=h.removeListener=h.removeAllListeners=h.listeners=h.listenerCount=h.eventNames=h.write=h.flush=Ar,h.serializers=i,h._serialize=n,h._stdErrSerialize=s,h.child=w,e&&(h._logEvent=on());function p(){return this.level==="silent"?1/0:this.levels.values[this.level]}function E(){return this._level}function L(b){if(b!=="silent"&&!this.levels.values[b])throw Error("unknown level "+b);this._level=b,ur(l,h,"error","log"),ur(l,h,"fatal","error"),ur(l,h,"warn","error"),ur(l,h,"info","log"),ur(l,h,"debug","log"),ur(l,h,"trace","log")}function w(b){if(!b)throw new Error("missing bindings for child Pino");var F=b.serializers;if(n&&F){var y=Object.assign({},i,F),O=t.browser.serialize===!0?Object.keys(y):n;delete b.serializers,ei([b],O,y,this._stdErrSerialize)}function N(C){this._childLevel=(C._childLevel|0)+1,this.error=hr(C,b,"error"),this.fatal=hr(C,b,"fatal"),this.warn=hr(C,b,"warn"),this.info=hr(C,b,"info"),this.debug=hr(C,b,"debug"),this.trace=hr(C,b,"trace"),y&&(this.serializers=y,this._serialize=O),e&&(this._logEvent=on([].concat(C._logEvent.bindings,b)))}return N.prototype=this,new N(this)}return h}It.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"}},It.stdSerializers=ol,It.stdTimeFunctions=Object.assign({},{nullTime:yo,epochTime:_o,unixTime:ll,isoTime:dl});function ur(t,e,r,i){var n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ar:n[r]?n[r]:Or[r]||Or[i]||Ar,al(t,e,r)}function al(t,e,r){!t.transmit&&e[r]===Ar||(e[r]=function(i){return function(){for(var s=t.timestamp(),u=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Or?Or:this,h=0;h<u.length;h++)u[h]=arguments[h];if(t.serialize&&!t.asObject&&ei(u,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(c,cl(this,r,u,s)):i.apply(c,u),t.transmit){var l=t.transmit.level||e.level,p=It.levels.values[l],E=It.levels.values[r];if(E<p)return;ul(this,{ts:s,methodLevel:r,methodValue:E,transmitLevel:l,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},u)}}}(e[r]))}function cl(t,e,r,i){t._serialize&&ei(r,t._serialize,t.serializers,t._stdErrSerialize);var n=r.slice(),s=n[0],u={};i&&(u.time=i),u.level=It.levels.values[e];var c=(t._childLevel|0)+1;if(c<1&&(c=1),s!==null&&typeof s=="object"){for(;c--&&typeof n[0]=="object";)Object.assign(u,n.shift());s=n.length?vo(n.shift(),n):void 0}else typeof s=="string"&&(s=vo(n.shift(),n));return s!==void 0&&(u.msg=s),u}function ei(t,e,r,i){for(var n in t)if(i&&t[n]instanceof Error)t[n]=It.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(var s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function hr(t,e,r){return function(){var 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 ul(t,e,r){var i=e.send,n=e.ts,s=e.methodLevel,u=e.methodValue,c=e.val,h=t._logEvent.bindings;ei(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(l){return h.indexOf(l)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=u,i(s,t._logEvent,c),t._logEvent=on(h)}function on(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function hl(t){var e={type:t.constructor.name,msg:t.message,stack:t.stack};for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}function fl(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?yo:_o}function ti(){return{}}function an(t){return t}function Ar(){}function yo(){return!1}function _o(){return Date.now()}function ll(){return Math.round(Date.now()/1e3)}function dl(){return new Date(Date.now()).toISOString()}function pl(){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 ri={};/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */var cn=function(t,e){return cn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},cn(t,e)};function gl(t,e){cn(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var un=function(){return un=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},un.apply(this,arguments)};function vl(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 yl(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(u=t[c])&&(s=(n<3?u(s):n>3?u(e,r,s):u(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function _l(t,e){return function(r,i){e(r,i,t)}}function bl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ml(t,e,r,i){function n(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function c(p){try{l(i.next(p))}catch(E){u(E)}}function h(p){try{l(i.throw(p))}catch(E){u(E)}}function l(p){p.done?s(p.value):n(p.value).then(c,h)}l((i=i.apply(t,e||[])).next())})}function wl(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(l){return function(p){return h([l,p])}}function h(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(p){l=[6,p],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function El(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Dl(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function hn(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 bo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],u;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(c){u={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return s}function xl(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bo(arguments[e]));return t}function Sl(){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],u=0,c=s.length;u<c;u++,n++)i[n]=s[u];return i}function Ir(t){return this instanceof Ir?(this.v=t,this):new Ir(t)}function Ol(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},u("next"),u("throw"),u("return"),n[Symbol.asyncIterator]=function(){return this},n;function u(L){i[L]&&(n[L]=function(w){return new Promise(function(b,F){s.push([L,w,b,F])>1||c(L,w)})})}function c(L,w){try{h(i[L](w))}catch(b){E(s[0][3],b)}}function h(L){L.value instanceof Ir?Promise.resolve(L.value.v).then(l,p):E(s[0][2],L)}function l(L){c("next",L)}function p(L){c("throw",L)}function E(L,w){L(w),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Al(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(u){return(r=!r)?{value:Ir(t[n](u)),done:n==="return"}:s?s(u):u}:s}}function Il(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 hn=="function"?hn(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(u){return new Promise(function(c,h){u=t[s](u),n(c,h,u.done,u.value)})}}function n(s,u,c,h){Promise.resolve(h).then(function(l){s({value:l,done:c})},u)}}function Cl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Tl(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Ll(t){return t&&t.__esModule?t:{default:t}}function Nl(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Pl(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var Rl=Object.freeze({__proto__:null,__extends:gl,get __assign(){return un},__rest:vl,__decorate:yl,__param:_l,__metadata:bl,__awaiter:ml,__generator:wl,__createBinding:El,__exportStar:Dl,__values:hn,__read:bo,__spread:xl,__spreadArrays:Sl,__await:Ir,__asyncGenerator:Ol,__asyncDelegator:Al,__asyncValues:Il,__makeTemplateObject:Cl,__importStar:Tl,__importDefault:Ll,__classPrivateFieldGet:Nl,__classPrivateFieldSet:Pl}),fn=bi(Rl),ii={exports:{}},mo;function Fl(){return mo||(mo=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?ii.exports=localStorage:ii.exports=new e}()),ii.exports}var Cr={},wo;function Eo(){if(wo)return Cr;wo=1,Object.defineProperty(Cr,"__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}}Cr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(i,n)=>typeof n>"u"?null:n)}return Cr.safeJsonStringify=e,Cr}var ln={},Tr={},Do;function Ul(){if(Do)return Tr;Do=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.IKeyValueStorage=void 0;class t{}return Tr.IKeyValueStorage=t,Tr}var Lr={},xo;function Ml(){if(xo)return Lr;xo=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.parseEntry=void 0;const t=Eo();function e(r){var i;return[r[0],t.safeJsonParse((i=r[1])!==null&&i!==void 0?i:"")]}return Lr.parseEntry=e,Lr}var So;function jl(){return So||(So=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=fn;e.__exportStar(Ul(),t),e.__exportStar(Ml(),t)}(ln)),ln}Object.defineProperty(ri,"__esModule",{value:!0}),ri.KeyValueStorage=void 0;const fr=fn,$l=fr.__importDefault(Fl()),Oo=Eo(),Bl=jl();class Ao{constructor(){this.localStorage=$l.default}getKeys(){return fr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return fr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Bl.parseEntry)})}getItem(e){return fr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Oo.safeJsonParse(r)})}setItem(e,r){return fr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Oo.safeJsonStringify(r))})}removeItem(e){return fr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}ri.KeyValueStorage=Ao;var zl=ri.default=Ao,Nr={},ni={},dn={},si={};class Xt{}var Hl=Object.freeze({__proto__:null,IEvents:Xt}),Kl=bi(Hl);Object.defineProperty(si,"__esModule",{value:!0}),si.IHeartBeat=void 0;const ql=Kl;class Vl extends ql.IEvents{constructor(e){super()}}si.IHeartBeat=Vl,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(si,t)}(dn);var pn={},lr={};Object.defineProperty(lr,"__esModule",{value:!0}),lr.HEARTBEAT_EVENTS=lr.HEARTBEAT_INTERVAL=void 0;const Gl=Ie;lr.HEARTBEAT_INTERVAL=Gl.FIVE_SECONDS,lr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(lr,t)}(pn);var gn=Z&&Z.__awaiter||function(t,e,r,i){function n(s){return s instanceof r?s:new r(function(u){u(s)})}return new(r||(r=Promise))(function(s,u){function c(p){try{l(i.next(p))}catch(E){u(E)}}function h(p){try{l(i.throw(p))}catch(E){u(E)}}function l(p){p.done?s(p.value):n(p.value).then(c,h)}l((i=i.apply(t,e||[])).next())})};Object.defineProperty(ni,"__esModule",{value:!0}),ni.HeartBeat=void 0;const Wl=gr,kl=Ie,Yl=dn,vn=pn;class yn extends Yl.IHeartBeat{constructor(e){super(e),this.events=new Wl.EventEmitter,this.interval=vn.HEARTBEAT_INTERVAL,this.interval=e?.interval||vn.HEARTBEAT_INTERVAL}static init(e){return gn(this,void 0,void 0,function*(){const r=new yn(e);return yield r.init(),r})}init(){return gn(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 gn(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),kl.toMiliseconds(this.interval))})}pulse(){this.events.emit(vn.HEARTBEAT_EVENTS.pulse)}}ni.HeartBeat=yn,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,u){u===void 0&&(u=s),Object.defineProperty(i,u,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,u){u===void 0&&(u=s),i[u]=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(ni,t),r(dn,t),r(pn,t)}(Nr);var Se={},Zt={},Io;function Co(){return Io||(Io=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.PINO_CUSTOM_CONTEXT_KEY=Zt.PINO_LOGGER_DEFAULTS=void 0,Zt.PINO_LOGGER_DEFAULTS={level:"info"},Zt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Zt}var ct={},To;function Jl(){if(To)return ct;To=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=Co();function e(c){return Object.assign(Object.assign({},c),{level:c?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(c,h=t.PINO_CUSTOM_CONTEXT_KEY){return c[h]||""}ct.getBrowserLoggerContext=r;function i(c,h,l=t.PINO_CUSTOM_CONTEXT_KEY){return c[l]=h,c}ct.setBrowserLoggerContext=i;function n(c,h=t.PINO_CUSTOM_CONTEXT_KEY){let l="";return typeof c.bindings>"u"?l=r(c,h):l=c.bindings().context||"",l}ct.getLoggerContext=n;function s(c,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const p=n(c,l);return p.trim()?`${p}/${h}`:h}ct.formatChildLoggerContext=s;function u(c,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const p=s(c,h,l),E=c.child({context:p});return i(E,p,l)}return ct.generateChildLogger=u,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=fn;e.__exportStar(Co(),t),e.__exportStar(Jl(),t)})(Se);class Xl extends Xt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Zl extends Xt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class Ql{constructor(e,r){this.logger=e,this.core=r}}class ed extends Xt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class td extends Xt{constructor(e){super()}}class rd{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class id extends Xt{constructor(e,r){super(),this.relayer=e,this.logger=r}}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var nd=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!sd(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,u;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 c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(r=this._events[t],Lo(r))return!1;if(Rt(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),u=r.slice(),i=u.length,s=0;s<i;s++)u[s].apply(this,n);return!0},Ke.prototype.addListener=function(t,e){var r;if(!Rt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Rt(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&&(Lo(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(!Rt(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(!Rt(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||Rt(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},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],Rt(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=[]:Rt(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(Rt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Rt(t){return typeof t=="function"}function sd(t){return typeof t=="number"}function Pr(t){return typeof t=="object"&&t!==null}function Lo(t){return t===void 0}class od{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class ov extends nd.EventEmitter{constructor(){super()}}class ad{constructor(e){this.client=e}}class cd extends Xt{constructor(e,r){super(),this.core=e,this.logger=r}}var _n={},No={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},c.prototype.update=function(h,l){if(l===void 0&&(l=h.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var p=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&l>0;)this._buffer[this._bufferLength++]=h[p++],l--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(p=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,p,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[p++],l--;return this},c.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,p=this._bufferLength,E=l/536870912|0,L=l<<3,w=l%128<112?128:256;this._buffer[p]=128;for(var b=p+1;b<w-8;b++)this._buffer[b]=0;e.writeUint32BE(E,this._buffer,w-8),e.writeUint32BE(L,this._buffer,w-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,w),this._finished=!0}for(var b=0;b<this.digestLength/8;b++)e.writeUint32BE(this._stateHi[b],h,b*8),e.writeUint32BE(this._stateLo[b],h,b*8+4);return this},c.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(h){return this._stateHi.set(h.stateHi),this._stateLo.set(h.stateLo),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},c}();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(c,h,l,p,E,L,w){for(var b=l[0],F=l[1],y=l[2],O=l[3],N=l[4],C=l[5],S=l[6],T=l[7],m=p[0],o=p[1],g=p[2],B=p[3],q=p[4],V=p[5],J=p[6],X=p[7],f,_,M,K,R,P,j,$;w>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+L;c[Q]=e.readUint32BE(E,H),h[Q]=e.readUint32BE(E,H+4)}for(var Q=0;Q<80;Q++){var ee=b,k=F,ae=y,I=O,A=N,D=C,a=S,v=T,z=m,Y=o,fe=g,ye=B,de=q,me=V,Fe=J,Te=X;if(f=T,_=X,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=(N>>>14|q<<32-14)^(N>>>18|q<<32-18)^(q>>>41-32|N<<32-(41-32)),_=(q>>>14|N<<32-14)^(q>>>18|N<<32-18)^(N>>>41-32|q<<32-(41-32)),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=N&C^~N&S,_=q&V^~q&J,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=n[Q*2],_=n[Q*2+1],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=c[Q%16],_=h[Q%16],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,M=j&65535|$<<16,K=R&65535|P<<16,f=M,_=K,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=(b>>>28|m<<32-28)^(m>>>34-32|b<<32-(34-32))^(m>>>39-32|b<<32-(39-32)),_=(m>>>28|b<<32-28)^(b>>>34-32|m<<32-(34-32))^(b>>>39-32|m<<32-(39-32)),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=b&F^b&y^F&y,_=m&o^m&g^o&g,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,v=j&65535|$<<16,Te=R&65535|P<<16,f=I,_=ye,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=M,_=K,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,I=j&65535|$<<16,ye=R&65535|P<<16,F=ee,y=k,O=ae,N=I,C=A,S=D,T=a,b=v,o=z,g=Y,B=fe,q=ye,V=de,J=me,X=Fe,m=Te,Q%16===15)for(var H=0;H<16;H++)f=c[H],_=h[H],R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=c[(H+9)%16],_=h[(H+9)%16],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,M=c[(H+1)%16],K=h[(H+1)%16],f=(M>>>1|K<<32-1)^(M>>>8|K<<32-8)^M>>>7,_=(K>>>1|M<<32-1)^(K>>>8|M<<32-8)^(K>>>7|M<<32-7),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,M=c[(H+14)%16],K=h[(H+14)%16],f=(M>>>19|K<<32-19)^(K>>>61-32|M<<32-(61-32))^M>>>6,_=(K>>>19|M<<32-19)^(M>>>61-32|K<<32-(61-32))^(K>>>6|M<<32-6),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,c[H]=j&65535|$<<16,h[H]=R&65535|P<<16}f=b,_=m,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[0],_=p[0],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[0]=b=j&65535|$<<16,p[0]=m=R&65535|P<<16,f=F,_=o,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[1],_=p[1],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[1]=F=j&65535|$<<16,p[1]=o=R&65535|P<<16,f=y,_=g,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[2],_=p[2],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[2]=y=j&65535|$<<16,p[2]=g=R&65535|P<<16,f=O,_=B,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[3],_=p[3],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[3]=O=j&65535|$<<16,p[3]=B=R&65535|P<<16,f=N,_=q,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[4],_=p[4],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[4]=N=j&65535|$<<16,p[4]=q=R&65535|P<<16,f=C,_=V,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[5],_=p[5],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[5]=C=j&65535|$<<16,p[5]=V=R&65535|P<<16,f=S,_=J,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[6],_=p[6],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[6]=S=j&65535|$<<16,p[6]=J=R&65535|P<<16,f=T,_=X,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[7],_=p[7],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[7]=T=j&65535|$<<16,p[7]=X=R&65535|P<<16,L+=128,w-=128}return L}function u(c){var h=new i;h.update(c);var l=h.digest();return h.clean(),l}t.hash=u})(No),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=No,i=pt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(I){var A=new Float64Array(16);if(I)for(var D=0;D<I.length;D++)A[D]=I[D];return A}var s=new Uint8Array(32);s[0]=9;var u=n(),c=n([1]),h=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),p=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),L=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(I,A){for(var D=0;D<16;D++)I[D]=A[D]|0}function b(I){for(var A=1,D=0;D<16;D++){var a=I[D]+A+65535;A=Math.floor(a/65536),I[D]=a-A*65536}I[0]+=A-1+37*(A-1)}function F(I,A,D){for(var a=~(D-1),v=0;v<16;v++){var z=a&(I[v]^A[v]);I[v]^=z,A[v]^=z}}function y(I,A){for(var D=n(),a=n(),v=0;v<16;v++)a[v]=A[v];b(a),b(a),b(a);for(var z=0;z<2;z++){D[0]=a[0]-65517;for(var v=1;v<15;v++)D[v]=a[v]-65535-(D[v-1]>>16&1),D[v-1]&=65535;D[15]=a[15]-32767-(D[14]>>16&1);var Y=D[15]>>16&1;D[14]&=65535,F(a,D,1-Y)}for(var v=0;v<16;v++)I[2*v]=a[v]&255,I[2*v+1]=a[v]>>8}function O(I,A){for(var D=0,a=0;a<32;a++)D|=I[a]^A[a];return(1&D-1>>>8)-1}function N(I,A){var D=new Uint8Array(32),a=new Uint8Array(32);return y(D,I),y(a,A),O(D,a)}function C(I){var A=new Uint8Array(32);return y(A,I),A[0]&1}function S(I,A){for(var D=0;D<16;D++)I[D]=A[2*D]+(A[2*D+1]<<8);I[15]&=32767}function T(I,A,D){for(var a=0;a<16;a++)I[a]=A[a]+D[a]}function m(I,A,D){for(var a=0;a<16;a++)I[a]=A[a]-D[a]}function o(I,A,D){var a,v,z=0,Y=0,fe=0,ye=0,de=0,me=0,Fe=0,Te=0,ve=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ie=0,_e=0,be=0,Ee=0,De=0,we=0,xt=0,Lt=0,qt=0,gt=0,er=0,zr=0,li=0,Ue=D[0],Le=D[1],Me=D[2],je=D[3],$e=D[4],Ne=D[5],We=D[6],ke=D[7],Ye=D[8],Je=D[9],Xe=D[10],ze=D[11],Be=D[12],Ae=D[13],Ze=D[14],Qe=D[15];a=A[0],z+=a*Ue,Y+=a*Le,fe+=a*Me,ye+=a*je,de+=a*$e,me+=a*Ne,Fe+=a*We,Te+=a*ke,ve+=a*Ye,pe+=a*Je,le+=a*Xe,ue+=a*ze,ce+=a*Be,oe+=a*Ae,se+=a*Ze,te+=a*Qe,a=A[1],Y+=a*Ue,fe+=a*Le,ye+=a*Me,de+=a*je,me+=a*$e,Fe+=a*Ne,Te+=a*We,ve+=a*ke,pe+=a*Ye,le+=a*Je,ue+=a*Xe,ce+=a*ze,oe+=a*Be,se+=a*Ae,te+=a*Ze,he+=a*Qe,a=A[2],fe+=a*Ue,ye+=a*Le,de+=a*Me,me+=a*je,Fe+=a*$e,Te+=a*Ne,ve+=a*We,pe+=a*ke,le+=a*Ye,ue+=a*Je,ce+=a*Xe,oe+=a*ze,se+=a*Be,te+=a*Ae,he+=a*Ze,ge+=a*Qe,a=A[3],ye+=a*Ue,de+=a*Le,me+=a*Me,Fe+=a*je,Te+=a*$e,ve+=a*Ne,pe+=a*We,le+=a*ke,ue+=a*Ye,ce+=a*Je,oe+=a*Xe,se+=a*ze,te+=a*Be,he+=a*Ae,ge+=a*Ze,ie+=a*Qe,a=A[4],de+=a*Ue,me+=a*Le,Fe+=a*Me,Te+=a*je,ve+=a*$e,pe+=a*Ne,le+=a*We,ue+=a*ke,ce+=a*Ye,oe+=a*Je,se+=a*Xe,te+=a*ze,he+=a*Be,ge+=a*Ae,ie+=a*Ze,_e+=a*Qe,a=A[5],me+=a*Ue,Fe+=a*Le,Te+=a*Me,ve+=a*je,pe+=a*$e,le+=a*Ne,ue+=a*We,ce+=a*ke,oe+=a*Ye,se+=a*Je,te+=a*Xe,he+=a*ze,ge+=a*Be,ie+=a*Ae,_e+=a*Ze,be+=a*Qe,a=A[6],Fe+=a*Ue,Te+=a*Le,ve+=a*Me,pe+=a*je,le+=a*$e,ue+=a*Ne,ce+=a*We,oe+=a*ke,se+=a*Ye,te+=a*Je,he+=a*Xe,ge+=a*ze,ie+=a*Be,_e+=a*Ae,be+=a*Ze,Ee+=a*Qe,a=A[7],Te+=a*Ue,ve+=a*Le,pe+=a*Me,le+=a*je,ue+=a*$e,ce+=a*Ne,oe+=a*We,se+=a*ke,te+=a*Ye,he+=a*Je,ge+=a*Xe,ie+=a*ze,_e+=a*Be,be+=a*Ae,Ee+=a*Ze,De+=a*Qe,a=A[8],ve+=a*Ue,pe+=a*Le,le+=a*Me,ue+=a*je,ce+=a*$e,oe+=a*Ne,se+=a*We,te+=a*ke,he+=a*Ye,ge+=a*Je,ie+=a*Xe,_e+=a*ze,be+=a*Be,Ee+=a*Ae,De+=a*Ze,we+=a*Qe,a=A[9],pe+=a*Ue,le+=a*Le,ue+=a*Me,ce+=a*je,oe+=a*$e,se+=a*Ne,te+=a*We,he+=a*ke,ge+=a*Ye,ie+=a*Je,_e+=a*Xe,be+=a*ze,Ee+=a*Be,De+=a*Ae,we+=a*Ze,xt+=a*Qe,a=A[10],le+=a*Ue,ue+=a*Le,ce+=a*Me,oe+=a*je,se+=a*$e,te+=a*Ne,he+=a*We,ge+=a*ke,ie+=a*Ye,_e+=a*Je,be+=a*Xe,Ee+=a*ze,De+=a*Be,we+=a*Ae,xt+=a*Ze,Lt+=a*Qe,a=A[11],ue+=a*Ue,ce+=a*Le,oe+=a*Me,se+=a*je,te+=a*$e,he+=a*Ne,ge+=a*We,ie+=a*ke,_e+=a*Ye,be+=a*Je,Ee+=a*Xe,De+=a*ze,we+=a*Be,xt+=a*Ae,Lt+=a*Ze,qt+=a*Qe,a=A[12],ce+=a*Ue,oe+=a*Le,se+=a*Me,te+=a*je,he+=a*$e,ge+=a*Ne,ie+=a*We,_e+=a*ke,be+=a*Ye,Ee+=a*Je,De+=a*Xe,we+=a*ze,xt+=a*Be,Lt+=a*Ae,qt+=a*Ze,gt+=a*Qe,a=A[13],oe+=a*Ue,se+=a*Le,te+=a*Me,he+=a*je,ge+=a*$e,ie+=a*Ne,_e+=a*We,be+=a*ke,Ee+=a*Ye,De+=a*Je,we+=a*Xe,xt+=a*ze,Lt+=a*Be,qt+=a*Ae,gt+=a*Ze,er+=a*Qe,a=A[14],se+=a*Ue,te+=a*Le,he+=a*Me,ge+=a*je,ie+=a*$e,_e+=a*Ne,be+=a*We,Ee+=a*ke,De+=a*Ye,we+=a*Je,xt+=a*Xe,Lt+=a*ze,qt+=a*Be,gt+=a*Ae,er+=a*Ze,zr+=a*Qe,a=A[15],te+=a*Ue,he+=a*Le,ge+=a*Me,ie+=a*je,_e+=a*$e,be+=a*Ne,Ee+=a*We,De+=a*ke,we+=a*Ye,xt+=a*Je,Lt+=a*Xe,qt+=a*ze,gt+=a*Be,er+=a*Ae,zr+=a*Ze,li+=a*Qe,z+=38*he,Y+=38*ge,fe+=38*ie,ye+=38*_e,de+=38*be,me+=38*Ee,Fe+=38*De,Te+=38*we,ve+=38*xt,pe+=38*Lt,le+=38*qt,ue+=38*gt,ce+=38*er,oe+=38*zr,se+=38*li,v=1,a=z+v+65535,v=Math.floor(a/65536),z=a-v*65536,a=Y+v+65535,v=Math.floor(a/65536),Y=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=de+v+65535,v=Math.floor(a/65536),de=a-v*65536,a=me+v+65535,v=Math.floor(a/65536),me=a-v*65536,a=Fe+v+65535,v=Math.floor(a/65536),Fe=a-v*65536,a=Te+v+65535,v=Math.floor(a/65536),Te=a-v*65536,a=ve+v+65535,v=Math.floor(a/65536),ve=a-v*65536,a=pe+v+65535,v=Math.floor(a/65536),pe=a-v*65536,a=le+v+65535,v=Math.floor(a/65536),le=a-v*65536,a=ue+v+65535,v=Math.floor(a/65536),ue=a-v*65536,a=ce+v+65535,v=Math.floor(a/65536),ce=a-v*65536,a=oe+v+65535,v=Math.floor(a/65536),oe=a-v*65536,a=se+v+65535,v=Math.floor(a/65536),se=a-v*65536,a=te+v+65535,v=Math.floor(a/65536),te=a-v*65536,z+=v-1+37*(v-1),v=1,a=z+v+65535,v=Math.floor(a/65536),z=a-v*65536,a=Y+v+65535,v=Math.floor(a/65536),Y=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=de+v+65535,v=Math.floor(a/65536),de=a-v*65536,a=me+v+65535,v=Math.floor(a/65536),me=a-v*65536,a=Fe+v+65535,v=Math.floor(a/65536),Fe=a-v*65536,a=Te+v+65535,v=Math.floor(a/65536),Te=a-v*65536,a=ve+v+65535,v=Math.floor(a/65536),ve=a-v*65536,a=pe+v+65535,v=Math.floor(a/65536),pe=a-v*65536,a=le+v+65535,v=Math.floor(a/65536),le=a-v*65536,a=ue+v+65535,v=Math.floor(a/65536),ue=a-v*65536,a=ce+v+65535,v=Math.floor(a/65536),ce=a-v*65536,a=oe+v+65535,v=Math.floor(a/65536),oe=a-v*65536,a=se+v+65535,v=Math.floor(a/65536),se=a-v*65536,a=te+v+65535,v=Math.floor(a/65536),te=a-v*65536,z+=v-1+37*(v-1),I[0]=z,I[1]=Y,I[2]=fe,I[3]=ye,I[4]=de,I[5]=me,I[6]=Fe,I[7]=Te,I[8]=ve,I[9]=pe,I[10]=le,I[11]=ue,I[12]=ce,I[13]=oe,I[14]=se,I[15]=te}function g(I,A){o(I,A,A)}function B(I,A){var D=n(),a;for(a=0;a<16;a++)D[a]=A[a];for(a=253;a>=0;a--)g(D,D),a!==2&&a!==4&&o(D,D,A);for(a=0;a<16;a++)I[a]=D[a]}function q(I,A){var D=n(),a;for(a=0;a<16;a++)D[a]=A[a];for(a=250;a>=0;a--)g(D,D),a!==1&&o(D,D,A);for(a=0;a<16;a++)I[a]=D[a]}function V(I,A){var D=n(),a=n(),v=n(),z=n(),Y=n(),fe=n(),ye=n(),de=n(),me=n();m(D,I[1],I[0]),m(me,A[1],A[0]),o(D,D,me),T(a,I[0],I[1]),T(me,A[0],A[1]),o(a,a,me),o(v,I[3],A[3]),o(v,v,l),o(z,I[2],A[2]),T(z,z,z),m(Y,a,D),m(fe,z,v),T(ye,z,v),T(de,a,D),o(I[0],Y,fe),o(I[1],de,ye),o(I[2],ye,fe),o(I[3],Y,de)}function J(I,A,D){for(var a=0;a<4;a++)F(I[a],A[a],D)}function X(I,A){var D=n(),a=n(),v=n();B(v,A[2]),o(D,A[0],v),o(a,A[1],v),y(I,a),I[31]^=C(D)<<7}function f(I,A,D){w(I[0],u),w(I[1],c),w(I[2],c),w(I[3],u);for(var a=255;a>=0;--a){var v=D[a/8|0]>>(a&7)&1;J(I,A,v),V(A,I),V(I,I),J(I,A,v)}}function _(I,A){var D=[n(),n(),n(),n()];w(D[0],p),w(D[1],E),w(D[2],c),o(D[3],p,E),f(I,D,A)}function M(I){if(I.length!==t.SEED_LENGTH)throw new Error("ed25519: seed must be "+t.SEED_LENGTH+" bytes");var A=r.hash(I);A[0]&=248,A[31]&=127,A[31]|=64;var D=new Uint8Array(32),a=[n(),n(),n(),n()];_(a,A),X(D,a);var v=new Uint8Array(64);return v.set(I),v.set(D,32),{publicKey:D,secretKey:v}}t.generateKeyPairFromSeed=M;function K(I){var A=e.randomBytes(32,I),D=M(A);return i.wipe(A),D}t.generateKeyPair=K;function R(I){if(I.length!==t.SECRET_KEY_LENGTH)throw new Error("ed25519: secret key must be "+t.SECRET_KEY_LENGTH+" bytes");return new Uint8Array(I.subarray(32))}t.extractPublicKeyFromSecretKey=R;var P=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(I,A){var D,a,v,z;for(a=63;a>=32;--a){for(D=0,v=a-32,z=a-12;v<z;++v)A[v]+=D-16*A[a]*P[v-(a-32)],D=Math.floor((A[v]+128)/256),A[v]-=D*256;A[v]+=D,A[a]=0}for(D=0,v=0;v<32;v++)A[v]+=D-(A[31]>>4)*P[v],D=A[v]>>8,A[v]&=255;for(v=0;v<32;v++)A[v]-=D*P[v];for(a=0;a<32;a++)A[a+1]+=A[a]>>8,I[a]=A[a]&255}function $(I){for(var A=new Float64Array(64),D=0;D<64;D++)A[D]=I[D];for(var D=0;D<64;D++)I[D]=0;j(I,A)}function Q(I,A){var D=new Float64Array(64),a=[n(),n(),n(),n()],v=r.hash(I.subarray(0,32));v[0]&=248,v[31]&=127,v[31]|=64;var z=new Uint8Array(64);z.set(v.subarray(32),32);var Y=new r.SHA512;Y.update(z.subarray(32)),Y.update(A);var fe=Y.digest();Y.clean(),$(fe),_(a,fe),X(z,a),Y.reset(),Y.update(z.subarray(0,32)),Y.update(I.subarray(32)),Y.update(A);var ye=Y.digest();$(ye);for(var de=0;de<32;de++)D[de]=fe[de];for(var de=0;de<32;de++)for(var me=0;me<32;me++)D[de+me]+=ye[de]*v[me];return j(z.subarray(32),D),z}t.sign=Q;function H(I,A){var D=n(),a=n(),v=n(),z=n(),Y=n(),fe=n(),ye=n();return w(I[2],c),S(I[1],A),g(v,I[1]),o(z,v,h),m(v,v,I[2]),T(z,I[2],z),g(Y,z),g(fe,Y),o(ye,fe,Y),o(D,ye,v),o(D,D,z),q(D,D),o(D,D,v),o(D,D,z),o(D,D,z),o(I[0],D,z),g(a,I[0]),o(a,a,z),N(a,v)&&o(I[0],I[0],L),g(a,I[0]),o(a,a,z),N(a,v)?-1:(C(I[0])===A[31]>>7&&m(I[0],u,I[0]),o(I[3],I[0],I[1]),0)}function ee(I,A,D){var a=new Uint8Array(32),v=[n(),n(),n(),n()],z=[n(),n(),n(),n()];if(D.length!==t.SIGNATURE_LENGTH)throw new Error("ed25519: signature must be "+t.SIGNATURE_LENGTH+" bytes");if(H(z,I))return!1;var Y=new r.SHA512;Y.update(D.subarray(0,32)),Y.update(I),Y.update(A);var fe=Y.digest();return $(fe),f(v,z,fe),_(z,D.subarray(32)),V(v,z),X(a,v),!O(D,a)}t.verify=ee;function k(I){var A=[n(),n(),n(),n()];if(H(A,I))throw new Error("Ed25519: invalid public key");var D=n(),a=n(),v=A[1];T(D,c,v),m(a,c,v),B(a,a),o(D,D,a);var z=new Uint8Array(32);return y(z,D),z}t.convertPublicKeyToX25519=k;function ae(I){var A=r.hash(I.subarray(0,32));A[0]&=248,A[31]&=127,A[31]|=64;var D=new Uint8Array(A.subarray(0,32));return i.wipe(A),D}t.convertSecretKeyToX25519=ae}(_n);const ud="EdDSA",hd="JWT",Po=".",Ro="base64url",fd="utf8",ld="utf8",dd=":",pd="did",gd="key",Fo="base58btc",vd="z",yd="K36",_d=32;function oi(t){return ft(ht(_r(t),fd),Ro)}function Uo(t){const e=ht(yd,Fo),r=vd+ft(ji([e,t]),Fo);return[pd,gd,r].join(dd)}function bd(t){return ft(t,Ro)}function md(t){return ht([oi(t.header),oi(t.payload)].join(Po),ld)}function wd(t){return[oi(t.header),oi(t.payload),bd(t.signature)].join(Po)}function Mo(t=nr.randomBytes(_d)){return _n.generateKeyPairFromSeed(t)}async function Ed(t,e,r,i,n=Ie.fromMiliseconds(Date.now())){const s={alg:ud,typ:hd},u=Uo(i.publicKey),c=n+r,h={iss:u,sub:t,aud:e,iat:n,exp:c},l=md({header:s,payload:h}),p=_n.sign(i.secretKey,l);return wd({header:s,payload:h,signature:p})}const Dd=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class xd{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.registering=!1,!qn(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(_r(e))}catch(i){this.onError(e.id,i)}}register(e=this.url){if(!qn(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);return this.registering?new Promise((r,i)=>{this.events.once("register_error",n=>{i(n)}),this.events.once("open",()=>{if(typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));r(this.socket)})}):(this.url=e,this.registering=!0,new Promise((r,i)=>{const n=Mn.isReactNative()?void 0:{rejectUnauthorized:!rc(e)},s=new Dd(e,[],n);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=u=>{const c=this.parseError(u.error);this.events.emit("register_error",c),this.onClose(),i(c)}}))}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"?Oi(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=qr(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return Un(e,r,"WS")}}var bn={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,u=9007199254740991,c="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",p="[object Boolean]",E="[object Date]",L="[object Error]",w="[object Function]",b="[object GeneratorFunction]",F="[object Map]",y="[object Number]",O="[object Null]",N="[object Object]",C="[object Promise]",S="[object Proxy]",T="[object RegExp]",m="[object Set]",o="[object String]",g="[object Symbol]",B="[object Undefined]",q="[object WeakMap]",V="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",f="[object Float64Array]",_="[object Int8Array]",M="[object Int16Array]",K="[object Int32Array]",R="[object Uint8Array]",P="[object Uint8ClampedArray]",j="[object Uint16Array]",$="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,k={};k[X]=k[f]=k[_]=k[M]=k[K]=k[R]=k[P]=k[j]=k[$]=!0,k[c]=k[h]=k[V]=k[p]=k[J]=k[E]=k[L]=k[w]=k[F]=k[y]=k[N]=k[T]=k[m]=k[o]=k[q]=!1;var ae=typeof Z=="object"&&Z&&Z.Object===Object&&Z,I=typeof self=="object"&&self&&self.Object===Object&&self,A=ae||I||Function("return this")(),D=e&&!e.nodeType&&e,a=D&&!0&&t&&!t.nodeType&&t,v=a&&a.exports===D,z=v&&ae.process,Y=function(){try{return z&&z.binding&&z.binding("util")}catch{}}(),fe=Y&&Y.isTypedArray;function ye(d,x){for(var U=-1,W=d==null?0:d.length,Oe=0,ne=[];++U<W;){var Pe=d[U];x(Pe,U,d)&&(ne[Oe++]=Pe)}return ne}function de(d,x){for(var U=-1,W=x.length,Oe=d.length;++U<W;)d[Oe+U]=x[U];return d}function me(d,x){for(var U=-1,W=d==null?0:d.length;++U<W;)if(x(d[U],U,d))return!0;return!1}function Fe(d,x){for(var U=-1,W=Array(d);++U<d;)W[U]=x(U);return W}function Te(d){return function(x){return d(x)}}function ve(d,x){return d.has(x)}function pe(d,x){return d?.[x]}function le(d){var x=-1,U=Array(d.size);return d.forEach(function(W,Oe){U[++x]=[Oe,W]}),U}function ue(d,x){return function(U){return d(x(U))}}function ce(d){var x=-1,U=Array(d.size);return d.forEach(function(W){U[++x]=W}),U}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=A["__core-js_shared__"],ge=se.toString,ie=te.hasOwnProperty,_e=function(){var d=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return d?"Symbol(src)_1."+d:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=v?A.Buffer:void 0,we=A.Symbol,xt=A.Uint8Array,Lt=te.propertyIsEnumerable,qt=oe.splice,gt=we?we.toStringTag:void 0,er=Object.getOwnPropertySymbols,zr=De?De.isBuffer:void 0,li=ue(Object.keys,Object),Ue=pr(A,"DataView"),Le=pr(A,"Map"),Me=pr(A,"Promise"),je=pr(A,"Set"),$e=pr(A,"WeakMap"),Ne=pr(Object,"create"),We=rr(Ue),ke=rr(Le),Ye=rr(Me),Je=rr(je),Xe=rr($e),ze=we?we.prototype:void 0,Be=ze?ze.valueOf:void 0;function Ae(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function Ze(){this.__data__=Ne?Ne(null):{},this.size=0}function Qe(d){var x=this.has(d)&&delete this.__data__[d];return this.size-=x?1:0,x}function g0(d){var x=this.__data__;if(Ne){var U=x[d];return U===i?void 0:U}return ie.call(x,d)?x[d]:void 0}function v0(d){var x=this.__data__;return Ne?x[d]!==void 0:ie.call(x,d)}function y0(d,x){var U=this.__data__;return this.size+=this.has(d)?0:1,U[d]=Ne&&x===void 0?i:x,this}Ae.prototype.clear=Ze,Ae.prototype.delete=Qe,Ae.prototype.get=g0,Ae.prototype.has=v0,Ae.prototype.set=y0;function jt(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function _0(){this.__data__=[],this.size=0}function b0(d){var x=this.__data__,U=pi(x,d);if(U<0)return!1;var W=x.length-1;return U==W?x.pop():qt.call(x,U,1),--this.size,!0}function m0(d){var x=this.__data__,U=pi(x,d);return U<0?void 0:x[U][1]}function w0(d){return pi(this.__data__,d)>-1}function E0(d,x){var U=this.__data__,W=pi(U,d);return W<0?(++this.size,U.push([d,x])):U[W][1]=x,this}jt.prototype.clear=_0,jt.prototype.delete=b0,jt.prototype.get=m0,jt.prototype.has=w0,jt.prototype.set=E0;function tr(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function D0(){this.size=0,this.__data__={hash:new Ae,map:new(Le||jt),string:new Ae}}function x0(d){var x=gi(this,d).delete(d);return this.size-=x?1:0,x}function S0(d){return gi(this,d).get(d)}function O0(d){return gi(this,d).has(d)}function A0(d,x){var U=gi(this,d),W=U.size;return U.set(d,x),this.size+=U.size==W?0:1,this}tr.prototype.clear=D0,tr.prototype.delete=x0,tr.prototype.get=S0,tr.prototype.has=O0,tr.prototype.set=A0;function di(d){var x=-1,U=d==null?0:d.length;for(this.__data__=new tr;++x<U;)this.add(d[x])}function I0(d){return this.__data__.set(d,i),this}function C0(d){return this.__data__.has(d)}di.prototype.add=di.prototype.push=I0,di.prototype.has=C0;function Vt(d){var x=this.__data__=new jt(d);this.size=x.size}function T0(){this.__data__=new jt,this.size=0}function L0(d){var x=this.__data__,U=x.delete(d);return this.size=x.size,U}function N0(d){return this.__data__.get(d)}function P0(d){return this.__data__.has(d)}function R0(d,x){var U=this.__data__;if(U instanceof jt){var W=U.__data__;if(!Le||W.length<r-1)return W.push([d,x]),this.size=++U.size,this;U=this.__data__=new tr(W)}return U.set(d,x),this.size=U.size,this}Vt.prototype.clear=T0,Vt.prototype.delete=L0,Vt.prototype.get=N0,Vt.prototype.has=P0,Vt.prototype.set=R0;function F0(d,x){var U=vi(d),W=!U&&J0(d),Oe=!U&&!W&&Ln(d),ne=!U&&!W&&!Oe&&Fa(d),Pe=U||W||Oe||ne,et=Pe?Fe(d.length,String):[],nt=et.length;for(var Ce in d)(x||ie.call(d,Ce))&&!(Pe&&(Ce=="length"||Oe&&(Ce=="offset"||Ce=="parent")||ne&&(Ce=="buffer"||Ce=="byteLength"||Ce=="byteOffset")||V0(Ce,nt)))&&et.push(Ce);return et}function pi(d,x){for(var U=d.length;U--;)if(La(d[U][0],x))return U;return-1}function U0(d,x,U){var W=x(d);return vi(d)?W:de(W,U(d))}function Hr(d){return d==null?d===void 0?B:O:gt&> in Object(d)?K0(d):Y0(d)}function Aa(d){return Kr(d)&&Hr(d)==c}function Ia(d,x,U,W,Oe){return d===x?!0:d==null||x==null||!Kr(d)&&!Kr(x)?d!==d&&x!==x:M0(d,x,U,W,Ia,Oe)}function M0(d,x,U,W,Oe,ne){var Pe=vi(d),et=vi(x),nt=Pe?h:Gt(d),Ce=et?h:Gt(x);nt=nt==c?N:nt,Ce=Ce==c?N:Ce;var vt=nt==N,St=Ce==N,at=nt==Ce;if(at&&Ln(d)){if(!Ln(x))return!1;Pe=!0,vt=!1}if(at&&!vt)return ne||(ne=new Vt),Pe||Fa(d)?Ca(d,x,U,W,Oe,ne):z0(d,x,nt,U,W,Oe,ne);if(!(U&n)){var _t=vt&&ie.call(d,"__wrapped__"),bt=St&&ie.call(x,"__wrapped__");if(_t||bt){var Wt=_t?d.value():d,$t=bt?x.value():x;return ne||(ne=new Vt),Oe(Wt,$t,U,W,ne)}}return at?(ne||(ne=new Vt),H0(d,x,U,W,Oe,ne)):!1}function j0(d){if(!Ra(d)||W0(d))return!1;var x=Na(d)?Ee:H;return x.test(rr(d))}function $0(d){return Kr(d)&&Pa(d.length)&&!!k[Hr(d)]}function B0(d){if(!k0(d))return li(d);var x=[];for(var U in Object(d))ie.call(d,U)&&U!="constructor"&&x.push(U);return x}function Ca(d,x,U,W,Oe,ne){var Pe=U&n,et=d.length,nt=x.length;if(et!=nt&&!(Pe&&nt>et))return!1;var Ce=ne.get(d);if(Ce&&ne.get(x))return Ce==x;var vt=-1,St=!0,at=U&s?new di:void 0;for(ne.set(d,x),ne.set(x,d);++vt<et;){var _t=d[vt],bt=x[vt];if(W)var Wt=Pe?W(bt,_t,vt,x,d,ne):W(_t,bt,vt,d,x,ne);if(Wt!==void 0){if(Wt)continue;St=!1;break}if(at){if(!me(x,function($t,ir){if(!ve(at,ir)&&(_t===$t||Oe(_t,$t,U,W,ne)))return at.push(ir)})){St=!1;break}}else if(!(_t===bt||Oe(_t,bt,U,W,ne))){St=!1;break}}return ne.delete(d),ne.delete(x),St}function z0(d,x,U,W,Oe,ne,Pe){switch(U){case J:if(d.byteLength!=x.byteLength||d.byteOffset!=x.byteOffset)return!1;d=d.buffer,x=x.buffer;case V:return!(d.byteLength!=x.byteLength||!ne(new xt(d),new xt(x)));case p:case E:case y:return La(+d,+x);case L:return d.name==x.name&&d.message==x.message;case T:case o:return d==x+"";case F:var et=le;case m:var nt=W&n;if(et||(et=ce),d.size!=x.size&&!nt)return!1;var Ce=Pe.get(d);if(Ce)return Ce==x;W|=s,Pe.set(d,x);var vt=Ca(et(d),et(x),W,Oe,ne,Pe);return Pe.delete(d),vt;case g:if(Be)return Be.call(d)==Be.call(x)}return!1}function H0(d,x,U,W,Oe,ne){var Pe=U&n,et=Ta(d),nt=et.length,Ce=Ta(x),vt=Ce.length;if(nt!=vt&&!Pe)return!1;for(var St=nt;St--;){var at=et[St];if(!(Pe?at in x:ie.call(x,at)))return!1}var _t=ne.get(d);if(_t&&ne.get(x))return _t==x;var bt=!0;ne.set(d,x),ne.set(x,d);for(var Wt=Pe;++St<nt;){at=et[St];var $t=d[at],ir=x[at];if(W)var Ua=Pe?W(ir,$t,at,x,d,ne):W($t,ir,at,d,x,ne);if(!(Ua===void 0?$t===ir||Oe($t,ir,U,W,ne):Ua)){bt=!1;break}Wt||(Wt=at=="constructor")}if(bt&&!Wt){var yi=d.constructor,_i=x.constructor;yi!=_i&&"constructor"in d&&"constructor"in x&&!(typeof yi=="function"&&yi instanceof yi&&typeof _i=="function"&&_i instanceof _i)&&(bt=!1)}return ne.delete(d),ne.delete(x),bt}function Ta(d){return U0(d,Q0,q0)}function gi(d,x){var U=d.__data__;return G0(x)?U[typeof x=="string"?"string":"hash"]:U.map}function pr(d,x){var U=pe(d,x);return j0(U)?U:void 0}function K0(d){var x=ie.call(d,gt),U=d[gt];try{d[gt]=void 0;var W=!0}catch{}var Oe=be.call(d);return W&&(x?d[gt]=U:delete d[gt]),Oe}var q0=er?function(d){return d==null?[]:(d=Object(d),ye(er(d),function(x){return Lt.call(d,x)}))}:ev,Gt=Hr;(Ue&&Gt(new Ue(new ArrayBuffer(1)))!=J||Le&&Gt(new Le)!=F||Me&&Gt(Me.resolve())!=C||je&&Gt(new je)!=m||$e&&Gt(new $e)!=q)&&(Gt=function(d){var x=Hr(d),U=x==N?d.constructor:void 0,W=U?rr(U):"";if(W)switch(W){case We:return J;case ke:return F;case Ye:return C;case Je:return m;case Xe:return q}return x});function V0(d,x){return x=x??u,!!x&&(typeof d=="number"||ee.test(d))&&d>-1&&d%1==0&&d<x}function G0(d){var x=typeof d;return x=="string"||x=="number"||x=="symbol"||x=="boolean"?d!=="__proto__":d===null}function W0(d){return!!_e&&_e in d}function k0(d){var x=d&&d.constructor,U=typeof x=="function"&&x.prototype||te;return d===U}function Y0(d){return be.call(d)}function rr(d){if(d!=null){try{return ge.call(d)}catch{}try{return d+""}catch{}}return""}function La(d,x){return d===x||d!==d&&x!==x}var J0=Aa(function(){return arguments}())?Aa:function(d){return Kr(d)&&ie.call(d,"callee")&&!Lt.call(d,"callee")},vi=Array.isArray;function X0(d){return d!=null&&Pa(d.length)&&!Na(d)}var Ln=zr||tv;function Z0(d,x){return Ia(d,x)}function Na(d){if(!Ra(d))return!1;var x=Hr(d);return x==w||x==b||x==l||x==S}function Pa(d){return typeof d=="number"&&d>-1&&d%1==0&&d<=u}function Ra(d){var x=typeof d;return d!=null&&(x=="object"||x=="function")}function Kr(d){return d!=null&&typeof d=="object"}var Fa=fe?Te(fe):$0;function Q0(d){return X0(d)?F0(d):B0(d)}function ev(){return[]}function tv(){return!1}t.exports=Z0})(bn,bn.exports);var Sd=bn.exports,Od=Object.defineProperty,jo=Object.getOwnPropertySymbols,Ad=Object.prototype.hasOwnProperty,Id=Object.prototype.propertyIsEnumerable,$o=(t,e,r)=>e in t?Od(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Ad.call(e,r)&&$o(t,r,e[r]);if(jo)for(var r of jo(e))Id.call(e,r)&&$o(t,r,e[r]);return t};function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var ai=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!Cd(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,u;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 c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}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(Rr(r))for(n=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,s=0;s<i;s++)u[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]?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&&(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(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],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 Cd(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function Bo(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),u=s.charCodeAt(0);if(r[u]!==255)throw new TypeError(s+" is ambiguous");r[u]=n}var c=t.length,h=t.charAt(0),l=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function E(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var F=0,y=0,O=0,N=b.length;O!==N&&b[O]===0;)O++,F++;for(var C=(N-O)*p+1>>>0,S=new Uint8Array(C);O!==N;){for(var T=b[O],m=0,o=C-1;(T!==0||m<y)&&o!==-1;o--,m++)T+=256*S[o]>>>0,S[o]=T%c>>>0,T=T/c>>>0;if(T!==0)throw new Error("Non-zero carry");y=m,O++}for(var g=C-y;g!==C&&S[g]===0;)g++;for(var B=h.repeat(F);g<C;++g)B+=t.charAt(S[g]);return B}function L(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var F=0;if(b[F]!==" "){for(var y=0,O=0;b[F]===h;)y++,F++;for(var N=(b.length-F)*l+1>>>0,C=new Uint8Array(N);b[F];){var S=r[b.charCodeAt(F)];if(S===255)return;for(var T=0,m=N-1;(S!==0||T<O)&&m!==-1;m--,T++)S+=c*C[m]>>>0,C[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");O=T,F++}if(b[F]!==" "){for(var o=N-O;o!==N&&C[o]===0;)o++;for(var g=new Uint8Array(y+(N-o)),B=y;o!==N;)g[B++]=C[o++];return g}}}function w(b){var F=L(b);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:L,decode:w}}var Ld=Td,Nd=Ld;const zo=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Pd=t=>new TextEncoder().encode(t),Rd=t=>new TextDecoder().decode(t);class Fd{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 Ud{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 Ho(this,e)}}class Md{constructor(e){this.decoders=e}or(e){return Ho(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 Ho=(t,e)=>new Md(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class jd{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Fd(e,r,i),this.decoder=new Ud(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ci=({name:t,prefix:e,encode:r,decode:i})=>new jd(t,e,r,i),Fr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Nd(r,e);return ci({prefix:t,name:e,encode:i,decode:s=>zo(n(s))})},$d=(t,e,r,i)=>{const n={};for(let p=0;p<e.length;++p)n[e[p]]=p;let s=t.length;for(;t[s-1]==="=";)--s;const u=new Uint8Array(s*r/8|0);let c=0,h=0,l=0;for(let p=0;p<s;++p){const E=n[t[p]];if(E===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<r|E,c+=r,c>=8&&(c-=8,u[l++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return u},Bd=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",u=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],u+=8;u>r;)u-=r,s+=e[n&c>>u];if(u&&(s+=e[n&c<<r-u]),i)for(;s.length*r&7;)s+="=";return s},it=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ci({prefix:e,name:t,encode(n){return Bd(n,i,r)},decode(n){return $d(n,i,r,t)}}),zd=ci({prefix:"\0",name:"identity",encode:t=>Rd(t),decode:t=>Pd(t)});var Hd=Object.freeze({__proto__:null,identity:zd});const Kd=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qd=Object.freeze({__proto__:null,base2:Kd});const Vd=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gd=Object.freeze({__proto__:null,base8:Vd});const Wd=Fr({prefix:"9",name:"base10",alphabet:"0123456789"});var kd=Object.freeze({__proto__:null,base10:Wd});const Yd=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jd=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Xd=Object.freeze({__proto__:null,base16:Yd,base16upper:Jd});const Zd=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qd=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ep=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tp=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rp=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ip=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),np=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sp=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),op=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ap=Object.freeze({__proto__:null,base32:Zd,base32upper:Qd,base32pad:ep,base32padupper:tp,base32hex:rp,base32hexupper:ip,base32hexpad:np,base32hexpadupper:sp,base32z:op});const cp=Fr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),up=Fr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var hp=Object.freeze({__proto__:null,base36:cp,base36upper:up});const fp=Fr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lp=Fr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dp=Object.freeze({__proto__:null,base58btc:fp,base58flickr:lp});const pp=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gp=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vp=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yp=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _p=Object.freeze({__proto__:null,base64:pp,base64pad:gp,base64url:vp,base64urlpad:yp});const Ko=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}"),bp=Ko.reduce((t,e,r)=>(t[r]=e,t),[]),mp=Ko.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function wp(t){return t.reduce((e,r)=>(e+=bp[r],e),"")}function Ep(t){const e=[];for(const r of t){const i=mp[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Dp=ci({prefix:"\u{1F680}",name:"base256emoji",encode:wp,decode:Ep});var xp=Object.freeze({__proto__:null,base256emoji:Dp}),Sp=Vo,qo=128,Op=127,Ap=~Op,Ip=Math.pow(2,31);function Vo(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Ip;)e[r++]=t&255|qo,t/=128;for(;t&Ap;)e[r++]=t&255|qo,t>>>=7;return e[r]=t|0,Vo.bytes=r-i+1,e}var Cp=mn,Tp=128,Go=127;function mn(t,i){var r=0,i=i||0,n=0,s=i,u,c=t.length;do{if(s>=c)throw mn.bytes=0,new RangeError("Could not decode varint");u=t[s++],r+=n<28?(u&Go)<<n:(u&Go)*Math.pow(2,n),n+=7}while(u>=Tp);return mn.bytes=s-i,r}var Lp=Math.pow(2,7),Np=Math.pow(2,14),Pp=Math.pow(2,21),Rp=Math.pow(2,28),Fp=Math.pow(2,35),Up=Math.pow(2,42),Mp=Math.pow(2,49),jp=Math.pow(2,56),$p=Math.pow(2,63),Bp=function(t){return t<Lp?1:t<Np?2:t<Pp?3:t<Rp?4:t<Fp?5:t<Up?6:t<Mp?7:t<jp?8:t<$p?9:10},zp={encode:Sp,decode:Cp,encodingLength:Bp},Wo=zp;const ko=(t,e,r=0)=>(Wo.encode(t,e,r),e),Yo=t=>Wo.encodingLength(t),wn=(t,e)=>{const r=e.byteLength,i=Yo(t),n=i+Yo(r),s=new Uint8Array(n+r);return ko(t,s,0),ko(r,s,i),s.set(e,n),new Hp(t,r,e,s)};class Hp{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Jo=({name:t,code:e,encode:r})=>new Kp(t,e,r);class Kp{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?wn(this.code,r):r.then(i=>wn(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Xo=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),qp=Jo({name:"sha2-256",code:18,encode:Xo("SHA-256")}),Vp=Jo({name:"sha2-512",code:19,encode:Xo("SHA-512")});var Gp=Object.freeze({__proto__:null,sha256:qp,sha512:Vp});const Zo=0,Wp="identity",Qo=zo;var kp=Object.freeze({__proto__:null,identity:{code:Zo,name:Wp,encode:Qo,digest:t=>wn(Zo,Qo(t))}});new TextEncoder,new TextDecoder;const ea=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},Hd),qd),Gd),kd),Xd),ap),hp),dp),_p),xp);ut(ut({},Gp),kp);function ta(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const ra=ta("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),En=ta("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Yp=ut({utf8:ra,"utf-8":ra,hex:ea.base16,latin1:En,ascii:En,binary:En},ea);function Jp(t,e="utf8"){const r=Yp[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}const ia="wc",Xp=2,Dn="core",Ur=`${ia}@${2}:${Dn}:`,Zp={name:Dn,logger:"error"},Qp={database:":memory:"},eg="crypto",na="client_ed25519_seed",tg=Ie.ONE_DAY,rg="keychain",ig="0.3",ng="messages",sg="0.3",og=Ie.SIX_HOURS,ag="publisher",sa="iridium",cg="error",ug="wss://relay.walletconnect.com",hg="relayer",Mr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},fg="_subscription",dr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},lg=Ie.ONE_SECOND,dg="2.0.0-rc.0",pg="0.3",Qt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},gg="subscription",vg="0.3",yg=Ie.FIVE_SECONDS*1e3;class _g{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=rg,this.version=ig,this.initialized=!1,this.storagePrefix=Ur,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}=G("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=Se.generateChildLogger(r,this.name)}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,eo(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?to(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class bg{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=Mo(n);return Uo(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=ef();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),u=Mo(s),c=Zi();return await Ed(c,n,tg,u)},this.generateSharedKey=(n,s,u)=>{this.isInitialized();const c=this.getPrivateKey(n),h=tf(c,s);return this.setSymKey(h,u)},this.setSymKey=async(n,s)=>{this.isInitialized();const u=s||rf(n);return await this.keychain.set(u,n),u},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,u)=>{this.isInitialized();const c=ks(u),h=_r(s);if(Ys(c)){const L=c.senderPublicKey,w=c.receiverPublicKey;n=await this.generateSharedKey(L,w)}const l=this.getSymKey(n),{type:p,senderPublicKey:E}=c;return sf({type:p,symKey:l,message:h,senderPublicKey:E})},this.decode=async(n,s,u)=>{this.isInitialized();const c=cf(s,u);if(Ys(c)){const p=c.receiverPublicKey,E=c.senderPublicKey;n=await this.generateSharedKey(p,E)}const h=this.getSymKey(n),l=of({symKey:h,encoded:s});return Oi(l)},this.core=e,this.logger=Se.generateChildLogger(r,this.name),this.keychain=i||new _g(this.core,this.logger)}get context(){return Se.getLoggerContext(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(na)}catch{e=Zi(),await this.keychain.set(na,e)}return Jp(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class mg extends Ql{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=Ur,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=Zr(n);let u=this.messages.get(i);return typeof u>"u"&&(u={}),typeof u[s]<"u"||(u[s]=n,this.messages.set(i,u),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),u=Zr(n);return typeof s[u]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Se.generateChildLogger(e,this.name),this.core=r}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,eo(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?to(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class wg extends ed{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new ai.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 u=s?.ttl||og,c=Qi(s),h=s?.prompt||!1,l=s?.tag||0,p={topic:i,message:n,opts:{ttl:u,relay:c,prompt:h,tag:l}},E=Zr(n);this.queue.set(E,p),await this.rpcPublish(i,n,u,c,h,l),this.onPublish(E,p),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}})}catch(u){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(u),u}},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=Se.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Se.getLoggerContext(this.logger)}rpcPublish(e,r,i,n,s,u){var c,h,l,p;const E={method:en(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:u}};return Et((c=E.params)==null?void 0:c.prompt)&&((h=E.params)==null||delete h.prompt),Et((l=E.params)==null?void 0:l.tag)&&((p=E.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:E}),this.relayer.provider.request(E)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:i,opts:{ttl:n,relay:s,prompt:u,tag:c}}=e,h=Zr(i);await this.rpcPublish(r,i,n,s,u,c),this.onPublish(h,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Nr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Eg{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 Dg=Object.defineProperty,xg=Object.defineProperties,Sg=Object.getOwnPropertyDescriptors,oa=Object.getOwnPropertySymbols,Og=Object.prototype.hasOwnProperty,Ag=Object.prototype.propertyIsEnumerable,aa=(t,e,r)=>e in t?Dg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ui=(t,e)=>{for(var r in e||(e={}))Og.call(e,r)&&aa(t,r,e[r]);if(oa)for(var r of oa(e))Ag.call(e,r)&&aa(t,r,e[r]);return t},xn=(t,e)=>xg(t,Sg(e));class Ig extends id{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Eg,this.events=new ai.EventEmitter,this.name=gg,this.version=vg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Ur,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),await this.reset(),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=Qi(n),u={topic:i,relay:s};this.pending.set(i,u);const c=await this.rpcSubscribe(i,s);return this.onSubscribe(c,u),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}}),c}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 u=new Ie.Watch;u.start(this.pendingSubscriptionWatchLabel);const c=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(c),u.stop(this.pendingSubscriptionWatchLabel),n(!0)),u.elapsed(this.pendingSubscriptionWatchLabel)>=yg&&(clearInterval(c),u.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.relayer=e,this.logger=Se.generateChildLogger(r,this.name)}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let 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=Qi(i);await this.rpcUnsubscribe(e,r,n);const s=rt("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:en(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:en(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,xn(ui({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,xn(ui({},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,ui({},r)),this.topicMap.set(r.topic,e),this.events.emit(Qt.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}=G("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(Qt.deleted,xn(ui({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Qt.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}=G("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.reset(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Nr.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(Qt.created,async e=>{const r=Qt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Qt.deleted,async e=>{const r=Qt.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}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Cg=Object.defineProperty,ca=Object.getOwnPropertySymbols,Tg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,ua=(t,e,r)=>e in t?Cg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ng=(t,e)=>{for(var r in e||(e={}))Tg.call(e,r)&&ua(t,r,e[r]);if(ca)for(var r of ca(e))Lg.call(e,r)&&ua(t,r,e[r]);return t};class Pg extends td{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new ai.EventEmitter,this.name=hg,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Se.generateChildLogger(e.logger,this.name):sn(Se.getDefaultLoggerOptions({level:e.logger||cg})),this.messages=new mg(this.logger,e.core),this.subscriber=new Ig(this,this.logger),this.publisher=new wg(this,this.logger),this.relayUrl=e?.relayUrl||ug,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized");const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=this.createProvider(e),await Promise.all([this.messages.init(),this.provider.connect(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Se.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,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)}createProvider(e){return new xi(new xd(Ef({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}),Gn(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(Ng({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(Mr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Di(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(Mr.connect)}),this.provider.on(dr.disconnect,()=>{this.events.emit(Mr.disconnect),setTimeout(()=>{this.provider.connect()},Ie.toMiliseconds(lg))}),this.provider.on(dr.error,e=>this.events.emit(Mr.error,e))}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Rg=Object.defineProperty,ha=Object.getOwnPropertySymbols,Fg=Object.prototype.hasOwnProperty,Ug=Object.prototype.propertyIsEnumerable,fa=(t,e,r)=>e in t?Rg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,la=(t,e)=>{for(var r in e||(e={}))Fg.call(e,r)&&fa(t,r,e[r]);if(ha)for(var r of ha(e))Ug.call(e,r)&&fa(t,r,e[r]);return t};class Sn extends rd{constructor(e,r,i,n=Ur){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=Ur,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>{Kf(s)?this.map.set(s.id,s):qf(s)&&this.map.set(s.topic,s)}),this.cached=[],this.initialized=!0)},this.set=async(s,u)=>{this.isInitialized(),this.map.has(s)?await this.update(s,u):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:s,value:u}),this.map.set(s,u),await this.persist())},this.get=s=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:s}),this.getData(s)),this.getAll=s=>s?this.values.filter(u=>Object.keys(s).every(c=>Sd(u[c],s[c]))):this.values,this.update=async(s,u)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:s,update:u});const c=la(la({},this.getData(s)),u);this.map.set(s,c),await this.persist()},this.delete=async(s,u)=>{this.isInitialized(),this.map.has(s)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:s,reason:u}),this.map.delete(s),await this.persist())},this.logger=Se.generateChildLogger(r,this.name),this.storagePrefix=n}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){const{message:i}=G("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}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Mg=Object.defineProperty,da=Object.getOwnPropertySymbols,jg=Object.prototype.hasOwnProperty,$g=Object.prototype.propertyIsEnumerable,pa=(t,e,r)=>e in t?Mg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ga=(t,e)=>{for(var r in e||(e={}))jg.call(e,r)&&pa(t,r,e[r]);if(da)for(var r of da(e))$g.call(e,r)&&pa(t,r,e[r]);return t};class On extends Xl{constructor(e){super(e),this.protocol=ia,this.version=Xp,this.name=Dn,this.events=new ai.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:sn(Se.getDefaultLoggerOptions({level:e?.logger||Zp.logger}));this.logger=Se.generateChildLogger(r,this.name),this.heartbeat=new Nr.HeartBeat,this.crypto=new bg(this,this.logger,e?.keychain),this.storage=e!=null&&e.storage?e.storage:new zl(ga(ga({},Qp),e?.storageOptions)),this.relayer=new Pg({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId})}static async init(e){const r=new On(e);return await r.initialize(),r}get context(){return Se.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.relayer.init(),await this.heartbeat.init(),this.initialized=!0,this.logger.info("Core Initilization Success")}catch(e){throw this.logger.info("Core Initilization Failure"),this.logger.error(e.message),e}}}const Bg=On;function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var hi=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!zg(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,i,n,s,u;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 c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(r=this._events[t],va(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(jr(r))for(n=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,s=0;s<i;s++)u[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]?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&&(va(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(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},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 zg(t){return typeof t=="number"}function jr(t){return typeof t=="object"&&t!==null}function va(t){return t===void 0}const ya="wc",_a=2,ba="client",$r=`${ya}@${_a}:${ba}:`,An={name:ba,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Hg="expirer",Dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Kg="0.3",Ct={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},qg="history",Vg="0.3",Gg="pairing",Wg="proposal",ma=cr(Ie.THIRTY_DAYS),kg="session",Yg=Ie.SEVEN_DAYS,fi=cr(Yg),Jg="engine",In={wc_pairingDelete:{req:{prompt:!1,tag:1e3},res:{prompt:!1,tag:1001}},wc_pairingPing:{req:{prompt:!1,tag:1002},res:{prompt:!1,tag:1003}},wc_sessionPropose:{req:{prompt:!0,tag:1100},res:{prompt:!1,tag:1101}},wc_sessionSettle:{req:{prompt:!1,tag:1102},res:{prompt:!1,tag:1103}},wc_sessionUpdate:{req:{prompt:!1,tag:1104},res:{prompt:!1,tag:1105}},wc_sessionExtend:{req:{prompt:!1,tag:1106},res:{prompt:!1,tag:1107}},wc_sessionRequest:{req:{prompt:!0,tag:1108},res:{prompt:!1,tag:1109}},wc_sessionEvent:{req:{prompt:!0,tag:1110},res:{prompt:!1,tag:1111}},wc_sessionDelete:{req:{prompt:!1,tag:1112},res:{prompt:!1,tag:1113}},wc_sessionPing:{req:{prompt:!1,tag:1114},res:{prompt:!1,tag:1115}}};var Xg=Object.defineProperty,Zg=Object.defineProperties,Qg=Object.getOwnPropertyDescriptors,wa=Object.getOwnPropertySymbols,e0=Object.prototype.hasOwnProperty,t0=Object.prototype.propertyIsEnumerable,Ea=(t,e,r)=>e in t?Xg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e)=>{for(var r in e||(e={}))e0.call(e,r)&&Ea(t,r,e[r]);if(wa)for(var r of wa(e))t0.call(e,r)&&Ea(t,r,e[r]);return t},Da=(t,e)=>Zg(t,Qg(e));class r0 extends ad{constructor(e){super(e),this.events=new hi,this.initialized=!1,this.name=Jg,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:i,requiredNamespaces:n,relays:s}=r;let u=i,c,h=!1;if(u&&(h=this.client.pairing.get(u).active),!u||!h){const{topic:y,uri:O}=await this.createPairing();u=y,c=O}const l=await this.client.core.crypto.generateKeyPair(),p={requiredNamespaces:n,relays:s??[{protocol:sa}],proposer:{publicKey:l,metadata:this.client.metadata}},{reject:E,resolve:L,done:w}=Jt();if(this.events.once(Re("session_connect"),async({error:y,session:O})=>{if(y)E(y);else if(O){O.self.publicKey=l;const N=Da(Kt({},O),{requiredNamespaces:n});await this.client.session.set(O.topic,N),await this.setExpiry(O.topic,O.expiry),u&&await this.client.pairing.update(u,{peerMetadata:O.peer.metadata}),L(N)}}),!u){const{message:y}=G("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(y)}const b=await this.sendRequest(u,"wc_sessionPropose",p),F=cr(Ie.FIVE_MINUTES);return await this.setProposal(b,Kt({id:b,expiry:F},p)),{uri:c,approval:w}},this.pair=async r=>{this.isInitialized(),this.isValidPair(r);const{topic:i,symKey:n,relay:s}=Nf(r.uri),u=cr(Ie.FIVE_MINUTES),c={topic:i,relay:s,expiry:u,active:!1};return await this.client.pairing.set(i,c),await this.client.core.crypto.setSymKey(n,i),await this.client.core.relayer.subscribe(i,{relay:s}),await this.setExpiry(i,u),c},this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:i,relayProtocol:n,namespaces:s}=r,{pairingTopic:u,proposer:c,requiredNamespaces:h}=this.client.proposal.get(i),l=await this.client.core.crypto.generateKeyPair(),p=c.publicKey,E=await this.client.core.crypto.generateSharedKey(l,p),L={relay:{protocol:n??"iridium"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:fi};await this.client.core.relayer.subscribe(E);const w=await this.sendRequest(E,"wc_sessionSettle",L),{done:b,resolve:F,reject:y}=Jt();this.events.once(Re("session_approve",w),({error:N})=>{N?y(N):F(this.client.session.get(E))});const O=Da(Kt({},L),{topic:E,acknowledged:!1,self:L.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:l});return await this.client.session.set(E,O),await this.setExpiry(E,fi),u&&await this.client.pairing.update(u,{peerMetadata:O.peer.metadata}),u&&i&&(await this.sendResult(i,u,{relay:{protocol:n??"iridium"},responderPublicKey:l}),await this.client.proposal.delete(i,rt("USER_DISCONNECTED")),await this.activatePairing(u)),{topic:E,acknowledged:b}},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,rt("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:u,resolve:c,reject:h}=Jt();return this.events.once(Re("session_update",s),({error:l})=>{l?h(l):c()}),await this.client.session.update(i,{namespaces:n}),{acknowledged:u}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:i}=r,n=await this.sendRequest(i,"wc_sessionExtend",{}),{done:s,resolve:u,reject:c}=Jt();return this.events.once(Re("session_extend",n),({error:h})=>{h?c(h):u()}),await this.setExpiry(i,fi),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:i,request:n,topic:s}=r,u=await this.sendRequest(s,"wc_sessionRequest",{request:n,chainId:i}),{done:c,resolve:h,reject:l}=Jt();return this.events.once(Re("session_request",u),({error:p,result:E})=>{p?l(p):h(E)}),await c()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n;Pt(n)?await this.sendResult(s,i,n.result):wt(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:u,reject:c}=Jt();this.events.once(Re("session_ping",n),({error:h})=>{h?c(h):u()}),await s()}else if(this.client.pairing.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:s,resolve:u,reject:c}=Jt();this.events.once(Re("pairing_ping",n),({error:h})=>{h?c(h):u()}),await s()}},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",rt("USER_DISCONNECTED")),await this.deleteSession(i)):this.client.pairing.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",rt("USER_DISCONNECTED")),await this.deletePairing(i))},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>Bf(i,r))),this.activatePairing=async r=>{await this.client.pairing.update(r,{active:!0,expiry:ma}),await this.setExpiry(r,ma)},this.deleteSession=async r=>{const{self:i}=this.client.session.get(r);await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deletePairing=async r=>{await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.pairing.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deleteProposal=async r=>{await Promise.all([this.client.proposal.delete(r,rt("USER_DISCONNECTED")),this.client.expirer.del(r)])},this.setExpiry=async(r,i)=>{this.client.pairing.keys.includes(r)?await this.client.pairing.update(r,{expiry:i}):this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:i}),this.client.expirer.set(r,i)},this.setProposal=async(r,i)=>{await this.client.proposal.set(r,i),this.client.expirer.set(r,i.expiry)},this.sendRequest=async(r,i,n)=>{const s=Ei(i,n),u=await this.client.core.crypto.encode(r,s),c=In[i].req;return await this.client.core.relayer.publish(r,u,c),this.client.history.set(r,s),s.id},this.sendResult=async(r,i,n)=>{const s=Di(r,n),u=await this.client.core.crypto.encode(i,s),c=await this.client.history.get(i,r),h=In[c.request.method].res;await this.client.core.relayer.publish(i,u,h),await this.client.history.resolve(s)},this.sendError=async(r,i,n)=>{const s=qr(r,n),u=await this.client.core.crypto.encode(i,s),c=await this.client.history.get(i,r),h=In[c.request.method].res;await this.client.core.relayer.publish(i,u,h),await this.client.history.resolve(s)},this.cleanup=async()=>{const r=[],i=[],n=[];this.client.session.getAll().forEach(s=>{Yt(s.expiry)&&r.push(s.topic)}),this.client.pairing.getAll().forEach(s=>{Yt(s.expiry)&&i.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Yt(s.expiry)&&n.push(s.id)}),await Promise.all([...r.map(this.deleteSession),...i.map(this.deletePairing),...n.map(this.deleteProposal)])},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_pairingPing":return this.onPairingPingRequest(i,n);case"wc_sessionDelete":return this.onSessionDeleteRequest(i,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(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.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_pairingPing":return this.onPairingPingResponse(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(Kt({},i.params));const u=cr(Ie.FIVE_MINUTES),c=Kt({id:s,pairingTopic:r,expiry:u},n);await this.setProposal(s,c),this.client.events.emit("session_proposal",{id:s,params:c})}catch(u){await this.sendError(s,r,u),this.client.logger.error(u)}},this.onSessionProposeResponse=async(r,i)=>{const{id:n}=i;if(Pt(i)){const{result:s}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const u=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:u});const c=u.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const l=await this.client.core.crypto.generateSharedKey(c,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:l});const p=await this.client.core.relayer.subscribe(l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.activatePairing(r)}else wt(i)&&(await this.client.proposal.delete(n,rt("USER_DISCONNECTED")),this.events.emit(Re("session_connect"),{error:i.error}))},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:u,controller:c,expiry:h,namespaces:l}=i.params,p={topic:r,relay:u,expiry:h,namespaces:l,acknowledged:!0,controller:c.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:c.publicKey,metadata:c.metadata}};await this.sendResult(i.id,r,!0),this.events.emit(Re("session_connect"),{session:p})}catch(u){await this.sendError(n,r,u),this.client.logger.error(u)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;Pt(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Re("session_approve",n),{})):wt(i)&&(await this.client.session.delete(r,rt("USER_DISCONNECTED")),this.events.emit(Re("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{this.isValidUpdate(Kt({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(u){await this.sendError(s,r,u),this.client.logger.error(u)}},this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i;Pt(i)?this.events.emit(Re("session_update",n),{}):wt(i)&&this.events.emit(Re("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,fi),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;Pt(i)?this.events.emit(Re("session_extend",n),{}):wt(i)&&this.events.emit(Re("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;Pt(i)?this.events.emit(Re("session_ping",n),{}):wt(i)&&this.events.emit(Re("session_ping",n),{error:i.error})},this.onPairingPingRequest=async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult(n,r,!0),this.client.events.emit("pairing_ping",{id:n,topic:r})}catch(s){await this.sendError(n,r,s),this.client.logger.error(s)}},this.onPairingPingResponse=(r,i)=>{const{id:n}=i;Pt(i)?this.events.emit(Re("pairing_ping",n),{}):wt(i)&&this.events.emit(Re("pairing_ping",n),{error:i.error})},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.onPairingDeleteRequest=async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),await this.sendResult(n,r,!0),await this.deletePairing(r),this.client.events.emit("pairing_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(Kt({topic:r},s)),this.client.events.emit("session_request",{id:n,topic:r,params:s})}catch(u){await this.sendError(n,r,u),this.client.logger.error(u)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i;Pt(i)?this.events.emit(Re("session_request",n),{result:i.result}):wt(i)&&this.events.emit(Re("session_request",n),{error:i.error})},this.onSessionEventRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidEmit(Kt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s})}catch(u){await this.sendError(n,r,u),this.client.logger.error(u)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:c}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,relays:s}=r;Et(i)||await this.isValidPairingTopic(i);const u=kf(n,"connect()");if(u)throw new Error(u.message);if(!Yf(s,!0)){const{message:c}=G("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(c)}},this.isValidPair=r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`pair() params: ${r}`);throw new Error(i)}if(!Hf(r.uri)){const{message:i}=G("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw new Error(i)}},this.isValidApprove=async r=>{if(!yt(r))throw new Error(G("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s}=r;await this.isValidProposalId(i);const u=this.client.proposal.get(i),c=nn(n,"approve()");if(c)throw new Error(c.message);const h=go(u.requiredNamespaces,n,"update()");if(h)throw new Error(h.message);if(!ot(s,!0)){const{message:l}=G("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(l)}},this.isValidReject=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(await this.isValidProposalId(i),!Xf(n)){const{message:s}=G("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!yt(r)){const{message:l}=G("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:i,controller:n,namespaces:s,expiry:u}=r;if(!lo(i)){const{message:l}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const c=Vf(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);const h=nn(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(Yt(u)){const{message:l}=G("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async r=>{if(!yt(r)){const{message:h}=G("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(h)}const{topic:i,namespaces:n}=r;await this.isValidSessionTopic(i);const s=this.client.session.get(i),u=nn(n,"update()");if(u)throw new Error(u.message);const c=go(s.requiredNamespaces,n,"update()");if(c)throw new Error(c.message)},this.isValidExtend=async r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionTopic(i)},this.isValidRequest=async r=>{if(!yt(r)){const{message:c}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!po(u,s)){const{message:c}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Zf(n)){const{message:c}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!tl(u,s,n.method)){const{message:c}=G("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}},this.isValidRespond=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:i,response:n}=r;if(await this.isValidSessionTopic(i),!Qf(n)){const{message:s}=G("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!yt(r)){const{message:c}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(c)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:u}=this.client.session.get(i);if(!po(u,s)){const{message:c}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(c)}if(!el(n)){const{message:c}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}if(!rl(u,s,n.name)){const{message:c}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}},this.isValidDisconnect=async r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}}async createPairing(){const e=Zi(),r=await this.client.core.crypto.setSymKey(e),i=cr(Ie.FIVE_MINUTES),n={protocol:sa},s={topic:r,expiry:i,relay:n,active:!1},u=Rf({protocol:this.client.protocol,version:this.client.version,topic:r,symKey:e,relay:n});return await this.client.pairing.set(r,s),await this.client.core.relayer.subscribe(r),await this.setExpiry(r,i),{topic:r,uri:u}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Mr.message,async e=>{const{topic:r,message:i}=e,n=await this.client.core.crypto.decode(r,i);Gn(n)?(this.client.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Wn(n)&&(await this.client.history.resolve(n),this.onRelayEventResponse({topic:r,payload:n}))})}registerExpirerEvents(){this.client.expirer.on(Dt.expired,async e=>{const{topic:r,id:i}=Sf(e.target);r?this.client.session.keys.includes(r)?(await this.deleteSession(r),this.client.events.emit("session_expire",{topic:r})):this.client.pairing.keys.includes(r)&&(await this.deletePairing(r),this.client.events.emit("pairing_expire",{topic:r})):i&&await this.deleteProposal(i)})}async isValidPairingTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.pairing.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Yt(this.client.pairing.get(e).expiry)){await this.deletePairing(e);const{message:r}=G("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Yt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=G("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.pairing.keys.includes(e))await this.isValidPairingTopic(e);else if(ot(e,!1)){const{message:r}=G("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=G("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Jf(e)){const{message:r}=G("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Yt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=G("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class i0 extends cd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new hi.EventEmitter,this.name=Hg,this.version=Kg,this.cached=[],this.initialized=!1,this.storagePrefix=$r,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),u={target:s,expiry:n};this.expirations.set(s,u),this.checkExpiry(s,u),this.events.emit(Dt.created,{target:s,expiration:u})},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(Dt.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=Se.generateChildLogger(r,this.name)}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Df(e);if(typeof e=="number")return xf(e);const{message:r}=G("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Dt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;Ie.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Dt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Nr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Dt.created,e=>{const r=Dt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.expired,e=>{const r=Dt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.deleted,e=>{const r=Dt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class n0 extends Zl{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new hi.EventEmitter,this.name=qg,this.version=Vg,this.cached=[],this.initialized=!1,this.storagePrefix=$r,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 u={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s};this.records.set(u.id,u),this.events.emit(Ct.created,u)},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=wt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.events.emit(Ct.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});const s=await this.getRecord(n);if(s.topic!==i){const{message:u}=G("MISMATCHED_TOPIC",`${this.name}, ${n}`);throw this.logger.error(u),new Error(u)}return s},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(Ct.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=Se.generateChildLogger(r,this.name)}get context(){return Se.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:Ei(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}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ct.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Ct.created,e=>{const r=Ct.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Ct.updated,e=>{const r=Ct.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Ct.deleted,e=>{const r=Ct.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class s0 extends Sn{constructor(e,r){super(e,r,Gg,$r),this.core=e,this.logger=r}}class o0 extends Sn{constructor(e,r){super(e,r,Wg,$r),this.core=e,this.logger=r}}class a0 extends Sn{constructor(e,r){super(e,r,kg,$r),this.core=e,this.logger=r}}class Cn extends od{constructor(e){super(e),this.protocol=ya,this.version=_a,this.name=An.name,this.events=new hi.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||An.name,this.metadata=e?.metadata||_f();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(Se.getDefaultLoggerOptions({level:e?.logger||An.logger}));this.core=e?.core||new Bg(e),this.logger=Se.generateChildLogger(r,this.name),this.pairing=new s0(this.core,this.logger),this.session=new a0(this.core,this.logger),this.proposal=new o0(this.core,this.logger),this.history=new n0(this.core,this.logger),this.expirer=new i0(this.core,this.logger),this.engine=new r0(this)}static async init(e){const r=new Cn(e);return await r.initialize(),r}get context(){return Se.getLoggerContext(this.logger)}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.pairing.init(),await this.session.init(),await this.proposal.init(),await this.history.init(),await this.expirer.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 Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var c0=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!u0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,i,n,s,u;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 c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(r=this._events[t],xa(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(Br(r))for(n=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,s=0;s<i;s++)u[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]?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&&(xa(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(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},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 u0(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function xa(t){return t===void 0}function h0(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 Ja{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?Wi(this.session.namespaces):Zh(this.requiredNamespaces)}get accounts(){return this.session?Gi(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:rt("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",Di(e.id,i))).catch(i=>this.events.emit("payload",qr(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(h0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Cn.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 Sa(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Oa(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Tn([t])]),r}function Tn(t){return Number(t[0].split(":")[1])}class p0{constructor(e){this.events=new gr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Sa(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Tn(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=Wi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Gi(e.namespaces,[this.namespace]);this.setAccounts(i)}),this.signer.connection.on(Tt.updated,e=>{const r=Wi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Gi(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 xi(r)}setHttpProvider(e){const r=Oa(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new xi(new ic(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)}}mt.default=p0,mt.getEthereumChainId=Tn,mt.getRpcConfig=Sa,mt.getRpcUrl=Oa,mt.signerEvents=d0,mt.signerMethods=l0,Object.defineProperty(mt,"__esModule",{value:!0})});
|
|
15
|
+
//# sourceMappingURL=index.umd.js.map
|