@walletconnect/ethereum-provider 2.0.0-45e9b7f5 → 2.0.0-635ab6d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 Xa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function wn(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var vr=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!Za(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||yr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ri(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:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(yr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ke.prototype.addListener=function(t,e){var r;if(!Nt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Nt(e.listener)?e.listener:e),this._events[t]?yr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,yr(this._events[t])&&!this._events[t].warned&&(Ri(this._maxListeners)?r=Ke.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ke.prototype.on=Ke.prototype.addListener,Ke.prototype.once=function(t,e){if(!Nt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ke.prototype.removeListener=function(t,e){var r,n,i,s;if(!Nt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Nt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(yr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ke.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Nt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Nt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Nt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function Za(t){return typeof t=="number"}function yr(t){return typeof t=="object"&&t!==null}function Ri(t){return t===void 0}const Qa="PARSE_ERROR",ec="INVALID_REQUEST",tc="METHOD_NOT_FOUND",rc="INVALID_PARAMS",Fi="INTERNAL_ERROR",En="SERVER_ERROR",nc=[-32700,-32600,-32601,-32602,-32603],_r={[Qa]:{code:-32700,message:"Parse error"},[ec]:{code:-32600,message:"Invalid Request"},[tc]:{code:-32601,message:"Method not found"},[rc]:{code:-32602,message:"Invalid params"},[Fi]:{code:-32603,message:"Internal error"},[En]:{code:-32e3,message:"Server error"}},Ui=En;function ic(t){return nc.includes(t)}function Mi(t){return Object.keys(_r).includes(t)?_r[t]:_r[Ui]}function sc(t){const e=Object.values(_r).find(r=>r.code===t);return e||_r[Ui]}function ji(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var $i={},$t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.isBrowserCryptoAvailable=$t.getSubtleCrypto=$t.getBrowerCrypto=void 0;function Dn(){return Z?.crypto||Z?.msCrypto||{}}$t.getBrowerCrypto=Dn;function Bi(){const t=Dn();return t.subtle||t.webkitSubtle}$t.getSubtleCrypto=Bi;function oc(){return!!Dn()&&!!Bi()}$t.isBrowserCryptoAvailable=oc;var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.isBrowser=Bt.isNode=Bt.isReactNative=void 0;function zi(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Bt.isReactNative=zi;function Hi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Bt.isNode=Hi;function ac(){return!zi()&&!Hi()}Bt.isBrowser=ac,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r($t,t),r(Bt,t)}($i);function cc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function xn(t,e,r){return{id:r||cc(),jsonrpc:"2.0",method:t,params:e}}function Sn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function qr(t,e,r){return{id:t,jsonrpc:"2.0",error:uc(e,r)}}function uc(t,e){return typeof t>"u"?Mi(Fi):(typeof t=="string"&&(t=Object.assign(Object.assign({},Mi(En)),{message:t})),typeof e<"u"&&(t.data=e),ic(t.code)&&(t=sc(t.code)),t)}class Ki{}class hc extends Ki{constructor(e){super()}}class fc extends Ki{constructor(){super()}}class lc extends fc{constructor(e){super()}}const dc="^https?:",pc="^wss?:";function gc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function qi(t,e){const r=gc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Vi(t){return qi(t,dc)}function Gi(t){return qi(t,pc)}function vc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Wi(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Yi(t){return Wi(t)&&"method"in t}function ki(t){return Wi(t)&&(Pt(t)||wt(t))}function Pt(t){return"result"in t}function wt(t){return"error"in t}class On extends lc{constructor(e){super(e),this.events=new vr.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(xn(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{wt(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ki(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 An={exports:{}};(function(t,e){var r=typeof self<"u"?self:Z,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(c){var u={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(u.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(f){return f&&l.indexOf(Object.prototype.toString.call(f))>-1};function D(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 C(f){return typeof f!="string"&&(f=String(f)),f}function x(f){var _={next:function(){var U=f.shift();return{done:U===void 0,value:U}}};return u.iterable&&(_[Symbol.iterator]=function(){return _}),_}function w(f){this.map={},f instanceof w?f.forEach(function(_,U){this.append(U,_)},this):Array.isArray(f)?f.forEach(function(_){this.append(_[0],_[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(_){this.append(_,f[_])},this)}w.prototype.append=function(f,_){f=D(f),_=C(_);var U=this.map[f];this.map[f]=U?U+", "+_:_},w.prototype.delete=function(f){delete this.map[D(f)]},w.prototype.get=function(f){return f=D(f),this.has(f)?this.map[f]:null},w.prototype.has=function(f){return this.map.hasOwnProperty(D(f))},w.prototype.set=function(f,_){this.map[D(f)]=C(_)},w.prototype.forEach=function(f,_){for(var U in this.map)this.map.hasOwnProperty(U)&&f.call(_,this.map[U],U,this)},w.prototype.keys=function(){var f=[];return this.forEach(function(_,U){f.push(U)}),x(f)},w.prototype.values=function(){var f=[];return this.forEach(function(_){f.push(_)}),x(f)},w.prototype.entries=function(){var f=[];return this.forEach(function(_,U){f.push([U,_])}),x(f)},u.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function R(f){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}function T(f){return new Promise(function(_,U){f.onload=function(){_(f.result)},f.onerror=function(){U(f.error)}})}function $(f){var _=new FileReader,U=T(_);return _.readAsArrayBuffer(f),U}function E(f){var _=new FileReader,U=T(_);return _.readAsText(f),U}function A(f){for(var _=new Uint8Array(f),U=new Array(_.length),q=0;q<_.length;q++)U[q]=String.fromCharCode(_[q]);return U.join("")}function y(f){if(f.slice)return f.slice(0);var _=new Uint8Array(f.byteLength);return _.set(new Uint8Array(f)),_.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(f){this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:u.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:u.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():u.arrayBuffer&&u.blob&&h(f)?(this._bodyArrayBuffer=y(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||g(f))?this._bodyArrayBuffer=y(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):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var f=R(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?R(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then($)}),this.text=function(){var f=R(this);if(f)return f;if(this._bodyBlob)return E(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(f){var _=f.toUpperCase();return b.indexOf(_)>-1?_:f}function d(f,_){_=_||{};var U=_.body;if(f instanceof d){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,_.headers||(this.headers=new w(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!U&&f._bodyInit!=null&&(U=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new w(_.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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(U)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function M(f){var _=new FormData;return f.trim().split("&").forEach(function(U){if(U){var q=U.split("="),P=q.shift().replace(/\+/g," "),N=q.join("=").replace(/\+/g," ");_.append(decodeURIComponent(P),decodeURIComponent(N))}}),_}function K(f){var _=new w,U=f.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function(q){var P=q.split(":"),N=P.shift().trim();if(N){var j=P.join(":").trim();_.append(N,j)}}),_}m.call(d.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 w(_.headers),this.url=_.url||"",this._initBody(f)}m.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(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}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(_,U){this.message=_,this.name=U;var q=Error(_);this.stack=q.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function X(f,_){return new Promise(function(U,q){var P=new d(f,_);if(P.signal&&P.signal.aborted)return q(new c.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function j(){N.abort()}N.onload=function(){var B={status:N.status,statusText:N.statusText,headers:K(N.getAllResponseHeaders()||"")};B.url="responseURL"in N?N.responseURL:B.headers.get("X-Request-URL");var Q="response"in N?N.response:N.responseText;U(new V(Q,B))},N.onerror=function(){q(new TypeError("Network request failed"))},N.ontimeout=function(){q(new TypeError("Network request failed"))},N.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},N.open(P.method,P.url,!0),P.credentials==="include"?N.withCredentials=!0:P.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&u.blob&&(N.responseType="blob"),P.headers.forEach(function(B,Q){N.setRequestHeader(Q,B)}),P.signal&&(P.signal.addEventListener("abort",j),N.onreadystatechange=function(){N.readyState===4&&P.signal.removeEventListener("abort",j)}),N.send(typeof P._bodyInit>"u"?null:P._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=w,s.Request=d,s.Response=V),c.Headers=w,c.Request=d,c.Response=V,c.fetch=X,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(An,An.exports);var Ji=Xa(An.exports);function In(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function br(t){return typeof t=="string"?t:JSON.stringify(t)}const Xi={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},Zi=10;class yc{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,r){this.isAvailable||await this.register();try{const n=br(e),s=await(await Ji(this.url,Object.assign(Object.assign({},Xi),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{const r=br({id:1,jsonrpc:"2.0",method:"test",params:[]});await Ji(e,Object.assign(Object.assign({},Xi),{body:r})),this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Zi&&this.events.setMaxListeners(Zi)}}var Ln={},Vr={},re={},Qi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(u,h){var l=u>>>16&65535,g=u&65535,D=h>>>16&65535,C=h&65535;return g*C+(l*C+g*D<<16>>>0)|0}t.mul=Math.imul||e;function r(u,h){return u+h|0}t.add=r;function n(u,h){return u-h|0}t.sub=n;function i(u,h){return u<<h|u>>>32-h}t.rotl=i;function s(u,h){return u<<32-h|u>>>h}t.rotr=s;function c(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}t.isInteger=Number.isInteger||c,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(u){return t.isInteger(u)&&u>=-t.MAX_SAFE_INTEGER&&u<=t.MAX_SAFE_INTEGER}})(Qi),Object.defineProperty(re,"__esModule",{value:!0});var es=Qi;function _c(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=_c;function bc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=bc;function mc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=mc;function wc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=wc;function ts(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=ts,re.writeInt16BE=ts;function rs(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=rs,re.writeInt16LE=rs;function Cn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Cn;function Tn(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=Tn;function Nn(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Nn;function Pn(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=Pn;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 Ec(t,e){e===void 0&&(e=0);var r=Cn(t,e),n=Cn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=Tn(t,e),n=Tn(t,e+4);return r*4294967296+n}re.readUint64BE=Dc;function xc(t,e){e===void 0&&(e=0);var r=Nn(t,e),n=Nn(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=xc;function Sc(t,e){e===void 0&&(e=0);var r=Pn(t,e),n=Pn(t,e+4);return n*4294967296+r}re.readUint64LE=Sc;function ns(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=ns,re.writeInt64BE=ns;function is(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=is,re.writeInt64LE=is;function Oc(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=Oc;function Ac(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=Ac;function Ic(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=Ic;function Lc(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=Lc;function Cc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Cc;function Tc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Tc;function Nc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Nc;function Pc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Pc;function Rc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=Rc;function Fc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=Fc;function Uc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=Uc;function Mc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=Mc;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});function jc(t){for(var e=0;e<t.length;e++)t[e]=0;return t}pt.wipe=jc,Object.defineProperty(Vr,"__esModule",{value:!0});var st=re,Rn=pt,$c=20;function Bc(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,c=1797285236,u=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],g=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],C=r[23]<<24|r[22]<<16|r[21]<<8|r[20],x=r[27]<<24|r[26]<<16|r[25]<<8|r[24],w=r[31]<<24|r[30]<<16|r[29]<<8|r[28],R=e[3]<<24|e[2]<<16|e[1]<<8|e[0],T=e[7]<<24|e[6]<<16|e[5]<<8|e[4],$=e[11]<<24|e[10]<<16|e[9]<<8|e[8],E=e[15]<<24|e[14]<<16|e[13]<<8|e[12],A=n,y=i,m=s,b=c,o=u,d=h,M=l,K=g,V=D,J=C,X=x,f=w,_=R,U=T,q=$,P=E,N=0;N<$c;N+=2)A=A+o|0,_^=A,_=_>>>32-16|_<<16,V=V+_|0,o^=V,o=o>>>32-12|o<<12,y=y+d|0,U^=y,U=U>>>32-16|U<<16,J=J+U|0,d^=J,d=d>>>32-12|d<<12,m=m+M|0,q^=m,q=q>>>32-16|q<<16,X=X+q|0,M^=X,M=M>>>32-12|M<<12,b=b+K|0,P^=b,P=P>>>32-16|P<<16,f=f+P|0,K^=f,K=K>>>32-12|K<<12,m=m+M|0,q^=m,q=q>>>32-8|q<<8,X=X+q|0,M^=X,M=M>>>32-7|M<<7,b=b+K|0,P^=b,P=P>>>32-8|P<<8,f=f+P|0,K^=f,K=K>>>32-7|K<<7,y=y+d|0,U^=y,U=U>>>32-8|U<<8,J=J+U|0,d^=J,d=d>>>32-7|d<<7,A=A+o|0,_^=A,_=_>>>32-8|_<<8,V=V+_|0,o^=V,o=o>>>32-7|o<<7,A=A+d|0,P^=A,P=P>>>32-16|P<<16,X=X+P|0,d^=X,d=d>>>32-12|d<<12,y=y+M|0,_^=y,_=_>>>32-16|_<<16,f=f+_|0,M^=f,M=M>>>32-12|M<<12,m=m+K|0,U^=m,U=U>>>32-16|U<<16,V=V+U|0,K^=V,K=K>>>32-12|K<<12,b=b+o|0,q^=b,q=q>>>32-16|q<<16,J=J+q|0,o^=J,o=o>>>32-12|o<<12,m=m+K|0,U^=m,U=U>>>32-8|U<<8,V=V+U|0,K^=V,K=K>>>32-7|K<<7,b=b+o|0,q^=b,q=q>>>32-8|q<<8,J=J+q|0,o^=J,o=o>>>32-7|o<<7,y=y+M|0,_^=y,_=_>>>32-8|_<<8,f=f+_|0,M^=f,M=M>>>32-7|M<<7,A=A+d|0,P^=A,P=P>>>32-8|P<<8,X=X+P|0,d^=X,d=d>>>32-7|d<<7;st.writeUint32LE(A+n|0,t,0),st.writeUint32LE(y+i|0,t,4),st.writeUint32LE(m+s|0,t,8),st.writeUint32LE(b+c|0,t,12),st.writeUint32LE(o+u|0,t,16),st.writeUint32LE(d+h|0,t,20),st.writeUint32LE(M+l|0,t,24),st.writeUint32LE(K+g|0,t,28),st.writeUint32LE(V+D|0,t,32),st.writeUint32LE(J+C|0,t,36),st.writeUint32LE(X+x|0,t,40),st.writeUint32LE(f+w|0,t,44),st.writeUint32LE(_+R|0,t,48),st.writeUint32LE(U+T|0,t,52),st.writeUint32LE(q+$|0,t,56),st.writeUint32LE(P+E|0,t,60)}function ss(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,c;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),c=s.length-e.length,s.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,c=i}for(var u=new Uint8Array(64),h=0;h<r.length;h+=64){Bc(u,s,t);for(var l=h;l<h+64&&l<r.length;l++)n[l]=r[l]^u[l-h];Hc(s,0,c)}return Rn.wipe(u),i===0&&Rn.wipe(s),n}Vr.streamXOR=ss;function zc(t,e,r,n){return n===void 0&&(n=0),Rn.wipe(r),ss(t,e,r,r,n)}Vr.stream=zc;function Hc(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var os={},zt={};Object.defineProperty(zt,"__esModule",{value:!0});function Kc(t,e,r){return~(t-1)&e|t-1&r}zt.select=Kc;function qc(t,e){return(t|0)-(e|0)-1>>>31&1}zt.lessOrEqual=qc;function as(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}zt.compare=as;function Vc(t,e){return t.length===0||e.length===0?!1:as(t,e)!==0}zt.equal=Vc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=zt,r=pt;t.DIGEST_LENGTH=16;var n=function(){function c(u){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=u[0]|u[1]<<8;this._r[0]=h&8191;var l=u[2]|u[3]<<8;this._r[1]=(h>>>13|l<<3)&8191;var g=u[4]|u[5]<<8;this._r[2]=(l>>>10|g<<6)&7939;var D=u[6]|u[7]<<8;this._r[3]=(g>>>7|D<<9)&8191;var C=u[8]|u[9]<<8;this._r[4]=(D>>>4|C<<12)&255,this._r[5]=C>>>1&8190;var x=u[10]|u[11]<<8;this._r[6]=(C>>>14|x<<2)&8191;var w=u[12]|u[13]<<8;this._r[7]=(x>>>11|w<<5)&8065;var R=u[14]|u[15]<<8;this._r[8]=(w>>>8|R<<8)&8191,this._r[9]=R>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return c.prototype._blocks=function(u,h,l){for(var g=this._fin?0:2048,D=this._h[0],C=this._h[1],x=this._h[2],w=this._h[3],R=this._h[4],T=this._h[5],$=this._h[6],E=this._h[7],A=this._h[8],y=this._h[9],m=this._r[0],b=this._r[1],o=this._r[2],d=this._r[3],M=this._r[4],K=this._r[5],V=this._r[6],J=this._r[7],X=this._r[8],f=this._r[9];l>=16;){var _=u[h+0]|u[h+1]<<8;D+=_&8191;var U=u[h+2]|u[h+3]<<8;C+=(_>>>13|U<<3)&8191;var q=u[h+4]|u[h+5]<<8;x+=(U>>>10|q<<6)&8191;var P=u[h+6]|u[h+7]<<8;w+=(q>>>7|P<<9)&8191;var N=u[h+8]|u[h+9]<<8;R+=(P>>>4|N<<12)&8191,T+=N>>>1&8191;var j=u[h+10]|u[h+11]<<8;$+=(N>>>14|j<<2)&8191;var B=u[h+12]|u[h+13]<<8;E+=(j>>>11|B<<5)&8191;var Q=u[h+14]|u[h+15]<<8;A+=(B>>>8|Q<<8)&8191,y+=Q>>>5|g;var H=0,ee=H;ee+=D*m,ee+=C*(5*f),ee+=x*(5*X),ee+=w*(5*J),ee+=R*(5*V),H=ee>>>13,ee&=8191,ee+=T*(5*K),ee+=$*(5*M),ee+=E*(5*d),ee+=A*(5*o),ee+=y*(5*b),H+=ee>>>13,ee&=8191;var Y=H;Y+=D*b,Y+=C*m,Y+=x*(5*f),Y+=w*(5*X),Y+=R*(5*J),H=Y>>>13,Y&=8191,Y+=T*(5*V),Y+=$*(5*K),Y+=E*(5*M),Y+=A*(5*d),Y+=y*(5*o),H+=Y>>>13,Y&=8191;var ae=H;ae+=D*o,ae+=C*b,ae+=x*m,ae+=w*(5*f),ae+=R*(5*X),H=ae>>>13,ae&=8191,ae+=T*(5*J),ae+=$*(5*V),ae+=E*(5*K),ae+=A*(5*M),ae+=y*(5*d),H+=ae>>>13,ae&=8191;var L=H;L+=D*d,L+=C*o,L+=x*b,L+=w*m,L+=R*(5*f),H=L>>>13,L&=8191,L+=T*(5*X),L+=$*(5*J),L+=E*(5*V),L+=A*(5*K),L+=y*(5*M),H+=L>>>13,L&=8191;var I=H;I+=D*M,I+=C*d,I+=x*o,I+=w*b,I+=R*m,H=I>>>13,I&=8191,I+=T*(5*f),I+=$*(5*X),I+=E*(5*J),I+=A*(5*V),I+=y*(5*K),H+=I>>>13,I&=8191;var S=H;S+=D*K,S+=C*M,S+=x*d,S+=w*o,S+=R*b,H=S>>>13,S&=8191,S+=T*m,S+=$*(5*f),S+=E*(5*X),S+=A*(5*J),S+=y*(5*V),H+=S>>>13,S&=8191;var a=H;a+=D*V,a+=C*K,a+=x*M,a+=w*d,a+=R*o,H=a>>>13,a&=8191,a+=T*b,a+=$*m,a+=E*(5*f),a+=A*(5*X),a+=y*(5*J),H+=a>>>13,a&=8191;var v=H;v+=D*J,v+=C*V,v+=x*K,v+=w*M,v+=R*d,H=v>>>13,v&=8191,v+=T*o,v+=$*b,v+=E*m,v+=A*(5*f),v+=y*(5*X),H+=v>>>13,v&=8191;var z=H;z+=D*X,z+=C*J,z+=x*V,z+=w*K,z+=R*M,H=z>>>13,z&=8191,z+=T*d,z+=$*o,z+=E*b,z+=A*m,z+=y*(5*f),H+=z>>>13,z&=8191;var k=H;k+=D*f,k+=C*X,k+=x*J,k+=w*V,k+=R*K,H=k>>>13,k&=8191,k+=T*M,k+=$*d,k+=E*o,k+=A*b,k+=y*m,H+=k>>>13,k&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,Y+=H,D=ee,C=Y,x=ae,w=L,R=I,T=S,$=a,E=v,A=z,y=k,h+=16,l-=16}this._h[0]=D,this._h[1]=C,this._h[2]=x,this._h[3]=w,this._h[4]=R,this._h[5]=T,this._h[6]=$,this._h[7]=E,this._h[8]=A,this._h[9]=y},c.prototype.finish=function(u,h){h===void 0&&(h=0);var l=new Uint16Array(10),g,D,C,x;if(this._leftover){for(x=this._leftover,this._buffer[x++]=1;x<16;x++)this._buffer[x]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,x=2;x<10;x++)this._h[x]+=g,g=this._h[x]>>>13,this._h[x]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,l[0]=this._h[0]+5,g=l[0]>>>13,l[0]&=8191,x=1;x<10;x++)l[x]=this._h[x]+g,g=l[x]>>>13,l[x]&=8191;for(l[9]-=1<<13,D=(g^1)-1,x=0;x<10;x++)l[x]&=D;for(D=~D,x=0;x<10;x++)this._h[x]=this._h[x]&D|l[x];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,C=this._h[0]+this._pad[0],this._h[0]=C&65535,x=1;x<8;x++)C=(this._h[x]+this._pad[x]|0)+(C>>>16)|0,this._h[x]=C&65535;return u[h+0]=this._h[0]>>>0,u[h+1]=this._h[0]>>>8,u[h+2]=this._h[1]>>>0,u[h+3]=this._h[1]>>>8,u[h+4]=this._h[2]>>>0,u[h+5]=this._h[2]>>>8,u[h+6]=this._h[3]>>>0,u[h+7]=this._h[3]>>>8,u[h+8]=this._h[4]>>>0,u[h+9]=this._h[4]>>>8,u[h+10]=this._h[5]>>>0,u[h+11]=this._h[5]>>>8,u[h+12]=this._h[6]>>>0,u[h+13]=this._h[6]>>>8,u[h+14]=this._h[7]>>>0,u[h+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(u){var h=0,l=u.length,g;if(this._leftover){g=16-this._leftover,g>l&&(g=l);for(var D=0;D<g;D++)this._buffer[this._leftover+D]=u[h+D];if(l-=g,h+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(l>=16&&(g=l-l%16,this._blocks(u,h,g),h+=g,l-=g),l){for(var D=0;D<l;D++)this._buffer[this._leftover+D]=u[h+D];this._leftover+=l}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var u=new Uint8Array(16);return this.finish(u),u},c.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();t.Poly1305=n;function i(c,u){var h=new n(c);h.update(u);var l=h.digest();return h.clean(),l}t.oneTimeAuth=i;function s(c,u){return c.length!==t.DIGEST_LENGTH||u.length!==t.DIGEST_LENGTH?!1:e.equal(c,u)}t.equal=s}(os),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vr,r=os,n=pt,i=re,s=zt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),u=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,g,D,C){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var x=new Uint8Array(16);x.set(l,x.length-l.length);var w=new Uint8Array(32);e.stream(this._key,x,w,4);var R=g.length+this.tagLength,T;if(C){if(C.length!==R)throw new Error("ChaCha20Poly1305: incorrect destination length");T=C}else T=new Uint8Array(R);return e.streamXOR(this._key,x,g,T,4),this._authenticate(T.subarray(T.length-this.tagLength,T.length),w,T.subarray(0,T.length-this.tagLength),D),n.wipe(x),T},h.prototype.open=function(l,g,D,C){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var x=new Uint8Array(16);x.set(l,x.length-l.length);var w=new Uint8Array(32);e.stream(this._key,x,w,4);var R=new Uint8Array(this.tagLength);if(this._authenticate(R,w,g.subarray(0,g.length-this.tagLength),D),!s.equal(R,g.subarray(g.length-this.tagLength,g.length)))return null;var T=g.length-this.tagLength,$;if(C){if(C.length!==T)throw new Error("ChaCha20Poly1305: incorrect destination length");$=C}else $=new Uint8Array(T);return e.streamXOR(this._key,x,g.subarray(0,g.length-this.tagLength),$,4),n.wipe(x),$},h.prototype.clean=function(){return n.wipe(this._key),this},h.prototype._authenticate=function(l,g,D,C){var x=new r.Poly1305(g);C&&(x.update(C),C.length%16>0&&x.update(c.subarray(C.length%16))),x.update(D),D.length%16>0&&x.update(c.subarray(D.length%16));var w=new Uint8Array(8);C&&i.writeUint64LE(C.length,w),x.update(w),i.writeUint64LE(D.length,w),x.update(w);for(var R=x.digest(),T=0;T<R.length;T++)l[T]=R[T];x.clean(),n.wipe(R),n.wipe(w)},h}();t.ChaCha20Poly1305=u}(Ln);var cs={},mr={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});function Gc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Fn.isSerializableHash=Gc,Object.defineProperty(mr,"__esModule",{value:!0});var Ot=Fn,Wc=zt,Yc=pt,us=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),Ot.isSerializableHash(this._inner)&&Ot.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Yc.wipe(n)}return t.prototype.reset=function(){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Ot.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ot.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();mr.HMAC=us;function kc(t,e,r){var n=new us(t,e);n.update(r);var i=n.digest();return n.clean(),i}mr.hmac=kc,mr.equal=Wc.equal,Object.defineProperty(cs,"__esModule",{value:!0});var hs=mr,fs=pt,Jc=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=hs.hmac(this._hash,n,r);this._hmac=new hs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),fs.wipe(this._buffer),fs.wipe(this._counter),this._bufpos=0},t}(),Xc=cs.HKDF=Jc,nr={},Un={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});var ls=65536,Zc=function(){function t(){this.isAvailable=!1,this.isInstantiated=!1;var e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var r=new Uint8Array(e),n=0;n<r.length;n+=ls)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,ls)));return r},t}();Mn.BrowserRandomSource=Zc;function Qc(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 jn={},eu={},tu=Object.freeze({__proto__:null,default:eu}),ru=wn(tu);Object.defineProperty(jn,"__esModule",{value:!0});var nu=pt,iu=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Qc<"u"){var e=ru;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 n=new Uint8Array(e),i=0;i<n.length;i++)n[i]=r[i];return nu.wipe(r),n},t}();jn.NodeRandomSource=iu,Object.defineProperty(Un,"__esModule",{value:!0});var su=Mn,ou=jn,au=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new su.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new ou.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}();Un.SystemRandomSource=au,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Un,r=re,n=pt;t.defaultRandomSource=new e.SystemRandomSource;function i(l,g){return g===void 0&&(g=t.defaultRandomSource),g.randomBytes(l)}t.randomBytes=i;function s(l){l===void 0&&(l=t.defaultRandomSource);var g=i(4,l),D=r.readUint32LE(g);return n.wipe(g),D}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function u(l,g,D){if(g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource),g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");for(var C="",x=g.length,w=256-256%x;l>0;){for(var R=i(Math.ceil(l*256/w),D),T=0;T<R.length&&l>0;T++){var $=R[T];$<w&&(C+=g.charAt($%x),l--)}n.wipe(R)}return C}t.randomString=u;function h(l,g,D){g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource);var C=Math.ceil(l/(Math.log(g.length)/Math.LN2));return u(C,g,D)}t.randomStringForEntropy=h}(nr);var Yr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function u(){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 u.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},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},u.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 g=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&l>0;)this._buffer[this._bufferLength++]=h[g++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(g=s(this._temp,this._state,h,g,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[g++],l--;return this},u.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,g=this._bufferLength,D=l/536870912|0,C=l<<3,x=l%64<56?64:128;this._buffer[g]=128;for(var w=g+1;w<x-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,x-8),e.writeUint32BE(C,this._buffer,x-4),s(this._temp,this._state,this._buffer,0,x),this._finished=!0}for(var w=0;w<this.digestLength/4;w++)e.writeUint32BE(this._state[w],h,w*4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.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}},u.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},u.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(u,h,l,g,D){for(;D>=64;){for(var C=h[0],x=h[1],w=h[2],R=h[3],T=h[4],$=h[5],E=h[6],A=h[7],y=0;y<16;y++){var m=g+y*4;u[y]=e.readUint32BE(l,m)}for(var y=16;y<64;y++){var b=u[y-2],o=(b>>>17|b<<32-17)^(b>>>19|b<<32-19)^b>>>10;b=u[y-15];var d=(b>>>7|b<<32-7)^(b>>>18|b<<32-18)^b>>>3;u[y]=(o+u[y-7]|0)+(d+u[y-16]|0)}for(var y=0;y<64;y++){var o=(((T>>>6|T<<26)^(T>>>11|T<<21)^(T>>>25|T<<7))+(T&$^~T&E)|0)+(A+(i[y]+u[y]|0)|0)|0,d=((C>>>2|C<<32-2)^(C>>>13|C<<32-13)^(C>>>22|C<<32-22))+(C&x^C&w^x&w)|0;A=E,E=$,$=T,T=R+o|0,R=w,w=x,x=C,C=o+d|0}h[0]+=C,h[1]+=x,h[2]+=w,h[3]+=R,h[4]+=T,h[5]+=$,h[6]+=E,h[7]+=A,g+=64,D-=64}return g}function c(u){var h=new n;h.update(u);var l=h.digest();return h.clean(),l}t.hash=c})(Yr);var $n={};(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 n(y){var m=new Float64Array(16);if(y)for(var b=0;b<y.length;b++)m[b]=y[b];return m}var i=new Uint8Array(32);i[0]=9;var s=n([56129,1]);function c(y){for(var m=1,b=0;b<16;b++){var o=y[b]+m+65535;m=Math.floor(o/65536),y[b]=o-m*65536}y[0]+=m-1+37*(m-1)}function u(y,m,b){for(var o=~(b-1),d=0;d<16;d++){var M=o&(y[d]^m[d]);y[d]^=M,m[d]^=M}}function h(y,m){for(var b=n(),o=n(),d=0;d<16;d++)o[d]=m[d];c(o),c(o),c(o);for(var M=0;M<2;M++){b[0]=o[0]-65517;for(var d=1;d<15;d++)b[d]=o[d]-65535-(b[d-1]>>16&1),b[d-1]&=65535;b[15]=o[15]-32767-(b[14]>>16&1);var K=b[15]>>16&1;b[14]&=65535,u(o,b,1-K)}for(var d=0;d<16;d++)y[2*d]=o[d]&255,y[2*d+1]=o[d]>>8}function l(y,m){for(var b=0;b<16;b++)y[b]=m[2*b]+(m[2*b+1]<<8);y[15]&=32767}function g(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]+b[o]}function D(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]-b[o]}function C(y,m,b){var o,d,M=0,K=0,V=0,J=0,X=0,f=0,_=0,U=0,q=0,P=0,N=0,j=0,B=0,Q=0,H=0,ee=0,Y=0,ae=0,L=0,I=0,S=0,a=0,v=0,z=0,k=0,fe=0,ye=0,de=0,me=0,Ue=0,Te=0,ve=b[0],pe=b[1],le=b[2],ue=b[3],ce=b[4],oe=b[5],se=b[6],te=b[7],he=b[8],ge=b[9],ne=b[10],_e=b[11],be=b[12],Ee=b[13],De=b[14],we=b[15];o=m[0],M+=o*ve,K+=o*pe,V+=o*le,J+=o*ue,X+=o*ce,f+=o*oe,_+=o*se,U+=o*te,q+=o*he,P+=o*ge,N+=o*ne,j+=o*_e,B+=o*be,Q+=o*Ee,H+=o*De,ee+=o*we,o=m[1],K+=o*ve,V+=o*pe,J+=o*le,X+=o*ue,f+=o*ce,_+=o*oe,U+=o*se,q+=o*te,P+=o*he,N+=o*ge,j+=o*ne,B+=o*_e,Q+=o*be,H+=o*Ee,ee+=o*De,Y+=o*we,o=m[2],V+=o*ve,J+=o*pe,X+=o*le,f+=o*ue,_+=o*ce,U+=o*oe,q+=o*se,P+=o*te,N+=o*he,j+=o*ge,B+=o*ne,Q+=o*_e,H+=o*be,ee+=o*Ee,Y+=o*De,ae+=o*we,o=m[3],J+=o*ve,X+=o*pe,f+=o*le,_+=o*ue,U+=o*ce,q+=o*oe,P+=o*se,N+=o*te,j+=o*he,B+=o*ge,Q+=o*ne,H+=o*_e,ee+=o*be,Y+=o*Ee,ae+=o*De,L+=o*we,o=m[4],X+=o*ve,f+=o*pe,_+=o*le,U+=o*ue,q+=o*ce,P+=o*oe,N+=o*se,j+=o*te,B+=o*he,Q+=o*ge,H+=o*ne,ee+=o*_e,Y+=o*be,ae+=o*Ee,L+=o*De,I+=o*we,o=m[5],f+=o*ve,_+=o*pe,U+=o*le,q+=o*ue,P+=o*ce,N+=o*oe,j+=o*se,B+=o*te,Q+=o*he,H+=o*ge,ee+=o*ne,Y+=o*_e,ae+=o*be,L+=o*Ee,I+=o*De,S+=o*we,o=m[6],_+=o*ve,U+=o*pe,q+=o*le,P+=o*ue,N+=o*ce,j+=o*oe,B+=o*se,Q+=o*te,H+=o*he,ee+=o*ge,Y+=o*ne,ae+=o*_e,L+=o*be,I+=o*Ee,S+=o*De,a+=o*we,o=m[7],U+=o*ve,q+=o*pe,P+=o*le,N+=o*ue,j+=o*ce,B+=o*oe,Q+=o*se,H+=o*te,ee+=o*he,Y+=o*ge,ae+=o*ne,L+=o*_e,I+=o*be,S+=o*Ee,a+=o*De,v+=o*we,o=m[8],q+=o*ve,P+=o*pe,N+=o*le,j+=o*ue,B+=o*ce,Q+=o*oe,H+=o*se,ee+=o*te,Y+=o*he,ae+=o*ge,L+=o*ne,I+=o*_e,S+=o*be,a+=o*Ee,v+=o*De,z+=o*we,o=m[9],P+=o*ve,N+=o*pe,j+=o*le,B+=o*ue,Q+=o*ce,H+=o*oe,ee+=o*se,Y+=o*te,ae+=o*he,L+=o*ge,I+=o*ne,S+=o*_e,a+=o*be,v+=o*Ee,z+=o*De,k+=o*we,o=m[10],N+=o*ve,j+=o*pe,B+=o*le,Q+=o*ue,H+=o*ce,ee+=o*oe,Y+=o*se,ae+=o*te,L+=o*he,I+=o*ge,S+=o*ne,a+=o*_e,v+=o*be,z+=o*Ee,k+=o*De,fe+=o*we,o=m[11],j+=o*ve,B+=o*pe,Q+=o*le,H+=o*ue,ee+=o*ce,Y+=o*oe,ae+=o*se,L+=o*te,I+=o*he,S+=o*ge,a+=o*ne,v+=o*_e,z+=o*be,k+=o*Ee,fe+=o*De,ye+=o*we,o=m[12],B+=o*ve,Q+=o*pe,H+=o*le,ee+=o*ue,Y+=o*ce,ae+=o*oe,L+=o*se,I+=o*te,S+=o*he,a+=o*ge,v+=o*ne,z+=o*_e,k+=o*be,fe+=o*Ee,ye+=o*De,de+=o*we,o=m[13],Q+=o*ve,H+=o*pe,ee+=o*le,Y+=o*ue,ae+=o*ce,L+=o*oe,I+=o*se,S+=o*te,a+=o*he,v+=o*ge,z+=o*ne,k+=o*_e,fe+=o*be,ye+=o*Ee,de+=o*De,me+=o*we,o=m[14],H+=o*ve,ee+=o*pe,Y+=o*le,ae+=o*ue,L+=o*ce,I+=o*oe,S+=o*se,a+=o*te,v+=o*he,z+=o*ge,k+=o*ne,fe+=o*_e,ye+=o*be,de+=o*Ee,me+=o*De,Ue+=o*we,o=m[15],ee+=o*ve,Y+=o*pe,ae+=o*le,L+=o*ue,I+=o*ce,S+=o*oe,a+=o*se,v+=o*te,z+=o*he,k+=o*ge,fe+=o*ne,ye+=o*_e,de+=o*be,me+=o*Ee,Ue+=o*De,Te+=o*we,M+=38*Y,K+=38*ae,V+=38*L,J+=38*I,X+=38*S,f+=38*a,_+=38*v,U+=38*z,q+=38*k,P+=38*fe,N+=38*ye,j+=38*de,B+=38*me,Q+=38*Ue,H+=38*Te,d=1,o=M+d+65535,d=Math.floor(o/65536),M=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=V+d+65535,d=Math.floor(o/65536),V=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=f+d+65535,d=Math.floor(o/65536),f=o-d*65536,o=_+d+65535,d=Math.floor(o/65536),_=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=P+d+65535,d=Math.floor(o/65536),P=o-d*65536,o=N+d+65535,d=Math.floor(o/65536),N=o-d*65536,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=Q+d+65535,d=Math.floor(o/65536),Q=o-d*65536,o=H+d+65535,d=Math.floor(o/65536),H=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,M+=d-1+37*(d-1),d=1,o=M+d+65535,d=Math.floor(o/65536),M=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=V+d+65535,d=Math.floor(o/65536),V=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=f+d+65535,d=Math.floor(o/65536),f=o-d*65536,o=_+d+65535,d=Math.floor(o/65536),_=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=P+d+65535,d=Math.floor(o/65536),P=o-d*65536,o=N+d+65535,d=Math.floor(o/65536),N=o-d*65536,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=Q+d+65535,d=Math.floor(o/65536),Q=o-d*65536,o=H+d+65535,d=Math.floor(o/65536),H=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,M+=d-1+37*(d-1),y[0]=M,y[1]=K,y[2]=V,y[3]=J,y[4]=X,y[5]=f,y[6]=_,y[7]=U,y[8]=q,y[9]=P,y[10]=N,y[11]=j,y[12]=B,y[13]=Q,y[14]=H,y[15]=ee}function x(y,m){C(y,m,m)}function w(y,m){for(var b=n(),o=0;o<16;o++)b[o]=m[o];for(var o=253;o>=0;o--)x(b,b),o!==2&&o!==4&&C(b,b,m);for(var o=0;o<16;o++)y[o]=b[o]}function R(y,m){for(var b=new Uint8Array(32),o=new Float64Array(80),d=n(),M=n(),K=n(),V=n(),J=n(),X=n(),f=0;f<31;f++)b[f]=y[f];b[31]=y[31]&127|64,b[0]&=248,l(o,m);for(var f=0;f<16;f++)M[f]=o[f];d[0]=V[0]=1;for(var f=254;f>=0;--f){var _=b[f>>>3]>>>(f&7)&1;u(d,M,_),u(K,V,_),g(J,d,K),D(d,d,K),g(K,M,V),D(M,M,V),x(V,J),x(X,d),C(d,K,d),C(K,M,J),g(J,d,K),D(d,d,K),x(M,d),D(K,V,X),C(d,K,s),g(d,d,V),C(K,K,d),C(d,V,X),C(V,M,o),x(M,J),u(d,M,_),u(K,V,_)}for(var f=0;f<16;f++)o[f+16]=d[f],o[f+32]=K[f],o[f+48]=M[f],o[f+64]=V[f];var U=o.subarray(32),q=o.subarray(16);w(U,U),C(q,q,U);var P=new Uint8Array(32);return h(P,q),P}t.scalarMult=R;function T(y){return R(y,i)}t.scalarMultBase=T;function $(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var m=new Uint8Array(y),b=T(m);return{publicKey:b,secretKey:m}}t.generateKeyPairFromSeed=$;function E(y){var m=e.randomBytes(32,y),b=$(m);return r.wipe(m),b}t.generateKeyPair=E;function A(y,m,b){if(b===void 0&&(b=!1),y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(m.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=R(y,m);if(b){for(var d=0,M=0;M<o.length;M++)d|=o[M];if(d===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=A})($n);function ds(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Bn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=ds(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function cu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),l=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var R=0,T=0,$=0,E=w.length;$!==E&&w[$]===0;)$++,R++;for(var A=(E-$)*g+1>>>0,y=new Uint8Array(A);$!==E;){for(var m=w[$],b=0,o=A-1;(m!==0||b<T)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%u>>>0,m=m/u>>>0;if(m!==0)throw new Error("Non-zero carry");T=b,$++}for(var d=A-T;d!==A&&y[d]===0;)d++;for(var M=h.repeat(R);d<A;++d)M+=t.charAt(y[d]);return M}function C(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var R=0;if(w[R]!==" "){for(var T=0,$=0;w[R]===h;)T++,R++;for(var E=(w.length-R)*l+1>>>0,A=new Uint8Array(E);w[R];){var y=r[w.charCodeAt(R)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<$)&&b!==-1;b--,m++)y+=u*A[b]>>>0,A[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");$=m,R++}if(w[R]!==" "){for(var o=E-$;o!==E&&A[o]===0;)o++;for(var d=new Uint8Array(T+(E-o)),M=T;o!==E;)d[M++]=A[o++];return d}}}function x(w){var R=C(w);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:x}}var uu=cu,hu=uu;const ps=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")},fu=t=>new TextEncoder().encode(t),lu=t=>new TextDecoder().decode(t);class du{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class pu{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gs(this,e)}}class gu{constructor(e){this.decoders=e}or(e){return gs(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const gs=(t,e)=>new gu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class vu{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new du(e,r,n),this.decoder=new pu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const kr=({name:t,prefix:e,encode:r,decode:n})=>new vu(t,e,r,n),wr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=hu(r,e);return kr({prefix:t,name:e,encode:n,decode:s=>ps(i(s))})},yu=(t,e,r,n)=>{const i={};for(let g=0;g<e.length;++g)i[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,l=0;for(let g=0;g<s;++g){const D=i[t[g]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|D,u+=r,u>=8&&(u-=8,c[l++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},_u=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>kr({prefix:e,name:t,encode(i){return _u(i,n,r)},decode(i){return yu(i,n,r,t)}}),bu=kr({prefix:"\0",name:"identity",encode:t=>lu(t),decode:t=>fu(t)});var mu=Object.freeze({__proto__:null,identity:bu});const wu=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Eu=Object.freeze({__proto__:null,base2:wu});const Du=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xu=Object.freeze({__proto__:null,base8:Du});const Su=wr({prefix:"9",name:"base10",alphabet:"0123456789"});var Ou=Object.freeze({__proto__:null,base10:Su});const Au=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Iu=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lu=Object.freeze({__proto__:null,base16:Au,base16upper:Iu});const Cu=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Nu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ru=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ju=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $u=Object.freeze({__proto__:null,base32:Cu,base32upper:Tu,base32pad:Nu,base32padupper:Pu,base32hex:Ru,base32hexupper:Fu,base32hexpad:Uu,base32hexpadupper:Mu,base32z:ju});const Bu=wr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zu=wr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hu=Object.freeze({__proto__:null,base36:Bu,base36upper:zu});const Ku=wr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qu=wr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vu=Object.freeze({__proto__:null,base58btc:Ku,base58flickr:qu});const Gu=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ku=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ju=Object.freeze({__proto__:null,base64:Gu,base64pad:Wu,base64url:Yu,base64urlpad:ku});const vs=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}"),Xu=vs.reduce((t,e,r)=>(t[r]=e,t),[]),Zu=vs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Qu(t){return t.reduce((e,r)=>(e+=Xu[r],e),"")}function eh(t){const e=[];for(const r of t){const n=Zu[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const th=kr({prefix:"\u{1F680}",name:"base256emoji",encode:Qu,decode:eh});var rh=Object.freeze({__proto__:null,base256emoji:th}),nh=_s,ys=128,ih=127,sh=~ih,oh=Math.pow(2,31);function _s(t,e,r){e=e||[],r=r||0;for(var n=r;t>=oh;)e[r++]=t&255|ys,t/=128;for(;t&sh;)e[r++]=t&255|ys,t>>>=7;return e[r]=t|0,_s.bytes=r-n+1,e}var ah=zn,ch=128,bs=127;function zn(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw zn.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&bs)<<i:(c&bs)*Math.pow(2,i),i+=7}while(c>=ch);return zn.bytes=s-n,r}var uh=Math.pow(2,7),hh=Math.pow(2,14),fh=Math.pow(2,21),lh=Math.pow(2,28),dh=Math.pow(2,35),ph=Math.pow(2,42),gh=Math.pow(2,49),vh=Math.pow(2,56),yh=Math.pow(2,63),_h=function(t){return t<uh?1:t<hh?2:t<fh?3:t<lh?4:t<dh?5:t<ph?6:t<gh?7:t<vh?8:t<yh?9:10},bh={encode:nh,decode:ah,encodingLength:_h},ms=bh;const ws=(t,e,r=0)=>(ms.encode(t,e,r),e),Es=t=>ms.encodingLength(t),Hn=(t,e)=>{const r=e.byteLength,n=Es(t),i=n+Es(r),s=new Uint8Array(i+r);return ws(t,s,0),ws(r,s,n),s.set(e,i),new mh(t,r,e,s)};class mh{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Ds=({name:t,code:e,encode:r})=>new wh(t,e,r);class wh{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Hn(this.code,r):r.then(n=>Hn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const xs=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Eh=Ds({name:"sha2-256",code:18,encode:xs("SHA-256")}),Dh=Ds({name:"sha2-512",code:19,encode:xs("SHA-512")});var xh=Object.freeze({__proto__:null,sha256:Eh,sha512:Dh});const Ss=0,Sh="identity",Os=ps;var Oh=Object.freeze({__proto__:null,identity:{code:Ss,name:Sh,encode:Os,digest:t=>Hn(Ss,Os(t))}});new TextEncoder,new TextDecoder;const As={...mu,...Eu,...xu,...Ou,...Lu,...$u,...Hu,...Vu,...Ju,...rh};({...xh,...Oh});function Is(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Ls=Is("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),Kn=Is("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=ds(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Cs={utf8:Ls,"utf-8":Ls,hex:As.base16,latin1:Kn,ascii:Kn,binary:Kn,...As};function ht(t,e="utf8"){const r=Cs[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function ft(t,e="utf8"){const r=Cs[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Ts=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Ah=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),Ih=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Lh=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),Ch=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Th=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Nh=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Ph=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ns=3,Rh=[["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",Nh]],Ps=[["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 Fh(t){return t?Rs(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Th:typeof navigator<"u"?Rs(navigator.userAgent):jh()}function Uh(t){return t!==""&&Rh.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function Rs(t){var e=Uh(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Ch;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Ns&&(i=Ts(Ts([],i,!0),$h(Ns-i.length),!0)):i=[];var s=i.join("."),c=Mh(t),u=Ph.exec(t);return u&&u[1]?new Lh(r,s,c,u[1]):new Ah(r,s,c)}function Mh(t){for(var e=0,r=Ps.length;e<r;e++){var n=Ps[e],i=n[0],s=n[1],c=s.exec(t);if(c)return i}return null}function jh(){var t=typeof process<"u"&&process.version;return t?new Ih(process.version.slice(1)):null}function $h(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Le={},Fs={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.delay=void 0;function Bh(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Jr.delay=Bh;var ir={},qn={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.ONE_THOUSAND=sr.ONE_HUNDRED=void 0,sr.ONE_HUNDRED=100,sr.ONE_THOUSAND=1e3;var Us={};(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})(Us),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sr,t),r(Us,t)}(qn),Object.defineProperty(ir,"__esModule",{value:!0}),ir.fromMiliseconds=ir.toMiliseconds=void 0;const Ms=qn;function zh(t){return t*Ms.ONE_THOUSAND}ir.toMiliseconds=zh;function Hh(t){return Math.floor(t/Ms.ONE_THOUSAND)}ir.fromMiliseconds=Hh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Jr,t),r(ir,t)}(Fs);var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.Watch=void 0;class js{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 n=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:n})}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}}Er.Watch=js,Er.default=js;var $s={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.IWatch=void 0;class Kh{}Xr.IWatch=Kh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xr,t)}($s),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Fs,t),r(Er,t),r($s,t),r(qn,t)}(Le);var Se={};Object.defineProperty(Se,"__esModule",{value:!0}),Se.getLocalStorage=Se.getLocalStorageOrThrow=Se.getCrypto=Se.getCryptoOrThrow=zs=Se.getLocation=Se.getLocationOrThrow=Vn=Se.getNavigator=Se.getNavigatorOrThrow=Bs=Se.getDocument=Se.getDocumentOrThrow=Se.getFromWindowOrThrow=Se.getFromWindow=void 0;function Wt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Se.getFromWindow=Wt;function or(t){const e=Wt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Se.getFromWindowOrThrow=or;function qh(){return or("document")}Se.getDocumentOrThrow=qh;function Vh(){return Wt("document")}var Bs=Se.getDocument=Vh;function Gh(){return or("navigator")}Se.getNavigatorOrThrow=Gh;function Wh(){return Wt("navigator")}var Vn=Se.getNavigator=Wh;function Yh(){return or("location")}Se.getLocationOrThrow=Yh;function kh(){return Wt("location")}var zs=Se.getLocation=kh;function Jh(){return or("crypto")}Se.getCryptoOrThrow=Jh;function Xh(){return Wt("crypto")}Se.getCrypto=Xh;function Zh(){return or("localStorage")}Se.getLocalStorageOrThrow=Zh;function Qh(){return Wt("localStorage")}Se.getLocalStorage=Qh;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});var Hs=Gn.getWindowMetadata=void 0;const Ks=Se;function ef(){let t,e;try{t=Ks.getDocumentOrThrow(),e=Ks.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),C=[];for(let x=0;x<D.length;x++){const w=D[x],R=w.getAttribute("rel");if(R&&R.toLowerCase().indexOf("icon")>-1){const T=w.getAttribute("href");if(T)if(T.toLowerCase().indexOf("https:")===-1&&T.toLowerCase().indexOf("http:")===-1&&T.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(T.indexOf("/")===0)$+=T;else{const E=e.pathname.split("/");E.pop(),$+=E.join("/")+"/"+T}C.push($)}else if(T.indexOf("//")===0){const $=e.protocol+T;C.push($)}else C.push(T)}}return C}function n(...D){const C=t.getElementsByTagName("meta");for(let x=0;x<C.length;x++){const w=C[x],R=["itemprop","property","name"].map(T=>w.getAttribute(T)).filter(T=>T?D.includes(T):!1);if(R.length&&R){const T=w.getAttribute("content");if(T)return T}}return""}function i(){let D=n("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return n("description","og:description","twitter:description","keywords")}const c=i(),u=s(),h=e.origin,l=r();return{description:u,url:h,icons:l,name:c}}Hs=Gn.getWindowMetadata=ef;var Dr={},tf=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qs="%[a-f0-9]{2}",Vs=new RegExp(qs,"gi"),Gs=new RegExp("("+qs+")+","gi");function Wn(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Wn(r),Wn(n))}function rf(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Vs),r=1;r<e.length;r++)t=Wn(e,r).join(""),e=t.match(Vs);return t}}function nf(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Gs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=rf(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Gs.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var c=i[s];t=t.replace(new RegExp(c,"g"),e[c])}return t}var sf=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 nf(t)}},of=(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)]},af=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var c=n[s],u=t[c];(i?e.indexOf(c)!==-1:e(c,u,t))&&(r[c]=u)}return r};(function(t){const e=tf,r=sf,n=of,i=af,s=E=>E==null,c=Symbol("encodeFragmentIdentifier");function u(E){switch(E.arrayFormat){case"index":return A=>(y,m)=>{const b=y.length;return m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),"[",b,"]"].join("")]:[...y,[g(A,E),"[",g(b,E),"]=",g(m,E)].join("")]};case"bracket":return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),"[]"].join("")]:[...y,[g(A,E),"[]=",g(m,E)].join("")];case"colon-list-separator":return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),":list="].join("")]:[...y,[g(A,E),":list=",g(m,E)].join("")];case"comma":case"separator":case"bracket-separator":{const A=E.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(m,b)=>b===void 0||E.skipNull&&b===null||E.skipEmptyString&&b===""?m:(b=b===null?"":b,m.length===0?[[g(y,E),A,g(b,E)].join("")]:[[m,g(b,E)].join(E.arrayFormatSeparator)])}default:return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,g(A,E)]:[...y,[g(A,E),"=",g(m,E)].join("")]}}function h(E){let A;switch(E.arrayFormat){case"index":return(y,m,b)=>{if(A=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!A){b[y]=m;return}b[y]===void 0&&(b[y]={}),b[y][A[1]]=m};case"bracket":return(y,m,b)=>{if(A=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!A){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"colon-list-separator":return(y,m,b)=>{if(A=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!A){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"comma":case"separator":return(y,m,b)=>{const o=typeof m=="string"&&m.includes(E.arrayFormatSeparator),d=typeof m=="string"&&!o&&D(m,E).includes(E.arrayFormatSeparator);m=d?D(m,E):m;const M=o||d?m.split(E.arrayFormatSeparator).map(K=>D(K,E)):m===null?m:D(m,E);b[y]=M};case"bracket-separator":return(y,m,b)=>{const o=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!o){b[y]=m&&D(m,E);return}const d=m===null?[]:m.split(E.arrayFormatSeparator).map(M=>D(M,E));if(b[y]===void 0){b[y]=d;return}b[y]=[].concat(b[y],d)};default:return(y,m,b)=>{if(b[y]===void 0){b[y]=m;return}b[y]=[].concat(b[y],m)}}}function l(E){if(typeof E!="string"||E.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(E,A){return A.encode?A.strict?e(E):encodeURIComponent(E):E}function D(E,A){return A.decode?r(E):E}function C(E){return Array.isArray(E)?E.sort():typeof E=="object"?C(Object.keys(E)).sort((A,y)=>Number(A)-Number(y)).map(A=>E[A]):E}function x(E){const A=E.indexOf("#");return A!==-1&&(E=E.slice(0,A)),E}function w(E){let A="";const y=E.indexOf("#");return y!==-1&&(A=E.slice(y)),A}function R(E){E=x(E);const A=E.indexOf("?");return A===-1?"":E.slice(A+1)}function T(E,A){return A.parseNumbers&&!Number.isNaN(Number(E))&&typeof E=="string"&&E.trim()!==""?E=Number(E):A.parseBooleans&&E!==null&&(E.toLowerCase()==="true"||E.toLowerCase()==="false")&&(E=E.toLowerCase()==="true"),E}function $(E,A){A=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},A),l(A.arrayFormatSeparator);const y=h(A),m=Object.create(null);if(typeof E!="string"||(E=E.trim().replace(/^[?#&]/,""),!E))return m;for(const b of E.split("&")){if(b==="")continue;let[o,d]=n(A.decode?b.replace(/\+/g," "):b,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?d:D(d,A),y(D(o,A),d,m)}for(const b of Object.keys(m)){const o=m[b];if(typeof o=="object"&&o!==null)for(const d of Object.keys(o))o[d]=T(o[d],A);else m[b]=T(o,A)}return A.sort===!1?m:(A.sort===!0?Object.keys(m).sort():Object.keys(m).sort(A.sort)).reduce((b,o)=>{const d=m[o];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?b[o]=C(d):b[o]=d,b},Object.create(null))}t.extract=R,t.parse=$,t.stringify=(E,A)=>{if(!E)return"";A=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},A),l(A.arrayFormatSeparator);const y=d=>A.skipNull&&s(E[d])||A.skipEmptyString&&E[d]==="",m=u(A),b={};for(const d of Object.keys(E))y(d)||(b[d]=E[d]);const o=Object.keys(b);return A.sort!==!1&&o.sort(A.sort),o.map(d=>{const M=E[d];return M===void 0?"":M===null?g(d,A):Array.isArray(M)?M.length===0&&A.arrayFormat==="bracket-separator"?g(d,A)+"[]":M.reduce(m(d),[]).join("&"):g(d,A)+"="+g(M,A)}).filter(d=>d.length>0).join("&")},t.parseUrl=(E,A)=>{A=Object.assign({decode:!0},A);const[y,m]=n(E,"#");return Object.assign({url:y.split("?")[0]||"",query:$(R(E),A)},A&&A.parseFragmentIdentifier&&m?{fragmentIdentifier:D(m,A)}:{})},t.stringifyUrl=(E,A)=>{A=Object.assign({encode:!0,strict:!0,[c]:!0},A);const y=x(E.url).split("?")[0]||"",m=t.extract(E.url),b=t.parse(m,{sort:!1}),o=Object.assign(b,E.query);let d=t.stringify(o,A);d&&(d=`?${d}`);let M=w(E.url);return E.fragmentIdentifier&&(M=`#${A[c]?g(E.fragmentIdentifier,A):E.fragmentIdentifier}`),`${y}${d}${M}`},t.pick=(E,A,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[c]:!1},y);const{url:m,query:b,fragmentIdentifier:o}=t.parseUrl(E,y);return t.stringifyUrl({url:m,query:i(b,A),fragmentIdentifier:o},y)},t.exclude=(E,A,y)=>{const m=Array.isArray(A)?b=>!A.includes(b):(b,o)=>!A(b,o);return t.pick(E,m,y)}})(Dr);const cf={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Ws=":";function uf(t){const{namespace:e,reference:r}=t;return[e,r].join(Ws)}function hf(t){const[e,r,n]=t.split(Ws);return{namespace:e,reference:r,address:n}}function ff(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function lf(t){const{namespace:e,reference:r}=hf(t);return uf({namespace:e,reference:r})}function df(t){return ff(t,lf)}function Yn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function kn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...df(i.accounts))}),r}function pf(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const Ys="base10",lt="base16",Jn="base64pad",Xn="utf8",ks=0,xr=1,gf=0,Js=1,Zn=12,Qn=32;function vf(){const t=$n.generateKeyPair();return{privateKey:ft(t.secretKey,lt),publicKey:ft(t.publicKey,lt)}}function ei(){const t=nr.randomBytes(Qn);return ft(t,lt)}function yf(t,e){const r=$n.sharedKey(ht(t,lt),ht(e,lt)),n=new Xc(Yr.SHA256,r).expand(Qn);return ft(n,lt)}function _f(t){const e=Yr.hash(ht(t,lt));return ft(e,lt)}function Zr(t){const e=Yr.hash(ht(t,Xn));return ft(e,lt)}function bf(t){return ht(`${t}`,Ys)}function Qr(t){return Number(ft(t,Ys))}function mf(t){const e=bf(typeof t.type<"u"?t.type:ks);if(Qr(e)===xr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ht(t.senderPublicKey,lt):void 0,n=typeof t.iv<"u"?ht(t.iv,lt):nr.randomBytes(Zn),i=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)).seal(n,ht(t.message,Xn));return Ef({type:e,sealed:i,iv:n,senderPublicKey:r})}function wf(t){const e=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:n}=Xs(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ft(i,Xn)}function Ef(t){if(Qr(t.type)===xr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(Bn([t.type,t.senderPublicKey,t.iv,t.sealed]),Jn)}return ft(Bn([t.type,t.iv,t.sealed]),Jn)}function Xs(t){const e=ht(t,Jn),r=e.slice(gf,Js),n=Js;if(Qr(r)===xr){const u=n+Qn,h=u+Zn,l=e.slice(n,u),g=e.slice(u,h),D=e.slice(h);return{type:r,sealed:D,iv:g,senderPublicKey:l}}const i=n+Zn,s=e.slice(n,i),c=e.slice(i);return{type:r,sealed:c,iv:s}}function Df(t,e){const r=Xs(t);return Zs({type:Qr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Zs(t){const e=t?.type||ks;if(e===xr){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 Qs(t){return t.type===xr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var xf=Object.defineProperty,eo=Object.getOwnPropertySymbols,Sf=Object.prototype.hasOwnProperty,Of=Object.prototype.propertyIsEnumerable,to=(t,e,r)=>e in t?xf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ro=(t,e)=>{for(var r in e||(e={}))Sf.call(e,r)&&to(t,r,e[r]);if(eo)for(var r of eo(e))Of.call(e,r)&&to(t,r,e[r]);return t};const Af="ReactNative",Sr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},If="js";function no(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Lf(){return!Bs()&&!!Vn()&&navigator.product===Af}function Cf(){return!no()&&!!Vn()}function Tf(){return Lf()?Sr.reactNative:no()?Sr.node:Cf()?Sr.browser:Sr.unknown}function Nf(t,e){let r=Dr.parse(t);return r=ro(ro({},r),e),t=Dr.stringify(r),t}function Pf(){return Hs()||{name:"",description:"",url:"",icons:[""]}}function Rf(){const t=Fh();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 Ff(){var t;const e=Tf();return e===Sr.browser?[e,((t=zs())==null?void 0:t.host)||"unknown"].join(":"):e}function Uf(t,e,r){const n=Rf(),i=Ff();return[[t,e].join("-"),[If,r].join("-"),n,i].join("/")}function Mf({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const c=r.split("?"),u=Uf(t,e,n),h={auth:i,ua:u,projectId:s},l=Nf(c[1]||"",h);return c[0]+"?"+l}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function io(t){return Object.fromEntries(t.entries())}function so(t){return new Map(Object.entries(t))}function ar(t,e){return Le.fromMiliseconds((e||Date.now())+Le.toMiliseconds(t))}function Yt(t){return Le.fromMiliseconds(Date.now())>=Le.toMiliseconds(t)}function kt(){const t=Le.toMiliseconds(Le.FIVE_MINUTES);let e,r,n;return{resolve:i=>{n&&e&&(clearTimeout(n),e(i))},reject:i=>{n&&r&&(clearTimeout(n),r(i))},done:()=>new Promise((i,s)=>{n=setTimeout(s,t),e=i,r=s})}}function oo(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function jf(t){return oo("topic",t)}function $f(t){return oo("id",t)}function Bf(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function Fe(t,e){return`${t}${e?`:${e}`:""}`}const zf="irn";function ti(t){return t?.relay||{protocol:zf}}function ri(t){const e=cf[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Hf=Object.defineProperty,ao=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,qf=Object.prototype.propertyIsEnumerable,co=(t,e,r)=>e in t?Hf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vf=(t,e)=>{for(var r in e||(e={}))Kf.call(e,r)&&co(t,r,e[r]);if(ao)for(var r of ao(e))qf.call(e,r)&&co(t,r,e[r]);return t};function Gf(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),c=t[i];r[s]=c}}),r}function Wf(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",c=Dr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:c.symKey,relay:Gf(c)}}function Yf(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function kf(t){return`${t.protocol}:${t.topic}@${t.version}?`+Dr.stringify(Vf({symKey:t.symKey},Yf(t.relay)))}function At(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function Jf(t){const e=[];return Object.values(t).forEach(r=>{e.push(...At(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...At(n.accounts))})}),e}function Xf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function Zf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.events)})}),r}const Qf={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}},el={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function G(t,e){const{message:r,code:n}=el[t];return{message:e?`${r} ${e}`:r,code:n}}function rt(t,e){const{message:r,code:n}=Qf[t];return{message:e?`${r} ${e}`:r,code:n}}function Or(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function uo(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 ho(t,e){return e&&Et(t)?!0:typeof t=="number"&&!isNaN(t)}function tl(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return dt(i,n)?(n.forEach(c=>{const{accounts:u,methods:h,events:l,extension:g}=t.namespaces[c],D=At(u),C=r[c];(!dt(C.chains,D)||!dt(C.methods,h)||!dt(C.events,l))&&(s=!1),s&&g&&g.forEach(x=>{var w;const{accounts:R,methods:T,events:$}=x,E=At(R);(w=C.extension)!=null&&w.find(A=>dt(A.chains,E)&&dt(A.methods,T)&&dt(A.events,$))||(s=!1)})}),s):!1}function ni(t){return ot(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function rl(t){if(ot(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ni(r)}}return!1}function nl(t){if(ot(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function il(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function sl(t){return t?.topic}function ol(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 ii(t,e){let r=null;return Et(t?.extension)||(!Or(t.extension)||!t.extension.length)&&(r=G("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function fo(t){let e=!0;return Or(t)?t.length&&(e=t.every(r=>ot(r,!1))):e=!1,e}function lo(t,e,r){let n=null;return Or(e)?e.forEach(i=>{n||(!ni(i)||!i.includes(t))&&(n=rt("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=rt("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function al(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=lo(n,i?.chains,`${e} requiredNamespace`),c=ii(i,e);s?r=s:c?r=c:i.extension&&i.extension.forEach(u=>{if(r)return;const h=lo(n,u.chains,`${e} extension`);h&&(r=h)})}),r}function po(t,e){let r=null;return Or(t)?t.forEach(n=>{r||rl(n)||(r=rt("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} 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 cl(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=po(n?.accounts,`${e} namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=po(c.accounts,`${e} extension`);u&&(r=u)})}),r}function go(t,e){let r=null;return fo(t?.methods)?fo(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 vo(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=go(n,`${e}, namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=go(c,`${e}, extension`);u&&(r=u)})}),r}function ul(t,e){let r=null;if(t&&uo(t)){const n=vo(t,e);n&&(r=n);const i=al(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function si(t,e){let r=null;if(t&&uo(t)){const n=vo(t,e);n&&(r=n);const i=cl(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function yo(t){return ot(t.protocol,!0)}function hl(t,e){let r=!1;return e&&!t?r=!0:t&&Or(t)&&t.length&&t.forEach(n=>{r=yo(n)}),r}function fl(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function ll(t){return!(!t||typeof t!="object"||!t.code||!ho(t.code,!1)||!t.message||!ot(t.message,!1))}function dl(t){return!(Et(t)||!ot(t.method,!1))}function pl(t){return!(Et(t)||Et(t.result)&&Et(t.error)||!ho(t.id,!1)||!ot(t.jsonrpc,!1))}function gl(t){return!(Et(t)||!ot(t.name,!1))}function _o(t,e){return!(!ni(e)||!Jf(t).includes(e))}function vl(t,e,r){return ot(r,!1)?Xf(t,e).includes(r):!1}function yl(t,e,r){return ot(r,!1)?Zf(t,e).includes(r):!1}function bo(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return dt(i,s)?i.forEach(c=>{var u;if(n)return;const h=t[c].chains,l=At(e[c].accounts);dt(h,l)?dt(t[c].methods,e[c].methods)?dt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`):t[c].extension&&e[c].extension&&((u=t[c].extension)==null||u.forEach(({methods:g,events:D,chains:C})=>{var x;n||(x=e[c].extension)!=null&&x.find(w=>{const R=At(w.accounts);return dt(C,R)&&dt(D,w.events)&&dt(g,w.methods)})||(n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function _l(){(typeof TextEncoder>"u"||typeof TextDecoder>"u")&&require("fast-text-encoding")}function bl(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var ml=wl;function wl(t,e,r){var n=r&&r.stringify||bl,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var c=new Array(s);c[0]=n(t);for(var u=1;u<s;u++)c[u]=n(e[u]);return c.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var l="",g=1-i,D=-1,C=t&&t.length||0,x=0;x<C;){if(t.charCodeAt(x)===37&&x+1<C){switch(D=D>-1?D:0,t.charCodeAt(x+1)){case 100:case 102:if(g>=h||e[g]==null)break;D<x&&(l+=t.slice(D,x)),l+=Number(e[g]),D=x+2,x++;break;case 105:if(g>=h||e[g]==null)break;D<x&&(l+=t.slice(D,x)),l+=Math.floor(Number(e[g])),D=x+2,x++;break;case 79:case 111:case 106:if(g>=h||e[g]===void 0)break;D<x&&(l+=t.slice(D,x));var w=typeof e[g];if(w==="string"){l+="'"+e[g]+"'",D=x+2,x++;break}if(w==="function"){l+=e[g].name||"<anonymous>",D=x+2,x++;break}l+=n(e[g]),D=x+2,x++;break;case 115:if(g>=h)break;D<x&&(l+=t.slice(D,x)),l+=String(e[g]),D=x+2,x++;break;case 37:D<x&&(l+=t.slice(D,x)),l+="%",D=x+2,x++,g--;break}++g}++x}return D===-1?t:(D<C&&(l+=t.slice(D)),l)}var mo=ml,oi=It,Ar=Cl().console||{},El={mapHttpRequest:tn,mapHttpResponse:tn,wrapRequestSerializer:ci,wrapResponseSerializer:ci,wrapErrorSerializer:ci,req:tn,res:tn,err:Ol};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||Ar;t.browser.write&&(t.browser.asObject=!0);var n=t.serializers||{},i=Array.isArray(t.browser.serialize)?t.browser.serialize.filter(function(w){return w!=="!stdSerializers.err"}):t.browser.serialize===!0?Object.keys(n):!1,s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);var c=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");var u=t.level||"info",h=Object.create(r);h.log||(h.log=Ir),Object.defineProperty(h,"levelVal",{get:g}),Object.defineProperty(h,"level",{get:D,set:C});var l={transmit:e,serialize:i,asObject:t.browser.asObject,levels:c,timestamp:Al(t)};h.levels=It.levels,h.level=u,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=Ir,h.serializers=n,h._serialize=i,h._stdErrSerialize=s,h.child=x,e&&(h._logEvent=ai());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function C(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,cr(l,h,"error","log"),cr(l,h,"fatal","error"),cr(l,h,"warn","error"),cr(l,h,"info","log"),cr(l,h,"debug","log"),cr(l,h,"trace","log")}function x(w){if(!w)throw new Error("missing bindings for child Pino");var R=w.serializers;if(i&&R){var T=Object.assign({},n,R),$=t.browser.serialize===!0?Object.keys(T):i;delete w.serializers,en([w],$,T,this._stdErrSerialize)}function E(A){this._childLevel=(A._childLevel|0)+1,this.error=ur(A,w,"error"),this.fatal=ur(A,w,"fatal"),this.warn=ur(A,w,"warn"),this.info=ur(A,w,"info"),this.debug=ur(A,w,"debug"),this.trace=ur(A,w,"trace"),T&&(this.serializers=T,this._serialize=$),e&&(this._logEvent=ai([].concat(A._logEvent.bindings,w)))}return E.prototype=this,new E(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=El,It.stdTimeFunctions=Object.assign({},{nullTime:wo,epochTime:Eo,unixTime:Il,isoTime:Ll});function cr(t,e,r,n){var i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ir:i[r]?i[r]:Ar[r]||Ar[n]||Ir,Dl(t,e,r)}function Dl(t,e,r){!t.transmit&&e[r]===Ir||(e[r]=function(n){return function(){for(var s=t.timestamp(),c=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ar?Ar:this,h=0;h<c.length;h++)c[h]=arguments[h];if(t.serialize&&!t.asObject&&en(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(u,xl(this,r,c,s)):n.apply(u,c),t.transmit){var l=t.transmit.level||e.level,g=It.levels.values[l],D=It.levels.values[r];if(D<g)return;Sl(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:l,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},c)}}}(e[r]))}function xl(t,e,r,n){t._serialize&&en(r,t._serialize,t.serializers,t._stdErrSerialize);var i=r.slice(),s=i[0],c={};n&&(c.time=n),c.level=It.levels.values[e];var u=(t._childLevel|0)+1;if(u<1&&(u=1),s!==null&&typeof s=="object"){for(;u--&&typeof i[0]=="object";)Object.assign(c,i.shift());s=i.length?mo(i.shift(),i):void 0}else typeof s=="string"&&(s=mo(i.shift(),i));return s!==void 0&&(c.msg=s),c}function en(t,e,r,n){for(var i in t)if(n&&t[i]instanceof Error)t[i]=It.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(var s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function ur(t,e,r){return function(){var n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function Sl(t,e,r){var n=e.send,i=e.ts,s=e.methodLevel,c=e.methodValue,u=e.val,h=t._logEvent.bindings;en(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(l){return h.indexOf(l)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=c,n(s,t._logEvent,u),t._logEvent=ai(h)}function ai(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Ol(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 Al(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?wo:Eo}function tn(){return{}}function ci(t){return t}function Ir(){}function wo(){return!1}function Eo(){return Date.now()}function Il(){return Math.round(Date.now()/1e3)}function Ll(){return new Date(Date.now()).toISOString()}function Cl(){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 rn={},ui=function(t,e){return ui=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},ui(t,e)};function Tl(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ui(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var hi=function(){return hi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},hi.apply(this,arguments)};function Nl(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Pl(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(s=(i<3?c(s):i>3?c(e,r,s):c(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Rl(t,e){return function(r,n){e(r,n,t)}}function Fl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Ul(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{l(n.next(g))}catch(D){c(D)}}function h(g){try{l(n.throw(g))}catch(D){c(D)}}function l(g){g.done?s(g.value):i(g.value).then(u,h)}l((n=n.apply(t,e||[])).next())})}function Ml(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(l){return function(g){return h([l,g])}}function h(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(g){l=[6,g],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}var fi=Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]};function jl(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&fi(e,t,r)}function li(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Do(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],c;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(u){c={error:u}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(c)throw c.error}}return s}function $l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Do(arguments[e]));return t}function Bl(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],c=0,u=s.length;c<u;c++,i++)n[i]=s[c];return n}function zl(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function Lr(t){return this instanceof Lr?(this.v=t,this):new Lr(t)}function Hl(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},c("next"),c("throw"),c("return"),i[Symbol.asyncIterator]=function(){return this},i;function c(C){n[C]&&(i[C]=function(x){return new Promise(function(w,R){s.push([C,x,w,R])>1||u(C,x)})})}function u(C,x){try{h(n[C](x))}catch(w){D(s[0][3],w)}}function h(C){C.value instanceof Lr?Promise.resolve(C.value.v).then(l,g):D(s[0][2],C)}function l(C){u("next",C)}function g(C){u("throw",C)}function D(C,x){C(x),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Kl(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(c){return(r=!r)?{value:Lr(t[i](c)),done:i==="return"}:s?s(c):c}:s}}function ql(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 li=="function"?li(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(c){return new Promise(function(u,h){c=t[s](c),i(u,h,c.done,c.value)})}}function i(s,c,u,h){Promise.resolve(h).then(function(l){s({value:l,done:u})},c)}}function Vl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var Gl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function Wl(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&fi(e,t,r);return Gl(e,t),e}function Yl(t){return t&&t.__esModule?t:{default:t}}function kl(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Jl(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function Xl(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}var Zl=Object.freeze({__proto__:null,__extends:Tl,get __assign(){return hi},__rest:Nl,__decorate:Pl,__param:Rl,__metadata:Fl,__awaiter:Ul,__generator:Ml,__createBinding:fi,__exportStar:jl,__values:li,__read:Do,__spread:$l,__spreadArrays:Bl,__spreadArray:zl,__await:Lr,__asyncGenerator:Hl,__asyncDelegator:Kl,__asyncValues:ql,__makeTemplateObject:Vl,__importStar:Wl,__importDefault:Yl,__classPrivateFieldGet:kl,__classPrivateFieldSet:Jl,__classPrivateFieldIn:Xl}),di=wn(Zl),nn={exports:{}},xo;function Ql(){return xo||(xo=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,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){var r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),Z.localStorage?nn.exports=localStorage:nn.exports=new e}()),nn.exports}var Cr={},So;function Oo(){if(So)return Cr;So=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,(n,i)=>typeof i>"u"?null:i)}return Cr.safeJsonStringify=e,Cr}var pi={},Tr={},Ao;function ed(){if(Ao)return Tr;Ao=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.IKeyValueStorage=void 0;class t{}return Tr.IKeyValueStorage=t,Tr}var Nr={},Io;function td(){if(Io)return Nr;Io=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.parseEntry=void 0;const t=Oo();function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Nr.parseEntry=e,Nr}var Lo;function rd(){return Lo||(Lo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(ed(),t),e.__exportStar(td(),t)}(pi)),pi}Object.defineProperty(rn,"__esModule",{value:!0}),rn.KeyValueStorage=void 0;const hr=di,nd=hr.__importDefault(Ql()),Co=Oo(),id=rd();class To{constructor(){this.localStorage=nd.default}getKeys(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(id.parseEntry)})}getItem(e){return hr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Co.safeJsonParse(r)})}setItem(e,r){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Co.safeJsonStringify(r))})}removeItem(e){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}rn.KeyValueStorage=To;var sd=rn.default=To,Pr={},sn={},gi={},on={};class Jt{}var od=Object.freeze({__proto__:null,IEvents:Jt}),ad=wn(od);Object.defineProperty(on,"__esModule",{value:!0}),on.IHeartBeat=void 0;const cd=ad;class ud extends cd.IEvents{constructor(e){super()}}on.IHeartBeat=ud,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(on,t)}(gi);var vi={},fr={};Object.defineProperty(fr,"__esModule",{value:!0}),fr.HEARTBEAT_EVENTS=fr.HEARTBEAT_INTERVAL=void 0;const hd=Le;fr.HEARTBEAT_INTERVAL=hd.FIVE_SECONDS,fr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(fr,t)}(vi);var yi=Z&&Z.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{l(n.next(g))}catch(D){c(D)}}function h(g){try{l(n.throw(g))}catch(D){c(D)}}function l(g){g.done?s(g.value):i(g.value).then(u,h)}l((n=n.apply(t,e||[])).next())})};Object.defineProperty(sn,"__esModule",{value:!0}),sn.HeartBeat=void 0;const fd=vr,ld=Le,dd=gi,_i=vi;class bi extends dd.IHeartBeat{constructor(e){super(e),this.events=new fd.EventEmitter,this.interval=_i.HEARTBEAT_INTERVAL,this.interval=e?.interval||_i.HEARTBEAT_INTERVAL}static init(e){return yi(this,void 0,void 0,function*(){const r=new bi(e);return yield r.init(),r})}init(){return yi(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 yi(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),ld.toMiliseconds(this.interval))})}pulse(){this.events.emit(_i.HEARTBEAT_EVENTS.pulse)}}sn.HeartBeat=bi,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sn,t),r(gi,t),r(vi,t)}(Pr);var Oe={},Xt={},No;function Po(){return No||(No=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.PINO_CUSTOM_CONTEXT_KEY=Xt.PINO_LOGGER_DEFAULTS=void 0,Xt.PINO_LOGGER_DEFAULTS={level:"info"},Xt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Xt}var ct={},Ro;function pd(){if(Ro)return ct;Ro=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=Po();function e(u){return Object.assign(Object.assign({},u),{level:u?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(u,h=t.PINO_CUSTOM_CONTEXT_KEY){return u[h]||""}ct.getBrowserLoggerContext=r;function n(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){return u[l]=h,u}ct.setBrowserLoggerContext=n;function i(u,h=t.PINO_CUSTOM_CONTEXT_KEY){let l="";return typeof u.bindings>"u"?l=r(u,h):l=u.bindings().context||"",l}ct.getLoggerContext=i;function s(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const g=i(u,l);return g.trim()?`${g}/${h}`:h}ct.formatChildLoggerContext=s;function c(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const g=s(u,h,l),D=u.child({context:g});return n(D,g,l)}return ct.generateChildLogger=c,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(Po(),t),e.__exportStar(pd(),t)})(Oe);class gd extends Jt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class vd extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class yd{constructor(e,r){this.logger=e,this.core=r}}class _d extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class bd extends Jt{constructor(e){super()}}class md{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class wd extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Ed=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!Dd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Rr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Fo(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:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Rr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},qe.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]?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&&(Fo(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(!Rt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},qe.prototype.removeListener=function(t,e){var r,n,i,s;if(!Rt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Rt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Rr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},qe.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],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},qe.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},qe.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Rt(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Rt(t){return typeof t=="function"}function Dd(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function Fo(t){return t===void 0}class xd{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class C0 extends Ed.EventEmitter{constructor(){super()}}class Sd{constructor(e){this.client=e}}class Od extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}var mi={},Uo={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function u(){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 u.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},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},u.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 g=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&l>0;)this._buffer[this._bufferLength++]=h[g++],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&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,g,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[g++],l--;return this},u.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,g=this._bufferLength,D=l/536870912|0,C=l<<3,x=l%128<112?128:256;this._buffer[g]=128;for(var w=g+1;w<x-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,x-8),e.writeUint32BE(C,this._buffer,x-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,x),this._finished=!0}for(var w=0;w<this.digestLength/8;w++)e.writeUint32BE(this._stateHi[w],h,w*8),e.writeUint32BE(this._stateLo[w],h,w*8+4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.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}},u.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},u.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(u,h,l,g,D,C,x){for(var w=l[0],R=l[1],T=l[2],$=l[3],E=l[4],A=l[5],y=l[6],m=l[7],b=g[0],o=g[1],d=g[2],M=g[3],K=g[4],V=g[5],J=g[6],X=g[7],f,_,U,q,P,N,j,B;x>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+C;u[Q]=e.readUint32BE(D,H),h[Q]=e.readUint32BE(D,H+4)}for(var Q=0;Q<80;Q++){var ee=w,Y=R,ae=T,L=$,I=E,S=A,a=y,v=m,z=b,k=o,fe=d,ye=M,de=K,me=V,Ue=J,Te=X;if(f=m,_=X,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=(E>>>14|K<<32-14)^(E>>>18|K<<32-18)^(K>>>41-32|E<<32-(41-32)),_=(K>>>14|E<<32-14)^(K>>>18|E<<32-18)^(E>>>41-32|K<<32-(41-32)),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=E&A^~E&y,_=K&V^~K&J,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=i[Q*2],_=i[Q*2+1],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=u[Q%16],_=h[Q%16],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,U=j&65535|B<<16,q=P&65535|N<<16,f=U,_=q,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=(w>>>28|b<<32-28)^(b>>>34-32|w<<32-(34-32))^(b>>>39-32|w<<32-(39-32)),_=(b>>>28|w<<32-28)^(w>>>34-32|b<<32-(34-32))^(w>>>39-32|b<<32-(39-32)),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=w&R^w&T^R&T,_=b&o^b&d^o&d,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,v=j&65535|B<<16,Te=P&65535|N<<16,f=L,_=ye,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=U,_=q,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,L=j&65535|B<<16,ye=P&65535|N<<16,R=ee,T=Y,$=ae,E=L,A=I,y=S,m=a,w=v,o=z,d=k,M=fe,K=ye,V=de,J=me,X=Ue,b=Te,Q%16===15)for(var H=0;H<16;H++)f=u[H],_=h[H],P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=u[(H+9)%16],_=h[(H+9)%16],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,U=u[(H+1)%16],q=h[(H+1)%16],f=(U>>>1|q<<32-1)^(U>>>8|q<<32-8)^U>>>7,_=(q>>>1|U<<32-1)^(q>>>8|U<<32-8)^(q>>>7|U<<32-7),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,U=u[(H+14)%16],q=h[(H+14)%16],f=(U>>>19|q<<32-19)^(q>>>61-32|U<<32-(61-32))^U>>>6,_=(q>>>19|U<<32-19)^(U>>>61-32|q<<32-(61-32))^(q>>>6|U<<32-6),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,u[H]=j&65535|B<<16,h[H]=P&65535|N<<16}f=w,_=b,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[0],_=g[0],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[0]=w=j&65535|B<<16,g[0]=b=P&65535|N<<16,f=R,_=o,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[1],_=g[1],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[1]=R=j&65535|B<<16,g[1]=o=P&65535|N<<16,f=T,_=d,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[2],_=g[2],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[2]=T=j&65535|B<<16,g[2]=d=P&65535|N<<16,f=$,_=M,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[3],_=g[3],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[3]=$=j&65535|B<<16,g[3]=M=P&65535|N<<16,f=E,_=K,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[4],_=g[4],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[4]=E=j&65535|B<<16,g[4]=K=P&65535|N<<16,f=A,_=V,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[5],_=g[5],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[5]=A=j&65535|B<<16,g[5]=V=P&65535|N<<16,f=y,_=J,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[6],_=g[6],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[6]=y=j&65535|B<<16,g[6]=J=P&65535|N<<16,f=m,_=X,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=l[7],_=g[7],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,l[7]=m=j&65535|B<<16,g[7]=X=P&65535|N<<16,C+=128,x-=128}return C}function c(u){var h=new n;h.update(u);var l=h.digest();return h.clean(),l}t.hash=c})(Uo),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=Uo,n=pt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(L){var I=new Float64Array(16);if(L)for(var S=0;S<L.length;S++)I[S]=L[S];return I}var s=new Uint8Array(32);s[0]=9;var c=i(),u=i([1]),h=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function x(L,I){for(var S=0;S<16;S++)L[S]=I[S]|0}function w(L){for(var I=1,S=0;S<16;S++){var a=L[S]+I+65535;I=Math.floor(a/65536),L[S]=a-I*65536}L[0]+=I-1+37*(I-1)}function R(L,I,S){for(var a=~(S-1),v=0;v<16;v++){var z=a&(L[v]^I[v]);L[v]^=z,I[v]^=z}}function T(L,I){for(var S=i(),a=i(),v=0;v<16;v++)a[v]=I[v];w(a),w(a),w(a);for(var z=0;z<2;z++){S[0]=a[0]-65517;for(var v=1;v<15;v++)S[v]=a[v]-65535-(S[v-1]>>16&1),S[v-1]&=65535;S[15]=a[15]-32767-(S[14]>>16&1);var k=S[15]>>16&1;S[14]&=65535,R(a,S,1-k)}for(var v=0;v<16;v++)L[2*v]=a[v]&255,L[2*v+1]=a[v]>>8}function $(L,I){for(var S=0,a=0;a<32;a++)S|=L[a]^I[a];return(1&S-1>>>8)-1}function E(L,I){var S=new Uint8Array(32),a=new Uint8Array(32);return T(S,L),T(a,I),$(S,a)}function A(L){var I=new Uint8Array(32);return T(I,L),I[0]&1}function y(L,I){for(var S=0;S<16;S++)L[S]=I[2*S]+(I[2*S+1]<<8);L[15]&=32767}function m(L,I,S){for(var a=0;a<16;a++)L[a]=I[a]+S[a]}function b(L,I,S){for(var a=0;a<16;a++)L[a]=I[a]-S[a]}function o(L,I,S){var a,v,z=0,k=0,fe=0,ye=0,de=0,me=0,Ue=0,Te=0,ve=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,_e=0,be=0,Ee=0,De=0,we=0,xt=0,Tt=0,Kt=0,gt=0,Qt=0,zr=0,pn=0,Me=S[0],Ne=S[1],je=S[2],$e=S[3],Be=S[4],Pe=S[5],We=S[6],Ye=S[7],ke=S[8],Je=S[9],Xe=S[10],He=S[11],ze=S[12],Ie=S[13],Ze=S[14],Qe=S[15];a=I[0],z+=a*Me,k+=a*Ne,fe+=a*je,ye+=a*$e,de+=a*Be,me+=a*Pe,Ue+=a*We,Te+=a*Ye,ve+=a*ke,pe+=a*Je,le+=a*Xe,ue+=a*He,ce+=a*ze,oe+=a*Ie,se+=a*Ze,te+=a*Qe,a=I[1],k+=a*Me,fe+=a*Ne,ye+=a*je,de+=a*$e,me+=a*Be,Ue+=a*Pe,Te+=a*We,ve+=a*Ye,pe+=a*ke,le+=a*Je,ue+=a*Xe,ce+=a*He,oe+=a*ze,se+=a*Ie,te+=a*Ze,he+=a*Qe,a=I[2],fe+=a*Me,ye+=a*Ne,de+=a*je,me+=a*$e,Ue+=a*Be,Te+=a*Pe,ve+=a*We,pe+=a*Ye,le+=a*ke,ue+=a*Je,ce+=a*Xe,oe+=a*He,se+=a*ze,te+=a*Ie,he+=a*Ze,ge+=a*Qe,a=I[3],ye+=a*Me,de+=a*Ne,me+=a*je,Ue+=a*$e,Te+=a*Be,ve+=a*Pe,pe+=a*We,le+=a*Ye,ue+=a*ke,ce+=a*Je,oe+=a*Xe,se+=a*He,te+=a*ze,he+=a*Ie,ge+=a*Ze,ne+=a*Qe,a=I[4],de+=a*Me,me+=a*Ne,Ue+=a*je,Te+=a*$e,ve+=a*Be,pe+=a*Pe,le+=a*We,ue+=a*Ye,ce+=a*ke,oe+=a*Je,se+=a*Xe,te+=a*He,he+=a*ze,ge+=a*Ie,ne+=a*Ze,_e+=a*Qe,a=I[5],me+=a*Me,Ue+=a*Ne,Te+=a*je,ve+=a*$e,pe+=a*Be,le+=a*Pe,ue+=a*We,ce+=a*Ye,oe+=a*ke,se+=a*Je,te+=a*Xe,he+=a*He,ge+=a*ze,ne+=a*Ie,_e+=a*Ze,be+=a*Qe,a=I[6],Ue+=a*Me,Te+=a*Ne,ve+=a*je,pe+=a*$e,le+=a*Be,ue+=a*Pe,ce+=a*We,oe+=a*Ye,se+=a*ke,te+=a*Je,he+=a*Xe,ge+=a*He,ne+=a*ze,_e+=a*Ie,be+=a*Ze,Ee+=a*Qe,a=I[7],Te+=a*Me,ve+=a*Ne,pe+=a*je,le+=a*$e,ue+=a*Be,ce+=a*Pe,oe+=a*We,se+=a*Ye,te+=a*ke,he+=a*Je,ge+=a*Xe,ne+=a*He,_e+=a*ze,be+=a*Ie,Ee+=a*Ze,De+=a*Qe,a=I[8],ve+=a*Me,pe+=a*Ne,le+=a*je,ue+=a*$e,ce+=a*Be,oe+=a*Pe,se+=a*We,te+=a*Ye,he+=a*ke,ge+=a*Je,ne+=a*Xe,_e+=a*He,be+=a*ze,Ee+=a*Ie,De+=a*Ze,we+=a*Qe,a=I[9],pe+=a*Me,le+=a*Ne,ue+=a*je,ce+=a*$e,oe+=a*Be,se+=a*Pe,te+=a*We,he+=a*Ye,ge+=a*ke,ne+=a*Je,_e+=a*Xe,be+=a*He,Ee+=a*ze,De+=a*Ie,we+=a*Ze,xt+=a*Qe,a=I[10],le+=a*Me,ue+=a*Ne,ce+=a*je,oe+=a*$e,se+=a*Be,te+=a*Pe,he+=a*We,ge+=a*Ye,ne+=a*ke,_e+=a*Je,be+=a*Xe,Ee+=a*He,De+=a*ze,we+=a*Ie,xt+=a*Ze,Tt+=a*Qe,a=I[11],ue+=a*Me,ce+=a*Ne,oe+=a*je,se+=a*$e,te+=a*Be,he+=a*Pe,ge+=a*We,ne+=a*Ye,_e+=a*ke,be+=a*Je,Ee+=a*Xe,De+=a*He,we+=a*ze,xt+=a*Ie,Tt+=a*Ze,Kt+=a*Qe,a=I[12],ce+=a*Me,oe+=a*Ne,se+=a*je,te+=a*$e,he+=a*Be,ge+=a*Pe,ne+=a*We,_e+=a*Ye,be+=a*ke,Ee+=a*Je,De+=a*Xe,we+=a*He,xt+=a*ze,Tt+=a*Ie,Kt+=a*Ze,gt+=a*Qe,a=I[13],oe+=a*Me,se+=a*Ne,te+=a*je,he+=a*$e,ge+=a*Be,ne+=a*Pe,_e+=a*We,be+=a*Ye,Ee+=a*ke,De+=a*Je,we+=a*Xe,xt+=a*He,Tt+=a*ze,Kt+=a*Ie,gt+=a*Ze,Qt+=a*Qe,a=I[14],se+=a*Me,te+=a*Ne,he+=a*je,ge+=a*$e,ne+=a*Be,_e+=a*Pe,be+=a*We,Ee+=a*Ye,De+=a*ke,we+=a*Je,xt+=a*Xe,Tt+=a*He,Kt+=a*ze,gt+=a*Ie,Qt+=a*Ze,zr+=a*Qe,a=I[15],te+=a*Me,he+=a*Ne,ge+=a*je,ne+=a*$e,_e+=a*Be,be+=a*Pe,Ee+=a*We,De+=a*Ye,we+=a*ke,xt+=a*Je,Tt+=a*Xe,Kt+=a*He,gt+=a*ze,Qt+=a*Ie,zr+=a*Ze,pn+=a*Qe,z+=38*he,k+=38*ge,fe+=38*ne,ye+=38*_e,de+=38*be,me+=38*Ee,Ue+=38*De,Te+=38*we,ve+=38*xt,pe+=38*Tt,le+=38*Kt,ue+=38*gt,ce+=38*Qt,oe+=38*zr,se+=38*pn,v=1,a=z+v+65535,v=Math.floor(a/65536),z=a-v*65536,a=k+v+65535,v=Math.floor(a/65536),k=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=Ue+v+65535,v=Math.floor(a/65536),Ue=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=k+v+65535,v=Math.floor(a/65536),k=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=Ue+v+65535,v=Math.floor(a/65536),Ue=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),L[0]=z,L[1]=k,L[2]=fe,L[3]=ye,L[4]=de,L[5]=me,L[6]=Ue,L[7]=Te,L[8]=ve,L[9]=pe,L[10]=le,L[11]=ue,L[12]=ce,L[13]=oe,L[14]=se,L[15]=te}function d(L,I){o(L,I,I)}function M(L,I){var S=i(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=253;a>=0;a--)d(S,S),a!==2&&a!==4&&o(S,S,I);for(a=0;a<16;a++)L[a]=S[a]}function K(L,I){var S=i(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=250;a>=0;a--)d(S,S),a!==1&&o(S,S,I);for(a=0;a<16;a++)L[a]=S[a]}function V(L,I){var S=i(),a=i(),v=i(),z=i(),k=i(),fe=i(),ye=i(),de=i(),me=i();b(S,L[1],L[0]),b(me,I[1],I[0]),o(S,S,me),m(a,L[0],L[1]),m(me,I[0],I[1]),o(a,a,me),o(v,L[3],I[3]),o(v,v,l),o(z,L[2],I[2]),m(z,z,z),b(k,a,S),b(fe,z,v),m(ye,z,v),m(de,a,S),o(L[0],k,fe),o(L[1],de,ye),o(L[2],ye,fe),o(L[3],k,de)}function J(L,I,S){for(var a=0;a<4;a++)R(L[a],I[a],S)}function X(L,I){var S=i(),a=i(),v=i();M(v,I[2]),o(S,I[0],v),o(a,I[1],v),T(L,a),L[31]^=A(S)<<7}function f(L,I,S){x(L[0],c),x(L[1],u),x(L[2],u),x(L[3],c);for(var a=255;a>=0;--a){var v=S[a/8|0]>>(a&7)&1;J(L,I,v),V(I,L),V(L,L),J(L,I,v)}}function _(L,I){var S=[i(),i(),i(),i()];x(S[0],g),x(S[1],D),x(S[2],u),o(S[3],g,D),f(L,S,I)}function U(L){if(L.length!==t.SEED_LENGTH)throw new Error("ed25519: seed must be "+t.SEED_LENGTH+" bytes");var I=r.hash(L);I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(32),a=[i(),i(),i(),i()];_(a,I),X(S,a);var v=new Uint8Array(64);return v.set(L),v.set(S,32),{publicKey:S,secretKey:v}}t.generateKeyPairFromSeed=U;function q(L){var I=e.randomBytes(32,L),S=U(I);return n.wipe(I),S}t.generateKeyPair=q;function P(L){if(L.length!==t.SECRET_KEY_LENGTH)throw new Error("ed25519: secret key must be "+t.SECRET_KEY_LENGTH+" bytes");return new Uint8Array(L.subarray(32))}t.extractPublicKeyFromSecretKey=P;var N=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(L,I){var S,a,v,z;for(a=63;a>=32;--a){for(S=0,v=a-32,z=a-12;v<z;++v)I[v]+=S-16*I[a]*N[v-(a-32)],S=Math.floor((I[v]+128)/256),I[v]-=S*256;I[v]+=S,I[a]=0}for(S=0,v=0;v<32;v++)I[v]+=S-(I[31]>>4)*N[v],S=I[v]>>8,I[v]&=255;for(v=0;v<32;v++)I[v]-=S*N[v];for(a=0;a<32;a++)I[a+1]+=I[a]>>8,L[a]=I[a]&255}function B(L){for(var I=new Float64Array(64),S=0;S<64;S++)I[S]=L[S];for(var S=0;S<64;S++)L[S]=0;j(L,I)}function Q(L,I){var S=new Float64Array(64),a=[i(),i(),i(),i()],v=r.hash(L.subarray(0,32));v[0]&=248,v[31]&=127,v[31]|=64;var z=new Uint8Array(64);z.set(v.subarray(32),32);var k=new r.SHA512;k.update(z.subarray(32)),k.update(I);var fe=k.digest();k.clean(),B(fe),_(a,fe),X(z,a),k.reset(),k.update(z.subarray(0,32)),k.update(L.subarray(32)),k.update(I);var ye=k.digest();B(ye);for(var de=0;de<32;de++)S[de]=fe[de];for(var de=0;de<32;de++)for(var me=0;me<32;me++)S[de+me]+=ye[de]*v[me];return j(z.subarray(32),S),z}t.sign=Q;function H(L,I){var S=i(),a=i(),v=i(),z=i(),k=i(),fe=i(),ye=i();return x(L[2],u),y(L[1],I),d(v,L[1]),o(z,v,h),b(v,v,L[2]),m(z,L[2],z),d(k,z),d(fe,k),o(ye,fe,k),o(S,ye,v),o(S,S,z),K(S,S),o(S,S,v),o(S,S,z),o(S,S,z),o(L[0],S,z),d(a,L[0]),o(a,a,z),E(a,v)&&o(L[0],L[0],C),d(a,L[0]),o(a,a,z),E(a,v)?-1:(A(L[0])===I[31]>>7&&b(L[0],c,L[0]),o(L[3],L[0],L[1]),0)}function ee(L,I,S){var a=new Uint8Array(32),v=[i(),i(),i(),i()],z=[i(),i(),i(),i()];if(S.length!==t.SIGNATURE_LENGTH)throw new Error("ed25519: signature must be "+t.SIGNATURE_LENGTH+" bytes");if(H(z,L))return!1;var k=new r.SHA512;k.update(S.subarray(0,32)),k.update(L),k.update(I);var fe=k.digest();return B(fe),f(v,z,fe),_(z,S.subarray(32)),V(v,z),X(a,v),!$(S,a)}t.verify=ee;function Y(L){var I=[i(),i(),i(),i()];if(H(I,L))throw new Error("Ed25519: invalid public key");var S=i(),a=i(),v=I[1];m(S,u,v),b(a,u,v),M(a,a),o(S,S,a);var z=new Uint8Array(32);return T(z,S),z}t.convertPublicKeyToX25519=Y;function ae(L){var I=r.hash(L.subarray(0,32));I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(I.subarray(0,32));return n.wipe(I),S}t.convertSecretKeyToX25519=ae}(mi);const Ad="EdDSA",Id="JWT",Mo=".",jo="base64url",Ld="utf8",Cd="utf8",Td=":",Nd="did",Pd="key",$o="base58btc",Rd="z",Fd="K36",Ud=32;function an(t){return ft(ht(br(t),Ld),jo)}function Bo(t){const e=ht(Fd,$o),r=Rd+ft(Bn([e,t]),$o);return[Nd,Pd,r].join(Td)}function Md(t){return ft(t,jo)}function jd(t){return ht([an(t.header),an(t.payload)].join(Mo),Cd)}function $d(t){return[an(t.header),an(t.payload),Md(t.signature)].join(Mo)}function zo(t=nr.randomBytes(Ud)){return mi.generateKeyPairFromSeed(t)}async function Bd(t,e,r,n,i=Le.fromMiliseconds(Date.now())){const s={alg:Ad,typ:Id},c=Bo(n.publicKey),u=i+r,h={iss:c,sub:t,aud:e,iat:i,exp:u},l=jd({header:s,payload:h}),g=mi.sign(n.secretKey,l);return $d({header:s,payload:h,signature:g})}const Ho=10,zd=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class Hd{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.registering=!1,!Gi(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(br(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!Gi(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=$i.isReactNative()?void 0:{rejectUnauthorized:!vc(e)},s=new zd(e,[],i);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const u=this.parseError(c.error);this.events.emit("register_error",u),this.onClose(),n(u)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const n=this.parseError(r.error);this.events.emit("error",n)},this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ho&&this.events.setMaxListeners(Ho)}}var wi={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,c=9007199254740991,u="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",g="[object Boolean]",D="[object Date]",C="[object Error]",x="[object Function]",w="[object GeneratorFunction]",R="[object Map]",T="[object Number]",$="[object Null]",E="[object Object]",A="[object Promise]",y="[object Proxy]",m="[object RegExp]",b="[object Set]",o="[object String]",d="[object Symbol]",M="[object Undefined]",K="[object WeakMap]",V="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",f="[object Float64Array]",_="[object Int8Array]",U="[object Int16Array]",q="[object Int32Array]",P="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",B="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,Y={};Y[X]=Y[f]=Y[_]=Y[U]=Y[q]=Y[P]=Y[N]=Y[j]=Y[B]=!0,Y[u]=Y[h]=Y[V]=Y[g]=Y[J]=Y[D]=Y[C]=Y[x]=Y[R]=Y[T]=Y[E]=Y[m]=Y[b]=Y[o]=Y[K]=!1;var ae=typeof Z=="object"&&Z&&Z.Object===Object&&Z,L=typeof self=="object"&&self&&self.Object===Object&&self,I=ae||L||Function("return this")(),S=e&&!e.nodeType&&e,a=S&&!0&&t&&!t.nodeType&&t,v=a&&a.exports===S,z=v&&ae.process,k=function(){try{return z&&z.binding&&z.binding("util")}catch{}}(),fe=k&&k.isTypedArray;function ye(p,O){for(var F=-1,W=p==null?0:p.length,Ae=0,ie=[];++F<W;){var Re=p[F];O(Re,F,p)&&(ie[Ae++]=Re)}return ie}function de(p,O){for(var F=-1,W=O.length,Ae=p.length;++F<W;)p[Ae+F]=O[F];return p}function me(p,O){for(var F=-1,W=p==null?0:p.length;++F<W;)if(O(p[F],F,p))return!0;return!1}function Ue(p,O){for(var F=-1,W=Array(p);++F<p;)W[F]=O(F);return W}function Te(p){return function(O){return p(O)}}function ve(p,O){return p.has(O)}function pe(p,O){return p?.[O]}function le(p){var O=-1,F=Array(p.size);return p.forEach(function(W,Ae){F[++O]=[Ae,W]}),F}function ue(p,O){return function(F){return p(O(F))}}function ce(p){var O=-1,F=Array(p.size);return p.forEach(function(W){F[++O]=W}),F}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=I["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,_e=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=v?I.Buffer:void 0,we=I.Symbol,xt=I.Uint8Array,Tt=te.propertyIsEnumerable,Kt=oe.splice,gt=we?we.toStringTag:void 0,Qt=Object.getOwnPropertySymbols,zr=De?De.isBuffer:void 0,pn=ue(Object.keys,Object),Me=gr(I,"DataView"),Ne=gr(I,"Map"),je=gr(I,"Promise"),$e=gr(I,"Set"),Be=gr(I,"WeakMap"),Pe=gr(Object,"create"),We=tr(Me),Ye=tr(Ne),ke=tr(je),Je=tr($e),Xe=tr(Be),He=we?we.prototype:void 0,ze=He?He.valueOf:void 0;function Ie(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function Ze(){this.__data__=Pe?Pe(null):{},this.size=0}function Qe(p){var O=this.has(p)&&delete this.__data__[p];return this.size-=O?1:0,O}function $v(p){var O=this.__data__;if(Pe){var F=O[p];return F===n?void 0:F}return ne.call(O,p)?O[p]:void 0}function Bv(p){var O=this.__data__;return Pe?O[p]!==void 0:ne.call(O,p)}function zv(p,O){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Pe&&O===void 0?n:O,this}Ie.prototype.clear=Ze,Ie.prototype.delete=Qe,Ie.prototype.get=$v,Ie.prototype.has=Bv,Ie.prototype.set=zv;function Mt(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function Hv(){this.__data__=[],this.size=0}function Kv(p){var O=this.__data__,F=vn(O,p);if(F<0)return!1;var W=O.length-1;return F==W?O.pop():Kt.call(O,F,1),--this.size,!0}function qv(p){var O=this.__data__,F=vn(O,p);return F<0?void 0:O[F][1]}function Vv(p){return vn(this.__data__,p)>-1}function Gv(p,O){var F=this.__data__,W=vn(F,p);return W<0?(++this.size,F.push([p,O])):F[W][1]=O,this}Mt.prototype.clear=Hv,Mt.prototype.delete=Kv,Mt.prototype.get=qv,Mt.prototype.has=Vv,Mt.prototype.set=Gv;function er(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function Wv(){this.size=0,this.__data__={hash:new Ie,map:new(Ne||Mt),string:new Ie}}function Yv(p){var O=yn(this,p).delete(p);return this.size-=O?1:0,O}function kv(p){return yn(this,p).get(p)}function Jv(p){return yn(this,p).has(p)}function Xv(p,O){var F=yn(this,p),W=F.size;return F.set(p,O),this.size+=F.size==W?0:1,this}er.prototype.clear=Wv,er.prototype.delete=Yv,er.prototype.get=kv,er.prototype.has=Jv,er.prototype.set=Xv;function gn(p){var O=-1,F=p==null?0:p.length;for(this.__data__=new er;++O<F;)this.add(p[O])}function Zv(p){return this.__data__.set(p,n),this}function Qv(p){return this.__data__.has(p)}gn.prototype.add=gn.prototype.push=Zv,gn.prototype.has=Qv;function qt(p){var O=this.__data__=new Mt(p);this.size=O.size}function e0(){this.__data__=new Mt,this.size=0}function t0(p){var O=this.__data__,F=O.delete(p);return this.size=O.size,F}function r0(p){return this.__data__.get(p)}function n0(p){return this.__data__.has(p)}function i0(p,O){var F=this.__data__;if(F instanceof Mt){var W=F.__data__;if(!Ne||W.length<r-1)return W.push([p,O]),this.size=++F.size,this;F=this.__data__=new er(W)}return F.set(p,O),this.size=F.size,this}qt.prototype.clear=e0,qt.prototype.delete=t0,qt.prototype.get=r0,qt.prototype.has=n0,qt.prototype.set=i0;function s0(p,O){var F=_n(p),W=!F&&m0(p),Ae=!F&&!W&&Pi(p),ie=!F&&!W&&!Ae&&ka(p),Re=F||W||Ae||ie,et=Re?Ue(p.length,String):[],it=et.length;for(var Ce in p)(O||ne.call(p,Ce))&&!(Re&&(Ce=="length"||Ae&&(Ce=="offset"||Ce=="parent")||ie&&(Ce=="buffer"||Ce=="byteLength"||Ce=="byteOffset")||g0(Ce,it)))&&et.push(Ce);return et}function vn(p,O){for(var F=p.length;F--;)if(Va(p[F][0],O))return F;return-1}function o0(p,O,F){var W=O(p);return _n(p)?W:de(W,F(p))}function Hr(p){return p==null?p===void 0?M:$:gt&> in Object(p)?d0(p):b0(p)}function za(p){return Kr(p)&&Hr(p)==u}function Ha(p,O,F,W,Ae){return p===O?!0:p==null||O==null||!Kr(p)&&!Kr(O)?p!==p&&O!==O:a0(p,O,F,W,Ha,Ae)}function a0(p,O,F,W,Ae,ie){var Re=_n(p),et=_n(O),it=Re?h:Vt(p),Ce=et?h:Vt(O);it=it==u?E:it,Ce=Ce==u?E:Ce;var vt=it==E,St=Ce==E,at=it==Ce;if(at&&Pi(p)){if(!Pi(O))return!1;Re=!0,vt=!1}if(at&&!vt)return ie||(ie=new qt),Re||ka(p)?Ka(p,O,F,W,Ae,ie):f0(p,O,it,F,W,Ae,ie);if(!(F&i)){var _t=vt&&ne.call(p,"__wrapped__"),bt=St&&ne.call(O,"__wrapped__");if(_t||bt){var Gt=_t?p.value():p,jt=bt?O.value():O;return ie||(ie=new qt),Ae(Gt,jt,F,W,ie)}}return at?(ie||(ie=new qt),l0(p,O,F,W,Ae,ie)):!1}function c0(p){if(!Ya(p)||y0(p))return!1;var O=Ga(p)?Ee:H;return O.test(tr(p))}function u0(p){return Kr(p)&&Wa(p.length)&&!!Y[Hr(p)]}function h0(p){if(!_0(p))return pn(p);var O=[];for(var F in Object(p))ne.call(p,F)&&F!="constructor"&&O.push(F);return O}function Ka(p,O,F,W,Ae,ie){var Re=F&i,et=p.length,it=O.length;if(et!=it&&!(Re&&it>et))return!1;var Ce=ie.get(p);if(Ce&&ie.get(O))return Ce==O;var vt=-1,St=!0,at=F&s?new gn:void 0;for(ie.set(p,O),ie.set(O,p);++vt<et;){var _t=p[vt],bt=O[vt];if(W)var Gt=Re?W(bt,_t,vt,O,p,ie):W(_t,bt,vt,p,O,ie);if(Gt!==void 0){if(Gt)continue;St=!1;break}if(at){if(!me(O,function(jt,rr){if(!ve(at,rr)&&(_t===jt||Ae(_t,jt,F,W,ie)))return at.push(rr)})){St=!1;break}}else if(!(_t===bt||Ae(_t,bt,F,W,ie))){St=!1;break}}return ie.delete(p),ie.delete(O),St}function f0(p,O,F,W,Ae,ie,Re){switch(F){case J:if(p.byteLength!=O.byteLength||p.byteOffset!=O.byteOffset)return!1;p=p.buffer,O=O.buffer;case V:return!(p.byteLength!=O.byteLength||!ie(new xt(p),new xt(O)));case g:case D:case T:return Va(+p,+O);case C:return p.name==O.name&&p.message==O.message;case m:case o:return p==O+"";case R:var et=le;case b:var it=W&i;if(et||(et=ce),p.size!=O.size&&!it)return!1;var Ce=Re.get(p);if(Ce)return Ce==O;W|=s,Re.set(p,O);var vt=Ka(et(p),et(O),W,Ae,ie,Re);return Re.delete(p),vt;case d:if(ze)return ze.call(p)==ze.call(O)}return!1}function l0(p,O,F,W,Ae,ie){var Re=F&i,et=qa(p),it=et.length,Ce=qa(O),vt=Ce.length;if(it!=vt&&!Re)return!1;for(var St=it;St--;){var at=et[St];if(!(Re?at in O:ne.call(O,at)))return!1}var _t=ie.get(p);if(_t&&ie.get(O))return _t==O;var bt=!0;ie.set(p,O),ie.set(O,p);for(var Gt=Re;++St<it;){at=et[St];var jt=p[at],rr=O[at];if(W)var Ja=Re?W(rr,jt,at,O,p,ie):W(jt,rr,at,p,O,ie);if(!(Ja===void 0?jt===rr||Ae(jt,rr,F,W,ie):Ja)){bt=!1;break}Gt||(Gt=at=="constructor")}if(bt&&!Gt){var bn=p.constructor,mn=O.constructor;bn!=mn&&"constructor"in p&&"constructor"in O&&!(typeof bn=="function"&&bn instanceof bn&&typeof mn=="function"&&mn instanceof mn)&&(bt=!1)}return ie.delete(p),ie.delete(O),bt}function qa(p){return o0(p,D0,p0)}function yn(p,O){var F=p.__data__;return v0(O)?F[typeof O=="string"?"string":"hash"]:F.map}function gr(p,O){var F=pe(p,O);return c0(F)?F:void 0}function d0(p){var O=ne.call(p,gt),F=p[gt];try{p[gt]=void 0;var W=!0}catch{}var Ae=be.call(p);return W&&(O?p[gt]=F:delete p[gt]),Ae}var p0=Qt?function(p){return p==null?[]:(p=Object(p),ye(Qt(p),function(O){return Tt.call(p,O)}))}:x0,Vt=Hr;(Me&&Vt(new Me(new ArrayBuffer(1)))!=J||Ne&&Vt(new Ne)!=R||je&&Vt(je.resolve())!=A||$e&&Vt(new $e)!=b||Be&&Vt(new Be)!=K)&&(Vt=function(p){var O=Hr(p),F=O==E?p.constructor:void 0,W=F?tr(F):"";if(W)switch(W){case We:return J;case Ye:return R;case ke:return A;case Je:return b;case Xe:return K}return O});function g0(p,O){return O=O??c,!!O&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<O}function v0(p){var O=typeof p;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?p!=="__proto__":p===null}function y0(p){return!!_e&&_e in p}function _0(p){var O=p&&p.constructor,F=typeof O=="function"&&O.prototype||te;return p===F}function b0(p){return be.call(p)}function tr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function Va(p,O){return p===O||p!==p&&O!==O}var m0=za(function(){return arguments}())?za:function(p){return Kr(p)&&ne.call(p,"callee")&&!Tt.call(p,"callee")},_n=Array.isArray;function w0(p){return p!=null&&Wa(p.length)&&!Ga(p)}var Pi=zr||S0;function E0(p,O){return Ha(p,O)}function Ga(p){if(!Ya(p))return!1;var O=Hr(p);return O==x||O==w||O==l||O==y}function Wa(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=c}function Ya(p){var O=typeof p;return p!=null&&(O=="object"||O=="function")}function Kr(p){return p!=null&&typeof p=="object"}var ka=fe?Te(fe):u0;function D0(p){return w0(p)?s0(p):h0(p)}function x0(){return[]}function S0(){return!1}t.exports=E0})(wi,wi.exports);var Kd=wi.exports,qd=Object.defineProperty,Ko=Object.getOwnPropertySymbols,Vd=Object.prototype.hasOwnProperty,Gd=Object.prototype.propertyIsEnumerable,qo=(t,e,r)=>e in t?qd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Vd.call(e,r)&&qo(t,r,e[r]);if(Ko)for(var r of Ko(e))Gd.call(e,r)&&qo(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var cn=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!Wd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Fr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Vo(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:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Fr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ve.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?Fr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Fr(this._events[t])&&!this._events[t].warned&&(Vo(this._maxListeners)?r=Ve.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ve.prototype.on=Ve.prototype.addListener,Ve.prototype.once=function(t,e){if(!Ft(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ve.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ft(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ft(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Fr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ve.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ft(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ve.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ft(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function Wd(t){return typeof t=="number"}function Fr(t){return typeof t=="object"&&t!==null}function Vo(t){return t===void 0}function Yd(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),l=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var R=0,T=0,$=0,E=w.length;$!==E&&w[$]===0;)$++,R++;for(var A=(E-$)*g+1>>>0,y=new Uint8Array(A);$!==E;){for(var m=w[$],b=0,o=A-1;(m!==0||b<T)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%u>>>0,m=m/u>>>0;if(m!==0)throw new Error("Non-zero carry");T=b,$++}for(var d=A-T;d!==A&&y[d]===0;)d++;for(var M=h.repeat(R);d<A;++d)M+=t.charAt(y[d]);return M}function C(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var R=0;if(w[R]!==" "){for(var T=0,$=0;w[R]===h;)T++,R++;for(var E=(w.length-R)*l+1>>>0,A=new Uint8Array(E);w[R];){var y=r[w.charCodeAt(R)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<$)&&b!==-1;b--,m++)y+=u*A[b]>>>0,A[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");$=m,R++}if(w[R]!==" "){for(var o=E-$;o!==E&&A[o]===0;)o++;for(var d=new Uint8Array(T+(E-o)),M=T;o!==E;)d[M++]=A[o++];return d}}}function x(w){var R=C(w);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:x}}var kd=Yd,Jd=kd;const Go=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")},Xd=t=>new TextEncoder().encode(t),Zd=t=>new TextDecoder().decode(t);class Qd{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ep{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Wo(this,e)}}class tp{constructor(e){this.decoders=e}or(e){return Wo(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Wo=(t,e)=>new tp(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class rp{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Qd(e,r,n),this.decoder=new ep(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const un=({name:t,prefix:e,encode:r,decode:n})=>new rp(t,e,r,n),Ur=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Jd(r,e);return un({prefix:t,name:e,encode:n,decode:s=>Go(i(s))})},np=(t,e,r,n)=>{const i={};for(let g=0;g<e.length;++g)i[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,l=0;for(let g=0;g<s;++g){const D=i[t[g]];if(D===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|D,u+=r,u>=8&&(u-=8,c[l++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},ip=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},nt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>un({prefix:e,name:t,encode(i){return ip(i,n,r)},decode(i){return np(i,n,r,t)}}),sp=un({prefix:"\0",name:"identity",encode:t=>Zd(t),decode:t=>Xd(t)});var op=Object.freeze({__proto__:null,identity:sp});const ap=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cp=Object.freeze({__proto__:null,base2:ap});const up=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var hp=Object.freeze({__proto__:null,base8:up});const fp=Ur({prefix:"9",name:"base10",alphabet:"0123456789"});var lp=Object.freeze({__proto__:null,base10:fp});const dp=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pp=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gp=Object.freeze({__proto__:null,base16:dp,base16upper:pp});const vp=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yp=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_p=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bp=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mp=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wp=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ep=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Dp=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xp=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Sp=Object.freeze({__proto__:null,base32:vp,base32upper:yp,base32pad:_p,base32padupper:bp,base32hex:mp,base32hexupper:wp,base32hexpad:Ep,base32hexpadupper:Dp,base32z:xp});const Op=Ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ap=Ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ip=Object.freeze({__proto__:null,base36:Op,base36upper:Ap});const Lp=Ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cp=Ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Tp=Object.freeze({__proto__:null,base58btc:Lp,base58flickr:Cp});const Np=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pp=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rp=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fp=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Up=Object.freeze({__proto__:null,base64:Np,base64pad:Pp,base64url:Rp,base64urlpad:Fp});const Yo=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}"),Mp=Yo.reduce((t,e,r)=>(t[r]=e,t),[]),jp=Yo.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $p(t){return t.reduce((e,r)=>(e+=Mp[r],e),"")}function Bp(t){const e=[];for(const r of t){const n=jp[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const zp=un({prefix:"\u{1F680}",name:"base256emoji",encode:$p,decode:Bp});var Hp=Object.freeze({__proto__:null,base256emoji:zp}),Kp=Jo,ko=128,qp=127,Vp=~qp,Gp=Math.pow(2,31);function Jo(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Gp;)e[r++]=t&255|ko,t/=128;for(;t&Vp;)e[r++]=t&255|ko,t>>>=7;return e[r]=t|0,Jo.bytes=r-n+1,e}var Wp=Ei,Yp=128,Xo=127;function Ei(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw Ei.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&Xo)<<i:(c&Xo)*Math.pow(2,i),i+=7}while(c>=Yp);return Ei.bytes=s-n,r}var kp=Math.pow(2,7),Jp=Math.pow(2,14),Xp=Math.pow(2,21),Zp=Math.pow(2,28),Qp=Math.pow(2,35),eg=Math.pow(2,42),tg=Math.pow(2,49),rg=Math.pow(2,56),ng=Math.pow(2,63),ig=function(t){return t<kp?1:t<Jp?2:t<Xp?3:t<Zp?4:t<Qp?5:t<eg?6:t<tg?7:t<rg?8:t<ng?9:10},sg={encode:Kp,decode:Wp,encodingLength:ig},Zo=sg;const Qo=(t,e,r=0)=>(Zo.encode(t,e,r),e),ea=t=>Zo.encodingLength(t),Di=(t,e)=>{const r=e.byteLength,n=ea(t),i=n+ea(r),s=new Uint8Array(i+r);return Qo(t,s,0),Qo(r,s,n),s.set(e,i),new og(t,r,e,s)};class og{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const ta=({name:t,code:e,encode:r})=>new ag(t,e,r);class ag{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Di(this.code,r):r.then(n=>Di(this.code,n))}else throw Error("Unknown type, must be binary type")}}const ra=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),cg=ta({name:"sha2-256",code:18,encode:ra("SHA-256")}),ug=ta({name:"sha2-512",code:19,encode:ra("SHA-512")});var hg=Object.freeze({__proto__:null,sha256:cg,sha512:ug});const na=0,fg="identity",ia=Go;var lg=Object.freeze({__proto__:null,identity:{code:na,name:fg,encode:ia,digest:t=>Di(na,ia(t))}});new TextEncoder,new TextDecoder;const sa=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},op),cp),hp),lp),gp),Sp),Ip),Tp),Up),Hp);ut(ut({},hg),lg);function dg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function oa(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const aa=oa("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),xi=oa("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=dg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),pg=ut({utf8:aa,"utf-8":aa,hex:sa.base16,latin1:xi,ascii:xi,binary:xi},sa);function gg(t,e="utf8"){const r=pg[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}const ca="wc",vg=2,Si="core",Mr=`${ca}@${2}:${Si}:`,yg={name:Si,logger:"error"},_g={database:":memory:"},bg="crypto",ua="client_ed25519_seed",mg=Le.ONE_DAY,wg="keychain",Eg="0.3",Dg="messages",xg="0.3",Sg=Le.SIX_HOURS,Og="publisher",ha="irn",Ag="error",Ig="wss://relay.walletconnect.com",Lg="relayer",jr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Cg="_subscription",lr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Tg=Le.ONE_SECOND,Ng="2.0.0-rc.1",Pg="0.3",Zt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},Rg="subscription",Fg="0.3",Ug=Le.FIVE_SECONDS*1e3;class Mg{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=wg,this.version=Eg,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=G("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,io(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?so(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 jg{constructor(e,r,n){this.core=e,this.logger=r,this.name=bg,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=zo(i);return Bo(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=vf();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),c=zo(s),u=ei();return await Bd(u,i,mg,c)},this.generateSharedKey=(i,s,c)=>{this.isInitialized();const u=this.getPrivateKey(i),h=yf(u,s);return this.setSymKey(h,c)},this.setSymKey=async(i,s)=>{this.isInitialized();const c=s||_f(i);return await this.keychain.set(c,i),c},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,c)=>{this.isInitialized();const u=Zs(c),h=br(s);if(Qs(u)){const C=u.senderPublicKey,x=u.receiverPublicKey;i=await this.generateSharedKey(C,x)}const l=this.getSymKey(i),{type:g,senderPublicKey:D}=u;return mf({type:g,symKey:l,message:h,senderPublicKey:D})},this.decode=async(i,s,c)=>{this.isInitialized();const u=Df(s,c);if(Qs(u)){const g=u.receiverPublicKey,D=u.senderPublicKey;i=await this.generateSharedKey(g,D)}const h=this.getSymKey(i),l=wf({symKey:h,encoded:s});return In(l)},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.keychain=n||new Mg(this.core,this.logger)}get context(){return Oe.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(ua)}catch{e=ei(),await this.keychain.set(ua,e)}return gg(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 $g extends yd{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Dg,this.version=xg,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Zr(i);let c=this.messages.get(n);return typeof c>"u"&&(c={}),typeof c[s]<"u"||(c[s]=i,this.messages.set(n,c),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),c=Zr(i);return typeof s[c]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Oe.generateChildLogger(e,this.name),this.core=r}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,io(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?so(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 Bg extends _d{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new cn.EventEmitter,this.name=Og,this.queue=new Map,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const c=s?.ttl||Sg,u=ti(s),h=s?.prompt||!1,l=s?.tag||0,g={topic:n,message:i,opts:{ttl:c,relay:u,prompt:h,tag:l}},D=Zr(i);this.queue.set(D,g),await this.rpcPublish(n,i,c,u,h,l),this.onPublish(D,g),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(c){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(c),c}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Oe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,c){var u,h,l,g;const D={method:ri(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:c}};return Et((u=D.params)==null?void 0:u.prompt)&&((h=D.params)==null||delete h.prompt),Et((l=D.params)==null?void 0:l.tag)&&((g=D.params)==null||delete g.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:{ttl:i,relay:s,prompt:c,tag:u}}=e,h=Zr(n);await this.rpcPublish(r,n,i,s,c,u),this.onPublish(h,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class zg{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Hg=Object.defineProperty,Kg=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,fa=Object.getOwnPropertySymbols,Vg=Object.prototype.hasOwnProperty,Gg=Object.prototype.propertyIsEnumerable,la=(t,e,r)=>e in t?Hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hn=(t,e)=>{for(var r in e||(e={}))Vg.call(e,r)&&la(t,r,e[r]);if(fa)for(var r of fa(e))Gg.call(e,r)&&la(t,r,e[r]);return t},Oi=(t,e)=>Kg(t,qg(e));class Wg extends wd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new zg,this.events=new cn.EventEmitter,this.name=Rg,this.version=Fg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),await this.reset(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=ti(i),c={topic:n,relay:s};this.pending.set(n,c);const u=await this.rpcSubscribe(n,s);return this.onSubscribe(u,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),u}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const c=new Le.Watch;c.start(this.pendingSubscriptionWatchLabel);const u=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),i(!0)),c.elapsed(this.pendingSubscriptionWatchLabel)>=Ug&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=ti(n);await this.rpcUnsubscribe(e,r,i);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:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r){const n={method:ri(r.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),await this.relayer.provider.request(n)}rpcUnsubscribe(e,r,n){const i={method:ri(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r))}addSubscription(e,r){this.subscriptions.set(e,hn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Zt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Zt.deleted,Oi(hn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Zt.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:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.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(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(lr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(lr.disconnect,()=>{this.onDisconnect()}),this.events.on(Zt.created,async e=>{const r=Zt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Zt.deleted,async e=>{const r=Zt.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 Yg=Object.defineProperty,da=Object.getOwnPropertySymbols,kg=Object.prototype.hasOwnProperty,Jg=Object.prototype.propertyIsEnumerable,pa=(t,e,r)=>e in t?Yg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xg=(t,e)=>{for(var r in e||(e={}))kg.call(e,r)&&pa(t,r,e[r]);if(da)for(var r of da(e))Jg.call(e,r)&&pa(t,r,e[r]);return t};class Zg extends bd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new cn.EventEmitter,this.name=Lg,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Oe.generateChildLogger(e.logger,this.name):oi(Oe.getDefaultLoggerOptions({level:e.logger||Ag})),this.messages=new $g(this.logger,e.core),this.subscriber=new Wg(this,this.logger),this.publisher=new Bg(this,this.logger),this.relayUrl=e?.relayUrl||Ig,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 Oe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){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 On(new Hd(Mf({sdkVersion:Ng,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Yi(e)){if(!e.method.endsWith(Cg))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Xg({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(jr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Sn(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(lr.payload,e=>this.onProviderPayload(e)),this.provider.on(lr.connect,()=>{this.events.emit(jr.connect)}),this.provider.on(lr.disconnect,()=>{this.events.emit(jr.disconnect),setTimeout(()=>{this.provider.connect()},Le.toMiliseconds(Tg))}),this.provider.on(lr.error,e=>this.events.emit(jr.error,e))}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qg=Object.defineProperty,ga=Object.getOwnPropertySymbols,ev=Object.prototype.hasOwnProperty,tv=Object.prototype.propertyIsEnumerable,va=(t,e,r)=>e in t?Qg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ya=(t,e)=>{for(var r in e||(e={}))ev.call(e,r)&&va(t,r,e[r]);if(ga)for(var r of ga(e))tv.call(e,r)&&va(t,r,e[r]);return t};class Ai extends md{constructor(e,r,n,i=Mr){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=Pg,this.cached=[],this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>{il(s)?this.map.set(s.id,s):sl(s)&&this.map.set(s.topic,s)}),this.cached=[],this.initialized=!0)},this.set=async(s,c)=>{this.isInitialized(),this.map.has(s)?await this.update(s,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:s,value:c}),this.map.set(s,c),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(c=>Object.keys(s).every(u=>Kd(c[u],s[u]))):this.values,this.update=async(s,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:s,update:c});const u=ya(ya({},this.getData(s)),c);this.map.set(s,u),await this.persist()},this.delete=async(s,c)=>{this.isInitialized(),this.map.has(s)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:s,reason:c}),this.map.delete(s),await this.persist())},this.logger=Oe.generateChildLogger(r,this.name),this.storagePrefix=i}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var rv=Object.defineProperty,_a=Object.getOwnPropertySymbols,nv=Object.prototype.hasOwnProperty,iv=Object.prototype.propertyIsEnumerable,ba=(t,e,r)=>e in t?rv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ma=(t,e)=>{for(var r in e||(e={}))nv.call(e,r)&&ba(t,r,e[r]);if(_a)for(var r of _a(e))iv.call(e,r)&&ba(t,r,e[r]);return t};class Ii extends gd{constructor(e){super(e),this.protocol=ca,this.version=vg,this.name=Si,this.events=new cn.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||yg.logger}));this.logger=Oe.generateChildLogger(r,this.name),this.heartbeat=new Pr.HeartBeat,this.crypto=new jg(this,this.logger,e?.keychain),this.storage=e!=null&&e.storage?e.storage:new sd(ma(ma({},_g),e?.storageOptions)),this.relayer=new Zg({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId})}static async init(e){const r=new Ii(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.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 sv=Ii;var dr={exports:{}},pr=typeof Reflect=="object"?Reflect:null,wa=pr&&typeof pr.apply=="function"?pr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},fn;pr&&typeof pr.ownKeys=="function"?fn=pr.ownKeys:Object.getOwnPropertySymbols?fn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fn=function(e){return Object.getOwnPropertyNames(e)};function ov(t){console&&console.warn&&console.warn(t)}var Ea=Number.isNaN||function(e){return e!==e};function xe(){xe.init.call(this)}dr.exports=xe,dr.exports.once=hv,xe.EventEmitter=xe,xe.prototype._events=void 0,xe.prototype._eventsCount=0,xe.prototype._maxListeners=void 0;var Da=10;function ln(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(xe,"defaultMaxListeners",{enumerable:!0,get:function(){return Da},set:function(t){if(typeof t!="number"||t<0||Ea(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Da=t}}),xe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},xe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ea(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function xa(t){return t._maxListeners===void 0?xe.defaultMaxListeners:t._maxListeners}xe.prototype.getMaxListeners=function(){return xa(this)},xe.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var u=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw u.context=c,u}var h=s[e];if(h===void 0)return!1;if(typeof h=="function")wa(h,this,r);else for(var l=h.length,g=La(h,l),n=0;n<l;++n)wa(g[n],this,r);return!0};function Sa(t,e,r,n){var i,s,c;if(ln(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),c=s[e]),c===void 0)c=s[e]=r,++t._eventsCount;else if(typeof c=="function"?c=s[e]=n?[r,c]:[c,r]:n?c.unshift(r):c.push(r),i=xa(t),i>0&&c.length>i&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=c.length,ov(u)}return t}xe.prototype.addListener=function(e,r){return Sa(this,e,r,!1)},xe.prototype.on=xe.prototype.addListener,xe.prototype.prependListener=function(e,r){return Sa(this,e,r,!0)};function av(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Oa(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=av.bind(n);return i.listener=r,n.wrapFn=i,i}xe.prototype.once=function(e,r){return ln(r),this.on(e,Oa(this,e,r)),this},xe.prototype.prependOnceListener=function(e,r){return ln(r),this.prependListener(e,Oa(this,e,r)),this},xe.prototype.removeListener=function(e,r){var n,i,s,c,u;if(ln(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,c=n.length-1;c>=0;c--)if(n[c]===r||n[c].listener===r){u=n[c].listener,s=c;break}if(s<0)return this;s===0?n.shift():cv(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},xe.prototype.off=xe.prototype.removeListener,xe.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),c;for(i=0;i<s.length;++i)c=s[i],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Aa(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?uv(i):La(i,i.length)}xe.prototype.listeners=function(e){return Aa(this,e,!0)},xe.prototype.rawListeners=function(e){return Aa(this,e,!1)},xe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Ia.call(t,e)},xe.prototype.listenerCount=Ia;function Ia(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}xe.prototype.eventNames=function(){return this._eventsCount>0?fn(this._events):[]};function La(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function cv(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function uv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function hv(t,e){return new Promise(function(r,n){function i(c){t.removeListener(e,s),n(c)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Ca(t,e,s,{once:!0}),e!=="error"&&fv(t,i,{once:!0})})}function fv(t,e,r){typeof t.on=="function"&&Ca(t,"error",e,r)}function Ca(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const Ta="wc",Na=2,Pa="client",$r=`${Ta}@${Na}:${Pa}:`,Li={name:Pa,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},lv="expirer",Dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},dv="0.3",Lt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},pv="history",gv="0.3",vv="pairing",yv="proposal",Ra=ar(Le.THIRTY_DAYS),_v="session",bv=Le.SEVEN_DAYS,dn=ar(bv),mv="engine",Ci={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 wv=Object.defineProperty,Ev=Object.defineProperties,Dv=Object.getOwnPropertyDescriptors,Fa=Object.getOwnPropertySymbols,xv=Object.prototype.hasOwnProperty,Sv=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?wv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ht=(t,e)=>{for(var r in e||(e={}))xv.call(e,r)&&Ua(t,r,e[r]);if(Fa)for(var r of Fa(e))Sv.call(e,r)&&Ua(t,r,e[r]);return t},Ma=(t,e)=>Ev(t,Dv(e));class Ov extends Sd{constructor(e){super(e),this.events=new dr.exports,this.initialized=!1,this.name=mv,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:n,requiredNamespaces:i,relays:s}=r;let c=n,u,h=!1;if(c&&(h=this.client.pairing.get(c).active),!c||!h){const{topic:T,uri:$}=await this.createPairing();c=T,u=$}const l=await this.client.core.crypto.generateKeyPair(),g={requiredNamespaces:i,relays:s??[{protocol:ha}],proposer:{publicKey:l,metadata:this.client.metadata}},{reject:D,resolve:C,done:x}=kt();if(this.events.once(Fe("session_connect"),async({error:T,session:$})=>{if(T)D(T);else if($){$.self.publicKey=l;const E=Ma(Ht({},$),{requiredNamespaces:i});await this.client.session.set($.topic,E),await this.setExpiry($.topic,$.expiry),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),C(E)}}),!c){const{message:T}=G("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const w=await this.sendRequest(c,"wc_sessionPropose",g),R=ar(Le.FIVE_MINUTES);return await this.setProposal(w,Ht({id:w,expiry:R},g)),{uri:u,approval:x}},this.pair=async r=>{this.isInitialized(),this.isValidPair(r);const{topic:n,symKey:i,relay:s}=Wf(r.uri),c=ar(Le.FIVE_MINUTES),u={topic:n,relay:s,expiry:c,active:!1};return await this.client.pairing.set(n,u),await this.client.core.crypto.setSymKey(i,n),await this.client.core.relayer.subscribe(n,{relay:s}),await this.setExpiry(n,c),u},this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,{pairingTopic:c,proposer:u,requiredNamespaces:h}=this.client.proposal.get(n),l=await this.client.core.crypto.generateKeyPair(),g=u.publicKey,D=await this.client.core.crypto.generateSharedKey(l,g),C={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:dn};await this.client.core.relayer.subscribe(D);const x=await this.sendRequest(D,"wc_sessionSettle",C),{done:w,resolve:R,reject:T}=kt();this.events.once(Fe("session_approve",x),({error:E})=>{E?T(E):R(this.client.session.get(D))});const $=Ma(Ht({},C),{topic:D,acknowledged:!1,self:C.controller,peer:{publicKey:u.publicKey,metadata:u.metadata},controller:l});return await this.client.session.set(D,$),await this.setExpiry(D,dn),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),c&&n&&(await this.sendResult(n,c,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")),await this.activatePairing(c)),{topic:D,acknowledged:w}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:c,resolve:u,reject:h}=kt();return this.events.once(Fe("session_update",s),({error:l})=>{l?h(l):u()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:c}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:c,reject:u}=kt();return this.events.once(Fe("session_extend",i),({error:h})=>{h?u(h):c()}),await this.setExpiry(n,dn),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n}),{done:u,resolve:h,reject:l}=kt();return this.events.once(Fe("session_request",c),({error:g,result:D})=>{g?l(g):h(D)}),await u()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Pt(i)?await this.sendResult(s,n,i.result):wt(i)&&await this.sendError(s,n,i.error)},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:c,reject:u}=kt();this.events.once(Fe("session_ping",i),({error:h})=>{h?u(h):c()}),await s()}else if(this.client.pairing.keys.includes(n)){const i=await this.sendRequest(n,"wc_pairingPing",{}),{done:s,resolve:c,reject:u}=kt();this.events.once(Fe("pairing_ping",i),({error:h})=>{h?u(h):c()}),await s()}},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",rt("USER_DISCONNECTED")),await this.deleteSession(n)):this.client.pairing.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",rt("USER_DISCONNECTED")),await this.deletePairing(n))},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>tl(n,r))),this.activatePairing=async r=>{await this.client.pairing.update(r,{active:!0,expiry:Ra}),await this.setExpiry(r,Ra)},this.deleteSession=async r=>{const{self:n}=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(n.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,n)=>{this.client.pairing.keys.includes(r)?await this.client.pairing.update(r,{expiry:n}):this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.expirer.set(r,n.expiry)},this.sendRequest=async(r,n,i)=>{const s=xn(n,i),c=await this.client.core.crypto.encode(r,s),u=Ci[n].req;return await this.client.core.relayer.publish(r,c,u),this.client.history.set(r,s),s.id},this.sendResult=async(r,n,i)=>{const s=Sn(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ci[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=qr(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ci[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[],i=[];this.client.session.getAll().forEach(s=>{Yt(s.expiry)&&r.push(s.topic)}),this.client.pairing.getAll().forEach(s=>{Yt(s.expiry)&&n.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Yt(s.expiry)&&i.push(s.id)}),await Promise.all([...r.map(this.deleteSession),...n.map(this.deletePairing),...i.map(this.deleteProposal)])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_pairingPing":return this.onPairingPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_pairingPing":return this.onPairingPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Ht({},n.params));const c=ar(Le.FIVE_MINUTES),u=Ht({id:s,pairingTopic:r,expiry:c},i);await this.setProposal(s,u),this.client.events.emit("session_proposal",{id:s,params:u})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Pt(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const c=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const u=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const l=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:l});const g=await this.client.core.relayer.subscribe(l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.activatePairing(r)}else wt(n)&&(await this.client.proposal.delete(i,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:c,controller:u,expiry:h,namespaces:l}=n.params,g={topic:r,relay:c,expiry:h,namespaces:l,acknowledged:!0,controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Fe("session_connect"),{session:g})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Pt(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Fe("session_approve",i),{})):wt(n)&&(await this.client.session.delete(r,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Ht({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_update",i),{}):wt(n)&&this.events.emit(Fe("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,dn),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_extend",i),{}):wt(n)&&this.events.emit(Fe("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_ping",i),{}):wt(n)&&this.events.emit(Fe("session_ping",i),{error:n.error})},this.onPairingPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("pairing_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("pairing_ping",i),{}):wt(n)&&this.events.emit(Fe("pairing_ping",i),{error:n.error})},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deletePairing(r),this.client.events.emit("pairing_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Ht({topic:r},s)),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_request",i),{result:n.result}):wt(n)&&this.events.emit(Fe("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Ht({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;Et(n)||await this.isValidPairingTopic(n);const c=ul(i,"connect()");if(c)throw new Error(c.message);if(!hl(s,!0)){const{message:u}=G("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(u)}},this.isValidPair=r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`pair() params: ${r}`);throw new Error(n)}if(!nl(r.uri)){const{message:n}=G("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw new Error(n)}},this.isValidApprove=async r=>{if(!yt(r))throw new Error(G("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const c=this.client.proposal.get(n),u=si(i,"approve()");if(u)throw new Error(u.message);const h=bo(c.requiredNamespaces,i,"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:n,reason:i}=r;if(await this.isValidProposalId(n),!ll(i)){const{message:s}=G("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);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:n,controller:i,namespaces:s,expiry:c}=r;if(!yo(n)){const{message:l}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const u=ol(i,"onSessionSettleRequest()");if(u)throw new Error(u.message);const h=si(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(Yt(c)){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:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),c=si(i,"update()");if(c)throw new Error(c.message);const u=bo(s.requiredNamespaces,i,"update()");if(u)throw new Error(u.message)},this.isValidExtend=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:n,request:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!_o(c,s)){const{message:u}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!dl(i)){const{message:u}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(u)}if(!vl(c,s,i.method)){const{message:u}=G("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(u)}},this.isValidRespond=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!pl(i)){const{message:s}=G("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(u)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!_o(c,s)){const{message:u}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(u)}if(!gl(i)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}if(!yl(c,s,i.name)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}},this.isValidDisconnect=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}async createPairing(){const e=ei(),r=await this.client.core.crypto.setSymKey(e),n=ar(Le.FIVE_MINUTES),i={protocol:ha},s={topic:r,expiry:n,relay:i,active:!1},c=kf({protocol:this.client.protocol,version:this.client.version,topic:r,symKey:e,relay:i});return await this.client.pairing.set(r,s),await this.client.core.relayer.subscribe(r),await this.setExpiry(r,n),{topic:r,uri:c}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(jr.message,async e=>{const{topic:r,message:n}=e,i=await this.client.core.crypto.decode(r,n);Yi(i)?(this.client.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):ki(i)&&(await this.client.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.expirer.on(Dt.expired,async e=>{const{topic:r,id:n}=Bf(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})):n&&await this.deleteProposal(n)})}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(!fl(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 Av extends Od{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new dr.exports.EventEmitter,this.name=lv,this.version=dv,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),c={target:s,expiry:i};this.expirations.set(s,c),this.checkExpiry(s,c),this.events.emit(Dt.created,{target:s,expiration:c})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{this.isInitialized();const i=this.formatTarget(n);if(this.has(i)){const s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Dt.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return jf(e);if(typeof e=="number")return $f(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:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Le.toMiliseconds(n)-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(Pr.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 Iv extends vd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new dr.exports.EventEmitter,this.name=pv,this.version=gv,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const c={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(c.id,c),this.events.emit(Lt.created,c)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=wt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Lt.updated,i))},this.get=async(n,i)=>{this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i});const s=await this.getRecord(i);if(s.topic!==n){const{message:c}=G("MISMATCHED_TOPIC",`${this.name}, ${i}`);throw this.logger.error(c),new Error(c)}return s},this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Lt.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:xn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Lt.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(Lt.created,e=>{const r=Lt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.updated,e=>{const r=Lt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.deleted,e=>{const r=Lt.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 Lv extends Ai{constructor(e,r){super(e,r,vv,$r),this.core=e,this.logger=r}}class Cv extends Ai{constructor(e,r){super(e,r,yv,$r),this.core=e,this.logger=r}}class Tv extends Ai{constructor(e,r){super(e,r,_v,$r),this.core=e,this.logger=r}}_l();class Ti extends xd{constructor(e){super(e),this.protocol=Ta,this.version=Na,this.name=Li.name,this.events=new dr.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.name=e?.name||Li.name,this.metadata=e?.metadata||Pf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||Li.logger}));this.core=e?.core||new sv(e),this.logger=Oe.generateChildLogger(r,this.name),this.pairing=new Lv(this.core,this.logger),this.session=new Tv(this.core,this.logger),this.proposal=new Cv(this.core,this.logger),this.history=new Iv(this.core,this.logger),this.expirer=new Av(this.core,this.logger),this.engine=new Ov(this)}static async init(e){const r=new Ti(e);return await r.initialize(),r}get context(){return Oe.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 Nv=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!Pv(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Br(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],ja(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:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Br(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ge.prototype.addListener=function(t,e){var r;if(!Ut(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ut(e.listener)?e.listener:e),this._events[t]?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&&(ja(this._maxListeners)?r=Ge.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ge.prototype.on=Ge.prototype.addListener,Ge.prototype.once=function(t,e){if(!Ut(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ge.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ut(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ut(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Br(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ge.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ut(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ge.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ut(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ut(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Ut(t){return typeof t=="function"}function Pv(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function ja(t){return t===void 0}function Rv(t){return typeof t<"u"&&typeof t.context<"u"}const Ct={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class Fv extends hc{constructor(e){super(),this.events=new Nv.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?kn(this.session.namespaces):pf(this.requiredNamespaces)}get accounts(){return this.session?Yn(this.session.namespaces):[]}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(Ct.uri,{uri:n}),this.session=await i(),this.events.emit(Ct.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason: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(n=>this.events.emit("payload",Sn(e.id,n))).catch(n=>this.events.emit("payload",qr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(Ct.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(Rv(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Ti.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Ct.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(Ct.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(Ct.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(Ct.deleted,this.session),this.session=void 0)}))}}const Uv=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],Mv=["chainChanged","accountsChanged"];function $a(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Ba(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Ni([t])]),r}function Ni(t){return Number(t[0].split(":")[1])}class jv{constructor(e){this.events=new vr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=$a(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Ni(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(Ct.created,e=>{const r=kn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Yn(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(Ct.updated,e=>{const r=kn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=Yn(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(Ct.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new Fv({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new On(r)}setHttpProvider(e){const r=Ba(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new On(new yc(r))}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}}mt.default=jv,mt.getEthereumChainId=Ni,mt.getRpcConfig=$a,mt.getRpcUrl=Ba,mt.signerEvents=Mv,mt.signerMethods=Uv,Object.defineProperty(mt,"__esModule",{value:!0})});
|
|
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 za(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(!Ha(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,c;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 u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Pn(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),c=r.slice(),i=c.length,s=0;s<i;s++)c[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&&(Pn(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 Ha(t){return typeof t=="number"}function vr(t){return typeof t=="object"&&t!==null}function Pn(t){return t===void 0}const Ka="PARSE_ERROR",qa="INVALID_REQUEST",Va="METHOD_NOT_FOUND",Ga="INVALID_PARAMS",Rn="INTERNAL_ERROR",mi="SERVER_ERROR",Wa=[-32700,-32600,-32601,-32602,-32603],yr={[Ka]:{code:-32700,message:"Parse error"},[qa]:{code:-32600,message:"Invalid Request"},[Va]:{code:-32601,message:"Method not found"},[Ga]:{code:-32602,message:"Invalid params"},[Rn]:{code:-32603,message:"Internal error"},[mi]:{code:-32e3,message:"Server error"}},Fn=mi;function ka(t){return Wa.includes(t)}function Un(t){return Object.keys(yr).includes(t)?yr[t]:yr[Fn]}function Ya(t){const e=Object.values(yr).find(r=>r.code===t);return e||yr[Fn]}function Mn(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var jn={},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 $n(){const t=wi();return t.subtle||t.webkitSubtle}Bt.getSubtleCrypto=$n;function Ja(){return!!wi()&&!!$n()}Bt.isBrowserCryptoAvailable=Ja;var zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.isBrowser=zt.isNode=zt.isReactNative=void 0;function Bn(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}zt.isReactNative=Bn;function zn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}zt.isNode=zn;function Xa(){return!Bn()&&!zn()}zt.isBrowser=Xa,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Bt,t),r(zt,t)}(jn);function Za(){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||Za(),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:Qa(e,r)}}function Qa(t,e){return typeof t>"u"?Un(Rn):(typeof t=="string"&&(t=Object.assign(Object.assign({},Un(mi)),{message:t})),typeof e<"u"&&(t.data=e),ka(t.code)&&(t=Ya(t.code)),t)}class Hn{}class ec extends Hn{constructor(e){super()}}class tc extends Hn{constructor(){super()}}class rc extends tc{constructor(e){super()}}const ic="^https?:",nc="^wss?:";function sc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Kn(t,e){const r=sc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function qn(t){return Kn(t,ic)}function Vn(t){return Kn(t,nc)}function oc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Gn(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Wn(t){return Gn(t)&&"method"in t}function kn(t){return Gn(t)&&(Pt(t)||wt(t))}function Pt(t){return"result"in t}function wt(t){return"error"in t}class xi extends rc{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),kn(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(c){var u={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(u.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(f){return f&&d.indexOf(Object.prototype.toString.call(f))>-1};function D(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 C(f){return typeof f!="string"&&(f=String(f)),f}function x(f){var _={next:function(){var U=f.shift();return{done:U===void 0,value:U}}};return u.iterable&&(_[Symbol.iterator]=function(){return _}),_}function w(f){this.map={},f instanceof w?f.forEach(function(_,U){this.append(U,_)},this):Array.isArray(f)?f.forEach(function(_){this.append(_[0],_[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(_){this.append(_,f[_])},this)}w.prototype.append=function(f,_){f=D(f),_=C(_);var U=this.map[f];this.map[f]=U?U+", "+_:_},w.prototype.delete=function(f){delete this.map[D(f)]},w.prototype.get=function(f){return f=D(f),this.has(f)?this.map[f]:null},w.prototype.has=function(f){return this.map.hasOwnProperty(D(f))},w.prototype.set=function(f,_){this.map[D(f)]=C(_)},w.prototype.forEach=function(f,_){for(var U in this.map)this.map.hasOwnProperty(U)&&f.call(_,this.map[U],U,this)},w.prototype.keys=function(){var f=[];return this.forEach(function(_,U){f.push(U)}),x(f)},w.prototype.values=function(){var f=[];return this.forEach(function(_){f.push(_)}),x(f)},w.prototype.entries=function(){var f=[];return this.forEach(function(_,U){f.push([U,_])}),x(f)},u.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function R(f){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}function L(f){return new Promise(function(_,U){f.onload=function(){_(f.result)},f.onerror=function(){U(f.error)}})}function $(f){var _=new FileReader,U=L(_);return _.readAsArrayBuffer(f),U}function E(f){var _=new FileReader,U=L(_);return _.readAsText(f),U}function A(f){for(var _=new Uint8Array(f),U=new Array(_.length),q=0;q<_.length;q++)U[q]=String.fromCharCode(_[q]);return U.join("")}function y(f){if(f.slice)return f.slice(0);var _=new Uint8Array(f.byteLength);return _.set(new Uint8Array(f)),_.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(f){this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:u.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:u.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():u.arrayBuffer&&u.blob&&h(f)?(this._bodyArrayBuffer=y(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||g(f))?this._bodyArrayBuffer=y(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):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var f=R(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?R(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then($)}),this.text=function(){var f=R(this);if(f)return f;if(this._bodyBlob)return E(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(f){var _=f.toUpperCase();return b.indexOf(_)>-1?_:f}function l(f,_){_=_||{};var U=_.body;if(f instanceof l){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,_.headers||(this.headers=new w(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!U&&f._bodyInit!=null&&(U=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new w(_.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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(U)}l.prototype.clone=function(){return new l(this,{body:this._bodyInit})};function M(f){var _=new FormData;return f.trim().split("&").forEach(function(U){if(U){var q=U.split("="),P=q.shift().replace(/\+/g," "),N=q.join("=").replace(/\+/g," ");_.append(decodeURIComponent(P),decodeURIComponent(N))}}),_}function K(f){var _=new w,U=f.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function(q){var P=q.split(":"),N=P.shift().trim();if(N){var j=P.join(":").trim();_.append(N,j)}}),_}m.call(l.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 w(_.headers),this.url=_.url||"",this._initBody(f)}m.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(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}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(_,U){this.message=_,this.name=U;var q=Error(_);this.stack=q.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function X(f,_){return new Promise(function(U,q){var P=new l(f,_);if(P.signal&&P.signal.aborted)return q(new c.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function j(){N.abort()}N.onload=function(){var B={status:N.status,statusText:N.statusText,headers:K(N.getAllResponseHeaders()||"")};B.url="responseURL"in N?N.responseURL:B.headers.get("X-Request-URL");var Q="response"in N?N.response:N.responseText;U(new V(Q,B))},N.onerror=function(){q(new TypeError("Network request failed"))},N.ontimeout=function(){q(new TypeError("Network request failed"))},N.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},N.open(P.method,P.url,!0),P.credentials==="include"?N.withCredentials=!0:P.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&u.blob&&(N.responseType="blob"),P.headers.forEach(function(B,Q){N.setRequestHeader(Q,B)}),P.signal&&(P.signal.addEventListener("abort",j),N.onreadystatechange=function(){N.readyState===4&&P.signal.removeEventListener("abort",j)}),N.send(typeof P._bodyInit>"u"?null:P._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=w,s.Request=l,s.Response=V),c.Headers=w,c.Request=l,c.Response=V,c.fetch=X,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e})(Si,Si.exports);var Yn=za(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 Jn={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},Xn=10;class ac{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.isAvailable=!1,this.registering=!1,!qn(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 Yn(this.url,Object.assign(Object.assign({},Jn),{body:i}))).json();this.onPayload({data:s})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!qn(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{const r=_r({id:1,jsonrpc:"2.0",method:"test",params:[]});await Yn(e,Object.assign(Object.assign({},Jn),{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 Mn(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Xn&&this.events.setMaxListeners(Xn)}}var Ai={},Vr={},re={},Zn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(u,h){var d=u>>>16&65535,g=u&65535,D=h>>>16&65535,C=h&65535;return g*C+(d*C+g*D<<16>>>0)|0}t.mul=Math.imul||e;function r(u,h){return u+h|0}t.add=r;function i(u,h){return u-h|0}t.sub=i;function n(u,h){return u<<h|u>>>32-h}t.rotl=n;function s(u,h){return u<<32-h|u>>>h}t.rotr=s;function c(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}t.isInteger=Number.isInteger||c,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(u){return t.isInteger(u)&&u>=-t.MAX_SAFE_INTEGER&&u<=t.MAX_SAFE_INTEGER}})(Zn),Object.defineProperty(re,"__esModule",{value:!0});var Qn=Zn;function cc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=cc;function uc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=uc;function hc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=hc;function fc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=fc;function es(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=es,re.writeInt16BE=es;function ts(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=ts,re.writeInt16LE=ts;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 Ti(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=Ti;function Ci(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Ci;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 lc(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=lc;function dc(t,e){e===void 0&&(e=0);var r=Ti(t,e),i=Ti(t,e+4);return r*4294967296+i}re.readUint64BE=dc;function pc(t,e){e===void 0&&(e=0);var r=Ci(t,e),i=Ci(t,e+4);return i*4294967296+r-(r>>31)*4294967296}re.readInt64LE=pc;function gc(t,e){e===void 0&&(e=0);var r=Li(t,e),i=Li(t,e+4);return i*4294967296+r}re.readUint64LE=gc;function rs(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=rs,re.writeInt64BE=rs;function is(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=is,re.writeInt64LE=is;function vc(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=vc;function yc(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s<r+t/8;s++)i+=e[s]*n,n*=256;return i}re.readUintLE=yc;function _c(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Qn.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=_c;function bc(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(!Qn.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=bc;function mc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=mc;function wc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=wc;function Ec(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Dc;function xc(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=xc;function Sc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t,!0),e}re.writeFloat32LE=Sc;function Oc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t),e}re.writeFloat64BE=Oc;function Ac(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=Ac;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});function Ic(t){for(var e=0;e<t.length;e++)t[e]=0;return t}pt.wipe=Ic,Object.defineProperty(Vr,"__esModule",{value:!0});var st=re,Ni=pt,Tc=20;function Cc(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,c=1797285236,u=r[3]<<24|r[2]<<16|r[1]<<8|r[0],h=r[7]<<24|r[6]<<16|r[5]<<8|r[4],d=r[11]<<24|r[10]<<16|r[9]<<8|r[8],g=r[15]<<24|r[14]<<16|r[13]<<8|r[12],D=r[19]<<24|r[18]<<16|r[17]<<8|r[16],C=r[23]<<24|r[22]<<16|r[21]<<8|r[20],x=r[27]<<24|r[26]<<16|r[25]<<8|r[24],w=r[31]<<24|r[30]<<16|r[29]<<8|r[28],R=e[3]<<24|e[2]<<16|e[1]<<8|e[0],L=e[7]<<24|e[6]<<16|e[5]<<8|e[4],$=e[11]<<24|e[10]<<16|e[9]<<8|e[8],E=e[15]<<24|e[14]<<16|e[13]<<8|e[12],A=i,y=n,m=s,b=c,o=u,l=h,M=d,K=g,V=D,J=C,X=x,f=w,_=R,U=L,q=$,P=E,N=0;N<Tc;N+=2)A=A+o|0,_^=A,_=_>>>32-16|_<<16,V=V+_|0,o^=V,o=o>>>32-12|o<<12,y=y+l|0,U^=y,U=U>>>32-16|U<<16,J=J+U|0,l^=J,l=l>>>32-12|l<<12,m=m+M|0,q^=m,q=q>>>32-16|q<<16,X=X+q|0,M^=X,M=M>>>32-12|M<<12,b=b+K|0,P^=b,P=P>>>32-16|P<<16,f=f+P|0,K^=f,K=K>>>32-12|K<<12,m=m+M|0,q^=m,q=q>>>32-8|q<<8,X=X+q|0,M^=X,M=M>>>32-7|M<<7,b=b+K|0,P^=b,P=P>>>32-8|P<<8,f=f+P|0,K^=f,K=K>>>32-7|K<<7,y=y+l|0,U^=y,U=U>>>32-8|U<<8,J=J+U|0,l^=J,l=l>>>32-7|l<<7,A=A+o|0,_^=A,_=_>>>32-8|_<<8,V=V+_|0,o^=V,o=o>>>32-7|o<<7,A=A+l|0,P^=A,P=P>>>32-16|P<<16,X=X+P|0,l^=X,l=l>>>32-12|l<<12,y=y+M|0,_^=y,_=_>>>32-16|_<<16,f=f+_|0,M^=f,M=M>>>32-12|M<<12,m=m+K|0,U^=m,U=U>>>32-16|U<<16,V=V+U|0,K^=V,K=K>>>32-12|K<<12,b=b+o|0,q^=b,q=q>>>32-16|q<<16,J=J+q|0,o^=J,o=o>>>32-12|o<<12,m=m+K|0,U^=m,U=U>>>32-8|U<<8,V=V+U|0,K^=V,K=K>>>32-7|K<<7,b=b+o|0,q^=b,q=q>>>32-8|q<<8,J=J+q|0,o^=J,o=o>>>32-7|o<<7,y=y+M|0,_^=y,_=_>>>32-8|_<<8,f=f+_|0,M^=f,M=M>>>32-7|M<<7,A=A+l|0,P^=A,P=P>>>32-8|P<<8,X=X+P|0,l^=X,l=l>>>32-7|l<<7;st.writeUint32LE(A+i|0,t,0),st.writeUint32LE(y+n|0,t,4),st.writeUint32LE(m+s|0,t,8),st.writeUint32LE(b+c|0,t,12),st.writeUint32LE(o+u|0,t,16),st.writeUint32LE(l+h|0,t,20),st.writeUint32LE(M+d|0,t,24),st.writeUint32LE(K+g|0,t,28),st.writeUint32LE(V+D|0,t,32),st.writeUint32LE(J+C|0,t,36),st.writeUint32LE(X+x|0,t,40),st.writeUint32LE(f+w|0,t,44),st.writeUint32LE(_+R|0,t,48),st.writeUint32LE(U+L|0,t,52),st.writeUint32LE(q+$|0,t,56),st.writeUint32LE(P+E|0,t,60)}function ns(t,e,r,i,n){if(n===void 0&&(n=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,c;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),c=s.length-e.length,s.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,c=n}for(var u=new Uint8Array(64),h=0;h<r.length;h+=64){Cc(u,s,t);for(var d=h;d<h+64&&d<r.length;d++)i[d]=r[d]^u[d-h];Nc(s,0,c)}return Ni.wipe(u),n===0&&Ni.wipe(s),i}Vr.streamXOR=ns;function Lc(t,e,r,i){return i===void 0&&(i=0),Ni.wipe(r),ns(t,e,r,r,i)}Vr.stream=Lc;function Nc(t,e,r){for(var i=1;r--;)i=i+(t[e]&255)|0,t[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var ss={},Ht={};Object.defineProperty(Ht,"__esModule",{value:!0});function Pc(t,e,r){return~(t-1)&e|t-1&r}Ht.select=Pc;function Rc(t,e){return(t|0)-(e|0)-1>>>31&1}Ht.lessOrEqual=Rc;function os(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=os;function Fc(t,e){return t.length===0||e.length===0?!1:os(t,e)!==0}Ht.equal=Fc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ht,r=pt;t.DIGEST_LENGTH=16;var i=function(){function c(u){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=u[0]|u[1]<<8;this._r[0]=h&8191;var d=u[2]|u[3]<<8;this._r[1]=(h>>>13|d<<3)&8191;var g=u[4]|u[5]<<8;this._r[2]=(d>>>10|g<<6)&7939;var D=u[6]|u[7]<<8;this._r[3]=(g>>>7|D<<9)&8191;var C=u[8]|u[9]<<8;this._r[4]=(D>>>4|C<<12)&255,this._r[5]=C>>>1&8190;var x=u[10]|u[11]<<8;this._r[6]=(C>>>14|x<<2)&8191;var w=u[12]|u[13]<<8;this._r[7]=(x>>>11|w<<5)&8065;var R=u[14]|u[15]<<8;this._r[8]=(w>>>8|R<<8)&8191,this._r[9]=R>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return c.prototype._blocks=function(u,h,d){for(var g=this._fin?0:2048,D=this._h[0],C=this._h[1],x=this._h[2],w=this._h[3],R=this._h[4],L=this._h[5],$=this._h[6],E=this._h[7],A=this._h[8],y=this._h[9],m=this._r[0],b=this._r[1],o=this._r[2],l=this._r[3],M=this._r[4],K=this._r[5],V=this._r[6],J=this._r[7],X=this._r[8],f=this._r[9];d>=16;){var _=u[h+0]|u[h+1]<<8;D+=_&8191;var U=u[h+2]|u[h+3]<<8;C+=(_>>>13|U<<3)&8191;var q=u[h+4]|u[h+5]<<8;x+=(U>>>10|q<<6)&8191;var P=u[h+6]|u[h+7]<<8;w+=(q>>>7|P<<9)&8191;var N=u[h+8]|u[h+9]<<8;R+=(P>>>4|N<<12)&8191,L+=N>>>1&8191;var j=u[h+10]|u[h+11]<<8;$+=(N>>>14|j<<2)&8191;var B=u[h+12]|u[h+13]<<8;E+=(j>>>11|B<<5)&8191;var Q=u[h+14]|u[h+15]<<8;A+=(B>>>8|Q<<8)&8191,y+=Q>>>5|g;var H=0,ee=H;ee+=D*m,ee+=C*(5*f),ee+=x*(5*X),ee+=w*(5*J),ee+=R*(5*V),H=ee>>>13,ee&=8191,ee+=L*(5*K),ee+=$*(5*M),ee+=E*(5*l),ee+=A*(5*o),ee+=y*(5*b),H+=ee>>>13,ee&=8191;var k=H;k+=D*b,k+=C*m,k+=x*(5*f),k+=w*(5*X),k+=R*(5*J),H=k>>>13,k&=8191,k+=L*(5*V),k+=$*(5*K),k+=E*(5*M),k+=A*(5*l),k+=y*(5*o),H+=k>>>13,k&=8191;var ae=H;ae+=D*o,ae+=C*b,ae+=x*m,ae+=w*(5*f),ae+=R*(5*X),H=ae>>>13,ae&=8191,ae+=L*(5*J),ae+=$*(5*V),ae+=E*(5*K),ae+=A*(5*M),ae+=y*(5*l),H+=ae>>>13,ae&=8191;var T=H;T+=D*l,T+=C*o,T+=x*b,T+=w*m,T+=R*(5*f),H=T>>>13,T&=8191,T+=L*(5*X),T+=$*(5*J),T+=E*(5*V),T+=A*(5*K),T+=y*(5*M),H+=T>>>13,T&=8191;var I=H;I+=D*M,I+=C*l,I+=x*o,I+=w*b,I+=R*m,H=I>>>13,I&=8191,I+=L*(5*f),I+=$*(5*X),I+=E*(5*J),I+=A*(5*V),I+=y*(5*K),H+=I>>>13,I&=8191;var S=H;S+=D*K,S+=C*M,S+=x*l,S+=w*o,S+=R*b,H=S>>>13,S&=8191,S+=L*m,S+=$*(5*f),S+=E*(5*X),S+=A*(5*J),S+=y*(5*V),H+=S>>>13,S&=8191;var a=H;a+=D*V,a+=C*K,a+=x*M,a+=w*l,a+=R*o,H=a>>>13,a&=8191,a+=L*b,a+=$*m,a+=E*(5*f),a+=A*(5*X),a+=y*(5*J),H+=a>>>13,a&=8191;var v=H;v+=D*J,v+=C*V,v+=x*K,v+=w*M,v+=R*l,H=v>>>13,v&=8191,v+=L*o,v+=$*b,v+=E*m,v+=A*(5*f),v+=y*(5*X),H+=v>>>13,v&=8191;var z=H;z+=D*X,z+=C*J,z+=x*V,z+=w*K,z+=R*M,H=z>>>13,z&=8191,z+=L*l,z+=$*o,z+=E*b,z+=A*m,z+=y*(5*f),H+=z>>>13,z&=8191;var Y=H;Y+=D*f,Y+=C*X,Y+=x*J,Y+=w*V,Y+=R*K,H=Y>>>13,Y&=8191,Y+=L*M,Y+=$*l,Y+=E*o,Y+=A*b,Y+=y*m,H+=Y>>>13,Y&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,k+=H,D=ee,C=k,x=ae,w=T,R=I,L=S,$=a,E=v,A=z,y=Y,h+=16,d-=16}this._h[0]=D,this._h[1]=C,this._h[2]=x,this._h[3]=w,this._h[4]=R,this._h[5]=L,this._h[6]=$,this._h[7]=E,this._h[8]=A,this._h[9]=y},c.prototype.finish=function(u,h){h===void 0&&(h=0);var d=new Uint16Array(10),g,D,C,x;if(this._leftover){for(x=this._leftover,this._buffer[x++]=1;x<16;x++)this._buffer[x]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,x=2;x<10;x++)this._h[x]+=g,g=this._h[x]>>>13,this._h[x]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,d[0]=this._h[0]+5,g=d[0]>>>13,d[0]&=8191,x=1;x<10;x++)d[x]=this._h[x]+g,g=d[x]>>>13,d[x]&=8191;for(d[9]-=1<<13,D=(g^1)-1,x=0;x<10;x++)d[x]&=D;for(D=~D,x=0;x<10;x++)this._h[x]=this._h[x]&D|d[x];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,C=this._h[0]+this._pad[0],this._h[0]=C&65535,x=1;x<8;x++)C=(this._h[x]+this._pad[x]|0)+(C>>>16)|0,this._h[x]=C&65535;return u[h+0]=this._h[0]>>>0,u[h+1]=this._h[0]>>>8,u[h+2]=this._h[1]>>>0,u[h+3]=this._h[1]>>>8,u[h+4]=this._h[2]>>>0,u[h+5]=this._h[2]>>>8,u[h+6]=this._h[3]>>>0,u[h+7]=this._h[3]>>>8,u[h+8]=this._h[4]>>>0,u[h+9]=this._h[4]>>>8,u[h+10]=this._h[5]>>>0,u[h+11]=this._h[5]>>>8,u[h+12]=this._h[6]>>>0,u[h+13]=this._h[6]>>>8,u[h+14]=this._h[7]>>>0,u[h+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(u){var h=0,d=u.length,g;if(this._leftover){g=16-this._leftover,g>d&&(g=d);for(var D=0;D<g;D++)this._buffer[this._leftover+D]=u[h+D];if(d-=g,h+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(d>=16&&(g=d-d%16,this._blocks(u,h,g),h+=g,d-=g),d){for(var D=0;D<d;D++)this._buffer[this._leftover+D]=u[h+D];this._leftover+=d}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var u=new Uint8Array(16);return this.finish(u),u},c.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();t.Poly1305=i;function n(c,u){var h=new i(c);h.update(u);var d=h.digest();return h.clean(),d}t.oneTimeAuth=n;function s(c,u){return c.length!==t.DIGEST_LENGTH||u.length!==t.DIGEST_LENGTH?!1:e.equal(c,u)}t.equal=s}(ss),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vr,r=ss,i=pt,n=re,s=Ht;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function h(d){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,d.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(d)}return h.prototype.seal=function(d,g,D,C){if(d.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var x=new Uint8Array(16);x.set(d,x.length-d.length);var w=new Uint8Array(32);e.stream(this._key,x,w,4);var R=g.length+this.tagLength,L;if(C){if(C.length!==R)throw new Error("ChaCha20Poly1305: incorrect destination length");L=C}else L=new Uint8Array(R);return e.streamXOR(this._key,x,g,L,4),this._authenticate(L.subarray(L.length-this.tagLength,L.length),w,L.subarray(0,L.length-this.tagLength),D),i.wipe(x),L},h.prototype.open=function(d,g,D,C){if(d.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var x=new Uint8Array(16);x.set(d,x.length-d.length);var w=new Uint8Array(32);e.stream(this._key,x,w,4);var R=new Uint8Array(this.tagLength);if(this._authenticate(R,w,g.subarray(0,g.length-this.tagLength),D),!s.equal(R,g.subarray(g.length-this.tagLength,g.length)))return null;var L=g.length-this.tagLength,$;if(C){if(C.length!==L)throw new Error("ChaCha20Poly1305: incorrect destination length");$=C}else $=new Uint8Array(L);return e.streamXOR(this._key,x,g.subarray(0,g.length-this.tagLength),$,4),i.wipe(x),$},h.prototype.clean=function(){return i.wipe(this._key),this},h.prototype._authenticate=function(d,g,D,C){var x=new r.Poly1305(g);C&&(x.update(C),C.length%16>0&&x.update(c.subarray(C.length%16))),x.update(D),D.length%16>0&&x.update(c.subarray(D.length%16));var w=new Uint8Array(8);C&&n.writeUint64LE(C.length,w),x.update(w),n.writeUint64LE(D.length,w),x.update(w);for(var R=x.digest(),L=0;L<R.length;L++)d[L]=R[L];x.clean(),i.wipe(R),i.wipe(w)},h}();t.ChaCha20Poly1305=u}(Ai);var as={},br={},Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});function Uc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Pi.isSerializableHash=Uc,Object.defineProperty(br,"__esModule",{value:!0});var Ot=Pi,Mc=Ht,jc=pt,cs=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()),jc.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=cs;function $c(t,e,r){var i=new cs(t,e);i.update(r);var n=i.digest();return i.clean(),n}br.hmac=$c,br.equal=Mc.equal,Object.defineProperty(as,"__esModule",{value:!0});var us=br,hs=pt,Bc=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=us.hmac(this._hash,i,r);this._hmac=new us.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(),hs.wipe(this._buffer),hs.wipe(this._counter),this._bufpos=0},t}(),zc=as.HKDF=Bc,nr={},Ri={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});var fs=65536,Hc=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+=fs)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,fs)));return r},t}();Fi.BrowserRandomSource=Hc;function Kc(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={},qc={},Vc=Object.freeze({__proto__:null,default:qc}),Gc=bi(Vc);Object.defineProperty(Ui,"__esModule",{value:!0});var Wc=pt,kc=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Kc<"u"){var e=Gc;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 Wc.wipe(r),i},t}();Ui.NodeRandomSource=kc,Object.defineProperty(Ri,"__esModule",{value:!0});var Yc=Fi,Jc=Ui,Xc=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new Yc.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Jc.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=Xc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ri,r=re,i=pt;t.defaultRandomSource=new e.SystemRandomSource;function n(d,g){return g===void 0&&(g=t.defaultRandomSource),g.randomBytes(d)}t.randomBytes=n;function s(d){d===void 0&&(d=t.defaultRandomSource);var g=n(4,d),D=r.readUint32LE(g);return i.wipe(g),D}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function u(d,g,D){if(g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource),g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");for(var C="",x=g.length,w=256-256%x;d>0;){for(var R=n(Math.ceil(d*256/w),D),L=0;L<R.length&&d>0;L++){var $=R[L];$<w&&(C+=g.charAt($%x),d--)}i.wipe(R)}return C}t.randomString=u;function h(d,g,D){g===void 0&&(g=c),D===void 0&&(D=t.defaultRandomSource);var C=Math.ceil(d/(Math.log(g.length)/Math.LN2));return u(C,g,D)}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 u(){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 u.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},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},u.prototype.update=function(h,d){if(d===void 0&&(d=h.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=d,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&d>0;)this._buffer[this._bufferLength++]=h[g++],d--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(d>=this.blockSize&&(g=s(this._temp,this._state,h,g,d),d%=this.blockSize);d>0;)this._buffer[this._bufferLength++]=h[g++],d--;return this},u.prototype.finish=function(h){if(!this._finished){var d=this._bytesHashed,g=this._bufferLength,D=d/536870912|0,C=d<<3,x=d%64<56?64:128;this._buffer[g]=128;for(var w=g+1;w<x-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,x-8),e.writeUint32BE(C,this._buffer,x-4),s(this._temp,this._state,this._buffer,0,x),this._finished=!0}for(var w=0;w<this.digestLength/4;w++)e.writeUint32BE(this._state[w],h,w*4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.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}},u.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},u.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();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(u,h,d,g,D){for(;D>=64;){for(var C=h[0],x=h[1],w=h[2],R=h[3],L=h[4],$=h[5],E=h[6],A=h[7],y=0;y<16;y++){var m=g+y*4;u[y]=e.readUint32BE(d,m)}for(var y=16;y<64;y++){var b=u[y-2],o=(b>>>17|b<<32-17)^(b>>>19|b<<32-19)^b>>>10;b=u[y-15];var l=(b>>>7|b<<32-7)^(b>>>18|b<<32-18)^b>>>3;u[y]=(o+u[y-7]|0)+(l+u[y-16]|0)}for(var y=0;y<64;y++){var o=(((L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7))+(L&$^~L&E)|0)+(A+(n[y]+u[y]|0)|0)|0,l=((C>>>2|C<<32-2)^(C>>>13|C<<32-13)^(C>>>22|C<<32-22))+(C&x^C&w^x&w)|0;A=E,E=$,$=L,L=R+o|0,R=w,w=x,x=C,C=o+l|0}h[0]+=C,h[1]+=x,h[2]+=w,h[3]+=R,h[4]+=L,h[5]+=$,h[6]+=E,h[7]+=A,g+=64,D-=64}return g}function c(u){var h=new i;h.update(u);var d=h.digest();return h.clean(),d}t.hash=c})(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(y){var m=new Float64Array(16);if(y)for(var b=0;b<y.length;b++)m[b]=y[b];return m}var n=new Uint8Array(32);n[0]=9;var s=i([56129,1]);function c(y){for(var m=1,b=0;b<16;b++){var o=y[b]+m+65535;m=Math.floor(o/65536),y[b]=o-m*65536}y[0]+=m-1+37*(m-1)}function u(y,m,b){for(var o=~(b-1),l=0;l<16;l++){var M=o&(y[l]^m[l]);y[l]^=M,m[l]^=M}}function h(y,m){for(var b=i(),o=i(),l=0;l<16;l++)o[l]=m[l];c(o),c(o),c(o);for(var M=0;M<2;M++){b[0]=o[0]-65517;for(var l=1;l<15;l++)b[l]=o[l]-65535-(b[l-1]>>16&1),b[l-1]&=65535;b[15]=o[15]-32767-(b[14]>>16&1);var K=b[15]>>16&1;b[14]&=65535,u(o,b,1-K)}for(var l=0;l<16;l++)y[2*l]=o[l]&255,y[2*l+1]=o[l]>>8}function d(y,m){for(var b=0;b<16;b++)y[b]=m[2*b]+(m[2*b+1]<<8);y[15]&=32767}function g(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]+b[o]}function D(y,m,b){for(var o=0;o<16;o++)y[o]=m[o]-b[o]}function C(y,m,b){var o,l,M=0,K=0,V=0,J=0,X=0,f=0,_=0,U=0,q=0,P=0,N=0,j=0,B=0,Q=0,H=0,ee=0,k=0,ae=0,T=0,I=0,S=0,a=0,v=0,z=0,Y=0,fe=0,ye=0,de=0,me=0,Fe=0,Ce=0,ve=b[0],pe=b[1],le=b[2],ue=b[3],ce=b[4],oe=b[5],se=b[6],te=b[7],he=b[8],ge=b[9],ie=b[10],_e=b[11],be=b[12],Ee=b[13],De=b[14],we=b[15];o=m[0],M+=o*ve,K+=o*pe,V+=o*le,J+=o*ue,X+=o*ce,f+=o*oe,_+=o*se,U+=o*te,q+=o*he,P+=o*ge,N+=o*ie,j+=o*_e,B+=o*be,Q+=o*Ee,H+=o*De,ee+=o*we,o=m[1],K+=o*ve,V+=o*pe,J+=o*le,X+=o*ue,f+=o*ce,_+=o*oe,U+=o*se,q+=o*te,P+=o*he,N+=o*ge,j+=o*ie,B+=o*_e,Q+=o*be,H+=o*Ee,ee+=o*De,k+=o*we,o=m[2],V+=o*ve,J+=o*pe,X+=o*le,f+=o*ue,_+=o*ce,U+=o*oe,q+=o*se,P+=o*te,N+=o*he,j+=o*ge,B+=o*ie,Q+=o*_e,H+=o*be,ee+=o*Ee,k+=o*De,ae+=o*we,o=m[3],J+=o*ve,X+=o*pe,f+=o*le,_+=o*ue,U+=o*ce,q+=o*oe,P+=o*se,N+=o*te,j+=o*he,B+=o*ge,Q+=o*ie,H+=o*_e,ee+=o*be,k+=o*Ee,ae+=o*De,T+=o*we,o=m[4],X+=o*ve,f+=o*pe,_+=o*le,U+=o*ue,q+=o*ce,P+=o*oe,N+=o*se,j+=o*te,B+=o*he,Q+=o*ge,H+=o*ie,ee+=o*_e,k+=o*be,ae+=o*Ee,T+=o*De,I+=o*we,o=m[5],f+=o*ve,_+=o*pe,U+=o*le,q+=o*ue,P+=o*ce,N+=o*oe,j+=o*se,B+=o*te,Q+=o*he,H+=o*ge,ee+=o*ie,k+=o*_e,ae+=o*be,T+=o*Ee,I+=o*De,S+=o*we,o=m[6],_+=o*ve,U+=o*pe,q+=o*le,P+=o*ue,N+=o*ce,j+=o*oe,B+=o*se,Q+=o*te,H+=o*he,ee+=o*ge,k+=o*ie,ae+=o*_e,T+=o*be,I+=o*Ee,S+=o*De,a+=o*we,o=m[7],U+=o*ve,q+=o*pe,P+=o*le,N+=o*ue,j+=o*ce,B+=o*oe,Q+=o*se,H+=o*te,ee+=o*he,k+=o*ge,ae+=o*ie,T+=o*_e,I+=o*be,S+=o*Ee,a+=o*De,v+=o*we,o=m[8],q+=o*ve,P+=o*pe,N+=o*le,j+=o*ue,B+=o*ce,Q+=o*oe,H+=o*se,ee+=o*te,k+=o*he,ae+=o*ge,T+=o*ie,I+=o*_e,S+=o*be,a+=o*Ee,v+=o*De,z+=o*we,o=m[9],P+=o*ve,N+=o*pe,j+=o*le,B+=o*ue,Q+=o*ce,H+=o*oe,ee+=o*se,k+=o*te,ae+=o*he,T+=o*ge,I+=o*ie,S+=o*_e,a+=o*be,v+=o*Ee,z+=o*De,Y+=o*we,o=m[10],N+=o*ve,j+=o*pe,B+=o*le,Q+=o*ue,H+=o*ce,ee+=o*oe,k+=o*se,ae+=o*te,T+=o*he,I+=o*ge,S+=o*ie,a+=o*_e,v+=o*be,z+=o*Ee,Y+=o*De,fe+=o*we,o=m[11],j+=o*ve,B+=o*pe,Q+=o*le,H+=o*ue,ee+=o*ce,k+=o*oe,ae+=o*se,T+=o*te,I+=o*he,S+=o*ge,a+=o*ie,v+=o*_e,z+=o*be,Y+=o*Ee,fe+=o*De,ye+=o*we,o=m[12],B+=o*ve,Q+=o*pe,H+=o*le,ee+=o*ue,k+=o*ce,ae+=o*oe,T+=o*se,I+=o*te,S+=o*he,a+=o*ge,v+=o*ie,z+=o*_e,Y+=o*be,fe+=o*Ee,ye+=o*De,de+=o*we,o=m[13],Q+=o*ve,H+=o*pe,ee+=o*le,k+=o*ue,ae+=o*ce,T+=o*oe,I+=o*se,S+=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=m[14],H+=o*ve,ee+=o*pe,k+=o*le,ae+=o*ue,T+=o*ce,I+=o*oe,S+=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=m[15],ee+=o*ve,k+=o*pe,ae+=o*le,T+=o*ue,I+=o*ce,S+=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,Ce+=o*we,M+=38*k,K+=38*ae,V+=38*T,J+=38*I,X+=38*S,f+=38*a,_+=38*v,U+=38*z,q+=38*Y,P+=38*fe,N+=38*ye,j+=38*de,B+=38*me,Q+=38*Fe,H+=38*Ce,l=1,o=M+l+65535,l=Math.floor(o/65536),M=o-l*65536,o=K+l+65535,l=Math.floor(o/65536),K=o-l*65536,o=V+l+65535,l=Math.floor(o/65536),V=o-l*65536,o=J+l+65535,l=Math.floor(o/65536),J=o-l*65536,o=X+l+65535,l=Math.floor(o/65536),X=o-l*65536,o=f+l+65535,l=Math.floor(o/65536),f=o-l*65536,o=_+l+65535,l=Math.floor(o/65536),_=o-l*65536,o=U+l+65535,l=Math.floor(o/65536),U=o-l*65536,o=q+l+65535,l=Math.floor(o/65536),q=o-l*65536,o=P+l+65535,l=Math.floor(o/65536),P=o-l*65536,o=N+l+65535,l=Math.floor(o/65536),N=o-l*65536,o=j+l+65535,l=Math.floor(o/65536),j=o-l*65536,o=B+l+65535,l=Math.floor(o/65536),B=o-l*65536,o=Q+l+65535,l=Math.floor(o/65536),Q=o-l*65536,o=H+l+65535,l=Math.floor(o/65536),H=o-l*65536,o=ee+l+65535,l=Math.floor(o/65536),ee=o-l*65536,M+=l-1+37*(l-1),l=1,o=M+l+65535,l=Math.floor(o/65536),M=o-l*65536,o=K+l+65535,l=Math.floor(o/65536),K=o-l*65536,o=V+l+65535,l=Math.floor(o/65536),V=o-l*65536,o=J+l+65535,l=Math.floor(o/65536),J=o-l*65536,o=X+l+65535,l=Math.floor(o/65536),X=o-l*65536,o=f+l+65535,l=Math.floor(o/65536),f=o-l*65536,o=_+l+65535,l=Math.floor(o/65536),_=o-l*65536,o=U+l+65535,l=Math.floor(o/65536),U=o-l*65536,o=q+l+65535,l=Math.floor(o/65536),q=o-l*65536,o=P+l+65535,l=Math.floor(o/65536),P=o-l*65536,o=N+l+65535,l=Math.floor(o/65536),N=o-l*65536,o=j+l+65535,l=Math.floor(o/65536),j=o-l*65536,o=B+l+65535,l=Math.floor(o/65536),B=o-l*65536,o=Q+l+65535,l=Math.floor(o/65536),Q=o-l*65536,o=H+l+65535,l=Math.floor(o/65536),H=o-l*65536,o=ee+l+65535,l=Math.floor(o/65536),ee=o-l*65536,M+=l-1+37*(l-1),y[0]=M,y[1]=K,y[2]=V,y[3]=J,y[4]=X,y[5]=f,y[6]=_,y[7]=U,y[8]=q,y[9]=P,y[10]=N,y[11]=j,y[12]=B,y[13]=Q,y[14]=H,y[15]=ee}function x(y,m){C(y,m,m)}function w(y,m){for(var b=i(),o=0;o<16;o++)b[o]=m[o];for(var o=253;o>=0;o--)x(b,b),o!==2&&o!==4&&C(b,b,m);for(var o=0;o<16;o++)y[o]=b[o]}function R(y,m){for(var b=new Uint8Array(32),o=new Float64Array(80),l=i(),M=i(),K=i(),V=i(),J=i(),X=i(),f=0;f<31;f++)b[f]=y[f];b[31]=y[31]&127|64,b[0]&=248,d(o,m);for(var f=0;f<16;f++)M[f]=o[f];l[0]=V[0]=1;for(var f=254;f>=0;--f){var _=b[f>>>3]>>>(f&7)&1;u(l,M,_),u(K,V,_),g(J,l,K),D(l,l,K),g(K,M,V),D(M,M,V),x(V,J),x(X,l),C(l,K,l),C(K,M,J),g(J,l,K),D(l,l,K),x(M,l),D(K,V,X),C(l,K,s),g(l,l,V),C(K,K,l),C(l,V,X),C(V,M,o),x(M,J),u(l,M,_),u(K,V,_)}for(var f=0;f<16;f++)o[f+16]=l[f],o[f+32]=K[f],o[f+48]=M[f],o[f+64]=V[f];var U=o.subarray(32),q=o.subarray(16);w(U,U),C(q,q,U);var P=new Uint8Array(32);return h(P,q),P}t.scalarMult=R;function L(y){return R(y,n)}t.scalarMultBase=L;function $(y){if(y.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var m=new Uint8Array(y),b=L(m);return{publicKey:b,secretKey:m}}t.generateKeyPairFromSeed=$;function E(y){var m=e.randomBytes(32,y),b=$(m);return r.wipe(m),b}t.generateKeyPair=E;function A(y,m,b){if(b===void 0&&(b=!1),y.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(m.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=R(y,m);if(b){for(var l=0,M=0;M<o.length;M++)l|=o[M];if(l===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=A})(Mi);function ls(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ji(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=ls(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function Zc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=n}var u=t.length,h=t.charAt(0),d=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var R=0,L=0,$=0,E=w.length;$!==E&&w[$]===0;)$++,R++;for(var A=(E-$)*g+1>>>0,y=new Uint8Array(A);$!==E;){for(var m=w[$],b=0,o=A-1;(m!==0||b<L)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%u>>>0,m=m/u>>>0;if(m!==0)throw new Error("Non-zero carry");L=b,$++}for(var l=A-L;l!==A&&y[l]===0;)l++;for(var M=h.repeat(R);l<A;++l)M+=t.charAt(y[l]);return M}function C(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var R=0;if(w[R]!==" "){for(var L=0,$=0;w[R]===h;)L++,R++;for(var E=(w.length-R)*d+1>>>0,A=new Uint8Array(E);w[R];){var y=r[w.charCodeAt(R)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<$)&&b!==-1;b--,m++)y+=u*A[b]>>>0,A[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");$=m,R++}if(w[R]!==" "){for(var o=E-$;o!==E&&A[o]===0;)o++;for(var l=new Uint8Array(L+(E-o)),M=L;o!==E;)l[M++]=A[o++];return l}}}function x(w){var R=C(w);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:x}}var Qc=Zc,eu=Qc;const ds=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")},tu=t=>new TextEncoder().encode(t),ru=t=>new TextDecoder().decode(t);class iu{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 nu{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 ps(this,e)}}class su{constructor(e){this.decoders=e}or(e){return ps(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 ps=(t,e)=>new su({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class ou{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new iu(e,r,i),this.decoder=new nu(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 ou(t,e,r,i),mr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=eu(r,e);return Yr({prefix:t,name:e,encode:i,decode:s=>ds(n(s))})},au=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,d=0;for(let g=0;g<s;++g){const D=n[t[g]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<r|D,u+=r,u>=8&&(u-=8,c[d++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},cu=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[n&u>>c];if(c&&(s+=e[n&u<<r-c]),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 cu(n,i,r)},decode(n){return au(n,i,r,t)}}),uu=Yr({prefix:"\0",name:"identity",encode:t=>ru(t),decode:t=>tu(t)});var hu=Object.freeze({__proto__:null,identity:uu});const fu=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lu=Object.freeze({__proto__:null,base2:fu});const du=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var pu=Object.freeze({__proto__:null,base8:du});const gu=mr({prefix:"9",name:"base10",alphabet:"0123456789"});var vu=Object.freeze({__proto__:null,base10:gu});const yu=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_u=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bu=Object.freeze({__proto__:null,base16:yu,base16upper:_u});const mu=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Eu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Du=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Su=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ou=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Au=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Iu=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tu=Object.freeze({__proto__:null,base32:mu,base32upper:wu,base32pad:Eu,base32padupper:Du,base32hex:xu,base32hexupper:Su,base32hexpad:Ou,base32hexpadupper:Au,base32z:Iu});const Cu=mr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lu=mr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nu=Object.freeze({__proto__:null,base36:Cu,base36upper:Lu});const Pu=mr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ru=mr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Fu=Object.freeze({__proto__:null,base58btc:Pu,base58flickr:Ru});const Uu=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ju=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$u=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Bu=Object.freeze({__proto__:null,base64:Uu,base64pad:Mu,base64url:ju,base64urlpad:$u});const gs=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}"),zu=gs.reduce((t,e,r)=>(t[r]=e,t),[]),Hu=gs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ku(t){return t.reduce((e,r)=>(e+=zu[r],e),"")}function qu(t){const e=[];for(const r of t){const i=Hu[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Vu=Yr({prefix:"\u{1F680}",name:"base256emoji",encode:Ku,decode:qu});var Gu=Object.freeze({__proto__:null,base256emoji:Vu}),Wu=ys,vs=128,ku=127,Yu=~ku,Ju=Math.pow(2,31);function ys(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Ju;)e[r++]=t&255|vs,t/=128;for(;t&Yu;)e[r++]=t&255|vs,t>>>=7;return e[r]=t|0,ys.bytes=r-i+1,e}var Xu=$i,Zu=128,_s=127;function $i(t,i){var r=0,i=i||0,n=0,s=i,c,u=t.length;do{if(s>=u)throw $i.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&_s)<<n:(c&_s)*Math.pow(2,n),n+=7}while(c>=Zu);return $i.bytes=s-i,r}var Qu=Math.pow(2,7),eh=Math.pow(2,14),th=Math.pow(2,21),rh=Math.pow(2,28),ih=Math.pow(2,35),nh=Math.pow(2,42),sh=Math.pow(2,49),oh=Math.pow(2,56),ah=Math.pow(2,63),ch=function(t){return t<Qu?1:t<eh?2:t<th?3:t<rh?4:t<ih?5:t<nh?6:t<sh?7:t<oh?8:t<ah?9:10},uh={encode:Wu,decode:Xu,encodingLength:ch},bs=uh;const ms=(t,e,r=0)=>(bs.encode(t,e,r),e),ws=t=>bs.encodingLength(t),Bi=(t,e)=>{const r=e.byteLength,i=ws(t),n=i+ws(r),s=new Uint8Array(n+r);return ms(t,s,0),ms(r,s,i),s.set(e,n),new hh(t,r,e,s)};class hh{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Es=({name:t,code:e,encode:r})=>new fh(t,e,r);class fh{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 Ds=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),lh=Es({name:"sha2-256",code:18,encode:Ds("SHA-256")}),dh=Es({name:"sha2-512",code:19,encode:Ds("SHA-512")});var ph=Object.freeze({__proto__:null,sha256:lh,sha512:dh});const xs=0,gh="identity",Ss=ds;var vh=Object.freeze({__proto__:null,identity:{code:xs,name:gh,encode:Ss,digest:t=>Bi(xs,Ss(t))}});new TextEncoder,new TextDecoder;const Os={...hu,...lu,...pu,...vu,...bu,...Tu,...Nu,...Fu,...Bu,...Gu};({...ph,...vh});function As(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Is=As("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),zi=As("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=ls(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ts={utf8:Is,"utf-8":Is,hex:Os.base16,latin1:zi,ascii:zi,binary:zi,...Os};function ht(t,e="utf8"){const r=Ts[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function ft(t,e="utf8"){const r=Ts[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Cs=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))},yh=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),_h=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),bh=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}(),mh=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),wh=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Eh=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Dh=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ls=3,xh=[["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",Eh]],Ns=[["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 Sh(t){return t?Ps(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new wh:typeof navigator<"u"?Ps(navigator.userAgent):Ih()}function Oh(t){return t!==""&&xh.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 Ps(t){var e=Oh(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new mh;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Ls&&(n=Cs(Cs([],n,!0),Th(Ls-n.length),!0)):n=[];var s=n.join("."),c=Ah(t),u=Dh.exec(t);return u&&u[1]?new bh(r,s,c,u[1]):new yh(r,s,c)}function Ah(t){for(var e=0,r=Ns.length;e<r;e++){var i=Ns[e],n=i[0],s=i[1],c=s.exec(t);if(c)return n}return null}function Ih(){var t=typeof process<"u"&&process.version;return t?new _h(process.version.slice(1)):null}function Th(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Ie={},Rs={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.delay=void 0;function Ch(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Jr.delay=Ch;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 Fs={};(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})(Fs),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(or,t),r(Fs,t)}(Hi),Object.defineProperty(sr,"__esModule",{value:!0}),sr.fromMiliseconds=sr.toMiliseconds=void 0;const Us=Hi;function Lh(t){return t*Us.ONE_THOUSAND}sr.toMiliseconds=Lh;function Nh(t){return Math.floor(t/Us.ONE_THOUSAND)}sr.fromMiliseconds=Nh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Jr,t),r(sr,t)}(Rs);var wr={};Object.defineProperty(wr,"__esModule",{value:!0}),wr.Watch=void 0;class Ms{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=Ms,wr.default=Ms;var js={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.IWatch=void 0;class Ph{}Xr.IWatch=Ph,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xr,t)}(js),function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Rs,t),r(wr,t),r(js,t),r(Hi,t)}(Ie);var xe={};Object.defineProperty(xe,"__esModule",{value:!0}),xe.getLocalStorage=xe.getLocalStorageOrThrow=xe.getCrypto=xe.getCryptoOrThrow=Bs=xe.getLocation=xe.getLocationOrThrow=Ki=xe.getNavigator=xe.getNavigatorOrThrow=$s=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 Rh(){return ar("document")}xe.getDocumentOrThrow=Rh;function Fh(){return kt("document")}var $s=xe.getDocument=Fh;function Uh(){return ar("navigator")}xe.getNavigatorOrThrow=Uh;function Mh(){return kt("navigator")}var Ki=xe.getNavigator=Mh;function jh(){return ar("location")}xe.getLocationOrThrow=jh;function $h(){return kt("location")}var Bs=xe.getLocation=$h;function Bh(){return ar("crypto")}xe.getCryptoOrThrow=Bh;function zh(){return kt("crypto")}xe.getCrypto=zh;function Hh(){return ar("localStorage")}xe.getLocalStorageOrThrow=Hh;function Kh(){return kt("localStorage")}xe.getLocalStorage=Kh;var qi={};Object.defineProperty(qi,"__esModule",{value:!0});var zs=qi.getWindowMetadata=void 0;const Hs=xe;function qh(){let t,e;try{t=Hs.getDocumentOrThrow(),e=Hs.getLocationOrThrow()}catch{return null}function r(){const D=t.getElementsByTagName("link"),C=[];for(let x=0;x<D.length;x++){const w=D[x],R=w.getAttribute("rel");if(R&&R.toLowerCase().indexOf("icon")>-1){const L=w.getAttribute("href");if(L)if(L.toLowerCase().indexOf("https:")===-1&&L.toLowerCase().indexOf("http:")===-1&&L.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(L.indexOf("/")===0)$+=L;else{const E=e.pathname.split("/");E.pop(),$+=E.join("/")+"/"+L}C.push($)}else if(L.indexOf("//")===0){const $=e.protocol+L;C.push($)}else C.push(L)}}return C}function i(...D){const C=t.getElementsByTagName("meta");for(let x=0;x<C.length;x++){const w=C[x],R=["itemprop","property","name"].map(L=>w.getAttribute(L)).filter(L=>L?D.includes(L):!1);if(R.length&&R){const L=w.getAttribute("content");if(L)return L}}return""}function n(){let D=i("name","og:site_name","og:title","twitter:title");return D||(D=t.title),D}function s(){return i("description","og:description","twitter:description","keywords")}const c=n(),u=s(),h=e.origin,d=r();return{description:u,url:h,icons:d,name:c}}zs=qi.getWindowMetadata=qh;var Er={},Vh=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ks="%[a-f0-9]{2}",qs=new RegExp(Ks,"gi"),Vs=new RegExp("("+Ks+")+","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 Gh(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(qs),r=1;r<e.length;r++)t=Vi(e,r).join(""),e=t.match(qs);return t}}function Wh(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Vs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=Gh(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Vs.exec(t)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var c=n[s];t=t.replace(new RegExp(c,"g"),e[c])}return t}var kh=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 Wh(t)}},Yh=(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)]},Jh=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var c=i[s],u=t[c];(n?e.indexOf(c)!==-1:e(c,u,t))&&(r[c]=u)}return r};(function(t){const e=Vh,r=kh,i=Yh,n=Jh,s=E=>E==null,c=Symbol("encodeFragmentIdentifier");function u(E){switch(E.arrayFormat){case"index":return A=>(y,m)=>{const b=y.length;return m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),"[",b,"]"].join("")]:[...y,[g(A,E),"[",g(b,E),"]=",g(m,E)].join("")]};case"bracket":return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),"[]"].join("")]:[...y,[g(A,E),"[]=",g(m,E)].join("")];case"colon-list-separator":return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,[g(A,E),":list="].join("")]:[...y,[g(A,E),":list=",g(m,E)].join("")];case"comma":case"separator":case"bracket-separator":{const A=E.arrayFormat==="bracket-separator"?"[]=":"=";return y=>(m,b)=>b===void 0||E.skipNull&&b===null||E.skipEmptyString&&b===""?m:(b=b===null?"":b,m.length===0?[[g(y,E),A,g(b,E)].join("")]:[[m,g(b,E)].join(E.arrayFormatSeparator)])}default:return A=>(y,m)=>m===void 0||E.skipNull&&m===null||E.skipEmptyString&&m===""?y:m===null?[...y,g(A,E)]:[...y,[g(A,E),"=",g(m,E)].join("")]}}function h(E){let A;switch(E.arrayFormat){case"index":return(y,m,b)=>{if(A=/\[(\d*)\]$/.exec(y),y=y.replace(/\[\d*\]$/,""),!A){b[y]=m;return}b[y]===void 0&&(b[y]={}),b[y][A[1]]=m};case"bracket":return(y,m,b)=>{if(A=/(\[\])$/.exec(y),y=y.replace(/\[\]$/,""),!A){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"colon-list-separator":return(y,m,b)=>{if(A=/(:list)$/.exec(y),y=y.replace(/:list$/,""),!A){b[y]=m;return}if(b[y]===void 0){b[y]=[m];return}b[y]=[].concat(b[y],m)};case"comma":case"separator":return(y,m,b)=>{const o=typeof m=="string"&&m.includes(E.arrayFormatSeparator),l=typeof m=="string"&&!o&&D(m,E).includes(E.arrayFormatSeparator);m=l?D(m,E):m;const M=o||l?m.split(E.arrayFormatSeparator).map(K=>D(K,E)):m===null?m:D(m,E);b[y]=M};case"bracket-separator":return(y,m,b)=>{const o=/(\[\])$/.test(y);if(y=y.replace(/\[\]$/,""),!o){b[y]=m&&D(m,E);return}const l=m===null?[]:m.split(E.arrayFormatSeparator).map(M=>D(M,E));if(b[y]===void 0){b[y]=l;return}b[y]=[].concat(b[y],l)};default:return(y,m,b)=>{if(b[y]===void 0){b[y]=m;return}b[y]=[].concat(b[y],m)}}}function d(E){if(typeof E!="string"||E.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(E,A){return A.encode?A.strict?e(E):encodeURIComponent(E):E}function D(E,A){return A.decode?r(E):E}function C(E){return Array.isArray(E)?E.sort():typeof E=="object"?C(Object.keys(E)).sort((A,y)=>Number(A)-Number(y)).map(A=>E[A]):E}function x(E){const A=E.indexOf("#");return A!==-1&&(E=E.slice(0,A)),E}function w(E){let A="";const y=E.indexOf("#");return y!==-1&&(A=E.slice(y)),A}function R(E){E=x(E);const A=E.indexOf("?");return A===-1?"":E.slice(A+1)}function L(E,A){return A.parseNumbers&&!Number.isNaN(Number(E))&&typeof E=="string"&&E.trim()!==""?E=Number(E):A.parseBooleans&&E!==null&&(E.toLowerCase()==="true"||E.toLowerCase()==="false")&&(E=E.toLowerCase()==="true"),E}function $(E,A){A=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},A),d(A.arrayFormatSeparator);const y=h(A),m=Object.create(null);if(typeof E!="string"||(E=E.trim().replace(/^[?#&]/,""),!E))return m;for(const b of E.split("&")){if(b==="")continue;let[o,l]=i(A.decode?b.replace(/\+/g," "):b,"=");l=l===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?l:D(l,A),y(D(o,A),l,m)}for(const b of Object.keys(m)){const o=m[b];if(typeof o=="object"&&o!==null)for(const l of Object.keys(o))o[l]=L(o[l],A);else m[b]=L(o,A)}return A.sort===!1?m:(A.sort===!0?Object.keys(m).sort():Object.keys(m).sort(A.sort)).reduce((b,o)=>{const l=m[o];return Boolean(l)&&typeof l=="object"&&!Array.isArray(l)?b[o]=C(l):b[o]=l,b},Object.create(null))}t.extract=R,t.parse=$,t.stringify=(E,A)=>{if(!E)return"";A=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},A),d(A.arrayFormatSeparator);const y=l=>A.skipNull&&s(E[l])||A.skipEmptyString&&E[l]==="",m=u(A),b={};for(const l of Object.keys(E))y(l)||(b[l]=E[l]);const o=Object.keys(b);return A.sort!==!1&&o.sort(A.sort),o.map(l=>{const M=E[l];return M===void 0?"":M===null?g(l,A):Array.isArray(M)?M.length===0&&A.arrayFormat==="bracket-separator"?g(l,A)+"[]":M.reduce(m(l),[]).join("&"):g(l,A)+"="+g(M,A)}).filter(l=>l.length>0).join("&")},t.parseUrl=(E,A)=>{A=Object.assign({decode:!0},A);const[y,m]=i(E,"#");return Object.assign({url:y.split("?")[0]||"",query:$(R(E),A)},A&&A.parseFragmentIdentifier&&m?{fragmentIdentifier:D(m,A)}:{})},t.stringifyUrl=(E,A)=>{A=Object.assign({encode:!0,strict:!0,[c]:!0},A);const y=x(E.url).split("?")[0]||"",m=t.extract(E.url),b=t.parse(m,{sort:!1}),o=Object.assign(b,E.query);let l=t.stringify(o,A);l&&(l=`?${l}`);let M=w(E.url);return E.fragmentIdentifier&&(M=`#${A[c]?g(E.fragmentIdentifier,A):E.fragmentIdentifier}`),`${y}${l}${M}`},t.pick=(E,A,y)=>{y=Object.assign({parseFragmentIdentifier:!0,[c]:!1},y);const{url:m,query:b,fragmentIdentifier:o}=t.parseUrl(E,y);return t.stringifyUrl({url:m,query:n(b,A),fragmentIdentifier:o},y)},t.exclude=(E,A,y)=>{const m=Array.isArray(A)?b=>!A.includes(b):(b,o)=>!A(b,o);return t.pick(E,m,y)}})(Er);const Xh={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Gs=":";function Zh(t){const{namespace:e,reference:r}=t;return[e,r].join(Gs)}function Qh(t){const[e,r,i]=t.split(Gs);return{namespace:e,reference:r,address:i}}function ef(t,e){const r=[];return t.forEach(i=>{const n=e(i);r.includes(n)||r.push(n)}),r}function tf(t){const{namespace:e,reference:r}=Qh(t);return Zh({namespace:e,reference:r})}function rf(t){return ef(t,tf)}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(...rf(n.accounts))}),r}function nf(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 Ws="base10",lt="base16",ki="base64pad",Yi="utf8",ks=0,Dr=1,sf=0,Ys=1,Ji=12,Xi=32;function of(){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 af(t,e){const r=Mi.sharedKey(ht(t,lt),ht(e,lt)),i=new zc(kr.SHA256,r).expand(Xi);return ft(i,lt)}function cf(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 uf(t){return ht(`${t}`,Ws)}function Qr(t){return Number(ft(t,Ws))}function hf(t){const e=uf(typeof t.type<"u"?t.type:ks);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 lf({type:e,sealed:n,iv:i,senderPublicKey:r})}function ff(t){const e=new Ai.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:i}=Js(t.encoded),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return ft(n,Yi)}function lf(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 Js(t){const e=ht(t,ki),r=e.slice(sf,Ys),i=Ys;if(Qr(r)===Dr){const u=i+Xi,h=u+Ji,d=e.slice(i,u),g=e.slice(u,h),D=e.slice(h);return{type:r,sealed:D,iv:g,senderPublicKey:d}}const n=i+Ji,s=e.slice(i,n),c=e.slice(n);return{type:r,sealed:c,iv:s}}function df(t,e){const r=Js(t);return Xs({type:Qr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Xs(t){const e=t?.type||ks;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 Zs(t){return t.type===Dr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var pf=Object.defineProperty,Qs=Object.getOwnPropertySymbols,gf=Object.prototype.hasOwnProperty,vf=Object.prototype.propertyIsEnumerable,eo=(t,e,r)=>e in t?pf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,to=(t,e)=>{for(var r in e||(e={}))gf.call(e,r)&&eo(t,r,e[r]);if(Qs)for(var r of Qs(e))vf.call(e,r)&&eo(t,r,e[r]);return t};const yf="ReactNative",xr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},_f="js";function ro(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function bf(){return!$s()&&!!Ki()&&navigator.product===yf}function mf(){return!ro()&&!!Ki()}function wf(){return bf()?xr.reactNative:ro()?xr.node:mf()?xr.browser:xr.unknown}function Ef(t,e){let r=Er.parse(t);return r=to(to({},r),e),t=Er.stringify(r),t}function Df(){return zs()||{name:"",description:"",url:"",icons:[""]}}function xf(){const t=Sh();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 Sf(){var t;const e=wf();return e===xr.browser?[e,((t=Bs())==null?void 0:t.host)||"unknown"].join(":"):e}function Of(t,e,r){const i=xf(),n=Sf();return[[t,e].join("-"),[_f,r].join("-"),i,n].join("/")}function Af({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s}){const c=r.split("?"),u=Of(t,e,i),h={auth:n,ua:u,projectId:s},d=Ef(c[1]||"",h);return c[0]+"?"+d}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function io(t){return Object.fromEntries(t.entries())}function no(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 so(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 If(t){return so("topic",t)}function Tf(t){return so("id",t)}function Cf(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 Lf="irn";function Qi(t){return t?.relay||{protocol:Lf}}function en(t){const e=Xh[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Nf=Object.defineProperty,oo=Object.getOwnPropertySymbols,Pf=Object.prototype.hasOwnProperty,Rf=Object.prototype.propertyIsEnumerable,ao=(t,e,r)=>e in t?Nf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ff=(t,e)=>{for(var r in e||(e={}))Pf.call(e,r)&&ao(t,r,e[r]);if(oo)for(var r of oo(e))Rf.call(e,r)&&ao(t,r,e[r]);return t};function Uf(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),c=t[n];r[s]=c}}),r}function Mf(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",c=Er.parse(s);return{protocol:i,topic:n[0],version:parseInt(n[1],10),symKey:c.symKey,relay:Uf(c)}}function jf(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 $f(t){return`${t.protocol}:${t.topic}@${t.version}?`+Er.stringify(Ff({symKey:t.symKey},jf(t.relay)))}function At(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Bf(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 zf(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 Hf(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 Kf={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3}},qf={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}=qf[t];return{message:e?`${r} ${e}`:r,code:i}}function rt(t,e){const{message:r,code:i}=Kf[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 co(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 uo(t,e){return e&&Et(t)?!0:typeof t=="number"&&!isNaN(t)}function Vf(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return dt(n,i)?(i.forEach(c=>{const{accounts:u,methods:h,events:d,extension:g}=t.namespaces[c],D=At(u),C=r[c];(!dt(C.chains,D)||!dt(C.methods,h)||!dt(C.events,d))&&(s=!1),s&&g&&g.forEach(x=>{var w;const{accounts:R,methods:L,events:$}=x,E=At(R);(w=C.extension)!=null&&w.find(A=>dt(A.chains,E)&&dt(A.methods,L)&&dt(A.events,$))||(s=!1)})}),s):!1}function tn(t){return ot(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Gf(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 Wf(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 Yf(t){return t?.topic}function Jf(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 ho(t){let e=!0;return Sr(t)?t.length&&(e=t.every(r=>ot(r,!1))):e=!1,e}function fo(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 Xf(t,e){let r=null;return Object.entries(t).forEach(([i,n])=>{if(r)return;const s=fo(i,n?.chains,`${e} requiredNamespace`),c=rn(n,e);s?r=s:c?r=c:n.extension&&n.extension.forEach(u=>{if(r)return;const h=fo(i,u.chains,`${e} extension`);h&&(r=h)})}),r}function lo(t,e){let r=null;return Sr(t)?t.forEach(i=>{r||Gf(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 Zf(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=lo(i?.accounts,`${e} namespace`),s=rn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const u=lo(c.accounts,`${e} extension`);u&&(r=u)})}),r}function po(t,e){let r=null;return ho(t?.methods)?ho(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 go(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=po(i,`${e}, namespace`),s=rn(i,e);n?r=n:s?r=s:i.extension&&i.extension.forEach(c=>{if(r)return;const u=po(c,`${e}, extension`);u&&(r=u)})}),r}function Qf(t,e){let r=null;if(t&&co(t)){const i=go(t,e);i&&(r=i);const n=Xf(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&&co(t)){const i=go(t,e);i&&(r=i);const n=Zf(t,e);n&&(r=n)}else r=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function vo(t){return ot(t.protocol,!0)}function el(t,e){let r=!1;return e&&!t?r=!0:t&&Sr(t)&&t.length&&t.forEach(i=>{r=vo(i)}),r}function tl(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function rl(t){return!(!t||typeof t!="object"||!t.code||!uo(t.code,!1)||!t.message||!ot(t.message,!1))}function il(t){return!(Et(t)||!ot(t.method,!1))}function nl(t){return!(Et(t)||Et(t.result)&&Et(t.error)||!uo(t.id,!1)||!ot(t.jsonrpc,!1))}function sl(t){return!(Et(t)||!ot(t.name,!1))}function yo(t,e){return!(!tn(e)||!Bf(t).includes(e))}function ol(t,e,r){return ot(r,!1)?zf(t,e).includes(r):!1}function al(t,e,r){return ot(r,!1)?Hf(t,e).includes(r):!1}function _o(t,e,r){let i=null;const n=Object.keys(t),s=Object.keys(e);return dt(n,s)?n.forEach(c=>{var u;if(i)return;const h=t[c].chains,d=At(e[c].accounts);dt(h,d)?dt(t[c].methods,e[c].methods)?dt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`):t[c].extension&&e[c].extension&&((u=t[c].extension)==null||u.forEach(({methods:g,events:D,chains:C})=>{var x;i||(x=e[c].extension)!=null&&x.find(w=>{const R=At(w.accounts);return dt(C,R)&&dt(D,w.events)&&dt(g,w.methods)})||(i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):i=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),i}function cl(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var ul=hl;function hl(t,e,r){var i=r&&r.stringify||cl,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var c=new Array(s);c[0]=i(t);for(var u=1;u<s;u++)c[u]=i(e[u]);return c.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var d="",g=1-n,D=-1,C=t&&t.length||0,x=0;x<C;){if(t.charCodeAt(x)===37&&x+1<C){switch(D=D>-1?D:0,t.charCodeAt(x+1)){case 100:case 102:if(g>=h||e[g]==null)break;D<x&&(d+=t.slice(D,x)),d+=Number(e[g]),D=x+2,x++;break;case 105:if(g>=h||e[g]==null)break;D<x&&(d+=t.slice(D,x)),d+=Math.floor(Number(e[g])),D=x+2,x++;break;case 79:case 111:case 106:if(g>=h||e[g]===void 0)break;D<x&&(d+=t.slice(D,x));var w=typeof e[g];if(w==="string"){d+="'"+e[g]+"'",D=x+2,x++;break}if(w==="function"){d+=e[g].name||"<anonymous>",D=x+2,x++;break}d+=i(e[g]),D=x+2,x++;break;case 115:if(g>=h)break;D<x&&(d+=t.slice(D,x)),d+=String(e[g]),D=x+2,x++;break;case 37:D<x&&(d+=t.slice(D,x)),d+="%",D=x+2,x++,g--;break}++g}++x}return D===-1?t:(D<C&&(d+=t.slice(D)),d)}var bo=ul,sn=It,Or=bl().console||{},fl={mapHttpRequest:ti,mapHttpResponse:ti,wrapRequestSerializer:an,wrapResponseSerializer:an,wrapErrorSerializer:an,req:ti,res:ti,err:gl};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(w){return w!=="!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 c=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");var u=t.level||"info",h=Object.create(r);h.log||(h.log=Ar),Object.defineProperty(h,"levelVal",{get:g}),Object.defineProperty(h,"level",{get:D,set:C});var d={transmit:e,serialize:n,asObject:t.browser.asObject,levels:c,timestamp:vl(t)};h.levels=It.levels,h.level=u,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=x,e&&(h._logEvent=on());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function D(){return this._level}function C(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,ur(d,h,"error","log"),ur(d,h,"fatal","error"),ur(d,h,"warn","error"),ur(d,h,"info","log"),ur(d,h,"debug","log"),ur(d,h,"trace","log")}function x(w){if(!w)throw new Error("missing bindings for child Pino");var R=w.serializers;if(n&&R){var L=Object.assign({},i,R),$=t.browser.serialize===!0?Object.keys(L):n;delete w.serializers,ei([w],$,L,this._stdErrSerialize)}function E(A){this._childLevel=(A._childLevel|0)+1,this.error=hr(A,w,"error"),this.fatal=hr(A,w,"fatal"),this.warn=hr(A,w,"warn"),this.info=hr(A,w,"info"),this.debug=hr(A,w,"debug"),this.trace=hr(A,w,"trace"),L&&(this.serializers=L,this._serialize=$),e&&(this._logEvent=on([].concat(A._logEvent.bindings,w)))}return E.prototype=this,new E(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=fl,It.stdTimeFunctions=Object.assign({},{nullTime:mo,epochTime:wo,unixTime:yl,isoTime:_l});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,ll(t,e,r)}function ll(t,e,r){!t.transmit&&e[r]===Ar||(e[r]=function(i){return function(){for(var s=t.timestamp(),c=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Or?Or:this,h=0;h<c.length;h++)c[h]=arguments[h];if(t.serialize&&!t.asObject&&ei(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(u,dl(this,r,c,s)):i.apply(u,c),t.transmit){var d=t.transmit.level||e.level,g=It.levels.values[d],D=It.levels.values[r];if(D<g)return;pl(this,{ts:s,methodLevel:r,methodValue:D,transmitLevel:d,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},c)}}}(e[r]))}function dl(t,e,r,i){t._serialize&&ei(r,t._serialize,t.serializers,t._stdErrSerialize);var n=r.slice(),s=n[0],c={};i&&(c.time=i),c.level=It.levels.values[e];var u=(t._childLevel|0)+1;if(u<1&&(u=1),s!==null&&typeof s=="object"){for(;u--&&typeof n[0]=="object";)Object.assign(c,n.shift());s=n.length?bo(n.shift(),n):void 0}else typeof s=="string"&&(s=bo(n.shift(),n));return s!==void 0&&(c.msg=s),c}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 pl(t,e,r){var i=e.send,n=e.ts,s=e.methodLevel,c=e.methodValue,u=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(d){return h.indexOf(d)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=c,i(s,t._logEvent,u),t._logEvent=on(h)}function on(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function gl(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 vl(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?mo:wo}function ti(){return{}}function an(t){return t}function Ar(){}function mo(){return!1}function wo(){return Date.now()}function yl(){return Math.round(Date.now()/1e3)}function _l(){return new Date(Date.now()).toISOString()}function bl(){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={},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)Object.prototype.hasOwnProperty.call(i,n)&&(r[n]=i[n])},cn(t,e)};function ml(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");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 wl(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 El(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(s=(n<3?c(s):n>3?c(e,r,s):c(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Dl(t,e){return function(r,i){e(r,i,t)}}function xl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Sl(t,e,r,i){function n(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{d(i.next(g))}catch(D){c(D)}}function h(g){try{d(i.throw(g))}catch(D){c(D)}}function d(g){g.done?s(g.value):n(g.value).then(u,h)}d((i=i.apply(t,e||[])).next())})}function Ol(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(d){return function(g){return h([d,g])}}function h(d){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=d[0]&2?n.return:d[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,d[1])).done)return s;switch(n=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,n=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){r.label=d[1];break}if(d[0]===6&&r.label<s[1]){r.label=s[1],s=d;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(d);break}s[2]&&r.ops.pop(),r.trys.pop();continue}d=e.call(t,r)}catch(g){d=[6,g],n=0}finally{i=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}var hn=Object.create?function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]};function Al(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&hn(e,t,r)}function fn(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 Eo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],c;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(u){c={error:u}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(c)throw c.error}}return s}function Il(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Eo(arguments[e]));return t}function Tl(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],c=0,u=s.length;c<u;c++,n++)i[n]=s[c];return i}function Cl(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}function Ir(t){return this instanceof Ir?(this.v=t,this):new Ir(t)}function Ll(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},c("next"),c("throw"),c("return"),n[Symbol.asyncIterator]=function(){return this},n;function c(C){i[C]&&(n[C]=function(x){return new Promise(function(w,R){s.push([C,x,w,R])>1||u(C,x)})})}function u(C,x){try{h(i[C](x))}catch(w){D(s[0][3],w)}}function h(C){C.value instanceof Ir?Promise.resolve(C.value.v).then(d,g):D(s[0][2],C)}function d(C){u("next",C)}function g(C){u("throw",C)}function D(C,x){C(x),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Nl(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(c){return(r=!r)?{value:Ir(t[n](c)),done:n==="return"}:s?s(c):c}:s}}function Pl(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 fn=="function"?fn(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(c){return new Promise(function(u,h){c=t[s](c),n(u,h,c.done,c.value)})}}function n(s,c,u,h){Promise.resolve(h).then(function(d){s({value:d,done:u})},c)}}function Rl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var Fl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function Ul(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&hn(e,t,r);return Fl(e,t),e}function Ml(t){return t&&t.__esModule?t:{default:t}}function jl(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)}function $l(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r}function Bl(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}var zl=Object.freeze({__proto__:null,__extends:ml,get __assign(){return un},__rest:wl,__decorate:El,__param:Dl,__metadata:xl,__awaiter:Sl,__generator:Ol,__createBinding:hn,__exportStar:Al,__values:fn,__read:Eo,__spread:Il,__spreadArrays:Tl,__spreadArray:Cl,__await:Ir,__asyncGenerator:Ll,__asyncDelegator:Nl,__asyncValues:Pl,__makeTemplateObject:Rl,__importStar:Ul,__importDefault:Ml,__classPrivateFieldGet:jl,__classPrivateFieldSet:$l,__classPrivateFieldIn:Bl}),ln=bi(zl),ii={exports:{}},Do;function Hl(){return Do||(Do=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 Tr={},xo;function So(){if(xo)return Tr;xo=1,Object.defineProperty(Tr,"__esModule",{value:!0});function t(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}Tr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(i,n)=>typeof n>"u"?null:n)}return Tr.safeJsonStringify=e,Tr}var dn={},Cr={},Oo;function Kl(){if(Oo)return Cr;Oo=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.IKeyValueStorage=void 0;class t{}return Cr.IKeyValueStorage=t,Cr}var Lr={},Ao;function ql(){if(Ao)return Lr;Ao=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.parseEntry=void 0;const t=So();function e(r){var i;return[r[0],t.safeJsonParse((i=r[1])!==null&&i!==void 0?i:"")]}return Lr.parseEntry=e,Lr}var Io;function Vl(){return Io||(Io=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ln;e.__exportStar(Kl(),t),e.__exportStar(ql(),t)}(dn)),dn}Object.defineProperty(ri,"__esModule",{value:!0}),ri.KeyValueStorage=void 0;const fr=ln,Gl=fr.__importDefault(Hl()),To=So(),Wl=Vl();class Co{constructor(){this.localStorage=Gl.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(Wl.parseEntry)})}getItem(e){return fr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return To.safeJsonParse(r)})}setItem(e,r){return fr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,To.safeJsonStringify(r))})}removeItem(e){return fr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}ri.KeyValueStorage=Co;var kl=ri.default=Co,Nr={},ni={},pn={},si={};class Xt{}var Yl=Object.freeze({__proto__:null,IEvents:Xt}),Jl=bi(Yl);Object.defineProperty(si,"__esModule",{value:!0}),si.IHeartBeat=void 0;const Xl=Jl;class Zl extends Xl.IEvents{constructor(e){super()}}si.IHeartBeat=Zl,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(si,t)}(pn);var gn={},lr={};Object.defineProperty(lr,"__esModule",{value:!0}),lr.HEARTBEAT_EVENTS=lr.HEARTBEAT_INTERVAL=void 0;const Ql=Ie;lr.HEARTBEAT_INTERVAL=Ql.FIVE_SECONDS,lr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(lr,t)}(gn);var vn=Z&&Z.__awaiter||function(t,e,r,i){function n(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{d(i.next(g))}catch(D){c(D)}}function h(g){try{d(i.throw(g))}catch(D){c(D)}}function d(g){g.done?s(g.value):n(g.value).then(u,h)}d((i=i.apply(t,e||[])).next())})};Object.defineProperty(ni,"__esModule",{value:!0}),ni.HeartBeat=void 0;const ed=gr,td=Ie,rd=pn,yn=gn;class _n extends rd.IHeartBeat{constructor(e){super(e),this.events=new ed.EventEmitter,this.interval=yn.HEARTBEAT_INTERVAL,this.interval=e?.interval||yn.HEARTBEAT_INTERVAL}static init(e){return vn(this,void 0,void 0,function*(){const r=new _n(e);return yield r.init(),r})}init(){return vn(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 vn(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),td.toMiliseconds(this.interval))})}pulse(){this.events.emit(yn.HEARTBEAT_EVENTS.pulse)}}ni.HeartBeat=_n,function(t){var e=Z&&Z.__createBinding||(Object.create?function(i,n,s,c){c===void 0&&(c=s),Object.defineProperty(i,c,{enumerable:!0,get:function(){return n[s]}})}:function(i,n,s,c){c===void 0&&(c=s),i[c]=n[s]}),r=Z&&Z.__exportStar||function(i,n){for(var s in i)s!=="default"&&!n.hasOwnProperty(s)&&e(n,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(ni,t),r(pn,t),r(gn,t)}(Nr);var Se={},Zt={},Lo;function No(){return Lo||(Lo=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={},Po;function id(){if(Po)return ct;Po=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=No();function e(u){return Object.assign(Object.assign({},u),{level:u?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(u,h=t.PINO_CUSTOM_CONTEXT_KEY){return u[h]||""}ct.getBrowserLoggerContext=r;function i(u,h,d=t.PINO_CUSTOM_CONTEXT_KEY){return u[d]=h,u}ct.setBrowserLoggerContext=i;function n(u,h=t.PINO_CUSTOM_CONTEXT_KEY){let d="";return typeof u.bindings>"u"?d=r(u,h):d=u.bindings().context||"",d}ct.getLoggerContext=n;function s(u,h,d=t.PINO_CUSTOM_CONTEXT_KEY){const g=n(u,d);return g.trim()?`${g}/${h}`:h}ct.formatChildLoggerContext=s;function c(u,h,d=t.PINO_CUSTOM_CONTEXT_KEY){const g=s(u,h,d),D=u.child({context:g});return i(D,g,d)}return ct.generateChildLogger=c,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ln;e.__exportStar(No(),t),e.__exportStar(id(),t)})(Se);class nd extends Xt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class sd extends Xt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class od{constructor(e,r){this.logger=e,this.core=r}}class ad extends Xt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class cd extends Xt{constructor(e){super()}}class ud{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class hd 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 fd=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!ld(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Pr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ro(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),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},Ke.prototype.addListener=function(t,e){var r;if(!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&&(Ro(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 ld(t){return typeof t=="number"}function Pr(t){return typeof t=="object"&&t!==null}function Ro(t){return t===void 0}class dd{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class pv extends fd.EventEmitter{constructor(){super()}}class pd{constructor(e){this.client=e}}class gd extends Xt{constructor(e,r){super(),this.core=e,this.logger=r}}var bn={},Fo={};(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 u(){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 u.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},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},u.prototype.update=function(h,d){if(d===void 0&&(d=h.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=d,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&d>0;)this._buffer[this._bufferLength++]=h[g++],d--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(d>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,g,d),d%=this.blockSize);d>0;)this._buffer[this._bufferLength++]=h[g++],d--;return this},u.prototype.finish=function(h){if(!this._finished){var d=this._bytesHashed,g=this._bufferLength,D=d/536870912|0,C=d<<3,x=d%128<112?128:256;this._buffer[g]=128;for(var w=g+1;w<x-8;w++)this._buffer[w]=0;e.writeUint32BE(D,this._buffer,x-8),e.writeUint32BE(C,this._buffer,x-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,x),this._finished=!0}for(var w=0;w<this.digestLength/8;w++)e.writeUint32BE(this._stateHi[w],h,w*8),e.writeUint32BE(this._stateLo[w],h,w*8+4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.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}},u.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},u.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();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(u,h,d,g,D,C,x){for(var w=d[0],R=d[1],L=d[2],$=d[3],E=d[4],A=d[5],y=d[6],m=d[7],b=g[0],o=g[1],l=g[2],M=g[3],K=g[4],V=g[5],J=g[6],X=g[7],f,_,U,q,P,N,j,B;x>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+C;u[Q]=e.readUint32BE(D,H),h[Q]=e.readUint32BE(D,H+4)}for(var Q=0;Q<80;Q++){var ee=w,k=R,ae=L,T=$,I=E,S=A,a=y,v=m,z=b,Y=o,fe=l,ye=M,de=K,me=V,Fe=J,Ce=X;if(f=m,_=X,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=(E>>>14|K<<32-14)^(E>>>18|K<<32-18)^(K>>>41-32|E<<32-(41-32)),_=(K>>>14|E<<32-14)^(K>>>18|E<<32-18)^(E>>>41-32|K<<32-(41-32)),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=E&A^~E&y,_=K&V^~K&J,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=n[Q*2],_=n[Q*2+1],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=u[Q%16],_=h[Q%16],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,U=j&65535|B<<16,q=P&65535|N<<16,f=U,_=q,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=(w>>>28|b<<32-28)^(b>>>34-32|w<<32-(34-32))^(b>>>39-32|w<<32-(39-32)),_=(b>>>28|w<<32-28)^(w>>>34-32|b<<32-(34-32))^(w>>>39-32|b<<32-(39-32)),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,f=w&R^w&L^R&L,_=b&o^b&l^o&l,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,v=j&65535|B<<16,Ce=P&65535|N<<16,f=T,_=ye,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=U,_=q,P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,T=j&65535|B<<16,ye=P&65535|N<<16,R=ee,L=k,$=ae,E=T,A=I,y=S,m=a,w=v,o=z,l=Y,M=fe,K=ye,V=de,J=me,X=Fe,b=Ce,Q%16===15)for(var H=0;H<16;H++)f=u[H],_=h[H],P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=u[(H+9)%16],_=h[(H+9)%16],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,U=u[(H+1)%16],q=h[(H+1)%16],f=(U>>>1|q<<32-1)^(U>>>8|q<<32-8)^U>>>7,_=(q>>>1|U<<32-1)^(q>>>8|U<<32-8)^(q>>>7|U<<32-7),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,U=u[(H+14)%16],q=h[(H+14)%16],f=(U>>>19|q<<32-19)^(q>>>61-32|U<<32-(61-32))^U>>>6,_=(q>>>19|U<<32-19)^(U>>>61-32|q<<32-(61-32))^(q>>>6|U<<32-6),P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,u[H]=j&65535|B<<16,h[H]=P&65535|N<<16}f=w,_=b,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[0],_=g[0],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[0]=w=j&65535|B<<16,g[0]=b=P&65535|N<<16,f=R,_=o,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[1],_=g[1],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[1]=R=j&65535|B<<16,g[1]=o=P&65535|N<<16,f=L,_=l,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[2],_=g[2],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[2]=L=j&65535|B<<16,g[2]=l=P&65535|N<<16,f=$,_=M,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[3],_=g[3],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[3]=$=j&65535|B<<16,g[3]=M=P&65535|N<<16,f=E,_=K,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[4],_=g[4],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[4]=E=j&65535|B<<16,g[4]=K=P&65535|N<<16,f=A,_=V,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[5],_=g[5],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[5]=A=j&65535|B<<16,g[5]=V=P&65535|N<<16,f=y,_=J,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[6],_=g[6],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[6]=y=j&65535|B<<16,g[6]=J=P&65535|N<<16,f=m,_=X,P=_&65535,N=_>>>16,j=f&65535,B=f>>>16,f=d[7],_=g[7],P+=_&65535,N+=_>>>16,j+=f&65535,B+=f>>>16,N+=P>>>16,j+=N>>>16,B+=j>>>16,d[7]=m=j&65535|B<<16,g[7]=X=P&65535|N<<16,C+=128,x-=128}return C}function c(u){var h=new i;h.update(u);var d=h.digest();return h.clean(),d}t.hash=c})(Fo),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=Fo,i=pt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(T){var I=new Float64Array(16);if(T)for(var S=0;S<T.length;S++)I[S]=T[S];return I}var s=new Uint8Array(32);s[0]=9;var c=n(),u=n([1]),h=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),D=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function x(T,I){for(var S=0;S<16;S++)T[S]=I[S]|0}function w(T){for(var I=1,S=0;S<16;S++){var a=T[S]+I+65535;I=Math.floor(a/65536),T[S]=a-I*65536}T[0]+=I-1+37*(I-1)}function R(T,I,S){for(var a=~(S-1),v=0;v<16;v++){var z=a&(T[v]^I[v]);T[v]^=z,I[v]^=z}}function L(T,I){for(var S=n(),a=n(),v=0;v<16;v++)a[v]=I[v];w(a),w(a),w(a);for(var z=0;z<2;z++){S[0]=a[0]-65517;for(var v=1;v<15;v++)S[v]=a[v]-65535-(S[v-1]>>16&1),S[v-1]&=65535;S[15]=a[15]-32767-(S[14]>>16&1);var Y=S[15]>>16&1;S[14]&=65535,R(a,S,1-Y)}for(var v=0;v<16;v++)T[2*v]=a[v]&255,T[2*v+1]=a[v]>>8}function $(T,I){for(var S=0,a=0;a<32;a++)S|=T[a]^I[a];return(1&S-1>>>8)-1}function E(T,I){var S=new Uint8Array(32),a=new Uint8Array(32);return L(S,T),L(a,I),$(S,a)}function A(T){var I=new Uint8Array(32);return L(I,T),I[0]&1}function y(T,I){for(var S=0;S<16;S++)T[S]=I[2*S]+(I[2*S+1]<<8);T[15]&=32767}function m(T,I,S){for(var a=0;a<16;a++)T[a]=I[a]+S[a]}function b(T,I,S){for(var a=0;a<16;a++)T[a]=I[a]-S[a]}function o(T,I,S){var a,v,z=0,Y=0,fe=0,ye=0,de=0,me=0,Fe=0,Ce=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=S[0],Le=S[1],Me=S[2],je=S[3],$e=S[4],Ne=S[5],We=S[6],ke=S[7],Ye=S[8],Je=S[9],Xe=S[10],ze=S[11],Be=S[12],Ae=S[13],Ze=S[14],Qe=S[15];a=I[0],z+=a*Ue,Y+=a*Le,fe+=a*Me,ye+=a*je,de+=a*$e,me+=a*Ne,Fe+=a*We,Ce+=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=I[1],Y+=a*Ue,fe+=a*Le,ye+=a*Me,de+=a*je,me+=a*$e,Fe+=a*Ne,Ce+=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=I[2],fe+=a*Ue,ye+=a*Le,de+=a*Me,me+=a*je,Fe+=a*$e,Ce+=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=I[3],ye+=a*Ue,de+=a*Le,me+=a*Me,Fe+=a*je,Ce+=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=I[4],de+=a*Ue,me+=a*Le,Fe+=a*Me,Ce+=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=I[5],me+=a*Ue,Fe+=a*Le,Ce+=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=I[6],Fe+=a*Ue,Ce+=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=I[7],Ce+=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=I[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=I[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=I[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=I[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=I[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=I[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=I[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=I[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,Ce+=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=Ce+v+65535,v=Math.floor(a/65536),Ce=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=Ce+v+65535,v=Math.floor(a/65536),Ce=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),T[0]=z,T[1]=Y,T[2]=fe,T[3]=ye,T[4]=de,T[5]=me,T[6]=Fe,T[7]=Ce,T[8]=ve,T[9]=pe,T[10]=le,T[11]=ue,T[12]=ce,T[13]=oe,T[14]=se,T[15]=te}function l(T,I){o(T,I,I)}function M(T,I){var S=n(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=253;a>=0;a--)l(S,S),a!==2&&a!==4&&o(S,S,I);for(a=0;a<16;a++)T[a]=S[a]}function K(T,I){var S=n(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=250;a>=0;a--)l(S,S),a!==1&&o(S,S,I);for(a=0;a<16;a++)T[a]=S[a]}function V(T,I){var S=n(),a=n(),v=n(),z=n(),Y=n(),fe=n(),ye=n(),de=n(),me=n();b(S,T[1],T[0]),b(me,I[1],I[0]),o(S,S,me),m(a,T[0],T[1]),m(me,I[0],I[1]),o(a,a,me),o(v,T[3],I[3]),o(v,v,d),o(z,T[2],I[2]),m(z,z,z),b(Y,a,S),b(fe,z,v),m(ye,z,v),m(de,a,S),o(T[0],Y,fe),o(T[1],de,ye),o(T[2],ye,fe),o(T[3],Y,de)}function J(T,I,S){for(var a=0;a<4;a++)R(T[a],I[a],S)}function X(T,I){var S=n(),a=n(),v=n();M(v,I[2]),o(S,I[0],v),o(a,I[1],v),L(T,a),T[31]^=A(S)<<7}function f(T,I,S){x(T[0],c),x(T[1],u),x(T[2],u),x(T[3],c);for(var a=255;a>=0;--a){var v=S[a/8|0]>>(a&7)&1;J(T,I,v),V(I,T),V(T,T),J(T,I,v)}}function _(T,I){var S=[n(),n(),n(),n()];x(S[0],g),x(S[1],D),x(S[2],u),o(S[3],g,D),f(T,S,I)}function U(T){if(T.length!==t.SEED_LENGTH)throw new Error("ed25519: seed must be "+t.SEED_LENGTH+" bytes");var I=r.hash(T);I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(32),a=[n(),n(),n(),n()];_(a,I),X(S,a);var v=new Uint8Array(64);return v.set(T),v.set(S,32),{publicKey:S,secretKey:v}}t.generateKeyPairFromSeed=U;function q(T){var I=e.randomBytes(32,T),S=U(I);return i.wipe(I),S}t.generateKeyPair=q;function P(T){if(T.length!==t.SECRET_KEY_LENGTH)throw new Error("ed25519: secret key must be "+t.SECRET_KEY_LENGTH+" bytes");return new Uint8Array(T.subarray(32))}t.extractPublicKeyFromSecretKey=P;var N=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(T,I){var S,a,v,z;for(a=63;a>=32;--a){for(S=0,v=a-32,z=a-12;v<z;++v)I[v]+=S-16*I[a]*N[v-(a-32)],S=Math.floor((I[v]+128)/256),I[v]-=S*256;I[v]+=S,I[a]=0}for(S=0,v=0;v<32;v++)I[v]+=S-(I[31]>>4)*N[v],S=I[v]>>8,I[v]&=255;for(v=0;v<32;v++)I[v]-=S*N[v];for(a=0;a<32;a++)I[a+1]+=I[a]>>8,T[a]=I[a]&255}function B(T){for(var I=new Float64Array(64),S=0;S<64;S++)I[S]=T[S];for(var S=0;S<64;S++)T[S]=0;j(T,I)}function Q(T,I){var S=new Float64Array(64),a=[n(),n(),n(),n()],v=r.hash(T.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(I);var fe=Y.digest();Y.clean(),B(fe),_(a,fe),X(z,a),Y.reset(),Y.update(z.subarray(0,32)),Y.update(T.subarray(32)),Y.update(I);var ye=Y.digest();B(ye);for(var de=0;de<32;de++)S[de]=fe[de];for(var de=0;de<32;de++)for(var me=0;me<32;me++)S[de+me]+=ye[de]*v[me];return j(z.subarray(32),S),z}t.sign=Q;function H(T,I){var S=n(),a=n(),v=n(),z=n(),Y=n(),fe=n(),ye=n();return x(T[2],u),y(T[1],I),l(v,T[1]),o(z,v,h),b(v,v,T[2]),m(z,T[2],z),l(Y,z),l(fe,Y),o(ye,fe,Y),o(S,ye,v),o(S,S,z),K(S,S),o(S,S,v),o(S,S,z),o(S,S,z),o(T[0],S,z),l(a,T[0]),o(a,a,z),E(a,v)&&o(T[0],T[0],C),l(a,T[0]),o(a,a,z),E(a,v)?-1:(A(T[0])===I[31]>>7&&b(T[0],c,T[0]),o(T[3],T[0],T[1]),0)}function ee(T,I,S){var a=new Uint8Array(32),v=[n(),n(),n(),n()],z=[n(),n(),n(),n()];if(S.length!==t.SIGNATURE_LENGTH)throw new Error("ed25519: signature must be "+t.SIGNATURE_LENGTH+" bytes");if(H(z,T))return!1;var Y=new r.SHA512;Y.update(S.subarray(0,32)),Y.update(T),Y.update(I);var fe=Y.digest();return B(fe),f(v,z,fe),_(z,S.subarray(32)),V(v,z),X(a,v),!$(S,a)}t.verify=ee;function k(T){var I=[n(),n(),n(),n()];if(H(I,T))throw new Error("Ed25519: invalid public key");var S=n(),a=n(),v=I[1];m(S,u,v),b(a,u,v),M(a,a),o(S,S,a);var z=new Uint8Array(32);return L(z,S),z}t.convertPublicKeyToX25519=k;function ae(T){var I=r.hash(T.subarray(0,32));I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(I.subarray(0,32));return i.wipe(I),S}t.convertSecretKeyToX25519=ae}(bn);const vd="EdDSA",yd="JWT",Uo=".",Mo="base64url",_d="utf8",bd="utf8",md=":",wd="did",Ed="key",jo="base58btc",Dd="z",xd="K36",Sd=32;function oi(t){return ft(ht(_r(t),_d),Mo)}function $o(t){const e=ht(xd,jo),r=Dd+ft(ji([e,t]),jo);return[wd,Ed,r].join(md)}function Od(t){return ft(t,Mo)}function Ad(t){return ht([oi(t.header),oi(t.payload)].join(Uo),bd)}function Id(t){return[oi(t.header),oi(t.payload),Od(t.signature)].join(Uo)}function Bo(t=nr.randomBytes(Sd)){return bn.generateKeyPairFromSeed(t)}async function Td(t,e,r,i,n=Ie.fromMiliseconds(Date.now())){const s={alg:vd,typ:yd},c=$o(i.publicKey),u=n+r,h={iss:c,sub:t,aud:e,iat:n,exp:u},d=Ad({header:s,payload:h}),g=bn.sign(i.secretKey,d);return Id({header:s,payload:h,signature:g})}const zo=10,Cd=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class Ld{constructor(e){if(this.url=e,this.events=new gr.EventEmitter,this.registering=!1,!Vn(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(!Vn(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=jn.isReactNative()?void 0:{rejectUnauthorized:!oc(e)},s=new Cd(e,[],n);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const u=this.parseError(c.error);this.events.emit("register_error",u),this.onClose(),i(u)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const i=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 Mn(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>zo&&this.events.setMaxListeners(zo)}}var mn={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,c=9007199254740991,u="[object Arguments]",h="[object Array]",d="[object AsyncFunction]",g="[object Boolean]",D="[object Date]",C="[object Error]",x="[object Function]",w="[object GeneratorFunction]",R="[object Map]",L="[object Number]",$="[object Null]",E="[object Object]",A="[object Promise]",y="[object Proxy]",m="[object RegExp]",b="[object Set]",o="[object String]",l="[object Symbol]",M="[object Undefined]",K="[object WeakMap]",V="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",f="[object Float64Array]",_="[object Int8Array]",U="[object Int16Array]",q="[object Int32Array]",P="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",B="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,k={};k[X]=k[f]=k[_]=k[U]=k[q]=k[P]=k[N]=k[j]=k[B]=!0,k[u]=k[h]=k[V]=k[g]=k[J]=k[D]=k[C]=k[x]=k[R]=k[L]=k[E]=k[m]=k[b]=k[o]=k[K]=!1;var ae=typeof Z=="object"&&Z&&Z.Object===Object&&Z,T=typeof self=="object"&&self&&self.Object===Object&&self,I=ae||T||Function("return this")(),S=e&&!e.nodeType&&e,a=S&&!0&&t&&!t.nodeType&&t,v=a&&a.exports===S,z=v&&ae.process,Y=function(){try{return z&&z.binding&&z.binding("util")}catch{}}(),fe=Y&&Y.isTypedArray;function ye(p,O){for(var F=-1,W=p==null?0:p.length,Oe=0,ne=[];++F<W;){var Pe=p[F];O(Pe,F,p)&&(ne[Oe++]=Pe)}return ne}function de(p,O){for(var F=-1,W=O.length,Oe=p.length;++F<W;)p[Oe+F]=O[F];return p}function me(p,O){for(var F=-1,W=p==null?0:p.length;++F<W;)if(O(p[F],F,p))return!0;return!1}function Fe(p,O){for(var F=-1,W=Array(p);++F<p;)W[F]=O(F);return W}function Ce(p){return function(O){return p(O)}}function ve(p,O){return p.has(O)}function pe(p,O){return p?.[O]}function le(p){var O=-1,F=Array(p.size);return p.forEach(function(W,Oe){F[++O]=[Oe,W]}),F}function ue(p,O){return function(F){return p(O(F))}}function ce(p){var O=-1,F=Array(p.size);return p.forEach(function(W){F[++O]=W}),F}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=I["__core-js_shared__"],ge=se.toString,ie=te.hasOwnProperty,_e=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=v?I.Buffer:void 0,we=I.Symbol,xt=I.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(I,"DataView"),Le=pr(I,"Map"),Me=pr(I,"Promise"),je=pr(I,"Set"),$e=pr(I,"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(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function Ze(){this.__data__=Ne?Ne(null):{},this.size=0}function Qe(p){var O=this.has(p)&&delete this.__data__[p];return this.size-=O?1:0,O}function D0(p){var O=this.__data__;if(Ne){var F=O[p];return F===i?void 0:F}return ie.call(O,p)?O[p]:void 0}function x0(p){var O=this.__data__;return Ne?O[p]!==void 0:ie.call(O,p)}function S0(p,O){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Ne&&O===void 0?i:O,this}Ae.prototype.clear=Ze,Ae.prototype.delete=Qe,Ae.prototype.get=D0,Ae.prototype.has=x0,Ae.prototype.set=S0;function jt(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function O0(){this.__data__=[],this.size=0}function A0(p){var O=this.__data__,F=pi(O,p);if(F<0)return!1;var W=O.length-1;return F==W?O.pop():qt.call(O,F,1),--this.size,!0}function I0(p){var O=this.__data__,F=pi(O,p);return F<0?void 0:O[F][1]}function T0(p){return pi(this.__data__,p)>-1}function C0(p,O){var F=this.__data__,W=pi(F,p);return W<0?(++this.size,F.push([p,O])):F[W][1]=O,this}jt.prototype.clear=O0,jt.prototype.delete=A0,jt.prototype.get=I0,jt.prototype.has=T0,jt.prototype.set=C0;function tr(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function L0(){this.size=0,this.__data__={hash:new Ae,map:new(Le||jt),string:new Ae}}function N0(p){var O=gi(this,p).delete(p);return this.size-=O?1:0,O}function P0(p){return gi(this,p).get(p)}function R0(p){return gi(this,p).has(p)}function F0(p,O){var F=gi(this,p),W=F.size;return F.set(p,O),this.size+=F.size==W?0:1,this}tr.prototype.clear=L0,tr.prototype.delete=N0,tr.prototype.get=P0,tr.prototype.has=R0,tr.prototype.set=F0;function di(p){var O=-1,F=p==null?0:p.length;for(this.__data__=new tr;++O<F;)this.add(p[O])}function U0(p){return this.__data__.set(p,i),this}function M0(p){return this.__data__.has(p)}di.prototype.add=di.prototype.push=U0,di.prototype.has=M0;function Vt(p){var O=this.__data__=new jt(p);this.size=O.size}function j0(){this.__data__=new jt,this.size=0}function $0(p){var O=this.__data__,F=O.delete(p);return this.size=O.size,F}function B0(p){return this.__data__.get(p)}function z0(p){return this.__data__.has(p)}function H0(p,O){var F=this.__data__;if(F instanceof jt){var W=F.__data__;if(!Le||W.length<r-1)return W.push([p,O]),this.size=++F.size,this;F=this.__data__=new tr(W)}return F.set(p,O),this.size=F.size,this}Vt.prototype.clear=j0,Vt.prototype.delete=$0,Vt.prototype.get=B0,Vt.prototype.has=z0,Vt.prototype.set=H0;function K0(p,O){var F=vi(p),W=!F&&nv(p),Oe=!F&&!W&&Nn(p),ne=!F&&!W&&!Oe&&$a(p),Pe=F||W||Oe||ne,et=Pe?Fe(p.length,String):[],nt=et.length;for(var Te in p)(O||ie.call(p,Te))&&!(Pe&&(Te=="length"||Oe&&(Te=="offset"||Te=="parent")||ne&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||Q0(Te,nt)))&&et.push(Te);return et}function pi(p,O){for(var F=p.length;F--;)if(Fa(p[F][0],O))return F;return-1}function q0(p,O,F){var W=O(p);return vi(p)?W:de(W,F(p))}function Hr(p){return p==null?p===void 0?M:$:gt&> in Object(p)?X0(p):iv(p)}function La(p){return Kr(p)&&Hr(p)==u}function Na(p,O,F,W,Oe){return p===O?!0:p==null||O==null||!Kr(p)&&!Kr(O)?p!==p&&O!==O:V0(p,O,F,W,Na,Oe)}function V0(p,O,F,W,Oe,ne){var Pe=vi(p),et=vi(O),nt=Pe?h:Gt(p),Te=et?h:Gt(O);nt=nt==u?E:nt,Te=Te==u?E:Te;var vt=nt==E,St=Te==E,at=nt==Te;if(at&&Nn(p)){if(!Nn(O))return!1;Pe=!0,vt=!1}if(at&&!vt)return ne||(ne=new Vt),Pe||$a(p)?Pa(p,O,F,W,Oe,ne):Y0(p,O,nt,F,W,Oe,ne);if(!(F&n)){var _t=vt&&ie.call(p,"__wrapped__"),bt=St&&ie.call(O,"__wrapped__");if(_t||bt){var Wt=_t?p.value():p,$t=bt?O.value():O;return ne||(ne=new Vt),Oe(Wt,$t,F,W,ne)}}return at?(ne||(ne=new Vt),J0(p,O,F,W,Oe,ne)):!1}function G0(p){if(!ja(p)||tv(p))return!1;var O=Ua(p)?Ee:H;return O.test(rr(p))}function W0(p){return Kr(p)&&Ma(p.length)&&!!k[Hr(p)]}function k0(p){if(!rv(p))return li(p);var O=[];for(var F in Object(p))ie.call(p,F)&&F!="constructor"&&O.push(F);return O}function Pa(p,O,F,W,Oe,ne){var Pe=F&n,et=p.length,nt=O.length;if(et!=nt&&!(Pe&&nt>et))return!1;var Te=ne.get(p);if(Te&&ne.get(O))return Te==O;var vt=-1,St=!0,at=F&s?new di:void 0;for(ne.set(p,O),ne.set(O,p);++vt<et;){var _t=p[vt],bt=O[vt];if(W)var Wt=Pe?W(bt,_t,vt,O,p,ne):W(_t,bt,vt,p,O,ne);if(Wt!==void 0){if(Wt)continue;St=!1;break}if(at){if(!me(O,function($t,ir){if(!ve(at,ir)&&(_t===$t||Oe(_t,$t,F,W,ne)))return at.push(ir)})){St=!1;break}}else if(!(_t===bt||Oe(_t,bt,F,W,ne))){St=!1;break}}return ne.delete(p),ne.delete(O),St}function Y0(p,O,F,W,Oe,ne,Pe){switch(F){case J:if(p.byteLength!=O.byteLength||p.byteOffset!=O.byteOffset)return!1;p=p.buffer,O=O.buffer;case V:return!(p.byteLength!=O.byteLength||!ne(new xt(p),new xt(O)));case g:case D:case L:return Fa(+p,+O);case C:return p.name==O.name&&p.message==O.message;case m:case o:return p==O+"";case R:var et=le;case b:var nt=W&n;if(et||(et=ce),p.size!=O.size&&!nt)return!1;var Te=Pe.get(p);if(Te)return Te==O;W|=s,Pe.set(p,O);var vt=Pa(et(p),et(O),W,Oe,ne,Pe);return Pe.delete(p),vt;case l:if(Be)return Be.call(p)==Be.call(O)}return!1}function J0(p,O,F,W,Oe,ne){var Pe=F&n,et=Ra(p),nt=et.length,Te=Ra(O),vt=Te.length;if(nt!=vt&&!Pe)return!1;for(var St=nt;St--;){var at=et[St];if(!(Pe?at in O:ie.call(O,at)))return!1}var _t=ne.get(p);if(_t&&ne.get(O))return _t==O;var bt=!0;ne.set(p,O),ne.set(O,p);for(var Wt=Pe;++St<nt;){at=et[St];var $t=p[at],ir=O[at];if(W)var Ba=Pe?W(ir,$t,at,O,p,ne):W($t,ir,at,p,O,ne);if(!(Ba===void 0?$t===ir||Oe($t,ir,F,W,ne):Ba)){bt=!1;break}Wt||(Wt=at=="constructor")}if(bt&&!Wt){var yi=p.constructor,_i=O.constructor;yi!=_i&&"constructor"in p&&"constructor"in O&&!(typeof yi=="function"&&yi instanceof yi&&typeof _i=="function"&&_i instanceof _i)&&(bt=!1)}return ne.delete(p),ne.delete(O),bt}function Ra(p){return q0(p,av,Z0)}function gi(p,O){var F=p.__data__;return ev(O)?F[typeof O=="string"?"string":"hash"]:F.map}function pr(p,O){var F=pe(p,O);return G0(F)?F:void 0}function X0(p){var O=ie.call(p,gt),F=p[gt];try{p[gt]=void 0;var W=!0}catch{}var Oe=be.call(p);return W&&(O?p[gt]=F:delete p[gt]),Oe}var Z0=er?function(p){return p==null?[]:(p=Object(p),ye(er(p),function(O){return Lt.call(p,O)}))}:cv,Gt=Hr;(Ue&&Gt(new Ue(new ArrayBuffer(1)))!=J||Le&&Gt(new Le)!=R||Me&&Gt(Me.resolve())!=A||je&&Gt(new je)!=b||$e&&Gt(new $e)!=K)&&(Gt=function(p){var O=Hr(p),F=O==E?p.constructor:void 0,W=F?rr(F):"";if(W)switch(W){case We:return J;case ke:return R;case Ye:return A;case Je:return b;case Xe:return K}return O});function Q0(p,O){return O=O??c,!!O&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<O}function ev(p){var O=typeof p;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?p!=="__proto__":p===null}function tv(p){return!!_e&&_e in p}function rv(p){var O=p&&p.constructor,F=typeof O=="function"&&O.prototype||te;return p===F}function iv(p){return be.call(p)}function rr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function Fa(p,O){return p===O||p!==p&&O!==O}var nv=La(function(){return arguments}())?La:function(p){return Kr(p)&&ie.call(p,"callee")&&!Lt.call(p,"callee")},vi=Array.isArray;function sv(p){return p!=null&&Ma(p.length)&&!Ua(p)}var Nn=zr||uv;function ov(p,O){return Na(p,O)}function Ua(p){if(!ja(p))return!1;var O=Hr(p);return O==x||O==w||O==d||O==y}function Ma(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=c}function ja(p){var O=typeof p;return p!=null&&(O=="object"||O=="function")}function Kr(p){return p!=null&&typeof p=="object"}var $a=fe?Ce(fe):W0;function av(p){return sv(p)?K0(p):k0(p)}function cv(){return[]}function uv(){return!1}t.exports=ov})(mn,mn.exports);var Nd=mn.exports,Pd=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Rd=Object.prototype.hasOwnProperty,Fd=Object.prototype.propertyIsEnumerable,Ko=(t,e,r)=>e in t?Pd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Rd.call(e,r)&&Ko(t,r,e[r]);if(Ho)for(var r of Ho(e))Fd.call(e,r)&&Ko(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(!Ud(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Rr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],qo(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),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},qe.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?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&&(qo(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 Ud(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function qo(t){return t===void 0}function Md(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=n}var u=t.length,h=t.charAt(0),d=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function D(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var R=0,L=0,$=0,E=w.length;$!==E&&w[$]===0;)$++,R++;for(var A=(E-$)*g+1>>>0,y=new Uint8Array(A);$!==E;){for(var m=w[$],b=0,o=A-1;(m!==0||b<L)&&o!==-1;o--,b++)m+=256*y[o]>>>0,y[o]=m%u>>>0,m=m/u>>>0;if(m!==0)throw new Error("Non-zero carry");L=b,$++}for(var l=A-L;l!==A&&y[l]===0;)l++;for(var M=h.repeat(R);l<A;++l)M+=t.charAt(y[l]);return M}function C(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var R=0;if(w[R]!==" "){for(var L=0,$=0;w[R]===h;)L++,R++;for(var E=(w.length-R)*d+1>>>0,A=new Uint8Array(E);w[R];){var y=r[w.charCodeAt(R)];if(y===255)return;for(var m=0,b=E-1;(y!==0||m<$)&&b!==-1;b--,m++)y+=u*A[b]>>>0,A[b]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");$=m,R++}if(w[R]!==" "){for(var o=E-$;o!==E&&A[o]===0;)o++;for(var l=new Uint8Array(L+(E-o)),M=L;o!==E;)l[M++]=A[o++];return l}}}function x(w){var R=C(w);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:C,decode:x}}var jd=Md,$d=jd;const Vo=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")},Bd=t=>new TextEncoder().encode(t),zd=t=>new TextDecoder().decode(t);class Hd{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 Kd{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 Go(this,e)}}class qd{constructor(e){this.decoders=e}or(e){return Go(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 Go=(t,e)=>new qd(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Vd{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Hd(e,r,i),this.decoder=new Kd(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 Vd(t,e,r,i),Fr=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=$d(r,e);return ci({prefix:t,name:e,encode:i,decode:s=>Vo(n(s))})},Gd=(t,e,r,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,d=0;for(let g=0;g<s;++g){const D=n[t[g]];if(D===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<r|D,u+=r,u>=8&&(u-=8,c[d++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},Wd=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[n&u>>c];if(c&&(s+=e[n&u<<r-c]),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 Wd(n,i,r)},decode(n){return Gd(n,i,r,t)}}),kd=ci({prefix:"\0",name:"identity",encode:t=>zd(t),decode:t=>Bd(t)});var Yd=Object.freeze({__proto__:null,identity:kd});const Jd=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xd=Object.freeze({__proto__:null,base2:Jd});const Zd=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Qd=Object.freeze({__proto__:null,base8:Zd});const ep=Fr({prefix:"9",name:"base10",alphabet:"0123456789"});var tp=Object.freeze({__proto__:null,base10:ep});const rp=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ip=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var np=Object.freeze({__proto__:null,base16:rp,base16upper:ip});const sp=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),op=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ap=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cp=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),up=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hp=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fp=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lp=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dp=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pp=Object.freeze({__proto__:null,base32:sp,base32upper:op,base32pad:ap,base32padupper:cp,base32hex:up,base32hexupper:hp,base32hexpad:fp,base32hexpadupper:lp,base32z:dp});const gp=Fr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vp=Fr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yp=Object.freeze({__proto__:null,base36:gp,base36upper:vp});const _p=Fr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bp=Fr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mp=Object.freeze({__proto__:null,base58btc:_p,base58flickr:bp});const wp=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ep=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dp=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xp=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Sp=Object.freeze({__proto__:null,base64:wp,base64pad:Ep,base64url:Dp,base64urlpad:xp});const Wo=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}"),Op=Wo.reduce((t,e,r)=>(t[r]=e,t),[]),Ap=Wo.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ip(t){return t.reduce((e,r)=>(e+=Op[r],e),"")}function Tp(t){const e=[];for(const r of t){const i=Ap[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Cp=ci({prefix:"\u{1F680}",name:"base256emoji",encode:Ip,decode:Tp});var Lp=Object.freeze({__proto__:null,base256emoji:Cp}),Np=Yo,ko=128,Pp=127,Rp=~Pp,Fp=Math.pow(2,31);function Yo(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Fp;)e[r++]=t&255|ko,t/=128;for(;t&Rp;)e[r++]=t&255|ko,t>>>=7;return e[r]=t|0,Yo.bytes=r-i+1,e}var Up=wn,Mp=128,Jo=127;function wn(t,i){var r=0,i=i||0,n=0,s=i,c,u=t.length;do{if(s>=u)throw wn.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=n<28?(c&Jo)<<n:(c&Jo)*Math.pow(2,n),n+=7}while(c>=Mp);return wn.bytes=s-i,r}var jp=Math.pow(2,7),$p=Math.pow(2,14),Bp=Math.pow(2,21),zp=Math.pow(2,28),Hp=Math.pow(2,35),Kp=Math.pow(2,42),qp=Math.pow(2,49),Vp=Math.pow(2,56),Gp=Math.pow(2,63),Wp=function(t){return t<jp?1:t<$p?2:t<Bp?3:t<zp?4:t<Hp?5:t<Kp?6:t<qp?7:t<Vp?8:t<Gp?9:10},kp={encode:Np,decode:Up,encodingLength:Wp},Xo=kp;const Zo=(t,e,r=0)=>(Xo.encode(t,e,r),e),Qo=t=>Xo.encodingLength(t),En=(t,e)=>{const r=e.byteLength,i=Qo(t),n=i+Qo(r),s=new Uint8Array(n+r);return Zo(t,s,0),Zo(r,s,i),s.set(e,n),new Yp(t,r,e,s)};class Yp{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const ea=({name:t,code:e,encode:r})=>new Jp(t,e,r);class Jp{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?En(this.code,r):r.then(i=>En(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ta=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Xp=ea({name:"sha2-256",code:18,encode:ta("SHA-256")}),Zp=ea({name:"sha2-512",code:19,encode:ta("SHA-512")});var Qp=Object.freeze({__proto__:null,sha256:Xp,sha512:Zp});const ra=0,eg="identity",ia=Vo;var tg=Object.freeze({__proto__:null,identity:{code:ra,name:eg,encode:ia,digest:t=>En(ra,ia(t))}});new TextEncoder,new TextDecoder;const na=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},Yd),Xd),Qd),tp),np),pp),yp),mp),Sp),Lp);ut(ut({},Qp),tg);function rg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function sa(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const oa=sa("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),Dn=sa("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=rg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),ig=ut({utf8:oa,"utf-8":oa,hex:na.base16,latin1:Dn,ascii:Dn,binary:Dn},na);function ng(t,e="utf8"){const r=ig[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}const aa="wc",sg=2,xn="core",Ur=`${aa}@${2}:${xn}:`,og={name:xn,logger:"error"},ag={database:":memory:"},cg="crypto",ca="client_ed25519_seed",ug=Ie.ONE_DAY,hg="keychain",fg="0.3",lg="messages",dg="0.3",pg=Ie.SIX_HOURS,gg="publisher",ua="irn",vg="error",yg="wss://relay.walletconnect.com",_g="relayer",Mr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},bg="_subscription",dr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},mg=Ie.ONE_SECOND,wg="2.0.0-rc.1",Eg="0.3",Qt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},Dg="subscription",xg="0.3",Sg=Ie.FIVE_SECONDS*1e3;class Og{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=hg,this.version=fg,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,io(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?no(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 Ag{constructor(e,r,i){this.core=e,this.logger=r,this.name=cg,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=Bo(n);return $o(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=of();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),c=Bo(s),u=Zi();return await Td(u,n,ug,c)},this.generateSharedKey=(n,s,c)=>{this.isInitialized();const u=this.getPrivateKey(n),h=af(u,s);return this.setSymKey(h,c)},this.setSymKey=async(n,s)=>{this.isInitialized();const c=s||cf(n);return await this.keychain.set(c,n),c},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,c)=>{this.isInitialized();const u=Xs(c),h=_r(s);if(Zs(u)){const C=u.senderPublicKey,x=u.receiverPublicKey;n=await this.generateSharedKey(C,x)}const d=this.getSymKey(n),{type:g,senderPublicKey:D}=u;return hf({type:g,symKey:d,message:h,senderPublicKey:D})},this.decode=async(n,s,c)=>{this.isInitialized();const u=df(s,c);if(Zs(u)){const g=u.receiverPublicKey,D=u.senderPublicKey;n=await this.generateSharedKey(g,D)}const h=this.getSymKey(n),d=ff({symKey:h,encoded:s});return Oi(d)},this.core=e,this.logger=Se.generateChildLogger(r,this.name),this.keychain=i||new Og(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(ca)}catch{e=Zi(),await this.keychain.set(ca,e)}return ng(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 Ig extends od{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=lg,this.version=dg,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 c=this.messages.get(i);return typeof c>"u"&&(c={}),typeof c[s]<"u"||(c[s]=n,this.messages.set(i,c),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),c=Zr(n);return typeof s[c]<"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,io(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?no(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 Tg extends ad{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new ai.EventEmitter,this.name=gg,this.queue=new Map,this.publish=async(i,n,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});try{const c=s?.ttl||pg,u=Qi(s),h=s?.prompt||!1,d=s?.tag||0,g={topic:i,message:n,opts:{ttl:c,relay:u,prompt:h,tag:d}},D=Zr(n);this.queue.set(D,g),await this.rpcPublish(i,n,c,u,h,d),this.onPublish(D,g),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}})}catch(c){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(c),c}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Se.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Se.getLoggerContext(this.logger)}rpcPublish(e,r,i,n,s,c){var u,h,d,g;const D={method:en(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:c}};return Et((u=D.params)==null?void 0:u.prompt)&&((h=D.params)==null||delete h.prompt),Et((d=D.params)==null?void 0:d.tag)&&((g=D.params)==null||delete g.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:D}),this.relayer.provider.request(D)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:i,opts:{ttl:n,relay:s,prompt:c,tag:u}}=e,h=Zr(i);await this.rpcPublish(r,i,n,s,c,u),this.onPublish(h,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Nr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Cg{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 Lg=Object.defineProperty,Ng=Object.defineProperties,Pg=Object.getOwnPropertyDescriptors,ha=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Fg=Object.prototype.propertyIsEnumerable,fa=(t,e,r)=>e in t?Lg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ui=(t,e)=>{for(var r in e||(e={}))Rg.call(e,r)&&fa(t,r,e[r]);if(ha)for(var r of ha(e))Fg.call(e,r)&&fa(t,r,e[r]);return t},Sn=(t,e)=>Ng(t,Pg(e));class Ug extends hd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Cg,this.events=new ai.EventEmitter,this.name=Dg,this.version=xg,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),c={topic:i,relay:s};this.pending.set(i,c);const u=await this.rpcSubscribe(i,s);return this.onSubscribe(u,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}}),u}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>this.topics.includes(i)?!0:await new Promise((n,s)=>{const c=new Ie.Watch;c.start(this.pendingSubscriptionWatchLabel);const u=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),n(!0)),c.elapsed(this.pendingSubscriptionWatchLabel)>=Sg&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.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,Sn(ui({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Sn(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,Sn(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 Mg=Object.defineProperty,la=Object.getOwnPropertySymbols,jg=Object.prototype.hasOwnProperty,$g=Object.prototype.propertyIsEnumerable,da=(t,e,r)=>e in t?Mg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bg=(t,e)=>{for(var r in e||(e={}))jg.call(e,r)&&da(t,r,e[r]);if(la)for(var r of la(e))$g.call(e,r)&&da(t,r,e[r]);return t};class zg extends cd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new ai.EventEmitter,this.name=_g,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||vg})),this.messages=new Ig(this.logger,e.core),this.subscriber=new Ug(this,this.logger),this.publisher=new Tg(this,this.logger),this.relayUrl=e?.relayUrl||yg,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 Ld(Af({sdkVersion:wg,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}),Wn(e)){if(!e.method.endsWith(bg))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(Bg({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(mg))}),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 Hg=Object.defineProperty,pa=Object.getOwnPropertySymbols,Kg=Object.prototype.hasOwnProperty,qg=Object.prototype.propertyIsEnumerable,ga=(t,e,r)=>e in t?Hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,va=(t,e)=>{for(var r in e||(e={}))Kg.call(e,r)&&ga(t,r,e[r]);if(pa)for(var r of pa(e))qg.call(e,r)&&ga(t,r,e[r]);return t};class On extends ud{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=Eg,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):Yf(s)&&this.map.set(s.topic,s)}),this.cached=[],this.initialized=!0)},this.set=async(s,c)=>{this.isInitialized(),this.map.has(s)?await this.update(s,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:s,value:c}),this.map.set(s,c),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(c=>Object.keys(s).every(u=>Nd(c[u],s[u]))):this.values,this.update=async(s,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:s,update:c});const u=va(va({},this.getData(s)),c);this.map.set(s,u),await this.persist()},this.delete=async(s,c)=>{this.isInitialized(),this.map.has(s)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:s,reason:c}),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 Vg=Object.defineProperty,ya=Object.getOwnPropertySymbols,Gg=Object.prototype.hasOwnProperty,Wg=Object.prototype.propertyIsEnumerable,_a=(t,e,r)=>e in t?Vg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ba=(t,e)=>{for(var r in e||(e={}))Gg.call(e,r)&&_a(t,r,e[r]);if(ya)for(var r of ya(e))Wg.call(e,r)&&_a(t,r,e[r]);return t};class An extends nd{constructor(e){super(e),this.protocol=aa,this.version=sg,this.name=xn,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||og.logger}));this.logger=Se.generateChildLogger(r,this.name),this.heartbeat=new Nr.HeartBeat,this.crypto=new Ag(this,this.logger,e?.keychain),this.storage=e!=null&&e.storage?e.storage:new kl(ba(ba({},ag),e?.storageOptions)),this.relayer=new zg({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId})}static async init(e){const r=new An(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 kg=An;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(!Yg(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||jr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],ma(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),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},Ve.prototype.addListener=function(t,e){var r;if(!Ut(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ut(e.listener)?e.listener:e),this._events[t]?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&&(ma(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 Yg(t){return typeof t=="number"}function jr(t){return typeof t=="object"&&t!==null}function ma(t){return t===void 0}const wa="wc",Ea=2,Da="client",$r=`${wa}@${Ea}:${Da}:`,In={name:Da,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Jg="expirer",Dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Xg="0.3",Tt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Zg="history",Qg="0.3",e0="pairing",t0="proposal",xa=cr(Ie.THIRTY_DAYS),r0="session",i0=Ie.SEVEN_DAYS,fi=cr(i0),n0="engine",Tn={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 s0=Object.defineProperty,o0=Object.defineProperties,a0=Object.getOwnPropertyDescriptors,Sa=Object.getOwnPropertySymbols,c0=Object.prototype.hasOwnProperty,u0=Object.prototype.propertyIsEnumerable,Oa=(t,e,r)=>e in t?s0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e)=>{for(var r in e||(e={}))c0.call(e,r)&&Oa(t,r,e[r]);if(Sa)for(var r of Sa(e))u0.call(e,r)&&Oa(t,r,e[r]);return t},Aa=(t,e)=>o0(t,a0(e));class h0 extends pd{constructor(e){super(e),this.events=new hi,this.initialized=!1,this.name=n0,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 c=i,u,h=!1;if(c&&(h=this.client.pairing.get(c).active),!c||!h){const{topic:L,uri:$}=await this.createPairing();c=L,u=$}const d=await this.client.core.crypto.generateKeyPair(),g={requiredNamespaces:n,relays:s??[{protocol:ua}],proposer:{publicKey:d,metadata:this.client.metadata}},{reject:D,resolve:C,done:x}=Jt();if(this.events.once(Re("session_connect"),async({error:L,session:$})=>{if(L)D(L);else if($){$.self.publicKey=d;const E=Aa(Kt({},$),{requiredNamespaces:n});await this.client.session.set($.topic,E),await this.setExpiry($.topic,$.expiry),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),C(E)}}),!c){const{message:L}=G("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(L)}const w=await this.sendRequest(c,"wc_sessionPropose",g),R=cr(Ie.FIVE_MINUTES);return await this.setProposal(w,Kt({id:w,expiry:R},g)),{uri:u,approval:x}},this.pair=async r=>{this.isInitialized(),this.isValidPair(r);const{topic:i,symKey:n,relay:s}=Mf(r.uri),c=cr(Ie.FIVE_MINUTES),u={topic:i,relay:s,expiry:c,active:!1};return await this.client.pairing.set(i,u),await this.client.core.crypto.setSymKey(n,i),await this.client.core.relayer.subscribe(i,{relay:s}),await this.setExpiry(i,c),u},this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:i,relayProtocol:n,namespaces:s}=r,{pairingTopic:c,proposer:u,requiredNamespaces:h}=this.client.proposal.get(i),d=await this.client.core.crypto.generateKeyPair(),g=u.publicKey,D=await this.client.core.crypto.generateSharedKey(d,g),C={relay:{protocol:n??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:d,metadata:this.client.metadata},expiry:fi};await this.client.core.relayer.subscribe(D);const x=await this.sendRequest(D,"wc_sessionSettle",C),{done:w,resolve:R,reject:L}=Jt();this.events.once(Re("session_approve",x),({error:E})=>{E?L(E):R(this.client.session.get(D))});const $=Aa(Kt({},C),{topic:D,acknowledged:!1,self:C.controller,peer:{publicKey:u.publicKey,metadata:u.metadata},controller:d});return await this.client.session.set(D,$),await this.setExpiry(D,fi),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),c&&i&&(await this.sendResult(i,c,{relay:{protocol:n??"irn"},responderPublicKey:d}),await this.client.proposal.delete(i,rt("USER_DISCONNECTED")),await this.activatePairing(c)),{topic:D,acknowledged:w}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:i,reason:n}=r,{pairingTopic:s}=this.client.proposal.get(i);s&&(await this.sendError(i,s,n),await this.client.proposal.delete(i,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:c,resolve:u,reject:h}=Jt();return this.events.once(Re("session_update",s),({error:d})=>{d?h(d):u()}),await this.client.session.update(i,{namespaces:n}),{acknowledged:c}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:i}=r,n=await this.sendRequest(i,"wc_sessionExtend",{}),{done:s,resolve:c,reject:u}=Jt();return this.events.once(Re("session_extend",n),({error:h})=>{h?u(h):c()}),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,c=await this.sendRequest(s,"wc_sessionRequest",{request:n,chainId:i}),{done:u,resolve:h,reject:d}=Jt();return this.events.once(Re("session_request",c),({error:g,result:D})=>{g?d(g):h(D)}),await u()},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:c,reject:u}=Jt();this.events.once(Re("session_ping",n),({error:h})=>{h?u(h):c()}),await s()}else if(this.client.pairing.keys.includes(i)){const n=await this.sendRequest(i,"wc_pairingPing",{}),{done:s,resolve:c,reject:u}=Jt();this.events.once(Re("pairing_ping",n),({error:h})=>{h?u(h):c()}),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=>Vf(i,r))),this.activatePairing=async r=>{await this.client.pairing.update(r,{active:!0,expiry:xa}),await this.setExpiry(r,xa)},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),c=await this.client.core.crypto.encode(r,s),u=Tn[i].req;return await this.client.core.relayer.publish(r,c,u),this.client.history.set(r,s),s.id},this.sendResult=async(r,i,n)=>{const s=Di(r,n),c=await this.client.core.crypto.encode(i,s),u=await this.client.history.get(i,r),h=Tn[u.request.method].res;await this.client.core.relayer.publish(i,c,h),await this.client.history.resolve(s)},this.sendError=async(r,i,n)=>{const s=qr(r,n),c=await this.client.core.crypto.encode(i,s),u=await this.client.history.get(i,r),h=Tn[u.request.method].res;await this.client.core.relayer.publish(i,c,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 c=cr(Ie.FIVE_MINUTES),u=Kt({id:s,pairingTopic:r,expiry:c},n);await this.setProposal(s,u),this.client.events.emit("session_proposal",{id:s,params:u})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},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 c=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const u=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const d=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:d});const g=await this.client.core.relayer.subscribe(d);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),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:c,controller:u,expiry:h,namespaces:d}=i.params,g={topic:r,relay:c,expiry:h,namespaces:d,acknowledged:!0,controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}};await this.sendResult(i.id,r,!0),this.events.emit(Re("session_connect"),{session:g})}catch(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;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(c){await this.sendError(s,r,c),this.client.logger.error(c)}},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(c){await this.sendError(n,r,c),this.client.logger.error(c)}},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(c){await this.sendError(n,r,c),this.client.logger.error(c)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,relays:s}=r;Et(i)||await this.isValidPairingTopic(i);const c=Qf(n,"connect()");if(c)throw new Error(c.message);if(!el(s,!0)){const{message:u}=G("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(u)}},this.isValidPair=r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`pair() params: ${r}`);throw new Error(i)}if(!Wf(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 c=this.client.proposal.get(i),u=nn(n,"approve()");if(u)throw new Error(u.message);const h=_o(c.requiredNamespaces,n,"update()");if(h)throw new Error(h.message);if(!ot(s,!0)){const{message:d}=G("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(d)}},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),!rl(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:d}=G("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(d)}const{relay:i,controller:n,namespaces:s,expiry:c}=r;if(!vo(i)){const{message:d}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(d)}const u=Jf(n,"onSessionSettleRequest()");if(u)throw new Error(u.message);const h=nn(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(Yt(c)){const{message:d}=G("EXPIRED","onSessionSettleRequest()");throw new Error(d)}},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),c=nn(n,"update()");if(c)throw new Error(c.message);const u=_o(s.requiredNamespaces,n,"update()");if(u)throw new Error(u.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:u}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:i,request:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!yo(c,s)){const{message:u}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!il(n)){const{message:u}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!ol(c,s,n.method)){const{message:u}=G("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}},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),!nl(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:u}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(u)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!yo(c,s)){const{message:u}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(u)}if(!sl(n)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}if(!al(c,s,n.name)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(u)}},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:ua},s={topic:r,expiry:i,relay:n,active:!1},c=$f({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:c}}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);Wn(n)?(this.client.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):kn(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}=Cf(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(!tl(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 f0 extends gd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new hi.EventEmitter,this.name=Jg,this.version=Xg,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),c={target:s,expiry:n};this.expirations.set(s,c),this.checkExpiry(s,c),this.events.emit(Dt.created,{target:s,expiration:c})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{this.isInitialized();const n=this.formatTarget(i);if(this.has(n)){const s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(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 If(e);if(typeof e=="number")return Tf(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 l0 extends sd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new hi.EventEmitter,this.name=Zg,this.version=Qg,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 c={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s};this.records.set(c.id,c),this.events.emit(Tt.created,c)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=wt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.events.emit(Tt.updated,n))},this.get=async(i,n)=>{this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n});const s=await this.getRecord(n);if(s.topic!==i){const{message:c}=G("MISMATCHED_TOPIC",`${this.name}, ${n}`);throw this.logger.error(c),new Error(c)}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(Tt.deleted,s)}})},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=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(Tt.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(Tt.created,e=>{const r=Tt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.updated,e=>{const r=Tt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Tt.deleted,e=>{const r=Tt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class d0 extends On{constructor(e,r){super(e,r,e0,$r),this.core=e,this.logger=r}}class p0 extends On{constructor(e,r){super(e,r,t0,$r),this.core=e,this.logger=r}}class g0 extends On{constructor(e,r){super(e,r,r0,$r),this.core=e,this.logger=r}}class Cn extends dd{constructor(e){super(e),this.protocol=wa,this.version=Ea,this.name=In.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||In.name,this.metadata=e?.metadata||Df();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:sn(Se.getDefaultLoggerOptions({level:e?.logger||In.logger}));this.core=e?.core||new kg(e),this.logger=Se.generateChildLogger(r,this.name),this.pairing=new d0(this.core,this.logger),this.session=new g0(this.core,this.logger),this.proposal=new p0(this.core,this.logger),this.history=new l0(this.core,this.logger),this.expirer=new f0(this.core,this.logger),this.engine=new h0(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 v0=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!y0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,i,n,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Br(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ia(r))return!1;if(Mt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(Br(r))for(n=Array.prototype.slice.call(arguments,1),c=r.slice(),i=c.length,s=0;s<i;s++)c[s].apply(this,n);return!0},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&&(Ia(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 y0(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function Ia(t){return t===void 0}function _0(t){return typeof t<"u"&&typeof t.context<"u"}const Ct={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class b0 extends ec{constructor(e){super(),this.events=new v0.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):nf(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(Ct.uri,{uri:i}),this.session=await n(),this.events.emit(Ct.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason: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(Ct.init,()=>{if(typeof this.client>"u")return i(new Error("Sign Client not initialized"));r(this.client)})});if(_0(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(Ct.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(Ct.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(Ct.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(Ct.deleted,this.session),this.session=void 0)}))}}const m0=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],w0=["chainChanged","accountsChanged"];function Ta(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Ca(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Ln([t])]),r}function Ln(t){return Number(t[0].split(":")[1])}class E0{constructor(e){this.events=new gr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=Ta(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Ln(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(i=>r(null,i)).catch(i=>r(i,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(Ct.created,e=>{const r=Wi(e.namespaces,[this.namespace]);this.setChainIds(r);const i=Gi(e.namespaces,[this.namespace]);this.setAccounts(i)}),this.signer.connection.on(Ct.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(Ct.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new b0({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=Ca(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new xi(new ac(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=E0,mt.getEthereumChainId=Ln,mt.getRpcConfig=Ta,mt.getRpcUrl=Ca,mt.signerEvents=w0,mt.signerMethods=m0,Object.defineProperty(mt,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|