1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9005],{1183:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromMiliseconds=t.toMiliseconds=void 0;let i=r(52892);t.toMiliseconds=function(e){return e*i.ONE_THOUSAND},t.fromMiliseconds=function(e){return Math.floor(e/i.ONE_THOUSAND)}},4839:(e,t,r)=>{"use strict";r.d(t,{IJsonRpcProvider:()=>o.kF,formatJsonRpcError:()=>n.dZ,formatJsonRpcRequest:()=>n.e_,formatJsonRpcResult:()=>n.Im,getBigIntRpcId:()=>n.eX,isHttpUrl:()=>a.q$,isJsonRpcError:()=>c.U$,isJsonRpcRequest:()=>c.p3,isJsonRpcResponse:()=>c.tq,isJsonRpcResult:()=>c.xT,isLocalhostUrl:()=>a.z,isWsUrl:()=>a.A1,parseConnectionError:()=>i.eF,payloadId:()=>n.ER}),r(85874);var i=r(46665),s=r(8772);r.o(s,"IJsonRpcProvider")&&r.d(t,{IJsonRpcProvider:function(){return s.IJsonRpcProvider}}),r.o(s,"formatJsonRpcError")&&r.d(t,{formatJsonRpcError:function(){return s.formatJsonRpcError}}),r.o(s,"formatJsonRpcRequest")&&r.d(t,{formatJsonRpcRequest:function(){return s.formatJsonRpcRequest}}),r.o(s,"formatJsonRpcResult")&&r.d(t,{formatJsonRpcResult:function(){return s.formatJsonRpcResult}}),r.o(s,"getBigIntRpcId")&&r.d(t,{getBigIntRpcId:function(){return s.getBigIntRpcId}}),r.o(s,"isHttpUrl")&&r.d(t,{isHttpUrl:function(){return s.isHttpUrl}}),r.o(s,"isJsonRpcError")&&r.d(t,{isJsonRpcError:function(){return s.isJsonRpcError}}),r.o(s,"isJsonRpcRequest")&&r.d(t,{isJsonRpcRequest:function(){return s.isJsonRpcRequest}}),r.o(s,"isJsonRpcResponse")&&r.d(t,{isJsonRpcResponse:function(){return s.isJsonRpcResponse}}),r.o(s,"isJsonRpcResult")&&r.d(t,{isJsonRpcResult:function(){return s.isJsonRpcResult}}),r.o(s,"isLocalhostUrl")&&r.d(t,{isLocalhostUrl:function(){return s.isLocalhostUrl}}),r.o(s,"isReactNative")&&r.d(t,{isReactNative:function(){return s.isReactNative}}),r.o(s,"isWsUrl")&&r.d(t,{isWsUrl:function(){return s.isWsUrl}}),r.o(s,"payloadId")&&r.d(t,{payloadId:function(){return s.payloadId}});var n=r(80706),o=r(27039),a=r(96346),c=r(28178)},7791:(e,t,r)=>{"use strict";r.d(t,{Vw:()=>p,Fc:()=>l,Id:()=>u,O8:()=>o,qv:()=>c,po:()=>f,Ow:()=>a,ZJ:()=>h,DH:()=>n,ld:()=>d});let i="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;var s=r(44150);function n(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function o(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function a(e,t){return e<<32-t|e>>>t}let c=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function l(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function h(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),(0,s.DO)(e),e}function u(...e){let t=0;for(let r=0;r<e.length;r++){let i=e[r];(0,s.DO)(i),t+=i.length}let r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}class p{clone(){return this._cloneInto()}}function d(e){let t=t=>e().update(h(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function f(e=32){if(i&&"function"==typeof i.getRandomValues)return i.getRandomValues(new Uint8Array(e));if(i&&"function"==typeof i.randomBytes)return i.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}},7915:(e,t,r)=>{"use strict";r.d(t,{F:()=>n});var i=r(69319),s=r(4839);class n extends s.IJsonRpcProvider{constructor(e){super(e),this.events=new i.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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict((0,s.formatJsonRpcRequest)(e.method,e.params||[],e.id||(0,s.getBigIntRpcId)().toString()),t)}async requestStrict(e,t){return new Promise(async(r,i)=>{if(!this.connection.connected)try{await this.open()}catch(e){i(e)}this.events.on(`${e.id}`,e=>{(0,s.isJsonRpcError)(e)?i(e.error):r(e.result)});try{await this.connection.send(e,t)}catch(e){i(e)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),(0,s.isJsonRpcResponse)(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}
1async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(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",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}},8012:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});class i{}},8772:(e,t,r)=>{"use strict";var i=r(22686);r.o(i,"IJsonRpcProvider")&&r.d(t,{IJsonRpcProvider:function(){return i.IJsonRpcProvider}}),r.o(i,"formatJsonRpcError")&&r.d(t,{formatJsonRpcError:function(){return i.formatJsonRpcError}}),r.o(i,"formatJsonRpcRequest")&&r.d(t,{formatJsonRpcRequest:function(){return i.formatJsonRpcRequest}}),r.o(i,"formatJsonRpcResult")&&r.d(t,{formatJsonRpcResult:function(){return i.formatJsonRpcResult}}),r.o(i,"getBigIntRpcId")&&r.d(t,{getBigIntRpcId:function(){return i.getBigIntRpcId}}),r.o(i,"isHttpUrl")&&r.d(t,{isHttpUrl:function(){return i.isHttpUrl}}),r.o(i,"isJsonRpcError")&&r.d(t,{isJsonRpcError:function(){return i.isJsonRpcError}}),r.o(i,"isJsonRpcRequest")&&r.d(t,{isJsonRpcRequest:function(){return i.isJsonRpcRequest}}),r.o(i,"isJsonRpcResponse")&&r.d(t,{isJsonRpcResponse:function(){return i.isJsonRpcResponse}}),r.o(i,"isJsonRpcResult")&&r.d(t,{isJsonRpcResult:function(){return i.isJsonRpcResult}}),r.o(i,"isLocalhostUrl")&&r.d(t,{isLocalhostUrl:function(){return i.isLocalhostUrl}}),r.o(i,"isReactNative")&&r.d(t,{isReactNative:function(){return i.isReactNative}}),r.o(i,"isWsUrl")&&r.d(t,{isWsUrl:function(){return i.isWsUrl}}),r.o(i,"payloadId")&&r.d(t,{payloadId:function(){return i.payloadId}})},13760:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_THOUSAND=t.ONE_HUNDRED=void 0,t.ONE_HUNDRED=100,t.ONE_THOUSAND=1e3},15063:(e,t,r)=>{"use strict";t.g=void 0;let i=r(98534);t.g=function(){let e,t,r;try{e=i.getDocumentOrThrow(),t=i.getLocationOrThrow()}catch(e){return null}function s(...t){let r=e.getElementsByTagName("meta");for(let e=0;e<r.length;e++){let i=r[e],s=["itemprop","property","name"].map(e=>i.getAttribute(e)).filter(e=>!!e&&t.includes(e));if(s.length&&s){let e=i.getAttribute("content");if(e)return e}}return""}let n=((r=s("name","og:site_name","og:title","twitter:title"))||(r=e.title),r),o=s("description","og:description","twitter:description","keywords"),a=t.origin;return{description:o,url:a,icons:function(){let r=e.getElementsByTagName("link"),i=[];for(let e=0;e<r.length;e++){let s=r[e],n=s.getAttribute("rel");if(n&&n.toLowerCase().indexOf("icon")>-1){let e=s.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let r=t.protocol+"//"+t.host;if(0===e.indexOf("/"))r+=e;else{let i=t.pathname.split("/");i.pop(),r+=i.join("/")+"/"+e}i.push(r)}else if(0===e.indexOf("//")){let r=t.protocol+e;i.push(r)}else i.push(e)}}return i}(),name:n}}},18498:(e,t,r)=>{var i="u">typeof globalThis&&globalThis||"u">typeof self&&self||void 0!==r.g&&r.g,s=function(){function e(){this.fetch=!1,this.DOMException=i.DOMException}return e.prototype=i,new e}();(function(e){var t=void 0!==s&&s||"u">typeof self&&self||void 0!==r.g&&r.g||{},i={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(i.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function a(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function c(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i.iterable&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(2!=e.length)throw TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function u(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(TypeError("Already read"));e.bodyUsed=!0}}function p(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function d(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function f(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){if(this.bodyUsed=this.bodyUsed,this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(i.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(i.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else{var t;i.arrayBuffer&&i.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=f(e):this._bodyText=e=Object.prototype.toString.call(e)}else this._noBody=!0,this._bodyText="";!this.headers.get("content-type")&&("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(!this._bodyFormData)return Promise.resolve(new Blob([this._bodyText]));throw Error("could not read FormData body as blob")}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=u(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i.blob)return this.blob().then(d);throw Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,i,s,n=u(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=p(t=new FileReader),s=(i=/charset=([A-Za-z0-9_-]+)/.exec(e.type))?i[1]:"utf-8",t.readAsText(e,s),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(!this._bodyFormData)return Promise.resolve(this._bodyText);throw Error("could not read FormData body as text")},i.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=a(e),t=c(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},h.prototype.delete=function(e){delete this.map[a(e)]},h.prototype.get=function(e){return e=a(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(a(e))},h.prototype.set=function(e,t){this.map[a(e)]=c(t)},h.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},h.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),l(e)},h.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),l(e)},h.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),l(e)},i.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function m(e,r){if(!(this instanceof m))throw TypeError('Please use the "new" operator, this DOM object c
1onstructor cannot be called as a function.');var i,s,n=(r=r||{}).body;if(e instanceof m){if(e.bodyUsed)throw TypeError("Already read");this.url=e.url,this.credentials=e.credentials,r.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=r.credentials||this.credentials||"same-origin",(r.headers||!this.headers)&&(this.headers=new h(r.headers)),this.method=(s=(i=r.method||this.method||"GET").toUpperCase(),y.indexOf(s)>-1?s:i),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return new AbortController().signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),("GET"===this.method||"HEAD"===this.method)&&("no-store"===r.cache||"no-cache"===r.cache)){var o=/([?&])_=[^&]*/;o.test(this.url)?this.url=this.url.replace(o,"$1_="+new Date().getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+new Date().getTime()}}function b(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(s))}}),t}function w(e,t){if(!(this instanceof w))throw TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},g.call(m.prototype),g.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var v=[301,302,303,307,308];w.redirect=function(e,t){if(-1===v.indexOf(t))throw RangeError("Invalid status code");return new w(null,{status:t,headers:{location:e}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function E(r,s){return new Promise(function(n,o){var l=new m(r,s);if(l.signal&&l.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function p(){u.abort()}if(u.onload=function(){var e,t,r={statusText:u.statusText,headers:(e=u.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e}).forEach(function(e){var r=e.split(":"),i=r.shift().trim();if(i){var s=r.join(":").trim();try{t.append(i,s)}catch(e){console.warn("Response "+e.message)}}}),t)};0===l.url.indexOf("file://")&&(u.status<200||u.status>599)?r.status=200:r.status=u.status,r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;setTimeout(function(){n(new w(i,r))},0)},u.onerror=function(){setTimeout(function(){o(TypeError("Network request failed"))},0)},u.ontimeout=function(){setTimeout(function(){o(TypeError("Network request timed out"))},0)},u.onabort=function(){setTimeout(function(){o(new e.DOMException("Aborted","AbortError"))},0)},u.open(l.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(l.url),!0),"include"===l.credentials?u.withCredentials=!0:"omit"===l.credentials&&(u.withCredentials=!1),"responseType"in u&&(i.blob?u.responseType="blob":i.arrayBuffer&&(u.responseType="arraybuffer")),s&&"object"==typeof s.headers&&!(s.headers instanceof h||t.Headers&&s.headers instanceof t.Headers)){var d=[];
1Object.getOwnPropertyNames(s.headers).forEach(function(e){d.push(a(e)),u.setRequestHeader(e,c(s.headers[e]))}),l.headers.forEach(function(e,t){-1===d.indexOf(t)&&u.setRequestHeader(t,e)})}else l.headers.forEach(function(e,t){u.setRequestHeader(t,e)});l.signal&&(l.signal.addEventListener("abort",p),u.onreadystatechange=function(){4===u.readyState&&l.signal.removeEventListener("abort",p)}),u.send(void 0===l._bodyInit?null:l._bodyInit)})}E.polyfill=!0,t.fetch||(t.fetch=E,t.Headers=h,t.Request=m,t.Response=w),e.Headers=h,e.Request=m,e.Response=w,e.fetch=E,Object.defineProperty(e,"__esModule",{value:!0})})({}),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var n=i.fetch?i:s;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},22686:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(95502);i.__exportStar(r(79195),t),i.__exportStar(r(83145),t)},27036:(e,t,r)=>{"use strict";r.d(t,{A:()=>S});let i=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,s=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function o(e,t){var r;return"__proto__"===e||"constructor"===e&&t&&"object"==typeof t&&"prototype"in t?void(r=e,console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)):t}function a(e,t={}){if("string"!=typeof e)return e;if('"'===e[0]&&'"'===e[e.length-1]&&-1===e.indexOf("\\"))return e.slice(1,-1);let r=e.trim();if(r.length<=9)switch(r.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return NaN;case"infinity":return 1/0;case"-infinity":return-1/0}if(!n.test(e)){if(t.strict)throw SyntaxError("[destr] Invalid JSON");return e}try{if(i.test(e)||s.test(e)){if(t.strict)throw Error("[destr] Possible prototype pollution");return JSON.parse(e,o)}return JSON.parse(e)}catch(r){if(t.strict)throw r;return e}}var c=r(82909).hp;function l(e,...t){try{var r;return(r=e(...t))&&"function"==typeof r.then?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}function h(e){let t,r;if(t=typeof e,null===e||"object"!==t&&"function"!==t)return String(e);if(!(r=Object.getPrototypeOf(e))||r.isPrototypeOf(Object)||Array.isArray(e))return JSON.stringify(e);if("function"==typeof e.toJSON)return h(e.toJSON());throw Error("[unstorage] Cannot stringify value!")}let u="base64:";function p(e){return e&&e.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function d(e){return(e=p(e))?e+":":""}function f(e,t,r){return e.watch?e.watch((e,i)=>t(e,r+i)):()=>{}}async function g(e){"function"==typeof e.dispose&&await l(e.dispose)}var y=r(87490),m=r(66602);class b{constructor(){this.indexedDb=function(e={}){let t,r={mounts:{"":e.driver||(t=new Map,{name:"memory",getInstance:()=>t,hasItem:e=>t.has(e),getItem:e=>t.get(e)??null,getItemRaw:e=>t.get(e)??null,setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys:()=>[...t.keys()],clear(){t.clear()},dispose(){t.clear()}})},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},i=e=>{for(let t of r.mountpoints)if(e.startsWith(t))return{base:t,relativeKey:e.slice(t.length),driver:r.mounts[t]};return{base:"",relativeKey:e,driver:r.mounts[""]}},s=(e,t)=>r.mountpoints.filter(r=>r.startsWith(e)||t&&e.startsWith(r)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,mountpoint:t,driver:r.mounts[t]})),n=(e,t)=>{if(r.watching)for(let i of(t=p(t),r.watchListeners))i(e,t)},o=async()=>{if(!r.watching)for(let e in r.watching=!0,r.mounts)r.unwatch[e]=await f(r.mounts[e],n,e)},y=async()=>{if(r.watching){for(let e in r.unwatch)await r.unwatch[e]();r.unwatch={},r.watching=!1}},m=(e,t,r)=>{let s=new Map,n=e=>{let t=s.get(e.base);return t||(t={driver:e.driver,base:e.base,items:[]},s.set(e.base,t)),t};for(let r of e){let e="string"==typeof r,s=p(e?r:r.key),o=e?void 0:r.value,a=e||!r.options?t:{...t,...r.options},c=i(s);n(c).items.push({key:s,value:o,relativeKey:c.relativeKey,options:a})}return Promise.all([...s.values()].map(e=>r(e))).then(e=>e.flat())},b={hasItem(e,t={}){let{relativeKey:r,driver:s}
1=i(e=p(e));return l(s.hasItem,r,t)},getItem(e,t={}){let{relativeKey:r,driver:s}=i(e=p(e));return l(s.getItem,r,t).then(e=>a(e))},getItems:(e,t={})=>m(e,t,e=>e.driver.getItems?l(e.driver.getItems,e.items.map(e=>({key:e.relativeKey,options:e.options})),t).then(t=>t.map(t=>({key:function(...e){return p(e.join(":"))}(e.base,t.key),value:a(t.value)}))):Promise.all(e.items.map(t=>l(e.driver.getItem,t.relativeKey,t.options).then(e=>({key:t.key,value:a(e)}))))),getItemRaw(e,t={}){let{relativeKey:r,driver:s}=i(e=p(e));return s.getItemRaw?l(s.getItemRaw,r,t):l(s.getItem,r,t).then(e=>{var t;return"string"==typeof e&&e.startsWith(u)?(t=e.slice(u.length),globalThis.Buffer?c.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))):e})},async setItem(e,t,r={}){if(void 0===t)return b.removeItem(e);let{relativeKey:s,driver:o}=i(e=p(e));o.setItem&&(await l(o.setItem,s,h(t),r),o.watch||n("update",e))},async setItems(e,t){await m(e,t,async e=>{if(e.driver.setItems)return l(e.driver.setItems,e.items.map(e=>({key:e.relativeKey,value:h(e.value),options:e.options})),t);e.driver.setItem&&await Promise.all(e.items.map(t=>l(e.driver.setItem,t.relativeKey,h(t.value),t.options)))})},async setItemRaw(e,t,r={}){if(void 0===t)return b.removeItem(e,r);let{relativeKey:s,driver:o}=i(e=p(e));if(o.setItemRaw)await l(o.setItemRaw,s,t,r);else{var a;if(!o.setItem)return;await l(o.setItem,s,"string"==typeof t?t:u+(a=t,globalThis.Buffer?c.from(a).toString("base64"):globalThis.btoa(String.fromCodePoint(...a))),r)}o.watch||n("update",e)},async removeItem(e,t={}){"boolean"==typeof t&&(t={removeMeta:t});let{relativeKey:r,driver:s}
1=i(e=p(e));s.removeItem&&(await l(s.removeItem,r,t),(t.removeMeta||t.removeMata)&&await l(s.removeItem,r+"$",t),s.watch||n("remove",e))},async getMeta(e,t={}){"boolean"==typeof t&&(t={nativeOnly:t});let{relativeKey:r,driver:s}=i(e=p(e)),n=Object.create(null);if(s.getMeta&&Object.assign(n,await l(s.getMeta,r,t)),!t.nativeOnly){let e=await l(s.getItem,r+"$",t).then(e=>a(e));e&&"object"==typeof e&&("string"==typeof e.atime&&(e.atime=new Date(e.atime)),"string"==typeof e.mtime&&(e.mtime=new Date(e.mtime)),Object.assign(n,e))}return n},setMeta(e,t,r={}){return this.setItem(e+"$",t,r)},removeMeta(e,t={}){return this.removeItem(e+"$",t)},async getKeys(e,t={}){let r=s(e=d(e),!0),i=[],n=[],o=!0;for(let e of r){for(let r of(e.driver.flags?.maxDepth||(o=!1),await l(e.driver.getKeys,e.relativeBase,t))){let t=e.mountpoint+p(r);i.some(e=>t.startsWith(e))||n.push(t)}i=[e.mountpoint,...i.filter(t=>!t.startsWith(e.mountpoint))]}let a=void 0!==t.maxDepth&&!o;return n.filter(r=>{var i;return(!a||function(e,t){if(void 0===t)return!0;let r=0,i=e.indexOf(":");for(;i>-1;)r++,i=e.indexOf(":",i+1);return r<=t}(r,t.maxDepth))&&((i=e)?r.startsWith(i)&&"$"!==r[r.length-1]:"$"!==r[r.length-1])})},async clear(e,t={}){e=d(e),await Promise.all(s(e,!1).map(async e=>e.driver.clear?l(e.driver.clear,e.relativeBase,t):e.driver.removeItem?Promise.all((await e.driver.getKeys(e.relativeBase||"",t)).map(r=>e.driver.removeItem(r,t))):void 0))},async dispose(){await Promise.all(Object.values(r.mounts).map(e=>g(e)))},watch:async e=>(await o(),r.watchListeners.push(e),async()=>{r.watchListeners=r.watchListeners.filter(t=>t!==e),0===r.watchListeners.length&&await y()}),async unwatch(){r.watchListeners=[],await y()},mount(e,t){if((e=d(e))&&r.mounts[e])throw Error(`already mounted at ${e}`);return e&&(r.mountpoints.push(e),r.mountpoints.sort((e,t)=>t.length-e.length)),r.mounts[e]=t,r.watching&&Promise.resolve(f(t,n,e)).then(t=>{r.unwatch[e]=t}).catch(console.error),b},async unmount(e,t=!0){(e=d(e))&&r.mounts[e]&&(r.watching&&e in r.unwatch&&(r.unwatch[e]?.(),delete r.unwatch[e]),t&&await g(r.mounts[e]),r.mountpoints=r.mountpoints.filter(t=>t!==e),delete r.mounts[e])},getMount(e=""){let t=i(e=p(e)+":");return{driver:t.driver,base:t.base}},getMounts:(e="",t={})=>s(e=p(e),t.parents).map(e=>({driver:e.driver,base:e.mountpoint})),keys:(e,t={})=>b.getKeys(e,t),get:(e,t={})=>b.getItem(e,t),set:(e,t,r={})=>b.setItem(e,t,r),has:(e,t={})=>b.hasItem(e,t),del:(e,t={})=>b.removeItem(e,t),remove:(e,t={})=>b.removeItem(e,t)};return b}({driver:((e={})=>{let t,r=e.base&&e.base.length>0?`${e.base}:`:"";return e.dbName&&e.storeName&&(t=(0,y.y$)(e.dbName,e.storeName)),{name:"idb-keyval",options:e,hasItem:async e=>!(typeof await (0,y.Jt)(r+e,t)>"u"),getItem:async e=>await (0,y.Jt)(r+e,t)??null,setItem:(e,i)=>(0,y.hZ)(r+e,i,t),removeItem:e=>(0,y.yH)(r+e,t),getKeys:()=>(0,y.HP)(t),clear:()=>(0,y.IU)(t)}})({dbName:"WALLET_CONNECT_V2_INDEXED_DB",storeName:"keyvaluestorage"})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(null!==t)return t}async setItem(e,t){await this.indexedDb.setItem(e,(0,m.h)(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var w="u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof r.g?r.g:"u">typeof self?self:{},v={exports:{}};function E(e){var t;return[e[0],(0,m.j)(null!=(t=e[1])?t:"")]}function I(){}I.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},I.prototype.setItem=function(e,t){this[e]=String(t)},I.prototype.removeItem=function(e){delete this[e]},I.prototype.clear=function(){let e=this;Object.keys(e).forEach(function(t){e[t]=void 0,delete e[t]})},I.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},I.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),"u">typeof w&&w.localStorage?v.exports=w.localStorage:"u">typeof window&&window.localStorage?v.exports=window.localStorage:v.exports=new I;
1class x{constructor(){this.localStorage=v.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(E)}async getItem(e){let t=this.localStorage.getItem(e);if(null!==t)return(0,m.j)(t)}async setItem(e,t){this.localStorage.setItem(e,(0,m.h)(t))}async removeItem(e){this.localStorage.removeItem(e)}}let P=async(e,t,r)=>{let i="wc_storage_version",s=await t.getItem(i);if(s&&s>=1)return void r(t);let n=await e.getKeys();if(!n.length)return void r(t);let o=[];for(;n.length;){let r=n.shift();if(!r)continue;let i=r.toLowerCase();if(i.includes("wc@")||i.includes("walletconnect")||i.includes("wc_")||i.includes("wallet_connect")){let i=await e.getItem(r);await t.setItem(r,i),o.push(r)}}await t.setItem(i,1),r(t),O(e,o)},O=async(e,t)=>{t.length&&t.forEach(async t=>{await e.removeItem(t)})};class S{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const e=new x;this.storage=e;try{const t=new b;P(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}},27039:(e,t,r)=>{"use strict";r.d(t,{kF:()=>n});class i{}class s extends i{constructor(){super()}}class n extends s{constructor(e){super()}}},28178:(e,t,r)=>{"use strict";function i(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function s(e){return i(e)&&"method"in e}function n(e){return i(e)&&(o(e)||a(e))}function o(e){return"result"in e}function a(e){return"error"in e}r.d(t,{U$:()=>a,p3:()=>s,tq:()=>n,xT:()=>o})},28627:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0,t.delay=function(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}},34514:(e,t,r)=>{"use strict";r.d(t,{D5:()=>x,U5:()=>I,h6:()=>s.a,iP:()=>v,oI:()=>E});var i=r(91123),s=r.n(i),n=r(66602);let o="custom_context";class a{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class c{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new a(e);if(t.size>this.maxSizeInBytes)throw Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?this.tail&&(this.tail.next=t):this.head=t,this.tail=t,this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;null!==t;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}}class l{constructor(e,t=1024e3){this.level=e??"error",this.levelValue=i.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new c(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===i.levels.values.error?console.error(e):t===i.levels.values.warn?console.warn(e):t===i.levels.values.debug?console.debug(e):t===i.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append((0,n.h)({timestamp:new Date().toISOString(),log:e}));let t="string"==typeof e?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new c(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push((0,n.h)({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class h{constructor(e,t=1024e3){this.baseChunkLogger=new l(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),r=document.createElement("a");r.href=t,r.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(t)}}class u{constructor(e,t=1024e3){this.baseChunkLogger=new l(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var p=Object.defineProperty,d=Object.defineProperties,f=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,b=(e,t,r)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))y.call(t,r)&&b(e,r,t[r]);if(g)for(var r of g(t))m.call(t,r)&&b(e,r,t[r]);return e};function v(e){return d(w({},e),f({level:e?.level||"info"}))}function E(e,t=o){return typeof e.bindings>"u"?function(e,t=o){return e[t]||""}(e,t):e.bindings().context||""}function I(e,t,r=o){let i=function(e,t,r=o){let i=E(e,r);return i.trim()?`${i}/${t}`:t}(e,t,r);return function(e,t,r=o){return e[r]=t,e}(e.child({context:i}),i,r)}function x(e){var t,r,i,n;let o,a,c,l;return"u">typeof e.loggerOverride&&"string"!=typeof e.loggerOverride?{logger:e.loggerOverride,chunkLoggerController:null}:"u">typeof window?(l=new h(null==(i=(r=e).opts)?void 0:i.level,r.maxSizeInBytes),{logger:s()((a=w({},r.opts),c={level:"trace",browser:d(w({},null==(n=r.opts)?void 0:n.browser),f({write:e=>l.write(e)}))},d(a,f(c)))),chunkLoggerController:l}):(o=new u(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes),{logger:s()(d(w({},e.opts),f({level:"trace"})),o),chunkLoggerController:o})}},41044:(e,t,r)=>{"use strict";
1Object.defineProperty(t,"__esModule",{value:!0});let i=r(70910);i.__exportStar(r(28627),t),i.__exportStar(r(1183),t)},44150:(e,t,r)=>{"use strict";function i(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function s(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function n(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");i(e.outputLen),i(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function a(e,t){s(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}r.d(t,{CC:()=>o,DO:()=>s,Fe:()=>i,Ht:()=>a,sd:()=>n})},46267:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IWatch=void 0;class r{}t.IWatch=r},46665:(e,t,r)=>{"use strict";r.d(t,{eF:()=>a,mE:()=>s,rI:()=>o,vG:()=>n});var i=r(85874);function s(e){return i.jf.includes(e)}function n(e){return Object.keys(i.Uf).includes(e)?i.Uf[e]:i.Uf[i.XW]}function o(e){let t=Object.values(i.Uf).find(t=>t.code===e);return t||i.Uf[i.XW]}function a(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?Error(`Unavailable ${r} RPC url at ${t}`):e}},49499:e=>{"use strict";function t(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,r,i){var s=i&&i.stringify||t;if("object"==typeof e&&null!==e){var n=r.length+1;if(1===n)return e;var o=Array(n);o[0]=s(e);for(var a=1;a<n;a++)o[a]=s(r[a]);return o.join(" ")}if("string"!=typeof e)return e;var c=r.length;if(0===c)return e;for(var l="",h=0,u=-1,p=e&&e.length||0,d=0;d<p;){if(37===e.charCodeAt(d)&&d+1<p){switch(u=u>-1?u:0,e.charCodeAt(d+1)){case 100:case 102:if(h>=c||null==r[h])break;u<d&&(l+=e.slice(u,d)),l+=Number(r[h]),u=d+2,d++;break;case 105:if(h>=c||null==r[h])break;u<d&&(l+=e.slice(u,d)),l+=Math.floor(Number(r[h])),u=d+2,d++;break;case 79:case 111:case 106:if(h>=c||void 0===r[h])break;u<d&&(l+=e.slice(u,d));var f=typeof r[h];if("string"===f){l+="'"+r[h]+"'",u=d+2,d++;break}if("function"===f){l+=r[h].name||"<anonymous>",u=d+2,d++;break}l+=s(r[h]),u=d+2,d++;break;case 115:if(h>=c)break;u<d&&(l+=e.slice(u,d)),l+=String(r[h]),u=d+2,d++;break;case 37:u<d&&(l+=e.slice(u,d)),l+="%",u=d+2,d++,h--}++h}++d}return -1===u?e:(u<p&&(l+=e.slice(u)),l)}},52652:(e,t,r)=>{"use strict";r.d(t,{o0:()=>d});var i=r(65364),s=function(e,t,r){if(r||2==arguments.length)for(var i,s=0,n=t.length;s<n;s++)!i&&s in t||(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))},n=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},o=function(e){this.version=e,this.type="node",this.name="node",this.os=i.platform},a=function(e,t,r,i){this.name=e,this.version=t,this.os=r,this.bot=i,this.type="bot-device"},c=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},l=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},h=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,u=[["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;
1\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",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],p=[["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 d(e){return e?f(e):"u"<typeof document&&"u">typeof navigator&&"ReactNative"===navigator.product?new l:"u">typeof navigator?f(navigator.userAgent):void 0!==i&&i.version?new o(i.version.slice(1)):null}function f(e){var t=""!==e&&u.reduce(function(t,r){var i=r[0],s=r[1];if(t)return t;var n=s.exec(e);return!!n&&[i,n]},!1);if(!t)return null;var r=t[0],i=t[1];if("searchbot"===r)return new c;var o=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);o?o.length<3&&(o=s(s([],o,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(3-o.length),!0)):o=[];var l=o.join("."),d=function(e){for(var t=0,r=p.length;t<r;t++){var i=p[t],s=i[0];if(i[1].exec(e))return s}return null}(e),f=h.exec(e);return f&&f[1]?new a(r,l,d,f[1]):new n(r,l,d)}},52892:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(70910);i.__exportStar(r(13760),t),i.__exportStar(r(82521),t)},54205:(e,t,r)=>{"use strict";r.d(t,{A:()=>m,V:()=>m});var i=r(69319),s=r(18498),n=r.n(s),o=r(66602),a=r(4839),c=Object.defineProperty,l=Object.defineProperties,h=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,r)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))p.call(t,r)&&f(e,r,t[r]);if(u)for(var r of u(t))d.call(t,r)&&f(e,r,t[r]);return e};let y={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class m{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new i.EventEmitter,this.isAvailable=!1,this.registering=!1,!(0,a.isHttpUrl)(e))throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{let t,r,i=(0,o.h)(e),s=await (await n()(this.url,(t=g({},y),r={body:i},l(t,h(r))))).json();this.onPayload({data:s})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!(0,a.isHttpUrl)(e))throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){let e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((e,t)=>{this.events.once("register_error",e=>{this.resetMaxListeners(),t(e)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return t(Error("HTTP connection is missing or invalid"));e()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){let t,r,i=(0,o.h)({id:1,jsonrpc:"2.0",method:"test",params:[]});await n()(e,(t=g({},y),r={body:i},l(t,h(r))))}this.onOpen()}catch(t){let e=this.parseError(t);throw this.events.emit("register_error",e),this.onClose(),e}}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;let t="string"==typeof e.data?(0,o.j)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let r=this.parseError(t),i=r.message||r.toString(),s=(0,a.formatJsonRpcError)(e,i);this.events.emit("payload",s)}parseError(e,t=this.url){return(0,a.parseConnectionError)(e,t,"HTTP")}
1resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}},56024:(e,t,r)=>{"use strict";let i,s;r.d(t,{Cq:()=>tP,FA:()=>tS,TZ:()=>tO,UF:()=>tx});var n,o=r(71726),a=r(66602);function c(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function l(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}let h="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function p(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),c(e),e}class d{clone(){return this._cloneInto()}}function f(e=32){if(h&&"function"==typeof h.getRandomValues)return h.getRandomValues(new Uint8Array(e));if(h&&"function"==typeof h.randomBytes)return h.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}
1class g extends d{constructor(e,t,r,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=u(this.buffer)}update(e){l(this);let{view:t,buffer:r,blockLen:i}=this,s=(e=p(e)).length;for(let n=0;n<s;){let o=Math.min(i-this.pos,s-n);if(o===i){let t=u(e);for(;i<=s-n;n+=i)this.process(t,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){l(this),function(e,t){c(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:s}=this,{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(r,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),c=4*!!i,l=4*!i;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)})(r,i-8,BigInt(8*this.length),s),this.process(r,0);let o=u(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,p=this.get();if(h>p.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<h;e++)o.setUint32(4*e,p[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:i,finished:s,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=s,e.destroyed=n,i%t&&e.buffer.set(r),e}}let y=BigInt(0x100000000-1),m=BigInt(32),b=(e,t,r)=>e>>>r,w=(e,t,r)=>e<<32-r|t>>>r,v=(e,t,r)=>e>>>r|t<<32-r,E=(e,t,r)=>e<<32-r|t>>>r,I=(e,t,r)=>e<<64-r|t>>>r-32,x=(e,t,r)=>e>>>r-32|t<<64-r,P=function(e,t,r,i){let s=(t>>>0)+(i>>>0);return{h:e+r+(s/0x100000000|0)|0,l:0|s}},O=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),S=(e,t,r,i)=>t+r+i+(e/0x100000000|0)|0,_=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),A=(e,t,r,i,s)=>t+r+i+s+(e/0x100000000|0)|0,R=(e,t,r,i,s,n)=>t+r+i+s+n+(e/0x100000000|0)|0,C=(e,t,r,i,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(s>>>0),[T,N]=function(e,t=!1){let r=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let s=0;s<e.length;s++){let{h:n,l:o}=function(e,t=!1){return t?{h:Number(e&y),l:Number(e>>m&y)}:{h:0|Number(e>>m&y),l:0|Number(e&y)}}(e[s],t);[r[s],i[s]]=[n,o]}return[r,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e3585
15771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),j=new Uint32Array(80),U=new Uint32Array(80);class q extends g{constructor(){super(128,64,16,!1),this.Ah=0x6a09e667,this.Al=-0xc4336f8,this.Bh=-0x4498517b,this.Bl=-0x7b3558c5,this.Ch=0x3c6ef372,this.Cl=-0x16b07d5,this.Dh=-0x5ab00ac6,this.Dl=0x5f1d36f1,this.Eh=0x510e527f,this.El=-0x52197d2f,this.Fh=-0x64fa9774,this.Fl=0x2b3e6c1f,this.Gh=0x1f83d9ab,this.Gl=-0x4be4295,this.Hh=0x5be0cd19,this.Hl=0x137e2179}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:s,Cl:n,Dh:o,Dl:a,Eh:c,El:l,Fh:h,Fl:u,Gh:p,Gl:d,Hh:f,Hl:g}=this;return[e,t,r,i,s,n,o,a,c,l,h,u,p,d,f,g]}set(e,t,r,i,s,n,o,a,c,l,h,u,p,d,f,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|i,this.Ch=0|s,this.Cl=0|n,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|u,this.Gh=0|p,this.Gl=0|d,this.Hh=0|f,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)j[r]=e.getUint32(t),U[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|j[e-15],r=0|U[e-15],i=v(t,r,1)^v(t,r,8)^b(t,r,7),s=E(t,r,1)^E(t,r,8)^w(t,r,7),n=0|j[e-2],o=0|U[e-2],a=v(n,o,19)^I(n,o,61)^b(n,o,6),c=_(s,E(n,o,19)^x(n,o,61)^w(n,o,6),U[e-7],U[e-16]),l=A(c,i,a,j[e-7],j[e-16]);j[e]=0|l,U[e]=0|c}let{Ah:r,Al:i,Bh:s,Bl:n,Ch:o,Cl:a,Dh:c,Dl:l,Eh:h,El:u,Fh:p,Fl:d,Gh:f,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){let t=v(h,u,14)^v(h,u,18)^I(h,u,41),b=E(h,u,14)^E(h,u,18)^x(h,u,41),w=h&p^~h&f,_=C(m,b,u&d^~u&g,N[e],U[e]),A=R(_,y,t,w,T[e],j[e]),q=0|_,k=v(r,i,28)^I(r,i,34)^I(r,i,39),D=E(r,i,28)^x(r,i,34)^x(r,i,39),L=r&s^r&o^s&o,B=i&n^i&a^n&a;y=0|f,m=0|g,f=0|p,g=0|d,p=0|h,d=0|u,({h:h,l:u}=P(0|c,0|l,0|A,0|q)),c=0|o,l=0|a,o=0|s,a=0|n,s=0|r,n=0|i;let M=O(q,D,B);r=S(M,A,k,L),i=0|M}({h:r,l:i}=P(0|this.Ah,0|this.Al,0|r,0|i)),({h:s,l:n}=P(0|this.Bh,0|this.Bl,0|s,0|n)),({h:o,l:a}=P(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:l}=P(0|this.Dh,0|this.Dl,0|c,0|l)),({h:h,l:u}=P(0|this.Eh,0|this.El,0|h,0|u)),({h:p,l:d}=P(0|this.Fh,0|this.Fl,0|p,0|d)),({h:f,l:g}=P(0|this.Gh,0|this.Gl,0|f,0|g)),({h:y,l:m}=P(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(r,i,s,n,o,a,c,l,h,u,p,d,f,g,y,m)}roundClean(){j.fill(0),U.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let k=(n=()=>new q,(i=e=>n().update(p(e)).digest()).outputLen=(s=n()).outputLen,i.blockLen=s.blockLen,i.create=()=>n(),i),D=BigInt(0),L=BigInt(1),B=BigInt(2);function M(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function $(e){if(!M(e))throw Error("Uint8Array expected")}function z(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}let H=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function V(e){$(e);let t="";for(let r=0;r<e.length;r++)t+=H[e[r]];return t}function F(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?D:BigInt("0x"+e)}function K(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function W(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){let r=K(e.charCodeAt(s)),n=K(e.charCodeAt(s+1));if(void 0===r||void 0===n)throw Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);i[t]=16*r+n}return i}function J(e){return $(e),F(V(Uint8Array.from(e).reverse()))}function G(e,t){return W(e.toString(16).padStart(2*t,"0"))}function Y(e,t){return G(e,t).reverse()}function Z(e,t,r){let i;if("string"==typeof t)try{i=W(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(M(t))i=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let s=i.length;if("number"==typeof r&&s!==r)throw Error(e+" of length "+r+" expected, got "+s);return i}function Q(...e){let t=0;for(let r=0;r<e.length;r++){let i=e[r];$(i),t+=i.length}let r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}let X=e=>"bigint"==typeof e&&D<=e;
1function ee(e,t,r,i){if(!(X(t)&&X(r)&&X(i))||!(r<=t)||!(t<i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}let et={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||M(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function er(e,t,r={}){let i=(t,r,i)=>{let s=et[r];if("function"!=typeof s)throw Error("invalid validator function");let n=e[t];if(!(i&&void 0===n)&&!s(n,e))throw Error("param "+String(t)+" is invalid. Expected "+r+", got "+n)};for(let[e,r]of Object.entries(t))i(e,r,!1);for(let[e,t]of Object.entries(r))i(e,t,!0);return e}function ei(e){let t=new WeakMap;return(r,...i)=>{let s=t.get(r);if(void 0!==s)return s;let n=e(r,...i);return t.set(r,n),n}}let es=BigInt(0),en=BigInt(1),eo=BigInt(2),ea=BigInt(3),ec=BigInt(4),el=BigInt(5),eh=BigInt(8);function eu(e,t){let r=e%t;return r>=es?r:t+r}function ep(e,t,r){let i=e;for(;t-- >es;)i*=i,i%=r;return i}function ed(e,t){if(e===es)throw Error("invert: expected non-zero number");if(t<=es)throw Error("invert: expected positive modulus, got "+t);let r=eu(e,t),i=t,s=es,n=en;for(;r!==es;){let e=i/r,t=i%r,o=s-n*e;i=r,r=t,s=n,n=o}if(i!==en)throw Error("invert: does not exist");return eu(s,t)}let ef=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function eg(e,t){let r=void 0!==t?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function ey(e,t,r=!1,i={}){let s;if(e<=es)throw Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:n,nByteLength:o}=eg(e,t);if(o>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let a=Object.freeze({ORDER:e,isLE:r,BITS:n,BYTES:o,MASK:(B<<BigInt(n-1))-L,ZERO:es,ONE:en,create:t=>eu(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return es<=t&&t<e},is0:e=>e===es,isOdd:e=>(e&en)===en,neg:t=>eu(-t,e),eql:(e,t)=>e===t,sqr:t=>eu(t*t,e),add:(t,r)=>eu(t+r,e),sub:(t,r)=>eu(t-r,e),mul:(t,r)=>eu(t*r,e),pow:(e,t)=>(function(e,t,r){if(r<es)throw Error("invalid exponent, negatives unsupported");if(r===es)return e.ONE;if(r===en)return t;let i=e.ONE,s=t;for(;r>es;)r&en&&(i=e.mul(i,s)),s=e.sqr(s),r>>=en;return i})(a,e,t),div:(t,r)=>eu(t*ed(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ed(t,e),sqrt:i.sqrt||(t=>(s||(s=function(e){if(e%ec===ea){let t=(e+en)/ec;return function(e,r){let i=e.pow(r,t);if(!e.eql(e.sqr(i),r))throw Error("Cannot find square root");return i}}if(e%eh===el){let t=(e-el)/eh;return function(e,r){let i=e.mul(r,eo),s=e.pow(i,t),n=e.mul(r,s),o=e.mul(e.mul(n,eo),s),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),r))throw Error("Cannot find square root");return a}}return function(e){let t,r,i,s=(e-en)/eo;for(t=e-en,r=0;t%eo===es;t/=eo,r++);for(i=eo;i<e&&function(e,t,r){if(t<es)throw Error("invalid exponent, negatives unsupported");if(r<=es)throw Error("invalid modulus");if(r===en)return es;let i=en;for(;t>es;)t&en&&(i=i*e%r),e=e*e%r,t>>=en;return i}(i,s,e)!==e-en;i++)if(i>1e3)throw Error("Cannot find square root: likely non-prime P");if(1===r){let t=(e+en)/ec;return function(e,r){let i=e.pow(r,t);if(!e.eql(e.sqr(i),r))throw Error("Cannot find square root");return i}}let n=(t+en)/eo;return function(e,o){if(e.pow(o,s)===e.neg(e.ONE))throw Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),t),l=e.pow(o,n),h=e.pow(o,t);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(h);t<a&&!e.eql(r,e.ONE);t++)r=e.sqr(r);let r=e.pow(c,en<<BigInt(a-t-1));c=e.sqr(r),l=e.mul(l,r),h=e.mul(h,c),a=t}return l}}(e)}(e)),s(a,t))),invertBatch:e=>{let t,r,i;return t=Array(e.length),r=e.reduce((e,r,i)=>a.is0(r)?e:(t[i]=e,a.mul(e,r)),a.ONE),i=a.inv(r),e.reduceRight((e,r,i)=>a.is0(r)?e:(t[i]=a.mul(e,t[i]),a.mul(e,r)),i),t},cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Y(e,o):G(e,o),fromBytes:e=>{if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);return r?J(e):F(V(e))}});return Object.freeze(a)}let em=BigInt(0),eb=BigInt(1);function ew(e,t){let r=t.negate();return e?r:t}function ev(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function eE(e,t){return ev(e,t),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}let eI=new WeakMap,ex=new WeakMap;function eP(e){return ex.get(e)||1}let eO=BigInt(0),eS=BigInt(1),e_=BigInt(2),eA=BigInt(8),eR={zip215:!0};BigInt(0),BigInt(1);let eC=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),eT=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);let eN=BigInt(1),ej=BigInt(2);BigInt(3);let eU=BigInt(5),eq=BigInt(8),ek=ey(eC,void 0,!0),eD=function(e){var t;let r,i=(er(e.Fp,ef.reduce((e,t)=>
1(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),er(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),r=Object.freeze({...eg(e.n,e.nBitLength),...e,p:e.Fp.ORDER}),er(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...r})),{Fp:s,n:n,prehash:o,hash:a,randomBytes:c,nByteLength:l,h:h}=i,u=e_<<BigInt(8*l)-eS,p=s.create,d=ey(i.n,i.nBitLength),f=i.uvRatio||((e,t)=>{try{return{isValid:!0,value:s.sqrt(e*s.inv(t))}}catch{return{isValid:!1,value:eO}}}),g=i.adjustScalarBytes||(e=>e),y=i.domain||((e,t,r)=>{if(z("phflag",r),t.length||r)throw Error("Contexts/pre-hash are not supported");return e});function m(e,t){ee("coordinate "+e,t,eO,u)}function b(e){if(!(e instanceof E))throw Error("ExtendedPoint expected")}let w=ei((e,t)=>{let{ex:r,ey:i,ez:n}=e,o=e.is0();null==t&&(t=o?eA:s.inv(n));let a=p(r*t),c=p(i*t),l=p(n*t);if(o)return{x:eO,y:eS};if(l!==eS)throw Error("invZ was invalid");return{x:a,y:c}}),v=ei(e=>{let{a:t,d:r}=i;if(e.is0())throw Error("bad point: ZERO");let{ex:s,ey:n,ez:o,et:a}=e,c=p(s*s),l=p(n*n),h=p(o*o),u=p(h*h),d=p(c*t);if(p(h*p(d+l))!==p(u+p(r*p(c*l))))throw Error("bad point: equation left != right (1)");if(p(s*n)!==p(o*a))throw Error("bad point: equation left != right (2)");return!0});
1class E{constructor(e,t,r,i){this.ex=e,this.ey=t,this.ez=r,this.et=i,m("x",e),m("y",t),m("z",r),m("t",i),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof E)throw Error("extended point not allowed");let{x:t,y:r}=e||{};return m("x",t),m("y",r),new E(t,r,eS,p(t*r))}static normalizeZ(e){let t=s.invertBatch(e.map(e=>e.ez));return e.map((e,r)=>e.toAffine(t[r])).map(E.fromAffine)}static msm(e,t){return function(e,t,r,i){if(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw Error("invalid point at index "+r)})}(r,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw Error("invalid scalar at index "+r)})}(i,t),r.length!==i.length)throw Error("arrays of points and scalars must have equal length");let s=e.ZERO,n=function(e){let t;for(t=0;e>D;e>>=L,t+=1);return t}(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=Array(a+1).fill(s),l=Math.floor((t.BITS-1)/o)*o,h=s;for(let e=l;e>=0;e-=o){c.fill(s);for(let t=0;t<i.length;t++){let s=Number(i[t]>>BigInt(e)&BigInt(a));c[s]=c[s].add(r[t])}let t=s;for(let e=c.length-1,r=s;e>0;e--)r=r.add(c[e]),t=t.add(r);if(h=h.add(t),0!==e)for(let e=0;e<o;e++)h=h.double()}return h}(E,d,e,t)}_setWindowSize(e){P.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){b(e);let{ex:t,ey:r,ez:i}=this,{ex:s,ey:n,ez:o}=e,a=p(t*o),c=p(s*i),l=p(r*o),h=p(n*i);return a===c&&l===h}is0(){return this.equals(E.ZERO)}negate(){return new E(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){let{a:e}=i,{ex:t,ey:r,ez:s}=this,n=p(t*t),o=p(r*r),a=p(e_*p(s*s)),c=p(e*n),l=t+r,h=p(p(l*l)-n-o),u=c+o,d=u-a,f=c-o,g=p(h*d),y=p(u*f),m=p(h*f);return new E(g,y,p(d*u),m)}add(e){b(e);let{a:t,d:r}=i,{ex:s,ey:n,ez:o,et:a}=this,{ex:c,ey:l,ez:h,et:u}=e;if(t===BigInt(-1)){let e=p((n-s)*(l+c)),t=p((n+s)*(l-c)),r=p(t-e);if(r===eO)return this.double();let i=p(o*e_*u),d=p(a*e_*h),f=d+i,g=t+e,y=d-i,m=p(f*r),b=p(g*y),w=p(f*y);return new E(m,b,p(r*g),w)}let d=p(s*c),f=p(n*l),g=p(a*r*u),y=p(o*h),m=p((s+n)*(c+l)-d-f),w=y-g,v=y+g,I=p(f-t*d),x=p(m*w),P=p(v*I),O=p(m*I);return new E(x,P,p(w*v),O)}subtract(e){return this.add(e.negate())}wNAF(e){return P.wNAFCached(this,e,E.normalizeZ)}multiply(e){ee("scalar",e,eS,n);let{p:t,f:r}=this.wNAF(e);return E.normalizeZ([t,r])[0]}multiplyUnsafe(e,t=E.ZERO){return ee("scalar",e,eO,n),e===eO?x:this.is0()||e===eS?this:P.wNAFCachedUnsafe(this,e,E.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(h).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(e){return w(this,e)}clearCofactor(){let{h:e}=i;return e===eS?this:this.multiplyUnsafe(e)}static fromHex(e,t=!1){let{d:r,a:n}=i,o=s.BYTES;e=Z("pointHex",e,o),z("zip215",t);let a=e.slice(),c=e[o-1];a[o-1]=-129&c;let l=J(a);ee("pointHex.y",l,eO,t?u:s.ORDER);let h=p(l*l),{isValid:d,value:g}=f(p(h-eS),p(r*h-n));if(!d)throw Error("Point.fromHex: invalid y coordinate");let y=(g&eS)===eS,m=(128&c)!=0;if(!t&&g===eO&&m)throw Error("Point.fromHex: x=0 and x_0=1");return m!==y&&(g=p(-g)),E.fromAffine({x:g,y:l})}static fromPrivateKey(e){return O(e).point}toRawBytes(){let{x:e,y:t}=this.toAffine(),r=Y(t,s.BYTES);return r[r.length-1]|=e&eS?128:0,r}toHex(){return V(this.toRawBytes())}}E.BASE=new E(i.Gx,i.Gy,eS,p(i.Gx*i.Gy)),E.ZERO=new E(eO,eS,eS,eO);let{BASE:I,ZERO:x}=E,P=(t=8*l,{constTimeNegate:ew,hasPrecomputes:e=>1!==eP(e),unsafeLadder(e,t,r=E.ZERO){let i=e;for(;t>em;)t&eb&&(r=r.add(i)),i=i.double(),t>>=eb;return r},precomputeWindow(e,r){let{windows:i,windowSize:s}=eE(r,t),n=[],o=e,a=o;for(let e=0;e<i;e++){a=o,n.push(a);for(let e=1;e<s;e++)a=a.add(o),n.push(a);o=a.double()}return n},wNAF(e,r,i){let{windows:s,windowSize:n}=eE(e,t),o=E.ZERO,a=E.BASE,c=BigInt(2**e-1),l=2**e,h=BigInt(e);for(let e=0;e<s;e++){let t=e*n,s=Number(i&c);i>>=h,s>n&&(s-=l,i+=eb);let u=t+Math.abs(s)-1,p=e%2!=0,d=s<0;0===s?a=a.add(ew(p,r[t])):o=o.add(ew(d,r[u]))}return{p:o,f:a}},wNAFUnsafe(e,r,i,s=E.ZERO){let{windows:n,windowSize:o}=eE(e,t),a=BigInt(2**e-1),c=2**e,l=BigInt(e);for(let e=0;e<n;e++){let t=e*o;if(i===em)break;let n=Number(i&a);if(i>>=l,n>o&&(n-=c,i+=eb),0===n)continue;let h=r[t+Math.abs(n)-1];n<0&&(h=h.negate()),s=s.add(h)}return s},getPrecomputes(e,t,r){let i=eI.get(t);
1return i||(i=this.precomputeWindow(t,e),1!==e&&eI.set(t,r(i))),i},wNAFCached(e,t,r){let i=eP(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)},wNAFCachedUnsafe(e,t,r,i){let s=eP(e);return 1===s?this.unsafeLadder(e,t,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),t,i)},setWindowSize(e,r){ev(r,t),ex.set(e,r),eI.delete(e)}});function O(e){let t=s.BYTES;e=Z("private key",e,t);let r=Z("hashed private key",a(e),2*t),i=g(r.slice(0,t)),o=r.slice(t,2*t),c=eu(J(i),n),l=I.multiply(c),h=l.toRawBytes();return{head:i,prefix:o,scalar:c,point:l,pointBytes:h}}function S(e=new Uint8Array,...t){return eu(J(a(y(Q(...t),Z("context",e),!!o))),n)}return I._setWindowSize(8),{CURVE:i,getPublicKey:function(e){return O(e).pointBytes},sign:function(e,t,r={}){e=Z("message",e),o&&(e=o(e));let{prefix:i,scalar:a,pointBytes:c}=O(t),l=S(r.context,i,e),h=I.multiply(l).toRawBytes(),u=eu(l+S(r.context,h,c,e)*a,n);return ee("signature.s",u,eO,n),Z("result",Q(h,Y(u,s.BYTES)),2*s.BYTES)},verify:function(e,t,r,i=eR){let n,a,c,{context:l,zip215:h}=i,u=s.BYTES;e=Z("signature",e,2*u),t=Z("message",t),r=Z("publicKey",r,u),void 0!==h&&z("zip215",h),o&&(t=o(t));let p=J(e.slice(u,2*u));try{n=E.fromHex(r,h),a=E.fromHex(e.slice(0,u),h),c=I.multiplyUnsafe(p)}catch{return!1}if(!h&&n.isSmallOrder())return!1;let d=S(l,a.toRawBytes(),n.toRawBytes(),t);return a.add(n.multiplyUnsafe(d)).subtract(c).clearCofactor().equals(E.ZERO)},ExtendedPoint:E,utils:{getExtendedPublicKey:O,randomPrivateKey:()=>c(s.BYTES),precompute:(e=8,t=E.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}}({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ek,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:eq,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:k,randomBytes:f,adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},uvRatio:function(e,t){var r;let i,s,n,o,a,c,l,h,u,p,d,f,g,y,m=eu(t*t*t,eC),b=(r=e*eu(m*m*t,eC),i=BigInt(10),s=BigInt(20),n=BigInt(40),o=BigInt(80),c=ep(a=r*r%eC*r%eC,ej,eC)*a%eC,l=ep(c,eN,eC)*r%eC,h=ep(l,eU,eC)*l%eC,u=ep(h,i,eC)*h%eC,p=ep(u,s,eC)*u%eC,d=ep(p,n,eC)*p%eC,f=ep(d,o,eC)*d%eC,g=ep(f,o,eC)*d%eC,y=ep(g,i,eC)*h%eC,{pow_p_5_8:ep(y,ej,eC)*r%eC,b2:a}).pow_p_5_8,w=eu(e*m*b,eC),v=eu(t*w*w,eC),E=w,I=eu(w*eT,eC),x=v===e,P=v===eu(-e,eC),O=v===eu(-e*eT,eC);return x&&(w=E),(P||O)&&(w=I),(eu(w,eC)&en)===en&&(w=eu(-w,eC)),{isValid:x||P,value:w}}}),eL="base64url",eB="utf8",eM="utf8",e$="base58btc";function ez(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function eH(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ez(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function eV(e,t){t||(t=e.reduce((e,t)=>e+t.length,0));let r=eH(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return ez(r)}var eF=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==r[o])throw TypeError(n+" is ambiguous");r[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var i=0,s=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var u=0,p=n-1;(0!==h||u<s)&&-1!==p;p--,u++)h+=a*o[p]>>>0,o[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");s=u,t++}if(" "!==e[t]){for(var d=n-s;d!==n&&0===o[d];)d++;for(var f=new Uint8Array(i+(n-d)),g=i;d!==n;)f[g++]=o[d++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,s=0,n=t.length;s!==n&&0===t[s];)s++,r++;for(var o=(n-s)*h+1>>>0,l=new Uint8Array(o);s!==n;){for(var u=t[s],p=0,d=o-1;(0!==u||p<i)&&-1!==d;d--,p++)u+=256*l[d]>>>0,l[d]=u%a>>>0,u=u/a>>>0;if(0!==u)throw Error("Non-zero carry");i=p,s++}for(var f=o-i;f!==o&&0===l[f];)f++;for(var g=c.repeat(r);f<o;++f)g+=e.charAt(l[f]);return g},decodeUnsafe:u,decode:function(e){var r=u(e);if(r)return r;throw Error(`Non-${t} character`)}}};let eK=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unknown type, must be binary type")};class eW{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class eJ{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name}
1 decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return eY(this,e)}}class eG{constructor(e){this.decoders=e}or(e){return eY(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let eY=(e,t)=>new eG({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class eZ{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new eW(e,t,r),this.decoder=new eJ(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let eQ=({name:e,prefix:t,encode:r,decode:i})=>new eZ(e,t,r,i),eX=({prefix:e,name:t,alphabet:r})=>{let{encode:i,decode:s}=eF(r,t);return eQ({prefix:e,name:t,encode:i,decode:e=>eK(s(e))})},e0=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>eQ({prefix:t,name:e,encode:e=>((e,t,r)=>{let i="="===t[t.length-1],s=(1<<r)-1,n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>r;)o-=r,n+=t[s&a>>o];if(o&&(n+=t[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n})(e,i,r),decode:t=>((e,t,r,i)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*r/8|0),a=0,c=0,l=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${i} character`);c=c<<r|n,(a+=r)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw SyntaxError("Unexpected end of data");return o})(t,i,r,e)});var e1=Object.freeze({__proto__:null,identity:eQ({prefix:"\0",name:"identity",encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)})}),e2=Object.freeze({__proto__:null,base2:e0({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),e8=Object.freeze({__proto__:null,base8:e0({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),e5=Object.freeze({__proto__:null,base10:eX({prefix:"9",name:"base10",alphabet:"0123456789"})}),e3=Object.freeze({__proto__:null,base16:e0({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:e0({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})}),e6=Object.freeze({__proto__:null,base32:e0({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper:e0({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad:e0({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper:e0({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex:e0({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper:e0({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad:e0({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper:e0({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:e0({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),e4=Object.freeze({__proto__:null,base36:eX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:eX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),e9=Object.freeze({__proto__:null,base58btc:eX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:eX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})}),e7=Object.freeze({__proto__:null,base64:e0({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad:e0({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url:e0({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:e0({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let te=Array.from("\uD83D\uDE80\uD83E\uDE90â\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09â\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02â¤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09âº\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9Eââ¨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2Dâ£\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33â\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13ââ
\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6â\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90â¹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20â\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2Bâ½\uD83E\uDD19â\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81â¡\uD83C\uDF1E\uD83C\uDF88ââ\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2Câ\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74â¶â¡â\uD83D\uDC8E\uD83D\uDCB8â¬\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7Aâ \uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37â\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51â\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),tt=te.reduce((e,t,r)=>(e[r]=t,e),[]),tr=te.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);var ti=Object.freeze({__proto__:null,base256emoji:eQ({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>
1e+=tt[t],"")},decode:function(e){let t=[];for(let r of e){let e=tr[r.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}})});function ts(e,t,r){t=t||[],r=r||0;for(var i=r;e>=0x80000000;)t[r++]=255&e|128,e/=128;for(;-128&e;)t[r++]=255&e|128,e>>>=7;return t[r]=0|e,ts.bytes=r-i+1,t}var tn=function(e){return e<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:e<0x800000000?5:e<0x40000000000?6:e<0x2000000000000?7:e<0x100000000000000?8:e<0x8000000000000000?9:10};let to=(e,t,r=0)=>(ts(e,t,r),t),ta=(e,t)=>{let r=t.byteLength,i=tn(e),s=i+tn(r),n=new Uint8Array(s+r);return to(e,n,0),to(r,n,i),n.set(t,s),new tc(e,r,t,n)};class tc{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}let tl=({name:e,code:t,encode:r})=>new th(e,t,r);class th{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ta(this.code,t):t.then(e=>ta(this.code,e))}throw Error("Unknown type, must be binary type")}}let tu=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var tp=Object.freeze({__proto__:null,sha256:tl({name:"sha2-256",code:18,encode:tu("SHA-256")}),sha512:tl({name:"sha2-512",code:19,encode:tu("SHA-512")})}),td=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:eK,digest:e=>ta(0,eK(e))}});new TextEncoder,new TextDecoder;let tf={...e1,...e2,...e8,...e5,...e3,...e6,...e4,...e9,...e7,...ti};function tg(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}({...tp,...td});let ty=tg("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),tm=tg("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{let t=eH((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),tb={utf8:ty,"utf-8":ty,hex:tf.base16,latin1:tm,ascii:tm,binary:tm,...tf};function tw(e,t="utf8"){let r=tb[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}function tv(e,t="utf8"){let r=tb[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?ez(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function tE(e){return(0,a.j)(tw(tv(e,eL),eB))}function tI(e){return tw(tv((0,a.h)(e),eB),eL)}function tx(e){return["did:key","z"+tw(eV([tv("K36",e$),e]),e$)].join(":")}function tP(e){let t=e.split(".");return{header:tE(t[0]),payload:tE(t[1]),signature:tv(t[2],eL),data:tv(t.slice(0,2).join("."),eM)}}function tO(e=f(32)){let t=eD.getPublicKey(e);return{secretKey:eV([e,t]),publicKey:t}}async function tS(e,t,r,i,s=(0,o.fromMiliseconds)(Date.now())){let n={alg:"EdDSA",typ:"JWT"},a={iss:tx(i.publicKey),sub:e,aud:t,iat:s,exp:s+r},c=tv([tI((l={header:n,payload:a}).header),tI(l.payload)].join("."),eM);var l,h={header:n,payload:a,signature:eD.sign(c,i.secretKey.slice(0,32))};return[tI(h.header),tI(h.payload),tw(h.signature,eL)].join(".")}},56759:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var i=r(69319),s=r(66602),n=r(4839);let o=e=>e.split("?")[0],a="u">typeof WebSocket?WebSocket:"u">typeof r.g&&"u">typeof r.g.WebSocket?r.g.WebSocket:"u">typeof window&&"u">typeof window.WebSocket?window.WebSocket:"u">typeof self&&"u">typeof self.WebSocket?self.WebSocket:r(58698);class c{constructor(e){if(this.url=e,this.events=new i.EventEmitter,this.registering=!1,!(0,n.isWsUrl)(e))throw Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return"u">typeof this.socket}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{typeof this.socket>"u"?t(Error("Connection already closed")):(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close())})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send((0,s.h)(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!(0,n.isWsUrl)(e))throw Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((e,t)=>
1{this.events.once("register_error",e=>{this.resetMaxListeners(),t(e)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return t(Error("WebSocket connection is missing or invalid"));e(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let s=(0,n.isReactNative)()?void 0:{rejectUnauthorized:!(0,n.isLocalhostUrl)(e)},o=new a(e,[],s);"u">typeof WebSocket||"u">typeof r.g&&"u">typeof r.g.WebSocket||"u">typeof window&&"u">typeof window.WebSocket||"u">typeof self&&"u">typeof self.WebSocket?o.onerror=e=>{i(this.emitError(e.error))}:o.on("error",e=>{i(this.emitError(e))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t="string"==typeof e.data?(0,s.j)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let r=this.parseError(t),i=r.message||r.toString(),s=(0,n.formatJsonRpcError)(e,i);this.events.emit("payload",s)}parseError(e,t=this.url){return(0,n.parseConnectionError)(e,o(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){let t=this.parseError(Error(e?.message||`WebSocket connection failed for host: ${o(this.url)}`));return this.events.emit("register_error",t),t}}},57981:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(void 0!==t.elapsed)throw Error(`Watch already stopped for label: ${e}`);let r=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:r})}get(e){let t=this.timestamps.get(e);if(void 0===t)throw Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}}t.Watch=r,t.default=r},58698:e=>{"use strict";e.exports=function(){throw Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},66602:(e,t,r)=>{"use strict";function i(e){if("string"!=typeof e)throw Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3'),(e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t)}catch(t){return e}}function s(e){return"string"==typeof e?e:JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"n":t)||""}r.d(t,{h:()=>s,j:()=>i})},69005:(e,t,r)=>{"use strict";let i,s,n;r.d(t,{EthereumProvider:()=>lj});var o,a,c=r(69319),l=r.n(c),h=r(52652),u=r(71726),p=r(98534),d=r(15063);let f="2.23.2",g={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${f}`};class y extends Error{constructor(e,t={}){const r=t.cause instanceof y?t.cause.details:t.cause?.message?t.cause.message:t.details,i=t.cause instanceof y&&t.cause.docsPath||t.docsPath,s=g.getDocsUrl?.({...t,docsPath:i});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...g.version?[`Version: ${g.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=f}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}function m(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}class b extends y{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function w(e,{dir:t,size:r=32}={}){return"string"==typeof e?function(e,{dir:t,size:r=32}={}){if(null===r)return e;let i=e.replace("0x","");if(i.length>2*r)throw new b({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i["right"===t?"padEnd":"padStart"](2*r,"0")}`}(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new b({size:e.length,targetSize:r,type:"bytes"});let i=new Uint8Array(r);for(let s=0;s<r;s++){let n="right"===t;i[n?s:r-s-1]=e[n?s:e.length-s-1]}return i}(e,{dir:t,size:r})}class v extends y{constructor({max:e,min:t,signed:r,size:i,value:s}){super(`Number "${s}" is not in safe ${i?`${8*i}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class E extends y{constructor({givenSize:e,maxSize:t}
1){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function I(e){return m(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function x(e,{size:t}){if(I(e)>t)throw new E({givenSize:I(e),maxSize:t})}function P(e,t={}){let{signed:r}=t;t.size&&x(e,{size:t.size});let i=BigInt(e);if(!r)return i;let s=(e.length-2)/2;return i<=(1n<<8n*BigInt(s)-1n)-1n?i:i-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}let O=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function S(e,t={}){return"number"==typeof e||"bigint"==typeof e?A(e,t):"string"==typeof e?function(e,t={}){return _(R.encode(e),t)}(e,t):"boolean"==typeof e?function(e,t={}){let r=`0x${Number(e)}`;return"number"==typeof t.size?(x(r,{size:t.size}),w(r,{size:t.size})):r}(e,t):_(e,t)}function _(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=O[e[t]];let i=`0x${r}`;return"number"==typeof t.size?(x(i,{size:t.size}),w(i,{dir:"right",size:t.size})):i}function A(e,t={}){let r,{signed:i,size:s}=t,n=BigInt(e);s?r=i?(1n<<8n*BigInt(s)-1n)-1n:2n**(8n*BigInt(s))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));let o="bigint"==typeof r&&i?-r-1n:0;if(r&&n>r||n<o){let t="bigint"==typeof e?"n":"";throw new v({max:r?`${r}${t}`:void 0,min:`${o}${t}`,signed:i,size:s,value:`${e}${t}`})}let a=`0x${(i&&n<0?(1n<<BigInt(8*s))+BigInt(n):n).toString(16)}`;return s?w(a,{size:s}):a}let R=new TextEncoder,C=new TextEncoder;function T(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function N(e,t={}){let r=e;t.size&&(x(r,{size:t.size}),r=w(r,{dir:"right",size:t.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);let s=i.length/2,n=new Uint8Array(s);for(let e=0,t=0;e<s;e++){let r=T(i.charCodeAt(t++)),s=T(i.charCodeAt(t++));if(void 0===r||void 0===s)throw new y(`Invalid byte sequence ("${i[t-2]}${i[t-1]}" in "${i}").`);n[e]=16*r+s}return n}function j(e,t={}){let r=C.encode(e);return"number"==typeof t.size?(x(r,{size:t.size}),w(r,{dir:"right",size:t.size})):r}var U=r(44150);let q=BigInt(0x100000000-1),k=BigInt(32);var D=r(7791);let L=[],B=[],M=[],$=BigInt(0),z=BigInt(1),H=BigInt(2),V=BigInt(7),F=BigInt(256),K=BigInt(113);for(let e=0,t=z,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],L.push(2*(5*i+r)),B.push((e+1)*(e+2)/2%64);let s=$;for(let e=0;e<7;e++)(t=(t<<z^(t>>V)*K)%F)&H&&(s^=z<<(z<<BigInt(e))-z);M.push(s)}let[W,J]=function(e,t=!1){let r=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let s=0;s<e.length;s++){let{h:n,l:o}=function(e,t=!1){return t?{h:Number(e&q),l:Number(e>>k&q)}:{h:0|Number(e>>k&q),l:0|Number(e&q)}}(e[s],t);[r[s],i[s]]=[n,o]}return[r,i]}(M,!0),G=(e,t,r)=>r>32?t<<r-32|e>>>64-r:e<<r|t>>>32-r,Y=(e,t,r)=>r>32?e<<r-32|t>>>64-r:t<<r|e>>>32-r;class Z extends D.Vw{constructor(e,t,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,U.Fe)(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,D.DH)(this.state)}keccak(){D.qv||(0,D.Fc)(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let i=(t+8)%10,s=(t+2)%10,n=r[s],o=r[s+1],a=G(n,o,1)^r[i],c=Y(n,o,1)^r[i+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],s=e[3];for(let r=0;r<24;r++){let i=B[r],n=G(t,s,i),o=Y(t,s,i),a=L[r];t=e[a],s=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)r[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~r[(i+2)%10]&r[(i+4)%10]}e[0]^=W[i],e[1]^=J[i]}r.fill(0)}(this.state32,this.rounds),D.qv||(0,D.Fc)(this.state32),this.posOut=0,this.pos=0}update(e){(0,U.CC)(this);let{blockLen:t,state:r}=this,i=(e=(0,D.ZJ)(e)).length;for(let s=0;s<i;){let n=Math.min(t-this.pos,i-s);for(let t=0;t<n;t++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,(128&t)!=0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){(0,U.CC)(this,!1),(0,U.DO)(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();let n=Math.min(r-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,U.Fe)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,U.Ht)(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:n}=this;return e||(e=new Z(t,r,i,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}let Q=(0,D.ld)(()=>new Z(136,1,32));function X(e,t){let r=Q(m(e,{strict:!1})?function(e,t={}){return"number"==typeof e||"bigint"==typeof e?N(A(e,t)):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?(x(r,{size:t.size}),w(r,{size:t.size})):r}(e,t):m(e)?N(e,t):j(e,t)}(e):e);return"bytes"===(t||"hex")?r:S(r)}class ee extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let et=new ee(8192);async function er({hash:e,signature:t}){let i=m(e)?e:S(e),{secp256k1:s}=await r.e(1788).then(r.bind(r,31788)),n=(()=>
1{if("object"==typeof t&&"r"in t&&"s"in t){let{r:e,s:r,v:i,yParity:n}=t,o=ei(Number(n??i));return new s.Signature(P(e),P(r)).addRecoveryBit(o)}let e=m(t)?t:S(t),r=ei(function(e,t={}){return Number(P(e,t))}(`0x${e.slice(130)}`));return s.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(r)})().recoverPublicKey(i.substring(2)).toHex(!1);return`0x${n}`}function ei(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw Error("Invalid yParityOrV value")}async function es({hash:e,signature:t}){var r;let i;return r=await er({hash:e,signature:t}),i=X(`0x${r.substring(4)}`).substring(26),function(e){if(et.has(`${e}.undefined`))return et.get(`${e}.undefined`);let t=e.substring(2).toLowerCase(),r=X(j(t),"bytes"),i=t.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&r[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let s=`0x${i.join("")}`;return et.set(`${e}.undefined`,s),s}(`0x${i}`)}var en=r(78356),eo=r(56024),ea=r(94135),ec=r(96794),el=r(65364),eh=r(82909).hp;function eu(e){let[t,r]=e.split(":");return{namespace:t,reference:r}}function ep(e,t=[]){let r=[];return Object.keys(e).forEach(i=>{if(t.length&&!t.includes(i))return;let s=e[i];r.push(...s.accounts)}),r}function ed(e,t){return e.includes(":")?[e]:t.chains||[]}var ef=Object.defineProperty,eg=Object.defineProperties,ey=Object.getOwnPropertyDescriptors,em=Object.getOwnPropertySymbols,eb=Object.prototype.hasOwnProperty,ew=Object.prototype.propertyIsEnumerable,ev=(e,t,r)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,eE=(e,t)=>{for(var r in t||(t={}))eb.call(t,r)&&ev(e,r,t[r]);if(em)for(var r of em(t))ew.call(t,r)&&ev(e,r,t[r]);return e};let eI="react-native",ex="node",eP="browser";function eO(){return"u">typeof el&&"u">typeof el.versions&&"u">typeof el.versions.node}function eS(){return!(0,p.getDocument)()&&!!(0,p.getNavigator)()&&"ReactNative"===navigator.product}function e_(){return!eO()&&!!(0,p.getNavigator)()&&!!(0,p.getDocument)()}function eA(){return eS()?eI:eO()?ex:e_()?eP:"unknown"}function eR(){var e;try{return eS()&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Application)?null==(e=r.g.Application)?void 0:e.applicationId:void 0}catch{return}}function eC(){return(0,d.g)()||{name:"",description:"",url:"",icons:[""]}}function eT(e,t,i){var s;let n,o=function(){if(eA()===eI&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Platform)){let{OS:e,Version:t}=r.g.Platform;return[e,t].join("-")}let e=(0,h.o0)();if(null===e)return"unknown";let t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=(n=eA())===eP?[n,(null==(s=(0,p.getLocation)())?void 0:s.host)||"unknown"].join(":"):n;return[[e,t].join("-"),["js",i].join("-"),o,a].join("/")}function eN(e,t){return e.filter(e=>t.includes(e)).length===e.length}function ej(e){return Object.fromEntries(e.entries())}function eU(e){return new Map(Object.entries(e))}function eq(e=u.FIVE_MINUTES,t){let r,i,s,n,o=(0,u.toMiliseconds)(e||u.FIVE_MINUTES);return{resolve:e=>{s&&r&&(clearTimeout(s),r(e),n=Promise.resolve(e))},reject:e=>{s&&i&&(clearTimeout(s),i(e))},done:()=>new Promise((e,a)=>{if(n)return e(n);s=setTimeout(()=>{let e=Error(t);n=Promise.reject(e),a(e)},o),r=e,i=a})}}function ek(e,t,r){return new Promise(async(i,s)=>{let n=setTimeout(()=>s(Error(r)),t);try{let t=await e;i(t)}catch(e){s(e)}clearTimeout(n)})}function eD(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw Error(`Unknown expirer target type: ${e}`)}function eL(e){let[t,r]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)i.topic=r;else if("id"===t&&Number.isInteger(Number(r)))i.id=Number(r);else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return i}function eB(e,t){return(0,u.fromMiliseconds)((t||Date.now())+(0,u.toMiliseconds)(e))}function eM(e){return Date.now()>=(0,u.toMiliseconds)(e)}function e$(e,t){return`${e}${t?`:${t}`:""}`}function ez(e=[],t=[]){return[...new Set([...e,...t])]}async function eH({id:e,topic:t,wcDeepLink:i}){var s,n;try{if(!i)return;let o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;let c=function(e,t,r){let i=`requestId=${t}&sessionTopic=${r}`;e.endsWith("/")&&(e=e.slice(0,-1));let s=`${e}`;if(e.startsWith("https://t.me")){let t=e.includes("?")?"&startapp=":"?startapp=";s=`${s}${t}${function(e,t=!1){let r=eh.from(e).toString("base64");return t?r.replace(/[=]/g,""):r}(i,!0)}`}else s=`${s}/wc?${i}`;return s}(a,e,t),l=eA();if(l===eP){let e;if(!(null!=(s=(0,p.getDocument)())&&s.hasFocus()))return void console.warn("Document does not have focus, skipping deeplink.");n=c,e="_self",!function(){try{return window.self!==window.top}catch{return!1}}()?("u">typeof window&&(window.TelegramWebviewProxy||window.Telegram||window.TelegramWebviewProxyProto)||n.startsWith("https://")||n.startsWith("http://"))&&(e="_blank"):e="_top",window.open(n,e,"noreferrer noopener")}else l===eI&&"u">typeof(null==r.g?void 0:r.g.Linking)&&await r.g.Linking.openURL(c)}catch(e){console.error(e)}}async function eV(e,t){let r="";try{if(e_()&&(r=localStorage.getItem(t)))return r;r=await e.getItem(t)}catch(e){console.error(e)}return r}function eF(e,t){if(!e.includes(t))return null;let r=e.split(/([&,?,=])/),i=r.indexOf(t);return r[i+2]}function eK(){return"u">typeof crypto&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function eW(){return"u">typeof el&&"true"===el.env.IS_VITEST}function eJ(e){return eh.from(e,"base64").toString("utf-8")}function eG(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function eY(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function eZ(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");eG(e.outputLen),eG(e.blockLen)}function eQ(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function eX(e,t){eY(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}let e0=BigInt(0x100000000-1),e1=BigInt(32),e2="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function e8(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function e5(e,t){return e<<32-t|e>>>t}let e3=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function e6(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function e4(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),eY(e),e}class e9{clone(){return this._cloneInto()}}function e7(e){let t=t=>e().update(e4(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function te(e=32){if(e2&&"function"==typeof e2.getRandomValues)return e2.getRandomValues(new Uint8Array(e));if(e2&&"function"==typeof e2.randomBytes)return e2.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}let tt=[],tr=[],ti=[],ts=BigInt(0),tn=BigInt(1),to=BigInt(2),ta=BigInt(7),tc=BigInt(256),tl=BigInt(113);for(let e=0,t=tn,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],tt.push(2*(5*i+r)),tr.push((e+1)*(e+2)/2%64);let s=ts;for(let e=0;e<7;e++)(t=(t<<tn^(t>>ta)*tl)%tc)&to&&(s^=tn<<(tn<<BigInt(e))-tn);ti.push(s)}let[th,tu]=function(e,t=!1){let r=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let s=0;s<e.length;s++){let{h:n,l:o}=function(e,t=!1){return t?{h:Number(e&e0),l:Number(e>>e1&e0)}:{h:0|Number(e>>e1&e0),l:0|Number(e&e0)}}(e[s],t);[r[s],i[s]]=[n,o]}return[r,i]}(ti,!0),tp=(e,t,r)=>r>32?t<<r-32|e>>>64-r:e<<r|t>>>32-r,td=(e,t,r)=>r>32?e<<r-32|t>>>64-r:t<<r|e>>>32-r;class tf extends e9{constructor(e,t,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,eG(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){e3||e6(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let i=(t+8)%10,s=(t+2)%10,n=r[s],o=r[s+1],a=tp(n,o,1)^r[i],c=td(n,o,1)^r[i+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],s=e[3];for(let r=0;r<24;r++){let i=tr[r],n=tp(t,s,i),o=td(t,s,i),a=tt[r];t=e[a],s=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)r[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~r[(i+2)%10]&r[(i+4)%10]}e[0]^=th[i],e[1]^=tu[i]}r.fill(0)}(this.state32,this.rounds),e3||e6(this.state32),this.posOut=0,this.pos=0}update(e){eQ(this);let{blockLen:t,state:r}=this,i=(e=e4(e)).length;for(let s=0;s<i;){let n=Math.min(t-this.pos,i-s);for(let t=0;t<n;t++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,(128&t)!=0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){eQ(this,!1),eY(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();let n=Math.min(r-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return eG(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(eX(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:n}=this;return e||(e=new tf(t,r,i,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}let tg=e7(()=>new tf(136,1,32));function ty(e){let t=`�Ethereum Signed Message: 2${e.length}`,r=new TextEncoder().encode(t+e);return"0x"+eh.from(tg(r)).toString("hex")}async function tm(e,t,r,i,s,n){switch(r.t){case"eip191":return await tb(e,t,r.s);case"eip1271":return await tw(e,t,r.s,i,s,n);default:throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function tb(e,t,r){return(await es({hash:ty(t),signature:r})).toLowerCase()===e.toLowerCase()}async function tw(e,t,r,i,s,n){let o=eu(i);if(!o.namespace||!o.reference)throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let o="0x1626ba7e",a=r.substring(2),c=ty(t).substring(2),l=o+c+"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041"+a,h=await fetch(`${n||"https://rpc.walletconnect.org/v1"}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:u}=await h.json();return!!u&&u.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}var tv=Object.defineProperty,tE=Object.defineProperties,tI=Object.getOwnPropertyDescriptors,tx=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,tO=Object.prototype.propertyIsEnumerable,tS=(e,t,r)=>t in e?tv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;let t_=e=>e?.split(":"),tA=e=>{let t=e&&t_(e);
2if(t)return t[2]+":"+t[3]},tR=e=>{let t=e&&t_(e);if(t)return t.pop()};async function tC(e){let{cacao:t,projectId:r}=e,{s:i,p:s}=t,n=tT(s,s.iss),o=tR(s.iss);return await tm(o,n,i,tA(s.iss),r)}let tT=(e,t)=>{let r=`${e.domain} wants you to sign in with your Ethereum account:`,i=tR(t);if(!e.aud&&!e.uri)throw Error("Either `aud` or `uri` is required to construct the message");let s=e.statement||void 0,n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{let t=e&&t_(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,l=`Issued At: ${e.iat}`,h=e.exp?`Expiration Time: ${e.exp}`:void 0,u=e.nbf?`Not Before: ${e.nbf}`:void 0,p=e.requestId?`Request ID: ${e.requestId}`:void 0,d=e.resources?`Resources:${e.resources.map(e=>` 3- ${e}`).join("")}`:void 0,f=tD(e.resources);return f&&(s=function(e="",t){tN(t);let r="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(r))return e;let i=[],s=0;Object.keys(t.att).forEach(e=>{let r=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));r.sort((e,t)=>e.action.localeCompare(t.action));let n={};r.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});let o=Object.keys(n).map(t=>(s++,`(${s}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))});let n=i.join(" "),o=`${r}${n}`;return`${e?e+" ":""}${o}`}(s,tU(f))),[r,i,"",s,"",n,o,a,c,l,h,u,p,d].filter(e=>null!=e).join(` 4`)};function tN(e){if(!e)throw Error("No recap provided, value is undefined");if(!e.att)throw Error("No `att` property found");let t=Object.keys(e.att);if(!(null!=t&&t.length))throw Error("No resources found in `att` property");t.forEach(t=>{let r=e.att[t];if(Array.isArray(r)||"object"!=typeof r)throw Error(`Resource must be an object: ${t}`);if(!Object.keys(r).length)throw Error(`Resource object is empty: ${t}`);Object.keys(r).forEach(e=>{let t=r[e];if(!Array.isArray(t))throw Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function tj(e){return tN(e),`urn:recap:${eh.from(JSON.stringify(e)).toString("base64").replace(/=/g,"")}`}function tU(e){var t;let r=(t=e.replace("urn:recap:",""),JSON.parse(eh.from(t,"base64").toString("utf-8")));return tN(r),r}function tq(e){var t;let r=tU(e);tN(r);let i=null==(t=r.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function tk(e){let t=tU(e);tN(t);let r=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&r.push(e[0].chains)})}),[...new Set(r.flat())]}function tD(e){if(!e)return;let t=e?.[e.length-1];return t&&t.includes("urn:recap:")?t:void 0}function tL(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function tB(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function tM(e,...t){if(!tB(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function t$(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function tz(e){if("boolean"!=typeof e)throw Error(`boolean expected, not ${e}`)}let tH=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([0x11223344]).buffer)[0])throw Error("Non little-endian hardware is not supported");function tV(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e);else if(tB(e))e=tW(e);else throw Error("Uint8Array expected, got "+typeof e);return e}function tF(e,t,r=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw Error("invalid output length, expected "+e+", got: "+t.length);if(r&&t.byteOffset%4!=0)throw Error("invalid output, must be aligned");return t}function tK(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),c=4*!!i,l=4*!i;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)}function tW(e){return Uint8Array.from(e)}function tJ(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}
4let tG=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),tY=tG("expand 16-byte k"),tZ=tG("expand 32-byte k"),tQ=tH(tY),tX=tH(tZ);function t0(e,t){return e<<t|e>>>32-t}function t1(e){return e.byteOffset%4==0}let t2=0x100000000-1,t8=new Uint32Array,t5=(e,t)=>255&e[t++]|(255&e[t++])<<8;class t3{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,tM(e=tV(e),32);const t=t5(e,0),r=t5(e,2),i=t5(e,4),s=t5(e,6),n=t5(e,8),o=t5(e,10),a=t5(e,12),c=t5(e,14);this.r[0]=8191&t,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|s<<9)&8191,this.r[4]=(s>>>4|n<<12)&255,this.r[5]=n>>>1&8190,this.r[6]=(n>>>14|o<<2)&8191,this.r[7]=(o>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=t5(e,16+2*t)}process(e,t,r=!1){let{h:i,r:s}=this,n=s[0],o=s[1],a=s[2],c=s[3],l=s[4],h=s[5],u=s[6],p=s[7],d=s[8],f=s[9],g=t5(e,t+0),y=t5(e,t+2),m=t5(e,t+4),b=t5(e,t+6),w=t5(e,t+8),v=t5(e,t+10),E=t5(e,t+12),I=t5(e,t+14),x=i[0]+(8191&g),P=i[1]+((g>>>13|y<<3)&8191),O=i[2]+((y>>>10|m<<6)&8191),S=i[3]+((m>>>7|b<<9)&8191),_=i[4]+((b>>>4|w<<12)&8191),A=i[5]+(w>>>1&8191),R=i[6]+((w>>>14|v<<2)&8191),C=i[7]+((v>>>11|E<<5)&8191),T=i[8]+((E>>>8|I<<8)&8191),N=i[9]+(I>>>5|2048*!r),j=0,U=0+x*n+5*f*P+5*d*O+5*p*S+5*u*_;j=U>>>13,U&=8191,U+=5*h*A+5*l*R+5*c*C+5*a*T+5*o*N,j+=U>>>13,U&=8191;let q=j+x*o+P*n+5*f*O+5*d*S+5*p*_;j=q>>>13,q&=8191,q+=5*u*A+5*h*R+5*l*C+5*c*T+5*a*N,j+=q>>>13,q&=8191;let k=j+x*a+P*o+O*n+5*f*S+5*d*_;j=k>>>13,k&=8191,k+=5*p*A+5*u*R+5*h*C+5*l*T+5*c*N,j+=k>>>13,k&=8191;let D=j+x*c+P*a+O*o+S*n+5*f*_;j=D>>>13,D&=8191,D+=5*d*A+5*p*R+5*u*C+5*h*T+5*l*N,j+=D>>>13,D&=8191;let L=j+x*l+P*c+O*a+S*o+_*n;j=L>>>13,L&=8191,L+=5*f*A+5*d*R+5*p*C+5*u*T+5*h*N,j+=L>>>13,L&=8191;let B=j+x*h+P*l+O*c+S*a+_*o;j=B>>>13,B&=8191,B+=A*n+5*f*R+5*d*C+5*p*T+5*u*N,j+=B>>>13,B&=8191;let M=j+x*u+P*h+O*l+S*c+_*a;j=M>>>13,M&=8191,M+=A*o+R*n+5*f*C+5*d*T+5*p*N,j+=M>>>13,M&=8191;let $=j+x*p+P*u+O*h+S*l+_*c;j=$>>>13,$&=8191,$+=A*a+R*o+C*n+5*f*T+5*d*N,j+=$>>>13,$&=8191;let z=j+x*d+P*p+O*u+S*h+_*l;j=z>>>13,z&=8191,z+=A*c+R*a+C*o+T*n+5*f*N,j+=z>>>13,z&=8191;let H=j+x*f+P*d+O*p+S*u+_*h;j=H>>>13,H&=8191,H+=A*l+R*c+C*a+T*o+N*n,j+=H>>>13,H&=8191,U=8191&(j=(j=(j<<2)+j|0)+U|0),j>>>=13,q+=j,i[0]=U,i[1]=q,i[2]=k,i[3]=D,i[4]=L,i[5]=B,i[6]=M,i[7]=$,i[8]=z,i[9]=H}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let t=1;t<10;t++)r[t]=e[t]+i,i=r[t]>>>13,r[t]&=8191;r[9]-=8192;let s=(1^i)-1;for(let e=0;e<10;e++)r[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|r[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let n=e[0]+t[0];e[0]=65535&n;for(let r=1;r<8;r++)n=(e[r]+t[r]|0)+(n>>>16)|0,e[r]=65535&n;tJ(r)}update(e){t$(this);let{buffer:t,blockLen:r}=this,i=(e=tV(e)).length;for(let s=0;s<i;){let n=Math.min(r-this.pos,i-s);if(n===r){for(;r<=i-s;s+=r)this.process(e,s);continue}t.set(e.subarray(s,s+n),this.pos),this.pos+=n,s+=n,this.pos===r&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){tJ(this.h,this.r,this.buffer,this.pad)}digestInto(e){t$(this),function(e,t){tM(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=r[t]>>>0,e[s++]=r[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}let t6=(o=e=>new t3(e),(i=(e,t)=>o(t).update(tV(e)).digest()).outputLen=(s=o(new Uint8Array(32))).outputLen,i.blockLen=s.blockLen,i.create=e=>o(e),i),t4=function(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:s,counterRight:n,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);
4if("function"!=typeof e)throw Error("core must be a function");return tL(s),tL(o),tz(n),tz(r),(t,a,c,l,h=0)=>{tM(t),tM(a),tM(c);let u=c.length;if(void 0===l&&(l=new Uint8Array(u)),tM(l),tL(h),h<0||h>=t2)throw Error("arx: counter overflow");if(l.length<u)throw Error(`arx: output (${l.length}) is shorter than data (${u})`);let p=[],d=t.length,f,g;if(32===d)p.push(f=tW(t)),g=tX;else if(16===d&&r)(f=new Uint8Array(32)).set(t),f.set(t,16),g=tQ,p.push(f);else throw Error(`arx: invalid 32-byte key, got length=${d}`);t1(a)||p.push(a=tW(a));let y=tH(f);if(i){if(24!==a.length)throw Error("arx: extended nonce must be 24 bytes");i(g,y,tH(a.subarray(0,16)),y),a=a.subarray(16)}let m=16-s;if(m!==a.length)throw Error(`arx: nonce must be ${m} or 16 bytes`);if(12!==m){let e=new Uint8Array(12);e.set(a,n?0:12-a.length),a=e,p.push(a)}return function(e,t,r,i,s,n,o,a){let c=s.length,l=new Uint8Array(64),h=tH(l),u=t1(s)&&t1(n),p=u?tH(s):t8,d=u?tH(n):t8;for(let f=0;f<c;o++){if(e(t,r,i,h,o,a),o>=t2)throw Error("arx: counter overflow");let g=Math.min(64,c-f);if(u&&64===g){let e=f/4;if(f%4!=0)throw Error("arx: invalid block position");for(let t=0,r;t<16;t++)d[r=e+t]=p[r]^h[t];f+=64;continue}for(let e=0,t;e<g;e++)n[t=f+e]=s[t]^l[e];f+=g}}(e,g,y,tH(a),c,l,h,o),tJ(...p),l}}(function(e,t,r,i,s,n=20){let o=e[0],a=e[1],c=e[2],l=e[3],h=t[0],u=t[1],p=t[2],d=t[3],f=t[4],g=t[5],y=t[6],m=t[7],b=r[0],w=r[1],v=r[2],E=o,I=a,x=c,P=l,O=h,S=u,_=p,A=d,R=f,C=g,T=y,N=m,j=s,U=b,q=w,k=v;for(let e=0;e<n;e+=2)R=R+(j=t0(j^(E=E+O|0),16))|0,E=E+(O=t0(O^R,12))|0,R=R+(j=t0(j^E,8))|0,O=t0(O^R,7),C=C+(U=t0(U^(I=I+S|0),16))|0,I=I+(S=t0(S^C,12))|0,C=C+(U=t0(U^I,8))|0,S=t0(S^C,7),T=T+(q=t0(q^(x=x+_|0),16))|0,x=x+(_=t0(_^T,12))|0,T=T+(q=t0(q^x,8))|0,_=t0(_^T,7),N=N+(k=t0(k^(P=P+A|0),16))|0,P=P+(A=t0(A^N,12))|0,N=N+(k=t0(k^P,8))|0,A=t0(A^N,7),T=T+(k=t0(k^(E=E+S|0),16))|0,E=E+(S=t0(S^T,12))|0,T=T+(k=t0(k^E,8))|0,S=t0(S^T,7),N=N+(j=t0(j^(I=I+_|0),16))|0,I=I+(_=t0(_^N,12))|0,N=N+(j=t0(j^I,8))|0,_=t0(_^N,7),R=R+(U=t0(U^(x=x+A|0),16))|0,x=x+(A=t0(A^R,12))|0,R=R+(U=t0(U^x,8))|0,A=t0(A^R,7),C=C+(q=t0(q^(P=P+O|0),16))|0,P=P+(O=t0(O^C,12))|0,C=C+(q=t0(q^P,8))|0,O=t0(O^C,7);let D=0;i[D++]=o+E|0,i[D++]=a+I|0,i[D++]=c+x|0,i[D++]=l+P|0,i[D++]=h+O|0,i[D++]=u+S|0,i[D++]=p+_|0,i[D++]=d+A|0,i[D++]=f+R|0,i[D++]=g+C|0,i[D++]=y+T|0,i[D++]=m+N|0,i[D++]=s+j|0,i[D++]=b+U|0,i[D++]=w+q|0,i[D++]=v+k|0},{counterRight:!1,counterLength:4,allowShortKeys:!1}),t9=new Uint8Array(16),t7=(e,t)=>{e.update(t);let r=t.length%16;r&&e.update(t9.subarray(r))},re=new Uint8Array(32);function rt(e,t,r,i,s){let n=e(t,r,re),o=t6.create(n);s&&t7(o,s),t7(o,i);let a=new Uint8Array(16),c=new DataView(a.buffer,a.byteOffset,a.byteLength);tK(c,0,BigInt(s?s.length:0),!0),tK(c,8,BigInt(i.length),!0),o.update(a);let l=o.digest();return tJ(n,a),l}let rr=((e,t)=>{function r(i,...s){if(tM(i),void 0!==e.nonceLength){let t=s[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?tM(t):tM(t,e.nonceLength)}let n=e.tagLength;n&&void 0!==s[1]&&tM(s[1]);let o=t(i,...s),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");tM(t)}},c=!1;return{encrypt(e,t){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,tM(e),a(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(tM(e),n&&e.length<n)throw Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(r,e),r})({blockSize:64,nonceLength:12,tagLength:16},(e,t,r)=>({encrypt(i,s){let n=i.length;(s=tF(n+16,s,!1)).set(i);let o=s.subarray(0,-16);t4(e,t,o,o,1);let a=rt(t4,e,t,o,r);return s.set(a,n),tJ(a),s},decrypt(i,s){s=tF(i.length-16,s,!1);let n=i.subarray(0,-16),o=i.subarray(-16),a=rt(t4,e,t,n,r);if(!function(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}(o,a))throw Error("invalid tag");return s.set(i.subarray(0,-16)),t4(e,t,s,s,1),tJ(a),s}}));class ri extends e9{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,eZ(e);const r=e4(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return eQ(this),this.iHash.update(e),this}digestInto(e){eQ(this),eY(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=s,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let rs=(e,t,r)=>new ri(e,t).update(r).digest();rs.create=(e,t)=>
4new ri(e,t);let rn=new Uint8Array([0]),ro=new Uint8Array;class ra extends e9{constructor(e,t,r,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=e8(this.buffer)}update(e){eQ(this);let{view:t,buffer:r,blockLen:i}=this,s=(e=e4(e)).length;for(let n=0;n<s;){let o=Math.min(i-this.pos,s-n);if(o===i){let t=e8(e);for(;i<=s-n;n+=i)this.process(t,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){eQ(this),eX(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:s}=this,{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(r,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),c=4*!!i,l=4*!i;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)})(r,i-8,BigInt(8*this.length),s),this.process(r,0);let o=e8(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:i,finished:s,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=s,e.destroyed=n,i%t&&e.buffer.set(r),e}}let rc=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),rl=new Uint32Array([0x6a09e66
47,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),rh=new Uint32Array(64);class ru extends ra{constructor(){super(64,32,8,!1),this.A=0|rl[0],this.B=0|rl[1],this.C=0|rl[2],this.D=0|rl[3],this.E=0|rl[4],this.F=0|rl[5],this.G=0|rl[6],this.H=0|rl[7]}get(){let{A:e,B:t,C:r,D:i,E:s,F:n,G:o,H:a}=this;return[e,t,r,i,s,n,o,a]}set(e,t,r,i,s,n,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|s,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)rh[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=rh[e-15],r=rh[e-2],i=e5(t,7)^e5(t,18)^t>>>3,s=e5(r,17)^e5(r,19)^r>>>10;rh[e]=s+rh[e-7]+i+rh[e-16]|0}let{A:r,B:i,C:s,D:n,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){var h,u,p,d;let t=l+(e5(o,6)^e5(o,11)^e5(o,25))+((h=o)&a^~h&c)+rc[e]+rh[e]|0,f=(e5(r,2)^e5(r,13)^e5(r,22))+((u=r)&(p=i)^u&(d=s)^p&d)|0;l=c,c=a,a=o,o=n+t|0,n=s,s=i,i=r,r=t+f|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,s,n,o,a,c,l)}roundClean(){rh.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let rp=e7(()=>new ru),rd=BigInt(0),rf=BigInt(1),rg=BigInt(2);function ry(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function rm(e){if(!ry(e))throw Error("Uint8Array expected")}function rb(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}let rw=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function rv(e){rm(e);let t="";for(let r=0;r<e.length;r++)t+=rw[e[r]];return t}function rE(e){let t=e.toString(16);return 1&t.length?"0"+t:t}function rI(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?rd:BigInt("0x"+e)}function rx(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function rP(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){let r=rx(e.charCodeAt(s)),n=rx(e.charCodeAt(s+1));if(void 0===r||void 0===n)throw Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);i[t]=16*r+n}return i}function rO(e){return rI(rv(e))}function rS(e){return rm(e),rI(rv(Uint8Array.from(e).reverse()))}function r_(e,t){return rP(e.toString(16).padStart(2*t,"0"))}function rA(e,t){return r_(e,t).reverse()}function rR(e,t,r){let i;if("string"==typeof t)try{i=rP(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(ry(t))i=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let s=i.length;if("number"==typeof r&&s!==r)throw Error(e+" of length "+r+" expected, got "+s);return i}function rC(...e){let t=0;for(let r=0;r<e.length;r++){let i=e[r];rm(i),t+=i.length}let r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}let rT=e=>"bigint"==typeof e&&rd<=e;function rN(e,t,r){return rT(e)&&rT(t)&&rT(r)&&t<=e&&e<r}function rj(e,t,r,i){if(!rN(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function rU(e){let t;for(t=0;e>rd;e>>=rf,t+=1);return t}let rq=e=>(rg<<BigInt(e-1))-rf,rk=e=>new Uint8Array(e);function rD(e,t,r){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");let i=rk(e),s=rk(e),n=0,o=()=>{i.fill(1),s.fill(0),n=0},a=(...e)=>r(s,i,...e),c=(e=rk())=>{let t,r;s=a((t=[0],Uint8Array.from(t)),e),i=a(),0!==e.length&&(s=a((r=[1],Uint8Array.from(r)),e),i=a())},l=()=>{if(n++>=1e3)throw Error("drbg: tried 1000 values");let e=0,r=[];for(;e<t;){let t=(i=a()).slice();r.push(t),e+=i.length}return rC(...r)};return(e,t)=>{let r;for(o(),c(e);!(r=t(l()));)c();return o(),r}}let rL={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||ry(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function rB(e,t,r={}){let i=(t,r,i)=>{let s=rL[r];if("function"!=typeof s)throw Error("invalid validator function");let n=e[t];if(!(i&&void 0===n)&&!s(n,e))throw Error("param "+String(t)+" is invali
4d. Expected "+r+", got "+n)};for(let[e,r]of Object.entries(t))i(e,r,!1);for(let[e,t]of Object.entries(r))i(e,t,!0);return e}function rM(e){let t=new WeakMap;return(r,...i)=>{let s=t.get(r);if(void 0!==s)return s;let n=e(r,...i);return t.set(r,n),n}}var r$=Object.freeze({__proto__:null,isBytes:ry,abytes:rm,abool:rb,bytesToHex:rv,numberToHexUnpadded:rE,hexToNumber:rI,hexToBytes:rP,bytesToNumberBE:rO,bytesToNumberLE:rS,numberToBytesBE:r_,numberToBytesLE:rA,numberToVarBytesBE:function(e){return rP(rE(e))},ensureBytes:rR,concatBytes:rC,equalBytes:function(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))},inRange:rN,aInRange:rj,bitLen:rU,bitGet:function(e,t){return e>>BigInt(t)&rf},bitSet:function(e,t,r){return e|(r?rf:rd)<<BigInt(t)},bitMask:rq,createHmacDrbg:rD,validateObject:rB,notImplemented:()=>{throw Error("not implemented")},memoized:rM});let rz=BigInt(0),rH=BigInt(1),rV=BigInt(2),rF=BigInt(3),rK=BigInt(4),rW=BigInt(5),rJ=BigInt(8);function rG(e,t){let r=e%t;return r>=rz?r:t+r}function rY(e,t,r){if(t<rz)throw Error("invalid exponent, negatives unsupported");if(r<=rz)throw Error("invalid modulus");if(r===rH)return rz;let i=rH;for(;t>rz;)t&rH&&(i=i*e%r),e=e*e%r,t>>=rH;return i}function rZ(e,t,r){let i=e;for(;t-- >rz;)i*=i,i%=r;return i}function rQ(e,t){if(e===rz)throw Error("invert: expected non-zero number");if(t<=rz)throw Error("invert: expected positive modulus, got "+t);let r=rG(e,t),i=t,s=rz,n=rH;for(;r!==rz;){let e=i/r,t=i%r,o=s-n*e;i=r,r=t,s=n,n=o}if(i!==rH)throw Error("invert: does not exist");return rG(s,t)}let rX=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function r0(e,t){let r=void 0!==t?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function r1(e,t,r=!1,i={}){let s;if(e<=rz)throw Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:n,nByteLength:o}=r0(e,t);if(o>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let a=Object.freeze({ORDER:e,isLE:r,BITS:n,BYTES:o,MASK:rq(n),ZERO:rz,ONE:rH,create:t=>rG(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return rz<=t&&t<e},is0:e=>e===rz,isOdd:e=>(e&rH)===rH,neg:t=>rG(-t,e),eql:(e,t)=>e===t,sqr:t=>rG(t*t,e),add:(t,r)=>rG(t+r,e),sub:(t,r)=>rG(t-r,e),mul:(t,r)=>rG(t*r,e),pow:(e,t)=>(function(e,t,r){if(r<rz)throw Error("invalid exponent, negatives unsupported");if(r===rz)return e.ONE;if(r===rH)return t;let i=e.ONE,s=t;for(;r>rz;)r&rH&&(i=e.mul(i,s)),s=e.sqr(s),r>>=rH;return i})(a,e,t),div:(t,r)=>rG(t*rQ(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>rQ(t,e),sqrt:i.sqrt||(t=>(s||(s=function(e){if(e%rK===rF){let t=(e+rH)/rK;return function(e,r){let i=e.pow(r,t);if(!e.eql(e.sqr(i),r))throw Error("Cannot find square root");return i}}if(e%rJ===rW){let t=(e-rW)/rJ;return function(e,r){let i=e.mul(r,rV),s=e.pow(i,t),n=e.mul(r,s),o=e.mul(e.mul(n,rV),s),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),r))throw Error("Cannot find square root");return a}}return function(e){let t,r,i,s=(e-rH)/rV;for(t=e-rH,r=0;t%rV===rz;t/=rV,r++);for(i=rV;i<e&&rY(i,s,e)!==e-rH;i++)if(i>1e3)throw Error("Cannot find square root: likely non-prime P");if(1===r){let t=(e+rH)/rK;return function(e,r){let i=e.pow(r,t);if(!e.eql(e.sqr(i),r))throw Error("Cannot find square root");return i}}let n=(t+rH)/rV;return function(e,o){if(e.pow(o,s)===e.neg(e.ONE))throw Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),t),l=e.pow(o,n),h=e.pow(o,t);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(h);t<a&&!e.eql(r,e.ONE);t++)r=e.sqr(r);let r=e.pow(c,rH<<BigInt(a-t-1));c=e.sqr(r),l=e.mul(l,r),h=e.mul(h,c),a=t}return l}}(e)}(e)),s(a,t))),invertBatch:e=>{let t,r,i;return t=Array(e.length),r=e.reduce((e,r,i)=>a.is0(r)?e:(t[i]=e,a.mul(e,r)),a.ONE),i=a.inv(r),e.reduceRight((e,r,i)=>a.is0(r)?e:(t[i]=a.mul(e,t[i]),a.mul(e,r)),i),t},cmov:(e,t,r)=>r?t:e,toBytes:e=>r?rA(e,o):r_(e,o),fromBytes:e=>{if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);return r?rS(e):rO(e)}});return Object.freeze(a)}function r2(e){if("bigint"!=typeof e)throw Error("field order must be bigint");return Math.ceil(e.toString(2).length/8)}function r8(e){let t=r2(e);return t+Math.ceil(t/2)}let r5=BigInt(0),r3=BigInt(1);function r6(e,t){let r=t.negate();return e?r:t}function r4(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function r9(e,t){return r4(e,t),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}let r7=new WeakMap,ie=new WeakMap;function it(e){return ie.get(e)||1}function ir(e){return rB(e.Fp,rX.reduce((e,t)=>
4(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),rB(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...r0(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);let ii=BigInt(0),is=BigInt(1),io=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);let ia=BigInt(1),ic=BigInt(2),il=BigInt(3),ih=BigInt(5);BigInt(8);let iu=function(e){let t=(rB(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})),{P:r}=t,i=e=>rG(e,r),s=t.montgomeryBits,n=Math.ceil(s/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>rY(e,r-BigInt(2),r));function l(e,t,r){let s=i(e*(t-r));return[t=i(t-s),r=i(r+s)]}let h=(t.a-BigInt(2))/BigInt(4);function u(e,t){let u,p=function(e,t){rj("u",e,ii,r),rj("scalar",t,ii,r);let n=is,o=ii,a=e,u=is,p=ii,d;for(let r=BigInt(s-1);r>=ii;r--){let s=t>>r&is;p^=s,n=(d=l(p,n,a))[0],a=d[1],o=(d=l(p,o,u))[0],u=d[1],p=s;let c=n+o,f=i(c*c),g=n-o,y=i(g*g),m=f-y,b=a+u,w=i((a-u)*c),v=i(b*g),E=w+v,I=w-v;a=i(E*E),u=i(e*i(I*I)),n=i(f*y),o=i(m*(f+i(h*m)))}return n=(d=l(p,n,a))[0],a=d[1],o=(d=l(p,o,u))[0],u=d[1],i(n*c(o))}((u=rR("u coordinate",t,n),32===o&&(u[31]&=127),rS(u)),function(e){let t=rR("scalar",e),r=t.length;if(r!==n&&r!==o)throw Error("invalid scalar, expected "+(""+n+" or ")+o+" bytes, got "+r);return rS(a(t))}(e));if(p===ii)throw Error("invalid private or public key received");return rA(i(p),n)}let p=rA(i(t.Gu),n);function d(e){return u(e,p)}return{scalarMult:u,scalarMultBase:d,getSharedSecret:(e,t)=>u(e,t),getPublicKey:e=>d(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}({P:io,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let t,r,i,s,n,o,a,c,l,h,u,p,d,f,{pow_p_5_8:g,b2:y}=(t=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),o=rZ(n=e*e%io*e%io,ic,io)*n%io,a=rZ(o,ia,io)*e%io,c=rZ(a,ih,io)*a%io,l=rZ(c,t,io)*c%io,h=rZ(l,r,io)*l%io,u=rZ(h,i,io)*h%io,p=rZ(u,s,io)*u%io,d=rZ(p,s,io)*u%io,f=rZ(d,t,io)*c%io,{pow_p_5_8:rZ(f,ic,io)*e%io,b2:n});return rG(rZ(g,il,io)*y,io)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:te});function ip(e){void 0!==e.lowS&&rb("lowS",e.lowS),void 0!==e.prehash&&rb("prehash",e.prehash)}let{bytesToNumberBE:id,hexToBytes:ig}=r$;class iy extends Error{constructor(e=""){super(e)}}let im={Err:iy,_tlv:{encode:(e,t)=>{let{Err:r}=im;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");let i=t.length/2,s=rE(i);if(s.length/2&128)throw new r("tlv.encode: long form length too big");let n=i>127?rE(s.length/2|128):"";return rE(e)+n+s+t},decode(e,t){let{Err:r}=im,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let s=t[i++],n=0;if(128&s){let e=127&s;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");let o=t.subarray(i,i+e);if(o.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(let e of o)n=n<<8|e;if(i+=e,n<128)throw new r("tlv.decode(long): not minimal encoding")}else n=s;let o=t.subarray(i,i+n);if(o.length!==n)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(i+n)}}},_int:{encode(e){let{Err:t}=im;if(e<ib)throw new t("integer: negative integers are not allowed");let r=rE(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=im;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return id(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=im,s="string"==typeof e?ig(e):e;rm(s);let{v:n,l:o}=i.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,n),{v:l,l:h}=i.decode(2,c);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=im,i=t.encode(2,r.encode(e.r)),s=t.encode(2,r.encode(e.s));return t.encode(48,i+s)}},ib=BigInt(0),iw=BigInt(1);BigInt(2);let iv=BigInt(3);BigInt(4);let iE=r1(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),iI=(a={a:iE.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:iE,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),G
vendor: 1,402 bytes, line 4
4y:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},{...(n=e=>(function(e){let t,r=(rB(t=ir(e),{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})),{Fp:i,n:s}=r,n=i.BYTES+1,o=2*i.BYTES+1;function a(e){return rG(e,s)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:u}=function(e){var t;let r=function(e){let t=ir(e);rB(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:i,a:s}=t;if(r){if(!i.eql(s,i.ZERO))throw Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:i}=r,s=r1(r.n,r.nBitLength),n=r.toBytes||((e,t,r)=>{let s=t.toAffine();return rC(Uint8Array.from([4]),i.toBytes(s.x),i.toBytes(s.y))}),o=r.fromBytes||(e=>{let t=e.subarray(1);return{x:i.fromBytes(t.subarray(0,i.BYTES)),y:i.fromBytes(t.subarray(i.BYTES,2*i.BYTES))}});function a(e){let{a:t,b:s}=r,n=i.sqr(e),o=i.mul(n,e);return i.add(i.add(o,i.mul(e,t)),s)}
4if(!i.eql(i.sqr(r.Gy),a(r.Gx)))throw Error("bad generator point: equation left != right");function c(e){let t,{allowedPrivateKeyLengths:i,nByteLength:s,wrapPrivateKey:n,n:o}=r;if(i&&"bigint"!=typeof e){if(ry(e)&&(e=rv(e)),"string"!=typeof e||!i.includes(e.length))throw Error("invalid private key");e=e.padStart(2*s,"0")}try{t="bigint"==typeof e?e:rO(rR("private key",e,s))}catch{throw Error("invalid private key, expected hex or "+s+" bytes, got "+typeof e)}return n&&(t=rG(t,o)),rj("private key",t,iw,o),t}function l(e){if(!(e instanceof p))throw Error("ProjectivePoint expected")}let h=rM((e,t)=>{let{px:r,py:s,pz:n}=e;if(i.eql(n,i.ONE))return{x:r,y:s};let o=e.is0();null==t&&(t=o?i.ONE:i.inv(n));let a=i.mul(r,t),c=i.mul(s,t),l=i.mul(n,t);if(o)return{x:i.ZERO,y:i.ZERO};if(!i.eql(l,i.ONE))throw Error("invZ was invalid");return{x:a,y:c}}),u=rM(e=>{if(e.is0()){if(r.allowInfinityPoint&&!i.is0(e.py))return;throw Error("bad point: ZERO")}let{x:t,y:s}=e.toAffine();if(!i.isValid(t)||!i.isValid(s))throw Error("bad point: x or y not FE");let n=i.sqr(s),o=a(t);if(!i.eql(n,o))throw Error("bad point: equation left != right");if(!e.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});class p{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!i.isValid(e))throw Error("x required");if(null==t||!i.isValid(t))throw Error("y required");if(null==r||!i.isValid(r))throw Error("z required");Object.freeze(this)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!i.isValid(t)||!i.isValid(r))throw Error("invalid affine point");if(e instanceof p)throw Error("projective point not allowed");let s=e=>i.eql(e,i.ZERO);return s(t)&&s(r)?p.ZERO:new p(t,r,i.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=i.invertBatch(e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(p.fromAffine)}static fromHex(e){let t=p.fromAffine(o(rR("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(c(e))}static msm(e,t){return function(e,t,r,i){if(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw Error("invalid point at index "+r)})}(r,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw Error("invalid scalar at index "+r)})}(i,t),r.length!==i.length)throw Error("arrays of points and scalars must have equal length");let s=e.ZERO,n=rU(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=Array(a+1).fill(s),l=Math.floor((t.BITS-1)/o)*o,h=s;for(let e=l;e>=0;e-=o){c.fill(s);for(let t=0;t<i.length;t++){let s=Number(i[t]>>BigInt(e)&BigInt(a));c[s]=c[s].add(r[t])}let t=s;for(let e=c.length-1,r=s;e>0;e--)r=r.add(c[e]),t=t.add(r);if(h=h.add(t),0!==e)for(let e=0;e<o;e++)h=h.double()}return h}(p,s,e,t)}_setWindowSize(e){f.setWindowSize(this,e)}assertValidity(){u(this)}hasEvenY(){let{y:e}=this.toAffine();if(i.isOdd)return!i.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){l(e);let{px:t,py:r,pz:s}=this,{px:n,py:o,pz:a}=e,c=i.eql(i.mul(t,a),i.mul(n,s)),h=i.eql(i.mul(r,a),i.mul(o,s));return c&&h}negate(){return new p(this.px,i.neg(this.py),this.pz)}double(){let{a:e,b:t}=r,s=i.mul(t,iv),{px:n,py:o,pz:a}=this,c=i.ZERO,l=i.ZERO,h=i.ZERO,u=i.mul(n,n),d=i.mul(o,o),f=i.mul(a,a),g=i.mul(n,o);return g=i.add(g,g),h=i.mul(n,a),h=i.add(h,h),c=i.mul(e,h),l=i.mul(s,f),l=i.add(c,l),c=i.sub(d,l),l=i.add(d,l),l=i.mul(c,l),c=i.mul(g,c),h=i.mul(s,h),f=i.mul(e,f),g=i.sub(u,f),g=i.mul(e,g),g=i.add(g,h),h=i.add(u,u),u=i.add(h,u),u=i.add(u,f),u=i.mul(u,g),l=i.add(l,u),f=i.mul(o,a),f=i.add(f,f),u=i.mul(f,g),c=i.sub(c,u),h=i.mul(f,d),h=i.add(h,h),new p(c,l,h=i.add(h,h))}add(e){l(e);let{px:t,py:s,pz:n}=this,{px:o,py:a,pz:c}=e,h=i.ZERO,u=i.ZERO,d=i.ZERO,f=r.a,g=i.mul(r.b,iv),y=i.mul(t,o),m=i.mul(s,a),b=i.mul(n,c),w=i.add(t,s),v=i.add(o,a);w=i.mul(w,v),v=i.add(y,m),w=i.sub(w,v),v=i.add(t,n);let E=i.add(o,c);return v=i.mul(v,E),E=i.add(y,b),v=i.sub(v,E),E=i.add(s,n),h=i.add(a,c),E=i.mul(E,h),h=i.add(m,b),E=i.sub(E,h),d=i.mul(f,v),h=i.mul(g,b),d=i.add(h,d),h=i.sub(m,d),d=i.add(m,d),u=i.mul(h,d),m=i.add(y,y),m=i.add(m,y),b=i.mul(f,b),v=i.mul(g,v),m=i.add(m,b),b=i.sub(y,b),b=i.mul(f,b),v=i.add(v,b),y=i.mul(m,v),u=i.add(u,y),y=i.mul(E,v),h=i.mul(w,h),h=i.sub(h,y),y=i.mul(w,m),d=i.mul(E,d),new p(h,u,d=i.add(d,y))}subtract(e){return this.add(e.negate())}is0(){return this.equals(p.ZERO)}wNAF(e){return f.wNAFCached(this,e,p.normalizeZ)}multiplyUnsafe(e){let{endo:t,n:s}=r;rj("scalar",e,ib,s);let n=p.ZERO;if(e===ib)return n;if(this.is0()||e===iw)return this;if(!t||f.hasPrecomputes(this))return f.wNAFCachedUnsafe(this,e,p.normalizeZ);
4let{k1neg:o,k1:a,k2neg:c,k2:l}=t.splitScalar(e),h=n,u=n,d=this;for(;a>ib||l>ib;)a&iw&&(h=h.add(d)),l&iw&&(u=u.add(d)),d=d.double(),a>>=iw,l>>=iw;return o&&(h=h.negate()),c&&(u=u.negate()),u=new p(i.mul(u.px,t.beta),u.py,u.pz),h.add(u)}multiply(e){let t,s,{endo:n,n:o}=r;if(rj("scalar",e,iw,o),n){let{k1neg:r,k1:o,k2neg:a,k2:c}=n.splitScalar(e),{p:l,f:h}=this.wNAF(o),{p:u,f:d}=this.wNAF(c);l=f.constTimeNegate(r,l),u=f.constTimeNegate(a,u),u=new p(i.mul(u.px,n.beta),u.py,u.pz),t=l.add(u),s=h.add(d)}else{let{p:r,f:i}=this.wNAF(e);t=r,s=i}return p.normalizeZ([t,s])[0]}multiplyAndAddUnsafe(e,t,r){let i=p.BASE,s=(e,t)=>t!==ib&&t!==iw&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),n=s(this,t).add(s(e,r));return n.is0()?void 0:n}toAffine(e){return h(this,e)}isTorsionFree(){let{h:e,isTorsionFree:t}=r;if(e===iw)return!0;if(t)return t(p,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:e,clearCofactor:t}=r;return e===iw?this:t?t(p,this):this.multiplyUnsafe(r.h)}toRawBytes(e=!0){return rb("isCompressed",e),this.assertValidity(),n(p,this,e)}toHex(e=!0){return rb("isCompressed",e),rv(this.toRawBytes(e))}}p.BASE=new p(r.Gx,r.Gy,i.ONE),p.ZERO=new p(i.ZERO,i.ONE,i.ZERO);let d=r.nBitLength,f=(t=r.endo?Math.ceil(d/2):d,{constTimeNegate:r6,hasPrecomputes:e=>1!==it(e),unsafeLadder(e,t,r=p.ZERO){let i=e;for(;t>r5;)t&r3&&(r=r.add(i)),i=i.double(),t>>=r3;return r},precomputeWindow(e,r){let{windows:i,windowSize:s}=r9(r,t),n=[],o=e,a=o;for(let e=0;e<i;e++){a=o,n.push(a);for(let e=1;e<s;e++)a=a.add(o),n.push(a);o=a.double()}return n},wNAF(e,r,i){let{windows:s,windowSize:n}=r9(e,t),o=p.ZERO,a=p.BASE,c=BigInt(2**e-1),l=2**e,h=BigInt(e);for(let e=0;e<s;e++){let t=e*n,s=Number(i&c);i>>=h,s>n&&(s-=l,i+=r3);let u=t+Math.abs(s)-1,p=e%2!=0,d=s<0;0===s?a=a.add(r6(p,r[t])):o=o.add(r6(d,r[u]))}return{p:o,f:a}},wNAFUnsafe(e,r,i,s=p.ZERO){let{windows:n,windowSize:o}=r9(e,t),a=BigInt(2**e-1),c=2**e,l=BigInt(e);for(let e=0;e<n;e++){let t=e*o;if(i===r5)break;let n=Number(i&a);if(i>>=l,n>o&&(n-=c,i+=r3),0===n)continue;let h=r[t+Math.abs(n)-1];n<0&&(h=h.negate()),s=s.add(h)}return s},getPrecomputes(e,t,r){let i=r7.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&r7.set(t,r(i))),i},wNAFCached(e,t,r){let i=it(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)},wNAFCachedUnsafe(e,t,r,i){let s=it(e);return 1===s?this.unsafeLadder(e,t,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),t,i)},setWindowSize(e,r){r4(r,t),ie.set(e,r),r7.delete(e)}});return{CURVE:r,ProjectivePoint:p,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:function(e){return rN(e,iw,r.n)}}}({...r,toBytes(e,t,r){let s=t.toAffine(),n=i.toBytes(s.x);return rb("isCompressed",r),r?rC(Uint8Array.from([t.hasEvenY()?2:3]),n):rC(Uint8Array.from([4]),n,i.toBytes(s.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===n&&(2===r||3===r)){let e,t=rO(s);if(!rN(t,iw,i.ORDER))throw Error("Point is not on curve");let n=h(t);try{e=i.sqrt(n)}catch(e){throw Error("Point is not on curve"+(e instanceof Error?": "+e.message:""))}return(1&r)==1!=((e&iw)===iw)&&(e=i.neg(e)),{x:t,y:e}}if(t===o&&4===r)return{x:i.fromBytes(s.subarray(0,i.BYTES)),y:i.fromBytes(s.subarray(i.BYTES,2*i.BYTES))};throw Error("invalid Point, expected length of "+n+", or uncompressed "+o+", got "+t)}}),p=e=>rv(r_(e,r.nByteLength)),d=(e,t,r)=>rO(e.slice(t,r));class f{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){let t=r.nByteLength;return new f(d(e=rR("compactSignature",e,2*t),0,t),d(e,t,2*t))}static fromDER(e){let{r:t,s:r}=im.toSig(rR("DER",e));return new f(t,r)}assertValidity(){rj("r",this.r,iw,s),rj("s",this.s,iw,s)}addRecoveryBit(e){return new f(this.r,this.s,e)}recoverPublicKey(e){let{r:t,s:n,recovery:o}=this,l=m(rR("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw Error("recovery id invalid");let h=2===o||3===o?t+r.n:t;if(h>=i.ORDER)throw Error("recovery id 2 or 3 invalid");let u=(1&o)==0?"02":"03",d=c.fromHex(u+p(h)),f=rQ(h,s),g=a(-l*f),y=a(n*f),b=c.BASE.multiplyAndAddUnsafe(d,g,y);if(!b)throw Error("point at infinify");return b.assertValidity(),b}hasHighS(){return this.s>s>>iw}normalizeS(){return this.hasHighS()?new f(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return rP(this.toDERHex())}toDERHex(){return im.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return rP(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}function g(e){let t=ry(e),r="string"==typeof e,i=(t||r)&&e.length;return t?i===n||i===o:r?i===2*n||i===2*o:e instanceof c}let y=r.bits2int||function(e){if(e.length>8192)throw Error("input is too large");let t=rO(e),i=8*e.length-r.nBitLength;return i>0?t>>BigInt(i):t},m=r.bits2int_modN||function(e){return a(y(e))},b=rq(r.nBitLength);function w(e){return rj("num < 2^"+r.nBitLength,e,ib,b),r_(e,r.nByteLength)}let v={lowS:r.lowS,prehash:!1},E={lowS:r.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(g(e))throw Error("first arg must be private key");if(!g(t))throw Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(r)},sign:function(e,t,n=v){let{seed:o,k2sig:h}=function(e,t,n=v){if(["recovered","canonical"].some(e=>e in n))throw Error("sign() legacy options not supported");let{hash:o,randomBytes:h}=r,{lowS:p,prehash:d,extraEntropy:g}=n;null==p&&(p=!0),e=rR("msgHash",e),ip(n),d&&(e=rR("prehashed msgHash",o(e)));let b=m(e),E=l(t),I=[w(E),w(b)];if(null!=g&&!1!==g){let e=!0===g?h(i.BYTES):g;I.push(rR("extraEntropy",e))}return{seed:rC(...I),k2sig:function(e){var t;let r=y(e);if(!u(r))return;let i=rQ(r,s),n=c.BASE.multiply(r).toAffine(),o=a(n.x);if(o===ib)return;let l=a(i*a(b+o*E));if(l===ib)return;let h=2*(n.x!==o)|Number(n.y&iw),d=l;return p&&l>s>>iw&&(d=(t=l)>s>>iw?a(-t):t,h^=1),new f(o,d,h)}}}
4(e,t,n);return rD(r.hash.outputLen,r.nByteLength,r.hmac)(o,h)},verify:function(e,t,i,n=E){let o,l;t=rR("msgHash",t),i=rR("publicKey",i);let{lowS:h,prehash:u,format:p}=n;if(ip(n),"strict"in n)throw Error("options.strict was renamed to lowS");if(void 0!==p&&"compact"!==p&&"der"!==p)throw Error("format must be compact or der");let d="string"==typeof e||ry(e),g=!d&&!p&&"object"==typeof e&&null!==e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!d&&!g)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");try{if(g&&(o=new f(e.r,e.s)),d){try{"compact"!==p&&(o=f.fromDER(e))}catch(e){if(!(e instanceof im.Err))throw e}o||"der"===p||(o=f.fromCompact(e))}l=c.fromHex(i)}catch{return!1}if(!o||h&&o.hasHighS())return!1;u&&(t=r.hash(t));let{r:y,s:b}=o,w=m(t),v=rQ(b,s),I=a(w*v),x=a(y*v),P=c.BASE.multiplyAndAddUnsafe(l,I,x)?.toAffine();return!!P&&a(P.x)===y},ProjectivePoint:c,Signature:f,utils:{isValidPrivateKey(e){try{return l(e),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let e=r8(r.n);return function(e,t,r=!1){let i=e.length,s=r2(t),n=r8(t);if(i<16||i<n||i>1024)throw Error("expected "+n+"-1024 bytes of input, got "+i);let o=rG(r?rS(e):rO(e),t-rH)+rH;return r?rA(o,s):r_(o,s)}(r.randomBytes(e),r.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}})({...a,hash:e,hmac:(t,...r)=>rs(e,t,function(...e){let t=0;for(let r=0;r<e.length;r++){let i=e[r];eY(i),t+=i.length}let r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}(...r)),randomBytes:te}))(rp),create:n}),ix="base10",iP="base16",iO="base64pad",iS="base64url",i_="utf8";function iA(){let e=te(32);return(0,ea.dI)(e,iP)}function iR(e){let t=rp((0,ea.sH)(e,iP));return(0,ea.dI)(t,iP)}function iC(e){let t=rp((0,ea.sH)(e,i_));return(0,ea.dI)(t,iP)}function iT(e){return(0,ea.sH)(`${e}`,ix)}function iN(e){return Number((0,ea.dI)(e,ix))}function ij(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function iU(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4;return t+"=".repeat(r)}function iq(e){if(2===iN(e.type))return(0,ea.dI)((0,ea.xW)([e.type,e.sealed]),iO);if(1===iN(e.type)){if(typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");return(0,ea.dI)((0,ea.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),iO)}return(0,ea.dI)((0,ea.xW)([e.type,e.iv,e.sealed]),iO)}function ik(e){let t=(e.encoding||iO)===iS?iU(e.encoded):e.encoded,r=(0,ea.sH)(t,iO),i=r.slice(0,1);if(1===iN(i)){let e=r.slice(1,33),t=r.slice(33,45);return{type:i,sealed:r.slice(45),iv:t,senderPublicKey:e}}if(2===iN(i))return{type:i,sealed:r.slice(1),iv:te(12)};let s=r.slice(1,13);return{type:i,sealed:r.slice(13),iv:s}}function iD(e){let t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function iL(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function iB(e){return e?.relay||{protocol:"irn"}}function iM(e){let t=ec.CG[e];if(typeof t>"u")throw Error(`Relay Protocol not supported: ${e}`);return t}function i$(e){var t;if(!e.includes("wc:")){let t=eJ(e);null!=t&&t.includes("wc:")&&(e=t)}let r=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,s=e.substring(0,r),n=e.substring(r+1,i).split("@"),o=new URLSearchParams("u">typeof i?e.substring(i):""),a={};o.forEach((e,t)=>{a[t]=e});let c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:(t=n[0]).startsWith("//")?t.substring(2):t,version:parseInt(n[1],10),symKey:a.symKey,relay:function(e,t="-"){let r={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){let s=t.replace(i,""),n=e[t];r[s]=n}}),r}(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function iz(e){let t=new URLSearchParams,r=function(e,t="-"){let r={};return Object.keys(e).forEach(i=>
4{e[i]&&(r["relay"+t+i]=e[i])}),r}(e.relay);Object.keys(r).sort().forEach(e=>{t.set(e,r[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));let i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}function iH(e,t,r){return`${e}?wc_ev=${r}&topic=${t}`}var iV=Object.defineProperty,iF=Object.defineProperties,iK=Object.getOwnPropertyDescriptors,iW=Object.getOwnPropertySymbols,iJ=Object.prototype.hasOwnProperty,iG=Object.prototype.propertyIsEnumerable,iY=(e,t,r)=>t in e?iV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,iZ=(e,t)=>{for(var r in t||(t={}))iJ.call(t,r)&&iY(e,r,t[r]);if(iW)for(var r of iW(t))iG.call(t,r)&&iY(e,r,t[r]);return e},iQ=(e,t)=>iF(e,iK(t));function iX(e){let t=[];return e.forEach(e=>{let[r,i]=e.split(":");t.push(`${r}:${i}`)}),t}function i0(e){return e.includes(":")}function i1(e){return i0(e)?e.split(":")[0]:e}function i2(e){var t,r,i;let s={};if(!i7(e))return s;for(let[n,o]of Object.entries(e)){let e=i0(n)?[n]:o.chains,a=o.methods||[],c=o.events||[],l=i1(n);s[l]=iQ(iZ({},s[l]),{chains:ez(e,null==(t=s[l])?void 0:t.chains),methods:ez(a,null==(r=s[l])?void 0:r.methods),events:ez(c,null==(i=s[l])?void 0:i.events)})}return s}function i8(e,t){var r;let i,s=(r=t=t.map(e=>e.replace("did:pkh:","")),i={},r?.forEach(e=>{var t;let[r,s]=e.split(":");i[r]||(i[r]={accounts:[],chains:[],events:[],methods:[]}),i[r].accounts.push(e),null==(t=i[r].chains)||t.push(`${r}:${s}`)}),i);for(let[t,r]of Object.entries(s))r.methods?r.methods=ez(r.methods,e):r.methods=e,r.events=["chainChanged","accountsChanged"];return s}let i5={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},i3={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 i6(e,t){let{message:r,code:i}=i3[e];return{message:t?`${r} ${t}`:r,code:i}}function i4(e,t){let{message:r,code:i}=i5[e];return{message:t?`${r} ${t}`:r,code:i}}function i9(e,t){return!!Array.isArray(e)&&(!("u">typeof t)||!e.length||e.every(t))}function i7(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function se(e){return typeof e>"u"}function st(e,t){return!!(t&&se(e))||"string"==typeof e&&!!e.trim().length}function sr(e,t){return!!(t&&se(e))||"number"==typeof e&&!isNaN(e)}function si(e){return!!(st(e,!1)&&e.includes(":"))&&2===e.split(":").length}function ss(e){let t=!0;return i9(e)?e.length&&(t=e.every(e=>st(e,!1))):t=!1,t}function sn(e,t){let r=null;
4return Object.values(e).forEach(e=>{var i;let s;if(r)return;let n=(i=`${t}, namespace`,s=null,ss(e?.methods)?ss(e?.events)||(s=i4("UNSUPPORTED_EVENTS",`${i}, events should be an array of strings or empty array for no events`)):s=i4("UNSUPPORTED_METHODS",`${i}, methods should be an array of strings or empty array for no methods`),s);n&&(r=n)}),r}function so(e,t){let r=null;if(e&&i7(e)){let i,s=sn(e,t);s&&(r=s);let n=(i=null,Object.values(e).forEach(e=>{var r,s;let n;if(i)return;let o=(r=e?.accounts,s=`${t} namespace`,n=null,i9(r)?r.forEach(e=>{n||function(e){if(st(e,!1)&&e.includes(":")){let t=e.split(":");if(3===t.length){let e=t[0]+":"+t[1];return!!t[2]&&si(e)}}return!1}(e)||(n=i4("UNSUPPORTED_ACCOUNTS",`${s}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):n=i4("UNSUPPORTED_ACCOUNTS",`${s}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n);o&&(i=o)}),i);n&&(r=n)}else r=i6("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function sa(e){return st(e.protocol,!0)}function sc(e){return"u">typeof e}function sl(e,t){let r;return!(!si(t)||!(r=[],Object.values(e).forEach(e=>{r.push(...iX(e.accounts))}),r).includes(t))}function sh(e,t,r){var i,s;let n,o,a=null,c=(n={},Object.keys(i=e).forEach(e=>{var t;e.includes(":")?n[e]=i[e]:null==(t=i[e].chains)||t.forEach(t=>{n[t]={methods:i[e].methods,events:i[e].events}})}),n),l=(o={},Object.keys(s=t).forEach(e=>{if(e.includes(":"))o[e]=s[e];else{let t=iX(s[e].accounts);t?.forEach(t=>{o[t]={accounts:s[e].accounts.filter(e=>e.includes(`${t}:`)),methods:s[e].methods,events:s[e].events}})}}),o),h=Object.keys(c),u=Object.keys(l),p=su(Object.keys(e)),d=su(Object.keys(t)),f=p.filter(e=>!d.includes(e));return f.length&&(a=i6("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. 5 Required: ${f.toString()} 6 Received: ${Object.keys(t).toString()}`)),eN(h,u)||(a=i6("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. 7 Required: ${h.toString()} 8 Approved: ${u.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||a)return;let i=iX(t[e].accounts);i.includes(e)||(a=i6("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e} 9 Required: ${e} 10 Approved: ${i.toString()}`))}),h.forEach(e=>{a||(eN(c[e].methods,l[e].methods)?eN(c[e].events,l[e].events)||(a=i6("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):a=i6("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))}),a}function su(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function sp(){let e=eA();return new Promise(t=>{switch(e){case eP:t(e_()&&navigator?.onLine);break;case eI:t(sd());break;default:t(!0)}})}
10async function sd(){if(eS()&&"u">typeof r.g&&null!=r.g&&r.g.NetInfo){let e=await (null==r.g?void 0:r.g.NetInfo.fetch());return e?.isConnected}return!0}let sf={};class sg{static get(e){return sf[e]}static set(e,t){sf[e]=t}static delete(e){delete sf[e]}}var sy=r(97638),sm=r(27036),sb=r(34514),sw=r(8012),sv=Object.defineProperty,sE=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?sv(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class sI extends sw.H{constructor(e){super(),this.opts=e,sE(this,"protocol","wc"),sE(this,"version",2)}}var sx=Object.defineProperty;class sP extends sw.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?sx(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r})(this,"records",new Map)}}class sO{constructor(e,t){this.logger=e,this.core=t}}class sS extends sw.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class s_ extends sw.H{constructor(e){super()}}class sA{constructor(e,t,r,i){this.core=e,this.logger=t,this.name=r}}class sR extends sw.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class sC extends sw.H{constructor(e,t){super(),this.core=e,this.logger=t}}class sT{constructor(e,t,r){this.core=e,this.logger=t,this.store=r}}class sN{constructor(e,t){this.projectId=e,this.logger=t}}class sj{constructor(e,t,r){this.core=e,this.logger=t,this.telemetryEnabled=r}}var sU=Object.defineProperty,sq=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?sU(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};l();class sk{constructor(e){this.opts=e,sq(this,"protocol","wc"),sq(this,"version",2)}}c.EventEmitter;class sD{constructor(e){this.client=e}}var sL=r(66602),sB=r(7915),sM=r(4839),s$=r(56759),sz=r(82909).hp,sH=r(65364);let sV="core",sF=`wc@2:${sV}:`,sK={database:":memory:"},sW="client_ed25519_seed",sJ=u.ONE_DAY,sG=u.SIX_HOURS,sY="wss://relay.walletconnect.org",sZ="relayer_message",sQ="relayer_message_ack",sX="relayer_connection_stalled",s0="relayer_publish",s1="payload",s2="connect",s8="disconnect",s5="error",s3="2.21.1",s6="link_mode",s4="relay",s9="inbound",s7="WALLETCONNECT_LINK_MODE_APPS",ne="subscription_created",nt="subscription_deleted",nr=(u.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:u.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:u.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:u.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:u.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:u.ONE_DAY,prompt:!1,tag:0},res:{ttl:u.ONE_DAY,prompt:!1,tag:0}}}),ni="pairing_create",ns="pairing_delete",nn="history_created",no="history_updated",na="history_deleted",nc="expirer_created",nl="expirer_deleted",nh="expirer_expired",nu="https://verify.walletconnect.org",np=`${nu}/v3`,nd=["https://verify.walletconnect.com",nu],nf="malformed_pairing_uri",ng="session_approve_started";var ny=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==r[o])throw TypeError(n+" is ambiguous");r[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var i=0,s=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var u=0,p=n-1;(0!==h||u<s)&&-1!==p;p--,u++)h+=a*o[p]>>>0,o[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");s=u,t++}if(" "!==e[t]){for(var d=n-s;d!==n&&0===o[d];)d++;for(var f=new Uint8Array(i+(n-d)),g=i;d!==n;)f[g++]=o[d++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,s=0,n=t.length;s!==n&&0===t[s];)s++,r++;for(var o=(n-s)*h+1>>>0,l=new Uint8Array(o);s!==n;){for(var u=t[s],p=0,d=o-1;(0!==u||p<i)&&-1!==d;d--,p++)u+=256*l[d]>>>0,l[d]=u%a>>>0,u=u/a>>>0;if(0!==u)throw Error("Non-zero carry");i=p,s++}for(var f=o-i;f!==o&&0===l[f];)f++;for(var g=c.repeat(r);f<o;++f)g+=e.charAt(l[f]);return g},decodeUnsafe:u,decode:function(e){var r=u(e);if(r)return r;throw Error(`Non-${t} character`)}}};let nm=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unknown type, must be binary type")};
10class nb{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class nw{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return nE(this,e)}}class nv{constructor(e){this.decoders=e}or(e){return nE(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let nE=(e,t)=>new nv({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});
10class nI{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new nb(e,t,r),this.decoder=new nw(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let nx=({name:e,prefix:t,encode:r,decode:i})=>new nI(e,t,r,i),nP=({prefix:e,name:t,alphabet:r})=>{let{encode:i,decode:s}=ny(r,t);return nx({prefix:e,name:t,encode:i,decode:e=>nm(s(e))})},nO=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>nx({prefix:t,name:e,encode:e=>((e,t,r)=>{let i="="===t[t.length-1],s=(1<<r)-1,n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>r;)o-=r,n+=t[s&a>>o];if(o&&(n+=t[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n})(e,i,r),decode:t=>((e,t,r,i)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*r/8|0),a=0,c=0,l=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${i} character`);c=c<<r|n,(a+=r)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw SyntaxError("Unexpected end of data");return o})(t,i,r,e)});var nS=Object.freeze({__proto__:null,identity:nx({prefix:"\0",name:"identity",encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)})}),n_=Object.freeze({__proto__:null,base2:nO({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),nA=Object.freeze({__proto__:null,base8:nO({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),nR=Object.freeze({__proto__:null,base10:nP({prefix:"9",name:"base10",alphabet:"0123456789"})}),nC=Object.freeze({__proto__:null,base16:nO({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:nO({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})}),nT=Object.freeze({__proto__:null,base32:nO({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper:nO({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad:nO({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper:nO({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex:nO({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper:nO({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad:nO({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper:nO({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:nO({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),nN=Object.freeze({__proto__:null,base36:nP({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:nP({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),nj=Object.freeze({__proto__:null,base58btc:nP({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:nP({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})}),nU=Object.freeze({__proto__:null,base64:nO({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad:nO({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url:nO({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:nO({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let nq=Array.from("\uD83D\uDE80\uD83E\uDE90â\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09â\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02â¤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09âº\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9Eââ¨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2Dâ£\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33â\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13ââ
\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6â\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90â¹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20â\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2Bâ½\uD83E\uDD19â\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81â¡\uD83C\uDF1E\uD83C\uDF88ââ\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2Câ\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74â¶â¡â\uD83D\uDC8E\uD83D\uDCB8â¬\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7Aâ \uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37â\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51â\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),nk=nq.reduce((e,t,r)=>(e[r]=t,e),[]),nD=nq.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);var nL=Object.freeze({__proto__:null,base256emoji:nx({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>
10e+=nk[t],"")},decode:function(e){let t=[];for(let r of e){let e=nD[r.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}})});function nB(e,t,r){t=t||[],r=r||0;for(var i=r;e>=0x80000000;)t[r++]=255&e|128,e/=128;for(;-128&e;)t[r++]=255&e|128,e>>>=7;return t[r]=0|e,nB.bytes=r-i+1,t}var nM=function(e){return e<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:e<0x800000000?5:e<0x40000000000?6:e<0x2000000000000?7:e<0x100000000000000?8:e<0x8000000000000000?9:10};let n$=(e,t,r=0)=>(nB(e,t,r),t),nz=(e,t)=>{let r=t.byteLength,i=nM(e),s=i+nM(r),n=new Uint8Array(s+r);return n$(e,n,0),n$(r,n,i),n.set(t,s),new nH(e,r,t,n)};class nH{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}let nV=({name:e,code:t,encode:r})=>new nF(e,t,r);class nF{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?nz(this.code,t):t.then(e=>nz(this.code,e))}throw Error("Unknown type, must be binary type")}}let nK=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var nW=Object.freeze({__proto__:null,sha256:nV({name:"sha2-256",code:18,encode:nK("SHA-256")}),sha512:nV({name:"sha2-512",code:19,encode:nK("SHA-512")})}),nJ=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:nm,digest:e=>nz(0,nm(e))}});new TextEncoder,new TextDecoder;let nG={...nS,...n_,...nA,...nR,...nC,...nT,...nN,...nj,...nU,...nL};function nY(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}({...nW,...nJ});let nZ=nY("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),nQ=nY("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{let t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),nX={utf8:nZ,"utf-8":nZ,hex:nG.base16,latin1:nQ,ascii:nQ,binary:nQ,...nG};var n0=Object.defineProperty,n1=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?n0(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class n2{constructor(e,t){this.core=e,this.logger=t,n1(this,"keychain",new Map),n1(this,"name","keychain"),n1(this,"version","0.3"),n1(this,"initialized",!1),n1(this,"storagePrefix",sF),n1(this,"init",async()=>{if(!this.initialized){let e=await this.getKeyChain();"u">typeof e&&(this.keychain=e),this.initialized=!0}}),n1(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),n1(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),n1(this,"get",e=>{this.isInitialized();let t=this.keychain.get(e);if(typeof t>"u"){let{message:t}=i6("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}),n1(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,sb.U5)(t,this.name)}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ej(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?eU(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var n8=Object.defineProperty,n5=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?n8(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class n3{constructor(e,t,r){this.core=e,this.logger=t,n5(this,"name","crypto"),n5(this,"keychain"),n5(this,"randomSessionIdentifier",iA()),n5(this,"initialized",!1),n5(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),n5(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),n5(this,"getClientId",async()=>{this.isInitialized();let e=await this.getClientSeed(),t=eo.TZ(e);return eo.UF(t.publicKey)}),n5(this,"generateKeyPair",()=>{let e,t;this.isInitialized();let r=(e=iu.utils.randomPrivateKey(),t=iu.getPublicKey(e),{privateKey:(0,ea.dI)(e,iP),publicKey:(0,ea.dI)(t,iP)}
10);return this.setPrivateKey(r.publicKey,r.privateKey)}),n5(this,"signJWT",async e=>{this.isInitialized();let t=await this.getClientSeed(),r=eo.TZ(t),i=this.randomSessionIdentifier;return await eo.FA(i,e,sJ,r)}),n5(this,"generateSharedKey",(e,t,r)=>{var i,s,n;let o,a;this.isInitialized();let c=(i=this.getPrivateKey(e),o=iu.getSharedSecret((0,ea.sH)(i,iP),(0,ea.sH)(t,iP)),s=void 0,a=function(e,t,r,i=32){if(eZ(e),eG(i),i>255*e.outputLen)throw Error("Length should be <= 255*HashLen");let s=Math.ceil(i/e.outputLen);void 0===r&&(r=ro);let n=new Uint8Array(s*e.outputLen),o=rs.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<s;t++)rn[0]=t+1,a.update(0===t?ro:c).update(r).update(rn).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),rn.fill(0),n.slice(0,i)}(rp,(n=void 0,eZ(rp),void 0===n&&(n=new Uint8Array(rp.outputLen)),rs(rp,e4(n),e4(o))),s,32),(0,ea.dI)(a,iP));return this.setSymKey(c,r)}),n5(this,"setSymKey",async(e,t)=>{this.isInitialized();let r=t||iR(e);return await this.keychain.set(r,e),r}),n5(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),n5(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),n5(this,"encode",async(e,t,r)=>{this.isInitialized();let i=iD(r),s=(0,sL.h)(t);if(2===i.type){var n;let e,t,i;return n=r?.encoding,e=iT(2),t=te(12),i=iq({type:e,sealed:(0,ea.sH)(s,i_),iv:t}),n===iS?ij(i):i}if(iL(i)){let t=i.senderPublicKey,r=i.receiverPublicKey;e=await this.generateSharedKey(t,r)}let o=this.getSymKey(e),{type:a,senderPublicKey:c}=i;return function(e){let t=iT("u">typeof e.type?e.type:0);if(1===iN(t)&&typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");let r="u">typeof e.senderPublicKey?(0,ea.sH)(e.senderPublicKey,iP):void 0,i="u">typeof e.iv?(0,ea.sH)(e.iv,iP):te(12),s=iq({type:t,sealed:rr((0,ea.sH)(e.symKey,iP),i).encrypt((0,ea.sH)(e.message,i_)),iv:i,senderPublicKey:r});return e.encoding===iS?ij(s):s}({type:a,symKey:o,message:s,senderPublicKey:c,encoding:r?.encoding})}),n5(this,"decode",async(e,t,r)=>{let i;this.isInitialized();let s=iD({type:iN((i=ik({encoded:t,encoding:r?.encoding})).type),senderPublicKey:"u">typeof i.senderPublicKey?(0,ea.dI)(i.senderPublicKey,iP):void 0,receiverPublicKey:r?.receiverPublicKey});if(2===s.type){let e=function(e,t){let{sealed:r}=ik({encoded:e,encoding:t});return(0,ea.dI)(r,i_)}(t,r?.encoding);return(0,sL.j)(e)}if(iL(s)){let t=s.receiverPublicKey,r=s.senderPublicKey;e=await this.generateSharedKey(t,r)}try{let i=this.getSymKey(e),s=function(e){let t=(0,ea.sH)(e.symKey,iP),{sealed:r,iv:i}=ik({encoded:e.encoded,encoding:e.encoding}),s=rr(t,i).decrypt(r);if(null===s)throw Error("Failed to decrypt");return(0,ea.dI)(s,i_)}({symKey:i,encoded:t,encoding:r?.encoding});return(0,sL.j)(s)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),n5(this,"getPayloadType",(e,t=iO)=>iN(ik({encoded:e,encoding:t}).type)),n5(this,"getPayloadSenderPublicKey",(e,t=iO)=>{let r=ik({encoded:e,encoding:t});return r.senderPublicKey?(0,ea.dI)(r.senderPublicKey,iP):void 0}),this.core=e,this.logger=(0,sb.U5)(t,this.name),this.keychain=r||new n2(this.core,this.logger)}get context(){return(0,sb.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(sW)}catch{e=iA(),await this.keychain.set(sW,e)}return function(e,t="utf8"){let r=nX[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e,"utf8"):r.decoder.decode(`${r.prefix}${e}`)}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var n6=Object.defineProperty,n4=Object.defineProperties,n9=Object.getOwnPropertyDescriptors,n7=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,or=(e,t,r)=>t in e?n6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oi=(e,t,r)=>or(e,"symbol"!=typeof t?t+"":t,r);class os extends sO{constructor(e,t){super(e,t),this.logger=e,this.core=t,oi(this,"messages",new Map),oi(this,"messagesWithoutClientAck",new Map),oi(this,"name","messages"),oi(this,"version","0.3"),oi(this,"initialized",!1),oi(this,"storagePrefix",sF),oi(this,"init",async()=>
10{if(!this.initialized){this.logger.trace("Initialized");try{let e=await this.getRelayerMessages();"u">typeof e&&(this.messages=e);let t=await this.getRelayerMessagesWithoutClientAck();"u">typeof t&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),oi(this,"set",async(e,t,r)=>{this.isInitialized();let i=iC(t),s=this.messages.get(e);if(typeof s>"u"&&(s={}),"u">typeof s[i])return i;if(s[i]=t,this.messages.set(e,s),r===s9){let r=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,n4(((e,t)=>{for(var r in t||(t={}))oe.call(t,r)&&or(e,r,t[r]);if(n7)for(var r of n7(t))ot.call(t,r)&&or(e,r,t[r]);return e})({},r),n9({[i]:t})))}return await this.persist(),i}),oi(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),oi(this,"getWithoutAck",e=>{this.isInitialized();let t={};for(let r of e){let e=this.messagesWithoutClientAck.get(r)||{};t[r]=Object.values(e)}return t}),oi(this,"has",(e,t)=>(this.isInitialized(),"u">typeof this.get(e)[iC(t)])),oi(this,"ack",async(e,t)=>{this.isInitialized();let r=this.messagesWithoutClientAck.get(e);if(typeof r>"u")return;let i=iC(t);delete r[i],0===Object.keys(r).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,r),await this.persist()}),oi(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,sb.U5)(e,this.name),this.core=t}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ej(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ej(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?eU(e):void 0}async getRelayerMessagesWithoutClientAck(){let e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return"u">typeof e?eU(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var on=Object.defineProperty,oo=Object.defineProperties,oa=Object.getOwnPropertyDescriptors,oc=Object.getOwnPropertySymbols,ol=Object.prototype.hasOwnProperty,oh=Object.prototype.propertyIsEnumerable,ou=(e,t,r)=>t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,op=(e,t)=>{for(var r in t||(t={}))ol.call(t,r)&&ou(e,r,t[r]);if(oc)for(var r of oc(t))oh.call(t,r)&&ou(e,r,t[r]);return e},od=(e,t,r)=>ou(e,"symbol"!=typeof t?t+"":t,r);class of extends sS{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,od(this,"events",new c.EventEmitter),od(this,"name","publisher"),od(this,"queue",new Map),od(this,"publishTimeout",(0,u.toMiliseconds)(u.ONE_MINUTE)),od(this,"initialPublishTimeout",(0,u.toMiliseconds)(15*u.ONE_SECOND)),od(this,"needsTransportRestart",!1),od(this,"publish",async(e,t,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});let s=r?.ttl||sG,n=iB(r),o=r?.prompt||!1,a=r?.tag||0,c=r?.id||(0,sM.getBigIntRpcId)().toString(),l={topic:e,message:t,opts:{ttl:s,relay:n,prompt:o,tag:a,id:c,attestation:r?.attestation,tvf:r?.tvf}},h=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{let i=new Promise(async i=>{let n=({id:e})=>{l.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(s0,n),i(l))};this.relayer.events.on(s0,n);let h=ek(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:s,prompt:o,tag:a,id:c,attestation:r?.attestation,tvf:r?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await h,this.events.removeListener(s0,n)}catch(r){let e,t;
10this.queue.set(c,(e=op({},l),t={attempt:1},oo(e,oa(t)))),this.logger.warn(r,r?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:r}}),await ek(i,this.publishTimeout,h)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=r?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),od(this,"on",(e,t)=>{this.events.on(e,t)}),od(this,"once",(e,t)=>{this.events.once(e,t)}),od(this,"off",(e,t)=>{this.events.off(e,t)}),od(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,sb.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,sb.oI)(this.logger)}async rpcPublish(e){var t,r,i,s;let{topic:n,message:o,ttl:a=sG,prompt:c,tag:l,id:h,attestation:u,tvf:p}=e,d={method:iM(iB().protocol).publish,params:op({topic:n,message:o,ttl:a,prompt:c,tag:l,attestation:u},p),id:h};se(null==(t=d.params)?void 0:t.prompt)&&(null==(r=d.params)||delete r.prompt),se(null==(i=d.params)?void 0:i.tag)&&(null==(s=d.params)||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:d});let f=await this.relayer.request(d);return this.relayer.events.emit(s0,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{let r=e.attempt+1;this.queue.set(t,oo(op({},e),oa({attempt:r})));let{topic:i,message:s,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(oo(op({},e),oa({topic:i,message:s,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf}))),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(sy.li.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(sX);return}this.checkQueue()}),this.relayer.on(sQ,e=>{this.removeRequestFromQueue(e.id.toString())})}}var og=Object.defineProperty,oy=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?og(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class om{constructor(){oy(this,"map",new Map),oy(this,"set",(e,t)=>{let r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])}),oy(this,"get",e=>this.map.get(e)||[]),oy(this,"exists",(e,t)=>this.get(e).includes(t)),oy(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;let r=this.get(e);if(!this.exists(e,t))return;let i=r.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),oy(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var ob=Object.defineProperty,ow=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,oE=Object.getOwnPropertySymbols,oI=Object.prototype.hasOwnProperty,ox=Object.prototype.propertyIsEnumerable,oP=(e,t,r)=>t in e?ob(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oO=(e,t)=>{for(var r in t||(t={}))oI.call(t,r)&&oP(e,r,t[r]);if(oE)for(var r of oE(t))ox.call(t,r)&&oP(e,r,t[r]);return e},oS=(e,t,r)=>oP(e,"symbol"!=typeof t?t+"":t,r);class o_ extends sR{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,oS(this,"subscriptions",new Map),oS(this,"topicMap",new om),oS(this,"events",new c.EventEmitter),oS(this,"name","subscription"),oS(this,"version","0.3"),oS(this,"pending",new Map),oS(this,"cached",[]),oS(this,"initialized",!1),oS(this,"storagePrefix",sF),oS(this,"subscribeTimeout",(0,u.toMiliseconds)(u.ONE_MINUTE)),oS(this,"initialSubscribeTimeout",(0,u.toMiliseconds)(15*u.ONE_SECOND)),oS(this,"clientId"),oS(this,"batchSubscribeTopicsLimit",500),oS(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),oS(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{let r=iB(t),i={topic:e,relay:r,transportType:t?.transportType};this.pending.set(e,i);let s=await this.rpcSubscribe(e,r,t);return"string"==typeof s&&(this.onSubscribe(s,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),s}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),oS(this,"unsubscribe",async(e,t)=>{this.isInitialized(),"u">typeof t?.id?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),oS(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),oS(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),oS(this,"on",(e,t)=>{this.events.on(e,t)}),oS(this,"once",(e,t)=>{this.events.once(e,t)}),oS(this,"off",(e,t)=>{this.events.off(e,t)}),oS(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),oS(this,"start",async()=>{await this.onConnect()}),oS(this,"stop",async()=>{await this.onDisconnect()}),oS(this,"restart",async()=>
10{await this.restore(),await this.onRestart()}),oS(this,"checkPending",async()=>{if(0===this.pending.size&&(!this.initialized||!this.relayer.connected))return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),oS(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(sy.li.pulse,async()=>{await this.checkPending()}),this.events.on(ne,async e=>{this.logger.info(`Emitting ${ne}`),this.logger.debug({type:"event",event:ne,data:e}),await this.persist()}),this.events.on(nt,async e=>{this.logger.info(`Emitting ${nt}`),this.logger.debug({type:"event",event:nt,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,sb.U5)(t,this.name),this.clientId=""}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+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}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let r=this.topicMap.get(e);await Promise.all(r.map(async r=>await this.unsubscribeById(e,r,t)))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{let i=iB(r);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);let s=i4("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,r){var i;r&&r?.transportType!==s4||await this.restartToComplete({topic:e,id:e,relay:t});let s={method:iM(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let n=null==(i=r?.internal)?void 0:i.throwOnFailedPublish;
10try{let t=await this.getSubscriptionId(e);if(r?.transportType===s6)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(e=>this.logger.warn(e))},(0,u.toMiliseconds)(u.ONE_SECOND)),t;let i=new Promise(async t=>{let r=i=>{i.topic===e&&(this.events.removeListener(ne,r),t(i.id))};this.events.on(ne,r);try{let i=await ek(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(ne,r),t(i)}catch{}}),o=await ek(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(sX),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t={method:iM(e[0].relay.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{await await ek(new Promise(e=>{this.relayer.request(t).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(sX)}}async rpcBatchFetchMessages(e){let t;if(!e.length)return;let r={method:iM(e[0].relay.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{t=await await ek(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(sX)}return t}rpcUnsubscribe(e,t,r){let i={method:iM(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,ow(oO({},t),ov({id:e}))),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,oO({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),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,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,oO({},t)),this.topicMap.set(t.topic,e),this.events.emit(ne,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:t}=i6("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(nt,ow(oO({},r),ov({reason:t})))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){let e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){let t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{let e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){let{message:e}=i6("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),Error(e)}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 batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>ow(oO({}
10,e),ov({id:await this.getSubscriptionId(e.topic)}))))))}async batchFetchMessages(e){var t;if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await (t=(0,u.toMiliseconds)(u.ONE_SECOND),new Promise(e=>setTimeout(e,t))),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}async restartToComplete(e){this.relayer.connected||this.relayer.connecting||(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return iC(e+await this.getClientId())}}var oA=Object.defineProperty,oR=Object.getOwnPropertySymbols,oC=Object.prototype.hasOwnProperty,oT=Object.prototype.propertyIsEnumerable,oN=(e,t,r)=>t in e?oA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oj=(e,t)=>{for(var r in t||(t={}))oC.call(t,r)&&oN(e,r,t[r]);if(oR)for(var r of oR(t))oT.call(t,r)&&oN(e,r,t[r]);return e},oU=(e,t,r)=>oN(e,"symbol"!=typeof t?t+"":t,r);class oq extends s_{constructor(e){super(e),oU(this,"protocol","wc"),oU(this,"version",2),oU(this,"core"),oU(this,"logger"),oU(this,"events",new c.EventEmitter),oU(this,"provider"),oU(this,"messages"),oU(this,"subscriber"),oU(this,"publisher"),oU(this,"name","relayer"),oU(this,"transportExplicitlyClosed",!1),oU(this,"initialized",!1),oU(this,"connectionAttemptInProgress",!1),oU(this,"relayUrl"),oU(this,"projectId"),oU(this,"packageName"),oU(this,"bundleId"),oU(this,"hasExperiencedNetworkDisruption",!1),oU(this,"pingTimeout"),oU(this,"heartBeatTimeout",(0,u.toMiliseconds)(u.THIRTY_SECONDS+u.FIVE_SECONDS)),oU(this,"reconnectTimeout"),oU(this,"connectPromise"),oU(this,"reconnectInProgress",!1),oU(this,"requestsInFlight",[]),oU(this,"connectTimeout",(0,u.toMiliseconds)(15*u.ONE_SECOND)),oU(this,"request",async e=>{var t,r;this.logger.debug("Publishing Request Payload");let i=e.id||(0,sM.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");let s=`${i}:${(null==(r=e.params)?void 0:r.tag)||""}`;this.requestsInFlight.push(s);let n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==s),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),oU(this,"resetPingTimeout",()=>{eO()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,r,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.terminate)||i.call(r)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),oU(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),oU(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \uD83D\uDEDC"),this.startPingTimeout(),this.events.emit("relayer_connect")}),oU(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \uD83D\uDED1"),this.requestsInFlight=[],this.onProviderDisconnect()}),oU(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit("relayer_error",e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),oU(this,"registerProviderListeners",()=>{this.provider.on(s1,this.onPayloadHandler),this.provider.on(s2,this.onConnectHandler),this.provider.on(s8,this.onDisconnectHandler),this.provider.on(s5,this.onProviderErrorHandler)}),this.core=e.core,this.logger="u">typeof e.logger&&"string"!=typeof e.logger?(0,sb.U5)(e.logger,this.name):(0,sb.h6)((0,sb.iP)({level:e.logger||"error"})),this.messages=new os(this.logger,e.core),this.subscriber=new o_(this,this.logger),this.publisher=new of(this,this.logger),this.relayUrl=e?.relayUrl||sY,this.projectId=e.projectId,eS()&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Platform)&&(null==r.g?void 0:r.g.Platform.OS)==="android"?this.packageName=eR():eS()&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Platform)&&(null==r.g?void 0:r.g.Platform.OS)==="ios"&&(this.bundleId=eR()),this.provider={}}
10async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,sb.oI)(this.logger)}get connected(){var e,t,r;return(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)===1}get connecting(){var e,t,r;return(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)===0||void 0!==this.connectPromise}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:s4},"outbound")}async subscribe(e,t){var r,i,s;this.isInitialized(),null!=t&&t.transportType&&t?.transportType!=="relay"||await this.toEstablishConnection();let n=typeof(null==(r=t?.internal)?void 0:r.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish),o=(null==(s=this.subscriber.topicMap.get(e))?void 0:s[0])||"",a,c=t=>{t.topic===e&&(this.subscriber.off(ne,c),a())};return await Promise.all([new Promise(e=>{a=e,this.subscriber.on(ne,c)}),new Promise(async(r,i)=>{o=await this.subscriber.subscribe(e,oj({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||o,r()})]),o}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await ek(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics)return void this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,r)=>{await this.connect(e).then(t).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await sp())throw Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0)return void this.logger.trace("Batch message events is empty. Ignoring...");let t=e.sort((e,t)=>e.publishedAt-t.publishedAt);for(let e of(this.logger.debug(`Batch of ${t.length} message events sorted`),t))try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:r}=e;if(!t.sessionExists){let e=eB(u.FIVE_MINUTES);await this.core.pairing.pairings.set(r,{topic:r,expiry:e,relay:{protocol:"irn"},active:!1})}this.events.emit(sZ,e),await this.recordMessageEvent(e,s9)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{let r=()=>{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(s8,r),await ek(new Promise((e,t)=>
10{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(s8,r),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{let r=()=>{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(s8,r),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(s8,r)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop(),this.logger.warn({},e.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,u.toMiliseconds)(+t))),t++}}startPingTimeout(){var e,t,r,i,s;if(eO())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(s=null==(i=null==(r=this.provider)?void 0:r.connection)?void 0:i.socket)||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new sB.F(new s$.A(function({protocol:e,version:t,relayUrl:r,sdkVersion:i,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){let l=r.split("?"),h=eT(e,t,i),u=function(e,t){let r=new URLSearchParams(e);for(let e of Object.keys(t).sort())if(t.hasOwnProperty(e)){let i=t[e];void 0!==i&&r.set(e,i)}return r.toString()}(l[1]||"",{auth:s,ua:h,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0});return l[0]+"?"+u}({sdkVersion:s3,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){let{topic:r,message:i}=e;await this.messages.set(r,i,t)}async shouldIgnoreMessageEvent(e){let{topic:t,message:r}=e;if(!r||0===r.length)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;let i=this.messages.has(t,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,sM.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;let t=e.params,{topic:r,message:i,publishedAt:s,attestation:n}=t.data,o={topic:r,message:i,publishedAt:s,transportType:s4,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(oj({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,sM.isJsonRpcResponse)(e)&&this.events.emit(sQ,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,s9),this.events.emit(sZ,e))}async acknowledgePayload(e){let t=(0,sM.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(s1,this.onPayloadHandler),this.provider.off(s2,this.onConnectHandler),this.provider.off(s8,this.onDisconnectHandler),this.provider.off(s5,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await sp();(function(e){var t,i;switch(eA()){case eP:t=e,!eS()&&e_()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)));break;case eI:i=e,eS()&&"u">typeof r.g&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener(e=>i(e?.isConnected))}})(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(sy.li.pulse,async()=>{var e;if(!this.transportExplicitlyClosed&&!this.connected&&(!(e_()&&(0,p.getDocument)())||
10(null==(e=(0,p.getDocument)())?void 0:e.visibilityState)==="visible"))try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit("relayer_disconnect"),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,u.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise)return void await this.connectPromise;await this.connect()}}}function ok(){}function oD(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function oL(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function oB(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let oM="[object Arguments]",o$="[object Object]";var oz=Object.defineProperty,oH=Object.getOwnPropertySymbols,oV=Object.prototype.hasOwnProperty,oF=Object.prototype.propertyIsEnumerable,oK=(e,t,r)=>t in e?oz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oW=(e,t)=>{for(var r in t||(t={}))oV.call(t,r)&&oK(e,r,t[r]);if(oH)for(var r of oH(t))oF.call(t,r)&&oK(e,r,t[r]);return e},oJ=(e,t,r)=>oK(e,"symbol"!=typeof t?t+"":t,r);class oG extends sA{constructor(e,t,r,i=sF,s){super(e,t,r,i),this.core=e,this.logger=t,this.name=r,oJ(this,"map",new Map),oJ(this,"version","0.3"),oJ(this,"cached",[]),oJ(this,"initialized",!1),oJ(this,"getKey"),oJ(this,"storagePrefix",sF),oJ(this,"recentlyDeleted",[]),oJ(this,"recentlyDeletedLimit",200),oJ(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{var t;this.getKey&&null!==e&&!se(e)?this.map.set(this.getKey(e),e):(null==(t=e?.proposer)?void 0:t.publicKey)?this.map.set(e.id,e):e?.topic&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),oJ(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),oJ(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),oJ(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(r=>{var i;return i=t[r],function e(t,r,i,s,n,o,a){let c=a(t,r,i,s,n,o);if(void 0!==c)return c;if(typeof t==typeof r)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return t===r;case"number":return t===r||Object.is(t,r)}return function t(r,i,s,n){if(Object.is(r,i))return!0;let o=oB(r),a=oB(i);if(o===oM&&(o=o$),a===oM&&(a=o$),o!==a)return!1;switch(o){case"[object String]":return r.toString()===i.toString();case"[object Number]":{let e=r.valueOf(),t=i.valueOf();return e===t||Number.isNaN(e)&&Number.isNaN(t)}case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(r.valueOf(),i.valueOf());case"[object RegExp]":return r.source===i.source&&r.flags===i.flags;case"[object Function]":return r===i}let c=(s=s??new Map).get(r),l=s.get(i);if(null!=c&&null!=l)return c===i;s.set(r,i),s.set(i,r);try{switch(o){case"[object Map]":if(r.size!==i.size)return!1;for(let[t,o]of r.entries())if(!i.has(t)||!e(o,i.get(t),t,r,i,s,n))return!1;return!0;case"[object Set]":{if(r.size!==i.size)return!1;let t=Array.from(r.values()),o=Array.from(i.values());for(let a=0;a<t.length;a++){let c=t[a],l=o.findIndex(t=>e(c,t,void 0,r,i,s,n));if(-1===l)return!1;o.splice(l,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array
10]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if("u">typeof sz&&sz.isBuffer(r)!==sz.isBuffer(i)||r.length!==i.length)return!1;for(let t=0;t<r.length;t++)if(!e(r[t],i[t],t,r,i,s,n))return!1;return!0;case"[object ArrayBuffer]":return r.byteLength===i.byteLength&&t(new Uint8Array(r),new Uint8Array(i),s,n);case"[object DataView]":return r.byteLength===i.byteLength&&r.byteOffset===i.byteOffset&&t(new Uint8Array(r),new Uint8Array(i),s,n);case"[object Error]":return r.name===i.name&&r.message===i.message;case o$:{if(!(t(r.constructor,i.constructor,s,n)||oD(r)&&oD(i)))return!1;let o=[...Object.keys(r),...oL(r)],a=[...Object.keys(i),...oL(i)];if(o.length!==a.length)return!1;for(let t=0;t<o.length;t++){let a=o[t],c=r[a];if(!Object.hasOwn(i,a))return!1;let l=i[a];if(!e(c,l,a,r,i,s,n))return!1}return!0}default:return!1}}finally{s.delete(r),s.delete(i)}}(t,r,o,a)}(i,e[r],void 0,void 0,void 0,void 0,ok)})):this.values)),oJ(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});let r=oW(oW({},this.getData(e)),t);this.map.set(e,r),await this.persist()}),oJ(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,sb.U5)(t,this.name),this.storagePrefix=i,this.getKey=s}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:t}=i6("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),Error(t)}let{message:t}=i6("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:e}=i6("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}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){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var oY=Object.defineProperty,oZ=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?oY(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class oQ{constructor(e,t){this.core=e,this.logger=t,oZ(this,"name","pairing"),oZ(this,"version","0.3"),oZ(this,"events",new(l())),oZ(this,"pairings"),oZ(this,"initialized",!1),oZ(this,"storagePrefix",sF),oZ(this,"ignoredPayloadTypes",[1]),oZ(this,"registeredMethods",[]),oZ(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),oZ(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),oZ(this,"create",async e=>{this.isInitialized();let t=iA(),r=await this.core.crypto.setSymKey(t),i=eB(u.FIVE_MINUTES),s={protocol:"irn"},n={topic:r,expiry:i,relay:s,active:!1,methods:e?.methods},o=iz({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:t,relay:s,expiryTimestamp:i,methods:e?.methods});return this.events.emit(ni,n),this.core.expirer.set(r,i),await this.pairings.set(r,n),await this.core.relayer.subscribe(r,{transportType:e?.transportType}),{topic:r,uri:o}}),oZ(this,"pair",async e=>{let t;this.isInitialized();let r=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:["pairing_started"]}});this.isValidPair(e,r);let{topic:i,symKey:s,relay:n,expiryTimestamp:o,methods:a}=i$(e.uri);if(r.props.properties.topic=i,r.addTrace("pairing_uri_validation_success"),r.addTrace("pairing_uri_not_expired"),this.pairings.keys.includes(i)){if(t=this.pairings.get(i),r.addTrace("existing_pairing"),t.active)throw r.setError("active_pairing_already_exists"),Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);r.addTrace("pairing_not_expired")}let c=o||eB(u.FIVE_MINUTES),l={topic:i,relay:n,expiry:c,active:!1,methods:a};this.core.expirer.set(i,c),await this.pairings.set(i,l),r.addTrace("store_new_pairing"),e.activatePairing&&await this.activate({topic:i}),this.events.emit(ni,l),r.addTrace("emit_inactive_pairing"),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(s,i),r.addTrace("subscribing_pairing_topic");try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{r.setError("no_internet_connection")}try{await this.core.relayer.subscribe(i,{relay:n})}catch(e){throw r.setError("subscribe_pairing_topic_failure"),e}return r.addTrace("subscribe_pairing_topic_success"),l}),oZ(this,"activate",async({topic:e})=>{this.isInitialized();let t=eB(u.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),oZ(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");let{topic:t}=e;if(this.pairings.keys.includes(t)){let e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:i,reject:s}=eq();this.events.once(e$("pairing_ping",e),({error:e})=>{e?s(e):i()}),await r()}}),oZ(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),oZ(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),oZ(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),oZ(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);let{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",i4("USER_DISCONNECTED")),await this.deletePairing(t))}),oZ(this,"formatUriFromPairing",e=>{this.isInitialized();let{topic:t,relay:r,expiry:i,methods:s}=e,n=this.core.crypto.keychain.get(t);return iz({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:r,expiryTimestamp:i,methods:s})}),oZ(this,"sendRequest",async(e,t,r)=>{let i=(0,sM.formatJsonRpcRequest)(t,r),s=await this.core.crypto.encode(e,i),n=nr[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,s,n),i.id}),oZ(this,"sendResult",async(e,t,r)=>{let i=(0,sM.formatJsonRpcResult)(e,r),s=await this.core.crypto.encode(t,i),n=nr[(await this.core.history.get(t,e)).request.method].res;await this.core.relayer.publish(t,s,n),await this.core.history.resolve(i)}),oZ(this,"sendError",async(e,t,r)=>{let i=(0,sM.formatJsonRpcError)(e,r),s=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=nr[n]?nr[n].res:nr.unregistered_method.res;await this.core.relayer.publish(t,s,o),await this.core.history.resolve(i)}),oZ(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,i4("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),oZ(this,"cleanup",async()=>{let e=this.pairings.getAll().filter(e=>eM(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),oZ(this,"onRelayEventRequest",async e=>{let{topic:t,payload:r}=e;switch(r.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,r);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,r);default:return await this.onUnknownRpcMethodRequest(t,r)}}),oZ(this,"onRelayEventResponse",async e=>{let{topic:t,payload:r}=e,i=(await this.core.history.get(t,r.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,r):this.onUnknownRpcMethodResponse(i)}),oZ(this,"onPairingPingRequest",async(e,t)=>{let{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit("pairing_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),oZ(this,"onPairingPingResponse",(e,t)=>{let{id:r}=t;setTimeout(()=>{(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("pairing_ping",r),{}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("pairing_ping",r),{error:t.error})},500)}),oZ(this,"onPairingDeleteRequest",async(e,t)=>{let{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(ns,{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),oZ(this,"onUnknownRpcMethodRequest",async(e,t)=>{let{id:r,method:i}=t;try{if(this.registeredMethods.includes(i))return;let t=i4("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),oZ(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error(i4("WC_METHOD_UNSUPPORTED",e))}),oZ(this,"isValidPair",(e,t)=>{var r;if(!sc(e)){let{message:r}=i6("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(nf),Error(r)}if(!function(e){function t(e){try{return"u">typeof new URL(e)}catch{return!1}}try{if(st(e,!1)){if(t(e))return!0;let r=eJ(e);return t(r)}}catch{}return!1}(e.uri)){let{message:r}=i6("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(nf),Error(r)}let i=i$(e?.uri);if(!(null!=(r=i?.relay)&&r.protocol)){let{message:e}=i6("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(nf),Error(e)}if(!(null!=i&&i.symKey)){let{message:e}=i6("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(nf),Error(e)}if(null!=i&&i.expiryTimestamp&&(0,u.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError("pairing_expired");let{message:e}=i6("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw Error(e)}}),oZ(this,"isValidPing",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),oZ(this,"isValidDisconnect",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),oZ(this,"isValidPairingTopic",async e=>{if(!st(e,!1)){let{message:t}=i6("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.pairings.keys.includes(e)){let{message:t}=i6("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(eM(this.pairings.get(e).expiry)){await this.deletePairing(e);let{message:t}=i6("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}),this.core=e,this.logger=(0,sb.U5)(t,this.name),this.pairings=new oG(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,sb.oI)(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}registerRelayerEvents(){this.core.relayer.on(sZ,async e=>{let{topic:t,message:r,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==s6&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{let e=await this.core.crypto.decode(t,r);(0,sM.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,sM.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,r)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(nh,async e=>{let{topic:t}=eL(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))})}}var oX=Object.defineProperty,o0=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?oX(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class o1 extends sP{constructor(e,t){super(e,t),this.core=e,this.logger=t,o0(this,"records",new Map),o0(this,"events",new c.EventEmitter),o0(this,"name","history"),o0(this,"version","0.3"),o0(this,"cac
10hed",[]),o0(this,"initialized",!1),o0(this,"storagePrefix",sF),o0(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),o0(this,"set",(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;let i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:eB(u.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(nn,i)}),o0(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;let t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,sM.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(no,t))}),o0(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),o0(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(r=>{r.topic===e&&("u">typeof t&&r.id!==t||(this.records.delete(r.id),this.events.emit(na,r)))}),this.persist()}),o0(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),o0(this,"on",(e,t)=>{this.events.on(e,t)}),o0(this,"once",(e,t)=>{this.events.once(e,t)}),o0(this,"off",(e,t)=>{this.events.off(e,t)}),o0(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,sb.U5)(t,this.name)}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+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(){let e=[];return this.values.forEach(t=>{if("u">typeof t.response)return;let r={topic:t.topic,request:(0,sM.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)}),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();let t=this.records.get(e);if(!t){let{message:t}=i6("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:e}=i6("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}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(nn,e=>{this.logger.info(`Emitting ${nn}`),this.logger.debug({type:"event",event:nn,record:e})}),this.events.on(no,e=>{this.logger.info(`Emitting ${no}`),this.logger.debug({type:"event",event:no,record:e})}),this.events.on(na,e=>{this.logger.info(`Emitting ${na}`),this.logger.debug({type:"event",event:na,record:e})}),this.core.heartbeat.on(sy.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,u.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(na,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var o2=Object.defineProperty,o8=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?o2(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class o5 extends sC{constructor(e,t){super(e,t),this.core=e,this.logger=t,o8(this,"expirations",new Map),o8(this,"events",new c.EventEmitter),o8(this,"name","expirer"),o8(this,"version","0.3"),o8(this,"cac
10hed",[]),o8(this,"initialized",!1),o8(this,"storagePrefix",sF),o8(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),o8(this,"has",e=>{try{let t=this.formatTarget(e);return"u">typeof this.getExpiration(t)}catch{return!1}}),o8(this,"set",(e,t)=>{this.isInitialized();let r=this.formatTarget(e),i={target:r,expiry:t};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(nc,{target:r,expiration:i})}),o8(this,"get",e=>{this.isInitialized();let t=this.formatTarget(e);return this.getExpiration(t)}),o8(this,"del",e=>{if(this.isInitialized(),this.has(e)){let t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(nl,{target:t,expiration:r})}}),o8(this,"on",(e,t)=>{this.events.on(e,t)}),o8(this,"once",(e,t)=>{this.events.once(e,t)}),o8(this,"off",(e,t)=>{this.events.off(e,t)}),o8(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,sb.U5)(t,this.name)}get context(){return(0,sb.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+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("string"==typeof e)return eD("topic",e);if("number"==typeof e)return eD("id",e);let{message:t}=i6("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw Error(t)}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("expirer_sync")}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:e}=i6("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}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){let t=this.expirations.get(e);if(!t){let{message:t}=i6("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),Error(t)}return t}checkExpiry(e,t){let{expiry:r}=t;(0,u.toMiliseconds)(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(nh,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(sy.li.pulse,()=>this.checkExpirations()),this.events.on(nc,e=>{this.logger.info(`Emitting ${nc}`),this.logger.debug({type:"event",event:nc,data:e}),this.persist()}),this.events.on(nh,e=>{this.logger.info(`Emitting ${nh}`),this.logger.debug({type:"event",event:nh,data:e}),this.persist()}),this.events.on(nl,e=>{this.logger.info(`Emitting ${nl}`),this.logger.debug({type:"event",event:nl,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}}var o3=Object.defineProperty,o6=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?o3(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class o4 extends sT{constructor(e,t,r){super(e,t,r),this.core=e,this.logger=t,this.store=r,o6(this,"name","verify-api"),o6(this,"abortController"),o6(this,"isDevEnv"),o6(this,"verifyUrlV3",np),o6(this,"storagePrefix",sF),o6(this,"version",2),o6(this,"publicKey"),o6(this,"fetchPromise"),o6(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,u.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),o6(this,"register",async e=>{if(!e_()||this.isDevEnv)return;let t=window.location.origin,{id:r,decryptedId:i}=e,s=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${r}&decryptedId=${i}`;try{let e=(0,p.getDocument)(),t=this.startAbortTimer(5*u.ONE_SECOND),i=await new Promise((i,n)=>{let o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);let a=e.createElement("iframe");a.src=s,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});let c=s=>{if(s.data&&"string"==typeof s.data)try{let n=JSON.parse(s.data);if("verify_attestation"===n.type){if((0,eo.Cq)(n.attestation).payload.id!==r)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),o6(this,"resolve",async e=>{if(this.isDevEnv)return"";let{attestationId:t,hash:r,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,eo.Cq)(t).payload.id!==i)return;let e=await this.isValidJwtAttestation(t);
10if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!r)return;let s=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(r,s)}),o6(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);let r=this.startAbortTimer(5*u.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0}),o6(this,"getVerifyUrl",e=>{let t=e||nu;return nd.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${nu}`),t=nu),t}),o6(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let e=this.startAbortTimer(u.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),o6(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),o6(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),o6(this,"isValidJwtAttestation",async e=>{let t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}let r=await this.fetchAndPersistPublicKey();try{if(r)return this.validateAttestation(e,r)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),o6(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),o6(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{let t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});let e=await this.fetchPromise;return this.fetchPromise=void 0,e}),o6(this,"validateAttestation",(e,t)=>{let r=function(e,t){let r,i,[s,n,o]=e.split("."),a=eh.from(iU(o),"base64");if(64!==a.length)throw Error("Invalid signature length");let c=a.slice(0,32),l=a.slice(32,64),h=rp(`${s}.${n}`),u=(r=eh.from(t.x,"base64"),i=eh.from(t.y,"base64"),(0,ea.xW)([new Uint8Array([4]),r,i]));if(!iI.verify((0,ea.xW)([c,l]),h,u))throw Error("Invalid signature");return(0,eo.Cq)(e).payload}(e,t.publicKey),i={hasExpired:(0,u.toMiliseconds)(r.exp)<Date.now(),payload:r};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,sb.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=eW(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,sb.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,u.toMiliseconds)(e))}}var o9=Object.defineProperty,o7=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?o9(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class ae extends sN{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,o7(this,"context","echo"),o7(this,"registerDeviceToken",async e=>{let{clientId:t,token:r,notificationType:i,enableEncrypted:s=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:r,always_raw:s})})}),this.logger=(0,sb.U5)(t,this.context)}}var at=Object.defineProperty,ar=Object.getOwnPropertySymbols,ai=Object.prototype.hasOwnProperty,as=Object.prototype.propertyIsEnumerable,an=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ao=(e,t)=>{for(var r in t||(t={}))ai.call(t,r)&&an(e,r,t[r]);if(ar)for(var r of ar(t))as.call(t,r)&&an(e,r,t[r]);return e},aa=(e,t,r)=>an(e,"symbol"!=typeof t?t+"":t,r);class ac extends sj{constructor(e,t,r=!0){super(e,t,r),this.core=e,this.logger=t,aa(this,"context","event-client"),aa(this,"storagePrefix",sF),aa(this,"storageVersion",.1),aa(this,"events",new Map),aa(this,"shouldPersist",!1),aa(this,"init",async()=>
10{if(!eW())try{let e={eventId:eK(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:eT(this.core.relayer.protocol,this.core.relayer.version,s3)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),aa(this,"createEvent",e=>{let{event:t="ERROR",type:r="",properties:{topic:i,trace:s}}=e,n=eK(),o=this.core.projectId||"",a=ao({eventId:n,timestamp:Date.now(),props:{event:t,type:r,properties:{topic:i,trace:s}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,a),this.shouldPersist=!0),a}),aa(this,"getEvent",e=>{let{eventId:t,topic:r}=e;if(t)return this.events.get(t);let i=Array.from(this.events.values()).find(e=>e.props.properties.topic===r);if(i)return ao(ao({},i),this.setMethods(i.eventId))}),aa(this,"deleteEvent",e=>{let{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),aa(this,"setEventListeners",()=>{this.core.heartbeat.on(sy.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,u.fromMiliseconds)(Date.now())-(0,u.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),aa(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),aa(this,"addTrace",(e,t)=>{let r=this.events.get(e);r&&(r.props.properties.trace.push(t),this.events.set(e,r),this.shouldPersist=!0)}),aa(this,"setError",(e,t)=>{let r=this.events.get(e);r&&(r.props.type=t,r.timestamp=Date.now(),this.events.set(e,r),this.shouldPersist=!0)}),aa(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),aa(this,"restore",async()=>{try{let e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,ao(ao({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),aa(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;let e=[];for(let[t,r]of this.events)r.props.type&&e.push(r);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(let t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),aa(this,"sendEvent",async e=>{let t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${s3}${t}`,{method:"POST",body:JSON.stringify(e)})}),aa(this,"getAppDomain",()=>eC().url),this.logger=(0,sb.U5)(t,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var al=Object.defineProperty,ah=Object.getOwnPropertySymbols,au=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,ad=(e,t,r)=>t in e?al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,af=(e,t)=>{for(var r in t||(t={}))au.call(t,r)&&ad(e,r,t[r]);if(ah)for(var r of ah(t))ap.call(t,r)&&ad(e,r,t[r]);return e},ag=(e,t,r)=>ad(e,"symbol"!=typeof t?t+"":t,r);class ay extends sI{constructor(e){var t;super(e),ag(this,"protocol","wc"),ag(this,"version",2),ag(this,"name",sV),ag(this,"relayUrl"),ag(this,"projectId"),ag(this,"customStoragePrefix"),ag(this,"events",new c.EventEmitter),ag(this,"logger"),ag(this,"heartbeat"),ag(this,"relayer"),ag(this,"crypto"),ag(this,"storage"),ag(this,"history"),ag(this,"expirer"),ag(this,"pairing"),ag(this,"verify"),ag(this,"echoClient"),ag(this,"linkModeSupportedApps"),ag(this,"eventClient"),ag(this,"initialized",!1),ag(this,"logChunkController"),ag(this,"on",(e,t)=>this.events.on(e,t)),ag(this,"once",(e,t)=>this.events.once(e,t)),ag(this,"off",(e,t)=>this.events.off(e,t)),ag(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),ag(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:r})=>{if(!e||!t)return;let i={topic:e,message:t,publishedAt:Date.now(),transportType:s6};this.relayer.onLinkMessageEvent(i,{sessionExists:r})});const r=this.getGlobalCore(e?.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(e){console.warn("Failed to copy global core",e)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||sY,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=(0,sb.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:sV}),{logger:s,chunkLoggerController:n}=(0,sb.D5)({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=n,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,sb.U5)(s,this.name),this.heartbeat=new sy.VH,this.crypto=new n3(this,this.logger,e?.keychain),this.history=new o1(this,this.logger),this.expirer=new o5(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new sm.A(af(af
10({},sK),e?.storageOptions)),this.relayer=new oq({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new oQ(this,this.logger),this.verify=new o4(this,this.logger,this.storage),this.echoClient=new ae(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new ac(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){let t=new ay(e);await t.initialize();let r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return(0,sb.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(s7,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(s7)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;let t=`_walletConnectCore_${e}`,r=`${t}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[t]}catch(e){console.warn("Failed to get global WalletConnect core",e);return}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;let r=`_walletConnectCore_${(null==(t=e.opts)?void 0:t.customStoragePrefix)||""}`;globalThis[r]=e}catch(e){console.warn("Failed to set global WalletConnect core",e)}}isGlobalCoreDisabled(){try{return"u">typeof sH&&"true"===sH.env.DISABLE_GLOBAL_CORE}catch{return!0}}}let am="client",ab=`wc@2:${am}:`,aw="WALLETCONNECT_DEEPLINK_CHOICE",av="Proposal expired",aE=u.SEVEN_DAYS,aI={wc_sessionPropose:{req:{ttl:u.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:u.ONE_DAY,prompt:!1,tag:1104},res:{ttl:u.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:u.ONE_DAY,prompt:!1,tag:1106},res:{ttl:u.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:u.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:u.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:u.ONE_DAY,prompt:!1,tag:1112},res:{ttl:u.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:u.ONE_DAY,prompt:!1,tag:1114},res:{ttl:u.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:u.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:u.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:u.FIVE_MINUTES,prompt:!1,tag:1119}}},ax={min:u.FIVE_MINUTES,max:u.SEVEN_DAYS},aP="IDLE",aO="ACTIVE",aS={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},a_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],aA="[email protected]:auth:",aR=`${aA}:PUB_KEY`;var aC=Object.defineProperty,aT=Object.defineProperties,aN=Object.getOwnPropertyDescriptors,aj=Object.getOwnPropertySymbols,aU=Object.prototype.hasOwnProperty,aq=Object.prototype.propertyIsEnumerable,ak=(e,t,r)=>t in e?aC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,aD=(e,t)=>{for(var r in t||(t={}))aU.call(t,r)&&ak(e,r,t[r]);if(aj)for(var r of aj(t))aq.call(t,r)&&ak(e,r,t[r]);return e},aL=(e,t,r)=>ak(e,"symbol"!=typeof t?t+"":t,r);class aB extends sD{constructor(e){super(e),aL(this,"name","engine"),aL(this,"events",new(l())),aL(this,"initialized",!1),aL(this,"requestQueue",{state:aP,queue:[]}),aL(this,"sessionRequestQueue",{state:aP,queue:[]}),aL(this,"requestQueueDelay",u.ONE_SECOND),aL(this,"expectedPairingMethodMap",new Map),aL(this,"recentlyDeletedMap",new Map),aL(this,"recentlyDeletedLimit",200),aL(this,"relayMessageCache",[]),aL(this,"pendingSessions",new Map),aL(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(aI)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,u.toMiliseconds)(this.requestQueueDelay)))}),aL(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let t=aT(aD({},e),aN({requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}}));await this.isValidConnect(t),t.optionalNamespaces=function(e,t){var r,i,s,n,o,a;let c=i2(e),l=i2(t),h={};for(let e of Object.keys(c).concat(Object.keys(l)))h[e]={chains:ez(null==(r=c[e])?void 0:r.chains,null==(i=l[e])?void 0:i.chains),methods:ez(null==(s=c[e])?void 0:s.methods,null==(n=l[e])?void 0:n.methods),events:ez(null==(o=c[e])?void 0:o.events,null==(a=l[e])?void 0:a.events)};return h}(t.requiredNamespaces,t.optionalNamespaces),t.requiredNamespaces={};let{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:n,scopedProperties:o,relays:a}=t,c=r,l,h=!1;try{if(c){let e=this.client.core.pairing.pairings.get(c);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),e}if(!c||!h){let{topic:e,uri:t}=await this.client.core.pairing.create();c=e,l=t}if(!c){let{message:e}=i6("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw Error(e)}let p=await this.client.core.crypto.generateKeyPair(),d=aI.wc_sessionPropose.req.ttl||u.FIVE_MINUTES,f=eB(d),g=aT(aD(aD({requiredNamespaces:i,optionalNamespaces:s,relays:a??[{protocol:"irn"}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:f,pairingTopic:c},n&&{sessionProperties:n}),o&&{scopedProperties:o}),aN({id:(0,sM.payloadId)()})),y=e$("session_connect",g.id),{reject:m,resolve:b,done:w}=eq(d,av),v=({id:e})=>{e===g.id&&(this.client.events.off("proposal_expire",v),this.pendingSessions.delete(g.id),this.events.emit(y,{error:{message:av,code:0}}))};return this.client.events.on("proposal_expire",v),this.events.once(y,({error:e,session:t})=>{this.client.events.off("proposal_expire",v),e?m(e):t&&b(t)}),await this.sendRequest({topic:c,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0,clientRpcId:g.id}),await this.setProposal(g.id,g),{uri:l,approval:w}}),aL(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),aL(this,"approve",async e=>{var t,r,i;let s=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[ng]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw s.setError("no_internet_connection"),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),s.setError("proposal_not_found"),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),s.setError("session_approve_namespace_validation_failure"),e}let{id:n,relayProtocol:o,namespaces:a,sessionProperties:c,scopedProperties:l,sessionConfig:h}=e,u=this.client.proposal.get(n);this.client.core.eventClient.deleteEvent({eventId:s.eventId});let{pairingTopic:p,proposer:d,requiredNamespaces:f,optionalNamespaces:g}=u,y=null==(r=this.client.core.eventClient)?void 0:r.getEvent({topic:p});y||(y=null==(i=this.client.core.eventClient)?void 0:i.createEvent({type:ng,properties:{topic:p,trace:[ng,"session_namespaces_validation_success"]}}));let m=await this.client.core.crypto.generateKeyPair(),b=d.publicKey,w=await this.client.core.crypto.generateSharedKey(m,b),v=aD(aD(aD({relay:{protocol:o??"irn"},namespaces:a,controller:{publicKey:m,metadata:this.client.metadata},expiry:eB(aE)},c&&{sessionProperties:c}),l&&{scopedProperties:l}),h&&{sessionConfig:h});y.addTrace("subscribing_session_topic");try{await this.client.core.relayer.subscribe(w,{transportType:s4})}catch(e){throw y.setError("subscribe_session_topic_failure"),e}y.addTrace("subscribe_session_topic_success");let E=aT(aD({},v),aN({topic:w,requiredNamespaces:f,optionalNamespaces:g,pairingTopic:p,acknowledged:!1,self:v.controller,peer:{publicKey:d.publicKey,metadata:d.metadata},controller:m,transportType:s4}));await this.client.session.set(w,E),y.addTrace("store_session");try{y.addTrace("publishing_session_settle"),await this.sendRequest({topic:w,method:"wc_sessionSettle",params:v,throwOnFailedPublish:!0}).catch(e=>{throw y?.setError("session_settle_publish_failure"),e}),y.addTrace("session_settle_publish_success"),y.addTrace("publishing_session_approve"),await this.sendResult({id:n,topic:p,result:{relay:{protocol:o??"irn"},responderPublicKey:m},throwOnFailedPublish:!0}).catch(e=>{throw y?.setError("session_approve_publish_failure"),e}),y.addTrace("session_approve_publish_success")}catch(e){throw this.client.logger.error(e),this.client.session.delete(w,i4("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(w),e}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:d.metadata}),await this.client.proposal.delete(n,i4("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(w,eB(aE)),{topic:w,acknowledged:()=>Promise.resolve(this.client.session.get(w))}}),aL(this,"reject",async e=>{let t;this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}let{id:r,reason:i}=e;try{t=this.client.proposal.get(r).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),e}
10t&&(await this.sendError({id:r,topic:t,error:i,rpcOpts:aI.wc_sessionPropose.reject}),await this.client.proposal.delete(r,i4("USER_DISCONNECTED")))}),aL(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}let{topic:t,namespaces:r}=e,{done:i,resolve:s,reject:n}=eq(),o=(0,sM.payloadId)(),a=(0,sM.getBigIntRpcId)().toString(),c=this.client.session.get(t).namespaces;return this.events.once(e$("session_update",o),({error:e})=>{e?n(e):s()}),await this.client.session.update(t,{namespaces:r}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:c}),n(e)}),{acknowledged:i}}),aL(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}let{topic:t}=e,r=(0,sM.payloadId)(),{done:i,resolve:s,reject:n}=eq();return this.events.once(e$("session_extend",r),({error:e})=>{e?n(e):s()}),await this.setExpiry(t,eB(aE)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:i}}),aL(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}let{chainId:t,request:r,topic:i,expiry:s=aI.wc_sessionRequest.req.ttl}=e,n=this.client.session.get(i);n?.transportType===s4&&await this.confirmOnlineStateOrThrow();let o=(0,sM.payloadId)(),a=(0,sM.getBigIntRpcId)().toString(),{done:c,resolve:l,reject:h}=eq(s,"Request expired. Please try again.");this.events.once(e$("session_request",o),({error:e,result:t})=>{e?h(e):l(t)});let u="wc_sessionRequest",p=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);if(p)return await this.sendRequest({clientRpcId:o,relayRpcId:a,topic:i,method:u,params:{request:aT(aD({},r),aN({expiryTimestamp:eB(s)})),chainId:t},expiry:s,throwOnFailedPublish:!0,appLink:p}).catch(e=>h(e)),this.client.events.emit("session_request_sent",{topic:i,request:r,chainId:t,id:o}),await c();let d={request:aT(aD({},r),aN({expiryTimestamp:eB(s)})),chainId:t},f=this.shouldSetTVF(u,d);return await Promise.all([new Promise(async e=>{await this.sendRequest(aD({clientRpcId:o,relayRpcId:a,topic:i,method:u,params:d,expiry:s,throwOnFailedPublish:!0},f&&{tvf:this.getTVFParams(o,d)})).catch(e=>h(e)),this.client.events.emit("session_request_sent",{topic:i,request:r,chainId:t,id:o}),e()}),new Promise(async e=>{var t;if(!(null!=(t=n.sessionConfig)&&t.disableDeepLink)){let e=await eV(this.client.core.storage,aw);await eH({id:o,topic:i,wcDeepLink:e})}e()}),c()]).then(e=>e[2])}),aL(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);let{topic:t,response:r}=e,{id:i}=r,s=this.client.session.get(t);s.transportType===s4&&await this.confirmOnlineStateOrThrow();let n=this.getAppLinkIfEnabled(s.peer.metadata,s.transportType);(0,sM.isJsonRpcResult)(r)?await this.sendResult({id:i,topic:t,result:r.result,throwOnFailedPublish:!0,appLink:n}):(0,sM.isJsonRpcError)(r)&&await this.sendError({id:i,topic:t,error:r.error,appLink:n}),this.cleanupAfterResponse(e)}),aL(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}let{topic:t}=e;if(this.client.session.keys.includes(t)){let e=(0,sM.payloadId)(),r=(0,sM.getBigIntRpcId)().toString(),{done:i,resolve:s,reject:n}=eq();this.events.once(e$("session_ping",e),({error:e})=>{e?n(e):s()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:r}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),aL(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);let{topic:t,event:r,chainId:i}=e,s=(0,sM.getBigIntRpcId)().toString(),n=(0,sM.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:r,chainId:i},throwOnFailedPublish:!0,relayRpcId:s,clientRpcId:n})}),aL(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);let{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:i4("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:e}=i6("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw Error(e)}}),aL(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(function(e,t){let{requiredNamespaces:r}=t,i=Object.keys(e.namespaces),s=Object.keys(r),n=!0;return!!eN(s,i)&&(i.forEach(t=>{let{accounts:i,methods:s,events:o}=e.namespaces[t],a=iX(i),c=r[t];eN(ed(t,c),a)&&eN(c.methods,s)&&eN(c.events,o)||(n=!1)}),n)})(t,e)))),aL(this,"getPendingSessionRequests",()=>
10this.client.pendingRequest.getAll()),aL(this,"authenticate",async(e,t)=>{var r,i,s,n,o;let a;this.isInitialized(),this.isValidAuthenticate(e);let c=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(r=this.client.metadata.redirect)?void 0:r.linkMode),l=c?s6:s4;l===s4&&await this.confirmOnlineStateOrThrow();let{chains:h,statement:u="",uri:p,domain:d,nonce:f,type:g,exp:y,nbf:m,methods:b=[],expiry:w}=e,v=[...e.resources||[]],{topic:E,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:l});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:I}});let x=await this.client.core.crypto.generateKeyPair(),P=iR(x);if(await Promise.all([this.client.auth.authKeys.set(aR,{responseTopic:P,publicKey:x}),this.client.auth.pairingTopics.set(P,{topic:P,pairingTopic:E})]),await this.client.core.relayer.subscribe(P,{transportType:l}),this.client.logger.info(`sending request to new pairing topic: ${E}`),b.length>0){let e,t,{namespace:r}=eu(h[0]),a=tj(function(e,t,r,i={}){return r?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:function(e,t,r={}){return Object.assign({},...(t=t?.sort((e,t)=>e.localeCompare(t))).map(t=>({[`${e}/${t}`]:[r]})))}(t,r,i)}}}(r,"request",b));tD(v)&&(i=a,s=v.pop(),a=tj((n=tU(i),o=tU(s),tN(n),tN(o),e=Object.keys(n.att).concat(Object.keys(o.att)).sort((e,t)=>e.localeCompare(t)),t={att:{}},e.forEach(e=>{var r,i;Object.keys((null==(r=n.att)?void 0:r[e])||{}).concat(Object.keys((null==(i=o.att)?void 0:i[e])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var i,s;t.att[e]=tE(((e,t)=>{for(var r in t||(t={}))tP.call(t,r)&&tS(e,r,t[r]);if(tx)for(var r of tx(t))tO.call(t,r)&&tS(e,r,t[r]);return e})({},t.att[e]),tI({[r]:(null==(i=n.att[e])?void 0:i[r])||(null==(s=o.att[e])?void 0:s[r])}))})}),t))),v.push(a)}let O=w&&w>aI.wc_sessionAuthenticate.req.ttl?w:aI.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:g??"caip122",chains:h,statement:u,aud:p,domain:d,version:"1",nonce:f,iat:new Date().toISOString(),exp:y,nbf:m,resources:v},requester:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:eB(O)},_={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:h,methods:[...new Set(["personal_sign",...b])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:eB(aI.wc_sessionPropose.req.ttl),id:(0,sM.payloadId)()},{done:A,resolve:R,reject:C}=eq(O,"Request expired"),T=(0,sM.payloadId)(),N=e$("session_connect",_.id),j=e$("session_request",T),U=async({error:e,session:t})=>{this.events.off(j,q),e?C(e):t&&R({session:t})},q=async e=>{var r,i,s;let n;if(await this.deletePendingAuthRequest(T,{message:"fulfilled",code:0}),e.error){let t=i4("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(N,U),C(e.error.message))}await this.deleteProposal(_.id),this.events.off(N,U);let{cacaos:o,responder:a}=e.result,c=[],h=[];for(let e of o){await tC({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),C(i4("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:t}=e,r=tD(t.resources),i=[tA(t.iss)],s=tR(t.iss);if(r){let e=tq(r),t=tk(r);c.push(...e),i.push(...t)}for(let e of i)h.push(`${e}:${s}`)}let u=await this.client.core.crypto.generateSharedKey(x,a.publicKey);c.length>0&&(n={topic:u,acknowledged:!0,self:{publicKey:x,metadata:this.client.metadata},peer:a,controller:a.publicKey,expiry:eB(aE),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:i8([...new Set(c)],[...new Set(h)]),transportType:l},await this.client.core.relayer.subscribe(u,{transportType:l}),await this.client.session.set(u,n),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:a.metadata}),n=this.client.session.get(u)),null!=(r=this.client.metadata.redirect)&&r.linkMode&&null!=(i=a.metadata.redirect)&&i.linkMode&&null!=(s=a.metadata.redirect)&&s.universal&&t&&(this.client.core.addLinkModeSupportedApp(a.metadata.redirect.universal),this.client.session.update(u,{transportType:s6})),R({auths:o,session:n})};this.events.once(N,U),this.events.once(j,q);try{if(c){let e=(0,sM.formatJsonRpcRequest)("wc_sessionAuthenticate",S,T);this.client.core.history.set(E,e);let r=await this.client.core.crypto.encode("",e,{type:2,encoding:iS});a=iH(t,E,r)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:S,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:T}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:_,expiry:aI.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:_.id})])}catch(e){throw this.events.off(N,U),this.events.off(j,q),e}return await this.setProposal(_.id,_),await this.setAuthRequest(T,{request:aT(aD({},S),aN({verifyContext:{}})),pairingTopic:E,transportType:l}),{uri:a??I,response:A}}),aL(this,"approveSessionAuthenticate",async e=>{let t,{id:r,auths:i}=e,s=this.client.core.eventClient.createEvent({properties:{topic:r.toString(),trace:["authenticated_session_approve_started"]}});try{this.isInitialized()}catch(e){throw s.setError("no_internet_connection"),e}let n=this.getPendingAuthRequest(r);if(!n)throw s.setError("authenticated_session_pending_request_not_found"),Error(`Could not find pending auth request with id ${r}`);let o=n.transportType||s4;o===s4&&await this.confirmOnlineStateOrThrow();let a=n.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=iR(a),h={type:1,receiverPublicKey:a,senderPublicKey:c},u=[],p=[];for(let e of i){if(!await tC({cacao:e,projectId:this.client.core.projectId})){s.setError("invalid_cacao");let e=i4("SESSION_SETTLEMENT_FAILED","Signature verification failed");
10throw await this.sendError({id:r,topic:l,error:e,encodeOpts:h}),Error(e.message)}s.addTrace("cacaos_verified");let{p:t}=e,i=tD(t.resources),n=[tA(t.iss)],o=tR(t.iss);if(i){let e=tq(i),t=tk(i);u.push(...e),n.push(...t)}for(let e of n)p.push(`${e}:${o}`)}let d=await this.client.core.crypto.generateSharedKey(c,a);if(s.addTrace("create_authenticated_session_topic"),u?.length>0){t={topic:d,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:a,metadata:n.requester.metadata},controller:a,expiry:eB(aE),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:i8([...new Set(u)],[...new Set(p)]),transportType:o},s.addTrace("subscribing_authenticated_session_topic");try{await this.client.core.relayer.subscribe(d,{transportType:o})}catch(e){throw s.setError("subscribe_authenticated_session_topic_failure"),e}s.addTrace("subscribe_authenticated_session_topic_success"),await this.client.session.set(d,t),s.addTrace("store_authenticated_session"),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}s.addTrace("publishing_authenticated_session_approve");try{await this.sendResult({topic:l,id:r,result:{cacaos:i,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw s.setError("authenticated_session_approve_publish_failure"),e}return await this.client.auth.requests.delete(r,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:t}}),aL(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();let{id:t,reason:r}=e,i=this.getPendingAuthRequest(t);if(!i)throw Error(`Could not find pending auth request with id ${t}`);i.transportType===s4&&await this.confirmOnlineStateOrThrow();let s=i.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),o=iR(s);await this.sendError({id:t,topic:o,error:r,encodeOpts:{type:1,receiverPublicKey:s,senderPublicKey:n},rpcOpts:aI.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,i4("USER_DISCONNECTED"))}),aL(this,"formatAuthMessage",e=>{this.isInitialized();let{request:t,iss:r}=e;return tT(t,r)}),aL(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{let e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),aL(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{let t=this.client.core.pairing.pairings.get(e.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter(r=>{var i,s;return(null==(i=r.peerMetadata)?void 0:i.url)&&(null==(s=r.peerMetadata)?void 0:s.url)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic});if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),aL(this,"deleteSession",async e=>{var t;let{topic:r,expirerHasDeleted:i=!1,emitEvent:s=!0,id:n=0}=e,{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,i4("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),i||this.client.core.expirer.del(r),this.client.core.storage.removeItem(aw).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===r&&this.deletePendingSessionRequest(e.id,i4("USER_DISCONNECTED"))}),r===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=aP),s&&this.client.events.emit("session_delete",{id:n,topic:r})}),aL(this,"deleteProposal",async(e,t)=>{if(t)try{let t=this.client.proposal.get(e),r=this.client.core.eventClient.getEvent({topic:t.pairingTopic});r?.setError("proposal_expired")}catch{}await Promise.all([this.client.proposal.delete(e,i4("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),aL(this,"deletePendingSessionRequest",async(e,t,r=!1)=>
10{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),r&&(this.sessionRequestQueue.state=aP,this.client.events.emit("session_request_expire",{id:e}))}),aL(this,"deletePendingAuthRequest",async(e,t,r=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])}),aL(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),aL(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,eB(aI.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),aL(this,"setAuthRequest",async(e,t)=>{let{request:r,pairingTopic:i,transportType:s=s4}=t;this.client.core.expirer.set(e,r.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:e,pairingTopic:i,verifyContext:r.verifyContext,transportType:s})}),aL(this,"setPendingSessionRequest",async e=>{let{id:t,topic:r,params:i,verifyContext:s}=e,n=i.request.expiryTimestamp||eB(aI.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:r,params:i,verifyContext:s})}),aL(this,"sendRequest",async e=>{let t,i,{topic:s,method:n,params:o,expiry:a,relayRpcId:c,clientRpcId:l,throwOnFailedPublish:h,appLink:u,tvf:p}=e,d=(0,sM.formatJsonRpcRequest)(n,o,l),f=!!u;try{let e=f?iS:iO;t=await this.client.core.crypto.encode(s,d,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${s} failed`),e}if(a_.includes(n)){let e=iC(JSON.stringify(d)),r=iC(t);i=await this.client.core.verify.register({id:r,decryptedId:e})}let g=aI[n].req;if(g.attestation=i,a&&(g.ttl=a),c&&(g.id=c),this.client.core.history.set(s,d),f){let e=iH(u,s,t);await r.g.Linking.openURL(e,this.client.name)}else{let e,r=aI[n].req;a&&(r.ttl=a),c&&(r.id=c),r.tvf=aT(aD({},p),aN({correlationId:d.id})),h?(e=aD({},r.internal),r.internal=aT(e,aN({throwOnFailedPublish:!0})),await this.client.core.relayer.publish(s,t,r)):this.client.core.relayer.publish(s,t,r).catch(e=>this.client.logger.error(e))}return d.id}),aL(this,"sendResult",async e=>{let t,i,s,{id:n,topic:o,result:a,throwOnFailedPublish:c,encodeOpts:l,appLink:h}=e,u=(0,sM.formatJsonRpcResult)(n,a),p=h&&"u">typeof(null==r.g?void 0:r.g.Linking);try{let e,r,i=p?iS:iO;t=await this.client.core.crypto.encode(o,u,(e=aD({},l||{}),r={encoding:i},aT(e,aN(r))))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${o} failed`),e}try{let e=(i=await this.client.core.history.get(o,n)).request;try{this.shouldSetTVF(e.method,e.params)&&(s=this.getTVFParams(n,e.params,a))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${o}, ${n}) failed`),e}if(p){let e=iH(h,o,t);await r.g.Linking.openURL(e,this.client.name)}else{let e,r=aI[i.request.method].res;r.tvf=aT(aD({},s),aN({correlationId:n})),c?(e=aD({},r.internal),r.internal=aT(e,aN({throwOnFailedPublish:!0})),await this.client.core.relayer.publish(o,t,r)):this.client.core.relayer.publish(o,t,r).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(u)}),aL(this,"sendError",async e=>{let t,i,{id:s,topic:n,error:o,encodeOpts:a,rpcOpts:c,appLink:l}=e,h=(0,sM.formatJsonRpcError)(s,o),u=l&&"u">typeof(null==r.g?void 0:r.g.Linking);try{let e,r,i=u?iS:iO;t=await this.client.core.crypto.encode(n,h,(e=aD({},a||{}),r={encoding:i},aT(e,aN(r))))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),e}try{i=await this.client.core.history.get(n,s)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${n}, ${s}) failed`),e}if(u){let e=iH(l,n,t);await r.g.Linking.openURL(e,this.client.name)}else{let e=i.request.method,r=c||aI[e].res;this.client.core.relayer.publish(n,t,r)}await this.client.core.history.resolve(h)}),aL(this,"cleanup",async()=>{let e=[],t=[];
10this.client.session.getAll().forEach(t=>{let r=!1;eM(t.expiry)&&(r=!0),this.client.core.crypto.keychain.has(t.topic)||(r=!0),r&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{eM(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),aL(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),aL(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),aL(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===aO)return void this.client.logger.info("Request queue already active, skipping...");for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=aO;let e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=aP}),aL(this,"processRequest",async e=>{let{topic:t,payload:r,attestation:i,transportType:s,encryptedId:n}=e,o=r.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest
10({topic:t,payload:r,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,r);case"wc_sessionPing":return await this.onSessionPingRequest(t,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:r,attestation:i,encryptedId:n,transportType:s});case"wc_sessionEvent":return await this.onSessionEventRequest(t,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:r,attestation:i,encryptedId:n,transportType:s});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),aL(this,"onRelayEventResponse",async e=>{let{topic:t,payload:r,transportType:i}=e,s=(await this.client.core.history.get(t,r.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${s}`)}}),aL(this,"onRelayEventUnknownPayload",e=>{let{topic:t}=e,{message:r}=i6("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw Error(r)}),aL(this,"shouldIgnorePairingRequest",e=>{let{topic:t,requestMethod:r}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(r))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),aL(this,"onSessionProposeRequest",async e=>{let{topic:t,payload:r,attestation:i,encryptedId:s}=e,{params:n,id:o}=r;try{let e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError("proposal_listener_not_found")),this.isValidConnect(aD({},r.params));let a=n.expiryTimestamp||eB(aI.wc_sessionPropose.req.ttl),c=aD({id:o,pairingTopic:t,expiryTimestamp:a},n);await this.setProposal(o,c);let l=await this.getVerifyContext({attestationId:i,hash:iC(JSON.stringify(r)),encryptedId:s,metadata:c.proposer.metadata});e?.addTrace("emit_session_proposal"),this.client.events.emit("session_proposal",{id:o,params:c,verifyContext:l})}catch(e){await this.sendError({id:o,topic:t,error:e,rpcOpts:aI.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),aL(this,"onSessionProposeResponse",async(e,t,r)=>{let{id:i}=t;if((0,sM.isJsonRpcResult)(t)){let{result:s}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});let n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});let o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});let a=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});let c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:c,pairingTopic:e,proposalId:i,publicKey:o});let l=await this.client.core.relayer.subscribe(c,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:e})}else if((0,sM.isJsonRpcError)(t)){await this.client.proposal.delete(i,i4("USER_DISCONNECTED"));let e=e$("session_connect",i);if(0===this.events.listenerCount(e))throw Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),aL(this,"onSessionSettleRequest",async(e,t)=>{let{id:r,params:i}=t;try{let r,s;this.isValidSessionSettleRequest(i);let{relay:n,controller:o,expiry:a,namespaces:c,sessionProperties:l,scopedProperties:h,sessionConfig:u}=t.params,p=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!p)return this.client.logger.error(`Pending session not found for topic ${e}`);let d=this.client.proposal.get(p.proposalId),f=(r=aD(aD(aD({topic:e,relay:n,expiry:a,namespaces:c,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:d.requiredNamespaces,optionalNamespaces:d.optionalNamespaces,controller:o.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}},l&&{sessionProperties:l}),h&&{scopedProperties:h}),u&&{sessionConfig:u}),s={transportType:s4}
10,aT(r,aN(s)));await this.client.session.set(f.topic,f),await this.setExpiry(f.topic,f.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:f.peer.metadata}),this.client.events.emit("session_connect",{session:f}),this.events.emit(e$("session_connect",p.proposalId),{session:f}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(f),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),aL(this,"onSessionSettleResponse",async(e,t)=>{let{id:r}=t;(0,sM.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(e$("session_approve",r),{})):(0,sM.isJsonRpcError)(t)&&(await this.client.session.delete(e,i4("USER_DISCONNECTED")),this.events.emit(e$("session_approve",r),{error:t.error}))}),aL(this,"onSessionUpdateRequest",async(e,t)=>{let{params:r,id:i}=t;try{let t=`${e}_session_update`,s=sg.get(t);if(s&&this.isRequestOutOfSync(s,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:e,error:i4("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(aD({topic:e},r));try{sg.set(t,i),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw sg.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:r})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),aL(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),aL(this,"onSessionUpdateResponse",(e,t)=>{let{id:r}=t,i=e$("session_update",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("session_update",r),{}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("session_update",r),{error:t.error})}),aL(this,"onSessionExtendRequest",async(e,t)=>{let{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,eB(aE)),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),aL(this,"onSessionExtendResponse",(e,t)=>{let{id:r}=t,i=e$("session_extend",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("session_extend",r),{}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("session_extend",r),{error:t.error})}),aL(this,"onSessionPingRequest",async(e,t)=>{let{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),aL(this,"onSessionPingResponse",(e,t)=>{let{id:r}=t,i=e$("session_ping",r);setTimeout(()=>{if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners 2176`);(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("session_ping",r),{}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("session_ping",r),{error:t.error})},500)}),aL(this,"onSessionDeleteRequest",async(e,t)=>{let{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(s0,async()=>{t(await this.deleteSession({topic:e,id:r}))})}),this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:i4("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),aL(this,"onSessionRequest",async e=>{var t,r,i;let{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=e,{id:l,params:h}=n;try{await this.isValidRequest(aD({topic:s},h));let e=this.client.session.get(s),n=await this.getVerifyContext({attestationId:o,hash:iC(JSON.stringify((0,sM.formatJsonRpcRequest)("wc_sessionRequest",h,l))),encryptedId:a,metadata:e.peer.metadata,transportType:c}
10),u={id:l,topic:s,params:h,verifyContext:n};await this.setPendingSessionRequest(u),c===s6&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(r=e.peer.metadata.redirect)?void 0:r.universal),null!=(i=this.client.signConfig)&&i.disableRequestQueue?this.emitSessionRequest(u):(this.addSessionRequestToSessionRequestQueue(u),this.processSessionRequestQueue())}catch(e){await this.sendError({id:l,topic:s,error:e}),this.client.logger.error(e)}}),aL(this,"onSessionRequestResponse",(e,t)=>{let{id:r}=t,i=e$("session_request",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("session_request",r),{result:t.result}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("session_request",r),{error:t.error})}),aL(this,"onSessionEventRequest",async(e,t)=>{let{id:r,params:i}=t;try{let t=`${e}_session_event_${i.event.name}`,s=sg.get(t);if(s&&this.isRequestOutOfSync(s,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(aD({topic:e},i)),this.client.events.emit("session_event",{id:r,topic:e,params:i}),sg.set(t,r)}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),aL(this,"onSessionAuthenticateResponse",(e,t)=>{let{id:r}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,sM.isJsonRpcResult)(t)?this.events.emit(e$("session_request",r),{result:t.result}):(0,sM.isJsonRpcError)(t)&&this.events.emit(e$("session_request",r),{error:t.error})}),aL(this,"onSessionAuthenticateRequest",async e=>{var t;let{topic:r,payload:i,attestation:s,encryptedId:n,transportType:o}=e;try{let{requester:e,authPayload:a,expiryTimestamp:c}=i.params,l=await this.getVerifyContext({attestationId:s,hash:iC(JSON.stringify(i)),encryptedId:n,metadata:e.metadata,transportType:o}),h={requester:e,pairingTopic:r,id:i.id,authPayload:a,verifyContext:l,expiryTimestamp:c};await this.setAuthRequest(i.id,{request:h,pairingTopic:r,transportType:o}),o===s6&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:i.params,id:i.id,verifyContext:l})}catch(n){this.client.logger.error(n);let e=i.params.requester.publicKey,t=await this.client.core.crypto.generateKeyPair(),s=this.getAppLinkIfEnabled(i.params.requester.metadata,o);await this.sendError({id:i.id,topic:r,error:n,encodeOpts:{type:1,receiverPublicKey:e,senderPublicKey:t},rpcOpts:aI.wc_sessionAuthenticate.autoReject,appLink:s})}}),aL(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),aL(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=aP,this.processSessionRequestQueue()},(0,u.toMiliseconds)(this.requestQueueDelay))}),aL(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{let r=this.client.core.history.pending;r.length>0&&r.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{let r=e$("session_request",e.request.id);if(0===this.events.listenerCount(r))throw Error(`emitting ${r} without any listeners`);this.events.emit(e$("session_request",e.request.id),{error:t})})}),aL(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===aO)return void this.client.logger.info("session request queue is already active.");let e=this.sessionRequestQueue.queue[0];if(!e)return void this.client.logger.info("session request queue is empty.");try{this.sessionRequestQueue.state=aO,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}}),aL(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),aL(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;let t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);
10t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,sM.formatJsonRpcRequest)("wc_sessionPropose",aT(aD({},t),aN({requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties})),t.id)})}),aL(this,"isValidConnect",async e=>{let t;if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw Error(t)}let{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:n,scopedProperties:o,relays:a}=e;if(se(r)||await this.isValidPairingTopic(r),t=!1,a?a&&i9(a)&&a.length&&a.forEach(e=>{t=sa(e)}):t=!0,!t){let{message:e}=i6("MISSING_OR_INVALID",`connect() relays: ${a}`);throw Error(e)}if(!se(i)&&0!==i7(i)){let e="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(e):this.client.logger.warn(e),this.validateNamespaces(i,"requiredNamespaces")}if(se(s)||0===i7(s)||this.validateNamespaces(s,"optionalNamespaces"),se(n)||this.validateSessionProps(n,"sessionProperties"),!se(o)){this.validateSessionProps(o,"scopedProperties");let e=Object.keys(i||{}).concat(Object.keys(s||{}));if(!Object.keys(o).every(t=>e.includes(t)))throw Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(o)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),aL(this,"validateNamespaces",(e,t)=>{let r=function(e,t,r){let i=null;if(e&&i7(e)){let s,n=sn(e,t);n&&(i=n);let o=(s=null,Object.entries(e).forEach(([e,i])=>{var n,o;let a;if(s)return;let c=(n=ed(e,i),o=`${t} ${r}`,a=null,i9(n)&&n.length?n.forEach(e=>{a||si(e)||(a=i4("UNSUPPORTED_CHAINS",`${o}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):si(e)||(a=i4("UNSUPPORTED_CHAINS",`${o}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),a);c&&(s=c)}),s);o&&(i=o)}else i=i6("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return i}(e,"connect()",t);if(r)throw Error(r.message)}),aL(this,"isValidApprove",async e=>{if(!sc(e))throw Error(i6("MISSING_OR_INVALID",`approve() params: ${e}`).message);let{id:t,namespaces:r,relayProtocol:i,sessionProperties:s,scopedProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let o=this.client.proposal.get(t),a=so(r,"approve()");if(a)throw Error(a.message);let c=sh(o.requiredNamespaces,r,"approve()");if(c)throw Error(c.message);if(!st(i,!0)){let{message:e}=i6("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw Error(e)}if(se(s)||this.validateSessionProps(s,"sessionProperties"),!se(n)){this.validateSessionProps(n,"scopedProperties");let e=new Set(Object.keys(r));if(!Object.keys(n).every(t=>e.has(t)))throw Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),aL(this,"isValidReject",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`reject() params: ${e}`);throw Error(t)}let{id:t,reason:r}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!r||"object"!=typeof r||!r.code||!sr(r.code,!1)||!r.message||!st(r.message,!1)){let{message:e}=i6("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw Error(e)}}),aL(this,"isValidSessionSettleRequest",e=>{let t;if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw Error(t)}let{relay:r,controller:i,namespaces:s,expiry:n}=e;if(!sa(r)){let{message:e}=i6("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw Error(e)}let o=(t=null,st(i?.publicKey,!1)||(t=i6("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),t);if(o)throw Error(o.message);let a=so(s,"onSessionSettleRequest()");if(a)throw Error(a.message);if(eM(n)){let{message:e}=i6("EXPIRED","onSessionSettleRequest()");throw Error(e)}}),aL(this,"isValidUpdate",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`update() params: ${e}`);throw Error(t)}let{topic:t,namespaces:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);
10let i=this.client.session.get(t),s=so(r,"update()");if(s)throw Error(s.message);let n=sh(i.requiredNamespaces,r,"update()");if(n)throw Error(n.message)}),aL(this,"isValidExtend",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`extend() params: ${e}`);throw Error(t)}let{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),aL(this,"isValidRequest",async e=>{var t;let r;if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`request() params: ${e}`);throw Error(t)}let{topic:i,request:s,chainId:n,expiry:o}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:a}=this.client.session.get(i);if(!sl(a,n)){let{message:e}=i6("MISSING_OR_INVALID",`request() chainId: ${n}`);throw Error(e)}if(se(s)||!st(s.method,!1)){let{message:e}=i6("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw Error(e)}if(!(st(t=s.method,!1)&&(r=[],Object.values(a).forEach(e=>{iX(e.accounts).includes(n)&&r.push(...e.methods)}),r).includes(t))){let{message:e}=i6("MISSING_OR_INVALID",`request() method: ${s.method}`);throw Error(e)}if(o&&(!sr(o,!1)||!(o<=ax.max)||!(o>=ax.min))){let{message:e}=i6("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${ax.min} and ${ax.max}`);throw Error(e)}}),aL(this,"isValidRespond",async e=>{var t;if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`respond() params: ${e}`);throw Error(t)}let{topic:r,response:i}=e;try{await this.isValidSessionTopic(r)}catch(r){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),r}if(se(i)||se(i.result)&&se(i.error)||!sr(i.id,!1)||!st(i.jsonrpc,!1)){let{message:e}=i6("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw Error(e)}}),aL(this,"isValidPing",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),aL(this,"isValidEmit",async e=>{var t;let r;if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`emit() params: ${e}`);throw Error(t)}let{topic:i,event:s,chainId:n}=e;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!sl(o,n)){let{message:e}=i6("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw Error(e)}if(se(s)||!st(s.name,!1)||!(st(t=s.name,!1)&&(r=[],Object.values(o).forEach(e=>{iX(e.accounts).includes(n)&&r.push(...e.events)}),r).includes(t))){let{message:e}=i6("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw Error(e)}}),aL(this,"isValidDisconnect",async e=>{if(!sc(e)){let{message:t}=i6("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),aL(this,"isValidAuthenticate",e=>{let{chains:t,uri:r,domain:i,nonce:s}=e;if(!Array.isArray(t)||0===t.length)throw Error("chains is required and must be a non-empty array");if(!st(r,!1))throw Error("uri is required parameter");if(!st(i,!1))throw Error("domain is required parameter");if(!st(s,!1))throw Error("nonce is required parameter");if([...new Set(t.map(e=>eu(e).namespace))].length>1)throw Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:n}=eu(t[0]);if("eip155"!==n)throw Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),aL(this,"getVerifyContext",async e=>{let{attestationId:t,hash:r,encryptedId:i,metadata:s,transportType:n}=e,o={verified:{verifyUrl:s.verifyUrl||nu,validation:"UNKNOWN",origin:s.url||""}};try{if(n===s6){let e=this.getAppLinkIfEnabled(s,n);return o.verified.validation=e&&new URL(e).origin===new URL(s.url).origin?"VALID":"INVALID",o}let e=await this.client.core.verify.resolve({attestationId:t,hash:r,encryptedId:i,verifyUrl:s.verifyUrl});e&&(o.verified.origin=e.origin,o.verified.isScam=e.isScam,o.verified.validation=e.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(o)}`),o}),aL(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((r,i)=>{if(null==r){let{message:s}=i6("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${r} for key ${Object.keys(e)[i]}`);throw Error(s)}})}),aL(this,"getPendingAuthRequest",e=>{let t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),aL(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0,t=this.recentlyDeletedLimit/2;
10for(let r of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(r)}}}),aL(this,"checkRecentlyDeleted",e=>{let t=this.recentlyDeletedMap.get(e);if(t){let{message:r}=i6("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw Error(r)}}),aL(this,"isLinkModeEnabled",(e,t)=>{var i,s,n,o,a,c,l,h,u;return!!e&&t===s6&&(null==(s=null==(i=this.client.metadata)?void 0:i.redirect)?void 0:s.linkMode)===!0&&(null==(o=null==(n=this.client.metadata)?void 0:n.redirect)?void 0:o.universal)!==void 0&&(null==(c=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:c.universal)!==""&&(null==(l=e?.redirect)?void 0:l.universal)!==void 0&&(null==(h=e?.redirect)?void 0:h.universal)!==""&&(null==(u=e?.redirect)?void 0:u.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&"u">typeof(null==r.g?void 0:r.g.Linking)}),aL(this,"getAppLinkIfEnabled",(e,t)=>{var r;return this.isLinkModeEnabled(e,t)?null==(r=e?.redirect)?void 0:r.universal:void 0}),aL(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;let t=eF(e,"topic")||"",r=decodeURIComponent(eF(e,"wc_ev")||""),i=this.client.session.keys.includes(t);i&&this.client.session.update(t,{transportType:s6}),this.client.core.dispatchEnvelope({topic:t,message:r,sessionExists:i})}),aL(this,"registerLinkModeListeners",async()=>{var e;if(eW()||eS()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){let e=null==r.g?void 0:r.g.Linking;if("u">typeof e){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);let t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),aL(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;let{request:r}=t;return Object.keys(aS).includes(r.method)}),aL(this,"getTVFParams",(e,t,r)=>{var i,s;try{let n,o,a=t.request.method,c=this.extractTxHashesFromResult(a,r);return n=aD({correlationId:e,rpcMethods:[a],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(s=null==(i=t.request.params)?void 0:i[0])?void 0:s.to]}),o={txHashes:c},aT(n,aN(o))}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),aL(this,"isValidContractData",e=>{var t;if(!e)return!1;try{let r=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!r.startsWith("0x"))return!1;let i=r.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),aL(this,"extractTxHashesFromResult",(e,t)=>{try{let r=aS[e];if("string"==typeof t)return[t];let i=t[r.key];if(i9(i))return"solana_signAllTransactions"===e?i.map(e=>(function(e){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);let i=r[0];if(0===i)throw Error("No signatures found");if(r.length<1+64*i)throw Error("Transaction data too short for claimed signature count");if(r.length<100)throw Error("Transaction too short");let s=eh.from(e,"base64").slice(1,65);return en.A.encode(s)})(e)):i;if("string"==typeof i)return[i]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{let e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(let[e,r]of Object.entries(t))for(let t of r)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){let{message:e}=i6("NOT_INITIALIZED",this.name);throw Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(sZ,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){let{topic:t,message:r,attestation:i,transportType:s}=e,{publicKey:n}=this.client.auth.authKeys.keys.includes(aR)?this.client.auth.authKeys.get(aR):{responseTopic:void 0,publicKey:void 0};try{let e=await this.client.core.crypto.decode(t,r,{receiverPublicKey:n,encoding:s===s6?iS:iO});(0,sM.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:i,transportType:s,encryptedId:iC(r)})):(0,sM.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:s}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:s}),await this.client.core.relayer.messages.ack(t,r)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(nh,async e=>
10{let{topic:t,id:r}=eL(e.target);return r&&this.client.pendingRequest.keys.includes(r)?await this.deletePendingSessionRequest(r,i6("EXPIRED"),!0):r&&this.client.auth.requests.keys.includes(r)?await this.deletePendingAuthRequest(r,i6("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r})))})}registerPairingEvents(){this.client.core.pairing.events.on(ni,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(ns,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!st(e,!1)){let{message:t}=i6("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=i6("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(eM(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=i6("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}async isValidSessionTopic(e){if(!st(e,!1)){let{message:t}=i6("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=i6("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw Error(t)}if(eM(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=i6("EXPIRED",`session topic: ${e}`);throw Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=i6("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(st(e,!1)){let{message:t}=i6("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw Error(t)}else{let{message:t}=i6("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw Error(t)}}async isValidProposalId(e){if("number"!=typeof e){let{message:t}=i6("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=i6("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw Error(t)}if(eM(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=i6("EXPIRED",`proposal id: ${e}`);throw Error(t)}}}class aM extends oG{constructor(e,t){super(e,t,"proposal",ab),this.core=e,this.logger=t}}class a$ extends oG{constructor(e,t){super(e,t,"session",ab),this.core=e,this.logger=t}}class az extends oG{constructor(e,t){super(e,t,"request",ab,e=>e.id),this.core=e,this.logger=t}}class aH extends oG{constructor(e,t){super(e,t,"authKeys",aA,()=>aR),this.core=e,this.logger=t}}class aV extends oG{constructor(e,t){super(e,t,"pairingTopics",aA),this.core=e,this.logger=t}}class aF extends oG{constructor(e,t){super(e,t,"requests",aA,e=>e.id),this.core=e,this.logger=t}}var aK=Object.defineProperty,aW=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?aK(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class aJ{constructor(e,t){this.core=e,this.logger=t,aW(this,"authKeys"),aW(this,"pairingTopics"),aW(this,"requests"),this.authKeys=new aH(this.core,this.logger),this.pairingTopics=new aV(this.core,this.logger),this.requests=new aF(this.core,this.logger)}
10async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var aG=Object.defineProperty,aY=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?aG(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class aZ extends sk{constructor(e){super(e),aY(this,"protocol","wc"),aY(this,"version",2),aY(this,"name",am),aY(this,"metadata"),aY(this,"core"),aY(this,"logger"),aY(this,"events",new c.EventEmitter),aY(this,"engine"),aY(this,"session"),aY(this,"proposal"),aY(this,"pendingRequest"),aY(this,"auth"),aY(this,"signConfig"),aY(this,"on",(e,t)=>this.events.on(e,t)),aY(this,"once",(e,t)=>this.events.once(e,t)),aY(this,"off",(e,t)=>this.events.off(e,t)),aY(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),aY(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),aY(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),aY(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),aY(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||am,this.metadata=function(e){var t,r;let i=eC();try{let s,n;return null!=e&&e.url&&i.url&&new URL(e.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),e.url=i.url),null!=(t=e?.icons)&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(e=>""!==e)),s=eE(eE({},i),e),n={url:e?.url||i.url,name:e?.name||i.name,description:e?.description||i.description,icons:null!=(r=e?.icons)&&r.length&&e.icons.length>0?e.icons:i.icons},eg(s,ey(n))}catch(t){return console.warn("Error populating app metadata",t),e||i}}(e?.metadata),this.signConfig=e?.signConfig;const t="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:(0,sb.h6)((0,sb.iP)({level:e?.logger||"error"}));this.core=e?.core||new ay(e),this.logger=(0,sb.U5)(t,this.name),this.session=new a$(this.core,this.logger),this.proposal=new aM(this.core,this.logger),this.pendingRequest=new az(this.core,this.logger),this.engine=new aB(this),this.auth=new aJ(this.core,this.logger)}static async init(e){let t=new aZ(e);return await t.initialize(),t}get context(){return(0,sb.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,u.toMiliseconds)(u.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var aQ=r(54205),aX=r(82909).hp;let a0="error",a1="wc@2:universal_provider:",a2="https://rpc.walletconnect.org/v1/",a8="generic",a5=`${a2}bundler`,a3="default_chain_changed";function a6(){}function a4(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function a9(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function a7(e){return"object"==typeof e&&null!==e}function ce(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
10function ct(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let cr="[object String]",ci="[object Number]",cs="[object Boolean]",cn="[object Arguments]";function co(e,t,r,i=new Map,s){let n=s?.(e,t,r,i);if(null!=n)return n;if(a4(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let t=Array(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=co(e[n],n,r,i,s);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;for(let[n,o]of(i.set(e,t),e))t.set(n,co(o,n,r,i,s));return t}if(e instanceof Set){let t=new Set;for(let n of(i.set(e,t),e))t.add(co(n,void 0,r,i,s));return t}if("u">typeof aX&&aX.isBuffer(e))return e.subarray();if(a9(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=co(e[n],n,r,i,s);return t}if(e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,t),ca(t,e,r,i,s),t}if("u">typeof File&&e instanceof File){let t=new File([e],e.name,{type:e.type});return i.set(e,t),ca(t,e,r,i,s),t}if(e instanceof Blob){let t=new Blob([e],{type:e.type});return i.set(e,t),ca(t,e,r,i,s),t}if(e instanceof Error){let t=new e.constructor;return i.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,ca(t,e,r,i,s),t}if("object"==typeof e&&function(e){switch(ct(e)){case cn:case"[object Array]":case"[object ArrayBuffer]":case"[object DataView]":case cs:case"[object Date]":case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Map]":case ci:case"[object Object]":case"[object RegExp]":case"[object Set]":case cr:case"[object Symbol]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return!0;default:return!1}}(e)){let t=Object.create(Object.getPrototypeOf(e));return i.set(e,t),ca(t,e,r,i,s),t}return e}function ca(e,t,r=e,i,s){let n=[...Object.keys(t),...ce(t)];for(let o=0;o<n.length;o++){let a=n[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=co(t[a],a,r,i,s))}}function cc(e){var t;return t=(t,r,i,s)=>{let n;if(null!=n)return n;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case ci:case cr:case cs:{let t=new e.constructor(e?.valueOf());return ca(t,e),t}case cn:{let t={};return ca(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}},co(e,void 0,e,new Map,t)}function cl(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===ct(e)}var ch=Object.defineProperty,cu=Object.defineProperties,cp=Object.getOwnPropertyDescriptors,cd=Object.getOwnPropertySymbols,cf=Object.prototype.hasOwnProperty,cg=Object.prototype.propertyIsEnumerable,cy=(e,t,r)=>t in e?ch(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,cm=(e,t)=>{for(var r in t||(t={}))cf.call(t,r)&&cy(e,r,t[r]);if(cd)for(var r of cd(t))cg.call(t,r)&&cy(e,r,t[r]);return e},cb=(e,t)=>cu(e,cp(t));function cw(e,t,r){var i;let s=eu(e);return(null==(i=t.rpcMap)?void 0:i[s.reference])||`${a2}?chainId=${s.namespace}:${s.reference}&projectId=${r}`}function cv(e){return e.includes(":")?e.split(":")[1]:e}function cE(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function cI(e={},t={}){return function(e,...t){return function(e,...t){let r=t.slice(0,-1),i=t[t.length-1],s=e;for(let e=0;e<r.length;e++)s=function e(t,r,i,s){if(a4(t)&&(t=Object(t)),null==r||"object"!=typeof r)return t;if(s.has(r))return function(e){if(a4(e))return e;if(Array.isArray(e)||a9(e)||e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);let t=Object.getPrototypeOf(e),r=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new r(e);if(e instanceof RegExp){let t=new r(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new r(e.buffer.slice(0));if(e instanceof Error){let t=new r(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}return"u">typeof File&&e instanceof File?new r([e],e.name,{type:e.type,lastModified:e.lastModified}):"object"==typeof e?Object.assign(Object.create(t),e):e}(s.get(r));if(s.set(r,t),Array.isArray(r)){r=r.slice();for(let e=0;e<r.length;e++)r[e]=r[e]??void 0}let n=[...Object.keys(r),...ce(r)];for(let o=0;o<n.length;o++){let a=n[o],c=r[a],l=t[a];if(cl(c)&&(c={...c}),cl(l)&&(l={...l}),"u">typeof aX&&aX.isBuffer(c)&&(c=cc(c)),Array.isArray(c))if("object"==typeof l&&null!=l){let e=[],t=Reflect.ownKeys(l);for(let r=0;r<t.length;r++){let i=t[r];e[i]=l[i]}l=e}else l=[];let h=i(l,c,a,t,r,s);null!=h?t[a]=h:Array.isArray(c)||a7(l)&&a7(c)?t[a]=e(l,c,i,s):null==l&&function(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;
10if("[object Object]"!==Object.prototype.toString.call(e)){let t=e[Symbol.toStringTag];return null!=t&&!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(c)?t[a]=e({},c,i,s):null==l&&a9(c)?t[a]=cc(c):(void 0===l||void 0!==c)&&(t[a]=c)}return t}(s,r[e],i,new Map);return s}(e,...t,a6)}(cx(e),cx(t))}function cx(e){var t,r,i,s,n;let o={};if(!i7(e))return o;for(let[a,c]of Object.entries(e)){let e=i0(a)?[a]:c.chains,l=c.methods||[],h=c.events||[],u=c.rpcMap||{},p=i1(a);o[p]=cb(cm(cm({},o[p]),c),{chains:ez(e,null==(t=o[p])?void 0:t.chains),methods:ez(l,null==(r=o[p])?void 0:r.methods),events:ez(h,null==(i=o[p])?void 0:i.events)}),(i7(u)||i7((null==(s=o[p])?void 0:s.rpcMap)||{}))&&(o[p].rpcMap=cm(cm({},u),null==(n=o[p])?void 0:n.rpcMap))}return o}function cP(e){return e.includes(":")?e.split(":")[2]:e}function cO(e){let t={};for(let[r,i]of Object.entries(e)){let e=i.methods||[],s=i.events||[],n=i.accounts||[],o=i0(r)?[r]:i.chains?i.chains:cE(i.accounts);t[r]={chains:o,methods:e,events:s,accounts:n}}return t}function cS(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):isNaN(Number(e=e.includes(":")?e.split(":")[1]:e))?e:Number(e)}let c_={},cA=e=>c_[e],cR=(e,t)=>{c_[e]=t};var cC=Object.defineProperty,cT=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?cC(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class cN{constructor(e){cT(this,"name","polkadot"),cT(this,"client"),cT(this,"httpProviders"),cT(this,"events"),cT(this,"namespace"),cT(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${e}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=cv(t);e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var cj=Object.defineProperty,cU=Object.defineProperties,cq=Object.getOwnPropertyDescriptors,ck=Object.getOwnPropertySymbols,cD=Object.prototype.hasOwnProperty,cL=Object.prototype.propertyIsEnumerable,cB=(e,t,r)=>t in e?cj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,cM=(e,t)=>{for(var r in t||(t={}))cD.call(t,r)&&cB(e,r,t[r]);if(ck)for(var r of ck(t))cL.call(t,r)&&cB(e,r,t[r]);return e},c$=(e,t,r)=>cB(e,"symbol"!=typeof t?t+"":t,r);class cz{constructor(e){c$(this,"name","eip155"),c$(this,"client"),c$(this,"chainId"),c$(this,"namespace"),c$(this,"httpProviders"),c$(this,"events"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(a3,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){let r=t||cw(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.V(r,cA("disableProviderPing")))}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=parseInt(cv(t));e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){let e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,r;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0",s=parseInt(i=i.startsWith("0x")?i:`0x${i}`,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain(`${s}`);else throw Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,r,i,s,n;let o=null==(r=null==(t=e.request)?void 0:t.params)?void 0:r[0],a=(null==(s=null==(i=e.request)?void 0:i.params)?void 0:s[1])||[],c=`${o}${a.join(",")}`;if(!o)throw Error("Missing address parameter in `wallet_getCapabilities` request");let l=this.client.session.get(e.topic),h=(null==(n=l?.sessionProperties)?void 0:n.capabilities)||{};if(null!=h&&h[c])return h?.[c];let u=await this.client.request(e);try{let t,r,i,s;await this.client.session.update(e.topic,{sessionProperties:(i=cM({},l.sessionProperties||{}),s={capabilities:(t=cM({},h||{}),r={[c]:u},cU(t,cq(r)))},cU(i,cq(s)))})}catch(e){console.warn("Failed to update session with capabilities",e)}return u}async getCallStatus(e){var t,r;let i=this.client.session.get(e.topic),s=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(s){let t=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}let n=null==(r=i.sessionProperties)?void 0:r.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var r;let i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,sM.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(r=t.request.params)?void 0:r[0]]))});if(!s.ok)throw Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}
10getBundlerUrl(e,t){return`${a5}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var cH=Object.defineProperty,cV=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?cH(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class cF{constructor(e){cV(this,"name","solana"),cV(this,"client"),cV(this,"httpProviders"),cV(this,"events"),cV(this,"namespace"),cV(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=cv(t);e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var cK=Object.defineProperty,cW=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?cK(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class cJ{constructor(e){cW(this,"name","cosmos"),cW(this,"client"),cW(this,"httpProviders"),cW(this,"events"),cW(this,"namespace"),cW(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=cv(t);e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var cG=Object.defineProperty,cY=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?cG(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class cZ{constructor(e){cY(this,"name","algorand"),cY(this,"client"),cY(this,"httpProviders"),cY(this,"events"),cY(this,"namespace"),cY(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){let r=t||cw(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(a3,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var cQ=Object.defineProperty,cX=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?cQ(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class c0{constructor(e){cX(this,"name","cip34"),cX(this,"client"),cX(this,"httpProviders"),cX(this,"events"),cX(this,"namespace"),cX(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{let r=this.getCardanoRPCUrl(t),i=cv(t);e[i]=this.createHttpProvider(i,r)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){let t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||this.getCardanoRPCUrl(e);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var c1=Object.defineProperty,c2=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?c1(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class c8{constructor(e){c2(this,"name","elrond"),c2(this,"client"),c2(this,"httpProviders"),c2(this,"events"),c2(this,"namespace"),c2(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=cv(t);e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var c5=Object.defineProperty,c3=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?c5(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class c6{constructor(e){c3(this,"name","multiversx"),c3(this,"client"),c3(this,"httpProviders"),c3(this,"events"),c3(this,"namespace"),c3(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;let i=cv(t);e[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var c4=Object.defineProperty,c9=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?c4(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class c7{constructor(e){c9(this,"name","near"),c9(this,"client"),c9(this,"httpProviders"),c9(this,"events"),c9(this,"namespace"),c9(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){let r=t||cw(`${this.name}:${e}`,this.namespace);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(a3,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace);return typeof r>"u"?void 0:new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var le=Object.defineProperty,lt=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?le(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class lr{constructor(e){lt(this,"name","tezos"),lt(this,"client"),lt(this,"httpProviders"),lt(this,"events"),lt(this,"namespace"),lt(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){let r=t||cw(`${this.name}:${e}`,this.namespace);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(a3,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace);return typeof r>"u"?void 0:new sB.F(new aQ.A(r))}}var li=Object.defineProperty,ls=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?li(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class ln{constructor(e){ls(this,"name",a8),ls(this,"client"),ls(this,"httpProviders"),ls(this,"events"),ls(this,"namespace"),ls(this,"chainId"),this.namespace=e.namespace,this.events=cA("events"),this.client=cA("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(a3,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;let r={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e
10=>{let t=eu(e);r[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),r}getHttpProvider(e){let t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){let r=t||cw(e,this.namespace,this.client.core.projectId);if(!r)throw Error(`No RPC url provided for chainId: ${e}`);return new sB.F(new aQ.A(r,cA("disableProviderPing")))}}var lo=Object.defineProperty,la=Object.defineProperties,lc=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,lh=Object.prototype.hasOwnProperty,lu=Object.prototype.propertyIsEnumerable,lp=(e,t,r)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ld=(e,t)=>{for(var r in t||(t={}))lh.call(t,r)&&lp(e,r,t[r]);if(ll)for(var r of ll(t))lu.call(t,r)&&lp(e,r,t[r]);return e},lf=(e,t,r)=>lp(e,"symbol"!=typeof t?t+"":t,r);class lg{constructor(e){lf(this,"client"),lf(this,"namespaces"),lf(this,"optionalNamespaces"),lf(this,"sessionProperties"),lf(this,"scopedProperties"),lf(this,"events",new(l())),lf(this,"rpcProviders",{}),lf(this,"session"),lf(this,"providerOpts"),lf(this,"logger"),lf(this,"uri"),lf(this,"disableProviderPing",!1),this.providerOpts=e,this.logger="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:(0,sb.h6)((0,sb.iP)({level:e?.logger||a0})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){let t=new lg(e);return await t.initialize(),t}async request(e,t,r){let[i,s]=this.validateChain(t);if(!this.session)throw Error("Please call connect() before request()");return await this.getProvider(i).request({request:ld({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:r})}sendAsync(e,t,r,i){let s=new Date().getTime();this.request(e,r,i).then(e=>t(null,(0,sM.formatJsonRpcResult)(s,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:i4("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();let{uri:r,response:i}=await this.client.authenticate(e,t);r&&(this.uri=r,this.events.emit("display_uri",r));let s=await i();if(this.session=s.session,this.session){let e=cO(this.session.namespaces);this.namespaces=cI(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){let{uri:t,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));let i=await r();this.session=i;let s=cO(i.namespaces);return this.namespaces=cI(this.namespaces,s),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;let[r,i]=this.validateChain(e),s=this.getProvider(r);s.name===a8?s.setDefaultChain(`${r}:${i}`,t):s.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");let t=this.client.pairing.getAll();if(i9(t)){for(let r of t)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,t;if(this.client=this.providerOpts.client||await aZ.init({core:this.providerOpts.core,logger:this.providerOpts.logger||a0,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{let e=this.client.session.getAll();this.session=e[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw Error("Sign Client not initialized");if(!this.session)throw Error("Session not initialized. Please call connect() before enable()");let e=[...new Set(Object.keys(this.session.namespaces).map(e=>i1(e)))];cR("client",this.client),cR("events",this.events),cR("disableProviderPing",this.disableProviderPing),e.forEach(e
10=>{if(!this.session)return;let t=function(e,t){let r=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!r.length)return[];let i=[];return r.forEach(e=>{let r=t.namespaces[e].accounts;i.push(...r)}),i}(e,this.session),r=cE(t),i=la(ld({},cI(this.namespaces,this.optionalNamespaces)[e]),lc({accounts:t,chains:r}));switch(e){case"eip155":this.rpcProviders[e]=new cz({namespace:i});break;case"algorand":this.rpcProviders[e]=new cZ({namespace:i});break;case"solana":this.rpcProviders[e]=new cF({namespace:i});break;case"cosmos":this.rpcProviders[e]=new cJ({namespace:i});break;case"polkadot":this.rpcProviders[e]=new cN({namespace:i});break;case"cip34":this.rpcProviders[e]=new c0({namespace:i});break;case"elrond":this.rpcProviders[e]=new c8({namespace:i});break;case"multiversx":this.rpcProviders[e]=new c6({namespace:i});break;case"near":this.rpcProviders[e]=new c7({namespace:i});break;case"tezos":this.rpcProviders[e]=new lr({namespace:i});break;default:this.rpcProviders[a8]?this.rpcProviders[a8].updateNamespace(i):this.rpcProviders[a8]=new ln({namespace:i})}})}registerEventListeners(){if(typeof this.client>"u")throw Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;let{topic:r}=e;r===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;let{params:r,topic:i}=e;if(i!==(null==(t=this.session)?void 0:t.topic))return;let{event:s}=r;if("accountsChanged"===s.name){let e=s.data;e&&i9(e)&&this.events.emit("accountsChanged",e.map(cP))}else if("chainChanged"===s.name){let e=r.chainId,t=r.event.data,i=i1(e),s=cS(e)!==cS(t)?`${i}:${cS(t)}`:e;this.onChainChanged(s)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var r,i;if(e!==(null==(r=this.session)?void 0:r.topic))return;let{namespaces:s}=t,n=null==(i=this.client)?void 0:i.session.get(e);this.session=la(ld({},n),lc({namespaces:s})),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",la(ld({},i4("USER_DISCONNECTED")),lc({data:e.topic}))))}),this.on(a3,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[a8]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){let{namespaces:t={},optionalNamespaces:r={},sessionProperties:i,scopedProperties:s}=e;this.optionalNamespaces=cI(t,r),this.sessionProperties=i,this.scopedProperties=s}validateChain(e){let[t,r]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,r];if(t&&!Object.keys(this.namespaces||{}).map(e=>i1(e)).includes(t))throw Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&r)return[t,r];let i=i1(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){let[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;let[r,i]=this.validateChain(e);if(!i)return;this.updateNamespaceChain(r,i),this.events.emit("chainChanged",i);let s=this.getProvider(r).getDefaultChain();t||this.getProvider(r).setDefaultChain(i),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:s,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:t,newChainId:r}){var i,s;try{if(t===r)return;let n=null==(s=null==(i=this.session)?void 0:i.namespaces[e])?void 0:s.accounts;if(!n)return;let o=n.filter(e=>e.includes(`${r}:`)).map(cP);if(!i9(o))return;this.events.emit("accountsChanged",o)}catch(e){this.logger.warn("Failed to emit accountsChanged on chain change",e)}}updateNamespaceChain(e,t){if(!this.namespaces)return;let r=this.namespaces[e]?e:`${e}:${t}`;this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=t):this.namespaces[r]={chains:[],methods:[],events:[],defaultChain:t}}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var r;let i=(null==(r=this.session)?void 0:r.topic)||"";await this.client.core.storage.setItem(`${a1}/${e}${i}`,t)}async getFromStore(e){var t;let r=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${a1}/${e}${r}`)}async deleteFromStore(e){var t;let r=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${a1}/${e}${r}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;for(let e of(await this.client.core.storage.getKeys()))e.startsWith(a1)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}let ly=["eth_sendTransaction","personal_sign"],lm=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],lb=["chainChanged","accountsChanged"],lw=["chainChanged","accountsChanged","message","disconnect","connect"],lv=async()=>{let{createAppKit:e}=await r.e(6390).then(r.bind(r,16390));return e};var lE=Object.defineProperty,lI=Object.defineProperties,lx=Object.getOwnPropertyDescriptors,lP=Object.getOwnPropertySymbols,lO=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,l_=(e,t,r)=>t in e?lE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lA=(e,t)=>
10{for(var r in t||(t={}))lO.call(t,r)&&l_(e,r,t[r]);if(lP)for(var r of lP(t))lS.call(t,r)&&l_(e,r,t[r]);return e},lR=(e,t,r)=>l_(e,"symbol"!=typeof t?t+"":t,r);function lC(e){return Number(e[0].split(":")[1])}function lT(e){return`0x${e.toString(16)}`}class lN{constructor(){lR(this,"events",new c.EventEmitter),lR(this,"namespace","eip155"),lR(this,"accounts",[]),lR(this,"signer"),lR(this,"chainId",1),lR(this,"modal"),lR(this,"rpc"),lR(this,"STORAGE_KEY","wc@2:ethereum_provider:"),lR(this,"on",(e,t)=>(this.events.on(e,t),this)),lR(this,"once",(e,t)=>(this.events.once(e,t),this)),lR(this,"removeListener",(e,t)=>(this.events.removeListener(e,t),this)),lR(this,"off",(e,t)=>(this.events.off(e,t),this)),lR(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){let t=new lN;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,r){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),r)}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){var t;if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);let{required:r,optional:i}=function(e){let{chains:t,optionalChains:r,methods:i,optionalMethods:s,events:n,optionalEvents:o,rpcMap:a}=e;if(!i9(t))throw Error("Invalid chains");let c={chains:t,methods:i||ly,events:n||lb,rpcMap:lA({},t.length?{[lC(t)]:a[lC(t)]}:{})},l=n?.filter(e=>!lb.includes(e)),h=i?.filter(e=>!ly.includes(e));if(!r&&!o&&!s&&!(null!=l&&l.length)&&!(null!=h&&h.length))return{required:t.length?c:void 0};let u={chains:[...new Set(l?.length&&h?.length||!r?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(null!=s&&s.length?s:lm))],events:[...new Set(c.events.concat(null!=o&&o.length?o:lw))],rpcMap:a};return{required:t.length?c:void 0,optional:r.length?u:void 0}}(this.rpc);try{let t=await new Promise(async(t,s)=>{var n,o;let a,c;this.rpc.showQrModal&&(null==(n=this.modal)||n.open(),null==(o=this.modal)||o.subscribeState(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),s(Error("Connection request reset. Please try again.")))}));let l=null!=e&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect((a=lA({namespaces:lA({},r&&{[this.namespace]:r})},i&&{optionalNamespaces:{[this.namespace]:i}}),c={pairingTopic:e?.pairingTopic,scopedProperties:l},lI(a,lx(c)))).then(e=>{t(e)}).catch(e=>{var t;null==(t=this.modal)||t.showErrorMessage("Unable to connect"),s(Error(e.message))})});if(!t)return;let s=ep(t.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:lT(this.chainId)})}catch(e){throw this.signer.logger.error(e),e}finally{null==(t=this.modal)||t.close()}}async authenticate(e,t){var r;if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{let r=await new Promise(async(r,i)=>{var s,n;let o,a;this.rpc.showQrModal&&(null==(s=this.modal)||s.open(),null==(n=this.modal)||n.subscribeState(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),i(Error("Connection request reset. Please try again.")))})),await this.signer.authenticate((o=lA({},e),a={chains:this.rpc.chains},lI(o,lx(a))),t).then(e=>{r(e)}).catch(e=>{var t;null==(t=this.modal)||t.showErrorMessage("Unable to connect"),i(Error(e.message))})}),i=r.session;if(i){let e=ep(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:e),this.setAccounts(e),this.events.emit("connect",{chainId:lT(this.chainId)})}return r}catch(e){throw this.signer.logger.error(e),e}finally{null==(r=this.modal)||r.close()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{let{params:t}=e,{event:r}=t;
10"accountsChanged"===r.name?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===r.name?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{let t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",lT(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",lI(lA({},i4("USER_DISCONNECTED")),lx({data:e.topic,name:"USER_DISCONNECTED"})))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){let t=e.filter(e=>this.isCompatibleChainId(e)).map(e=>this.parseChainId(e));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",lT(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){let t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){let[t,r,i]=e.split(":");return{chainId:`${t}:${r}`,address:i}}setAccounts(e){this.accounts=e.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,r;let i=null!=(t=e?.chains)?t:[],s=null!=(r=e?.optionalChains)?r:[],n=i.concat(s);if(!n.length)throw Error("No chains specified in either `chains` or `optionalChains`");let o=i.length?e?.methods||ly:[],a=i.length?e?.events||lb:[],c=e?.optionalMethods||[],l=e?.optionalEvents||[],h=e?.rpcMap||this.buildRpcMap(n,e.projectId),u=e?.qrModalOptions||void 0;return{chains:i?.map(e=>this.formatChainId(e)),optionalChains:s.map(e=>this.formatChainId(e)),methods:o,events:a,optionalMethods:c,optionalEvents:l,rpcMap:h,showQrModal:!!(null!=e&&e.showQrModal),qrModalOptions:u,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){let r={};return e.forEach(e=>{r[e]=this.getRpcUrl(e,t)}),r}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?lC(this.rpc.chains):lC(this.rpc.optionalChains),this.signer=await lg.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{let t,r,i,s,n=await lv(),{convertWCMToAppKitOptions:o}=await Promise.resolve().then(function(){return lV}),a=o((t=lA({},this.rpc.qrModalOptions),r={chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId},lI(t,lx(r))));if(!a.networks.length)throw Error("No networks found for WalletConnect\xb7");e=n((i=lA({},a),s={universalProvider:this.signer,manualWCControl:!0},lI(i,lx(s))))}catch(e){throw console.warn(e),Error("To use QR modal, please install @reown/appkit package")}if(e)try{this.modal=e}catch(e){throw this.signer.logger.error(e),Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;let{chains:t,optionalChains:r,rpcMap:i}=e;t&&i9(t)&&(this.rpc.chains=t.map(e=>this.formatChainId(e)),t.forEach(e=>{this.rpc.rpcMap[e]=i?.[e]||this.getRpcUrl(e)})),r&&i9(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=r?.map(e=>this.formatChainId(e)),r.forEach(e=>{this.rpc.rpcMap[e]=i?.[e]||this.getRpcUrl(e)}))}getRpcUrl(e,t){var r;return(null==(r=this.rpc.rpcMap)?void 0:r[e])||`https://rpc.walletconnect.org/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{let e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map(e=>this.parseAccount(e))}}let lj=lN;var lU=Object.defineProperty,lq=Object.defineProperties,lk=Object.getOwnPropertyDescriptors,lD=Object.getOwnPropertySymbols,lL=Object.prototype.hasOwnProperty,lB=Object.prototype.propertyIsEnumerable,lM=(e,t,r)=>t in e?lU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l$=(e,t)=>{for(var r in t||(t={}))lL.call(t,r)&&lM(e,r,t[r]);if(lD)for(var r of lD(t))lB.call(t,r)&&lM(e,r,t[r]);return e};let lz=e=>{let[t,r]=e.split(":");return lH({id:r,caipNetworkId:e,chainNamespace:t,name:"",nativeCurrency:{name:"",symbol
10:"",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}})};function lH(e){return l$({formatters:void 0,fees:void 0,serializers:void 0},e)}var lV=Object.freeze({__proto__:null,convertWCMToAppKitOptions:function(e){var t,r,i,s,n,o,a;let c=null==(t=e.chains)?void 0:t.map(lz).filter(Boolean);if(0===c.length)throw Error("At least one chain must be specified");let l=c.find(t=>{var r;return t.id===(null==(r=e.defaultChain)?void 0:r.id)}),h={projectId:e.projectId,networks:c,themeMode:e.themeMode,themeVariables:function(e){if(e)return{"--w3m-font-family":e["--wcm-font-family"],"--w3m-accent":e["--wcm-accent-color"],"--w3m-color-mix":e["--wcm-background-color"],"--w3m-z-index":e["--wcm-z-index"]?Number(e["--wcm-z-index"]):void 0,"--w3m-qr-color":e["--wcm-accent-color"],"--w3m-font-size-master":e["--wcm-text-medium-regular-size"],"--w3m-border-radius-master":e["--wcm-container-border-radius"],"--w3m-color-mix-strength":0}}(e.themeVariables),chainImages:e.chainImages,connectorImages:e.walletImages,defaultNetwork:l,metadata:lq(l$({},e.metadata),lk({name:(null==(r=e.metadata)?void 0:r.name)||"WalletConnect",description:(null==(i=e.metadata)?void 0:i.description)||"Connect to WalletConnect-compatible wallets",url:(null==(s=e.metadata)?void 0:s.url)||"https://walletconnect.org",icons:(null==(n=e.metadata)?void 0:n.icons)||["https://walletconnect.org/walletconnect-logo.png"]})),showWallets:!0,featuredWalletIds:"NONE"===e.explorerRecommendedWalletIds?[]:Array.isArray(e.explorerRecommendedWalletIds)?e.explorerRecommendedWalletIds:[],excludeWalletIds:"ALL"===e.explorerExcludedWalletIds?[]:Array.isArray(e.explorerExcludedWalletIds)?e.explorerExcludedWalletIds:[],enableEIP6963:!1,enableInjected:!1,enableCoinbase:!0,enableWalletConnect:!0,features:{email:!1,socials:!1}};if(null!=(o=e.mobileWallets)&&o.length||null!=(a=e.desktopWallets)&&a.length){let t=[...(e.mobileWallets||[]).map(e=>({id:e.id,name:e.name,links:e.links})),...(e.desktopWallets||[]).map(e=>({id:e.id,name:e.name,links:{native:e.links.native,universal:e.links.universal}}))],r=[...h.featuredWalletIds||[],...h.excludeWalletIds||[]],i=t.filter(e=>!r.includes(e.id));i.length&&(h.customWallets=i)}return h},defineChain:lH})},69319:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise(function(r,i){var s,n,o;function a(r){e.removeListener(t,c),i(r)}function c(){"function"==typeof e.removeListener&&e.removeListener("error",a),r([].slice.call(arguments))}g(e,t,c,{once:!0}),"error"!==t&&(s=e,n=a,o={once:!0},"function"==typeof s.on&&g(s,"error",n,o))})},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function l(e,t,r,i){if(a(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),o=n[t]),void 0===o)o=n[t]=r,++e._eventsCount;else if("function"==typeof o?o=n[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var s,n,o,l=Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,console&&console.warn&&console.warn(l)}return e}function h(){if(!this.fired)return(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0==arguments.length)?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=h.bind(i);return s.listener=r,i.wrapFn=s,s}function p(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):f(s,s.length)}function d(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=Array(t),i=0;i<t;++i)r[i]=e[i];return r}
10function g(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else if("function"==typeof e.addEventListener)e.addEventListener(t,function s(n){i.once&&e.removeEventListener(t,s),r(n)});else throw TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||s(e))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),n.init=function(){(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return c(this)},n.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,n=this._events;if(void 0!==n)s=s&&void 0===n.error;else if(!s)return!1;if(s){if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var o,a=Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else for(var l=c.length,h=f(c,l),r=0;r<l;++r)i(h[r],this,t);return!0},n.prototype.addListener=function(e,t){return l(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return l(this,e,t,!0)},n.prototype.once=function(e,t){return a(t),this.on(e,u(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,u(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,i,s,n,o;if(a(t),void 0===(i=this._events)||void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){o=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0==arguments.length){var s,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(s=n[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},n.prototype.listeners=function(e){return p(this,e,!0)},n.prototype.rawListeners=function(e){return p(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},n.prototype.listenerCount=d,n.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},70910:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__assign:()=>n,__asyncDelegator:()=>v,__asyncGenerator:()=>w,__asyncValues:()=>E,__await:()=>b,__awaiter:()=>h,__classPrivateFieldGet:()=>O,__classPrivateFieldSet:()=>S,__createBinding:()=>p,__decorate:()=>a,__exportStar:()=>d,__extends:()=>s,__generator:()=>u,__importDefault:()=>P,__importStar:()=>
10x,__makeTemplateObject:()=>I,__metadata:()=>l,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>y,__spreadArrays:()=>m,__values:()=>f});var i=function(e,t){return(i=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function s(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var n=function(){return(n=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)0>t.indexOf(i[s])&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]]);return r}function a(e,t,r,i){var s,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,r,o):s(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function c(e,t){return function(r,i){t(r,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function u(e,t){var r,i,s,n,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){var c=[n,a];if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(s=2&c[0]?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[2&c[0],s.value]),c[0]){case 0:case 1:s=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,i=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!s||c[1]>s[0]&&c[1]<s[3])){o.label=c[1];break}if(6===c[0]&&o.label<s[1]){o.label=s[1],s=c;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(c);break}s[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],i=0}finally{r=s=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function p(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}function d(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||(t[r]=e[r])}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function m(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var i=Array(e),s=0,t=0;t<r;t++)for(var n=arguments[t],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function w(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,s=r.apply(e,t||[]),n=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){s[e]&&(i[e]=function(t){return new Promise(function(r,i){n.push([e,t,r,i])>1||a(e,t)})})}function a(e,t){try{var r;(r=s[e](t)).value instanceof b?Promise.resolve(r.value.v).then(c,l):h(n[0][2],r)}catch(e){h(n[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function h(e,t){e(t),n.shift(),n.length&&a(n[0][0],n[0][1])}}function v(e){var t,r;return t={},i("next"),i("throw",function(e){throw e}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,s){t[i]=e[i]?function(t){return(r=!r)?{value:b(e[i](t)),done:"return"===i}:s?s(t):t}:s}}function E(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=f(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise(function(i,s){var n,o,a;n=i,o=s,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){n({value:e,done:a})},o)})}}}function I(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}
10function x(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function P(e){return e&&e.__esModule?e:{default:e}}function O(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}function S(e,t,r){if(!t.has(e))throw TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},71726:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(70910);i.__exportStar(r(41044),t),i.__exportStar(r(57981),t),i.__exportStar(r(96304),t),i.__exportStar(r(52892),t)},78356:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});let i=function(e){if(e.length>=255)throw TypeError("Alphabet too long");let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){let i=e.charAt(r),s=i.charCodeAt(0);if(255!==t[s])throw TypeError(i+" is ambiguous");t[s]=r}let r=e.length,i=e.charAt(0),s=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function o(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,o=0,a=0;for(;e[n]===i;)o++,n++;let c=(e.length-n)*s+1>>>0,l=new Uint8Array(c);for(;n<e.length;){let i=e.charCodeAt(n);if(i>255)return;let s=t[i];if(255===s)return;let o=0;for(let e=c-1;(0!==s||o<a)&&-1!==e;e--,o++)s+=r*l[e]>>>0,l[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw Error("Non-zero carry");a=o,n++}let h=c-a;for(;h!==c&&0===l[h];)h++;let u=new Uint8Array(o+(c-h)),p=o;for(;h!==c;)u[p++]=l[h++];return u}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";let s=0,o=0,a=0,c=t.length;for(;a!==c&&0===t[a];)a++,s++;let l=(c-a)*n+1>>>0,h=new Uint8Array(l);for(;a!==c;){let e=t[a],i=0;for(let t=l-1;(0!==e||i<o)&&-1!==t;t--,i++)e+=256*h[t]>>>0,h[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw Error("Non-zero carry");o=i,a++}let u=l-o;for(;u!==l&&0===h[u];)u++;let p=i.repeat(s);for(;u<l;++u)p+=e.charAt(h[u]);return p},decodeUnsafe:o,decode:function(e){let t=o(e);if(t)return t;throw Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},79195:(e,t,r)=>{"use strict";function i(){return(null===r.g||void 0===r.g?void 0:r.g.crypto)||(null===r.g||void 0===r.g?void 0:r.g.msCrypto)||{}}function s(){let e=i();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=i,t.getSubtleCrypto=s,t.isBrowserCryptoAvailable=function(){return!!i()&&!!s()}},80706:(e,t,r)=>{"use strict";r.d(t,{ER:()=>n,Im:()=>c,dZ:()=>l,eX:()=>o,e_:()=>a});var i=r(46665),s=r(85874);
10function n(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function o(e=6){return BigInt(n(e))}function a(e,t,r){return{id:r||n(),jsonrpc:"2.0",method:e,params:t}}function c(e,t){return{id:e,jsonrpc:"2.0",result:t}}function l(e,t,r){var n,o;return{id:e,jsonrpc:"2.0",error:(n=t,o=r,void 0===n?(0,i.vG)(s.zR):("string"==typeof n&&(n=Object.assign(Object.assign({},(0,i.vG)(s.fO)),{message:n})),void 0!==o&&(n.data=o),(0,i.mE)(n.code)&&(n=(0,i.rI)(n.code)),n))}}},82521:(e,t)=>{"use strict";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=5*t.ONE_MINUTE,t.TEN_MINUTES=10*t.ONE_MINUTE,t.THIRTY_MINUTES=30*t.ONE_MINUTE,t.SIXTY_MINUTES=60*t.ONE_MINUTE,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=3*t.ONE_HOUR,t.SIX_HOURS=6*t.ONE_HOUR,t.TWELVE_HOURS=12*t.ONE_HOUR,t.TWENTY_FOUR_HOURS=24*t.ONE_HOUR,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=3*t.ONE_DAY,t.FIVE_DAYS=5*t.ONE_DAY,t.SEVEN_DAYS=7*t.ONE_DAY,t.THIRTY_DAYS=30*t.ONE_DAY,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=2*t.ONE_WEEK,t.THREE_WEEKS=3*t.ONE_WEEK,t.FOUR_WEEKS=4*t.ONE_WEEK,t.ONE_YEAR=365*t.ONE_DAY},83145:(e,t,r)=>{"use strict";var i=r(65364);function s(){return"u"<typeof document&&"u">typeof navigator&&"ReactNative"===navigator.product}function n(){return void 0!==i&&void 0!==i.versions&&void 0!==i.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=s,t.isNode=n,t.isBrowser=function(){return!s()&&!n()}},85874:(e,t,r)=>{"use strict";r.d(t,{Uf:()=>o,XW:()=>a,fO:()=>s,jf:()=>n,zR:()=>i});let i="INTERNAL_ERROR",s="SERVER_ERROR",n=[-32700,-32600,-32601,-32602,-32603],o={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[i]:{code:-32603,message:"Internal error"},[s]:{code:-32e3,message:"Server error"}},a=s},91123:(e,t,r)=>{"use strict";let i=r(49499);e.exports=n;let s=function(){function e(e){return void 0!==e&&e}try{if("u">typeof globalThis)return globalThis;return Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{};function n(e){var t,r;(e=e||{}).browser=e.browser||{};let i=e.browser.transmit;if(i&&"function"!=typeof i.send)throw Error("pino: transmit option must have a send function");let h=e.browser.write||s;e.browser.write&&(e.browser.asObject=!0);let u=e.serializers||{},g=(t=e.browser.serialize,Array.isArray(t)?t.filter(function(e){return"!stdSerializers.err"!==e}):!0===t&&Object.keys(u)),y=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(y=!1),"function"==typeof h&&(h.error=h.fatal=h.warn=h.info=h.debug=h.trace=h),!1===e.enabled&&(e.level="silent");let m=e.level||"info",b=Object.create(h);b.log||(b.log=p),Object.defineProperty(b,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(b,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,o(w,b,"error","log"),o(w,b,"fatal","error"),o(w,b,"warn","error"),o(w,b,"info","log"),o(w,b,"debug","log"),o(w,b,"trace","log")}});let w={transmit:i,serialize:g,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:"function"==typeof(r=e).timestamp?r.timestamp:!1===r.timestamp?d:f};return b.levels=n.levels,b.level=m,b.setMaxListeners=b.getMaxListeners=b.emit=b.addListener=b.on=b.prependListener=b.once=b.prepe
10ndOnceListener=b.removeListener=b.removeAllListeners=b.listeners=b.listenerCount=b.eventNames=b.write=b.flush=p,b.serializers=u,b._serialize=g,b._stdErrSerialize=y,b.child=function(t,r){if(!t)throw Error("missing bindings for child Pino");r=r||{},g&&t.serializers&&(r.serializers=t.serializers);let s=r.serializers;if(g&&s){var n=Object.assign({},u,s),o=!0===e.browser.serialize?Object.keys(n):g;delete t.serializers,a([t],o,n,this._stdErrSerialize)}function h(e){this._childLevel=(0|e._childLevel)+1,this.error=c(e,t,"error"),this.fatal=c(e,t,"fatal"),this.warn=c(e,t,"warn"),this.info=c(e,t,"info"),this.debug=c(e,t,"debug"),this.trace=c(e,t,"trace"),n&&(this.serializers=n,this._serialize=o),i&&(this._logEvent=l([].concat(e._logEvent.bindings,t)))}return h.prototype=this,new h(this)},i&&(b._logEvent=l()),b}function o(e,t,r,o){let c=Object.getPrototypeOf(t);t[r]=t.levelVal>t.levels.values[r]?p:c[r]?c[r]:s[r]||s[o]||p,function(e,t,r){if(e.transmit||t[r]!==p){var o;t[r]=(o=t[r],function(){let c=e.timestamp(),h=Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===s?s:this;for(var p,d,f,g=0;g<h.length;g++)h[g]=arguments[g];if(e.serialize&&!e.asObject&&a(h,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?o.call(u,function(e,t,r,s){e._serialize&&a(r,e._serialize,e.serializers,e._stdErrSerialize);let o=r.slice(),c=o[0],l={};s&&(l.time=s),l.level=n.levels.values[t];let h=(0|e._childLevel)+1;if(h<1&&(h=1),null!==c&&"object"==typeof c){for(;h--&&"object"==typeof o[0];)Object.assign(l,o.shift());c=o.length?i(o.shift(),o):void 0}else"string"==typeof c&&(c=i(o.shift(),o));return void 0!==c&&(l.msg=c),l}(this,r,h,c)):o.apply(u,h),e.transmit){let i,s,o,u,g,y,m=e.transmit.level||t.level,b=n.levels.values[m],w=n.levels.values[r];if(w<b)return;p=this,d={ts:c,methodLevel:r,methodValue:w,transmitLevel:m,transmitValue:n.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},f=h,i=d.send,s=d.ts,o=d.methodLevel,u=d.methodValue,g=d.val,y=p._logEvent.bindings,a(f,p._serialize||Object.keys(p.serializers),p.serializers,void 0===p._stdErrSerialize||p._stdErrSerialize),p._logEvent.ts=s,p._logEvent.messages=f.filter(function(e){return -1===y.indexOf(e)}),p._logEvent.level.label=o,p._logEvent.level.value=u,i(o,p._logEvent,g),p._logEvent=l(y)}})}}(e,t,r)}function a(e,t,r,i){for(let s in e)if(i&&e[s]instanceof Error)e[s]=n.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s]))for(let i in e[s])t&&t.indexOf(i)>-1&&i in r&&(e[s][i]=r[i](e[s][i]))}function c(e,t,r){return function(){let i=Array(1+arguments.length);i[0]=t;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return e[r].apply(this,i)}}function l(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function h(){return{}}function u(e){return e}function p(){}function d(){return!1}function f(){return Date.now()}n.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},n.stdSerializers={mapHttpRequest:h,mapHttpResponse:h,wrapRequestSerializer:u,wrapResponseSerializer:u,wrapErrorSerializer:u,req:h,res:h,err:function(e){let t={type:e.constructor.name,msg:e.message,stack:e.stack};for(let r in e)void 0===t[r]&&(t[r]=e[r]);return t}},n.stdTimeFunctions=Object.assign({},{nullTime:d,epochTime:f,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},94135:(e,t,r)=>{"use strict";r.d(t,{xW:()=>b,sH:()=>eA,dI:()=>eR});var i={};r.r(i),r.d(i,{identity:()=>R});var s={};r.r(s),r.d(s,{base2:()=>C});var n={};r.r(n),r.d(n,{base8:()=>T});var o={};r.r(o),r.d(o,{base10:()=>N});var a={};r.r(a),r.d(a,{base16:()=>j,base16upper:()=>U});var c={};r.r(c),r.d(c,{base32:()=>q,base32hex:()=>B,base32hexpad:()=>$,base32hexpadupper:()=>z,base32hexupper:()=>M,base32pad:()=>D,base32padupper:()=>L,base32upper:()=>k,base32z:()=>H});var l={};r.r(l),r.d(l,{base36:()=>V,base36upper:()=>F});var h={};r.r(h),r.d(h,{base58btc:()=>K,base58flickr:()=>W});var u={};r.r(u),r.d(u,{base64:()=>J,base64pad:()=>G,base64url:()=>Y,base64urlpad:()=>Z});var p={};r.r(p),r.d(p,{base256emoji:()=>et});var d={};r.r(d),r.d(d,{sha256:()=>eh,sha512:()=>eu});var f={};r.r(f),r.d(f,{identity:()=>ep});var g={};r.r(g),r.d(g,{code:()=>ef,decode:()=>ey,encode:()=>eg,name:()=>ed});var y={};function m(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}function b(e,t){t||(t=e.reduce((e,t)=>
10e+t.length,0));let r=m(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}r.r(y),r.d(y,{code:()=>ev,decode:()=>eI,encode:()=>eE,name:()=>ew});let w=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==r[o])throw TypeError(n+" is ambiguous");r[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var i=0,s=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var u=0,p=n-1;(0!==h||u<s)&&-1!==p;p--,u++)h+=a*o[p]>>>0,o[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");s=u,t++}if(" "!==e[t]){for(var d=n-s;d!==n&&0===o[d];)d++;for(var f=new Uint8Array(i+(n-d)),g=i;d!==n;)f[g++]=o[d++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,s=0,n=t.length;s!==n&&0===t[s];)s++,r++;for(var o=(n-s)*h+1>>>0,l=new Uint8Array(o);s!==n;){for(var u=t[s],p=0,d=o-1;(0!==u||p<i)&&-1!==d;d--,p++)u+=256*l[d]>>>0,l[d]=u%a>>>0,u=u/a>>>0;if(0!==u)throw Error("Non-zero carry");i=p,s++}for(var f=o-i;f!==o&&0===l[f];)f++;for(var g=c.repeat(r);f<o;++f)g+=e.charAt(l[f]);return g},decodeUnsafe:u,decode:function(e){var r=u(e);if(r)return r;throw Error(`Non-${t} character`)}}};new Uint8Array(0);let v=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unknown type, must be binary type")};class E{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class I{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return P(this,e)}}class x{constructor(e){this.decoders=e}or(e){return P(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let P=(e,t)=>new x({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});
10class O{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new E(e,t,r),this.decoder=new I(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let S=({name:e,prefix:t,encode:r,decode:i})=>new O(e,t,r,i),_=({prefix:e,name:t,alphabet:r})=>{let{encode:i,decode:s}=w(r,t);return S({prefix:e,name:t,encode:i,decode:e=>v(s(e))})},A=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>S({prefix:t,name:e,encode:e=>((e,t,r)=>{let i="="===t[t.length-1],s=(1<<r)-1,n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>r;)o-=r,n+=t[s&a>>o];if(o&&(n+=t[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n})(e,i,r),decode:t=>((e,t,r,i)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*r/8|0),a=0,c=0,l=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${i} character`);c=c<<r|n,(a+=r)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw SyntaxError("Unexpected end of data");return o})(t,i,r,e)}),R=S({prefix:"\0",name:"identity",encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)}),C=A({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),T=A({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),N=_({prefix:"9",name:"base10",alphabet:"0123456789"}),j=A({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U=A({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),q=A({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),k=A({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),D=A({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),L=A({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),B=A({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),M=A({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$=A({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),z=A({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),H=A({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),V=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),F=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),K=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),W=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),J=A({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),G=A({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Y=A({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Z=A({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Q=Array.from("\uD83D\uDE80\uD83E\uDE90â\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09â\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02â¤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09âº\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9Eââ¨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2Dâ£\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33â\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13ââ
\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6â\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90â¹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20â\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2Bâ½\uD83E\uDD19â\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81â¡\uD83C\uDF1E\uD83C\uDF88ââ\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2Câ\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74â¶â¡â\uD83D\uDC8E\uD83D\uDCB8â¬\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7Aâ \uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37â\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51â\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),X=Q.reduce((e,t,r)=>(e[r]=t,e),[]),ee=Q.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]),et=S({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>
10e+=X[t],"")},decode:function(e){let t=[];for(let r of e){let e=ee[r.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});function er(e,t,r){t=t||[];for(var i=r=r||0;e>=0x80000000;)t[r++]=255&e|128,e/=128;for(;-128&e;)t[r++]=255&e|128,e>>>=7;return t[r]=0|e,er.bytes=r-i+1,t}let ei=function(e){return e<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:e<0x800000000?5:e<0x40000000000?6:e<0x2000000000000?7:e<0x100000000000000?8:e<0x8000000000000000?9:10},es=(e,t,r=0)=>(er(e,t,r),t),en=(e,t)=>{let r=t.byteLength,i=ei(e),s=i+ei(r),n=new Uint8Array(s+r);return es(e,n,0),es(r,n,i),n.set(t,s),new eo(e,r,t,n)};class eo{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}let ea=({name:e,code:t,encode:r})=>new ec(e,t,r);class ec{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?en(this.code,t):t.then(e=>en(this.code,e))}throw Error("Unknown type, must be binary type")}}let el=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),eh=ea({name:"sha2-256",code:18,encode:el("SHA-256")}),eu=ea({name:"sha2-512",code:19,encode:el("SHA-512")}),ep={code:0,name:"identity",encode:v,digest:e=>en(0,v(e))},ed="raw",ef=85,eg=e=>v(e),ey=e=>v(e),em=new TextEncoder,eb=new TextDecoder,ew="json",ev=512,eE=e=>em.encode(JSON.stringify(e)),eI=e=>JSON.parse(eb.decode(e));Symbol.for("nodejs.util.inspect.custom"),Symbol.for("@ipld/js-cid/CID");let ex={...i,...s,...n,...o,...a,...c,...l,...h,...u,...p};function eP(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}({...d,...f});let eO=eP("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),eS=eP("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{let t=m((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),e_={utf8:eO,"utf-8":eO,hex:ex.base16,latin1:eS,ascii:eS,binary:eS,...ex};function eA(e,t="utf8"){let r=e_[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e,"utf8"):r.decoder.decode(`${r.prefix}${e}`)}function eR(e,t="utf8"){let r=e_[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}},95502:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__assign:()=>n,__asyncDelegator:()=>v,__asyncGenerator:()=>w,__asyncValues:()=>E,__await:()=>b,__awaiter:()=>h,__classPrivateFieldGet:()=>O,__classPrivateFieldSet:()=>S,__createBinding:()=>p,__decorate:()=>a,__exportStar:()=>d,__extends:()=>s,__generator:()=>u,__importDefault:()=>P,__importStar:()=>
10x,__makeTemplateObject:()=>I,__metadata:()=>l,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>y,__spreadArrays:()=>m,__values:()=>f});var i=function(e,t){return(i=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function s(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var n=function(){return(n=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)0>t.indexOf(i[s])&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]]);return r}function a(e,t,r,i){var s,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,r,o):s(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function c(e,t){return function(r,i){t(r,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function u(e,t){var r,i,s,n,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){var c=[n,a];if(r)throw TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(s=2&c[0]?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[2&c[0],s.value]),c[0]){case 0:case 1:s=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,i=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!s||c[1]>s[0]&&c[1]<s[3])){o.label=c[1];break}if(6===c[0]&&o.label<s[1]){o.label=s[1],s=c;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(c);break}s[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],i=0}finally{r=s=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function p(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}function d(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||(t[r]=e[r])}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function m(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var i=Array(e),s=0,t=0;t<r;t++)for(var n=arguments[t],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function w(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,s=r.apply(e,t||[]),n=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){s[e]&&(i[e]=function(t){return new Promise(function(r,i){n.push([e,t,r,i])>1||a(e,t)})})}function a(e,t){try{var r;(r=s[e](t)).value instanceof b?Promise.resolve(r.value.v).then(c,l):h(n[0][2],r)}catch(e){h(n[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function h(e,t){e(t),n.shift(),n.length&&a(n[0][0],n[0][1])}}function v(e){var t,r;return t={},i("next"),i("throw",function(e){throw e}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,s){t[i]=e[i]?function(t){return(r=!r)?{value:b(e[i](t)),done:"return"===i}:s?s(t):t}:s}}function E(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=f(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise(function(i,s){var n,o,a;n=i,o=s,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){n({value:e,done:a})},o)})}}}function I(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}
10function x(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function P(e){return e&&e.__esModule?e:{default:e}}function O(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}function S(e,t,r){if(!t.has(e))throw TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},96304:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(70910).__exportStar(r(46267),t)},96346:(e,t,r)=>{"use strict";function i(e,t){let r=function(e){let t=e.match(RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==r&&new RegExp(t).test(r)}function s(e){return i(e,"^https?:")}function n(e){return i(e,"^wss?:")}function o(e){return RegExp("wss?://localhost(:d{2,5})?").test(e)}r.d(t,{A1:()=>n,q$:()=>s,z:()=>o})},96794:(e,t,r)=>{"use strict";r.d(t,{CG:()=>i});let i={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}}},97638:(e,t,r)=>{"use strict";r.d(t,{VH:()=>l,li:()=>c});var i=r(69319),s=r(71726),n=r(8012);class o extends n.H{constructor(e){super()}}let a=s.FIVE_SECONDS,c={pulse:"heartbeat_pulse"};class l extends o{constructor(e){super(e),this.events=new i.EventEmitter,this.interval=a,this.interval=e?.interval||a}static async init(e){let t=new l(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,s.toMiliseconds)(this.interval))}pulse(){this.events.emit(c.pulse)}}},98534:(e,t)=>{"use strict";function r(e){let t;return"u">typeof window&&void 0!==window[e]&&(t=window[e]),t}function i(e){let t=r(e);if(!t)throw Error(`${e} is not defined in Window`);return t}Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalStorage=t.getLocalStorageOrThrow=t.getCrypto=t.getCryptoOrThrow=t.getLocation=t.getLocationOrThrow=t.getNavigator=t.getNavigatorOrThrow=t.getDocument=t.getDocumentOrThrow=t.getFromWindowOrThrow=t.getFromWindow=void 0,t.getFromWindow=r,t.getFromWindowOrThrow=i,t.getDocumentOrThrow=function(){return i("document")},t.getDocument=function(){return r("document")},t.getNavigatorOrThrow=function(){return i("navigator")},t.getNavigator=function(){return r("navigator")},t.getLocationOrThrow=function(){return i("location")},t.getLocation=function(){return r("location")},t.getCryptoOrThrow=function(){return i("crypto")},t.getCrypto=function(){return r("crypto")},t.getLocalStorageOrThrow=function(){return i("localStorage")},t.getLocalStorage=function(){return r("localStorage")}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.