@dodoex/wallet-web3 0.0.64 → 0.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{alchemy-provider-5870b6fa-457cd6bb.js → alchemy-provider-5870b6fa-66fa57c4.js} +1 -1
- package/dist/{alchemy-websocket-provider-213da986-746c5eca.js → alchemy-websocket-provider-213da986-81f5908b.js} +1 -1
- package/dist/{blocto-ee2a838e.js → blocto-a0fb786c.js} +1 -1
- package/dist/{ccip-c55250b6.js → ccip-8057d290.js} +1 -1
- package/dist/cjs/{alchemy-provider-5870b6fa-1de644f2.cjs → alchemy-provider-5870b6fa-ae5f424d.cjs} +1 -1
- package/dist/cjs/{alchemy-websocket-provider-213da986-e220e8bd.cjs → alchemy-websocket-provider-213da986-d62eca48.cjs} +1 -1
- package/dist/cjs/{blocto-0a1f8c82.cjs → blocto-0d2f6547.cjs} +1 -1
- package/dist/cjs/{ccip-6d742628.cjs → ccip-32d25bb9.cjs} +1 -1
- package/dist/cjs/{draggabilly-8dcddcae.cjs → draggabilly-9a233d31.cjs} +1 -1
- package/dist/cjs/id-cd1c0250.cjs +1 -0
- package/dist/cjs/{index-fed98538.cjs → index-0d072f8e.cjs} +1 -1
- package/dist/cjs/{index-fe9fcb08.cjs → index-28ccfd4f.cjs} +1 -1
- package/dist/cjs/{index-91f65724.cjs → index-42d4f376.cjs} +3 -3
- package/dist/cjs/{index-b0f51d7d.cjs → index-51df874d.cjs} +1 -1
- package/dist/cjs/{index-3d1bc02e.cjs → index-530ea415.cjs} +1 -1
- package/dist/cjs/{index-78ce40b2.cjs → index-702527b2.cjs} +2 -2
- package/dist/cjs/{index-dcff3fbf.cjs → index-99530e6c.cjs} +1 -1
- package/dist/cjs/{index-b10f5546.cjs → index-a6e52f1a.cjs} +2 -2
- package/dist/cjs/{index-db3fa985.cjs → index-c17746ed.cjs} +1 -1
- package/dist/cjs/{index-6cb4d019.cjs → index-e6e26ad5.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-75a30b77.cjs → index.es-d4262962.cjs} +1 -1
- package/dist/cjs/{interface-1412cfee.cjs → interface-e004907f.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-45edc54c.cjs → lib-typedarrays-dbe83bf4.cjs} +1 -1
- package/dist/cjs/{portis-9ac42c6a.cjs → portis-9e401273.cjs} +1 -1
- package/dist/cjs/{provider-25d93a69.cjs → provider-7bfbbff3.cjs} +1 -1
- package/dist/cjs/{rainbow-a04db469.cjs → rainbow-6331cb27.cjs} +1 -1
- package/dist/cjs/{sha224-2fadd06e.cjs → sha224-0d4d6fdd.cjs} +1 -1
- package/dist/cjs/{sha256-9f8015ea.cjs → sha256-3aa003e0.cjs} +1 -1
- package/dist/cjs/{typed-data-dde4a66f.cjs → typed-data-01967235.cjs} +1 -1
- package/dist/cjs/{uAuth-ea317035.cjs → uAuth-766da269.cjs} +1 -1
- package/dist/cjs/{walletConnect-15fc29df.cjs → walletConnect-0c48b404.cjs} +1 -1
- package/dist/cjs/{walletLink-3ac9efad.cjs → walletLink-99768078.cjs} +2 -2
- package/dist/{draggabilly-e028ec41.js → draggabilly-042d2baf.js} +1 -1
- package/dist/id-06102aea.js +1 -0
- package/dist/{index-7a5a2895.js → index-2461634e.js} +1 -1
- package/dist/{index-e9aacae8.js → index-553ce10b.js} +1 -1
- package/dist/{index-1256acc9.js → index-75136e75.js} +1 -1
- package/dist/{index-5772df94.js → index-7d9f2ac0.js} +3 -3
- package/dist/{index-26ab1f42.js → index-7ed0e2da.js} +2 -2
- package/dist/{index-fa8ae676.js → index-938018a1.js} +1 -1
- package/dist/{index-b559a26e.js → index-bd8e8702.js} +1 -1
- package/dist/{index-239ddf05.js → index-d9830b67.js} +1 -1
- package/dist/{index-af74b255.js → index-ea4428da.js} +2 -2
- package/dist/{index-de37a495.js → index-fa54ba53.js} +1 -1
- package/dist/{index.es-3b789bf9.js → index.es-938556e7.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-001cd30f.js → interface-424d0728.js} +1 -1
- package/dist/{lib-typedarrays-0f3d7cfd.js → lib-typedarrays-7ec5ace4.js} +1 -1
- package/dist/{portis-aa99a2cc.js → portis-df3f2ecc.js} +1 -1
- package/dist/{provider-ed732881.js → provider-c1f0eadb.js} +1 -1
- package/dist/{rainbow-1636f787.js → rainbow-9dbf58c4.js} +1 -1
- package/dist/{sha224-3bdc932c.js → sha224-f656013d.js} +1 -1
- package/dist/{sha256-4da40dc5.js → sha256-1f582b12.js} +1 -1
- package/dist/{typed-data-1847b6ed.js → typed-data-869afd88.js} +1 -1
- package/dist/{uAuth-d30d3c61.js → uAuth-2faa4403.js} +1 -1
- package/dist/{walletConnect-f307066d.js → walletConnect-590ee7ef.js} +1 -1
- package/dist/{walletLink-091917c3.js → walletLink-af9b8335.js} +2 -2
- package/package.json +1 -1
- package/dist/cjs/id-a70f30cf.cjs +0 -1
- package/dist/id-17eaf985.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("./index-91f65724.cjs"),t=require("./v4-3e682452.cjs");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}require("@ethersproject/address"),require("@ethersproject/providers"),require("zustand"),require("@ethersproject/bytes"),require("@ethersproject/properties"),require("@ethersproject/abstract-signer"),require("buffer"),require("@ethersproject/abstract-provider"),require("@ethersproject/contracts"),require("events"),require("@ethersproject/constants"),require("@ethersproject/transactions");var r={exports:{}};!function(t,n){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e.commonjsGlobal&&e.commonjsGlobal,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==n&&n,r={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};if(r.arrayBuffer)var i=["[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&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function u(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function h(e){var t=new FileReader,n=u(t);return t.readAsArrayBuffer(e),n}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 p(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=f(e):this._bodyText=e=Object.prototype.toString.call(e):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):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=d(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)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=d(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))}return this.blob().then(h)}),this.text=function(){var e,t,n,r=d(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=u(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=a(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=a(t)},l.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),c(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),c(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),c(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,i=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function y(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function v(e,t){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},p.call(m.prototype),p.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var b=[301,302,303,307,308];v.redirect=function(e,t){if(-1===b.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function w(e,i){return new Promise((function(o,s){var c=new m(e,i);if(c.signal&&c.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function u(){d.abort()}d.onload=function(){var e,t,n={status:d.status,statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new l,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 n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in d?d.responseURL:n.headers.get("X-Request-URL");var r="response"in d?d.response:d.responseText;setTimeout((function(){o(new v(r,n))}),0)},d.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.onabort=function(){setTimeout((function(){s(new t.DOMException("Aborted","AbortError"))}),0)},d.open(c.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?d.withCredentials=!0:"omit"===c.credentials&&(d.withCredentials=!1),"responseType"in d&&(r.blob?d.responseType="blob":r.arrayBuffer&&c.headers.get("Content-Type")&&-1!==c.headers.get("Content-Type").indexOf("application/octet-stream")&&(d.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof l?c.headers.forEach((function(e,t){d.setRequestHeader(t,e)})):Object.getOwnPropertyNames(i.headers).forEach((function(e){d.setRequestHeader(e,a(i.headers[e]))})),c.signal&&(c.signal.addEventListener("abort",u),d.onreadystatechange=function(){4===d.readyState&&c.signal.removeEventListener("abort",u)}),d.send(void 0===c._bodyInit?null:c._bodyInit)}))}w.polyfill=!0,n.fetch||(n.fetch=w,n.Headers=l,n.Request=m,n.Response=v),t.Headers=l,t.Request=m,t.Response=v,t.fetch=w}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(n=o.fetch).default=o.fetch,n.fetch=o.fetch,n.Headers=o.Headers,n.Request=o.Request,n.Response=o.Response,t.exports=n}(r,r.exports);var i,o,s=r.exports,a={exports:{}};function c(){if(o)return i;o=1;var e=1e3,t=60*e,n=60*t,r=24*n,s=7*r,a=365.25*r;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return i=function(i,o){o=o||{};var l=typeof i;if("string"===l&&i.length>0)return function(i){if((i=String(i)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!o)return;var c=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*a;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(i);if("number"===l&&isFinite(i))return o.long?function(i){var o=Math.abs(i);if(o>=r)return c(i,o,r,"day");if(o>=n)return c(i,o,n,"hour");if(o>=t)return c(i,o,t,"minute");if(o>=e)return c(i,o,e,"second");return i+" ms"}(i):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))},i}var l=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=c(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=l(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(a,a.exports);var d,u=a.exports,h={exports:{}};
|
|
1
|
+
"use strict";var e=require("./index-42d4f376.cjs"),t=require("./v4-3e682452.cjs");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}require("@ethersproject/address"),require("@ethersproject/providers"),require("zustand"),require("@ethersproject/bytes"),require("@ethersproject/properties"),require("@ethersproject/abstract-signer"),require("buffer"),require("@ethersproject/abstract-provider"),require("@ethersproject/contracts"),require("events"),require("@ethersproject/constants"),require("@ethersproject/transactions");var r={exports:{}};!function(t,n){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e.commonjsGlobal&&e.commonjsGlobal,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==n&&n,r={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};if(r.arrayBuffer)var i=["[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&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function u(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function h(e){var t=new FileReader,n=u(t);return t.readAsArrayBuffer(e),n}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 p(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=f(e):this._bodyText=e=Object.prototype.toString.call(e):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):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=d(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)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=d(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))}return this.blob().then(h)}),this.text=function(){var e,t,n,r=d(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=u(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=a(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=a(t)},l.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),c(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),c(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),c(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,i=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function y(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function v(e,t){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},p.call(m.prototype),p.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var b=[301,302,303,307,308];v.redirect=function(e,t){if(-1===b.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function w(e,i){return new Promise((function(o,s){var c=new m(e,i);if(c.signal&&c.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function u(){d.abort()}d.onload=function(){var e,t,n={status:d.status,statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new l,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 n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in d?d.responseURL:n.headers.get("X-Request-URL");var r="response"in d?d.response:d.responseText;setTimeout((function(){o(new v(r,n))}),0)},d.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.onabort=function(){setTimeout((function(){s(new t.DOMException("Aborted","AbortError"))}),0)},d.open(c.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?d.withCredentials=!0:"omit"===c.credentials&&(d.withCredentials=!1),"responseType"in d&&(r.blob?d.responseType="blob":r.arrayBuffer&&c.headers.get("Content-Type")&&-1!==c.headers.get("Content-Type").indexOf("application/octet-stream")&&(d.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof l?c.headers.forEach((function(e,t){d.setRequestHeader(t,e)})):Object.getOwnPropertyNames(i.headers).forEach((function(e){d.setRequestHeader(e,a(i.headers[e]))})),c.signal&&(c.signal.addEventListener("abort",u),d.onreadystatechange=function(){4===d.readyState&&c.signal.removeEventListener("abort",u)}),d.send(void 0===c._bodyInit?null:c._bodyInit)}))}w.polyfill=!0,n.fetch||(n.fetch=w,n.Headers=l,n.Request=m,n.Response=v),t.Headers=l,t.Request=m,t.Response=v,t.fetch=w}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(n=o.fetch).default=o.fetch,n.fetch=o.fetch,n.Headers=o.Headers,n.Request=o.Request,n.Response=o.Response,t.exports=n}(r,r.exports);var i,o,s=r.exports,a={exports:{}};function c(){if(o)return i;o=1;var e=1e3,t=60*e,n=60*t,r=24*n,s=7*r,a=365.25*r;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return i=function(i,o){o=o||{};var l=typeof i;if("string"===l&&i.length>0)return function(i){if((i=String(i)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!o)return;var c=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*a;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(i);if("number"===l&&isFinite(i))return o.long?function(i){var o=Math.abs(i);if(o>=r)return c(i,o,r,"day");if(o>=n)return c(i,o,n,"hour");if(o>=t)return c(i,o,t,"minute");if(o>=e)return c(i,o,e,"second");return i+" ms"}(i):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))},i}var l=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=c(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=l(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(a,a.exports);var d,u=a.exports,h={exports:{}};
|
|
2
2
|
/*!
|
|
3
3
|
* EventEmitter2
|
|
4
4
|
* https://github.com/hij1nx/EventEmitter2
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* Copyright (c) 2013 hij1nx
|
|
7
7
|
* Licensed under the MIT license.
|
|
8
8
|
*/
|
|
9
|
-
d=h,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof process&&"function"==typeof process.nextTick,i="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,a=i?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function u(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var h=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function f(t,n){for(var r={},i=t.length,o=n?n.length:0,s=0;s<i;s++)r[t[s]]=s<o?n[s]:e;return r}function p(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(n,r,i,o){var s=Object.assign({},r);if(!n)return s;if("object"!=typeof n)throw TypeError("options must be an object");var a,c,l,d=Object.keys(n),u=d.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<u;f++){if(a=d[f],!o&&!t.call(r,a))throw Error('Unknown "'+a+'" option');(c=n[a])!==e&&(l=i[a],s[a]=l?l(c,h):c)}return s}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var o=typeof e;if(o===r||o===i)return e;n(t)}:function(r,i){for(var o=typeof r,s=n;s-- >0;)if(o===e[s])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var r=h.apply(null,arguments),s={data:r,name:t,original:e};n?!1!==n.call(i,s)&&o.emit.apply(o,[s.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=a,r._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,s=this._emitter,c=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function d(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=E.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;c.call(l,e,t),delete o[e],--this._listenersCount||d()}else{for(r=(n=a(o)).length;r-- >0;)e=n[r],c.call(l,e,o[e]);this._listeners={},this._listenersCount=0,d()}}});var v=y(["function"]),b=y(["object","function"]);function w(e,t,n){var r,i,o,s=0,a=new e((function(c,l,d){function u(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=g(n,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof d;var h=function(e){u(),c(e)},f=function(e){u(),l(e)};r?t(h,f,d):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),l(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function E(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function C(e,t,n,r,i){if(!n)return null;if(0===r){var o=typeof t;if("string"===o){var s,c,l=0,d=0,u=this.delimiter,h=u.length;if(-1!==(c=t.indexOf(u))){s=new Array(5);do{s[l++]=t.slice(d,c),d=c+h}while(-1!==(c=t.indexOf(u,d)));s[l++]=t.slice(d),t=s,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,y,v,b,w=null,E=t[r],_=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===E){for(c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&(b=C(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===E){for((y=r+1===i||r+2===i&&"*"===_)&&n._listeners&&(w=C(e,t,n,i,i)),c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&("*"===f||"**"===f?(n[f]._listeners&&!y&&(b=C(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=C(e,t,n[f],r,i)):b=C(e,t,n[f],f===_?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[E]&&(w=C(e,t,n[E],r+1,i))}if((p=n["*"])&&C(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&C(e,t,g,i,i),c=(v=a(g)).length;c-- >0;)"_listeners"!==(f=v[c])&&(f===_?C(e,t,g[f],r+2,i):f===E?C(e,t,g[f],r+1,i):((m={})[f]=g[f],C(e,t,{"**":m},r+1,i)));else g._listeners?C(e,t,g,i,i):g["*"]&&g["*"]._listeners&&C(e,t,g["*"],i,i);return w}function _(e,t,n){var r,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,r),s=r+c}while(-1!==(r=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+1<o;r++)if("**"===i[r]&&"**"===i[r+1])return;var l,d=this.listenerTree;for(r=0;r<o;r++)if(d=d[l=i[r]]||(d[l]={}),r===o-1)return d._listeners?("function"==typeof d._listeners&&(d._listeners=[d._listeners]),n?d._listeners.unshift(t):d._listeners.push(t),!d._listeners.warned&&this._maxListeners>0&&d._listeners.length>this._maxListeners&&(d._listeners.warned=!0,u.call(this,d._listeners.length,l))):d._listeners=t,!0;return!0}function S(e,t,n,r){for(var i,o,s,c,l=a(e),d=l.length,u=e._listeners;d-- >0;)i=e[o=l[d]],s="_listeners"===o?n:n?n.concat(o):[o],c=r||"symbol"==typeof o,u&&t.push(c?s:s.join(this.delimiter)),"object"==typeof i&&S.call(this,i,t,s,c);return t}function k(e){for(var t,n,r,i=a(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,"_listeners"===n||k(t)||delete e[n]);return r}function x(e,t,n){this.emitter=e,this.event=t,this.listener=n}function A(t,n,i){if(!0===i)a=!0;else if(!1===i)o=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var o=i.async,a=i.promisify,c=i.nextTick,l=i.objectify}if(o||c||a){var d=n,u=n._origin||n;if(c&&!r)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?c?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?process.nextTick:s)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=u}return[n,l?new x(this,t,n):this]}function M(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},M.EventEmitter2=M,M.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,r=i.reducers,s=E.call(o,t);n=-1===s?new p(o,t,i):o._observers[s];for(var c,l=a(e),d=l.length,u="function"==typeof r,h=0;h<d;h++)c=l[h],n.subscribe(c,e[c]||c,u?r:r&&r[c])}return i=g(i,{on:e,off:e,reducers:e},{on:v,off:v,reducers:b}),n(r)?s(f(r)):s("string"==typeof r?f(r.split(/\s+/)):r),this},M.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},M.prototype.delimiter=".",M.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},M.prototype.getMaxListeners=function(){return this._maxListeners},M.prototype.event="",M.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},M.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},M.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},M.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},M.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},M.prototype._many=function(e,t,n,r,i){var o=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},M.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,i)for(r=0;r<n;r++)if("symbol"==typeof a[r]){s=!0;break}s||(a=a.join(this.delimiter))}var d,u=arguments.length;if(this._all&&this._all.length)for(r=0,n=(d=this._all.slice()).length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this,a);break;case 2:d[r].call(this,a,arguments[1]);break;case 3:d[r].call(this,a,arguments[1],arguments[2]);break;default:d[r].apply(this,arguments)}if(l)d=[],C.call(this,d,e,this.listenerTree,0,n);else{if("function"==typeof(d=this._events[a])){switch(this.event=a,u){case 1:d.call(this);break;case 2:d.call(this,arguments[1]);break;case 3:d.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];d.apply(this,t)}return!0}d&&(d=d.slice())}if(d&&d.length){if(u>3)for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];for(r=0,n=d.length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this);break;case 2:d[r].call(this,arguments[1]);break;case 3:d[r].call(this,arguments[1],arguments[2]);break;default:d[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},M.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,i)for(o=0;o<r;o++)if("symbol"==typeof a[o]){t=!0;break}t||(a=a.join(this.delimiter))}var d,u=[],h=arguments.length;if(this._all)for(o=0,r=this._all.length;o<r;o++)switch(this.event=a,h){case 1:u.push(this._all[o].call(this,a));break;case 2:u.push(this._all[o].call(this,a,arguments[1]));break;case 3:u.push(this._all[o].call(this,a,arguments[1],arguments[2]));break;default:u.push(this._all[o].apply(this,arguments))}if(l?(d=[],C.call(this,d,e,this.listenerTree,0)):d=this._events[a],"function"==typeof d)switch(this.event=a,h){case 1:u.push(d.call(this));break;case 2:u.push(d.call(this,arguments[1]));break;case 3:u.push(d.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];u.push(d.apply(this,n))}else if(d&&d.length){if(d=d.slice(),h>3)for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];for(o=0,r=d.length;o<r;o++)switch(this.event=a,h){case 1:u.push(d[o].call(this));break;case 2:u.push(d[o].call(this,arguments[1]));break;case 3:u.push(d[o].call(this,arguments[1],arguments[2]));break;default:u.push(d[o].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(u)},M.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},M.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},M.prototype.onAny=function(e){return this._onAny(e,!1)},M.prototype.prependAny=function(e){return this._onAny(e,!0)},M.prototype.addListener=M.prototype.on,M.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},M.prototype._on=function(t,n,r,i){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,s=this;return i!==e&&(n=(o=A.call(this,t,n,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(_.call(this,t,n,r),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),r?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,u.call(this,this._events[t].length,t))):this._events[t]=n,s)},M.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=C.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var c=-1,l=0,d=r.length;l<d;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&k(this.listenerTree),this},M.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},M.prototype.removeListener=M.prototype.off,M.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,r=C.call(this,null,t,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&k(this.listenerTree)}else this._events&&(this._events[t]=null);return this},M.prototype.listeners=function(t){var n,r,i,o,s,c=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!c)return[];for(o=(n=a(c)).length,i=[];o-- >0;)"function"==typeof(r=c[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],d="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,l,d,s,0),l}return c&&(r=c[t])?"function"==typeof r?[r]:r:[]},M.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?a(t):[]},M.prototype.listenerCount=function(e){return this.listeners(e).length},M.prototype.hasListeners=function(t){if(this.wildcard){var n=[],r="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?a(i).length:i[t]))},M.prototype.listenersAny=function(){return this._all?this._all:[]},M.prototype.waitFor=function(t,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),w((n=g(n,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:v,Promise:m})).Promise,(function(e,i,o){function s(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(t,s),n.handleError){var a=arguments[0];a?i(a):e(h.apply(null,arguments).slice(1))}else e(h.apply(null,arguments))}o((function(){r.off(t,s)})),r._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var L=M.prototype;Object.defineProperties(M,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=g(n,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,r,i){var o;if("function"==typeof e.addEventListener)return o=function(){n(h.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),n(h.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,a),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return M})):d.exports=M}();var f=h.exports;const p=Object.create(null);p.open="0",p.close="1",p.ping="2",p.pong="3",p.message="4",p.upgrade="5",p.noop="6";const g=Object.create(null);Object.keys(p).forEach((e=>{g[p[e]]=e}));const m={type:"error",data:"parser error"},y="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),v="function"==typeof ArrayBuffer,b=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,w=({type:e,data:t},n,r)=>y&&t instanceof Blob?n?r(t):E(t,r):v&&(t instanceof ArrayBuffer||b(t))?n?r(t):E(new Blob([t]),r):r(p[e]+(t||"")),E=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function C(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let _;const S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)k[S.charCodeAt(e)]=e;const x="function"==typeof ArrayBuffer,A=(e,t)=>{if("string"!=typeof e)return{type:"message",data:L(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:M(e.substring(1),t)};return g[n]?e.length>1?{type:g[n],data:e.substring(1)}:{type:g[n]}:m},M=(e,t)=>{if(x){const n=(e=>{let t,n,r,i,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),d=new Uint8Array(l);for(t=0;t<a;t+=4)n=k[e.charCodeAt(t)],r=k[e.charCodeAt(t+1)],i=k[e.charCodeAt(t+2)],o=k[e.charCodeAt(t+3)],d[c++]=n<<2|r>>4,d[c++]=(15&r)<<4|i>>2,d[c++]=(3&i)<<6|63&o;return l})(e);return L(n,t)}return{base64:!0,data:e}},L=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,O=String.fromCharCode(30);function T(){return new TransformStream({transform(e,t){!function(e,t){y&&e.data instanceof Blob?e.data.arrayBuffer().then(C).then(t):v&&(e.data instanceof ArrayBuffer||b(e.data))?t(C(e.data)):w(e,!1,(e=>{_||(_=new TextEncoder),t(_.encode(e))}))}(e,(n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)}))}})}let R;function P(e){return e.reduce(((e,t)=>e+t.length),0)}function I(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function N(e){if(e)return function(e){for(var t in N.prototype)e[t]=N.prototype[t];return e}(e)}N.prototype.on=N.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},N.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},N.prototype.off=N.prototype.removeListener=N.prototype.removeAllListeners=N.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},N.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},N.prototype.emitReserved=N.prototype.emit,N.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},N.prototype.hasListeners=function(e){return!!this.listeners(e).length};const B="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function D(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const $=B.setTimeout,j=B.clearTimeout;function K(e,t){t.useNativeTimers?(e.setTimeoutFn=$.bind(B),e.clearTimeoutFn=j.bind(B)):(e.setTimeoutFn=B.setTimeout.bind(B),e.clearTimeoutFn=B.clearTimeout.bind(B))}class U extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class F extends N{constructor(e){super(),this.writable=!1,K(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new U(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=A(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const H="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),z=64,q={};let V,W=0,G=0;function Y(e){let t="";do{t=H[e%z]+t,e=Math.floor(e/z)}while(e>0);return t}function Z(){const e=Y(+new Date);return e!==V?(W=0,V=e):e+"."+Y(W++)}for(;G<z;G++)q[H[G]]=G;let J=!1;try{J="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const X=J;function Q(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||X))return new XMLHttpRequest}catch(e){}if(!t)try{return new(B[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function ee(){}const te=null!=new Q({xdomain:!1}).responseType;class ne extends N{constructor(e,t){super(),K(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=D(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new Q(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ne.requestsCount++,ne.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=ee,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ne.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ne.requestsCount=0,ne.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",re);else if("function"==typeof addEventListener){addEventListener("onpagehide"in B?"pagehide":"unload",re,!1)}function re(){for(let e in ne.requests)ne.requests.hasOwnProperty(e)&&ne.requests[e].abort()}const ie="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),oe=B.WebSocket||B.MozWebSocket,se="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const ae={websocket:class extends F{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=se?{}:D(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=se?new oe(e,t,n):t?new oe(e,t):new oe(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;w(n,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}r&&ie((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!oe}},webtransport:class extends F{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){R||(R=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(P(n)<1)break;const e=I(n,1);o=128==(128&e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(P(n)<2)break;const e=I(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(P(n)<8)break;const e=I(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(m);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(P(n)<i)break;const e=I(n,i);a.enqueue(A(o?e:R.decode(e),t)),r=0}if(0===i||i>e){a.enqueue(m);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=T();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const i=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then((()=>{r&&ie((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends F{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=te&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(O),r=[];for(let e=0;e<n.length;e++){const i=A(n[e],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach(((e,o)=>{w(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(O))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ne(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},ce=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,le=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function de(e){if(e.length>2e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=ce.exec(e||""),o={},s=14;for(;s--;)o[le[s]]=i[s]||"";return-1!=n&&-1!=r&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,o.path),o.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,o.query),o}class ue extends N{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=de(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=de(t.host).host),K(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new ae[e](n)}open(){let e;if(this.opts.rememberUpgrade&&ue.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),n=!1;ue.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;ue.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&i()}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",ue.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let n=0;n<this.writeBuffer.length;n++){const r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}var t;return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){ue.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}ue.protocol=4;const he="function"==typeof ArrayBuffer,fe=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,pe=Object.prototype.toString,ge="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===pe.call(Blob),me="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===pe.call(File);function ye(e){return he&&(e instanceof ArrayBuffer||fe(e))||ge&&e instanceof Blob||me&&e instanceof File}function ve(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ve(e[t]))return!0;return!1}if(ye(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ve(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ve(e[t]))return!0;return!1}function be(e){const t=[],n=e.data,r=e;return r.data=we(n,t),r.attachments=t.length,{packet:r,buffers:t}}function we(e,t){if(!e)return e;if(ye(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=we(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=we(e[r],t));return n}return e}function Ee(e,t){return e.data=Ce(e.data,t),delete e.attachments,e}function Ce(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Ce(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Ce(e[n],t));return e}const _e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Se;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Se||(Se={}));function ke(e){return"[object Object]"===Object.prototype.toString.call(e)}class xe extends N{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===Se.BINARY_EVENT;n||t.type===Se.BINARY_ACK?(t.type=n?Se.EVENT:Se.ACK,this.reconstructor=new Ae(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!ye(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===Se[n.type])throw new Error("unknown packet type "+n.type);if(n.type===Se.BINARY_EVENT||n.type===Se.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!xe.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Se.CONNECT:return ke(t);case Se.DISCONNECT:return void 0===t;case Se.CONNECT_ERROR:return"string"==typeof t||ke(t);case Se.EVENT:case Se.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===_e.indexOf(t[0]));case Se.ACK:case Se.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ae{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Ee(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Me=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Se},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Se.EVENT&&e.type!==Se.ACK||!ve(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Se.EVENT?Se.BINARY_EVENT:Se.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Se.BINARY_EVENT&&e.type!==Se.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=be(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Decoder:xe});function Le(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Oe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Te extends N{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Le(e,"open",this.onopen.bind(this)),Le(e,"packet",this.onpacket.bind(this)),Le(e,"error",this.onerror.bind(this)),Le(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Oe.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:Se.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const n=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((r,i)=>{t.push(((e,t)=>n?e?i(e):r(t):r(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Se.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Se.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Se.EVENT:case Se.BINARY_EVENT:this.onevent(e);break;case Se.ACK:case Se.BINARY_ACK:this.onack(e);break;case Se.DISCONNECT:this.ondisconnect();break;case Se.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:Se.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Se.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function Re(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Re.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Re.prototype.reset=function(){this.attempts=0},Re.prototype.setMin=function(e){this.ms=e},Re.prototype.setMax=function(e){this.max=e},Re.prototype.setJitter=function(e){this.jitter=e};class Pe extends N{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,K(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new Re({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Me;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ue(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Le(t,"open",(function(){n.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=Le(t,"error",i);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn((()=>{r(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Le(e,"ping",this.onping.bind(this)),Le(e,"data",this.ondata.bind(this)),Le(e,"error",this.onerror.bind(this)),Le(e,"close",this.onclose.bind(this)),Le(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){ie((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Te(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ie={};function Ne(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=de(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=Ie[i]&&o in Ie[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Pe(r,t):(Ie[i]||(Ie[i]=new Pe(r,t)),a=Ie[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function Be(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}Object.assign(Ne,{Manager:Pe,Socket:Te,io:Ne,connect:Ne}),"function"==typeof SuppressedError&&SuppressedError;var De="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},$e=[],je=[],Ke="undefined"!=typeof Uint8Array?Uint8Array:Array,Ue=!1;function Fe(){Ue=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)$e[t]=e[t],je[e.charCodeAt(t)]=t;je["-".charCodeAt(0)]=62,je["_".charCodeAt(0)]=63}function He(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push($e[(i=r)>>18&63]+$e[i>>12&63]+$e[i>>6&63]+$e[63&i]);return o.join("")}function ze(e){var t;Ue||Fe();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,c=n-r;a<c;a+=s)o.push(He(e,a,a+s>c?c:a+s));return 1===r?(t=e[n-1],i+=$e[t>>2],i+=$e[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=$e[t>>10],i+=$e[t>>4&63],i+=$e[t<<2&63],i+="="),o.push(i),o.join("")}function qe(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=n?i-1:0,h=n?-1:1,f=e[t+u];for(u+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function Ve(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,d=(1<<l)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,i),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+f]=255&s,f+=p,s/=256,l-=8);e[n+f-p]|=128*g}var We={}.toString,Ge=Array.isArray||function(e){return"[object Array]"==We.call(e)};Xe.TYPED_ARRAY_SUPPORT=void 0===De.TYPED_ARRAY_SUPPORT||De.TYPED_ARRAY_SUPPORT;var Ye=Ze();function Ze(){return Xe.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Je(e,t){if(Ze()<t)throw new RangeError("Invalid typed array length");return Xe.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Xe.prototype:(null===e&&(e=new Xe(t)),e.length=t),e}function Xe(e,t,n){if(!(Xe.TYPED_ARRAY_SUPPORT||this instanceof Xe))return new Xe(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return tt(this,e)}return Qe(this,e,t,n)}function Qe(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Xe.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Xe.prototype:e=nt(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Xe.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ot(t,n),i=(e=Je(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(it(t)){var n=0|rt(t.length);return 0===(e=Je(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Je(e,0):nt(e,t);if("Buffer"===t.type&&Ge(t.data))return nt(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function et(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function tt(e,t){if(et(t),e=Je(e,t<0?0:0|rt(t)),!Xe.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function nt(e,t){var n=t.length<0?0:0|rt(t.length);e=Je(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function rt(e){if(e>=Ze())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ze().toString(16)+" bytes");return 0|e}function it(e){return!(null==e||!e._isBuffer)}function ot(e,t){if(it(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Rt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Pt(e).length;default:if(r)return Rt(e).length;t=(""+t).toLowerCase(),r=!0}}function st(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Et(this,t,n);case"utf8":case"utf-8":return yt(this,t,n);case"ascii":return bt(this,t,n);case"latin1":case"binary":return wt(this,t,n);case"base64":return mt(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ct(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function at(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function ct(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=Xe.from(t,r)),it(t))return 0===t.length?-1:lt(e,t,n,r,i);if("number"==typeof t)return t&=255,Xe.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):lt(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function lt(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var d=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function dt(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function ut(e,t,n,r){return It(Rt(t,e.length-n),e,n,r)}function ht(e,t,n,r){return It(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function ft(e,t,n,r){return ht(e,t,n,r)}function pt(e,t,n,r){return It(Pt(t),e,n,r)}function gt(e,t,n,r){return It(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function mt(e,t,n){return 0===t&&n===e.length?ze(e):ze(e.slice(t,n))}function yt(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],d=null,u=l>239?4:l>223?3:l>191?2:1;if(i+u<=n)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),i+=u}return function(e){var t=e.length;if(t<=vt)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=vt));return n}(r)}Xe.poolSize=8192,Xe._augment=function(e){return e.__proto__=Xe.prototype,e},Xe.from=function(e,t,n){return Qe(null,e,t,n)},Xe.TYPED_ARRAY_SUPPORT&&(Xe.prototype.__proto__=Uint8Array.prototype,Xe.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Xe[Symbol.species]),Xe.alloc=function(e,t,n){return function(e,t,n,r){return et(t),t<=0?Je(e,t):void 0!==n?"string"==typeof r?Je(e,t).fill(n,r):Je(e,t).fill(n):Je(e,t)}(null,e,t,n)},Xe.allocUnsafe=function(e){return tt(null,e)},Xe.allocUnsafeSlow=function(e){return tt(null,e)},Xe.isBuffer=Nt,Xe.compare=function(e,t){if(!it(e)||!it(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},Xe.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Xe.concat=function(e,t){if(!Ge(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Xe.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Xe.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!it(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},Xe.byteLength=ot,Xe.prototype._isBuffer=!0,Xe.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)at(this,t,t+1);return this},Xe.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)at(this,t,t+3),at(this,t+1,t+2);return this},Xe.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)at(this,t,t+7),at(this,t+1,t+6),at(this,t+2,t+5),at(this,t+3,t+4);return this},Xe.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?yt(this,0,e):st.apply(this,arguments)},Xe.prototype.equals=function(e){if(!it(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Xe.compare(this,e)},Xe.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Xe.prototype.compare=function(e,t,n,r,i){if(!it(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},Xe.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Xe.prototype.indexOf=function(e,t,n){return ct(this,e,t,n,!0)},Xe.prototype.lastIndexOf=function(e,t,n){return ct(this,e,t,n,!1)},Xe.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return dt(this,e,t,n);case"utf8":case"utf-8":return ut(this,e,t,n);case"ascii":return ht(this,e,t,n);case"latin1":case"binary":return ft(this,e,t,n);case"base64":return pt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gt(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},Xe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var vt=4096;function bt(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function wt(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function Et(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=Tt(e[o]);return i}function Ct(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function _t(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function St(e,t,n,r,i,o){if(!it(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function kt(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function xt(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function At(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Mt(e,t,n,r,i){return i||At(e,0,n,4),Ve(e,t,n,r,23,4),n+4}function Lt(e,t,n,r,i){return i||At(e,0,n,8),Ve(e,t,n,r,52,8),n+8}Xe.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Xe.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Xe.prototype;else{var i=t-e;n=new Xe(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},Xe.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},Xe.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},Xe.prototype.readUInt8=function(e,t){return t||_t(e,1,this.length),this[e]},Xe.prototype.readUInt16LE=function(e,t){return t||_t(e,2,this.length),this[e]|this[e+1]<<8},Xe.prototype.readUInt16BE=function(e,t){return t||_t(e,2,this.length),this[e]<<8|this[e+1]},Xe.prototype.readUInt32LE=function(e,t){return t||_t(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Xe.prototype.readUInt32BE=function(e,t){return t||_t(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Xe.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},Xe.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Xe.prototype.readInt8=function(e,t){return t||_t(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Xe.prototype.readInt16LE=function(e,t){t||_t(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Xe.prototype.readInt16BE=function(e,t){t||_t(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Xe.prototype.readInt32LE=function(e,t){return t||_t(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Xe.prototype.readInt32BE=function(e,t){return t||_t(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Xe.prototype.readFloatLE=function(e,t){return t||_t(e,4,this.length),qe(this,e,!0,23,4)},Xe.prototype.readFloatBE=function(e,t){return t||_t(e,4,this.length),qe(this,e,!1,23,4)},Xe.prototype.readDoubleLE=function(e,t){return t||_t(e,8,this.length),qe(this,e,!0,52,8)},Xe.prototype.readDoubleBE=function(e,t){return t||_t(e,8,this.length),qe(this,e,!1,52,8)},Xe.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||St(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},Xe.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||St(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},Xe.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,1,255,0),Xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Xe.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,65535,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):kt(this,e,t,!0),t+2},Xe.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,65535,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):kt(this,e,t,!1),t+2},Xe.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,4294967295,0),Xe.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):xt(this,e,t,!0),t+4},Xe.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,4294967295,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):xt(this,e,t,!1),t+4},Xe.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);St(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},Xe.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);St(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},Xe.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,1,127,-128),Xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Xe.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,32767,-32768),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):kt(this,e,t,!0),t+2},Xe.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,32767,-32768),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):kt(this,e,t,!1),t+2},Xe.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,2147483647,-2147483648),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):xt(this,e,t,!0),t+4},Xe.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):xt(this,e,t,!1),t+4},Xe.prototype.writeFloatLE=function(e,t,n){return Mt(this,e,t,!0,n)},Xe.prototype.writeFloatBE=function(e,t,n){return Mt(this,e,t,!1,n)},Xe.prototype.writeDoubleLE=function(e,t,n){return Lt(this,e,t,!0,n)},Xe.prototype.writeDoubleBE=function(e,t,n){return Lt(this,e,t,!1,n)},Xe.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!Xe.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},Xe.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Xe.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=it(e)?e:Rt(new Xe(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var Ot=/[^+\/0-9A-Za-z-_]/g;function Tt(e){return e<16?"0"+e.toString(16):e.toString(16)}function Rt(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Pt(e){return function(e){var t,n,r,i,o,s;Ue||Fe();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Ke(3*a/4-o),r=o>0?a-4:a;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=je[e.charCodeAt(t)]<<18|je[e.charCodeAt(t+1)]<<12|je[e.charCodeAt(t+2)]<<6|je[e.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=je[e.charCodeAt(t)]<<2|je[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=je[e.charCodeAt(t)]<<10|je[e.charCodeAt(t+1)]<<4|je[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ot,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function It(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||Bt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Bt(e.slice(0,0))}(e))}function Bt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Dt=Object.freeze({__proto__:null,Buffer:Xe,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),Xe.alloc(+e)},isBuffer:Nt,kMaxLength:Ye}),$t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function jt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Kt(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Ut={},Ft={},Ht={};function zt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function qt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Vt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Wt(e,...t){if(!Vt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Gt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");zt(e.outputLen),zt(e.blockLen)}function Yt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Zt(e,t){Wt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.isBytes=Vt,Ht.number=zt,Ht.bool=qt,Ht.bytes=Wt,Ht.hash=Gt,Ht.exists=Yt,Ht.output=Zt;const Jt={number:zt,bool:qt,bytes:Wt,hash:Gt,exists:Yt,output:Zt};Ht.default=Jt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=e.createView=e.u32=e.u16=e.u8=void 0,e.bytesToHex=r,e.hexToBytes=s,e.hexToNumber=a,e.bytesToNumberBE=function(e){return a(r(e))},e.numberToBytesBE=function(e,t){return s(e.toString(16).padStart(2*t,"0"))},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=c,e.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},e.toBytes=function(e){if("string"==typeof e)e=c(e);else{if(!(0,t.isBytes)(e))throw new Error("Uint8Array expected, got "+typeof e);e=d(e)}return e},e.concatBytes=function(...e){let n=0;for(let r=0;r<e.length;r++){const i=e[r];(0,t.bytes)(i),n+=i.length}const r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},e.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},e.setBigUint64=l,e.u64Lengths=function(t,n){const r=new Uint8Array(16),i=(0,e.createView)(r);return l(i,0,BigInt(n?n.length:0),!0),l(i,8,BigInt(t.length),!0),r},e.isAligned32=function(e){return e.byteOffset%4==0},e.copyBytes=d,e.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)};const t=Ht;if(e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u16=e=>new Uint16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2)),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function r(e){(0,t.bytes)(e);let r="";for(let t=0;t<e.length;t++)r+=n[e[t]];return r}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function a(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function c(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function l(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}function d(e){return Uint8Array.from(e)}e.nextTick=async()=>{},e.Hash=class{},e.wrapCipher=(e,t)=>(Object.assign(t,e),t)}(Ft);var Xt={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.AEAD_TAG_LENGTH=Qt.XCHACHA20_NONCE_LENGTH=Qt.CURVE25519_PUBLIC_KEY_SIZE=Qt.ETH_PUBLIC_KEY_SIZE=Qt.UNCOMPRESSED_PUBLIC_KEY_SIZE=Qt.COMPRESSED_PUBLIC_KEY_SIZE=Qt.SECRET_KEY_LENGTH=void 0,Qt.SECRET_KEY_LENGTH=32,Qt.COMPRESSED_PUBLIC_KEY_SIZE=33,Qt.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,Qt.ETH_PUBLIC_KEY_SIZE=64,Qt.CURVE25519_PUBLIC_KEY_SIZE=32,Qt.XCHACHA20_NONCE_LENGTH=24,Qt.AEAD_TAG_LENGTH=16,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=Qt;e.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},e.ellipticCurve=function(){return e.ECIES_CONFIG.ellipticCurve},e.isEphemeralKeyCompressed=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed},e.isHkdfKeyCompressed=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed},e.symmetricAlgorithm=function(){return e.ECIES_CONFIG.symmetricAlgorithm},e.symmetricNonceLength=function(){return e.ECIES_CONFIG.symmetricNonceLength},e.ephemeralKeySize=function(){var n={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in n)return n[e.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}}(Xt);var en={},tn={},nn={},rn={},on={},sn={};Object.defineProperty(sn,"__esModule",{value:!0}),sn.crypto=void 0,sn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=i,e.getWebcryptoSubtle=o,e.managedNonce=function(e){return(0,n.number)(e.nonceLength),(t,...n)=>({encrypt(o,...s){const{nonceLength:a}=e,c=i(a),l=e(t,c,...n).encrypt(o,...s),d=(0,r.concatBytes)(c,l);return l.fill(0),d},decrypt(r,...i){const{nonceLength:o}=e,s=r.subarray(0,o),a=r.subarray(o);return e(t,s,...n).decrypt(a,...i)}})};const t=sn,n=Ht,r=Ft;function i(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function o(){if(t.crypto&&"object"==typeof t.crypto.subtle&&null!=t.crypto.subtle)return t.crypto.subtle;throw new Error("crypto.subtle must be defined")}e.utils={async encrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["encrypt"]),a=await i.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["decrypt"]),a=await i.decrypt(n,s,r);return new Uint8Array(a)}};const s={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(t){return(r,i,o)=>{(0,n.bytes)(r),(0,n.bytes)(i);const a={name:t,length:8*r.length},c=function(e,t,n){if(e===s.CBC)return{name:s.CBC,iv:t};if(e===s.CTR)return{name:s.CTR,counter:t,length:64};if(e===s.GCM)return n?{name:s.GCM,iv:t,additionalData:n}:{name:s.GCM,iv:t};throw new Error("unknown aes block mode")}(t,i,o);return{encrypt:t=>((0,n.bytes)(t),e.utils.encrypt(r,a,c,t)),decrypt:t=>((0,n.bytes)(t),e.utils.decrypt(r,a,c,t))}}}e.cbc=a(s.CBC),e.ctr=a(s.CTR),e.gcm=a(s.GCM)}(on);var an={},cn={},ln={},dn={};function un(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function hn(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function fn(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function pn(e,...t){if(!fn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function gn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");un(e.outputLen),un(e.blockLen)}function mn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function yn(e,t){pn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(dn,"__esModule",{value:!0}),dn.isBytes=fn,dn.number=un,dn.bool=hn,dn.bytes=pn,dn.hash=gn,dn.exists=mn,dn.output=yn;const vn={number:un,bool:hn,bytes:pn,hash:gn,exists:mn,output:yn};dn.default=vn;var bn={},wn={};Object.defineProperty(wn,"__esModule",{value:!0}),wn.crypto=void 0,wn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},e.byteSwap32=function(t){for(let n=0;n<t.length;n++)t[n]=(0,e.byteSwap)(t[n])},e.bytesToHex=function(e){(0,n.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=r[e[n]];return t},e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=s,e.toBytes=a,e.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];(0,n.bytes)(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==c.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(a(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=wn,n=dn;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.rotr=(e,t)=>e<<32-t|e>>>t,e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t);const r=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){return"string"==typeof e&&(e=s(e)),(0,n.bytes)(e),e}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(bn),Object.defineProperty(ln,"__esModule",{value:!0}),ln.HashMD=ln.Maj=ln.Chi=void 0;const En=dn,Cn=bn;ln.Chi=(e,t,n)=>e&t^~e&n,ln.Maj=(e,t,n)=>e&t^e&n^t&n,ln.HashMD=class extends Cn.Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Cn.createView)(this.buffer)}update(e){(0,En.exists)(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=(0,Cn.toBytes)(e)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=(0,Cn.createView)(e);for(;r<=i-o;o+=r)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,En.exists)(this),(0,En.output)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=(0,Cn.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}};var _n={};Object.defineProperty(_n,"__esModule",{value:!0}),_n.add5L=_n.add5H=_n.add4H=_n.add4L=_n.add3H=_n.add3L=_n.rotlBL=_n.rotlBH=_n.rotlSL=_n.rotlSH=_n.rotr32L=_n.rotr32H=_n.rotrBL=_n.rotrBH=_n.rotrSL=_n.rotrSH=_n.shrSL=_n.shrSH=_n.toBig=void 0,_n.fromBig=xn,_n.split=An,_n.add=Un;const Sn=BigInt(2**32-1),kn=BigInt(32);function xn(e,t=!1){return t?{h:Number(e&Sn),l:Number(e>>kn&Sn)}:{h:0|Number(e>>kn&Sn),l:0|Number(e&Sn)}}function An(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=xn(e[i],t);[n[i],r[i]]=[o,s]}return[n,r]}const Mn=(e,t)=>BigInt(e>>>0)<<kn|BigInt(t>>>0);_n.toBig=Mn;const Ln=(e,t,n)=>e>>>n;_n.shrSH=Ln;const On=(e,t,n)=>e<<32-n|t>>>n;_n.shrSL=On;const Tn=(e,t,n)=>e>>>n|t<<32-n;_n.rotrSH=Tn;const Rn=(e,t,n)=>e<<32-n|t>>>n;_n.rotrSL=Rn;const Pn=(e,t,n)=>e<<64-n|t>>>n-32;_n.rotrBH=Pn;const In=(e,t,n)=>e>>>n-32|t<<64-n;_n.rotrBL=In;const Nn=(e,t)=>t;_n.rotr32H=Nn;const Bn=(e,t)=>e;_n.rotr32L=Bn;const Dn=(e,t,n)=>e<<n|t>>>32-n;_n.rotlSH=Dn;const $n=(e,t,n)=>t<<n|e>>>32-n;_n.rotlSL=$n;const jn=(e,t,n)=>t<<n-32|e>>>64-n;_n.rotlBH=jn;const Kn=(e,t,n)=>e<<n-32|t>>>64-n;function Un(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}_n.rotlBL=Kn;const Fn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);_n.add3L=Fn;const Hn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;_n.add3H=Hn;const zn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);_n.add4L=zn;const qn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;_n.add4H=qn;const Vn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);_n.add5L=Vn;const Wn=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;_n.add5H=Wn;const Gn={fromBig:xn,split:An,toBig:Mn,shrSH:Ln,shrSL:On,rotrSH:Tn,rotrSL:Rn,rotrBH:Pn,rotrBL:In,rotr32H:Nn,rotr32L:Bn,rotlSH:Dn,rotlSL:$n,rotlBH:jn,rotlBL:Kn,add:Un,add3L:Fn,add3H:Hn,add4L:zn,add4H:qn,add5H:Wn,add5L:Vn};_n.default=Gn,Object.defineProperty(cn,"__esModule",{value:!0}),cn.sha384=cn.sha512_256=cn.sha512_224=cn.sha512=cn.SHA384=cn.SHA512_256=cn.SHA512_224=cn.SHA512=void 0;const Yn=ln,Zn=_n,Jn=bn,[Xn,Qn]=Zn.default.split(["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","0xf40e35855771202a","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)))),er=new Uint32Array(80),tr=new Uint32Array(80);class nr extends Yn.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:d,Fl:u,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g]}set(e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|d,this.Fl=0|u,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)er[n]=e.getUint32(t),tr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|er[e-15],n=0|tr[e-15],r=Zn.default.rotrSH(t,n,1)^Zn.default.rotrSH(t,n,8)^Zn.default.shrSH(t,n,7),i=Zn.default.rotrSL(t,n,1)^Zn.default.rotrSL(t,n,8)^Zn.default.shrSL(t,n,7),o=0|er[e-2],s=0|tr[e-2],a=Zn.default.rotrSH(o,s,19)^Zn.default.rotrBH(o,s,61)^Zn.default.shrSH(o,s,6),c=Zn.default.rotrSL(o,s,19)^Zn.default.rotrBL(o,s,61)^Zn.default.shrSL(o,s,6),l=Zn.default.add4L(i,c,tr[e-7],tr[e-16]),d=Zn.default.add4H(l,r,a,er[e-7],er[e-16]);er[e]=0|d,tr[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:d,El:u,Fh:h,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){const t=Zn.default.rotrSH(d,u,14)^Zn.default.rotrSH(d,u,18)^Zn.default.rotrBH(d,u,41),v=Zn.default.rotrSL(d,u,14)^Zn.default.rotrSL(d,u,18)^Zn.default.rotrBL(d,u,41),b=d&h^~d&p,w=u&f^~u&g,E=Zn.default.add5L(y,v,w,Qn[e],tr[e]),C=Zn.default.add5H(E,m,t,b,Xn[e],er[e]),_=0|E,S=Zn.default.rotrSH(n,r,28)^Zn.default.rotrBH(n,r,34)^Zn.default.rotrBH(n,r,39),k=Zn.default.rotrSL(n,r,28)^Zn.default.rotrBL(n,r,34)^Zn.default.rotrBL(n,r,39),x=n&i^n&s^i&s,A=r&o^r&a^o&a;m=0|p,y=0|g,p=0|h,g=0|f,h=0|d,f=0|u,({h:d,l:u}=Zn.default.add(0|c,0|l,0|C,0|_)),c=0|s,l=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const M=Zn.default.add3L(_,k,A);n=Zn.default.add3H(M,C,S,x),r=0|M}({h:n,l:r}=Zn.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Zn.default.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Zn.default.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:l}=Zn.default.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:d,l:u}=Zn.default.add(0|this.Eh,0|this.El,0|d,0|u)),({h:h,l:f}=Zn.default.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=Zn.default.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Zn.default.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,o,s,a,c,l,d,u,h,f,p,g,m,y)}roundClean(){er.fill(0),tr.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)}}cn.SHA512=nr;class rr extends nr{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}cn.SHA512_224=rr;class ir extends nr{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}cn.SHA512_256=ir;class or extends nr{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}cn.SHA384=or,cn.sha512=(0,Jn.wrapConstructor)((()=>new nr)),cn.sha512_224=(0,Jn.wrapConstructor)((()=>new rr)),cn.sha512_256=(0,Jn.wrapConstructor)((()=>new ir)),cn.sha384=(0,Jn.wrapConstructor)((()=>new or));var sr={},ar={},cr={},lr={};Object.defineProperty(lr,"__esModule",{value:!0}),lr.notImplemented=lr.bitMask=void 0,lr.isBytes=fr,lr.abytes=pr,lr.abool=function(e,t){if("boolean"!=typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)},lr.bytesToHex=mr,lr.numberToHexUnpadded=yr,lr.hexToNumber=vr,lr.hexToBytes=Er,lr.bytesToNumberBE=function(e){return vr(mr(e))},lr.bytesToNumberLE=function(e){return pr(e),vr(mr(Uint8Array.from(e).reverse()))},lr.numberToBytesBE=Cr,lr.numberToBytesLE=function(e,t){return Cr(e,t).reverse()},lr.numberToVarBytesBE=function(e){return Er(yr(e))},lr.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=Er(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!fr(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},lr.concatBytes=_r,lr.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},lr.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},lr.inRange=kr,lr.aInRange=function(e,t,n,r){if(!kr(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)},lr.bitLen=function(e){let t;for(t=0;e>dr;e>>=ur,t+=1);return t},lr.bitGet=function(e,t){return e>>BigInt(t)&ur},lr.bitSet=function(e,t,n){return e|(n?ur:dr)<<BigInt(t)},lr.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=xr(e),i=xr(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=xr())=>{i=a(Ar([0]),e),r=a(),0!==e.length&&(i=a(Ar([1]),e),r=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return _r(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}},lr.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=Mr[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},lr.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}};const dr=BigInt(0),ur=BigInt(1),hr=BigInt(2);function fr(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function pr(e){if(!fr(e))throw new Error("Uint8Array expected")}const gr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function mr(e){pr(e);let t="";for(let n=0;n<e.length;n++)t+=gr[e[n]];return t}function yr(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function vr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const br={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function wr(e){return e>=br._0&&e<=br._9?e-br._0:e>=br._A&&e<=br._F?e-(br._A-10):e>=br._a&&e<=br._f?e-(br._a-10):void 0}function Er(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=wr(e.charCodeAt(i)),o=wr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Cr(e,t){return Er(e.toString(16).padStart(2*t,"0"))}function _r(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];pr(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}const Sr=e=>"bigint"==typeof e&&dr<=e;function kr(e,t,n){return Sr(e)&&Sr(t)&&Sr(n)&&t<=e&&e<n}lr.bitMask=e=>(hr<<BigInt(e-1))-ur;const xr=e=>new Uint8Array(e),Ar=e=>Uint8Array.from(e),Mr={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||fr(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)};lr.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(cr,"__esModule",{value:!0}),cr.isNegativeLE=void 0,cr.mod=Dr,cr.pow=$r,cr.pow2=function(e,t,n){let r=e;for(;t-- >Or;)r*=r,r%=n;return r},cr.invert=jr,cr.tonelliShanks=Kr,cr.FpSqrt=Ur,cr.validateField=function(e){const t=Fr.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,Lr.validateObject)(e,t)},cr.FpPow=Hr,cr.FpInvertBatch=zr,cr.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?jr(n,e.ORDER):e.inv(n))},cr.FpLegendre=qr,cr.FpIsSquare=function(e){const t=qr(e.ORDER);return n=>{const r=t(e,n);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},cr.nLength=Vr,cr.Field=function(e,t,n=!1,r={}){if(e<=Or)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Vr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ur(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,Lr.bitMask)(i),ZERO:Or,ONE:Tr,create:t=>Dr(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Or<=t&&t<e},is0:e=>e===Or,isOdd:e=>(e&Tr)===Tr,neg:t=>Dr(-t,e),eql:(e,t)=>e===t,sqr:t=>Dr(t*t,e),add:(t,n)=>Dr(t+n,e),sub:(t,n)=>Dr(t-n,e),mul:(t,n)=>Dr(t*n,e),pow:(e,t)=>Hr(a,e,t),div:(t,n)=>Dr(t*jr(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>jr(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>zr(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,Lr.numberToBytesLE)(e,o):(0,Lr.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?(0,Lr.bytesToNumberLE)(e):(0,Lr.bytesToNumberBE)(e)}});return Object.freeze(a)},cr.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},cr.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},cr.hashToPrivateScalar=function(e,t,n=!1){const r=(e=(0,Lr.ensureBytes)("privateHash",e)).length,i=Vr(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return Dr(n?(0,Lr.bytesToNumberLE)(e):(0,Lr.bytesToNumberBE)(e),t-Tr)+Tr},cr.getFieldBytesLength=Wr,cr.getMinHashLength=Gr,cr.mapHashToField=function(e,t,n=!1){const r=e.length,i=Wr(t),o=Gr(t);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=Dr(n?(0,Lr.bytesToNumberBE)(e):(0,Lr.bytesToNumberLE)(e),t-Tr)+Tr;return n?(0,Lr.numberToBytesLE)(s,i):(0,Lr.numberToBytesBE)(s,i)};const Lr=lr,Or=BigInt(0),Tr=BigInt(1),Rr=BigInt(2),Pr=BigInt(3),Ir=BigInt(4),Nr=BigInt(5),Br=BigInt(8);function Dr(e,t){const n=e%t;return n>=Or?n:t+n}function $r(e,t,n){if(n<=Or||t<Or)throw new Error("Expected power/modulo > 0");if(n===Tr)return Or;let r=Tr;for(;t>Or;)t&Tr&&(r=r*e%n),e=e*e%n,t>>=Tr;return r}function jr(e,t){if(e===Or||t<=Or)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Dr(e,t),r=t,i=Or,o=Tr;for(;n!==Or;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Tr)throw new Error("invert: does not exist");return Dr(i,t)}function Kr(e){const t=(e-Tr)/Rr;let n,r,i;for(n=e-Tr,r=0;n%Rr===Or;n/=Rr,r++);for(i=Rr;i<e&&$r(i,t,e)!==e-Tr;i++);if(1===r){const t=(e+Tr)/Ir;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const o=(n+Tr)/Rr;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(s,o),d=e.pow(s,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Tr<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),a=t}return l}}function Ur(e){if(e%Ir===Pr){const t=(e+Tr)/Ir;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%Br===Nr){const t=(e-Nr)/Br;return function(e,n){const r=e.mul(n,Rr),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Rr),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return Kr(e)}BigInt(9),BigInt(16),cr.isNegativeLE=(e,t)=>(Dr(e,t)&Tr)===Tr;const Fr=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hr(e,t,n){if(n<Or)throw new Error("Expected power > 0");if(n===Or)return e.ONE;if(n===Tr)return t;let r=e.ONE,i=t;for(;n>Or;)n&Tr&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Tr;return r}function zr(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function qr(e){const t=(e-Tr)/Rr;return(e,n)=>e.pow(n,t)}function Vr(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Wr(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Gr(e){const t=Wr(e);return t+Math.ceil(t/2)}Object.defineProperty(ar,"__esModule",{value:!0}),ar.wNAF=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>{if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error(`Wrong window size=${e}, should be [1..${t}]`)},i=e=>(r(e),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>Jr;)n&Xr&&(r=r.add(i)),i=i.double(),n>>=Xr;return r},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,r,o){const{windows:s,windowSize:a}=i(t);let c=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),u=2**t,h=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let i=Number(o&d);o>>=h,i>a&&(i-=u,o+=Xr);const s=t,f=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?l=l.add(n(p,r[s])):c=c.add(n(g,r[f]))}return{p:c,f:l}},wNAFCached(e,t,n){const r=ei.get(e)||1;let i=Qr.get(e);return i||(i=this.precomputeWindow(e,r),1!==r&&Qr.set(e,n(i))),this.wNAF(r,i,t)},setWindowSize(e,t){r(t),ei.set(e,t),Qr.delete(e)}}},ar.pippenger=function(e,t,n,r){if(!Array.isArray(n)||!Array.isArray(r)||r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");r.forEach(((e,n)=>{if(!t.isValid(e))throw new Error(`wrong scalar at index ${n}`)})),n.forEach(((t,n)=>{if(!(t instanceof e))throw new Error(`wrong point at index ${n}`)}));const i=(0,Zr.bitLen)(BigInt(n.length)),o=i>12?i-3:i>4?i-2:i?2:1,s=(1<<o)-1,a=new Array(s+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/o)*o;let l=e.ZERO;for(let t=c;t>=0;t-=o){a.fill(e.ZERO);for(let e=0;e<r.length;e++){const i=r[e],o=Number(i>>BigInt(t)&BigInt(s));a[o]=a[o].add(n[e])}let i=e.ZERO;for(let t=a.length-1,n=e.ZERO;t>0;t--)n=n.add(a[t]),i=i.add(n);if(l=l.add(i),0!==t)for(let e=0;e<o;e++)l=l.double()}return l},ar.validateBasic=function(e){return(0,Yr.validateField)(e.Fp),(0,Zr.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Yr.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};const Yr=cr,Zr=lr,Jr=BigInt(0),Xr=BigInt(1),Qr=new WeakMap,ei=new WeakMap;Object.defineProperty(sr,"__esModule",{value:!0}),sr.twistedEdwards=function(e){const t=function(e){const t=(0,ti.validateBasic)(e);return ri.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,l=ai<<BigInt(8*a)-si,d=n.create,u=(0,ni.Field)(t.n,t.nBitLength),h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(e){return{isValid:!1,value:oi}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if((0,ii.abool)("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){ri.aInRange("coordinate "+e,t,oi,l)}function m(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const y=(0,ii.memoized)(((e,t)=>{const{ex:r,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?ci:n.inv(o));const a=d(r*t),c=d(i*t),l=d(o*t);if(s)return{x:oi,y:si};if(l!==si)throw new Error("invZ was invalid");return{x:a,y:c}})),v=(0,ii.memoized)((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=d(i*i),l=d(o*o),u=d(s*s),h=d(u*u),f=d(c*n);if(d(u*d(f+l))!==d(h+d(r*d(c*l))))throw new Error("bad point: equation left != right (1)");if(d(i*o)!==d(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{constructor(e,t,n,r){this.ex=e,this.ey=t,this.ez=n,this.et=r,g("x",e),g("y",t),g("z",n),g("t",r),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof b)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new b(t,n,si,d(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(b.fromAffine)}static msm(e,t){return(0,ti.pippenger)(b,u,e,t)}_setWindowSize(e){C.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){m(e);const{ex:t,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=e,a=d(t*s),c=d(i*r),l=d(n*s),u=d(o*r);return a===c&&l===u}is0(){return this.equals(b.ZERO)}negate(){return new b(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:i}=this,o=d(n*n),s=d(r*r),a=d(ai*d(i*i)),c=d(e*o),l=n+r,u=d(d(l*l)-o-s),h=c+s,f=h-a,p=c-s,g=d(u*f),m=d(h*p),y=d(u*p),v=d(f*h);return new b(g,m,v,y)}add(e){m(e);const{a:n,d:r}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:l,ez:u,et:h}=e;if(n===BigInt(-1)){const e=d((o-i)*(l+c)),t=d((o+i)*(l-c)),n=d(t-e);if(n===oi)return this.double();const r=d(s*ai*h),f=d(a*ai*u),p=f+r,g=t+e,m=f-r,y=d(p*n),v=d(g*m),w=d(p*m),E=d(n*g);return new b(y,v,E,w)}const f=d(i*c),p=d(o*l),g=d(a*r*h),y=d(s*u),v=d((i+o)*(c+l)-f-p),w=y-g,E=y+g,C=d(p-n*f),_=d(v*w),S=d(E*C),k=d(v*C),x=d(w*E);return new b(_,S,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return C.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;ri.aInRange("scalar",t,si,r);const{p:n,f:i}=this.wNAF(t);return b.normalizeZ([n,i])[0]}multiplyUnsafe(e){const t=e;return ri.aInRange("scalar",t,oi,r),t===oi?E:this.equals(E)||t===si?this:this.equals(w)?this.wNAF(t).p:C.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return C.unsafeLadder(this,r).is0()}toAffine(e){return y(this,e)}clearCofactor(){const{h:e}=t;return e===si?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:i,a:o}=t,s=n.BYTES;e=(0,ii.ensureBytes)("pointHex",e,s),(0,ii.abool)("zip215",r);const a=e.slice(),c=e[s-1];a[s-1]=-129&c;const u=ri.bytesToNumberLE(a),f=r?l:n.ORDER;ri.aInRange("pointHex.y",u,oi,f);const p=d(u*u),g=d(p-si),m=d(i*p-o);let{isValid:y,value:v}=h(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const w=(v&si)===si,E=0!=(128&c);if(!r&&v===oi&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==w&&(v=d(-v)),b.fromAffine({x:v,y:u})}static fromPrivateKey(e){return k(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=ri.numberToBytesLE(t,n.BYTES);return r[r.length-1]|=e&si?128:0,r}toHex(){return ri.bytesToHex(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,si,d(t.Gx*t.Gy)),b.ZERO=new b(oi,si,si,oi);const{BASE:w,ZERO:E}=b,C=(0,ti.wNAF)(b,8*a);function _(e){return(0,ni.mod)(e,r)}function S(e){return _(ri.bytesToNumberLE(e))}function k(e){const t=a;e=(0,ii.ensureBytes)("private key",e,t);const n=(0,ii.ensureBytes)("hashed private key",o(e),2*t),r=f(n.slice(0,t)),i=n.slice(t,2*t),s=S(r),c=w.multiply(s),l=c.toRawBytes();return{head:r,prefix:i,scalar:s,point:c,pointBytes:l}}function x(e=new Uint8Array,...t){const n=ri.concatBytes(...t);return S(o(p(n,(0,ii.ensureBytes)("context",e),!!i)))}const A=li;w._setWindowSize(8);const M={getExtendedPublicKey:k,randomPrivateKey:()=>s(n.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};return{CURVE:t,getPublicKey:function(e){return k(e).pointBytes},sign:function(e,t,o={}){e=(0,ii.ensureBytes)("message",e),i&&(e=i(e));const{prefix:s,scalar:c,pointBytes:l}=k(t),d=x(o.context,s,e),u=w.multiply(d).toRawBytes(),h=_(d+x(o.context,u,l,e)*c);ri.aInRange("signature.s",h,oi,r);const f=ri.concatBytes(u,ri.numberToBytesLE(h,n.BYTES));return(0,ii.ensureBytes)("result",f,2*a)},verify:function(e,t,r,o=A){const{context:s,zip215:a}=o,c=n.BYTES;e=(0,ii.ensureBytes)("signature",e,2*c),t=(0,ii.ensureBytes)("message",t),void 0!==a&&(0,ii.abool)("zip215",a),i&&(t=i(t));const l=ri.bytesToNumberLE(e.slice(c,2*c));let d,u,h;try{d=b.fromHex(r,a),u=b.fromHex(e.slice(0,c),a),h=w.multiplyUnsafe(l)}catch(e){return!1}if(!a&&d.isSmallOrder())return!1;const f=x(s,u.toRawBytes(),d.toRawBytes(),t);return u.add(d.multiplyUnsafe(f)).subtract(h).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:M}};const ti=ar,ni=cr,ri=lr,ii=lr,oi=BigInt(0),si=BigInt(1),ai=BigInt(2),ci=BigInt(8),li={zip215:!0};var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.expand_message_xmd=yi,di.expand_message_xof=vi,di.hash_to_field=bi,di.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},di.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=bi(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=bi(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error(`mapToCurve: expected array of bigints, got ${e} in array`);const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const ui=cr,hi=lr,fi=hi.bytesToNumberBE;function pi(e,t){if(mi(e),mi(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function gi(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function mi(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function yi(e,t,n,r){(0,hi.abytes)(e),(0,hi.abytes)(t),mi(n),t.length>255&&(t=r((0,hi.concatBytes)((0,hi.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=r,s=Math.ceil(n/i);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=(0,hi.concatBytes)(t,pi(t.length,1)),c=pi(0,o),l=pi(n,2),d=new Array(s),u=r((0,hi.concatBytes)(c,e,l,pi(0,1),a));d[0]=r((0,hi.concatBytes)(u,pi(1,1),a));for(let e=1;e<=s;e++){const t=[gi(u,d[e-1]),pi(e+1,1),a];d[e]=r((0,hi.concatBytes)(...t))}return(0,hi.concatBytes)(...d).slice(0,n)}function vi(e,t,n,r,i){if((0,hi.abytes)(e),(0,hi.abytes)(t),mi(n),t.length>255){const e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update((0,hi.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(e).update(pi(n,2)).update(t).update(pi(t.length,1)).digest()}function bi(e,t,n){(0,hi.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:o,hash:s,expand:a,DST:c}=n;(0,hi.abytes)(e),mi(t);const l="string"==typeof c?(0,hi.utf8ToBytes)(c):c,d=r.toString(2).length,u=Math.ceil((d+i)/8),h=t*o*u;let f;if("xmd"===a)f=yi(e,l,h,s);else if("xof"===a)f=vi(e,l,h,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');f=e}const p=new Array(t);for(let e=0;e<t;e++){const t=new Array(o);for(let n=0;n<o;n++){const i=u*(n+e*o),s=f.subarray(i,i+u);t[n]=(0,ui.mod)(fi(s),r)}p[e]=t}return p}var wi={};Object.defineProperty(wi,"__esModule",{value:!0}),wi.montgomery=function(e){const t=function(e){return(0,Ci.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:n}=t,r=e=>(0,Ei.mod)(e,n),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>(0,Ei.pow)(e,n-BigInt(2),n));function l(e,t,n){const i=r(e*(t-n));return[t=r(t-i),n=r(n+i)]}const d=(t.a-BigInt(2))/BigInt(4);function u(e){return(0,Ci.numberToBytesLE)(r(e),o)}function h(e,t){const h=function(e){const t=(0,Ci.ensureBytes)("u coordinate",e,o);return 32===s&&(t[31]&=127),(0,Ci.bytesToNumberLE)(t)}(t),f=function(e){const t=(0,Ci.ensureBytes)("scalar",e),n=t.length;if(n!==o&&n!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${n}`);return(0,Ci.bytesToNumberLE)(a(t))}(e),p=function(e,t){(0,Ci.aInRange)("u",e,_i,n),(0,Ci.aInRange)("scalar",t,_i,n);const o=t,s=e;let a,u=Si,h=_i,f=e,p=Si,g=_i;for(let e=BigInt(i-1);e>=_i;e--){const t=o>>e&Si;g^=t,a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1],g=t;const n=u+h,i=r(n*n),c=u-h,m=r(c*c),y=i-m,v=f+p,b=r((f-p)*n),w=r(v*c),E=b+w,C=b-w;f=r(E*E),p=r(s*r(C*C)),u=r(i*m),h=r(y*(i+r(d*y)))}a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1];const m=c(h);return r(u*m)}(h,f);if(p===_i)throw new Error("Invalid private or public key received");return u(p)}const f=u(t.Gu);function p(e){return h(e,f)}return{scalarMult:h,scalarMultBase:p,getSharedSecret:(e,t)=>h(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:f}};const Ei=cr,Ci=lr,_i=BigInt(0),Si=BigInt(1);!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.RistrettoPoint=e.encodeToCurve=e.hashToCurve=e.edwardsToMontgomery=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=e.ED25519_TORSION_SUBGROUP=void 0,e.edwardsToMontgomeryPub=C,e.edwardsToMontgomeryPriv=function(e){const t=w.hash(e.subarray(0,32));return w.adjustScalarBytes(t).subarray(0,32)};const t=cn,n=bn,r=sr,i=di,o=cr,s=wi,a=lr,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),d=BigInt(0),u=BigInt(1),h=BigInt(2),f=BigInt(3),p=BigInt(5),g=BigInt(8);function m(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),s=c,a=e*e%s*e%s,l=(0,o.pow2)(a,h,s)*a%s,d=(0,o.pow2)(l,u,s)*e%s,f=(0,o.pow2)(d,p,s)*d%s,g=(0,o.pow2)(f,t,s)*f%s,m=(0,o.pow2)(g,n,s)*g%s,y=(0,o.pow2)(m,r,s)*m%s,v=(0,o.pow2)(y,i,s)*y%s,b=(0,o.pow2)(v,i,s)*y%s,w=(0,o.pow2)(b,t,s)*f%s;return{pow_p_5_8:(0,o.pow2)(w,h,s)*e%s,b2:a}}function y(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const n=c,r=(0,o.mod)(t*t*t,n),i=m(e*(0,o.mod)(r*r*t,n)).pow_p_5_8;let s=(0,o.mod)(e*r*i,n);const a=(0,o.mod)(t*s*s,n),d=s,u=(0,o.mod)(s*l,n),h=a===e,f=a===(0,o.mod)(-e,n),p=a===(0,o.mod)(-e*l,n);return h&&(s=d),(f||p)&&(s=u),(0,o.isNegativeLE)(s,n)&&(s=(0,o.mod)(-s,n)),{isValid:h||f,value:s}}e.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const b=(0,o.Field)(c,void 0,!0),w={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:b,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:g,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:t.sha512,randomBytes:n.randomBytes,adjustScalarBytes:y,uvRatio:v};function E(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function C(t){const{y:n}=e.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return b.toBytes(b.create((r+n)*b.inv(r-n)))}e.ed25519=(0,r.twistedEdwards)(w),e.ed25519ctx=(0,r.twistedEdwards)({...w,domain:E}),e.ed25519ph=(0,r.twistedEdwards)(Object.assign({},w,{domain:E,prehash:t.sha512})),e.x25519=(0,s.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=c,{pow_p_5_8:n,b2:r}=m(e);return(0,o.mod)((0,o.pow2)(n,f,t)*r,t)},adjustScalarBytes:y,randomBytes:n.randomBytes}),e.edwardsToMontgomery=C;const _=(b.ORDER+f)/g,S=b.pow(h,_),k=b.sqrt(b.neg(b.ONE)),x=(0,o.FpSqrtEven)(b,b.neg(BigInt(486664)));const A=(0,i.createHasher)(e.ed25519.ExtendedPoint,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:i}=function(e){const t=(b.ORDER-p)/g,n=BigInt(486662);let r=b.sqr(e);r=b.mul(r,h);let i=b.add(r,b.ONE),o=b.neg(n),s=b.sqr(i),a=b.mul(s,i),c=b.mul(r,n);c=b.mul(c,o),c=b.add(c,s),c=b.mul(c,o);let l=b.sqr(a);s=b.sqr(l),l=b.mul(l,a),l=b.mul(l,c),s=b.mul(s,l);let d=b.pow(s,t);d=b.mul(d,l);let f=b.mul(d,k);s=b.sqr(d),s=b.mul(s,a);let m=b.eql(s,c),y=b.cmov(f,d,m),v=b.mul(o,r),w=b.mul(d,e);w=b.mul(w,S);let E=b.mul(w,k),C=b.mul(c,r);s=b.sqr(w),s=b.mul(s,a);let _=b.eql(s,C),x=b.cmov(E,w,_);s=b.sqr(y),s=b.mul(s,a);let A=b.eql(s,c),M=b.cmov(v,o,A),L=b.cmov(x,y,A),O=b.isOdd(L);return L=b.cmov(L,b.neg(L),A!==O),{xMn:M,xMd:i,yMn:L,yMd:u}}(e);let o=b.mul(t,i);o=b.mul(o,x);let s=b.mul(n,r),a=b.sub(t,n),c=b.add(t,n),l=b.mul(s,c),d=b.eql(l,b.ZERO);o=b.cmov(o,b.ZERO,d),s=b.cmov(s,b.ONE,d),a=b.cmov(a,b.ONE,d),c=b.cmov(c,b.ONE,d);const f=b.invertBatch([s,c]);return{x:b.mul(o,f[0]),y:b.mul(a,f[1])}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:t.sha512});function M(e){if(!(e instanceof $))throw new Error("RistrettoPoint expected")}e.hashToCurve=A.hashToCurve,e.encodeToCurve=A.encodeToCurve;const L=l,O=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),T=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),P=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),I=e=>v(u,e),N=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),B=t=>e.ed25519.CURVE.Fp.create((0,a.bytesToNumberLE)(t)&N);function D(t){const{d:n}=e.ed25519.CURVE,r=e.ed25519.CURVE.Fp.ORDER,i=e.ed25519.CURVE.Fp.create,s=i(L*t*t),a=i((s+u)*R);let c=BigInt(-1);const l=i((c-n*s)*i(s+n));let{isValid:d,value:h}=v(a,l),f=i(h*t);(0,o.isNegativeLE)(f,r)||(f=i(-f)),d||(h=f),d||(c=s);const p=i(c*(s-u)*P-l),g=h*h,m=i((h+h)*l),y=i(p*O),b=i(u-g),w=i(u+g);return new e.ed25519.ExtendedPoint(i(m*w),i(b*y),i(y*w),i(m*b))}class ${constructor(e){this.ep=e}static fromAffine(t){return new $(e.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(e){e=(0,a.ensureBytes)("ristrettoHash",e,64);const t=D(B(e.slice(0,32))),n=D(B(e.slice(32,64)));return new $(t.add(n))}static fromHex(t){t=(0,a.ensureBytes)("ristrettoHex",t,32);const{a:n,d:r}=e.ed25519.CURVE,i=e.ed25519.CURVE.Fp.ORDER,s=e.ed25519.CURVE.Fp.create,c="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",l=B(t);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(l,32),t)||(0,o.isNegativeLE)(l,i))throw new Error(c);const h=s(l*l),f=s(u+n*h),p=s(u-n*h),g=s(f*f),m=s(p*p),y=s(n*r*g-m),{isValid:v,value:b}=I(s(y*m)),w=s(b*p),E=s(b*w*y);let C=s((l+l)*w);(0,o.isNegativeLE)(C,i)&&(C=s(-C));const _=s(f*E),S=s(C*_);if(!v||(0,o.isNegativeLE)(S,i)||_===d)throw new Error(c);return new $(new e.ed25519.ExtendedPoint(C,_,u,S))}toRawBytes(){let{ex:t,ey:n,ez:r,et:i}=this.ep;const s=e.ed25519.CURVE.Fp.ORDER,c=e.ed25519.CURVE.Fp.create,l=c(c(r+n)*c(r-n)),d=c(t*n),u=c(d*d),{value:h}=I(c(l*u)),f=c(h*l),p=c(h*d),g=c(f*p*i);let m;if((0,o.isNegativeLE)(i*g,s)){let e=c(n*L),r=c(t*L);t=e,n=r,m=c(f*T)}else m=p;(0,o.isNegativeLE)(t*g,s)&&(n=c(-n));let y=c((r-n)*m);return(0,o.isNegativeLE)(y,s)&&(y=c(-y)),(0,a.numberToBytesLE)(y,32)}toHex(){return(0,a.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const{ex:n,ey:r}=this.ep,{ex:i,ey:o}=t.ep,s=e.ed25519.CURVE.Fp.create,a=s(n*o)===s(r*i),c=s(r*o)===s(n*i);return a||c}add(e){return M(e),new $(this.ep.add(e.ep))}subtract(e){return M(e),new $(this.ep.subtract(e.ep))}multiply(e){return new $(this.ep.multiply(e))}multiplyUnsafe(e){return new $(this.ep.multiplyUnsafe(e))}double(){return new $(this.ep.double())}negate(){return new $(this.ep.negate())}}e.RistrettoPoint=($.BASE||($.BASE=new $(e.ed25519.ExtendedPoint.BASE)),$.ZERO||($.ZERO=new $(e.ed25519.ExtendedPoint.ZERO)),$),e.hashToRistretto255=(e,r)=>{const o=r.DST,s="string"==typeof o?(0,n.utf8ToBytes)(o):o,a=(0,i.expand_message_xmd)(e,s,64,t.sha512);return $.hashToCurve(a)},e.hash_to_ristretto255=e.hashToRistretto255}(an);var ki={},xi={};Object.defineProperty(xi,"__esModule",{value:!0}),xi.sha224=xi.sha256=xi.SHA256=void 0;const Ai=ln,Mi=bn,Li=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ti=new Uint32Array(64);class Ri extends Ai.HashMD{constructor(){super(64,32,8,!1),this.A=0|Oi[0],this.B=0|Oi[1],this.C=0|Oi[2],this.D=0|Oi[3],this.E=0|Oi[4],this.F=0|Oi[5],this.G=0|Oi[6],this.H=0|Oi[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Ti[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ti[e-15],n=Ti[e-2],r=(0,Mi.rotr)(t,7)^(0,Mi.rotr)(t,18)^t>>>3,i=(0,Mi.rotr)(n,17)^(0,Mi.rotr)(n,19)^n>>>10;Ti[e]=i+Ti[e-7]+r+Ti[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+((0,Mi.rotr)(s,6)^(0,Mi.rotr)(s,11)^(0,Mi.rotr)(s,25))+(0,Ai.Chi)(s,a,c)+Li[e]+Ti[e]|0,d=((0,Mi.rotr)(n,2)^(0,Mi.rotr)(n,13)^(0,Mi.rotr)(n,22))+(0,Ai.Maj)(n,r,i)|0;l=c,c=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,o,s,a,c,l)}roundClean(){Ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}xi.SHA256=Ri;class Pi extends Ri{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}xi.sha256=(0,Mi.wrapConstructor)((()=>new Ri)),xi.sha224=(0,Mi.wrapConstructor)((()=>new Pi));var Ii={},Ni={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=dn,n=bn;class r extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,n.toBytes)(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);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(0,t.exists)(this),this.iHash.update(e),this}digestInto(e){(0,t.exists)(this),(0,t.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=r,e.hmac=(e,t,n)=>new r(e,t).update(n).digest(),e.hmac.create=(e,t)=>new r(e,t)}(Ni);var Bi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=f,e.weierstrass=function(s){const a=function(e){const n=(0,t.validateBasic)(e);return r.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}(s),{Fp:d,n:u}=a,h=d.BYTES+1,p=2*d.BYTES+1;function g(e){return n.mod(e,u)}function m(e){return n.invert(e,u)}const{ProjectivePoint:y,normPrivateKeyToScalar:v,weierstrassEquation:b,isWithinCurveOrder:w}=f({...a,toBytes(e,t,n){const o=t.toAffine(),s=d.toBytes(o.x),a=r.concatBytes;return(0,i.abool)("isCompressed",n),n?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,d.toBytes(o.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===p&&4===n)return{x:d.fromBytes(i.subarray(0,d.BYTES)),y:d.fromBytes(i.subarray(d.BYTES,2*d.BYTES))};throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${p} uncompressed bytes`)}{const t=r.bytesToNumberBE(i);if(!r.inRange(t,l,d.ORDER))throw new Error("Point is not on curve");const o=b(t);let s;try{s=d.sqrt(o)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&n)!=((s&l)===l)&&(s=d.neg(s)),{x:t,y:s}}}}),E=e=>r.bytesToHex(r.numberToBytesBE(e,a.nByteLength));function C(e){return e>u>>l}const _=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=a.nByteLength;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new S(_(e,0,t),_(e,t,2*t))}static fromDER(t){const{r:n,s:r}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new S(n,r)}assertValidity(){r.aInRange("r",this.r,l,u),r.aInRange("s",this.s,l,u)}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:n,recovery:r}=this,o=M((0,i.ensureBytes)("msgHash",e));if(null==r||![0,1,2,3].includes(r))throw new Error("recovery id invalid");const s=2===r||3===r?t+a.n:t;if(s>=d.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&r)?"02":"03",l=y.fromHex(c+E(s)),u=m(s),h=g(-o*u),f=g(n*u),p=y.BASE.multiplyAndAddUnsafe(l,h,f);if(!p)throw new Error("point at infinify");return p.assertValidity(),p}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,g(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const k={isValidPrivateKey(e){try{return v(e),!0}catch(e){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const e=n.getMinHashLength(a.n);return n.mapHashToField(a.randomBytes(e),a.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function x(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===h||i===p:n?i===2*h||i===2*p:e instanceof y}const A=a.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-a.nBitLength;return n>0?t>>BigInt(n):t},M=a.bits2int_modN||function(e){return g(A(e))},L=r.bitMask(a.nBitLength);function O(e){return r.aInRange(`num < 2^${a.nBitLength}`,e,c,L),r.numberToBytesBE(e,a.nByteLength)}function T(e,t,n=R){if(["recovered","canonical"].some((e=>e in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=a;let{lowS:h,prehash:f,extraEntropy:p}=n;null==h&&(h=!0),e=(0,i.ensureBytes)("msgHash",e),o(n),f&&(e=(0,i.ensureBytes)("prehashed msgHash",s(e)));const b=M(e),E=v(t),_=[O(E),O(b)];if(null!=p&&!1!==p){const e=!0===p?u(d.BYTES):p;_.push((0,i.ensureBytes)("extraEntropy",e))}const k=r.concatBytes(..._),x=b;return{seed:k,k2sig:function(e){const t=A(e);if(!w(t))return;const n=m(t),r=y.BASE.multiply(t).toAffine(),i=g(r.x);if(i===c)return;const o=g(n*g(x+i*E));if(o===c)return;let s=(r.x===i?0:2)|Number(r.y&l),a=o;return h&&C(o)&&(a=function(e){return C(e)?g(-e):e}(o),s^=1),new S(i,a,s)}}}const R={lowS:a.lowS,prehash:!1},P={lowS:a.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:a,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(x(e))throw new Error("first arg must be private key");if(!x(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(v(e)).toRawBytes(n)},sign:function(e,t,n=R){const{seed:i,k2sig:o}=T(e,t,n),s=a;return r.createHmacDrbg(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,n,s,c=P){const l=t;if(n=(0,i.ensureBytes)("msgHash",n),s=(0,i.ensureBytes)("publicKey",s),"strict"in c)throw new Error("options.strict was renamed to lowS");o(c);const{lowS:d,prehash:u}=c;let h,f;try{if("string"==typeof l||r.isBytes(l))try{h=S.fromDER(l)}catch(t){if(!(t instanceof e.DER.Err))throw t;h=S.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;h=new S(e,t)}}f=y.fromHex(s)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(d&&h.hasHighS())return!1;u&&(n=a.hash(n));const{r:p,s:v}=h,b=M(n),w=m(v),E=g(b*w),C=g(p*w),_=y.BASE.multiplyAndAddUnsafe(f,E,C)?.toAffine();if(!_)return!1;return g(_.x)===p},ProjectivePoint:y,Signature:S,utils:k}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(e,t){if(n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,c,l,d,u;i=e.sqr(n),i=e.mul(i,t.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(s),l=e.sqr(a),c=e.mul(l,t.A),o=e.add(o,c),o=e.mul(o,s),l=e.mul(l,a),c=e.mul(l,t.B),o=e.add(o,c),d=e.mul(i,s);const{isValid:h,value:f}=r(o,l);u=e.mul(i,n),u=e.mul(u,f),d=e.cmov(d,s,h),u=e.cmov(u,f,h);const p=e.isOdd(n)===e.isOdd(u);return u=e.cmov(e.neg(u),u,p),d=e.div(d,a),{x:d,y:u}}};const t=ar,n=cr,r=lr,i=lr;function o(e){void 0!==e.lowS&&(0,i.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,i.abool)("prehash",e.prehash)}const{bytesToNumberBE:s,hexToBytes:a}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,n)=>{const{Err:i}=e.DER;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(1&n.length)throw new i("tlv.encode: unpadded data");const o=n.length/2,s=r.numberToHexUnpadded(o);if(s.length/2&128)throw new i("tlv.encode: long form length too big");const a=o>127?r.numberToHexUnpadded(s.length/2|128):"";return`${r.numberToHexUnpadded(t)}${a}${s}${n}`},decode(t,n){const{Err:r}=e.DER;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[i++]!==t)throw new r("tlv.decode: wrong tlv");const o=n[i++];let s=0;if(128&o){const e=127&o;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");const t=n.subarray(i,i+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)s=s<<8|e;if(i+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const a=n.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(i+s)}}},_int:{encode(t){const{Err:n}=e.DER;if(t<c)throw new n("integer: negative integers are not allowed");let i=r.numberToHexUnpadded(t);if(8&Number.parseInt(i[0],16)&&(i="00"+i),1&i.length)throw new n("unexpected assertion");return i},decode(t){const{Err:n}=e.DER;if(128&t[0])throw new n("Invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new n("Invalid signature integer: unnecessary leading zero");return s(t)}},toSig(t){const{Err:n,_int:i,_tlv:o}=e.DER,s="string"==typeof t?a(t):t;r.abytes(s);const{v:c,l:l}=o.decode(48,s);if(l.length)throw new n("Invalid signature: left bytes after parsing");const{v:d,l:u}=o.decode(2,c),{v:h,l:f}=o.decode(2,u);if(f.length)throw new n("Invalid signature: left bytes after parsing");return{r:i.decode(d),s:i.decode(h)}},hexFromSig(t){const{_tlv:n,_int:r}=e.DER,i=`${n.encode(2,r.encode(t.r))}${n.encode(2,r.encode(t.s))}`;return n.encode(48,i)}};const c=BigInt(0),l=BigInt(1),d=BigInt(2),u=BigInt(3),h=BigInt(4);function f(e){const o=function(e){const n=(0,t.validateBasic)(e);r.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:i,Fp:o,a:s}=n;if(i){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof i||"bigint"!=typeof i.beta||"function"!=typeof i.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}(e),{Fp:s}=o,a=n.Field(o.n,o.nBitLength),d=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),h=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:n}=o,r=s.sqr(e),i=s.mul(r,e);return s.add(s.add(i,s.mul(e,t)),n)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function p(e){const{allowedPrivateKeyLengths:t,nByteLength:s,wrapPrivateKey:a,n:c}=o;if(t&&"bigint"!=typeof e){if(r.isBytes(e)&&(e=r.bytesToHex(e)),"string"!=typeof e||!t.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*s,"0")}let d;try{d="bigint"==typeof e?e:r.bytesToNumberBE((0,i.ensureBytes)("private key",e,s))}catch(t){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof e}`)}return a&&(d=n.mod(d,c)),r.aInRange("private key",d,l,c),d}function g(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const m=(0,i.memoized)(((e,t)=>{const{px:n,py:r,pz:i}=e;if(s.eql(i,s.ONE))return{x:n,y:r};const o=e.is0();null==t&&(t=o?s.ONE:s.inv(i));const a=s.mul(n,t),c=s.mul(r,t),l=s.mul(i,t);if(o)return{x:s.ZERO,y:s.ZERO};if(!s.eql(l,s.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),y=(0,i.memoized)((e=>{if(e.is0()){if(o.allowInfinityPoint&&!s.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=e.toAffine();if(!s.isValid(t)||!s.isValid(n))throw new Error("bad point: x or y not FE");const r=s.sqr(n),i=f(t);if(!s.eql(r,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!s.isValid(e))throw new Error("x required");if(null==t||!s.isValid(t))throw new Error("y required");if(null==n||!s.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!s.isValid(t)||!s.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const r=e=>s.eql(e,s.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(h((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(p(e))}static msm(e,n){return(0,t.pippenger)(v,a,e,n)}_setWindowSize(e){w.setWindowSize(this,e)}assertValidity(){y(this)}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,r)),l=s.eql(s.mul(n,a),s.mul(o,r));return c&&l}negate(){return new v(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,n=s.mul(t,u),{px:r,py:i,pz:a}=this;let c=s.ZERO,l=s.ZERO,d=s.ZERO,h=s.mul(r,r),f=s.mul(i,i),p=s.mul(a,a),g=s.mul(r,i);return g=s.add(g,g),d=s.mul(r,a),d=s.add(d,d),c=s.mul(e,d),l=s.mul(n,p),l=s.add(c,l),c=s.sub(f,l),l=s.add(f,l),l=s.mul(c,l),c=s.mul(g,c),d=s.mul(n,d),p=s.mul(e,p),g=s.sub(h,p),g=s.mul(e,g),g=s.add(g,d),d=s.add(h,h),h=s.add(d,h),h=s.add(h,p),h=s.mul(h,g),l=s.add(l,h),p=s.mul(i,a),p=s.add(p,p),h=s.mul(p,g),c=s.sub(c,h),d=s.mul(p,f),d=s.add(d,d),d=s.add(d,d),new v(c,l,d)}add(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:a,pz:c}=e;let l=s.ZERO,d=s.ZERO,h=s.ZERO;const f=o.a,p=s.mul(o.b,u);let m=s.mul(t,i),y=s.mul(n,a),b=s.mul(r,c),w=s.add(t,n),E=s.add(i,a);w=s.mul(w,E),E=s.add(m,y),w=s.sub(w,E),E=s.add(t,r);let C=s.add(i,c);return E=s.mul(E,C),C=s.add(m,b),E=s.sub(E,C),C=s.add(n,r),l=s.add(a,c),C=s.mul(C,l),l=s.add(y,b),C=s.sub(C,l),h=s.mul(f,E),l=s.mul(p,b),h=s.add(l,h),l=s.sub(y,h),h=s.add(y,h),d=s.mul(l,h),y=s.add(m,m),y=s.add(y,m),b=s.mul(f,b),E=s.mul(p,E),y=s.add(y,b),b=s.sub(m,b),b=s.mul(f,b),E=s.add(E,b),m=s.mul(y,E),d=s.add(d,m),m=s.mul(C,E),l=s.mul(w,l),l=s.sub(l,m),m=s.mul(w,y),h=s.mul(C,h),h=s.add(h,m),new v(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return w.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){r.aInRange("scalar",e,c,o.n);const t=v.ZERO;if(e===c)return t;if(e===l)return this;const{endo:n}=o;if(!n)return w.unsafeLadder(this,e);let{k1neg:i,k1:a,k2neg:d,k2:u}=n.splitScalar(e),h=t,f=t,p=this;for(;a>c||u>c;)a&l&&(h=h.add(p)),u&l&&(f=f.add(p)),p=p.double(),a>>=l,u>>=l;return i&&(h=h.negate()),d&&(f=f.negate()),f=new v(s.mul(f.px,n.beta),f.py,f.pz),h.add(f)}multiply(e){const{endo:t,n:n}=o;let i,a;if(r.aInRange("scalar",e,l,n),t){const{k1neg:n,k1:r,k2neg:o,k2:c}=t.splitScalar(e);let{p:l,f:d}=this.wNAF(r),{p:u,f:h}=this.wNAF(c);l=w.constTimeNegate(n,l),u=w.constTimeNegate(o,u),u=new v(s.mul(u.px,t.beta),u.py,u.pz),i=l.add(u),a=d.add(h)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return v.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=v.BASE,i=(e,t)=>t!==c&&t!==l&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){return m(this,e)}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===l)return!0;if(t)return t(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===l?this:t?t(v,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),d(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),r.bytesToHex(this.toRawBytes(e))}}v.BASE=new v(o.Gx,o.Gy,s.ONE),v.ZERO=new v(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,w=(0,t.wNAF)(v,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:v,normPrivateKeyToScalar:p,weierstrassEquation:f,isWithinCurveOrder:function(e){return r.inRange(e,l,o.n)}}}function p(e,t){const n=e.ORDER;let r=c;for(let e=n-l;e%d===c;e/=d)r+=l;const i=r,o=d<<i-l-l,s=o*d,a=(n-l)/s,f=(a-l)/d,p=s-l,g=o,m=e.pow(t,a),y=e.pow(t,(a+l)/d);let v=(t,n)=>{let r=m,o=e.pow(n,p),s=e.sqr(o);s=e.mul(s,n);let a=e.mul(t,s);a=e.pow(a,f),a=e.mul(a,o),o=e.mul(a,n),s=e.mul(a,t);let c=e.mul(s,o);a=e.pow(c,g);let u=e.eql(a,e.ONE);o=e.mul(s,y),a=e.mul(c,r),s=e.cmov(o,s,u),c=e.cmov(a,c,u);for(let t=i;t>l;t--){let n=t-d;n=d<<n-l;let i=e.pow(c,n);const a=e.eql(i,e.ONE);o=e.mul(s,r),r=e.mul(r,r),i=e.mul(c,r),s=e.cmov(o,s,a),c=e.cmov(i,c,a)}return{isValid:u,value:s}};if(e.ORDER%h===u){const n=(e.ORDER-u)/h,r=e.sqrt(e.neg(t));v=(t,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,n);a=e.mul(a,s);const c=e.mul(a,r),l=e.mul(e.sqr(a),i),d=e.eql(l,t);return{isValid:d,value:e.cmov(c,a,d)}}}return v}}(Bi),Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.getHash=Ki,Ii.createCurve=function(e,t){const n=t=>(0,ji.weierstrass)({...e,...Ki(t)});return Object.freeze({...n(t),create:n})};const Di=Ni,$i=bn,ji=Bi;function Ki(e){return{hash:e,hmac:(t,...n)=>(0,Di.hmac)(e,t,(0,$i.concatBytes)(...n)),randomBytes:$i.randomBytes}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const t=xi,n=bn,r=Ii,i=di,o=cr,s=lr,a=Bi,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(1),u=BigInt(2),h=(e,t)=>(e+t/u)/t;function f(e){const t=c,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),l=BigInt(44),d=BigInt(88),h=e*e*e%t,f=h*h*e%t,g=(0,o.pow2)(f,n,t)*f%t,m=(0,o.pow2)(g,n,t)*f%t,y=(0,o.pow2)(m,u,t)*h%t,v=(0,o.pow2)(y,i,t)*y%t,b=(0,o.pow2)(v,s,t)*v%t,w=(0,o.pow2)(b,l,t)*b%t,E=(0,o.pow2)(w,d,t)*w%t,C=(0,o.pow2)(E,l,t)*b%t,_=(0,o.pow2)(C,n,t)*f%t,S=(0,o.pow2)(_,a,t)*v%t,k=(0,o.pow2)(S,r,t)*h%t,x=(0,o.pow2)(k,u,t);if(!p.eql(p.sqr(x),e))throw new Error("Cannot find square root");return x}const p=(0,o.Field)(c,void 0,void 0,{sqrt:f});e.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=h(s*e,t),u=h(-r*e,t);let f=(0,o.mod)(e-c*n-u*i,t),p=(0,o.mod)(-c*r-u*s,t);const g=f>a,m=p>a;if(g&&(f=t-f),m&&(p=t-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:f,k2neg:m,k2:p}}}},t.sha256);const g=BigInt(0),m={};function y(e,...n){let r=m[e];if(void 0===r){const n=(0,t.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=(0,s.concatBytes)(n,n),m[e]=r}return(0,t.sha256)((0,s.concatBytes)(r,...n))}const v=e=>e.toRawBytes(!0).slice(1),b=e=>(0,s.numberToBytesBE)(e,32),w=e=>(0,o.mod)(e,c),E=e=>(0,o.mod)(e,l),C=e.secp256k1.ProjectivePoint,_=(e,t,n)=>C.BASE.multiplyAndAddUnsafe(e,t,n);function S(t){let n=e.secp256k1.utils.normPrivateKeyToScalar(t),r=C.fromPrivateKey(n);return{scalar:r.hasEvenY()?n:E(-n),bytes:v(r)}}function k(e){(0,s.aInRange)("x",e,d,c);const t=w(e*e);let n=f(w(t*e+BigInt(7)));n%u!==g&&(n=w(-n));const r=new C(e,n,d);return r.assertValidity(),r}const x=s.bytesToNumberBE;function A(...e){return E(x(y("BIP0340/challenge",...e)))}function M(e,t,n){const r=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),o=(0,s.ensureBytes)("publicKey",n,32);try{const e=k(x(o)),t=x(r.subarray(0,32));if(!(0,s.inRange)(t,d,c))return!1;const n=x(r.subarray(32,64));if(!(0,s.inRange)(n,d,l))return!1;const a=A(b(t),v(e),i),u=_(e,n,E(-a));return!(!u||!u.hasEvenY()||u.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:function(e){return S(e).bytes},sign:function(e,t,r=(0,n.randomBytes)(32)){const i=(0,s.ensureBytes)("message",e),{bytes:o,scalar:a}=S(t),c=(0,s.ensureBytes)("auxRand",r,32),l=b(a^x(y("BIP0340/aux",c))),d=y("BIP0340/nonce",l,o,i),u=E(x(d));if(u===g)throw new Error("sign failed: k is zero");const{bytes:h,scalar:f}=S(u),p=A(h,o,i),m=new Uint8Array(64);if(m.set(h,0),m.set(b(E(f+p*a)),32),!M(m,i,o))throw new Error("sign: Invalid signature produced");return m},verify:M,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:k,pointToBytes:v,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,taggedHash:y,mod:o.mod}};const L=(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),O=(0,a.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}),T=(0,i.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:n}=O(p.create(e[0]));return L(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256});e.hashToCurve=T.hashToCurve,e.encodeToCurve=T.encodeToCurve}(ki);var Ui={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeHex=e.remove0x=void 0;var t=Ft;e.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},e.decodeHex=function(n){return(0,t.hexToBytes)((0,e.remove0x)(n))}}(Ui),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=on,n=an,r=ki,i=Xt,o=Qt,s=Ui;function a(e,t,i,o){if("secp256k1"===e)return t(r.secp256k1);if("x25519"===e)return i(n.x25519);if("ed25519"===e)return o(n.ed25519);throw new Error("Not implemented")}e.getValidSecret=function(){var n;do{n=(0,t.randomBytes)(o.SECRET_KEY_LENGTH)}while(!(0,e.isValidPrivateKey)(n));return n},e.isValidPrivateKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.utils.isValidPrivateKey(e)}),(function(){return!0}),(function(){return!0}))},e.getPublicKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},e.getSharedPoint=function(e,t,n){return a((0,i.ellipticCurve)(),(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return l(n,e,t)}))},e.convertPublicKeyFormat=function(e,t){return a((0,i.ellipticCurve)(),(function(n){return n.getSharedSecret(BigInt(1),e,t)}),(function(){return e}),(function(){return e}))},e.hexToPublicKey=function(e){var t=(0,s.decodeHex)(e);return a((0,i.ellipticCurve)(),(function(){return c(t)}),(function(){return t}),(function(){return t}))};var c=function(e){if(e.length===o.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},l=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.ExtendedPoint.fromHex(n).multiply(r).toRawBytes()}}(rn);var Fi={},Hi={};Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.hkdf=void 0,Hi.extract=Wi,Hi.expand=Zi;const zi=dn,qi=bn,Vi=Ni;function Wi(e,t,n){return(0,zi.hash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,Vi.hmac)(e,(0,qi.toBytes)(n),(0,qi.toBytes)(t))}const Gi=new Uint8Array([0]),Yi=new Uint8Array;function Zi(e,t,n,r=32){if((0,zi.hash)(e),(0,zi.number)(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=Yi);const o=new Uint8Array(i*e.outputLen),s=Vi.hmac.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let t=0;t<i;t++)Gi[0]=t+1,a.update(0===t?Yi:c).update(n).update(Gi).digestInto(c),o.set(c,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Gi.fill(0),o.slice(0,r)}Hi.hkdf=(e,t,n,r,i)=>Zi(e,Wi(e,t,n),r,i),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=Ft,n=Hi,r=xi;e.deriveKey=function(e,t,i){return(0,n.hkdf)(r.sha256,e,t,i,32)},e.getSharedKey=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0,e.deriveKey)(t.concatBytes.apply(void 0,n))}}(Fi);var Ji={},Xi={},Qi={},eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.polyval=eo.ghash=void 0,eo._toGHASHKey=ao;const to=Ht,no=Ft,ro=16,io=new Uint8Array(16),oo=(0,no.u32)(io),so=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function ao(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class co{constructor(e,t){this.blockLen=ro,this.outputLen=ro,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,no.toBytes)(e),(0,to.bytes)(e,16);const n=(0,no.createView)(e);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let e=0;e<128;e++)a.push({s0:so(r),s1:so(i),s2:so(o),s3:so(s)}),({s0:r,s1:i,s2:o,s3:s}={s3:(d=o)<<31|(u=s)>>>1,s2:(l=i)<<31|d>>>1,s1:(c=r)<<31|l>>>1,s0:c>>>1^225<<24&-(1&u)});var c,l,d,u;const h=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(h))throw new Error(`ghash: wrong window size=${h}, should be 2, 4 or 8`);this.W=h;const f=128/h,p=this.windowSize=2**h,g=[];for(let e=0;e<f;e++)for(let t=0;t<p;t++){let n=0,r=0,i=0,o=0;for(let s=0;s<h;s++){if(!(t>>>h-s-1&1))continue;const{s0:c,s1:l,s2:d,s3:u}=a[h*e+s];n^=c,r^=l,i^=d,o^=u}g.push({s0:n,s1:r,s2:i,s3:o})}this.t=g}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:o,windowSize:s}=this;let a=0,c=0,l=0,d=0;const u=(1<<i)-1;let h=0;for(const f of[e,t,n,r])for(let e=0;e<4;e++){const t=f>>>8*e&255;for(let e=8/i-1;e>=0;e--){const n=t>>>i*e&u,{s0:r,s1:f,s2:p,s3:g}=o[h*s+n];a^=r,c^=f,l^=p,d^=g,h+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=d}update(e){e=(0,no.toBytes)(e),(0,to.exists)(this);const t=(0,no.u32)(e),n=Math.floor(e.length/ro),r=e.length%ro;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return r&&(io.set(e.subarray(n*ro)),this._updateBlock(oo[0],oo[1],oo[2],oo[3]),(0,no.clean)(oo)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,to.exists)(this),(0,to.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,no.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e}digest(){const e=new Uint8Array(ro);return this.digestInto(e),this.destroy(),e}}class lo extends co{constructor(e,t){e=(0,no.toBytes)(e);const n=ao((0,no.copyBytes)(e));super(n,t),(0,no.clean)(n)}update(e){e=(0,no.toBytes)(e),(0,to.exists)(this);const t=(0,no.u32)(e),n=e.length%ro,r=Math.floor(e.length/ro);for(let e=0;e<r;e++)this._updateBlock(so(t[4*e+3]),so(t[4*e+2]),so(t[4*e+1]),so(t[4*e+0]));return n&&(io.set(e.subarray(r*ro)),this._updateBlock(so(oo[3]),so(oo[2]),so(oo[1]),so(oo[0])),(0,no.clean)(oo)),this}digestInto(e){(0,to.exists)(this),(0,to.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,no.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e.reverse()}}function uo(e){const t=(t,n)=>e(n,t.length).update((0,no.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}eo.ghash=uo(((e,t)=>new co(e,t))),eo.polyval=uo(((e,t)=>new lo(e,t))),Object.defineProperty(Qi,"__esModule",{value:!0}),Qi.unsafe=Qi.aeskwp=Qi.aeskw=Qi.siv=Qi.gcm=Qi.cfb=Qi.cbc=Qi.ecb=Qi.ctr=void 0,Qi.expandKeyLE=Lo,Qi.expandKeyDecLE=Oo;const ho=Ht,fo=eo,po=Ft,go=16,mo=new Uint8Array(go),yo=283;function vo(e){return e<<1^yo&-(e>>7)}function bo(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=vo(e);return n}const wo=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=vo(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,po.clean)(e),t})(),Eo=wo.map(((e,t)=>wo.indexOf(t))),Co=e=>e<<24|e>>>8,_o=e=>e<<8|e>>>24,So=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function ko(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(_o),i=r.map(_o),o=i.map(_o),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const d=256*t+l;s[d]=n[t]^r[l],a[d]=i[t]^o[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const xo=ko(wo,(e=>bo(e,3)<<24|e<<16|e<<8|bo(e,2))),Ao=ko(Eo,(e=>bo(e,11)<<24|bo(e,13)<<16|bo(e,9)<<8|bo(e,14))),Mo=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=vo(n))e[t]=n;return e})();function Lo(e){(0,ho.bytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=xo,r=[];(0,po.isAligned32)(e)||r.push(e=(0,po.copyBytes)(e));const i=(0,po.u32)(e),o=i.length,s=e=>Ro(n,e,e,e,e),a=new Uint32Array(t+28);a.set(i);for(let e=o;e<a.length;e++){let t=a[e-1];e%o==0?t=s(Co(t))^Mo[e/o-1]:o>6&&e%o==4&&(t=s(t)),a[e]=a[e-o]^t}return(0,po.clean)(...r),a}function Oo(e){const t=Lo(e),n=t.slice(),r=t.length,{sbox2:i}=xo,{T0:o,T1:s,T2:a,T3:c}=Ao;for(let e=0;e<r;e+=4)for(let i=0;i<4;i++)n[e+i]=t[r-e-4+i];(0,po.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=Ro(i,t,t,t,t);n[e]=o[255&r]^s[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function To(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Ro(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function Po(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=xo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^To(s,a,t,n,r,i),l=e[c++]^To(s,a,n,r,i,t),d=e[c++]^To(s,a,r,i,t,n),u=e[c++]^To(s,a,i,t,n,r);t=o,n=l,r=d,i=u}return{s0:e[c++]^Ro(o,t,n,r,i),s1:e[c++]^Ro(o,n,r,i,t),s2:e[c++]^Ro(o,r,i,t,n),s3:e[c++]^Ro(o,i,t,n,r)}}function Io(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Ao;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^To(s,a,t,i,r,n),l=e[c++]^To(s,a,n,t,i,r),d=e[c++]^To(s,a,r,n,t,i),u=e[c++]^To(s,a,i,r,n,t);t=o,n=l,r=d,i=u}return{s0:e[c++]^Ro(o,t,i,r,n),s1:e[c++]^Ro(o,n,t,i,r),s2:e[c++]^Ro(o,r,n,t,i),s3:e[c++]^Ro(o,i,r,n,t)}}function No(e,t){if(void 0===t)return new Uint8Array(e);if((0,ho.bytes)(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);if(!(0,po.isAligned32)(t))throw new Error("unaligned dst");return t}function Bo(e,t,n,r){(0,ho.bytes)(t,go),(0,ho.bytes)(n);const i=n.length;r=No(i,r);const o=t,s=(0,po.u32)(o);let{s0:a,s1:c,s2:l,s3:d}=Po(e,s[0],s[1],s[2],s[3]);const u=(0,po.u32)(n),h=(0,po.u32)(r);for(let t=0;t+4<=u.length;t+=4){h[t+0]=u[t+0]^a,h[t+1]=u[t+1]^c,h[t+2]=u[t+2]^l,h[t+3]=u[t+3]^d;let n=1;for(let e=o.length-1;e>=0;e--)n=n+(255&o[e])|0,o[e]=255&n,n>>>=8;({s0:a,s1:c,s2:l,s3:d}=Po(e,s[0],s[1],s[2],s[3]))}const f=go*Math.floor(u.length/4);if(f<i){const e=new Uint32Array([a,c,l,d]),t=(0,po.u8)(e);for(let e=f,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,po.clean)(e)}return r}function Do(e,t,n,r,i){(0,ho.bytes)(n,go),(0,ho.bytes)(r),i=No(r.length,i);const o=n,s=(0,po.u32)(o),a=(0,po.createView)(o),c=(0,po.u32)(r),l=(0,po.u32)(i),d=t?0:12,u=r.length;let h=a.getUint32(d,t),{s0:f,s1:p,s2:g,s3:m}=Po(e,s[0],s[1],s[2],s[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^f,l[n+1]=c[n+1]^p,l[n+2]=c[n+2]^g,l[n+3]=c[n+3]^m,h=h+1>>>0,a.setUint32(d,h,t),({s0:f,s1:p,s2:g,s3:m}=Po(e,s[0],s[1],s[2],s[3]));const y=go*Math.floor(c.length/4);if(y<u){const e=new Uint32Array([f,p,g,m]),t=(0,po.u8)(e);for(let e=y,n=0;e<u;e++,n++)i[e]=r[e]^t[n];(0,po.clean)(e)}return i}function $o(e){if((0,ho.bytes)(e),e.length%go!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function jo(e,t,n){(0,ho.bytes)(e);let r=e.length;const i=r%go;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,po.isAligned32)(e)||(e=(0,po.copyBytes)(e));const o=(0,po.u32)(e);if(t){let e=go-i;e||(e=go),r+=e}const s=No(r,n);return{b:o,o:(0,po.u32)(s),out:s}}function Ko(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function Uo(e){const t=new Uint8Array(16),n=(0,po.u32)(t);t.set(e);const r=go-e.length;for(let e=go-r;e<go;e++)t[e]=r;return n}function Fo(e,t,n,r,i){const o=null==i?0:i.length,s=e.create(n,r.length+o);i&&s.update(i),s.update(r);const a=new Uint8Array(16),c=(0,po.createView)(a);i&&(0,po.setBigUint64)(c,0,BigInt(8*o),t),(0,po.setBigUint64)(c,8,BigInt(8*r.length),t),s.update(a);const l=s.digest();return(0,po.clean)(a),l}Qi.ctr=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,ho.bytes)(n),void 0!==r&&((0,ho.bytes)(r),!(0,po.isAligned32)(r)))throw new Error("unaligned destination");const i=Lo(e),o=(0,po.copyBytes)(t),s=[i,o];(0,po.isAligned32)(n)||s.push(n=(0,po.copyBytes)(n));const a=Bo(i,o,n,r);return(0,po.clean)(...s),a}return(0,ho.bytes)(e),(0,ho.bytes)(t,go),{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),Qi.ecb=(0,po.wrapCipher)({blockSize:16},(function(e,t={}){(0,ho.bytes)(e);const n=!t.disablePadding;return{encrypt(t,r){const{b:i,o:o,out:s}=jo(t,n,r),a=Lo(e);let c=0;for(;c+4<=i.length;){const{s0:e,s1:t,s2:n,s3:r}=Po(a,i[c+0],i[c+1],i[c+2],i[c+3]);o[c++]=e,o[c++]=t,o[c++]=n,o[c++]=r}if(n){const e=Uo(t.subarray(4*c)),{s0:n,s1:r,s2:i,s3:s}=Po(a,e[0],e[1],e[2],e[3]);o[c++]=n,o[c++]=r,o[c++]=i,o[c++]=s}return(0,po.clean)(a),s},decrypt(t,r){$o(t);const i=Oo(e),o=No(t.length,r),s=[i];(0,po.isAligned32)(t)||s.push(t=(0,po.copyBytes)(t));const a=(0,po.u32)(t),c=(0,po.u32)(o);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=Io(i,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,po.clean)(...s),Ko(o,n)}}})),Qi.cbc=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){(0,ho.bytes)(e),(0,ho.bytes)(t,16);const r=!n.disablePadding;return{encrypt(n,i){const o=Lo(e),{b:s,o:a,out:c}=jo(n,r,i);let l=t;const d=[o];(0,po.isAligned32)(l)||d.push(l=(0,po.copyBytes)(l));const u=(0,po.u32)(l);let h=u[0],f=u[1],p=u[2],g=u[3],m=0;for(;m+4<=s.length;)h^=s[m+0],f^=s[m+1],p^=s[m+2],g^=s[m+3],({s0:h,s1:f,s2:p,s3:g}=Po(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g;if(r){const e=Uo(n.subarray(4*m));h^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:h,s1:f,s2:p,s3:g}=Po(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g}return(0,po.clean)(...d),c},decrypt(n,i){$o(n);const o=Oo(e);let s=t;const a=[o];(0,po.isAligned32)(s)||a.push(s=(0,po.copyBytes)(s));const c=(0,po.u32)(s),l=No(n.length,i);(0,po.isAligned32)(n)||a.push(n=(0,po.copyBytes)(n));const d=(0,po.u32)(n),u=(0,po.u32)(l);let h=c[0],f=c[1],p=c[2],g=c[3];for(let e=0;e+4<=d.length;){const t=h,n=f,r=p,i=g;h=d[e+0],f=d[e+1],p=d[e+2],g=d[e+3];const{s0:s,s1:a,s2:c,s3:l}=Io(o,h,f,p,g);u[e++]=s^t,u[e++]=a^n,u[e++]=c^r,u[e++]=l^i}return(0,po.clean)(...a),Ko(l,r)}}})),Qi.cfb=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,ho.bytes)(n);const o=n.length;i=No(o,i);const s=Lo(e);let a=t;const c=[s];(0,po.isAligned32)(a)||c.push(a=(0,po.copyBytes)(a)),(0,po.isAligned32)(n)||c.push(n=(0,po.copyBytes)(n));const l=(0,po.u32)(n),d=(0,po.u32)(i),u=r?d:l,h=(0,po.u32)(a);let f=h[0],p=h[1],g=h[2],m=h[3];for(let e=0;e+4<=l.length;){const{s0:t,s1:n,s2:r,s3:i}=Po(s,f,p,g,m);d[e+0]=l[e+0]^t,d[e+1]=l[e+1]^n,d[e+2]=l[e+2]^r,d[e+3]=l[e+3]^i,f=u[e++],p=u[e++],g=u[e++],m=u[e++]}const y=go*Math.floor(l.length/4);if(y<o){({s0:f,s1:p,s2:g,s3:m}=Po(s,f,p,g,m));const e=(0,po.u8)(new Uint32Array([f,p,g,m]));for(let t=y,r=0;t<o;t++,r++)i[t]=n[t]^e[r];(0,po.clean)(e)}return(0,po.clean)(...c),i}return(0,ho.bytes)(e),(0,ho.bytes)(t,16),{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),Qi.gcm=(0,po.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){if((0,ho.bytes)(e),(0,ho.bytes)(t),void 0!==n&&(0,ho.bytes)(n),t.length<8)throw new Error("aes/gcm: invalid nonce length");function r(e,t,r){const i=Fo(fo.ghash,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){const n=Lo(e),r=mo.slice(),i=mo.slice();if(Do(n,!1,i,i,r),12===t.length)i.set(t);else{const e=mo.slice(),n=(0,po.createView)(e);(0,po.setBigUint64)(n,8,BigInt(8*t.length),!1);const o=fo.ghash.create(r).update(t).update(e);o.digestInto(i),o.destroy()}return{xk:n,authKey:r,counter:i,tagMask:Do(n,!1,i,mo)}}return{encrypt(e){(0,ho.bytes)(e);const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=new Uint8Array(e.length+16),c=[t,n,o,s];(0,po.isAligned32)(e)||c.push(e=(0,po.copyBytes)(e)),Do(t,!1,o,e,a);const l=r(n,s,a.subarray(0,a.length-16));return c.push(l),a.set(l,e.length),(0,po.clean)(...c),a},decrypt(e){if((0,ho.bytes)(e),e.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=[t,n,s,o];(0,po.isAligned32)(e)||a.push(e=(0,po.copyBytes)(e));const c=e.subarray(0,-16),l=e.subarray(-16),d=r(n,s,c);if(a.push(d),!(0,po.equalBytes)(d,l))throw new Error("aes/gcm: invalid ghash tag");const u=Do(t,!1,o,c);return(0,po.clean)(...a),u}}}));const Ho=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(`${e}: invalid value=${r}, must be [${t}..${n}]`)};function zo(e){return null!=e&&"object"==typeof e&&(e instanceof Uint32Array||"Uint32Array"===e.constructor.name)}function qo(e,t){if((0,ho.bytes)(t,16),!zo(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,po.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Po(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}function Vo(e,t){if((0,ho.bytes)(t,16),!zo(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,po.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Io(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}Qi.siv=(0,po.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){const r=Ho("AAD",0,2**36),i=Ho("plaintext",0,2**36),o=Ho("nonce",12,12),s=Ho("ciphertext",16,2**36+16);function a(){const n=Lo(e),r=new Uint8Array(e.length),i=new Uint8Array(16),o=[n,r];let s=t;(0,po.isAligned32)(s)||o.push(s=(0,po.copyBytes)(s));const a=(0,po.u32)(s);let c=0,l=a[0],d=a[1],u=a[2],h=0;for(const e of[i,r].map(po.u32)){const t=(0,po.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:i}=Po(n,c,l,d,u);t[e+0]=r,t[e+1]=i,c=++h}}const f={authKey:i,encKey:Lo(r)};return(0,po.clean)(...o),f}function c(e,r,i){const o=Fo(fo.polyval,!0,r,i,n);for(let e=0;e<12;e++)o[e]^=t[e];o[15]&=127;const s=(0,po.u32)(o);let a=s[0],c=s[1],l=s[2],d=s[3];return({s0:a,s1:c,s2:l,s3:d}=Po(e,a,c,l,d)),s[0]=a,s[1]=c,s[2]=l,s[3]=d,o}function l(e,t,n){let r=(0,po.copyBytes)(t);r[15]|=128;const i=Do(e,!0,r,n);return(0,po.clean)(r),i}return(0,ho.bytes)(e,16,24,32),(0,ho.bytes)(t),o(t.length),void 0!==n&&((0,ho.bytes)(n),r(n.length)),{encrypt(e){(0,ho.bytes)(e),i(e.length);const{encKey:t,authKey:n}=a(),r=c(t,n,e),o=[t,n,r];(0,po.isAligned32)(e)||o.push(e=(0,po.copyBytes)(e));const s=new Uint8Array(e.length+16);return s.set(r,e.length),s.set(l(t,r,e)),(0,po.clean)(...o),s},decrypt(e){(0,ho.bytes)(e),s(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=a(),i=[n,r];(0,po.isAligned32)(e)||i.push(e=(0,po.copyBytes)(e));const o=l(n,t,e.subarray(0,-16)),d=c(n,r,o);if(i.push(d),!(0,po.equalBytes)(t,d))throw(0,po.clean)(...i),new Error("invalid polyval tag");return(0,po.clean)(...i),o}}}));const Wo={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=Lo(e);if(16===t.length)qo(n,t);else{const e=(0,po.u32)(t);let r=e[0],i=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:s,s1:a,s2:c,s3:l}=Po(n,r,i,e[t],e[t+1]);r=s,i=a^So(o),e[t]=c,e[t+1]=l}e[0]=r,e[1]=i}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=Oo(e),r=t.length/8-1;if(1===r)Vo(n,t);else{const e=(0,po.u32)(t);let i=e[0],o=e[1];for(let t=0,s=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,s--){o^=So(s);const{s0:r,s1:a,s2:c,s3:l}=Io(n,i,o,e[t],e[t+1]);i=r,o=a,e[t]=c,e[t+1]=l}e[0]=i,e[1]=o}n.fill(0)}},Go=new Uint8Array(8).fill(166);Qi.aeskw=(0,po.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,ho.bytes)(t),!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,po.concatBytes)(Go,t);return Wo.encrypt(e,n),n},decrypt(t){if((0,ho.bytes)(t),t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,po.copyBytes)(t);if(Wo.decrypt(e,n),!(0,po.equalBytes)(n.subarray(0,8),Go))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const Yo=2790873510;Qi.aeskwp=(0,po.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,ho.bytes)(t),!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const i=(0,po.u32)(r);return i[0]=Yo,i[1]=So(t.length),Wo.encrypt(e,r),r},decrypt(t){if((0,ho.bytes)(t),t.length<16)throw new Error("invalid ciphertext length");const n=(0,po.copyBytes)(t),r=(0,po.u32)(n);Wo.decrypt(e,n);const i=So(r[1])>>>0,o=8*Math.ceil(i/8);if(r[0]!==Yo||n.length-8!==o)throw new Error("integrity check failed");for(let e=i;e<o;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}}))),Qi.unsafe={expandKeyLE:Lo,expandKeyDecLE:Oo,encrypt:Po,decrypt:Io,encryptBlock:qo,decryptBlock:Vo,ctrCounter:Bo,ctr32:Do},Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.aes256cbc=Xi.aes256gcm=void 0;var Zo=Qi;Xi.aes256gcm=function(e,t,n){return(0,Zo.gcm)(e,t,n)},Xi.aes256cbc=function(e,t,n){return(0,Zo.cbc)(e,t)};var Jo={},Xo={},Qo={};Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.sigma=void 0,Qo.rotl=function(e,t){return e<<t|e>>>32-t},Qo.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=(0,ts.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,es.number)(i),(0,es.number)(s),(0,es.bool)(o),(0,es.bool)(n),(t,a,c,l,d=0)=>{(0,es.bytes)(t),(0,es.bytes)(a),(0,es.bytes)(c);const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),(0,es.bytes)(l),(0,es.number)(d),d<0||d>=ds)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=(0,ts.copyBytes)(t)),p=ss;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=os,h.push(f)}as(a)||h.push(a=(0,ts.copyBytes)(a));const m=(0,ts.u32)(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,(0,ts.u32)(a.subarray(0,16)),m),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,h.push(a)}const v=(0,ts.u32)(a);return function(e,t,n,r,i,o,s,a){const c=i.length,l=new Uint8Array(cs),d=(0,ts.u32)(l),u=as(i)&&as(o),h=u?(0,ts.u32)(i):us,f=u?(0,ts.u32)(o):us;for(let p=0;p<c;s++){if(e(t,n,r,d,s,a),s>=ds)throw new Error("arx: counter overflow");const g=Math.min(cs,c-p);if(u&&g===cs){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<ls;n++)t=e+n,f[t]=h[t]^d[n];p+=cs}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^l[t];p+=g}}}(e,p,m,v,c,l,d,s),(0,ts.clean)(...h),l}};const es=Ht,ts=Ft,ns=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),rs=ns("expand 16-byte k"),is=ns("expand 32-byte k"),os=(0,ts.u32)(rs),ss=(0,ts.u32)(is);function as(e){return e.byteOffset%4==0}Qo.sigma=ss.slice();const cs=64,ls=16,ds=2**32-1,us=new Uint32Array;var hs={};Object.defineProperty(hs,"__esModule",{value:!0}),hs.poly1305=void 0,hs.wrapConstructorWithKey=ys;const fs=Ht,ps=Ft,gs=(e,t)=>255&e[t++]|(255&e[t++])<<8;class ms{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,e=(0,ps.toBytes)(e),(0,fs.bytes)(e,32);const t=gs(e,0),n=gs(e,2),r=gs(e,4),i=gs(e,6),o=gs(e,8),s=gs(e,10),a=gs(e,12),c=gs(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=gs(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],d=o[4],u=o[5],h=o[6],f=o[7],p=o[8],g=o[9],m=gs(e,t+0),y=gs(e,t+2),v=gs(e,t+4),b=gs(e,t+6),w=gs(e,t+8),E=gs(e,t+10),C=gs(e,t+12),_=gs(e,t+14);let S=i[0]+(8191&m),k=i[1]+(8191&(m>>>13|y<<3)),x=i[2]+(8191&(y>>>10|v<<6)),A=i[3]+(8191&(v>>>7|b<<9)),M=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),O=i[6]+(8191&(w>>>14|E<<2)),T=i[7]+(8191&(E>>>11|C<<5)),R=i[8]+(8191&(C>>>8|_<<8)),P=i[9]+(_>>>5|r),I=0,N=I+S*s+k*(5*g)+x*(5*p)+A*(5*f)+M*(5*h);I=N>>>13,N&=8191,N+=L*(5*u)+O*(5*d)+T*(5*l)+R*(5*c)+P*(5*a),I+=N>>>13,N&=8191;let B=I+S*a+k*s+x*(5*g)+A*(5*p)+M*(5*f);I=B>>>13,B&=8191,B+=L*(5*h)+O*(5*u)+T*(5*d)+R*(5*l)+P*(5*c),I+=B>>>13,B&=8191;let D=I+S*c+k*a+x*s+A*(5*g)+M*(5*p);I=D>>>13,D&=8191,D+=L*(5*f)+O*(5*h)+T*(5*u)+R*(5*d)+P*(5*l),I+=D>>>13,D&=8191;let $=I+S*l+k*c+x*a+A*s+M*(5*g);I=$>>>13,$&=8191,$+=L*(5*p)+O*(5*f)+T*(5*h)+R*(5*u)+P*(5*d),I+=$>>>13,$&=8191;let j=I+S*d+k*l+x*c+A*a+M*s;I=j>>>13,j&=8191,j+=L*(5*g)+O*(5*p)+T*(5*f)+R*(5*h)+P*(5*u),I+=j>>>13,j&=8191;let K=I+S*u+k*d+x*l+A*c+M*a;I=K>>>13,K&=8191,K+=L*s+O*(5*g)+T*(5*p)+R*(5*f)+P*(5*h),I+=K>>>13,K&=8191;let U=I+S*h+k*u+x*d+A*l+M*c;I=U>>>13,U&=8191,U+=L*a+O*s+T*(5*g)+R*(5*p)+P*(5*f),I+=U>>>13,U&=8191;let F=I+S*f+k*h+x*u+A*d+M*l;I=F>>>13,F&=8191,F+=L*c+O*a+T*s+R*(5*g)+P*(5*p),I+=F>>>13,F&=8191;let H=I+S*p+k*f+x*h+A*u+M*d;I=H>>>13,H&=8191,H+=L*l+O*c+T*a+R*s+P*(5*g),I+=H>>>13,H&=8191;let z=I+S*g+k*p+x*f+A*h+M*u;I=z>>>13,z&=8191,z+=L*d+O*l+T*c+R*a+P*s,I+=z>>>13,z&=8191,I=(I<<2)+I|0,I=I+N|0,N=8191&I,I>>>=13,B+=I,i[0]=N,i[1]=B,i[2]=D,i[3]=$,i[4]=j,i[5]=K,i[6]=U,i[7]=F,i[8]=H,i[9]=z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let o=e[0]+t[0];e[0]=65535&o;for(let n=1;n<8;n++)o=(e[n]+t[n]|0)+(o>>>16)|0,e[n]=65535&o;(0,ps.clean)(n)}update(e){(0,fs.exists)(this);const{buffer:t,blockLen:n}=this,r=(e=(0,ps.toBytes)(e)).length;for(let i=0;i<r;){const o=Math.min(n-this.pos,r-i);if(o!==n)t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){(0,ps.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,fs.exists)(this),(0,fs.output)(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function ys(e){const t=(t,n)=>e(n).update((0,ps.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}hs.poly1305=ys((e=>new ms(e))),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xchacha20poly1305=e.chacha20poly1305=e._poly1305_aead=e.chacha12=e.chacha8=e.xchacha20=e.chacha20=e.chacha20orig=void 0,e.hchacha=s;const t=Qo,n=Ht,r=hs,i=Ft;function o(e,n,r,i,o,s=20){let a=e[0],c=e[1],l=e[2],d=e[3],u=n[0],h=n[1],f=n[2],p=n[3],g=n[4],m=n[5],y=n[6],v=n[7],b=o,w=r[0],E=r[1],C=r[2],_=a,S=c,k=l,x=d,A=u,M=h,L=f,O=p,T=g,R=m,P=y,I=v,N=b,B=w,D=E,$=C;for(let e=0;e<s;e+=2)_=_+A|0,N=(0,t.rotl)(N^_,16),T=T+N|0,A=(0,t.rotl)(A^T,12),_=_+A|0,N=(0,t.rotl)(N^_,8),T=T+N|0,A=(0,t.rotl)(A^T,7),S=S+M|0,B=(0,t.rotl)(B^S,16),R=R+B|0,M=(0,t.rotl)(M^R,12),S=S+M|0,B=(0,t.rotl)(B^S,8),R=R+B|0,M=(0,t.rotl)(M^R,7),k=k+L|0,D=(0,t.rotl)(D^k,16),P=P+D|0,L=(0,t.rotl)(L^P,12),k=k+L|0,D=(0,t.rotl)(D^k,8),P=P+D|0,L=(0,t.rotl)(L^P,7),x=x+O|0,$=(0,t.rotl)($^x,16),I=I+$|0,O=(0,t.rotl)(O^I,12),x=x+O|0,$=(0,t.rotl)($^x,8),I=I+$|0,O=(0,t.rotl)(O^I,7),_=_+M|0,$=(0,t.rotl)($^_,16),P=P+$|0,M=(0,t.rotl)(M^P,12),_=_+M|0,$=(0,t.rotl)($^_,8),P=P+$|0,M=(0,t.rotl)(M^P,7),S=S+L|0,N=(0,t.rotl)(N^S,16),I=I+N|0,L=(0,t.rotl)(L^I,12),S=S+L|0,N=(0,t.rotl)(N^S,8),I=I+N|0,L=(0,t.rotl)(L^I,7),k=k+O|0,B=(0,t.rotl)(B^k,16),T=T+B|0,O=(0,t.rotl)(O^T,12),k=k+O|0,B=(0,t.rotl)(B^k,8),T=T+B|0,O=(0,t.rotl)(O^T,7),x=x+A|0,D=(0,t.rotl)(D^x,16),R=R+D|0,A=(0,t.rotl)(A^R,12),x=x+A|0,D=(0,t.rotl)(D^x,8),R=R+D|0,A=(0,t.rotl)(A^R,7);let j=0;i[j++]=a+_|0,i[j++]=c+S|0,i[j++]=l+k|0,i[j++]=d+x|0,i[j++]=u+A|0,i[j++]=h+M|0,i[j++]=f+L|0,i[j++]=p+O|0,i[j++]=g+T|0,i[j++]=m+R|0,i[j++]=y+P|0,i[j++]=v+I|0,i[j++]=b+N|0,i[j++]=w+B|0,i[j++]=E+D|0,i[j++]=C+$|0}function s(e,n,r,i){let o=e[0],s=e[1],a=e[2],c=e[3],l=n[0],d=n[1],u=n[2],h=n[3],f=n[4],p=n[5],g=n[6],m=n[7],y=r[0],v=r[1],b=r[2],w=r[3];for(let e=0;e<20;e+=2)o=o+l|0,y=(0,t.rotl)(y^o,16),f=f+y|0,l=(0,t.rotl)(l^f,12),o=o+l|0,y=(0,t.rotl)(y^o,8),f=f+y|0,l=(0,t.rotl)(l^f,7),s=s+d|0,v=(0,t.rotl)(v^s,16),p=p+v|0,d=(0,t.rotl)(d^p,12),s=s+d|0,v=(0,t.rotl)(v^s,8),p=p+v|0,d=(0,t.rotl)(d^p,7),a=a+u|0,b=(0,t.rotl)(b^a,16),g=g+b|0,u=(0,t.rotl)(u^g,12),a=a+u|0,b=(0,t.rotl)(b^a,8),g=g+b|0,u=(0,t.rotl)(u^g,7),c=c+h|0,w=(0,t.rotl)(w^c,16),m=m+w|0,h=(0,t.rotl)(h^m,12),c=c+h|0,w=(0,t.rotl)(w^c,8),m=m+w|0,h=(0,t.rotl)(h^m,7),o=o+d|0,w=(0,t.rotl)(w^o,16),g=g+w|0,d=(0,t.rotl)(d^g,12),o=o+d|0,w=(0,t.rotl)(w^o,8),g=g+w|0,d=(0,t.rotl)(d^g,7),s=s+u|0,y=(0,t.rotl)(y^s,16),m=m+y|0,u=(0,t.rotl)(u^m,12),s=s+u|0,y=(0,t.rotl)(y^s,8),m=m+y|0,u=(0,t.rotl)(u^m,7),a=a+h|0,v=(0,t.rotl)(v^a,16),f=f+v|0,h=(0,t.rotl)(h^f,12),a=a+h|0,v=(0,t.rotl)(v^a,8),f=f+v|0,h=(0,t.rotl)(h^f,7),c=c+l|0,b=(0,t.rotl)(b^c,16),p=p+b|0,l=(0,t.rotl)(l^p,12),c=c+l|0,b=(0,t.rotl)(b^c,8),p=p+b|0,l=(0,t.rotl)(l^p,7);let E=0;i[E++]=o,i[E++]=s,i[E++]=a,i[E++]=c,i[E++]=y,i[E++]=v,i[E++]=b,i[E++]=w}e.chacha20orig=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,allowShortKeys:!0}),e.chacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,allowShortKeys:!1}),e.xchacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,extendNonceFn:s,allowShortKeys:!1}),e.chacha8=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:8}),e.chacha12=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:12});const a=new Uint8Array(16),c=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(a.subarray(n))},l=new Uint8Array(32);function d(e,t,n,o,s){const a=e(t,n,l),d=r.poly1305.create(a);s&&c(d,s),c(d,o);const u=new Uint8Array(16),h=(0,i.createView)(u);(0,i.setBigUint64)(h,0,BigInt(s?s.length:0),!0),(0,i.setBigUint64)(h,8,BigInt(o.length),!0),d.update(u);const f=d.digest();return(0,i.clean)(a,u),f}e._poly1305_aead=e=>(t,r,o)=>((0,n.bytes)(t,32),(0,n.bytes)(r),{encrypt(s,a){const c=s.length,l=c+16;a?(0,n.bytes)(a,l):a=new Uint8Array(l),e(t,r,s,a,1);const u=d(e,t,r,a.subarray(0,-16),o);return a.set(u,c),(0,i.clean)(u),a},decrypt(s,a){const c=s.length,l=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");a?(0,n.bytes)(a,l):a=new Uint8Array(l);const u=s.subarray(0,-16),h=s.subarray(-16),f=d(e,t,r,u,o);if(!(0,i.equalBytes)(h,f))throw new Error("invalid tag");return e(t,r,u,a,1),(0,i.clean)(f),a}}),e.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,e._poly1305_aead)(e.chacha20)),e.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,e._poly1305_aead)(e.xchacha20))}(Xo),Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.xchacha20=void 0;var vs,bs,ws,Es=Xo;Jo.xchacha20=function(e,t,n){return(0,Es.xchacha20poly1305)(e,t,n)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=Ft,n=on,r=Xi,i=Jo,o=Xt,s=Qt;function a(e,t,n,a){var c=(0,o.symmetricAlgorithm)();if("aes-256-gcm"===c)return e(r.aes256gcm,t,n,(0,o.symmetricNonceLength)(),s.AEAD_TAG_LENGTH,a);if("xchacha20"===c)return e(i.xchacha20,t,n,s.XCHACHA20_NONCE_LENGTH,s.AEAD_TAG_LENGTH,a);if("aes-256-cbc"===c)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function c(e,r,i,o,s,a){var c=(0,n.randomBytes)(o),l=e(r,c,a).encrypt(i);if(0===s)return(0,t.concatBytes)(c,l);var d=l.length-s,u=l.subarray(0,d),h=l.subarray(d);return(0,t.concatBytes)(c,h,u)}function l(e,n,r,i,o,s){var a=r.subarray(0,i),c=e(n,Uint8Array.from(a),s),l=r.subarray(i);if(0===o)return c.decrypt(l);var d=l.subarray(0,o),u=l.subarray(o);return c.decrypt((0,t.concatBytes)(u,d))}e.symEncrypt=function(e,t,n){return a(c,e,t,n)},e.symDecrypt=function(e,t,n){return a(l,e,t,n)},e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt}(Ji),vs=nn,bs=$t&&$t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),ws=$t&&$t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||bs(t,e,n)},Object.defineProperty(vs,"__esModule",{value:!0}),ws(rn,vs),ws(Fi,vs),ws(Ui,vs),ws(Ji,vs);var Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.PublicKey=void 0;var _s=Ft,Ss=nn,ks=function(){function e(e){this.data=(0,Ss.convertPublicKeyFormat)(e,!0)}return e.fromHex=function(t){return new e((0,Ss.hexToPublicKey)(t))},Object.defineProperty(e.prototype,"uncompressed",{get:function(){return Xe.from((0,Ss.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return Xe.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,_s.bytesToHex)(e?this.data:this.uncompressed)},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.data:this.uncompressed,r=e.multiply(this,t);return(0,Ss.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,_s.equalBytes)(this.data,e.data)},e}();Cs.PublicKey=ks,Object.defineProperty(tn,"__esModule",{value:!0}),tn.PrivateKey=void 0;var xs=Ft,As=nn,Ms=Cs,Ls=function(){function e(e){if(void 0===e)this.data=(0,As.getValidSecret)();else{if(!(0,As.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new Ms.PublicKey((0,As.getPublicKey)(this.data))}return e.fromHex=function(t){return new e((0,As.decodeHex)(t))},Object.defineProperty(e.prototype,"secret",{get:function(){return Xe.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,xs.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.publicKey.compressed:this.publicKey.uncompressed,r=this.multiply(e,t);return(0,As.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,As.getSharedPoint)(this.data,e.compressed,t)},e.prototype.equals=function(e){return(0,xs.equalBytes)(this.data,e.data)},e}();tn.PrivateKey=Ls,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=tn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return t.PrivateKey}});var n=Cs;Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})}(en),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=function(e,o){var s=new r.PrivateKey,a=e instanceof Uint8Array?new r.PublicKey(e):r.PublicKey.fromHex(e),c=s.encapsulate(a,(0,n.isHkdfKeyCompressed)()),l=(0,n.isEphemeralKeyCompressed)()?s.publicKey.compressed:s.publicKey.uncompressed,d=(0,i.symEncrypt)(c,o);return Xe.from((0,t.concatBytes)(l,d))},e.decrypt=function(e,t){var o=e instanceof Uint8Array?new r.PrivateKey(e):r.PrivateKey.fromHex(e),s=(0,n.ephemeralKeySize)(),a=new r.PublicKey(t.subarray(0,s)),c=t.subarray(s),l=a.decapsulate(o,(0,n.isHkdfKeyCompressed)());return Xe.from((0,i.symDecrypt)(l,c))};var t=Ft,n=Xt,r=en,i=nn,o=Xt;Object.defineProperty(e,"ECIES_CONFIG",{enumerable:!0,get:function(){return o.ECIES_CONFIG}});var s=en;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return s.PrivateKey}}),Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return s.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}}(Ut);const Os=u("KeyExchange:Layer"),Ts=u("SocketService:Layer"),Rs=u("Ecies:Layer"),Ps=u("RemoteCommunication:Layer");Os.color="##95c44e",Ts.color="#f638d7",Rs.color="#465b9c",Ps.color="#47a2be";const Is={KeyExchange:Os,SocketService:Ts,Ecies:Rs,RemoteCommunication:Ps};let Ns,Bs=[],Ds=[];const $s=(e,t)=>Be(void 0,void 0,void 0,(function*(){Ns=t,Ds.push(e),function(e){return Be(this,void 0,void 0,(function*(){if(!Ns||!e)return;!function(){const e=Ds;Ds=Bs,Bs=e}();const t=Ns.endsWith("/")?`${Ns}evt`:`${Ns}/evt`,n=Object.assign({},e);if(delete n.params,e.params)for(const[t,r]of Object.entries(e.params))n[t]=r;const r=JSON.stringify(n);Is.RemoteCommunication(`[sendBufferedEvents] Sending ${Bs.length} analytics events to ${t}`);try{const e=yield s(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:r}),n=yield e.text();Is.RemoteCommunication(`[sendBufferedEvents] Response: ${n}`),Bs.length=0}catch(t){}}))}(e).catch((()=>{}))}));class js{constructor(e){this.enabled=!0,(null==e?void 0:e.debug)&&u.enable("Ecies:Layer"),this.ecies=(null==e?void 0:e.privateKey)?Ut.PrivateKey.fromHex(e.privateKey):new Ut.PrivateKey,Is.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),Is.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),Is.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new Ut.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,t){let n=e;if(this.enabled)try{Is.Ecies("[ECIES: encrypt()] using otherPublicKey",t);const r=Xe.from(e),i=Ut.encrypt(t,r);n=Xe.from(i).toString("base64")}catch(n){throw Is.Ecies("[ECIES: encrypt()] error encrypt:",n),Is.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),Is.Ecies("[ECIES: encrypt()] data: ",e),Is.Ecies("[ECIES: encrypt()] otherkey: ",t),n}return n}decrypt(e){let t=e;if(this.enabled)try{Is.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const n=Xe.from(e.toString(),"base64");t=Ut.decrypt(this.ecies.toHex(),n).toString()}catch(t){throw Is.Ecies("[ECIES: decrypt()] error decrypt",t),Is.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),Is.Ecies("[ECIES: decrypt()] encryptedData: ",e),t}return t}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){Is.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var Ks={name:"@metamask/sdk-communication-layer",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk.git",directory:"packages/sdk-communication-layer"},main:"dist/node/cjs/metamask-sdk-communication-layer.js",unpkg:"dist/browser/umd/metamask-sdk-communication-layer.js",module:"dist/node/es/metamask-sdk-communication-layer.js",browser:"dist/browser/es/metamask-sdk-communication-layer.js","react-native":"dist/react-native/es/metamask-sdk-communication-layer.js",types:"dist/types/src/index.d.ts",files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types","build:clean":"yarn clean && yarn build",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",dev:'concurrently "tsc --watch" "rollup -c --bundleConfigAsCjs -w"',"build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",size:"size-limit",clean:"rimraf ./dist",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk-communication-layer","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore","publish:preview":"yarn npm publish --tag preview",prepack:"../../scripts/prepack.sh",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:coverage":"jest --coverage","test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":"jest",watch:"rollup -c --bundleConfigAsCjs -w"},dependencies:{bufferutil:"^4.0.8","date-fns":"^2.29.3",debug:"^4.3.4","utf-8-validate":"^5.0.2",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@size-limit/preset-big-lib":"^11.0.2","@types/jest":"^29.2.4","@types/node":"^20.1.3","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0",concurrently:"^9.1.2","cross-fetch":"^4.0.0",eciesjs:"^0.4.11",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0",eventemitter2:"^6.4.9",jest:"^29.3.1",prettier:"^2.3.0",rimraf:"^3.0.2",rollup:"^4.26.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.4.0","rollup-plugin-peer-deps-external":"^2.2.4","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.1.6","socket.io-client":"^4.5.1","stream-browserify":"^3.0.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^5.6.3"},peerDependencies:{"cross-fetch":"^4.0.0",eciesjs:"*",eventemitter2:"^6.4.9","readable-stream":"^3.6.2","socket.io-client":"^4.5.1"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"@lavamoat/preinstall-always-fail":!1,canvas:!0,"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,bufferutil:!1,"utf-8-validate":!1}}};const Us="https://metamask-sdk.api.cx.metamask.io/",Fs=["websocket"],Hs=6048e5,zs=3e3,qs={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",ETH_REQUESTACCOUNTS:"eth_requestAccounts"};function Vs(e){const{context:t}=e;Is.RemoteCommunication(`[RemoteCommunication: clean()] context=${t}`),e.channelConfig=void 0,e.ready=!1,e.originatorConnectStarted=!1}var Ws,Gs,Ys,Zs,Js,Xs,Qs;(Qs=Ws||(Ws={})).DISCONNECTED="disconnected",Qs.WAITING="waiting",Qs.TIMEOUT="timeout",Qs.LINKED="linked",Qs.PAUSED="paused",Qs.TERMINATED="terminated",function(e){e.KEY_INFO="key_info",e.SERVICE_STATUS="service_status",e.PROVIDER_UPDATE="provider_update",e.RPC_UPDATE="rpc_update",e.KEYS_EXCHANGED="keys_exchanged",e.JOIN_CHANNEL="join_channel",e.PUBLIC_KEY="public_key",e.CHANNEL_CREATED="channel_created",e.CLIENTS_CONNECTED="clients_connected",e.CLIENTS_DISCONNECTED="clients_disconnected",e.CLIENTS_WAITING="clients_waiting",e.CLIENTS_READY="clients_ready",e.REJECTED="rejected",e.WALLET_INIT="wallet_init",e.CHANNEL_PERSISTENCE="channel_persistence",e.CONFIG="config",e.MESSAGE_ACK="ack",e.SOCKET_DISCONNECTED="socket_disconnected",e.SOCKET_RECONNECT="socket_reconnect",e.OTP="otp",e.SDK_RPC_CALL="sdk_rpc_call",e.AUTHORIZED="authorized",e.CONNECTION_STATUS="connection_status",e.MESSAGE="message",e.TERMINATE="terminate"}(Gs||(Gs={})),(Ys||(Ys={})).KEY_EXCHANGE="key_exchange",function(e){e.KEY_HANDSHAKE_START="key_handshake_start",e.KEY_HANDSHAKE_CHECK="key_handshake_check",e.KEY_HANDSHAKE_SYN="key_handshake_SYN",e.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",e.KEY_HANDSHAKE_ACK="key_handshake_ACK",e.KEY_HANDSHAKE_WALLET="key_handshake_wallet",e.KEY_HANDSHAKE_NONE="none"}(Zs||(Zs={}));class ea extends h.exports.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:t,context:n,ecies:r,logging:i}){super(),this.keysExchanged=!1,this.step=Zs.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=n,this.communicationLayer=e,(null==r?void 0:r.privateKey)&&t&&(Is.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${t} set keysExchanged to true!`,r),this.keysExchanged=!0),this.myECIES=new js(Object.assign(Object.assign({},r),{debug:null==i?void 0:i.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=!0===(null==i?void 0:i.keyExchangeLayer),t&&this.setOtherPublicKey(t),this.communicationLayer.on(Ys.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:t}=this.communicationLayer.remote.state;if(Is.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${t}`,e),t)return void Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:n}=e;this.keysExchanged&&Is.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(Gs.KEY_INFO,n.type),n.type===Zs.KEY_HANDSHAKE_SYN?(this.checkStep([Zs.KEY_HANDSHAKE_NONE,Zs.KEY_HANDSHAKE_ACK]),Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",n),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((e=>{Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",e)})),this.setStep(Zs.KEY_HANDSHAKE_ACK)):n.type===Zs.KEY_HANDSHAKE_SYNACK?(this.checkStep([Zs.KEY_HANDSHAKE_SYNACK,Zs.KEY_HANDSHAKE_ACK,Zs.KEY_HANDSHAKE_NONE]),Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}).catch((e=>{Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",e)})),this.keysExchanged=!0,this.setStep(Zs.KEY_HANDSHAKE_ACK),this.emit(Gs.KEYS_EXCHANGED)):n.type===Zs.KEY_HANDSHAKE_ACK&&(Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Zs.KEY_HANDSHAKE_ACK,Zs.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Zs.KEY_HANDSHAKE_ACK),this.emit(Gs.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new js(e)}clean(){Is.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Zs.KEY_HANDSHAKE_NONE),this.emit(Gs.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:t}){const{relayPersistence:n,protocolVersion:r}=this.communicationLayer.remote.state,i=r>=2;n?Is.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(Is.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${r} isOriginator=${e} step=${this.step} force=${t} relayPersistence=${n} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Zs.KEY_HANDSHAKE_NONE&&this.step!==Zs.KEY_HANDSHAKE_SYNACK)||t?(Is.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${t}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Zs.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",e)}))):Is.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&!0!==t?Is.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):i?this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",e)})):(this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_START}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",e)})),this.clean()))}setStep(e){this.step=e,this.emit(Gs.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:t}){this.otherPublicKey=t,this.myECIES=new js({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){Is.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}!function(e){e.TERMINATE="terminate",e.ANSWER="answer",e.OFFER="offer",e.CANDIDATE="candidate",e.JSONRPC="jsonrpc",e.WALLET_INFO="wallet_info",e.WALLET_INIT="wallet_init",e.ORIGINATOR_INFO="originator_info",e.PAUSE="pause",e.OTP="otp",e.AUTHORIZED="authorized",e.PING="ping",e.READY="ready"}(Js||(Js={})),function(e){e.REQUEST="sdk_connect_request_started",e.REQUEST_MOBILE="sdk_connect_request_started_mobile",e.RECONNECT="sdk_reconnect_request_started",e.CONNECTED="sdk_connection_established",e.CONNECTED_MOBILE="sdk_connection_established_mobile",e.AUTHORIZED="sdk_connection_authorized",e.REJECTED="sdk_connection_rejected",e.TERMINATED="sdk_connection_terminated",e.DISCONNECTED="sdk_disconnected",e.SDK_USE_EXTENSION="sdk_use_extension",e.SDK_RPC_REQUEST="sdk_rpc_request",e.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",e.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",e.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",e.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"}(Xs||(Xs={}));const ta=(e,t,n)=>Be(void 0,void 0,void 0,(function*(){var r,i,o,s,a,c;const{remote:l,state:d}=e,{channelId:u,isOriginator:h}=d;if("error_terminated"===t)return Is.SocketService(`handleJoinChannelResults: Channel ${u} terminated`),void e.emit(Gs.TERMINATE);if(!n)return void Is.SocketService(`handleJoinChannelResults: No result for channel ${u}`);const{persistence:f,walletKey:p,rejected:g}=n;if(Is.SocketService(`handleJoinChannelResults: Channel ${u} persistence=${f} walletKey=${p} rejected=${g}`),g)return Is.SocketService(`handleJoinChannelResults: Channel ${u} rejected`),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Gs.REJECTED,{channelId:u}),void e.remote.emitServiceStatusEvent();if(p&&!(null===(r=l.state.channelConfig)||void 0===r?void 0:r.otherKey)){e.getKeyExchange().setOtherPublicKey(p),null===(i=e.state.keyExchange)||void 0===i||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Gs.AUTHORIZED);const{communicationLayer:t,storageManager:n}=l.state,r=Object.assign(Object.assign({},l.state.channelConfig),{channelId:null!==(o=l.state.channelId)&&void 0!==o?o:"",validUntil:Date.now()+Hs,localKey:null==t?void 0:t.getKeyInfo().ecies.private,otherKey:p});e.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}).catch((e=>{})),null===(s=e.state.socket)||void 0===s||s.emit(Js.PING,{id:u,clientType:h?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield null==n?void 0:n.persistChannelConfig(r),l.emitServiceStatusEvent(),l.setConnectionStatus(Ws.LINKED)}f&&(e.emit(Gs.CHANNEL_PERSISTENCE),null===(a=e.state.keyExchange)||void 0===a||a.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Gs.AUTHORIZED),$s(Object.assign(Object.assign({id:null!=u?u:"",event:h?Xs.CONNECTED:Xs.CONNECTED_MOBILE},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Ks.version,walletVersion:null===(c=e.remote.state.walletInfo)||void 0===c?void 0:c.version}),d.communicationServerUrl).catch((e=>{})))})),na=e=>new Promise((t=>{setTimeout(t,e)})),ra=(e,t,...n)=>Be(void 0,[e,t,...n],void 0,(function*(e,t,n=200){let r;const i=Date.now();let o=!1;for(;!o;){if(o=Date.now()-i>3e5,r=t[e],void 0!==r.elapsedTime)return r;yield na(n)}throw new Error(`RPC ${e} timed out`)})),ia=e=>Be(void 0,void 0,void 0,(function*(){const{state:t}=e,{socket:n,channelId:r,context:i,isOriginator:o,isReconnecting:s}=t;if(s)return Is.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",e),!1;if(!n)return Is.SocketService("[SocketService: reconnectSocket()] socket is not defined",e),!1;if(!r)return!1;const{connected:a}=n;t.isReconnecting=!0,t.reconnectionAttempts=0,Is.SocketService(`[SocketService: reconnectSocket()] connected=${a} trying to reconnect after socketio disconnection`,e);try{for(;3>t.reconnectionAttempts;){if(Is.SocketService(`[SocketService: reconnectSocket()] Attempt ${t.reconnectionAttempts+1} of 3`,e),yield na(200),n.connected)return Is.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(Js.PING,{id:r,clientType:o?"dapp":"wallet",context:"on_channel_config",message:""}),!0;t.resumed=!0,n.connect(),e.emit(Gs.SOCKET_RECONNECT);try{if(yield new Promise(((t,s)=>{n.emit(Gs.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:o?"dapp":"wallet"},((n,r)=>Be(void 0,void 0,void 0,(function*(){try{yield ta(e,n,r),t()}catch(e){s(e)}}))))})),yield na(100),n.connected)return Is.SocketService(`Reconnection successful on attempt ${t.reconnectionAttempts+1}`),!0}catch(e){Is.SocketService(`Error during reconnection attempt ${t.reconnectionAttempts+1}:`,e)}t.reconnectionAttempts+=1,3>t.reconnectionAttempts&&(yield na(200))}return Is.SocketService("Failed to reconnect after 3 attempts"),!1}finally{t.isReconnecting=!1,t.reconnectionAttempts=0}}));function oa(e,t){return Be(this,void 0,void 0,(function*(){var n;const r=null===(n=e.state.keyExchange)||void 0===n?void 0:n.encryptMessage(JSON.stringify(t)),i={id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:r,plaintext:e.state.hasPlaintext?JSON.stringify(t):void 0};return Is.SocketService(`[SocketService: encryptAndSendMessage()] context=${e.state.context}`,i),t.type===Js.TERMINATE&&(e.state.manualDisconnect=!0),new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Gs.MESSAGE,i,((e,r)=>{var i;e&&(Is.SocketService(`[SocketService: encryptAndSendMessage()] error=${e}`),n(e)),Is.SocketService("[encryptAndSendMessage] response",r),t(null!==(i=null==r?void 0:r.success)&&void 0!==i&&i)}))}))}))}var sa;!function(e){e.RPC_CHECK="rpcCheck",e.SKIPPED_RPC="skippedRpc"}(sa||(sa={}));const aa=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map((e=>e.toLowerCase())),ca=[{event:Gs.CLIENTS_CONNECTED,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var n,r,i,o,s,a,c,l,d,u,h;const f=null!==(r=null===(n=e.remote.state.channelConfig)||void 0===n?void 0:n.relayPersistence)&&void 0!==r&&r;if(Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected-${t}' relayPersistence=${f} resumed=${e.state.resumed} clientsPaused=${e.state.clientsPaused} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()} isOriginator=${e.state.isOriginator}`),e.emit(Gs.CLIENTS_CONNECTED,{isOriginator:e.state.isOriginator,keysExchanged:null===(o=e.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged(),context:e.state.context}),e.state.resumed)e.state.isOriginator||(Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} 'clients_connected' / keysExchanged=${null===(s=e.state.keyExchange)||void 0===s?void 0:s.areKeysExchanged()} -- backward compatibility`),null===(a=e.state.keyExchange)||void 0===a||a.start({isOriginator:null!==(c=e.state.isOriginator)&&void 0!==c&&c})),e.state.resumed=!1;else if(e.state.clientsPaused)Is.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!e.state.isOriginator){const t=!f;Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(l=e.state.keyExchange)||void 0===l?void 0:l.areKeysExchanged()} -- force=${t} -- backward compatibility`),Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(d=e.state.keyExchange)||void 0===d?void 0:d.areKeysExchanged()} -- force=${t} -- backward compatibility`),null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h,force:t})}e.state.clientsConnected=!0,e.state.clientsPaused=!1}))}},{event:Gs.CHANNEL_CREATED,handler:function(e,t){return n=>{Is.SocketService(`[SocketService: handleChannelCreated()] context=${e.state.context} on 'channel_created-${t}'`,n),e.emit(Gs.CHANNEL_CREATED,n)}}},{event:Gs.CLIENTS_DISCONNECTED,handler:function(e,t){return()=>{var n;e.state.clientsConnected=!1,Is.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}'`),e.remote.state.relayPersistence?Is.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}' - relayPersistence enabled, skipping key exchange cleanup.`):(e.state.isOriginator&&!e.state.clientsPaused&&(null===(n=e.state.keyExchange)||void 0===n||n.clean()),e.emit(Gs.CLIENTS_DISCONNECTED,t))}}},{event:Gs.CONFIG,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var r,i,o;Is.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${t}'`,n);const{persistence:s,walletKey:a}=n;e.state.isOriginator&&e.remote.state.channelConfig?(n.walletKey&&!e.remote.state.channelConfig.otherKey&&(Is.SocketService(`Setting wallet key ${a}`),e.remote.state.channelConfig.otherKey=a,e.getKeyExchange().setOtherPublicKey(n.walletKey),null===(r=e.state.keyExchange)||void 0===r||r.setKeysExchanged(!0),yield e.remote.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}),yield e.remote.sendMessage({type:Js.PING}),yield null===(i=e.remote.state.storageManager)||void 0===i?void 0:i.persistChannelConfig(e.remote.state.channelConfig)),!0!==s||e.remote.state.channelConfig.relayPersistence||(Is.SocketService(`Setting relay persistence ${s}`),e.remote.state.channelConfig.relayPersistence=s,e.remote.state.relayPersistence=!0,e.remote.emit(Gs.CHANNEL_PERSISTENCE),e.remote.state.authorized=!0,e.remote.state.ready=!0,e.remote.emit(Gs.AUTHORIZED),yield null===(o=e.remote.state.storageManager)||void 0===o?void 0:o.persistChannelConfig(e.remote.state.channelConfig))):e.state.isOriginator||n.persistence&&(e.remote.state.relayPersistence=!0,e.remote.emit(Gs.CHANNEL_PERSISTENCE))}))}},{event:Gs.MESSAGE,handler:function(e,t){return n=>{var r,i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w;const{ackId:E,message:C,error:_}=n,S=null!==(r=e.remote.state.relayPersistence)&&void 0!==r&&r;if(Is.SocketService(`[SocketService handleMessage()] relayPersistence=${S} context=${e.state.context} on 'message' ${t} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()}`,n),_)throw Is.SocketService(`\n [SocketService handleMessage()] context=${e.state.context}::on 'message' error=${_}`),new Error(_);const k="string"==typeof C;if(!k&&(null==C?void 0:C.type)===Zs.KEY_HANDSHAKE_START){if(S)return;return Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received HANDSHAKE_START isOriginator=${e.state.isOriginator}`,C),void(null===(o=e.state.keyExchange)||void 0===o||o.start({isOriginator:null!==(s=e.state.isOriginator)&&void 0!==s&&s,force:!0}))}if(!k&&(null===(a=null==C?void 0:C.type)||void 0===a?void 0:a.startsWith("key_handshake"))){if(S)return;return Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' emit KEY_EXCHANGE`,C),void e.emit(Ys.KEY_EXCHANGE,{message:C,context:e.state.context})}if(k&&!(null===(c=e.state.keyExchange)||void 0===c?void 0:c.areKeysExchanged())){let t=!1;try{Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' trying to decrypt message`),null===(l=e.state.keyExchange)||void 0===l||l.decryptMessage(C),t=!0}catch(t){Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' error`,t)}if(!t)return e.state.isOriginator?null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h}):e.sendMessage({type:Zs.KEY_HANDSHAKE_START}).catch((e=>{})),void Is.SocketService(`Message ignored because invalid key exchange status. step=${null===(f=e.state.keyExchange)||void 0===f?void 0:f.getKeyInfo().step}`,null===(p=e.state.keyExchange)||void 0===p?void 0:p.getKeyInfo(),C);Is.SocketService("Invalid key exchange status detected --- updating it."),null===(d=e.state.keyExchange)||void 0===d||d.setKeysExchanged(!0)}else if(!k&&(null==C?void 0:C.type))return void e.emit(Gs.MESSAGE,C);if(!k)return void e.emit(Gs.MESSAGE,C);const x=null===(g=e.state.keyExchange)||void 0===g?void 0:g.decryptMessage(C),A=JSON.parse(null!=x?x:"{}");if(E&&(null==E?void 0:E.length)>0&&(Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' ackid=${E} channelId=${t}`),null===(m=e.state.socket)||void 0===m||m.emit(Gs.MESSAGE_ACK,{ackId:E,channelId:t,clientType:e.state.isOriginator?"dapp":"wallet"})),e.state.clientsPaused=(null==A?void 0:A.type)===Js.PAUSE,e.state.isOriginator&&A.data){const t=A.data,n=e.state.rpcMethodTracker[t.id];if(n){const r=Date.now()-n.timestamp;Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received answer for id=${t.id} method=${n.method} responseTime=${r}`,A),e.remote.state.analytics&&aa.includes(n.method.toLowerCase())&&$s(Object.assign(Object.assign({id:null!==(y=e.remote.state.channelId)&&void 0!==y?y:"",event:Xs.SDK_RPC_REQUEST_DONE,sdkVersion:e.remote.state.sdkVersion,commLayerVersion:Ks.version},e.remote.state.originatorInfo),{walletVersion:null===(v=e.remote.state.walletInfo)||void 0===v?void 0:v.version,params:{method:n.method,from:"mobile"}}),e.remote.state.communicationServerUrl).catch((e=>{}));const i=Object.assign(Object.assign({},n),{result:t.result,error:t.error?{code:null===(b=t.error)||void 0===b?void 0:b.code,message:null===(w=t.error)||void 0===w?void 0:w.message}:void 0,elapsedTime:r});e.state.rpcMethodTracker[t.id]=i,e.emit(Gs.RPC_UPDATE,i)}}e.emit(Gs.MESSAGE,{message:A})}}},{event:Gs.REJECTED,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var n;e.state.isOriginator&&!e.remote.state.ready?(Is.SocketService(`[SocketService: handleChannelRejected()] context=${e.state.context} channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`,e.remote.state.originatorInfo),$s(Object.assign(Object.assign({id:t,event:Xs.REJECTED},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Ks.version,walletVersion:null===(n=e.remote.state.walletInfo)||void 0===n?void 0:n.version}),e.remote.state.communicationServerUrl).catch((e=>{})),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Gs.REJECTED,{channelId:t}),e.remote.setConnectionStatus(Ws.DISCONNECTED)):Is.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`)}))}},{event:"clients_waiting_to_join",handler:function(e,t){return n=>{Is.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${e.state.context} on 'clients_waiting_to_join-${t}'`,n),e.emit(Gs.CLIENTS_WAITING,n)}}}],la=[{event:Gs.KEY_INFO,handler:function(e){return t=>{Is.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",t),e.emit(Gs.KEY_INFO,t)}}},{event:Gs.KEYS_EXCHANGED,handler:function(e){return()=>{var t,n,r;Is.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`);const{channelConfig:i}=e.remote.state;if(i){const t=e.getKeyExchange().getKeyInfo().ecies;i.localKey=t.private,i.otherKey=t.otherPubKey,e.remote.state.channelConfig=i,null===(n=e.remote.state.storageManager)||void 0===n||n.persistChannelConfig(i).catch((e=>{}))}e.emit(Gs.KEYS_EXCHANGED,{keysExchanged:null===(r=e.state.keyExchange)||void 0===r?void 0:r.areKeysExchanged(),isOriginator:e.state.isOriginator});const o={keyInfo:e.getKeyInfo()};e.emit(Gs.SERVICE_STATUS,o)}}}];function da(e,t){Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} setting socket listeners for channel ${t}...`);const{socket:n}=e.state,{keyExchange:r}=e.state;n&&e.state.isOriginator&&(e.state.debug&&(null==n||n.io.on("error",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=error`,t)})),null==n||n.io.on("reconnect",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect`,t),ia(e).catch((e=>{}))})),null==n||n.io.on("reconnect_error",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_error`,t)})),null==n||n.io.on("reconnect_failed",(()=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_failed`)}))),null==n||n.on("disconnect",(t=>(Is.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${t}' begin recovery...`),function(e){return t=>{Is.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${e.state.manualDisconnect}`,t),e.state.manualDisconnect||(e.emit(Gs.SOCKET_DISCONNECTED),ia(e).catch((e=>{})))}}(e)(t))))),ca.forEach((({event:r,handler:i})=>{null==n||n.on(`${r}-${t}`,i(e,t))})),la.forEach((({event:t,handler:n})=>{null==r||r.on(t,n(e))})),e.state.setupChannelListeners=!0}class ua extends h.exports.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:t,communicationLayerPreference:n,communicationServerUrl:r,context:i,remote:o,logging:s}=e;this.state.resumed=t,this.state.context=i,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=n,this.state.debug=!0===(null==s?void 0:s.serviceLayer),this.remote=o,!0===(null==s?void 0:s.serviceLayer)&&u.enable("SocketService:Layer"),this.state.communicationServerUrl=r,this.state.hasPlaintext=this.state.communicationServerUrl!==Us&&!0===(null==s?void 0:s.plaintext),Is.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:t,ecies:n,logging:r}=this.options,i={autoConnect:!1,transports:Fs,withCredentials:!0},o=this.state.communicationServerUrl;Is.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=Ne(o,i),function(e){if("undefined"!=typeof window&&"undefined"!=typeof document&&(Is.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,e),!e.state.focusListenerAdded)){const t=()=>{Is.SocketService("Document has focus --- reconnecting socket"),ia(e).catch((e=>{}))};window.addEventListener("focus",t),e.state.focusListenerAdded=!0,e.state.removeFocusListener=()=>{window.removeEventListener("focus",t),e.state.focusListenerAdded=!1}}}(this);const s={communicationLayer:this,otherPublicKey:t,sendPublicKey:!1,context:null!==(e=this.state.context)&&void 0!==e?e:"",ecies:n,logging:r};this.state.keyExchange=new ea(s)}resetKeys(){return Is.SocketService("[SocketService: resetKeys()] Resetting keys."),void(null===(e=this.state.keyExchange)||void 0===e||e.resetKeys());var e}createChannel(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var n,r,i;if(Is.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),null===(n=e.state.socket)||void 0===n?void 0:n.connected)throw new Error("socket already connected");null===(r=e.state.socket)||void 0===r||r.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const o=t.v4();e.state.channelId=o,da(e,o),yield new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Gs.JOIN_CHANNEL,{channelId:o,context:`${e.state.context}createChannel`,clientType:"dapp"},((r,i)=>Be(this,void 0,void 0,(function*(){try{yield ta(e,r,i),t()}catch(e){n(e)}}))))}));const s=null===(i=e.state.keyExchange)||void 0===i?void 0:i.getKeyInfo();return{channelId:o,pubKey:(null==s?void 0:s.ecies.public)||"",privKey:(null==s?void 0:s.ecies.private)||""}}))}(this)}))}connectToChannel({channelId:e,withKeyExchange:t=!1,authorized:n}){return function(e){return Be(this,arguments,void 0,(function*({options:e,instance:t}){const{channelId:n,authorized:r,withKeyExchange:i}=e,{state:o,remote:s}=t,{isOriginator:a=!1,socket:c,keyExchange:l}=o,{channelConfig:d}=s.state;if(null==c?void 0:c.connected)throw new Error("socket already connected");if(a&&(null==d?void 0:d.relayPersistence)){const{localKey:e,otherKey:t}=d;e&&t&&(null==l||l.setRelayPersistence({localKey:e,otherKey:t}))}return Object.assign(o,{manualDisconnect:!1,withKeyExchange:i,isOriginator:a,channelId:n}),null==c||c.connect(),da(t,n),!a&&r&&(null==l||l.setKeysExchanged(!0),Object.assign(s.state,{ready:!0,authorized:!0})),new Promise((e=>{var i;const s=null===(i=null==l?void 0:l.getKeyInfo())||void 0===i?void 0:i.ecies.public;null==c||c.emit(Gs.JOIN_CHANNEL,{channelId:n,context:`${o.context}_connectToChannel`,clientType:a?"dapp":"wallet",publicKey:r&&!a?s:void 0},((n,r)=>Be(this,void 0,void 0,(function*(){yield ta(t,n,r),e()}))))}))}))}({options:{channelId:e,withKeyExchange:t,authorized:n},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,t;null===(t=(e=this).state.socket)||void 0===t||t.emit(Gs.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Zs.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return Be(this,void 0,void 0,(function*(){return function(e,t){return Be(this,void 0,void 0,(function*(){var n,r,i;if(!e.state.channelId)throw Is.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(Is.SocketService(`[SocketService: handleSendMessage()] context=${e.state.context} areKeysExchanged=${null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`,t),null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.startsWith("key_handshake"))return function(e,t){var n;Is.SocketService(`[SocketService: handleKeyHandshake()] context=${e.state.context}`,t),null===(n=e.state.socket)||void 0===n||n.emit(Gs.MESSAGE,{id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:t})}(e,t),!0;!function(e,t){var n;if(!(null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&!e.remote.state.relayPersistence)throw Is.SocketService(`[SocketService: validateKeyExchange()] context=${e.state.context} ERROR keys not exchanged`,t),new Error("Keys not exchanged BBB")}(e,t),function(e,t){var n;const r=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"",i=null==t?void 0:t.id;e.state.isOriginator&&i&&(e.state.rpcMethodTracker[i]={id:i,timestamp:Date.now(),method:r},e.emit(Gs.RPC_UPDATE,e.state.rpcMethodTracker[i]))}(e,t);const o=yield oa(e,t);return e.remote.state.analytics&&e.remote.state.isOriginator&&t.method&&aa.includes(t.method.toLowerCase())&&$s({id:null!==(i=e.remote.state.channelId)&&void 0!==i?i:"",event:Xs.SDK_RPC_REQUEST,params:{method:t.method,from:"mobile"}},e.remote.state.communicationServerUrl).catch((e=>{})),function(e,t){return Be(this,void 0,void 0,(function*(){var n;const r=null==t?void 0:t.id,i=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"";if(e.state.isOriginator&&r)try{const n=ra(r,e.state.rpcMethodTracker,200).then((e=>({type:sa.RPC_CHECK,result:e}))),o=(()=>Be(this,void 0,void 0,(function*(){const t=yield(e=>Be(void 0,[e],void 0,(function*({rpcId:e,instance:t}){for(;t.state.lastRpcId===e||void 0===t.state.lastRpcId;)yield na(200);return t.state.lastRpcId})))({instance:e,rpcId:r}),n=yield ra(t,e.state.rpcMethodTracker,200);return{type:sa.SKIPPED_RPC,result:n}})))(),s=yield Promise.race([n,o]);if(s.type===sa.RPC_CHECK){const e=s.result;Is.SocketService(`[SocketService:handleRpcReplies()] id=${t.id} ${i} ( ${e.elapsedTime} ms)`,e.result)}else{if(s.type!==sa.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${r}`);{const t=Object.assign(Object.assign({},e.state.rpcMethodTracker[r]),{error:new Error("SDK_CONNECTION_ISSUE")});e.emit(Gs.RPC_UPDATE,t);const n={data:Object.assign(Object.assign({},t),{jsonrpc:"2.0"}),name:"metamask-provider"};e.emit(Gs.MESSAGE,{message:n})}}}catch(e){throw e}}))}(e,t).catch((e=>{})),o}))}(this,e)}))}ping(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n;Is.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`),null===(n=e.state.socket)||void 0===n||n.emit(Js.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})}))}(this)}pause(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n;Is.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,(null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged())&&(yield e.sendMessage({type:Js.PAUSE})),null===(n=e.state.socket)||void 0===n||n.disconnect()}))}(this)}isConnected(){var e;return null===(e=this.state.socket)||void 0===e?void 0:e.connected}resume(){return function(e){return Be(this,void 0,void 0,(function*(){const{state:t,remote:n}=e,{socket:r,channelId:i,context:o,keyExchange:s,isOriginator:a}=t,{isOriginator:c}=n.state;if(Is.SocketService(`[SocketService: resume()] channelId=${i} context=${o} connected=${null==r?void 0:r.connected} manualDisconnect=${t.manualDisconnect} resumed=${t.resumed} keysExchanged=${null==s?void 0:s.areKeysExchanged()}`),!i)throw Is.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");(null==r?void 0:r.connected)?(Is.SocketService("[SocketService: resume()] already connected."),r.emit(Js.PING,{id:i,clientType:c?"dapp":"wallet",context:"on_channel_config",message:""}),n.hasRelayPersistence()||(null==s?void 0:s.areKeysExchanged())||(a?yield e.sendMessage({type:Js.READY}):null==s||s.start({isOriginator:!1}))):(null==r||r.connect(),Is.SocketService(`[SocketService: resume()] after connecting socket --\x3e connected=${null==r?void 0:r.connected}`),null==r||r.emit(Gs.JOIN_CHANNEL,{channelId:i,context:`${o}_resume`,clientType:c?"dapp":"wallet"},((t,n)=>Be(this,void 0,void 0,(function*(){try{yield ta(e,t,n)}catch(e){}}))))),t.manualDisconnect=!1,t.resumed=!0}))}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(e,t){var n,r,i,o,s;Is.SocketService(`[SocketService: disconnect()] context=${e.state.context}`,t),(null==t?void 0:t.terminate)&&(null===(r=(n=e.state).removeFocusListener)||void 0===r||r.call(n),e.state.channelId=t.channelId,null===(i=e.state.socket)||void 0===i||i.removeAllListeners(),null===(o=e.state.keyExchange)||void 0===o||o.clean(),e.remote.state.ready=!1,e.state.socket=void 0,e.state.rpcMethodTracker={}),e.state.manualDisconnect=!0,null===(s=e.state.socket)||void 0===s||s.disconnect()}(this,e)}}var ha,fa,pa;function ga(e){return()=>Be(this,void 0,void 0,(function*(){var t,n,r;const{state:i}=e;if(i.authorized)return;yield(()=>Be(this,void 0,void 0,(function*(){for(;!i.walletInfo;)yield na(500)})))();const o="7.3".localeCompare((null===(t=i.walletInfo)||void 0===t?void 0:t.version)||"");if(Is.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${null===(n=i.walletInfo)||void 0===n?void 0:n.version} compareValue=${o}`),1!==o)return;const s=i.platformType===fa.MobileWeb||i.platformType===fa.ReactNative||i.platformType===fa.MetaMaskMobileWebview;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${s} channel=${i.channelId} walletVersion=${null===(r=i.walletInfo)||void 0===r?void 0:r.version}`),s&&(i.authorized=!0,e.emit(Gs.AUTHORIZED))}))}function ma(e){return t=>{const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${t}`),e.emit(Gs.CHANNEL_CREATED,t)}}function ya(e,t){return()=>{var n,r,i,o;const{state:s}=e;Is.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${s.channelId} keysExchanged=${null===(r=null===(n=s.communicationLayer)||void 0===n?void 0:n.getKeyInfo())||void 0===r?void 0:r.keysExchanged}`),s.analytics&&$s(Object.assign(Object.assign({id:null!==(i=s.channelId)&&void 0!==i?i:"",event:s.reconnection?Xs.RECONNECT:s.isOriginator?Xs.REQUEST:Xs.REQUEST_MOBILE},s.originatorInfo),{commLayer:t,sdkVersion:s.sdkVersion,walletVersion:null===(o=s.walletInfo)||void 0===o?void 0:o.version,commLayerVersion:Ks.version}),s.communicationServerUrl).catch((e=>{})),s.clientsConnected=!0,s.originatorInfoSent=!1,e.emit(Gs.CLIENTS_CONNECTED)}}function va(e){return t=>{const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${t}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),e.emit(Gs.CLIENTS_DISCONNECTED,n.channelId),e.setConnectionStatus(Ws.DISCONNECTED)}}function ba(e){return t=>{var n;const{state:r}=e;if(Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${t} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),e.setConnectionStatus(Ws.WAITING),e.emit(Gs.CLIENTS_WAITING,t),r.originatorConnectStarted){Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const t=(null===(n=r.autoConnectOptions)||void 0===n?void 0:n.timeout)||3e3,i=setTimeout((()=>{Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${t}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||e.setConnectionStatus(Ws.TIMEOUT),clearTimeout(i)}),t)}}}function wa(e,t){return n=>{var r,i,o,s,a,c,l,d;const{state:u}=e;if(Is.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${u.context} on commLayer.'keys_exchanged' channel=${u.channelId}`,n),null===(i=null===(r=u.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.keysExchanged){const t=Object.assign(Object.assign({},u.channelConfig),{channelId:null!==(o=u.channelId)&&void 0!==o?o:"",validUntil:(null===(s=u.channelConfig)||void 0===s?void 0:s.validUntil)||Hs,localKey:u.communicationLayer.getKeyInfo().ecies.private,otherKey:u.communicationLayer.getKeyInfo().ecies.otherPubKey});null===(a=u.storageManager)||void 0===a||a.persistChannelConfig(t).catch((e=>{})),e.setConnectionStatus(Ws.LINKED)}!function(e,t){var n,r,i,o,s,a,c,l;const{state:d}=e;Is.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${d.channelId}`,t);const u=Object.assign(Object.assign({},d.channelConfig),{channelId:null!==(n=d.channelId)&&void 0!==n?n:"",validUntil:null!==(i=null===(r=d.channelConfig)||void 0===r?void 0:r.validUntil)&&void 0!==i?i:0,relayPersistence:d.relayPersistence,localKey:null===(s=null===(o=d.communicationLayer)||void 0===o?void 0:o.state.keyExchange)||void 0===s?void 0:s.getKeyInfo().ecies.private,otherKey:null===(c=null===(a=d.communicationLayer)||void 0===a?void 0:a.state.keyExchange)||void 0===c?void 0:c.getKeyInfo().ecies.otherPubKey,lastActive:t.getTime()});null===(l=d.storageManager)||void 0===l||l.persistChannelConfig(u)}(e,new Date),u.analytics&&u.channelId&&$s(Object.assign(Object.assign({id:u.channelId,event:n.isOriginator?Xs.CONNECTED:Xs.CONNECTED_MOBILE},u.originatorInfo),{sdkVersion:u.sdkVersion,commLayer:t,commLayerVersion:Ks.version,walletVersion:null===(c=u.walletInfo)||void 0===c?void 0:c.version}),u.communicationServerUrl).catch((e=>{})),u.isOriginator=n.isOriginator,n.isOriginator||(null===(l=u.communicationLayer)||void 0===l||l.sendMessage({type:Js.READY}),u.ready=!0,u.paused=!1),n.isOriginator&&!u.originatorInfoSent&&(null===(d=u.communicationLayer)||void 0===d||d.sendMessage({type:Js.ORIGINATOR_INFO,originatorInfo:u.originatorInfo,originator:u.originatorInfo}),u.originatorInfoSent=!0)}}function Ea(e){return t=>{let n=t;t.message&&(n=n.message),function(e,t){const{state:n}=t;if(Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${n.context} on 'message' typeof=${typeof e}`,e),t.state.ready=!0,n.isOriginator||e.type!==Js.ORIGINATOR_INFO)if(n.isOriginator&&e.type===Js.WALLET_INFO)!function(e,t){const{state:n}=e;n.walletInfo=t.walletInfo,n.paused=!1}(t,e);else{if(n.isOriginator&&e.type===Js.WALLET_INIT)(function(e,t){return Be(this,void 0,void 0,(function*(){var n,r,i;const{state:o}=e;if(o.isOriginator){const o=t.data||{};if("object"==typeof o&&"accounts"in o&&"chainId"in o&&"walletKey"in o)try{const{channelConfig:t}=e.state;if(Is.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(t,null,2)),t){const s=o.accounts,a=o.chainId,c=o.walletKey;let l,d=!1;"deeplinkProtocol"in o&&(d=Boolean(o.deeplinkProtocol),e.state.deeplinkProtocolAvailable=d),"walletVersion"in o&&(l=o.walletVersion),yield null===(n=e.state.storageManager)||void 0===n?void 0:n.persistChannelConfig(Object.assign(Object.assign({},t),{otherKey:c,walletVersion:l,deeplinkProtocolAvailable:d,relayPersistence:!0})),yield null===(r=e.state.storageManager)||void 0===r?void 0:r.persistAccounts(s),yield null===(i=e.state.storageManager)||void 0===i?void 0:i.persistChainId(a)}e.emit(Gs.WALLET_INIT,{accounts:o.accounts,chainId:o.chainId})}catch(n){}}}))})(t,e).catch((e=>{Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Js.TERMINATE)(function(e){return Be(this,void 0,void 0,(function*(){const{state:t}=e;t.isOriginator&&(yield xa({options:{terminate:!0,sendMessage:!1},instance:e}),e.emit(Gs.TERMINATE))}))})(t).catch((e=>{Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Js.PAUSE)!function(e){const{state:t}=e;t.paused=!0,e.setConnectionStatus(Ws.PAUSED)}(t);else if(e.type===Js.READY&&n.isOriginator)!function(e){const{state:t}=e;e.setConnectionStatus(Ws.LINKED);const n=t.paused;t.paused=!1,e.emit(Gs.CLIENTS_READY,{isOriginator:t.isOriginator,walletInfo:t.walletInfo}),n&&(t.authorized=!0,e.emit(Gs.AUTHORIZED))}(t);else{if(e.type===Js.OTP&&n.isOriginator)return void function(e,t){var n;const{state:r}=e;e.emit(Gs.OTP,t.otpAnswer),1==="6.6".localeCompare((null===(n=r.walletInfo)||void 0===n?void 0:n.version)||"")&&e.emit(Gs.SDK_RPC_CALL,{method:qs.ETH_REQUESTACCOUNTS,params:[]})}(t,e);e.type===Js.AUTHORIZED&&n.isOriginator&&function(e){const{state:t}=e;t.authorized=!0,e.emit(Gs.AUTHORIZED)}(t)}t.emit(Gs.MESSAGE,e)}else!function(e,t){var n;const{state:r}=e;null===(n=r.communicationLayer)||void 0===n||n.sendMessage({type:Js.WALLET_INFO,walletInfo:r.walletInfo}),r.originatorInfo=t.originatorInfo||t.originator,e.emit(Gs.CLIENTS_READY,{isOriginator:r.isOriginator,originatorInfo:r.originatorInfo}),r.paused=!1}(t,e)}(n,e)}}function Ca(e){return()=>{const{state:t}=e;Is.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),t.ready=!1,t.authorized=!1,Vs(t),e.emitServiceStatusEvent({context:"socket_reconnect"})}}function _a(e){return()=>{const{state:t}=e;Is.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),t.ready=!1}}function Sa(e){return()=>Be(this,void 0,void 0,(function*(){var t,n,r,i,o,s,a;const{state:c}=e;Is.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),e.state.ready=!0,e.state.clientsConnected=!0,e.state.authorized=!0,e.state.relayPersistence=!0,null===(t=e.state.communicationLayer)||void 0===t||t.getKeyExchange().setKeysExchanged(!0),e.emit(Gs.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),e.emit(Gs.AUTHORIZED),e.emit(Gs.CLIENTS_READY),e.emit(Gs.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:null===(n=c.communicationLayer)||void 0===n?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:null===(r=c.communicationLayer)||void 0===r?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:null!==(i=c.channelId)&&void 0!==i?i:"",validUntil:null!==(s=null===(o=c.channelConfig)||void 0===o?void 0:o.validUntil)&&void 0!==s?s:Hs,relayPersistence:!0}),yield null===(a=c.storageManager)||void 0===a?void 0:a.persistChannelConfig(c.channelConfig)}catch(t){}}))}function ka({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,ecies:r,communicationServerUrl:i=Us,instance:o}){var s,a,c,l,d,u,h,f,p,g,m;const{state:y}=o;if(Is.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(y,null,2)),e!==ha.SOCKET)throw new Error("Invalid communication protocol");y.communicationLayer=new ua({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,transports:y.transports,communicationServerUrl:i,context:y.context,ecies:r,logging:y.logging,remote:o});let v="undefined"!=typeof document&&document.URL||"",b="undefined"!=typeof document&&document.title||"";(null===(s=y.dappMetadata)||void 0===s?void 0:s.url)&&(v=y.dappMetadata.url),(null===(a=y.dappMetadata)||void 0===a?void 0:a.name)&&(b=y.dappMetadata.name);const w=null!==(u=null!==(l=null===(c=y.dappMetadata)||void 0===c?void 0:c.name)&&void 0!==l?l:null===(d=y.dappMetadata)||void 0===d?void 0:d.url)&&void 0!==u?u:"N/A",E="undefined"!=typeof window&&void 0!==window.location&&null!==(h=window.location.hostname)&&void 0!==h?h:w,C={url:v,title:b,source:null===(f=y.dappMetadata)||void 0===f?void 0:f.source,dappId:E,icon:(null===(p=y.dappMetadata)||void 0===p?void 0:p.iconUrl)||(null===(g=y.dappMetadata)||void 0===g?void 0:g.base64Icon),platform:y.platformType,apiVersion:Ks.version,connector:null===(m=y.dappMetadata)||void 0===m?void 0:m.connector};y.originatorInfo=C;const _={[Gs.AUTHORIZED]:ga(o),[Gs.MESSAGE]:Ea(o),[Gs.CHANNEL_PERSISTENCE]:Sa(o),[Gs.CLIENTS_CONNECTED]:ya(o,e),[Gs.KEYS_EXCHANGED]:wa(o,e),[Gs.SOCKET_DISCONNECTED]:_a(o),[Gs.SOCKET_RECONNECT]:Ca(o),[Gs.CLIENTS_DISCONNECTED]:va(o),[Gs.KEY_INFO]:()=>{},[Gs.CHANNEL_CREATED]:ma(o),[Gs.CLIENTS_WAITING]:ba(o),[Gs.RPC_UPDATE]:e=>{o.emit(Gs.RPC_UPDATE,e)}};for(const[t,n]of Object.entries(_))try{y.communicationLayer.on(t,n)}catch(e){}}function xa(e){return Be(this,arguments,void 0,(function*({options:e,instance:n}){const{state:r}=n;return Is.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${r.channelId}`,e),new Promise(((i,o)=>{var s,a,c,l,d,u;(null==e?void 0:e.terminate)?(n.state.ready&&$s({id:null!==(s=n.state.channelId)&&void 0!==s?s:"",event:Xs.TERMINATED},n.state.communicationServerUrl).catch((e=>{})),r.ready=!1,r.paused=!1,null===(a=r.storageManager)||void 0===a||a.terminate(null!==(c=r.channelId)&&void 0!==c?c:""),n.state.terminated=!0,e.sendMessage?(null===(l=r.communicationLayer)||void 0===l?void 0:l.getKeyInfo().keysExchanged)&&n.state.communicationLayer&&oa(n.state.communicationLayer,{type:Js.TERMINATE}).then((()=>{i(!0)})).catch((e=>{o(e)})):i(!0),r.authorized=!1,r.relayPersistence=!1,r.channelId=t.v4(),e.channelId=r.channelId,r.channelConfig=void 0,r.originatorConnectStarted=!1,null===(d=r.communicationLayer)||void 0===d||d.disconnect(e),n.setConnectionStatus(Ws.TERMINATED)):(null===(u=r.communicationLayer)||void 0===u||u.disconnect(e),n.setConnectionStatus(Ws.DISCONNECTED),i(!0))}))}))}(ha||(ha={})).SOCKET="socket",function(e){e.NonBrowser="nodejs",e.MetaMaskMobileWebview="in-app-browser",e.DesktopWeb="web-desktop",e.MobileWeb="web-mobile",e.ReactNative="react-native"}(fa||(fa={}));class Aa extends h.exports.EventEmitter2{constructor(e){super(),this.state={ready:!1,authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:Us,context:"",persist:!1,clientsConnected:!1,sessionDuration:Hs,originatorConnectStarted:!1,debug:!1,_connectionStatus:Ws.DISCONNECTED},this._options=e;const{platformType:t,communicationLayerPreference:n,otherPublicKey:r,reconnect:i,walletInfo:o,dappMetadata:s,protocolVersion:a,transports:c,context:l,relayPersistence:d,ecies:h,analytics:f=!1,storage:p,sdkVersion:g,communicationServerUrl:m=Us,logging:y,autoConnect:v={timeout:zs}}=e;this.state.otherPublicKey=r,this.state.dappMetadata=s,this.state.walletInfo=o,this.state.transports=c,this.state.platformType=t,this.state.analytics=f,this.state.protocolVersion=null!=a?a:1,this.state.isOriginator=!r,this.state.relayPersistence=d,this.state.communicationServerUrl=m,this.state.context=l,this.state.terminated=!1,this.state.sdkVersion=g,this.setMaxListeners(50),this.setConnectionStatus(Ws.DISCONNECTED),(null==p?void 0:p.duration)&&(this.state.sessionDuration=Hs),this.state.storageOptions=p,this.state.autoConnectOptions=v,this.state.debug=!0===(null==y?void 0:y.remoteLayer),!0===(null==y?void 0:y.remoteLayer)&&u.enable("RemoteCommunication:Layer"),!0===(null==y?void 0:y.serviceLayer)&&u.enable("SocketService:Layer"),!0===(null==y?void 0:y.eciesLayer)&&u.enable("ECIES:Layer"),!0===(null==y?void 0:y.keyExchangeLayer)&&u.enable("KeyExchange:Layer"),this.state.logging=y,(null==p?void 0:p.storageManager)&&(this.state.storageManager=p.storageManager),Is.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${a} relayPersistence=${d} isOriginator=${this.state.isOriginator} communicationLayerPreference=${n} otherPublicKey=${r} reconnect=${i}`),this.state.isOriginator||ka({communicationLayerPreference:n,otherPublicKey:r,reconnect:i,ecies:h,communicationServerUrl:m,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return Be(this,void 0,void 0,(function*(){var e;if(this.state.storageManager){const t=yield this.state.storageManager.getPersistedChannelConfig({});t&&(this.state.channelConfig=t,this.state.channelId=t.channelId,this.state.deeplinkProtocolAvailable=null!==(e=t.deeplinkProtocolAvailable)&&void 0!==e&&e,t.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(Ws.LINKED),yield this.connectToChannel({channelId:t.channelId})))}ka({communicationLayerPreference:ha.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return Be(this,void 0,void 0,(function*(){return yield function(e){return Be(this,void 0,void 0,(function*(){var t;const{state:n}=e;if(!n.storageManager)return void Is.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const r=yield n.storageManager.getPersistedChannelConfig({});if(Is.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${n.originatorConnectStarted} channelConfig`,r),null===(t=n.communicationLayer)||void 0===t?void 0:t.isConnected())return Is.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),r;if(r){if(r.validUntil>Date.now())return n.channelConfig=r,n.originatorConnectStarted=!0,n.channelId=null==r?void 0:r.channelId,n.reconnection=!0,r;Is.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}n.originatorConnectStarted=!1}))}(this)}))}generateChannelIdConnect(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n,r,i,o,s;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(null===(t=e.communicationLayer)||void 0===t?void 0:t.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),null===(n=e.storageManager)||void 0===n||n.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:null===(i=null===(r=e.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.ecies.private,pubKey:null===(s=null===(o=e.communicationLayer)||void 0===o?void 0:o.getKeyInfo())||void 0===s?void 0:s.ecies.public};Is.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const a=yield e.communicationLayer.createChannel();Is.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",a);const c=Object.assign(Object.assign({},e.channelConfig),{channelId:a.channelId,localKey:a.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=a.channelId,e.channelConfig=c,{channelId:e.channelId,pubKey:a.pubKey,privKey:a.privKey}}))}(this.state)}))}clean(){return Vs(this.state)}connectToChannel({channelId:e,withKeyExchange:n,authorized:r}){return function(e){return Be(this,arguments,void 0,(function*({channelId:e,withKeyExchange:n,authorized:r,state:i}){var o,s,a;if(!t.validate(e))throw Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} channelId=${e} withKeyExchange=${n}`),null===(o=i.communicationLayer)||void 0===o?void 0:o.isConnected())return void Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} already connected - interrupt connection.`);i.channelId=e,yield null===(s=i.communicationLayer)||void 0===s?void 0:s.connectToChannel({channelId:e,authorized:r,withKeyExchange:n});const c=Object.assign(Object.assign({},i.channelConfig),{channelId:e,validUntil:Date.now()+i.sessionDuration});i.channelConfig=c,null===(a=i.storageManager)||void 0===a||a.persistChannelConfig(c)}))}({channelId:e,authorized:r,withKeyExchange:n,state:this.state})}sendMessage(e){return function(e,t){return Be(this,void 0,void 0,(function*(){var n,r;const{state:i}=e;Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} paused=${i.paused} ready=${i.ready} relayPersistence=${i.relayPersistence} authorized=${i.authorized} socket=${null===(n=i.communicationLayer)||void 0===n?void 0:n.isConnected()} clientsConnected=${i.clientsConnected} status=${i._connectionStatus}`,t),i.relayPersistence||i.ready&&(null===(r=i.communicationLayer)||void 0===r?void 0:r.isConnected())&&i.clientsConnected||(Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((t=>{e.once(Gs.CLIENTS_READY,t)})),Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} AFTER SKIP / READY -- sending pending message`));try{const n=yield function(e,t){return Be(this,void 0,void 0,(function*(){return new Promise((n=>{var r;const{state:i}=e;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} ready=${i.ready} authorized=${i.authorized} method=${t.method}`),!i.isOriginator||i.authorized||i.relayPersistence?null===(r=i.communicationLayer)||void 0===r||r.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)})):e.once(Gs.AUTHORIZED,(()=>{var e;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} AFTER SKIP / AUTHORIZED -- sending pending message`),null===(e=i.communicationLayer)||void 0===e||e.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)}))}))}))}))}(e,t);return n}catch(e){throw e}}))}(this,e)}testStorage(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t;const n=yield null===(t=e.storageManager)||void 0===t?void 0:t.getPersistedChannelConfig();Is.RemoteCommunication("[RemoteCommunication: testStorage()] res",n)}))}(this.state)}))}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return Be(this,void 0,void 0,(function*(){var e;Is.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.ping()}))}testLogger(){Is.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),Is.SocketService(`testLogger() channel=${this.state.channelId}`),Is.Ecies(`testLogger() channel=${this.state.channelId}`),Is.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;Is.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),null===(e=this.state.communicationLayer)||void 0===e||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(Gs.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(Gs.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getKeyInfo()}resetKeys(){var e;null===(e=this.state.communicationLayer)||void 0===e||e.resetKeys()}setOtherPublicKey(e){var t;const n=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange();if(!n)throw new Error("KeyExchange is not initialized.");n.getOtherPublicKey()!==e&&n.setOtherPublicKey(e)}pause(){return Be(this,void 0,void 0,(function*(){var e;Is.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.pause(),this.setConnectionStatus(Ws.PAUSED)}))}getVersion(){return Ks.version}hasRelayPersistence(){var e;return null!==(e=this.state.relayPersistence)&&void 0!==e&&e}resume(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t;const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: resume()] channel=${n.channelId}`),yield null===(t=n.communicationLayer)||void 0===t?void 0:t.resume(),e.setConnectionStatus(Ws.LINKED)}))}(this)}))}encrypt(e){var t,n,r;const i=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange(),o=null==i?void 0:i.getOtherPublicKey();if(!o)throw new Error("KeyExchange not completed");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.encrypt(e,o)}decrypt(e){var t,n,r;if(!(null===(t=this.state.communicationLayer)||void 0===t?void 0:t.state.eciesInstance))throw new Error("ECIES instance is not initialized");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return function(e){return Be(this,arguments,void 0,(function*({channelId:e,state:n}){var r,i,o;if(!t.validate(e))throw Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${n.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(n.isOriginator)return void Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} isOriginator=${n.isOriginator} channelId=${e}`);const{socket:s}=null!==(i=null===(r=n.communicationLayer)||void 0===r?void 0:r.state)&&void 0!==i?i:{};(null==s?void 0:s.connected)||(Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket already connected`),null==s||s.connect()),$s(Object.assign(Object.assign({id:e,event:Xs.REJECTED},n.originatorInfo),{sdkVersion:n.sdkVersion,commLayerVersion:Ks.version,walletVersion:null===(o=n.walletInfo)||void 0===o?void 0:o.version}),n.communicationServerUrl).catch((e=>{})),yield new Promise(((t,r)=>{null==s||s.emit(Gs.REJECTED,{channelId:e},((e,i)=>{Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket=${null==s?void 0:s.id}`,{error:e,response:i}),e?r(e):t(i)}))}))}))}({channelId:e,state:this.state})}disconnect(e){return Be(this,void 0,void 0,(function*(){return xa({options:e,instance:this})}))}}!function(e){e.RENEW="renew",e.LINK="link"}(pa||(pa={}));var Ma="ERC721",La="ERC1155",Oa={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`MetaMask: Connected to chain with ID "${e}".`},warnings:{chainIdDeprecation:"MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",networkVersionDeprecation:"MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",selectedAddressDeprecation:"MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",enableDeprecation:"MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102",sendDeprecation:"MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193",events:{close:"MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect",data:"MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message",networkChanged:"MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged",notification:"MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message"},rpc:{ethDecryptDeprecation:"MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",ethGetEncryptionPublicKeyDeprecation:"MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",walletWatchAssetNFTExperimental:"MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle"},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function Ta(e){const t={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{t.ethDecryptDeprecation||"eth_decrypt"!==n.method?t.ethGetEncryptionPublicKeyDeprecation||"eth_getEncryptionPublicKey"!==n.method?!t.walletWatchAssetNFTExperimental&&"wallet_watchAsset"===n.method&&[Ma,La].includes(n.params?.type||"")&&(e.warn(Oa.warnings.rpc.walletWatchAssetNFTExperimental),t.walletWatchAssetNFTExperimental=!0):(e.warn(Oa.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),t.ethGetEncryptionPublicKeyDeprecation=!0):(e.warn(Oa.warnings.rpc.ethDecryptDeprecation),t.ethDecryptDeprecation=!0),i()}}var Ra=4294967295,Pa=Math.floor(Math.random()*Ra);var Ia=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Na=(e,t,n)=>(Ia(e,t,"read from private field"),n?n.call(e):t.get(e)),Ba=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Da=(e,t,n,r)=>(Ia(e,t,"write to private field"),t.set(e,n),n),$a=(e,t,n)=>(Ia(e,t,"access private method"),n),ja=-32600,Ka=-32603,Ua={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function Fa(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}var Ha=(e,t)=>Object.hasOwnProperty.call(e,t);class za extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...o}=e,{path:s}=e,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function qa(e){return"object"==typeof e&&null!=e}function Va(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Wa(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=n,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Va(r)}\``}=e;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Ga(e,t,n,r){(function(e){return qa(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Wa(i,t,n,r);e&&(yield e)}}function*Ya(e,t,n={}){const{path:r=[],branch:i=[e],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&qa(t.schema)&&qa(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,a))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[l,d,u]of t.entries(e,a)){const t=Ya(d,u,{path:void 0===l?r:[...r,l],branch:void 0===l?i:[...i,d],coerce:o,mask:s,message:n.message});for(const n of t)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):o&&(d=n[1],void 0===l?e=d:e instanceof Map?e.set(l,d):e instanceof Set?e.add(d):qa(e)&&(void 0!==d||l in e)&&(e[l]=d))}if("not_valid"!==c)for(const r of t.refiner(e,a))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class Za{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:s=function*(){}}=e;this.type=t,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(e,t)=>Ga(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Ga(i(e,t),t,this,e):()=>[]}assert(e,t){return Ja(e,this,t)}create(e,t){return Xa(e,this,t)}is(e){return Qa(e,this)}mask(e,t){return function(e,t,n){const r=ec(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return ec(e,this,t)}}function Ja(e,t,n){const r=ec(e,t,{message:n});if(r[0])throw r[0]}function Xa(e,t,n){const r=ec(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function Qa(e,t){return!ec(e,t)[0]}function ec(e,t,n={}){const r=Ya(e,t,n),i=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(i[0]){return[new za(i[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}function tc(e,t){return new Za({type:e,schema:null,validator:t})}function nc(e){let t;return new Za({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function rc(e){return new Za({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Va(e)}`})}function ic(e){const t=Va(e),n=typeof e;return new Za({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${Va(n)}`})}function oc(){return tc("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Va(e)}`))}function sc(e){const t=e?Object.keys(e):[],n=tc("never",(()=>!1));return new Za({type:"object",schema:e||null,*entries(r){if(e&&qa(r)){const i=new Set(Object.keys(r));for(const n of t)i.delete(n),yield[n,r[n],e[n]];for(const e of i)yield[e,r[e],n]}},validator:e=>qa(e)||`Expected an object, but received: ${Va(e)}`,coercer:e=>qa(e)?{...e}:e})}function ac(e){return new Za({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function cc(e,t){return new Za({type:"record",schema:null,*entries(n){if(qa(n))for(const r in n){const i=n[r];yield[r,r,e],yield[r,i,t]}},validator:e=>qa(e)||`Expected an object, but received: ${Va(e)}`})}function lc(){return tc("string",(e=>"string"==typeof e||`Expected a string, but received: ${Va(e)}`))}function dc(e){const t=e.map((e=>e.type)).join(" | ");return new Za({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const i=[];for(const t of e){const[...e]=Ya(n,t,r),[o]=e;if(!o[0])return[];for(const[t]of e)t&&i.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Va(n)}`,...i]}})}var uc=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};function hc(){throw new Error("setTimeout has not been defined")}function fc(){throw new Error("clearTimeout has not been defined")}var pc=hc,gc=fc;function mc(e){if(pc===setTimeout)return setTimeout(e,0);if((pc===hc||!pc)&&setTimeout)return pc=setTimeout,setTimeout(e,0);try{return pc(e,0)}catch(t){try{return pc.call(null,e,0)}catch(t){return pc.call(this,e,0)}}}"function"==typeof De.setTimeout&&(pc=setTimeout),"function"==typeof De.clearTimeout&&(gc=clearTimeout);var yc,vc=[],bc=!1,wc=-1;function Ec(){bc&&yc&&(bc=!1,yc.length?vc=yc.concat(vc):wc=-1,vc.length&&Cc())}function Cc(){if(!bc){var e=mc(Ec);bc=!0;for(var t=vc.length;t;){for(yc=vc,vc=[];++wc<t;)yc&&yc[wc].run();wc=-1,t=vc.length}yc=null,bc=!1,function(e){if(gc===clearTimeout)return clearTimeout(e);if((gc===fc||!gc)&&clearTimeout)return gc=clearTimeout,clearTimeout(e);try{return gc(e)}catch(t){try{return gc.call(null,e)}catch(t){return gc.call(this,e)}}}(e)}}function _c(e,t){this.fun=e,this.array=t}function Sc(){}_c.prototype.run=function(){this.fun.apply(null,this.array)};var kc=Sc,xc=Sc,Ac=Sc,Mc=Sc,Lc=Sc,Oc=Sc,Tc=Sc,Rc=De.performance||{},Pc=Rc.now||Rc.mozNow||Rc.msNow||Rc.oNow||Rc.webkitNow||function(){return(new Date).getTime()},Ic=new Date,Nc={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];vc.push(new _c(e,t)),1!==vc.length||bc||mc(Cc)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:kc,addListener:xc,once:Ac,off:Mc,removeListener:Lc,removeAllListeners:Oc,emit:Tc,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Pc.call(Rc),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ic)/1e3}},Bc=e=>sc(e);function Dc({path:e,branch:t}){const n=e[e.length-1];return Ha(t[t.length-2],n)}function $c(e){return new Za({...e,type:`optional ${e.type}`,validator:(t,n)=>!Dc(n)||e.validator(t,n),refiner:(t,n)=>!Dc(n)||e.refiner(t,n)})}var jc,Kc,Uc,Fc=dc([ic(null),tc("boolean",(e=>"boolean"==typeof e)),tc("finite number",(e=>Qa(e,oc())&&Number.isFinite(e))),lc(),rc(nc((()=>Fc))),cc(lc(),nc((()=>Fc)))]),Hc=(jc=Fc,Kc=tc("any",(()=>!0)),Uc=e=>(function(e,t,n="Assertion failed",r=uc){try{Ja(e,t)}catch(e){throw function(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}(r,`${n}: ${function(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}(e)}.`)}}(e,Fc),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))),new Za({...jc,coercer:(e,t)=>Qa(e,Kc)?jc.coercer(Uc(e),t):jc.coercer(e,t)}));function zc(e){try{return function(e){Xa(e,Hc)}(e),!0}catch{return!1}}var qc=ic("2.0"),Vc=function(e){return new Za({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}(dc([oc(),lc()])),Wc=Bc({code:tc("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${Va(e)}`)),message:lc(),data:$c(Hc),stack:$c(lc())}),Gc=dc([cc(lc(),Hc),rc(Hc)]),Yc=Bc({id:Vc,jsonrpc:qc,method:lc(),params:$c(Gc)}),Zc=Bc({jsonrpc:qc,method:lc(),params:$c(Gc)});function Jc(e){return Qa(e,Yc)}function Xc(e){return Qa(e,Wc)}sc({id:Vc,jsonrpc:qc,result:ac(tc("unknown",(()=>!0))),error:ac(Wc)}),dc([Bc({id:Vc,jsonrpc:qc,result:Hc}),Bc({id:Vc,jsonrpc:qc,error:Wc})]);var Qc="Unspecified error message. This is a bug, please report it.",el={code:Ka,message:nl(Ka)},tl="Unspecified server error.";function nl(e,t=Qc){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(Ha(Ua,t))return Ua[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return tl}return t}function rl(e,{fallbackError:t=el,shouldIncludeStack:n=!0}={}){if(!Xc(t))throw new Error("Must provide fallback error with integer number code and string message.");const r=function(e,t){if(e&&"object"==typeof e&&"serialize"in e&&"function"==typeof e.serialize)return e.serialize();if(Xc(e))return e;return{...t,data:{cause:il(e)}}}(e,t);return n||delete r.stack,r}function il(e){return Array.isArray(e)?e.map((e=>zc(e)?e:Fa(e)?ol(e):null)):Fa(e)?ol(e):zc(e)?e:null}function ol(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return zc(r)&&(t[n]=r),t}),{})}var sl=hl;hl.default=hl,hl.stable=ml,hl.stableStringify=ml;var al="[...]",cl="[Circular]",ll=[],dl=[];function ul(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function hl(e,t,n,r){var i;void 0===r&&(r=ul()),pl(e,"",0,[],void 0,0,r);try{i=0===dl.length?JSON.stringify(e,t,n):JSON.stringify(e,vl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ll.length;){var o=ll.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function fl(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:e}),ll.push([r,n,t,i])):dl.push([t,n,e]):(r[n]=e,ll.push([r,n,t]))}function pl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void fl(cl,e,t,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void fl(al,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void fl(al,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)pl(e[a],a,a,r,e,o,s);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var l=c[a];pl(e[l],l,a,r,e,o,s)}}r.pop()}}function gl(e,t){return e<t?-1:e>t?1:0}function ml(e,t,n,r){void 0===r&&(r=ul());var i,o=yl(e,"",0,[],void 0,0,r)||e;try{i=0===dl.length?JSON.stringify(o,t,n):JSON.stringify(o,vl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ll.length;){var s=ll.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function yl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void fl(cl,e,t,i);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void fl(al,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void fl(al,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)yl(e[a],a,a,r,e,o,s);else{var c={},l=Object.keys(e).sort(gl);for(a=0;a<l.length;a++){var d=l[a];yl(e[d],d,a,r,e,o,s),c[d]=e[d]}if(void 0===i)return c;ll.push([i,t,e]),i[t]=c}r.pop()}}function vl(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(dl.length>0)for(var r=0;r<dl.length;r++){var i=dl[r];if(i[1]===t&&i[0]===n){n=i[2],dl.splice(r,1);break}}return e.call(this,t,n)}}var bl=jt(sl),wl=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}}(this.data)&&(e.data.cause=il(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return bl(this.serialize(),El,2)}};function El(e,t){if("[Circular]"!==t)return t}var Cl=e=>function(e,t){const[n,r]=function(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}(t);return new wl(e,n??nl(e),r)}(ja,e);var _l={};function Sl(){}function kl(){kl.init.call(this)}function xl(e){return void 0===e._maxListeners?kl.defaultMaxListeners:e._maxListeners}function Al(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new Sl,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=xl(e))&&i>0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(a)}}else s=o[t]=n,++e._eventsCount;return e}function Ml(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Ll(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Ol(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}Sl.prototype=Object.create(null),kl.EventEmitter=kl,kl.usingDomains=!1,kl.prototype.domain=void 0,kl.prototype._events=void 0,kl.prototype._maxListeners=void 0,kl.defaultMaxListeners=10,kl.init=function(){this.domain=null,kl.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Sl,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kl.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},kl.prototype.getMaxListeners=function(){return xl(this)},kl.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var d="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Ol(e,r),o=0;o<r;++o)i[o].call(n)}(n,d,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=Ol(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,d,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=Ol(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=Ol(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=Ol(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,d,this,i)}return!0},kl.prototype.addListener=function(e,t){return Al(this,e,t,!1)},kl.prototype.on=kl.prototype.addListener,kl.prototype.prependListener=function(e,t){return Al(this,e,t,!0)},kl.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ml(this,e,t)),this},kl.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ml(this,e,t)),this},kl.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Sl:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Sl,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},kl.prototype.off=function(e,t){return this.removeListener(e,t)},kl.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Sl,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Sl:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Sl,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},kl.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},kl.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ll.call(e,t)},kl.prototype.listenerCount=Ll,kl.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Tl=Kt(Object.freeze({__proto__:null,EventEmitter:kl,default:kl}));Object.defineProperty(_l,"__esModule",{value:!0});const Rl=Tl;function Pl(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}let Il=class extends Rl.EventEmitter{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)Pl(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)Pl(n[r],this,t)}return!0}};var Nl,Bl,Dl,$l,jl,Kl,Ul,Fl,Hl,zl,ql,Vl,Wl,Gl,Yl,Zl,Jl,Xl,Ql,ed=_l.default=Il,td=class e extends ed{constructor({notificationHandler:e}={}){super(),Ba(this,$l),Ba(this,Kl),Ba(this,Fl),Ba(this,Nl,!1),Ba(this,Bl,void 0),Ba(this,Dl,void 0),Da(this,Bl,[]),Da(this,Dl,e)}destroy(){Na(this,Bl).forEach((e=>{"destroy"in e&&"function"==typeof e.destroy&&e.destroy()})),Da(this,Bl,[]),Da(this,Nl,!0)}push(e){$a(this,$l,jl).call(this),Na(this,Bl).push(e)}handle(e,t){if($a(this,$l,jl).call(this),t&&"function"!=typeof t)throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?t?$a(this,Kl,Ul).call(this,e,t):$a(this,Kl,Ul).call(this,e):t?$a(this,Fl,Hl).call(this,e,t):this._promiseHandle(e)}asMiddleware(){return $a(this,$l,jl).call(this),async(t,n,r,i)=>{var o,s;try{const[a,c,l]=await $a(o=e,Vl,Wl).call(o,t,n,Na(this,Bl));return c?(await $a(s=e,Zl,Jl).call(s,l),i(a)):r((async t=>{var n;try{await $a(n=e,Zl,Jl).call(n,l)}catch(e){return t(e)}return t()}))}catch(e){return i(e)}}}async _promiseHandle(e){return new Promise(((t,n)=>{$a(this,Fl,Hl).call(this,e,((e,r)=>{e&&void 0===r?n(e):t(r)})).catch(n)}))}};Nl=new WeakMap,Bl=new WeakMap,Dl=new WeakMap,$l=new WeakSet,jl=function(){if(Na(this,Nl))throw new Error("This engine is destroyed and can no longer be used.")},Kl=new WeakSet,Ul=async function(e,t){try{if(0===e.length){const e=[{id:null,jsonrpc:"2.0",error:new wl(ja,"Request batch must contain plain objects. Received an empty array")}];return t?t(null,e):e}const n=(await Promise.all(e.map(this._promiseHandle.bind(this)))).filter((e=>void 0!==e));return t?t(null,n):n}catch(e){if(t)return t(e);throw e}},Fl=new WeakSet,Hl=async function(e,t){var n;if(!e||Array.isArray(e)||"object"!=typeof e){const n=new wl(ja,"Requests must be plain objects. Received: "+typeof e,{request:e});return t(n,{id:null,jsonrpc:"2.0",error:n})}if("string"!=typeof e.method){const n=new wl(ja,"Must specify a string method. Received: "+typeof e.method,{request:e});return Na(this,Dl)&&!Jc(e)?t(null):t(n,{id:e.id??null,jsonrpc:"2.0",error:n})}if(Na(this,Dl)&&Qa(e,Zc)&&!Jc(e)){try{await Na(this,Dl).call(this,e)}catch(e){return t(e)}return t(null)}let r=null;const i={...e},o={id:i.id,jsonrpc:i.jsonrpc};try{await $a(n=td,zl,ql).call(n,i,o,Na(this,Bl))}catch(e){r=e}return r&&(delete o.result,o.error||(o.error=rl(r))),t(r,o)},zl=new WeakSet,ql=async function(e,t,n){var r,i,o;const[s,a,c]=await $a(r=td,Vl,Wl).call(r,e,t,n);if($a(i=td,Xl,Ql).call(i,e,t,a),await $a(o=td,Zl,Jl).call(o,c),s)throw s},Vl=new WeakSet,Wl=async function(e,t,n){var r;const i=[];let o=null,s=!1;for(const a of n)if([o,s]=await $a(r=td,Gl,Yl).call(r,e,t,a,i),s)break;return[o,s,i.reverse()]},Gl=new WeakSet,Yl=async function(e,t,n,r){return new Promise((i=>{const o=e=>{const n=e||t.error;n&&(t.error=rl(n)),i([n,!0])},s=n=>{t.error?o(t.error):(n&&("function"!=typeof n&&o(new wl(Ka,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof n}" for request:\n${rd(e)}`,{request:e})),r.push(n)),i([null,!1]))};try{n(e,t,s,o)}catch(e){o(e)}}))},Zl=new WeakSet,Jl=async function(e){for(const t of e)await new Promise(((e,n)=>{t((t=>t?n(t):e()))}))},Xl=new WeakSet,Ql=function(e,t,n){if(!Ha(t,"result")&&!Ha(t,"error"))throw new wl(Ka,`JsonRpcEngine: Response has no error or result for request:\n${rd(e)}`,{request:e});if(!n)throw new wl(Ka,`JsonRpcEngine: Nothing ended request:\n${rd(e)}`,{request:e})},Ba(td,zl),Ba(td,Vl),Ba(td,Gl),Ba(td,Zl),Ba(td,Xl);var nd=td;function rd(e){return JSON.stringify(e,null,2)}var id=Object.freeze(["eth_subscription"]),od=(e=console)=>[(e,t,n,r)=>{const i=e.id,o=Pa=(Pa+1)%Ra;e.id=o,t.id=o,n((n=>{e.id=i,t.id=i,n()}))},sd(e),Ta(e)];function sd(e){return(t,n,r)=>{"string"==typeof t.method&&t.method||(n.error=Cl({message:"The request 'method' must be a non-empty string.",data:t})),r((t=>{const{error:r}=n;return r?(e.error(`MetaMask - RPC Error: ${r.message}`,r),t()):t()}))}}var ad=(e,t,n=!0)=>(r,i)=>{r||i.error?t(r||i.error):!n||Array.isArray(i)?e(i):e(i.result)},cd=e=>Boolean(e)&&"string"==typeof e&&e.startsWith("0x"),ld=()=>{};async function dd(e,t){try{const t=await async function(){return{name:ud(window),icon:await hd(window)}}();e.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:t},ld)}catch(e){t.error({message:Oa.errors.sendSiteMetadata(),originalError:e})}}function ud(e){const{document:t}=e,n=t.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=t.querySelector('head > meta[name="title"]');return r?r.content:t.title&&t.title.length>0?t.title:window.location.hostname}async function hd(e){const{document:t}=e,n=t.querySelectorAll('head > link[rel~="icon"]');for(const e of Array.from(n))if(e&&await fd(e.href))return e.href;return null}async function fd(e){return new Promise(((t,n)=>{try{const n=document.createElement("img");n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e}catch(e){n(e)}}))}var pd=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},gd=(e,t,n)=>(pd(e,t,"read from private field"),n?n.call(e):t.get(e)),md=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},yd=(e,t,n,r)=>(pd(e,t,"write to private field"),t.set(e,n),n);function vd(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}class bd extends kl{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)vd(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)vd(n[r],this,t)}return!0}}var wd,Ed,Cd=jt((function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n})),_d=class e extends bd{constructor({logger:t=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),md(this,wd,void 0),md(this,Ed,void 0),this._log=t,this.setMaxListeners(n),this._state={...e._defaultState},yd(this,Ed,null),yd(this,wd,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new nd;r.forEach((e=>i.push(e))),this._rpcEngine=i}get chainId(){return gd(this,wd)}get selectedAddress(){return gd(this,Ed)}isConnected(){return this._state.isConnected}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw Cl({message:Oa.errors.invalidRequestArgs(),data:e});const{method:t,params:n}=e;if("string"!=typeof t||0===t.length)throw Cl({message:Oa.errors.invalidRequestMethod(),data:e});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw Cl({message:Oa.errors.invalidRequestParams(),data:e});const r=null==n?{method:t}:{method:t,params:n};return new Promise(((e,t)=>{this._rpcRequest(r,ad(e,t))}))}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:t,chainId:n,isUnlocked:r,networkVersion:i}=e;this._handleConnect(n),this._handleChainChanged({chainId:n,networkVersion:i}),this._handleUnlockStateChanged({accounts:t,isUnlocked:r}),this._handleAccountsChanged(t)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,t){let n=t;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),"eth_accounts"!==e.method&&"eth_requestAccounts"!==e.method||(n=(n,r)=>{this._handleAccountsChanged(r.result??[],"eth_accounts"===e.method),t(n,r)})),this._rpcEngine.handle(e,n)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(Oa.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let n;this._state.isConnected=!1,e?(n=new wl(1013,t??Oa.errors.disconnected()),this._log.debug(n)):(n=new wl(1011,t??Oa.errors.permanentlyDisconnected()),this._log.error(n),yd(this,wd,null),this._state.accounts=null,yd(this,Ed,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",n)}}_handleChainChanged({chainId:e}={}){cd(e)?(this._handleConnect(e),e!==gd(this,wd)&&(yd(this,wd,e),this._state.initialized&&this.emit("chainChanged",gd(this,wd)))):this._log.error(Oa.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,t=!1){let n=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),n=[]);for(const t of e)if("string"!=typeof t){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),n=[];break}if(!Cd(this._state.accounts,n)&&(t&&null!==this._state.accounts&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",n),this._state.accounts=n,gd(this,Ed)!==n[0]&&yd(this,Ed,n[0]||null),this._state.initialized)){const e=[...n];this.emit("accountsChanged",e)}}_handleUnlockStateChanged({accounts:e,isUnlocked:t}={}){"boolean"==typeof t?t!==this._state.isUnlocked&&(this._state.isUnlocked=t,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};wd=new WeakMap,Ed=new WeakMap,_d._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var Sd,kd,xd=_d,Ad={exports:{}};function Md(){return kd?Sd:(kd=1,Sd=Tl.EventEmitter)}var Ld,Od=Kt(Dt);Ld="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var Td=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},Rd=/%[sdj%]/g;function Pd(e){if(!Yd(e)){for(var t=[],n=0;n<arguments.length;n++)t.push($d(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(Rd,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])Vd(s)||!Qd(s)?o+=" "+s:o+=" "+$d(s);return o}function Id(e,t){if(Jd(De.process))return function(){return Id(e,t).apply(this,arguments)};if(!0===Nc.noDeprecation)return e;var n=!1;return function(){if(!n){if(Nc.throwDeprecation)throw new Error(t);Nc.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var Nd,Bd={};function Dd(e){return Jd(Nd)&&(Nd=Nc.env.NODE_DEBUG||""),e=e.toUpperCase(),Bd[e]||(new RegExp("\\b"+e+"\\b","i").test(Nd)?Bd[e]=function(){var t=Pd.apply(null,arguments);console.error("%s %d: %s",e,0,t)}:Bd[e]=function(){}),Bd[e]}function $d(e,t){var n={seen:[],stylize:Kd};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),qd(t)?n.showHidden=t:t&&lu(n,t),Jd(n.showHidden)&&(n.showHidden=!1),Jd(n.depth)&&(n.depth=2),Jd(n.colors)&&(n.colors=!1),Jd(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=jd),Ud(n,e,n.depth)}function jd(e,t){var n=$d.styles[t];return n?"["+$d.colors[n][0]+"m"+e+"["+$d.colors[n][1]+"m":e}function Kd(e,t){return e}function Ud(e,t,n){if(e.customInspect&&t&&nu(t.inspect)&&t.inspect!==$d&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return Yd(r)||(r=Ud(e,r,n)),r}var i=function(e,t){if(Jd(t))return e.stylize("undefined","undefined");if(Yd(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return Gd(t)?e.stylize(""+t,"number"):qd(t)?e.stylize(""+t,"boolean"):Vd(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),tu(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Fd(t);if(0===o.length){if(nu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Xd(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(eu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(tu(t))return Fd(t)}var c,l="",d=!1,u=["{","}"];return zd(t)&&(d=!0,u=["[","]"]),nu(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),Xd(t)&&(l=" "+RegExp.prototype.toString.call(t)),eu(t)&&(l=" "+Date.prototype.toUTCString.call(t)),tu(t)&&(l=" "+Fd(t)),0!==o.length||d&&0!=t.length?n<0?Xd(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)du(t,String(s))?o.push(Hd(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(Hd(e,t,n,r,i,!0))})),o}(e,t,n,s,o):o.map((function(r){return Hd(e,t,n,s,r,d)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,u)):u[0]+l+u[1]}function Fd(e){return"["+Error.prototype.toString.call(e)+"]"}function Hd(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),du(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Vd(n)?Ud(e,c.value,null):Ud(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),Jd(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function zd(e){return Array.isArray(e)}function qd(e){return"boolean"==typeof e}function Vd(e){return null===e}function Wd(e){return null==e}function Gd(e){return"number"==typeof e}function Yd(e){return"string"==typeof e}function Zd(e){return"symbol"==typeof e}function Jd(e){return void 0===e}function Xd(e){return Qd(e)&&"[object RegExp]"===ou(e)}function Qd(e){return"object"==typeof e&&null!==e}function eu(e){return Qd(e)&&"[object Date]"===ou(e)}function tu(e){return Qd(e)&&("[object Error]"===ou(e)||e instanceof Error)}function nu(e){return"function"==typeof e}function ru(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function iu(e){return Xe.isBuffer(e)}function ou(e){return Object.prototype.toString.call(e)}function su(e){return e<10?"0"+e.toString(10):e.toString(10)}$d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},$d.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var au=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function cu(){console.log("%s - %s",function(){var e=new Date,t=[su(e.getHours()),su(e.getMinutes()),su(e.getSeconds())].join(":");return[e.getDate(),au[e.getMonth()],t].join(" ")}(),Pd.apply(null,arguments))}function lu(e,t){if(!t||!Qd(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function du(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var uu="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function hu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(uu&&e[uu]){var t;if("function"!=typeof(t=e[uu]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,uu,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),uu&&Object.defineProperty(t,uu,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,Td(e))}function fu(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}function pu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if("function"!=typeof r)throw new TypeError("The last argument must be of type Function");var i=this,o=function(){return r.apply(i,arguments)};e.apply(this,t).then((function(e){Nc.nextTick(o.bind(null,null,e))}),(function(e){Nc.nextTick(fu.bind(null,e,o))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Td(e)),t}hu.custom=uu;var gu,mu,yu,vu,bu={inherits:Ld,_extend:lu,log:cu,isBuffer:iu,isPrimitive:ru,isFunction:nu,isError:tu,isDate:eu,isObject:Qd,isRegExp:Xd,isUndefined:Jd,isSymbol:Zd,isString:Yd,isNumber:Gd,isNullOrUndefined:Wd,isNull:Vd,isBoolean:qd,isArray:zd,inspect:$d,deprecate:Id,format:Pd,debuglog:Dd,promisify:hu,callbackify:pu},wu=Kt(Object.freeze({__proto__:null,_extend:lu,callbackify:pu,debuglog:Dd,default:bu,deprecate:Id,format:Pd,inherits:Ld,inspect:$d,isArray:zd,isBoolean:qd,isBuffer:iu,isDate:eu,isError:tu,isFunction:nu,isNull:Vd,isNullOrUndefined:Wd,isNumber:Gd,isObject:Qd,isPrimitive:ru,isRegExp:Xd,isString:Yd,isSymbol:Zd,isUndefined:Jd,log:cu,promisify:hu}));function Eu(){if(mu)return gu;function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}mu=1;var i=Od.Buffer,o=wu.inspect,s=o&&o.custom||"inspect";return gu=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return function(e,t,n){t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,o=i.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,r=a,i.prototype.copy.call(t,n,r),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=i.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,s),0==(e-=s)){s===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(s));break}++r}return this.length-=r,t}},{key:s,value:function(e,n){return o(this,t(t({},n),{},{depth:0,customInspect:!1}))}}]),e}(),gu}function Cu(){if(vu)return yu;function e(e,r){n(e,r),t(e)}function t(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}return vu=1,yu={destroy:function(r,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Nc.nextTick(n,this,r)):Nc.nextTick(n,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(n){!i&&n?o._writableState?o._writableState.errorEmitted?Nc.nextTick(t,o):(o._writableState.errorEmitted=!0,Nc.nextTick(e,o,n)):Nc.nextTick(e,o,n):i?(Nc.nextTick(t,o),i(n)):Nc.nextTick(t,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},yu}var _u,Su,ku={},xu={};function Au(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,xu[e]=r}function Mu(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function Lu(){if(Su)return _u;Su=1;var e=ku.codes.ERR_INVALID_OPT_VALUE;return _u={getHighWaterMark:function(t,n,r,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(n,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new e(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}}Au("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),Au("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,i,o;if("string"==typeof t&&(i="not ",t.substr(0,4)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))o="The ".concat(e," ").concat(r," ").concat(Mu(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+1>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(Mu(t,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),Au("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Au("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),Au("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Au("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),Au("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Au("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Au("ERR_STREAM_WRITE_AFTER_END","write after end"),Au("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Au("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),Au("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),ku.codes=xu;var Ou,Tu,Ru,Pu,Iu,Nu,Bu="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},Du=Kt(Object.freeze({__proto__:null,default:Bu}));function $u(){if(Tu)return Ou;function e(e){try{if(!$t.localStorage)return!1}catch(e){return!1}var t=$t.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}return Tu=1,Ou=function(t,n){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),r=!0}return t.apply(this,arguments)}},Ou}function ju(){if(Pu)return Ru;function e(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var t;Pu=1,Ru=E,E.WritableState=w;var n,r={deprecate:$u()},i=Md(),o=Od.Buffer,s=(void 0!==$t?$t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},a=Cu(),c=Lu().getHighWaterMark,l=ku.codes,d=l.ERR_INVALID_ARG_TYPE,u=l.ERR_METHOD_NOT_IMPLEMENTED,h=l.ERR_MULTIPLE_CALLBACK,f=l.ERR_STREAM_CANNOT_PIPE,p=l.ERR_STREAM_DESTROYED,g=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,y=l.ERR_UNKNOWN_ENCODING,v=a.errorOrDestroy;function b(){}function w(n,r,i){t=t||Ku(),n=n||{},"boolean"!=typeof i&&(i=r instanceof t),this.objectMode=!!n.objectMode,i&&(this.objectMode=this.objectMode||!!n.writableObjectMode),this.highWaterMark=c(this,n,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===n.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=n.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new h;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Nc.nextTick(i,r),Nc.nextTick(A,e,t),e._writableState.errorEmitted=!0,v(e,r)):(i(r),e._writableState.errorEmitted=!0,v(e,r),A(e,t))}(e,n,r,t,i);else{var o=k(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),r?Nc.nextTick(_,e,n,o,i):_(e,n,o,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==n.emitClose,this.autoDestroy=!!n.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function E(e){var r=this instanceof(t=t||Ku());if(!r&&!n.call(E,this))return new E(e);this._writableState=new w(e,this,r),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),i.call(this)}function C(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new p("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function _(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function S(t,n){n.bufferProcessing=!0;var r=n.bufferedRequest;if(t._writev&&r&&r.next){var i=n.bufferedRequestCount,o=new Array(i),s=n.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,C(t,n,!0,n.length,o,"",s.finish),n.pendingcb++,n.lastBufferedRequest=null,s.next?(n.corkedRequestsFree=s.next,s.next=null):n.corkedRequestsFree=new e(n),n.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,d=r.encoding,u=r.callback;if(C(t,n,!1,n.objectMode?1:l.length,l,d,u),r=r.next,n.bufferedRequestCount--,n.writing)break}null===r&&(n.lastBufferedRequest=null)}n.bufferedRequest=r,n.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&v(e,n),t.prefinished=!0,e.emit("prefinish"),A(e,t)}))}function A(e,t){var n=k(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Nc.nextTick(x,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}return Du(E,i),w.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(w.prototype,"buffer",{get:r.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!n.call(this,e)||this===E&&e&&e._writableState instanceof w}})):n=function(e){return e instanceof this},E.prototype.pipe=function(){v(this,new f)},E.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,c=!i.objectMode&&(r=e,o.isBuffer(r)||r instanceof s);return c&&!o.isBuffer(e)&&(e=function(e){return o.from(e)}(e)),"function"==typeof t&&(n=t,t=null),c?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=b),i.ending?function(e,t){var n=new m;v(e,n),Nc.nextTick(t,n)}(this,n):(c||function(e,t,n,r){var i;return null===n?i=new g:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(v(e,i),Nc.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,s){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var c=t.objectMode?1:r.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,c,r,i,s);return l}(this,i,c,e,t,n)),a},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||S(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new y(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,n){n(new u("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,A(e,t),n&&(t.finished?Nc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=a.destroy,E.prototype._undestroy=a.undestroy,E.prototype._destroy=function(e,t){t(e)},Ru}function Ku(){if(Nu)return Iu;Nu=1;var e=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};Iu=s;var t=nh(),n=ju();Du(s,t);for(var r=e(n.prototype),i=0;i<r.length;i++){var o=r[i];s.prototype[o]||(s.prototype[o]=n.prototype[o])}function s(e){if(!(this instanceof s))return new s(e);t.call(this,e),n.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",a)))}function a(){this._writableState.ended||Nc.nextTick(c,this)}function c(e){e.end()}return Object.defineProperty(s.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(s.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(s.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),Iu}var Uu=Xe.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Fu(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Uu(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=zu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=qu;break;default:return void(this.write=Hu)}this.charBuffer=new Xe(6),this.charReceived=0,this.charLength=0}function Hu(e){return e.toString(this.encoding)}function zu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function qu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Fu.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(e=e.slice(n,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),i=(t+=e.toString(this.encoding,0,i)).length-1,(r=t.charCodeAt(i))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},Fu.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},Fu.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};var Vu=Kt(Object.freeze({__proto__:null,StringDecoder:Fu})),Wu=ku.codes.ERR_STREAM_PREMATURE_CLOSE;function Gu(){}var Yu,Zu,Ju,Xu,Qu,eh,th=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||Gu);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){o=!1,a=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,d=function(){i=!1,l=!0,o||r.call(t)},u=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new Wu),r.call(t,e)):o&&!a?(t._writableState&&t._writableState.ended||(e=new Wu),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",c),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",s),t.on("close",s)),t.on("end",d),t.on("finish",c),!1!==n.error&&t.on("error",u),t.on("close",h),function(){t.removeListener("complete",c),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",d),t.removeListener("error",u),t.removeListener("close",h)}};function nh(){if(eh)return Qu;var e;eh=1,Qu=E,E.ReadableState=w,Tl.EventEmitter;var t,n=function(e,t){return e.listeners(t).length},r=Md(),i=Od.Buffer,o=(void 0!==$t?$t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},s=wu;t=s&&s.debuglog?s.debuglog("stream"):function(){};var a,c,l,d=Eu(),u=Cu(),h=Lu().getHighWaterMark,f=ku.codes,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_STREAM_PUSH_AFTER_EOF,m=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Du(E,r);var v=u.errorOrDestroy,b=["error","close","destroy","pause","resume"];function w(t,n,r){e=e||Ku(),t=t||{},"boolean"!=typeof r&&(r=n instanceof e),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=h(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(a||(a=Vu.StringDecoder),this.decoder=new a(t.encoding),this.encoding=t.encoding)}function E(t){if(e=e||Ku(),!(this instanceof E))return new E(t);var n=this instanceof e;this._readableState=new w(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),r.call(this)}function C(e,n,r,s,a){t("readableAddChunk",n);var c,l=e._readableState;if(null===n)l.reading=!1,function(e,n){if(t("onEofChunk"),!n.ended){if(n.decoder){var r=n.decoder.end();r&&r.length&&(n.buffer.push(r),n.length+=n.objectMode?1:r.length)}n.ended=!0,n.sync?x(e):(n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,A(e)))}}(e,l);else if(a||(c=function(e,t){var n,r;return r=t,i.isBuffer(r)||r instanceof o||"string"==typeof t||void 0===t||e.objectMode||(n=new p("chunk",["string","Buffer","Uint8Array"],t)),n}(l,n)),c)v(e,c);else if(l.objectMode||n&&n.length>0)if("string"==typeof n||l.objectMode||Object.getPrototypeOf(n)===i.prototype||(n=function(e){return i.from(e)}(n)),s)l.endEmitted?v(e,new y):_(e,l,n,!0);else if(l.ended)v(e,new g);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(n=l.decoder.write(n),l.objectMode||0!==n.length?_(e,l,n,!1):M(e,l)):_(e,l,n,!1)}else s||(l.reading=!1,M(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function _(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),M(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=u.destroy,E.prototype._undestroy=u.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=i.from(e,t),t=""),n=!0),C(this,e,t,!1,n)},E.prototype.unshift=function(e){return C(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){a||(a=Vu.StringDecoder);var t=new a(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var S=1073741824;function k(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var n=e._readableState;t("emitReadable",n.needReadable,n.emittedReadable),n.needReadable=!1,n.emittedReadable||(t("emitReadable",n.flowing),n.emittedReadable=!0,Nc.nextTick(A,e))}function A(e){var n=e._readableState;t("emitReadable_",n.destroyed,n.length,n.ended),n.destroyed||!n.length&&!n.ended||(e.emit("readable"),n.emittedReadable=!1),n.needReadable=!n.flowing&&!n.ended&&n.length<=n.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,Nc.nextTick(L,e,t))}function L(e,n){for(;!n.reading&&!n.ended&&(n.length<n.highWaterMark||n.flowing&&0===n.length);){var r=n.length;if(t("maybeReadMore read 0"),e.read(0),r===n.length)break}n.readingMore=!1}function O(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function T(e){t("readable nexttick read 0"),e.read(0)}function R(e,n){t("resume",n.reading),n.reading||e.read(0),n.resumeScheduled=!1,e.emit("resume"),P(e),n.flowing&&!n.reading&&e.read(0)}function P(e){var n=e._readableState;for(t("flow",n.flowing);n.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function N(e){var n=e._readableState;t("endReadable",n.endEmitted),n.endEmitted||(n.ended=!0,Nc.nextTick(B,n,e))}function B(e,n){if(t("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,n.readable=!1,n.emit("end"),e.autoDestroy)){var r=n._writableState;(!r||r.autoDestroy&&r.finished)&&n.destroy()}}function D(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}return E.prototype.read=function(e){t("read",e),e=parseInt(e,10);var n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&((0!==n.highWaterMark?n.length>=n.highWaterMark:n.length>0)||n.ended))return t("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?N(this):x(this),null;if(0===(e=k(e,n))&&n.ended)return 0===n.length&&N(this),null;var i,o=n.needReadable;return t("need readable",o),(0===n.length||n.length-e<n.highWaterMark)&&t("length less than watermark",o=!0),n.ended||n.reading?t("reading or ended",o=!1):o&&(t("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=k(r,n))),null===(i=e>0?I(e,n):null)?(n.needReadable=n.length<=n.highWaterMark,e=0):(n.length-=e,n.awaitDrain=0),0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&N(this)),null!==i&&this.emit("data",i),i},E.prototype._read=function(e){v(this,new m("_read()"))},E.prototype.pipe=function(e,r){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,t("pipe count=%d opts=%j",o.pipesCount,r);var s=r&&!1===r.end||e===Nc.stdout||e===Nc.stderr?p:a;function a(){t("onend"),e.end()}o.endEmitted?Nc.nextTick(s):i.once("end",s),e.on("unpipe",(function n(r,s){t("onunpipe"),r===i&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,t("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",n),i.removeListener("end",a),i.removeListener("end",p),i.removeListener("data",d),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}));var c=function(e){return function(){var r=e._readableState;t("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,0===r.awaitDrain&&n(e,"data")&&(r.flowing=!0,P(e))}}(i);e.on("drain",c);var l=!1;function d(n){t("ondata");var r=e.write(n);t("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==D(o.pipes,e))&&!l&&(t("false write response, pause",o.awaitDrain),o.awaitDrain++),i.pause())}function u(r){t("onerror",r),p(),e.removeListener("error",u),0===n(e,"error")&&v(e,r)}function h(){e.removeListener("finish",f),p()}function f(){t("onfinish"),e.removeListener("close",h),p()}function p(){t("unpipe"),i.unpipe(e)}return i.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",u),e.once("close",h),e.once("finish",f),e.emit("pipe",i),o.flowing||(t("pipe resume"),i.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},E.prototype.on=function(e,n){var i=r.prototype.on.call(this,e,n),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,t("on readable",o.length,o.reading),o.length?x(this):o.reading||Nc.nextTick(T,this))),i},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var n=r.prototype.removeListener.call(this,e,t);return"readable"===e&&Nc.nextTick(O,this),n},E.prototype.removeAllListeners=function(e){var t=r.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Nc.nextTick(O,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(t("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Nc.nextTick(R,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return t("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(t("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var n=this,r=this._readableState,i=!1;for(var o in e.on("end",(function(){if(t("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&n.push(e)}n.push(null)})),e.on("data",(function(o){t("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(n.push(o)||(i=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<b.length;s++)e.on(b[s],this.emit.bind(this,b[s]));return this._read=function(n){t("wrapped _read",n),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===c&&(c=function(){if(Zu)return Yu;var e;function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Zu=1;var n=th,r=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),s=Symbol("ended"),a=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function u(e){var t=e[r];if(null!==t){var n=e[l].read();null!==n&&(e[a]=null,e[r]=null,e[i]=null,t(d(n,!1)))}}function h(e){Nc.nextTick(u,e)}var f=Object.getPrototypeOf((function(){})),p=Object.setPrototypeOf((t(e={get stream(){return this[l]},next:function(){var e=this,t=this[o];if(null!==t)return Promise.reject(t);if(this[s])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise((function(t,n){Nc.nextTick((function(){e[o]?n(e[o]):t(d(void 0,!0))}))}));var n,r=this[a];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[s]?n(d(void 0,!0)):t[c](n,r)}),r)}}(r,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[c])}return this[a]=n,n}},Symbol.asyncIterator,(function(){return this})),t(e,"return",(function(){var e=this;return new Promise((function(t,n){e[l].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),e),f);return Yu=function(e){var u,f=Object.create(p,(t(u={},l,{value:e,writable:!0}),t(u,r,{value:null,writable:!0}),t(u,i,{value:null,writable:!0}),t(u,o,{value:null,writable:!0}),t(u,s,{value:e._readableState.endEmitted,writable:!0}),t(u,c,{value:function(e,t){var n=f[l].read();n?(f[a]=null,f[r]=null,f[i]=null,e(d(n,!1))):(f[r]=e,f[i]=t)},writable:!0}),u));return f[a]=null,n(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=f[i];return null!==t&&(f[a]=null,f[r]=null,f[i]=null,t(e)),void(f[o]=e)}var n=f[r];null!==n&&(f[a]=null,f[r]=null,f[i]=null,n(d(void 0,!0))),f[s]=!0})),e.on("readable",h.bind(null,f)),f},Yu}()),c(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=I,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===l&&(l=Xu?Ju:(Xu=1,Ju=function(){throw new Error("Readable.from is not available in the browser")})),l(E,e,t)}),Qu}var rh=uh,ih=ku.codes,oh=ih.ERR_METHOD_NOT_IMPLEMENTED,sh=ih.ERR_MULTIPLE_CALLBACK,ah=ih.ERR_TRANSFORM_ALREADY_TRANSFORMING,ch=ih.ERR_TRANSFORM_WITH_LENGTH_0,lh=Ku();function dh(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new sh);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function uh(e){if(!(this instanceof uh))return new uh(e);lh.call(this,e),this._transformState={afterTransform:dh.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",hh)}function hh(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?fh(this,null,null):this._flush((function(t,n){fh(e,t,n)}))}function fh(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new ch;if(e._transformState.transforming)throw new ah;return e.push(null)}Du(uh,lh),uh.prototype.push=function(e,t){return this._transformState.needTransform=!1,lh.prototype.push.call(this,e,t)},uh.prototype._transform=function(e,t,n){n(new oh("_transform()"))},uh.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},uh.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},uh.prototype._destroy=function(e,t){lh.prototype._destroy.call(this,e,(function(e){t(e)}))};var ph,gh=yh,mh=rh;function yh(e){if(!(this instanceof yh))return new yh(e);mh.call(this,e)}Du(yh,mh),yh.prototype._transform=function(e,t,n){n(null,e)};var vh=ku.codes,bh=vh.ERR_MISSING_ARGS,wh=vh.ERR_STREAM_DESTROYED;function Eh(e){if(e)throw e}function Ch(e){e()}function _h(e,t){return e.pipe(t)}var Sh=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=function(e){return e.length?"function"!=typeof e[e.length-1]?Eh:e.pop():Eh}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new bh("streams");var o=t.map((function(e,n){var s=n<t.length-1;return function(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===ph&&(ph=th),ph(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new wh("pipe"))}}(e,s,n>0,(function(e){r||(r=e),e&&o.forEach(Ch),s||(o.forEach(Ch),i(r))}))}));return t.reduce(_h)};!function(e,t){(t=Ad.exports=nh()).Stream=t,t.Readable=t,t.Writable=ju(),t.Duplex=Ku(),t.Transform=rh,t.PassThrough=gh,t.finished=th,t.pipeline=Sh}(0,Ad.exports);var kh=Ad.exports;var xh={},Ah={exports:{}},Mh=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}};function Lh(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Oh(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}Ah.exports=Mh(Lh),Ah.exports.strict=Mh(Oh),Lh.proto=Lh((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Lh(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Oh(this)},configurable:!0})}));var Th=Ah.exports,Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.Substream=void 0;const Ph=kh;class Ih extends Ph.Duplex{constructor({parent:e,name:t}){super({objectMode:!0}),this._parent=e,this._name=t}_read(){}_write(e,t,n){this._parent.push({name:this._name,data:e}),n()}}Rh.Substream=Ih;var Nh=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xh,"__esModule",{value:!0}),xh.ObjectMultiplex=void 0;const Bh=kh,Dh=Nh(Th),$h=Rh,jh=Symbol("IGNORE_SUBSTREAM");let Kh=class extends Bh.Duplex{constructor(e={}){super(Object.assign(Object.assign({},e),{objectMode:!0})),this._substreams={}}createStream(e){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already ended`);if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);const t=new $h.Substream({parent:this,name:e});return this._substreams[e]=t,function(e,t){const n=(0,Dh.default)(t);(0,Bh.finished)(e,{readable:!1},n),(0,Bh.finished)(e,{writable:!1},n)}(this,(e=>t.destroy(e||void 0))),t}ignoreStream(e){if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);this._substreams[e]=jh}_read(){}_write(e,t,n){const{name:r,data:i}=e;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${e}"`),n();const o=this._substreams[r];return o?(o!==jh&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};xh.ObjectMultiplex=Kh;var Uh=jt(xh.ObjectMultiplex);const Fh=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;Fh.writable=e=>Fh(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState,Fh.readable=e=>Fh(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState,Fh.duplex=e=>Fh.writable(e)&&Fh.readable(e),Fh.transform=e=>Fh.duplex(e)&&"function"==typeof e._transform;var Hh,zh=Fh,qh=class extends xd{constructor(e,{jsonRpcStreamName:t,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!zh.duplex(e))throw new Error(Oa.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new Uh;kh.pipeline(e,o,e,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=function(e={}){const t={},n=new kh.Duplex({objectMode:!0,read:()=>{},write:function(n,o,s){let a=null;try{n.id?function(e){const{id:n}=e;if(null===n)return;const r=t[n];r?(delete t[n],Object.assign(r.res,e),setTimeout(r.end)):console.warn(`StreamMiddleware - Unknown response id "${n}"`)}(n):function(n){e?.retryOnMessage&&n.method===e.retryOnMessage&&Object.values(t).forEach((({req:e,retryCount:n=0})=>{if(!e.id)return;if(n>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${e.id}"`);const r=t[e.id];r&&(r.retryCount=n+1),i(e)})),r.emit("notification",n)}(n)}catch(e){a=e}s(a)}}),r=new ed;return{events:r,middleware:(e,n,r,o)=>{t[e.id]={req:e,res:n,next:r,end:o},i(e)},stream:n};function i(e){n.push(e)}}({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),kh.pipeline(this._jsonRpcConnection.stream,o.createStream(t),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",(t=>{const{method:n,params:r}=t;"metamask_accountsChanged"===n?this._handleAccountsChanged(r):"metamask_unlockStateChanged"===n?this._handleUnlockStateChanged(r):"metamask_chainChanged"===n?this._handleChainChanged(r):id.includes(n)?this.emit("message",{type:n,data:r}):"METAMASK_STREAM_FAILURE"===n&&e.destroy(new Error(Oa.errors.permanentlyDisconnected()))}))}async _initializeStateAsync(){let e;try{e=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(e)}_handleStreamDisconnect(e,t){let n=`MetaMask: Lost connection to "${e}".`;t?.stack&&(n+=`\n${t.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,t?t.message:void 0)}_handleChainChanged({chainId:e,networkVersion:t}={}){cd(e)&&(e=>Boolean(e)&&"string"==typeof e)(t)?"loading"===t?this._handleDisconnect(!0):super._handleChainChanged({chainId:e}):this._log.error(Oa.errors.invalidNetworkParams(),{chainId:e,networkVersion:t})}},Vh=class extends qh{constructor(e,{jsonRpcStreamName:t="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(e,{jsonRpcStreamName:t,logger:n,maxEventListeners:r,rpcMiddleware:od(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},md(this,Hh,void 0),this._initializeStateAsync(),yd(this,Hh,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",(e=>{const{method:t}=e;id.includes(t)&&(this.emit("data",e),this.emit("notification",e.params.result))})),i)if("complete"===document.readyState)dd(this._rpcEngine,this._log);else{const e=()=>{dd(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",e)};window.addEventListener("DOMContentLoaded",e)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Oa.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Oa.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),gd(this,Hh)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Oa.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(e,t){this._rpcRequest(e,t)}addListener(e,t){return this._warnOfDeprecation(e),super.addListener(e,t)}on(e,t){return this._warnOfDeprecation(e),super.on(e,t)}once(e,t){return this._warnOfDeprecation(e),super.once(e,t)}prependListener(e,t){return this._warnOfDeprecation(e),super.prependListener(e,t)}prependOnceListener(e,t){return this._warnOfDeprecation(e),super.prependOnceListener(e,t)}_handleDisconnect(e,t){super._handleDisconnect(e,t),gd(this,Hh)&&!e&&yd(this,Hh,null)}_warnOfDeprecation(e){!1===this._sentWarnings?.events[e]&&(this._log.warn(Oa.warnings.events[e]),this._sentWarnings.events[e]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Oa.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((e,t)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},ad(e,t))}catch(e){t(e)}}))}send(e,t){return this._sentWarnings.send||(this._log.warn(Oa.warnings.sendDeprecation),this._sentWarnings.send=!0),"string"!=typeof e||t&&!Array.isArray(t)?e&&"object"==typeof e&&"function"==typeof t?this._rpcRequest(e,t):this._sendSync(e):new Promise(((n,r)=>{try{this._rpcRequest({method:e,params:t},ad(n,r,!1))}catch(e){r(e)}}))}_sendSync(e){let t;switch(e.method){case"eth_accounts":t=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":t=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(e,ld),t=!0;break;case"net_version":t=gd(this,Hh)??null;break;default:throw new Error(Oa.errors.unsupportedSync(e.method))}return{id:e.id,jsonrpc:e.jsonrpc,result:t}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise((e=>{this.on("_initialized",(()=>e()))})),this._state.isUnlocked),requestBatch:async e=>{if(!Array.isArray(e))throw Cl({message:"Batch requests must be made with an array of request objects.",data:e});return new Promise(((t,n)=>{this._rpcRequest(e,ad(t,n))}))}},{get:(e,t,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Oa.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(e,t,...n))})}_handleChainChanged({chainId:e,networkVersion:t}={}){super._handleChainChanged({chainId:e,networkVersion:t}),this._state.isConnected&&t!==gd(this,Hh)&&(yd(this,Hh,t),this._state.initialized&&this.emit("networkChanged",gd(this,Hh)))}};Hh=new WeakMap;const Wh=u("MM_SDK");Wh.color="#FFAC1C";var Gh={},Yh={};Object.defineProperty(Yh,"__esModule",{value:!0}),Yh.EthereumProviderError=Yh.EthereumRpcError=void 0;const Zh=sl;class Jh extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return Zh.default(this.serialize(),Xh,2)}}function Xh(e,t){if("[Circular]"!==t)return t}Yh.EthereumRpcError=Jh,Yh.EthereumProviderError=class extends Jh{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};var Qh={},ef={};Object.defineProperty(ef,"__esModule",{value:!0}),ef.errorValues=ef.errorCodes=void 0,ef.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},ef.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=ef,n=Yh,r=t.errorCodes.rpc.internal,i={code:r,message:o(r)};function o(n,r="Unspecified error message. This is a bug, please report it."){if(Number.isInteger(n)){const r=n.toString();if(l(t.errorValues,r))return t.errorValues[r].message;if(a(n))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function s(e){if(!Number.isInteger(e))return!1;const n=e.toString();return!!t.errorValues[n]||!!a(e)}function a(e){return e>=-32099&&e<=-32e3}function c(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function l(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=o,e.isValidCode=s,e.serializeError=function(e,{fallbackError:t=i,shouldIncludeStack:r=!1}={}){var a,d;if(!t||!Number.isInteger(t.code)||"string"!=typeof t.message)throw new Error("Must provide fallback error with integer number code and string message.");if(e instanceof n.EthereumRpcError)return e.serialize();const u={};if(e&&"object"==typeof e&&!Array.isArray(e)&&l(e,"code")&&s(e.code)){const t=e;u.code=t.code,t.message&&"string"==typeof t.message?(u.message=t.message,l(t,"data")&&(u.data=t.data)):(u.message=o(u.code),u.data={originalError:c(e)})}else{u.code=t.code;const n=null===(a=e)||void 0===a?void 0:a.message;u.message=n&&"string"==typeof n?n:t.message,u.data={originalError:c(e)}}const h=null===(d=e)||void 0===d?void 0:d.stack;return r&&e&&h&&"string"==typeof h&&(u.stack=h),u}}(Qh);var tf={};Object.defineProperty(tf,"__esModule",{value:!0}),tf.ethErrors=void 0;const nf=Yh,rf=Qh,of=ef;function sf(e,t){const[n,r]=cf(t);return new nf.EthereumRpcError(e,n||rf.getMessageFromCode(e),r)}function af(e,t){const[n,r]=cf(t);return new nf.EthereumProviderError(e,n||rf.getMessageFromCode(e),r)}function cf(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}tf.ethErrors={rpc:{parse:e=>sf(of.errorCodes.rpc.parse,e),invalidRequest:e=>sf(of.errorCodes.rpc.invalidRequest,e),invalidParams:e=>sf(of.errorCodes.rpc.invalidParams,e),methodNotFound:e=>sf(of.errorCodes.rpc.methodNotFound,e),internal:e=>sf(of.errorCodes.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return sf(t,e)},invalidInput:e=>sf(of.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>sf(of.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>sf(of.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>sf(of.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>sf(of.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>sf(of.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>af(of.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>af(of.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>af(of.errorCodes.provider.unsupportedMethod,e),disconnected:e=>af(of.errorCodes.provider.disconnected,e),chainDisconnected:e=>af(of.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new nf.EthereumProviderError(t,n,r)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=Yh;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const n=Qh;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=tf;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=ef;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Gh);var lf={exports:{}};lf.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=n(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,r){void 0===r&&(r=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(n),s=Math.max(i,o),a=0,c=e.map([t,n],(function(t){var n=s-e.getVersionPrecision(t),r=t+new Array(n+1).join(".0");return e.map(r.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(r&&(a=s-Math.min(i,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)r.push(t(e[n]));return r},e.find=function(e,t){var n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){var i=e[n];if(t(i,n))return i}},e.assign=function(e){for(var t,n,r=e,i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){r[t]=e[t]}))};for(t=0,n=o.length;t<n;t+=1)a();return e},e.getBrowserAlias=function(e){return r.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return r.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},o=n(18);function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=function(){function e(){}var t,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],null&&s(t.prototype,null),n&&s(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=c(n(92)),i=c(n(93)),o=c(n(94)),s=c(n(95)),a=c(n(17));function c(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(r.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},r=0,i={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(i[t]=s,o+=1):"object"==typeof s&&(n[t]=s,r+=1)})),r>0){var s=Object.keys(n),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var l=this.satisfies(n[c]);if(void 0!==l)return l}var d=a.default.find(s,(function(e){return t.isPlatform(e)}));if(d){var u=this.satisfies(n[d]);if(void 0!==u)return u}}if(o>0){var h=Object.keys(i),f=a.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(i[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n},t.compareVersion=function(e){var t=[0],n=e,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(a.default.compareVersions(i,n,r))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},n=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=i.default.getMacOSVersionName(t),r={name:o.OS_MAP.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=i.default.getAndroidVersionName(t),r={name:o.OS_MAP.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:o.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},n=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},n=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},n=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},n=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=s,e.exports=t.default}});var df=jt(lf.exports);const uf={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class hf{constructor({shouldSetOnWindow:e,connectionStream:t,shouldSendMetadata:n=!1,shouldShimWeb3:r,sdkInstance:i}){const o=new gf({connectionStream:t,shouldSendMetadata:n,shouldSetOnWindow:e,shouldShimWeb3:r,autoRequestAccounts:!1}),s=new Proxy(o,{deleteProperty:()=>!0});if(this.provider=s,this.sdkInstance=i,e&&"undefined"!=typeof window)try{a=o,window.ethereum=a,window.dispatchEvent(new Event("ethereum#initialized"))}catch(e){Wh("[Ethereum] Unable to set global provider - window.ethereum may be read-only",e)}var a;if(r&&"undefined"!=typeof window)try{!function(e,t=console){let n=!1,r=!1;if(!window.web3){const i="__isMetaMaskShim__";let o={currentProvider:e};Object.defineProperty(o,i,{value:!0,enumerable:!0,configurable:!1,writable:!1}),o=new Proxy(o,{get:(o,s,...a)=>("currentProvider"!==s||n?"currentProvider"===s||s===i||r||(r=!0,t.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),e.request({method:"metamask_logWeb3ShimUsage"}).catch((e=>{t.debug("MetaMask: Failed to log web3 shim usage.",e)}))):(n=!0,t.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(o,s,...a)),set:(...e)=>(t.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...e))}),Object.defineProperty(window,"web3",{value:o,enumerable:!1,configurable:!0,writable:!0})}}(this.provider)}catch(e){Wh("[Ethereum] Unable to shim web3 - window.web3 may be read-only",e)}this.provider.on("display_uri",(e=>{this.sdkInstance.emit(uf.DisplayURI,e)})),this.provider.on("_initialized",(()=>{const e={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(uf.Initialized,e),Wh("[Ethereum: constructor()] provider initialized",e)}))}static init(e){var t;return Wh("[Ethereum: init()] Initializing Ethereum service"),this.instance=new hf(e),null===(t=this.instance)||void 0===t?void 0:t.provider}static destroy(){}static getInstance(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class ff{constructor({useDeepLink:e,preferredOpenLink:t,debug:n=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=t,this.state.debug=n}openDeeplink(e,t,n){return function(e,t,n,r){const{state:i}=e;Wh(`[PlatfformManager: openDeeplink()] universalLink --\x3e ${t}`),Wh(`[PlatfformManager: openDeeplink()] deepLink --\x3e ${n}`);try{if(i.preferredOpenLink)return void i.preferredOpenLink(i.useDeeplink?n:t,r);if(Wh(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${i.useDeeplink} link=${i.useDeeplink?n:t}`),i.useDeeplink)"undefined"!=typeof window&&(window.location.href=n);else if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.target="_self",e.rel="noreferrer noopener",e.click()}}catch(e){console.log("[PlatfformManager: openDeeplink()] can't open link",e)}}(this,e,t,n)}isReactNative(){var e;return this.isNotBrowser()&&"undefined"!=typeof window&&(null===window||void 0===window?void 0:window.navigator)&&"ReactNative"===(null===(e=window.navigator)||void 0===e?void 0:e.product)}isMetaMaskInstalled(){return function(){const e=hf.getProvider()||(null===window||void 0===window?void 0:window.ethereum);return Wh(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${null==e?void 0:e.isMetaMask} isConnected=${null==e?void 0:e.isConnected()}`),(null==e?void 0:e.isMetaMask)&&(null==e?void 0:e.isConnected())}()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,t;const n=df.parse(window.navigator.userAgent);return"mobile"===(null===(e=null==n?void 0:n.platform)||void 0===e?void 0:e.type)||"tablet"===(null===(t=null==n?void 0:n.platform)||void 0===t?void 0:t.type)}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return"undefined"!=typeof window&&Boolean(window.ReactNativeWebView)&&Boolean(navigator.userAgent.endsWith("MetaMaskMobile"))}isMobileWeb(){return this.state.platformType===fa.MobileWeb}static isNotBrowser(){var e;return"undefined"==typeof window||!(null===window||void 0===window?void 0:window.navigator)||void 0!==De&&"ReactNative"===(null===(e=null==De?void 0:De.navigator)||void 0===e?void 0:e.product)||"ReactNative"===(null===navigator||void 0===navigator?void 0:navigator.product)}isNotBrowser(){return ff.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return ff.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(e){const{state:t}=e;return t.platformType?t.platformType:e.isReactNative()?fa.ReactNative:e.isNotBrowser()?fa.NonBrowser:e.isMetaMaskMobileWebView()?fa.MetaMaskMobileWebview:e.isMobile()?fa.MobileWeb:fa.DesktopWeb}(this)}}const pf=e=>Be(void 0,void 0,void 0,(function*(){if(ff.isBrowser()){const{StorageManagerWeb:t}=yield Promise.resolve().then((function(){return pp}));return new t(e)}const t={persistChannelConfig:()=>Be(void 0,void 0,void 0,(function*(){})),getPersistedChannelConfig:()=>Be(void 0,void 0,void 0,(function*(){})),persistAccounts:()=>Be(void 0,void 0,void 0,(function*(){})),getCachedAccounts:()=>Be(void 0,void 0,void 0,(function*(){return[]})),persistChainId:()=>Be(void 0,void 0,void 0,(function*(){})),getCachedChainId:()=>Be(void 0,void 0,void 0,(function*(){})),terminate:()=>Be(void 0,void 0,void 0,(function*(){}))};return Promise.resolve(t)}));class gf extends Vh{constructor({connectionStream:e,shouldSendMetadata:t,autoRequestAccounts:n=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:t}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},Wh(`[SDKProvider: constructor()] autoRequestAccounts=${n}`),this.state.autoRequestAccounts=n}forceInitializeState(){return Be(this,void 0,void 0,(function*(){return Wh(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){Wh("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:t}=this._state;return t&&0!==t.length?(null===(e=t[0])||void 0===e?void 0:e.toLowerCase())||"":(Wh("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,t){return this._handleAccountsChanged(e,t)}handleDisconnect({terminate:e=!1}){!function({terminate:e=!1,instance:t}){const{state:n}=t;Wh(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${e}`,t),e&&(t._state.accounts=null,t._state.isUnlocked=!1,t._state.isPermanentlyDisconnected=!0,t._state.initialized=!1),t._handleAccountsChanged([]),t._state.isConnected=!1,t.emit("disconnect",Gh.ethErrors.provider.disconnected()),n.providerStateRequested=!1}({terminate:e,instance:this})}_initializeStateAsync(){return Be(this,void 0,void 0,(function*(){return function(e){var t,n;return Be(this,void 0,void 0,(function*(){void 0===e.state&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:r}=e;let i;if(r.providerStateRequested)Wh("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let o;r.providerStateRequested=!0;let s=null,a=!1,c=!1;const l=yield pf({enabled:!0});if(l){const e=yield l.getPersistedChannelConfig({});a=null!==(t=null==e?void 0:e.relayPersistence)&&void 0!==t&&t,o=yield l.getCachedChainId();const n=yield l.getCachedAccounts();n.length>0&&(s=n[0])}if(Wh(`[SDKProvider: initializeStateAsync()] relayPersistence=${a}`,{relayPersistence:a,cachedChainId:o,cachedSelectedAddress:s}),a)if(o&&s)i={accounts:[s],chainId:o,isUnlocked:!1},c=!0;else try{i=yield e.request({method:"metamask_getProviderState"})}catch(t){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",t),void(r.providerStateRequested=!1)}if(0===(null===(n=null==i?void 0:i.accounts)||void 0===n?void 0:n.length))if(e.getSelectedAddress())i.accounts=[e.getSelectedAddress()];else{Wh("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const t=yield e.request({method:"eth_requestAccounts",params:[]});i.accounts=t}e._initializeState(i),r.providerStateRequested=!1,c&&(e._state.isConnected=!0,e.emit("connect",{chainId:null==i?void 0:i.chainId}))}}))}(this)}))}_initializeState(e){return Wh("[SDKProvider: _initializeState()]",e),function(e,t,n){return Wh("[SDKProvider: initializeState()] set state._initialized to false"),e._state.initialized=!1,t(n)}(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:t}={}){this.state.chainId=e,this.state.networkVersion=t,function({instance:e,chainId:t,networkVersion:n,superHandleChainChanged:r}){Wh(`[SDKProvider: handleChainChanged()] chainId=${t} networkVersion=${n}`);let i=n;n||(Wh("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),i="1"),e._state.isConnected=!0,e.emit("connect",{chainId:t}),r({chainId:t,networkVersion:i})}({instance:this,chainId:e,networkVersion:t,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var mf,yf={name:"@metamask/sdk",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"^4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};!function(e){e.INPAGE="metamask-inpage",e.CONTENT_SCRIPT="metamask-contentscript",e.PROVIDER="metamask-provider"}(mf||(mf={}));const vf="direct",bf="https://metamask.app.link/connect",wf="metamask://connect",Ef={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},Cf=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,_f={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},Sf={[_f.ETH_REQUESTACCOUNTS]:!0,[_f.ETH_SENDTRANSACTION]:!0,[_f.ETH_SIGNTRANSACTION]:!0,[_f.ETH_SIGN]:!0,[_f.PERSONAL_SIGN]:!0,[_f.ETH_ACCOUNTS]:!1,[_f.ETH_CHAINID]:!1,[_f.PERSONAL_SIGN]:!0,[_f.ETH_SIGNTYPEDDATA]:!0,[_f.ETH_SIGNTYPEDDATA_V3]:!0,[_f.ETH_SIGNTYPEDDATA_V4]:!0,[_f.WALLET_REQUESTPERMISSIONS]:!0,[_f.WALLET_GETPERMISSIONS]:!0,[_f.WALLET_WATCHASSET]:!0,[_f.WALLET_ADDETHEREUMCHAIN]:!0,[_f.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[_f.METAMASK_CONNECTSIGN]:!0,[_f.METAMASK_CONNECTWITH]:!0,[_f.PERSONAL_EC_RECOVER]:!0,[_f.METAMASK_BATCH]:!0,[_f.METAMASK_OPEN]:!0},kf=Object.keys(Sf).map((e=>e.toLowerCase())),xf=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map((e=>e.toLowerCase())),Af=".sdk-comm",Mf="providerType",Lf=".MMSDK_cached_address",Of=".MMSDK_cached_chainId",Tf="chainChanged",Rf="accountsChanged",Pf="disconnect",If="connect",Nf="connected";var Bf;!function(e){e.TERMINATE="terminate",e.EXTENSION="extension",e.INITIALIZED="initialized"}(Bf||(Bf={}));const Df="undefined"!=typeof window&&window.localStorage;function $f(e){var t,n;return Be(this,void 0,void 0,(function*(){Wh("[MetaMaskSDK: connectWithExtensionProvider()] ",e),e.sdkProvider=e.activeProvider,e.activeProvider=window.extension,window.ethereum=window.extension;try{const e=yield null===(t=window.extension)||void 0===t?void 0:t.request({method:"eth_requestAccounts"});Wh(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${e}`)}catch(e){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",e)}localStorage.setItem(Mf,"extension"),e.extensionActive=!0,e.emit(uf.ProviderUpdate,Bf.EXTENSION),e.options.enableAnalytics&&(null===(n=e.analytics)||void 0===n||n.send({event:Xs.SDK_USE_EXTENSION}))}))}function jf(e){let t;if(void 0!==Xe)t=Xe.from(e,"utf8").toString("base64");else if("function"==typeof btoa)t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/gu,((e,t)=>String.fromCharCode(parseInt(t,16)))));else{if("object"!=typeof De||!("Buffer"in De))throw new Error("Unable to base64 encode: No available method.");t=De.Buffer.from(e,"utf8").toString("base64")}return t}class Kf extends kh.Duplex{constructor({name:e,remote:t,deeplinkProtocol:n,platformManager:r}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=e,this.state.remote=t,this.state.deeplinkProtocol=n,this.state.platformManager=r,this._onMessage=this._onMessage.bind(this),this.state.remote.on(Gs.MESSAGE,this._onMessage)}_write(e,t,n){return Be(this,void 0,void 0,(function*(){return function(e,t,n,r){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C,_;return Be(this,void 0,void 0,(function*(){const n=null===(i=e.state.remote)||void 0===i?void 0:i.isReady(),S=null===(o=e.state.remote)||void 0===o?void 0:o.isConnected(),k=null===(s=e.state.remote)||void 0===s?void 0:s.isPaused(),x=hf.getProvider(),A=null===(a=e.state.remote)||void 0===a?void 0:a.getChannelId(),M=null===(c=e.state.remote)||void 0===c?void 0:c.isAuthorized(),{deeplinkProtocol:L}=e.state,{method:O,data:T,triggeredInstaller:R}=(e=>{var t,n,r,i;let o;Xe.isBuffer(e)?(o=e.toJSON(),o._isBuffer=!0):o=e;const s=null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.method;let a=!1;return"object"==typeof(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.params)&&!0===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.params)||void 0===i?void 0:i.__triggeredInstaller)&&(a=!0,o.data.params=o.data.params.wrappedParams),{method:s,data:o,triggeredInstaller:a}})(t);if(Wh(`[RCPMS: write()] method='${O}' isRemoteReady=${n} channelId=${A} isSocketConnected=${S} isRemotePaused=${k} providerConnected=${x.isConnected()}`,t),!A)return O!==_f.METAMASK_GETPROVIDERSTATE&&Wh(`[RCPMS: write()] ${O} --\x3e channelId is undefined`),r(new Error("disconnected"));Wh(`[RCPMS: write()] remote.isPaused()=${null===(l=e.state.remote)||void 0===l?void 0:l.isPaused()} authorized=${M} ready=${n} socketConnected=${S}`,t);const P=null===(d=e.state.platformManager)||void 0===d?void 0:d.isSecure(),I=null!==(h=null===(u=e.state.platformManager)||void 0===u?void 0:u.isMobileWeb())&&void 0!==h&&h,N=null!==(p=null===(f=e.state.remote)||void 0===f?void 0:f.hasDeeplinkProtocol())&&void 0!==p&&p&&I&&M;try{if(!R){const t=JSON.stringify(null==T?void 0:T.data);if(t.length>1e6)return r(new Error(`Message size ${t.length} exceeds maximum allowed size of 1000000 bytes`));null===(g=e.state.remote)||void 0===g||g.sendMessage(null==T?void 0:T.data).then((()=>{Wh(`[RCPMS: _write()] ${O} sent successfully`)})).catch((e=>{Wh("[RCPMS: _write()] error sending message",e)}))}if(!P)return Wh(`[RCPMS: _write()] unsecure platform for method ${O} -- return callback`),r();if(R)return Wh("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const t=null!==(v=null===(y=null===(m=e.state.remote)||void 0===m?void 0:m.getKeyInfo())||void 0===y?void 0:y.ecies.public)&&void 0!==v?v:"";let n=encodeURI(`channelId=${A}&pubkey=${t}&comm=socket&t=d&v=2`);if(N){const t=JSON.stringify(null==T?void 0:T.data),i=null===(b=e.state.remote)||void 0===b?void 0:b.encrypt(t);if(!i)return Wh("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));n+=`&scheme=${L}&rpc=${jf(i)}`}if(!(null===(w=e.state.platformManager)||void 0===w?void 0:w.isMetaMaskInstalled()))return Wh("[RCPMS: _write()] prevent deeplink until installation is completed."),r();Sf[O]?(Wh(`[RCPMS: _write()] redirect link for '${O}' socketConnected=${S} connect?${n}`),null===(E=e.state.platformManager)||void 0===E||E.openDeeplink(`${bf}?${n}`,`${wf}?${n}`,"_self")):(null===(C=e.state.remote)||void 0===C?void 0:C.isPaused())?(Wh(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${O}`),null===(_=e.state.platformManager)||void 0===_||_.openDeeplink(`${bf}?redirect=true&${n}`,`${wf}?redirect=true&${n}`,"_self")):Wh(`[RCPMS: _write()] method ${O} doesn't need redirect.`)}catch(e){return Wh("[RCPMS: _write()] error sending message",e),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()}))}(this,e,0,n)}))}_read(){}_onMessage(e){return function(e,t){try{if(Wh("[RCPMS: onMessage()] message",t),!t||"object"!=typeof t)return;if("object"!=typeof(null==t?void 0:t.data))return;if(!(null==t?void 0:t.name))return void Wh("[RCPMS: onMessage()] ignore message without name",t);if((null==t?void 0:t.name)!==mf.PROVIDER)return void Wh(`[RCPMS: onMessage()] ignore message with wrong name message=${t}`);if(Xe.isBuffer(t)){const n=Xe.from(t);e.push(n)}else e.push(t)}catch(e){Wh(`[RCPMS: onMessage()] ignore message error err=${e}`)}}(this,e)}start(){}}let Uf=1;const Ff=e=>new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),Hf=({checkInstallationOnAllCalls:e=!1,communicationLayerPreference:t,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:o,sdk:a,remoteConnection:c,debug:l})=>Be(void 0,void 0,void 0,(function*(){var d,u;const h=(({name:e,remoteConnection:t})=>{if(!t||!(null==t?void 0:t.getConnector()))throw new Error("Missing remote connection parameter");return new Kf({name:e,remote:null==t?void 0:t.getConnector(),deeplinkProtocol:null==t?void 0:t.state.deeplinkProtocol,platformManager:null==t?void 0:t.getPlatformManager()})})({name:mf.INPAGE,target:mf.CONTENT_SCRIPT,platformManager:i,communicationLayerPreference:t,remoteConnection:c}),f=i.getPlatformType(),p=a.options.dappMetadata,g=`Sdk/Javascript SdkVersion/${yf.version} Platform/${f} dApp/${null!==(d=p.url)&&void 0!==d?d:p.name} dAppTitle/${p.name}`;let m=null,y=null;const v=null===(u=a.options.storage)||void 0===u?void 0:u.storageManager;if(v){try{const e=yield v.getCachedAccounts();e.length>0&&(m=e[0])}catch(e){console.error(`[initializeMobileProvider] failed to get cached addresses: ${e}`)}try{const e=yield v.getCachedChainId();e&&(y=e)}catch(e){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${e}`)}}Wh(`[initializeMobileProvider] cachedAccountAddress: ${m}, cachedChainId: ${y}`);const b=!(!n||f===fa.NonBrowser||f===fa.ReactNative),w=hf.init({shouldSetOnWindow:b,connectionStream:h,shouldShimWeb3:r,sdkInstance:a});let E=!1;const C=e=>{E=e},_=()=>E,S=(t,n,r,l)=>Be(void 0,void 0,void 0,(function*(){var d,u,h,f,p,b,w,S,k;const x=hf.getProvider();if(E){x.emit("display_uri",(null==c?void 0:c.state.qrcodeLink)||""),null==c||c.showActiveModal();let e=_();for(;e;){const t=_(),n=null==c?void 0:c.isAuthorized();e=t&&!n,Wh(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${t} authorized: ${n}`),yield Ff(1e3)}return Wh("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),r(...n)}const A=i.isMetaMaskInstalled(),M=null==c?void 0:c.isConnected();let L=null,O=null,T=null;if(L=null!==(d=x.getSelectedAddress())&&void 0!==d?d:m,T=x.getChainId()||y,L&&v&&L!==m&&v.persistAccounts([L]).catch((e=>{console.error(`[initializeMobileProvider] failed to persist account: ${e}`)})),T&&(y=T,v&&v.persistChainId(T).catch((e=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${e}`)}))),Wh("[initializeMobileProvider: sendRequest()]",{selectedAddress:L,chainId:T}),l&&Wh(`[initializeMobileProvider: sendRequest()] method=${t} ongoing=${E} selectedAddress=${L} isInstalled=${A} checkInstallationOnAllCalls=${e} socketConnected=${M}`),L&&t.toLowerCase()===_f.ETH_ACCOUNTS.toLowerCase())return[L];if(T&&t.toLowerCase()===_f.ETH_CHAINID.toLowerCase())return T;const R=[_f.ETH_REQUESTACCOUNTS,_f.WALLET_REQUESTPERMISSIONS,_f.METAMASK_CONNECTSIGN,_f.METAMASK_CONNECTWITH],P=!Sf[t],I=null===(u=a.options.readonlyRPCMap)||void 0===u?void 0:u[T];if(I&&P)try{const e=null===(h=null==n?void 0:n[0])||void 0===h?void 0:h.params,r=yield(({rpcEndpoint:e,method:t,sdkInfo:n,params:r})=>Be(void 0,void 0,void 0,(function*(){const i=JSON.stringify({jsonrpc:"2.0",method:t,params:r,id:(Uf+=1,Uf)}),o={Accept:"application/json","Content-Type":"application/json"};let a;e.includes("infura")&&(o["Metamask-Sdk-Info"]=n);try{a=yield s(e,{method:"POST",headers:o,body:i})}catch(e){throw e instanceof Error?new Error(`Failed to fetch from RPC: ${e.message}`):new Error(`Failed to fetch from RPC: ${e}`)}if(!a.ok)throw new Error(`Server responded with a status of ${a.status}`);return(yield a.json()).result})))({rpcEndpoint:I,sdkInfo:g,method:t,params:e||[]});return l&&Wh(`initializeProvider::ReadOnlyRPCResponse ${r}`),r}catch(e){console.warn(`[initializeMobileProvider: sendRequest()] method=${t} readOnlyRPCRequest failed:`,e)}if((!A||A&&!M)&&t!==_f.METAMASK_GETPROVIDERSTATE){const s=(null===(f=null==n?void 0:n[0])||void 0===f?void 0:f.params)||[];if(-1!==R.indexOf(t)||e){C(!0);const e=t===_f.METAMASK_CONNECTWITH,i=`${Date.now()}`;try{yield o.start({wait:!1,connectWith:e?{method:t,id:i,params:s}:void 0}),yield new Promise(((e,t)=>{(null==c?void 0:c.isAuthorized())&&(Wh("[initializeMobileProvider: sendRequest()] already authorized"),e(!0)),null==c||c.getConnector().once(Gs.AUTHORIZED,(()=>{e(!0)})),a.once(Gs.PROVIDER_UPDATE,(e=>{Wh(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${e}`),e===Bf.EXTENSION?t(Gs.PROVIDER_UPDATE):t(new Error("Connection Terminated"))}))}))}catch(e){if(Bf.EXTENSION===e){if(Wh(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${t} on the active provider`),t.toLowerCase()===_f.METAMASK_CONNECTSIGN.toLowerCase()){const e=yield null===(p=a.getProvider())||void 0===p?void 0:p.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!e.length)throw new Error("SDK state invalid -- undefined accounts");const t=yield null===(b=a.getProvider())||void 0===b?void 0:b.request({method:_f.PERSONAL_SIGN,params:[s[0],e[0]]});return a.emit(uf.ConnectWithResponse,t),t}if(t.toLowerCase()===_f.METAMASK_CONNECTWITH.toLowerCase()){const[e]=s,t=yield(({method:e,sdk:t,params:n})=>Be(void 0,void 0,void 0,(function*(){var r,i,o,s;if(!t.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");Wh("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",e,n);const a=yield null===(r=t.getProvider())||void 0===r?void 0:r.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!a.length)throw new Error("SDK state invalid -- undefined accounts");if((null==e?void 0:e.toLowerCase())===_f.PERSONAL_SIGN.toLowerCase()){const r={method:e,params:[n[0],a[0]]};return yield null===(i=t.getProvider())||void 0===i?void 0:i.request(r)}if((null==e?void 0:e.toLowerCase())===_f.ETH_SENDTRANSACTION.toLowerCase()){const r={method:e,params:[Object.assign(Object.assign({},n[0]),{from:a[0]})]};return yield null===(o=t.getProvider())||void 0===o?void 0:o.request(r)}return xf.includes(e.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${e} -- not handled by the extension -- call separately`),a):yield null===(s=t.getProvider())||void 0===s?void 0:s.request({method:e,params:n})})))({method:e.method,sdk:a,params:e.params});return a.emit(uf.ConnectWithResponse,t),t}return Wh(`[initializeMobileProvider: sendRequest()] sending '${t}' on active provider`,s),yield null===(w=a.getProvider())||void 0===w?void 0:w.request({method:t,params:s})}if(e===Gs.REJECTED)throw null==c||c.closeModal(),null===(S=a.getProvider())||void 0===S||S.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001});throw Wh(`[initializeMobileProvider: sendRequest()] failed to start installer: ${e}`),e}finally{C(!1)}if(t===_f.ETH_REQUESTACCOUNTS)return O=yield new Promise((e=>{const t=setInterval((()=>{const{accounts:n}=x.getState();n&&(clearInterval(t),e(n))}),100)})),Wh(`[initializeMobileProvider: sendRequest()] selectedAddress: ${L} --- SKIP rpc call`),O;if(t===_f.METAMASK_CONNECTWITH)try{let e=0;const t=5,n=({resolve:n,reject:r})=>{e+=1;const o=null==c?void 0:c.getConnector().getRPCMethodTracker(),s=null==o?void 0:o[i];return Wh(`TRACKER: update method ${i}`,s),(null==s?void 0:s.result)?(Wh("[initializeMobileProvider: sendRequest()] found result",s.result),a.emit(uf.ConnectWithResponse,s.result),void n(s.result)):(null==s?void 0:s.error)?(Wh("[initializeMobileProvider: sendRequest()] found error",s.error),void r(s.error)):e>=t?(Wh("[initializeMobileProvider: sendRequest()] max message count reached without result"),void r(new Error("Max message count reached without result"))):void Wh("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let r,o;const s=yield new Promise(((e,t)=>{const s=null==c?void 0:c.getConnector().getRPCMethodTracker();Wh(`TRACKER: method ${i}`,s),(null==s?void 0:s[i].result)?(Wh("[initializeMobileProvider: sendRequest()] found result",null==s?void 0:s[i].result),e(null==s?void 0:s[i].result)):(null==s?void 0:s[i].error)&&(Wh("[initializeMobileProvider: sendRequest()] found error",null==s?void 0:s[i].error),t(null==s?void 0:s[i].error)),o=()=>n({resolve:e,reject:t}),r=null==c?void 0:c.getConnector().on(Gs.RPC_UPDATE,o)}));return o&&(null==r||r.off(Gs.RPC_UPDATE,o)),Wh("TRACKER: result",s),s}catch(e){throw Wh("[initializeMobileProvider: sendRequest()] error:",e),e}return n[0]&&"object"==typeof n[0]&&(n[0].params={__triggeredInstaller:!0,wrappedParams:n[0].params}),r(...n)}if(i.isSecure()&&Sf[t])return r(...n);if(a.isExtensionActive())return Wh(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${t}' to it`,n,s),yield null===(k=a.getProvider())||void 0===k?void 0:k.request({method:t,params:s});throw Wh(`[initializeMobileProvider: sendRequest()] method=${t} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const e=yield r(...n);if(Wh(`[initializeMobileProvider: sendRequest()] method=${t} rpcResponse`,e),t===_f.WALLET_REQUESTPERMISSIONS){const t=e.reduce(((e,t)=>{var n;if("eth_accounts"===t.parentCapability){const r=null===(n=t.caveats.find((e=>"restrictReturnedAccounts"===e.type)))||void 0===n?void 0:n.value;r&&e.push(...r)}return e}),[]);Wh("[initializeMobileProvider: sendRequest()] accountsToPersist:",t),t.length>0&&(x.handleAccountsChanged(t,!1),null==v||v.persistAccounts(t))}return e}catch(e){throw console.error("[initializeMobileProvider: sendRequest()] error:",e),e}})),{request:k}=w;w.request=(...e)=>Be(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0].method,e,k,l)}));const{send:x}=w;return w.send=(...e)=>Be(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0],e,x,l)})),Wh("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),h.start(),w}));class zf{constructor({serverUrl:e,enabled:t,originatorInfo:n}){this.serverURL=Us,this.serverURL=e,this.originatorInfo=n,this.enabled=null==t||t}send({event:e,params:t}){if(!this.enabled)return;const n=Object.assign(Object.assign({id:"sdk",event:e,sdkVersion:yf.version},this.originatorInfo),{params:t});Wh(`[Analytics: send()] event: ${e}`,n),$s(n,this.serverURL).catch((e=>{Wh(`[Analytics: send()] error: ${e}`)}))}}function qf(e){var n,r,i;const{dappMetadata:o}=e,s=function({url:e,name:n}){var r;const i=jf(e+n);if(!localStorage)return"";let o=null!==(r=localStorage.getItem(i))&&void 0!==r?r:"";if(!o){o=t.v4();try{localStorage.setItem(i,o)}catch(e){return""}}return o}({url:null!==(n=null==o?void 0:o.url)&&void 0!==n?n:"no_url",name:null!==(r=null==o?void 0:o.name)&&void 0!==r?r:"no_name"}),a=null===(i=e.platformManager)||void 0===i?void 0:i.getPlatformType(),c=a===fa.DesktopWeb,l=a===fa.MetaMaskMobileWebview;let d="N/A";return c?d="extension":l&&(d="mobile"),{id:s,from:d}}const Vf=({provider:e,sdkInstance:t})=>{if("state"in e)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(e,{get:(n,r)=>"request"===r?function(e){var r,i;return Be(this,void 0,void 0,(function*(){Wh("[wrapExtensionProvider()] Overwriting request method",e);const{method:o,params:s}=e,a=kf.includes(o.toLowerCase()),{id:c,from:l}=qf(t);if(a&&(null===(r=t.analytics)||void 0===r||r.send({event:Xs.SDK_RPC_REQUEST,params:{method:o,from:l,id:c}})),o===_f.METAMASK_BATCH&&Array.isArray(s))return(({target:e,args:t,trackEvent:n,sdkInstance:r})=>Be(void 0,void 0,void 0,(function*(){var i,o;if("metamask_batch"!==t.method)throw new Error("Invalid usage");const s=[],a=null!==(i=null==t?void 0:t.params)&&void 0!==i?i:[];for(const t of a){const n=yield null==e?void 0:e.request({method:t.method,params:t.params});s.push(n)}const{id:c,from:l}=qf(r);return n&&(null===(o=r.analytics)||void 0===o||o.send({event:Xs.SDK_RPC_REQUEST_DONE,params:{method:t.method,from:l,id:c}})),s})))({target:n,args:e,trackEvent:a,sdkInstance:t});if(o.toLowerCase()===_f.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>Be(void 0,void 0,void 0,(function*(){const n=yield e.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!n.length)throw new Error("SDK state invalid -- undefined accounts");return yield e.request({method:_f.PERSONAL_SIGN,params:[t[0],n[0]]})})))({target:n,params:s});if(o.toLowerCase()===_f.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>Be(void 0,void 0,void 0,(function*(){const[n]=t,r=n.method,i=n.params,o=yield e.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!o.length)throw new Error("SDK state invalid -- undefined accounts");return(null==r?void 0:r.toLowerCase())===_f.PERSONAL_SIGN.toLowerCase()?yield e.request({method:r,params:[i[0],o[0]]}):(null==r?void 0:r.toLowerCase())===_f.ETH_SENDTRANSACTION.toLowerCase()?yield e.request({method:r,params:[Object.assign(Object.assign({},i[0]),{from:o[0]})]}):xf.includes(r.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${r} -- not handled by the extension -- call separately`),o):yield e.request({method:r,params:i})})))({target:n,params:s});let d;try{return d=yield n.request(e),d}finally{a&&(null===(i=t.analytics)||void 0===i||i.send({event:Xs.SDK_RPC_REQUEST_DONE,params:{method:o,from:l,id:c}}))}}))}:"getChainId"===r?function(){return e.chainId}:"getNetworkVersion"===r?function(){return e.networkVersion}:"getSelectedAddress"===r?function(){return e.selectedAddress}:"isConnected"===r?function(){return e._state.isConnected}:n[r]})};var Wf;!function(e){e.Announce="eip6963:announceProvider",e.Request="eip6963:requestProvider"}(Wf||(Wf={}));var Gf="INSTALLED",Yf="NOT_INSTALLED",Zf="REGISTERED",Jf="REGISTERING",Xf="RELOADING",Qf={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},ep="REGISTRATION_IN_PROGRESS",tp="FORWARDER_ID",np=function(){function e(t){var n=void 0===t?{}:t,r=n.forwarderOrigin,i=void 0===r?"https://fwd.metamask.io":r,o=n.forwarderMode,s=void 0===o?e.FORWARDER_MODE.INJECT:o;this.forwarderOrigin=i,this.forwarderMode=s,this.state=e.isMetaMaskInstalled()?Gf:Yf;var a=e._detectBrowser();this.downloadUrl=a?Qf[a]:Qf.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),s===e.FORWARDER_MODE.INJECT&&"true"===sessionStorage.getItem(ep)&&e._injectForwarder(this.forwarderOrigin)}return e.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return"metamask:reload"===e.data.type?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},e.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},e.prototype._onMessageFromForwarder=function(t){return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(n){switch(n.label){case 0:switch(this.state){case Xf:return[3,1];case Yf:return[3,2];case Gf:return[3,3];case Jf:return[3,5];case Zf:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=Xf,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=Jf,[4,e._register()];case 4:return n.sent(),this.state=Zf,t.source.postMessage({type:"metamask:registrationCompleted"},t.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}}))}))},e.prototype.startOnboarding=function(){sessionStorage.setItem(ep,"true"),this._openDownloadPage(),this._openForwarder()},e.prototype.stopOnboarding=function(){"true"===sessionStorage.getItem(ep)&&(this.forwarderMode===e.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),e._removeForwarder()),sessionStorage.setItem(ep,"false"))},e.prototype._openForwarder=function(){this.forwarderMode===e.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):e._injectForwarder(this.forwarderOrigin)},e.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},e.isMetaMaskInstalled=function(){return Boolean(window.ethereum&&window.ethereum.isMetaMask)},e._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},e._injectForwarder=function(e){var t=document.body,n=document.createElement("iframe");n.setAttribute("height","0"),n.setAttribute("width","0"),n.setAttribute("style","display: none;"),n.setAttribute("src",e),n.setAttribute("id",tp),t.insertBefore(n,t.children[0])},e._removeForwarder=function(){var e;null===(e=document.getElementById(tp))||void 0===e||e.remove()},e._detectBrowser=function(){var e=df.parse(window.navigator.userAgent);return"Firefox"===e.browser.name?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},e.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},e}();class rp{constructor({remote:e,preferDesktop:t,platformManager:n,debug:r=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=t,this.state.platformManager=n,this.state.debug=r}startDesktopOnboarding(){return function(){return Be(this,void 0,void 0,(function*(){Wh("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),(new np).startOnboarding()}))}()}redirectToProperInstall(){return Be(this,void 0,void 0,(function*(){return function(e){var t,n;return Be(this,void 0,void 0,(function*(){const{state:r}=e,i=null===(t=r.platformManager)||void 0===t?void 0:t.getPlatformType();if(Wh(`[MetamaskInstaller: redirectToProperInstall()] platform=${i}`),i===fa.MetaMaskMobileWebview)return!1;r.isInstalling=!0;try{yield null===(n=r.remote)||void 0===n?void 0:n.startConnection({connectWith:r.connectWith}),r.isInstalling=!1,r.hasInstalled=!0}catch(e){throw r.isInstalling=!1,e}return!0}))}(this)}))}checkInstallation(){return Be(this,void 0,void 0,(function*(){return function(e){var t;return Be(this,void 0,void 0,(function*(){const{state:n}=e,r=null===(t=n.platformManager)||void 0===t?void 0:t.isMetaMaskInstalled();return Wh(`[MetamaskInstaller: checkInstallation()] isInstalled=${r}`),!!r||(yield e.redirectToProperInstall())}))}(this)}))}start({wait:e=!1,connectWith:t}){return Be(this,void 0,void 0,(function*(){this.state.connectWith=t,Wh(`[MetaMaskInstaller: start()] wait=${e}`,t),yield function(e,{wait:t=!1}){return Be(this,void 0,void 0,(function*(){return Wh(`[MetamaskInstaller: startInstaller()] wait=${t}`),t&&(yield Ff(1e3)),yield e.checkInstallation()}))}(this,{wait:e})}))}}class ip{constructor({debug:e,sdkVersion:t}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=null!=e&&e,this.sdkVersion=t}loadComponent(e){return Be(this,void 0,void 0,(function*(){if(!this.defined[e]){this.defined[e]=!0;try{const e=yield Promise.resolve().then((function(){return Og}));console.log("loader",e),e.defineCustomElements()}catch(t){console.error(`Failed to load ${e} modal:`,t)}}}))}renderInstallModal(e){var t;return Be(this,void 0,void 0,(function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const n=document.createElement("mm-install-modal");n.link=e.link,n.preferDesktop=e.preferDesktop,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),n.addEventListener("trackAnalytics",(t=>{var n;return null===(n=e.onAnalyticsEvent)||void 0===n?void 0:n.call(e,t.detail)})),e.parentElement.appendChild(n)}))}renderSelectModal(e){var t;return Be(this,void 0,void 0,(function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const n=document.createElement("mm-select-modal");n.link=e.link,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.preferDesktop=e.preferDesktop,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(n),setTimeout((()=>this.updateQRCode(e.link)),100)}))}renderPendingModal(e){var t;return Be(this,void 0,void 0,(function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const n=document.createElement("mm-pending-modal");n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.displayOTP=e.displayOTP,n.addEventListener("close",e.onClose),n.addEventListener("updateOTPValue",(({detail:{otpValue:t}})=>e.updateOTPValue(t))),e.onDisconnect&&n.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(n)}))}updateOTPValue(e){const t=()=>{var t;const n=null===(t=this.containers.pending)||void 0===t?void 0:t.querySelector("mm-pending-modal");return!!n&&(n.otpCode=e,!0)};setTimeout((()=>{t()}),800)}updateQRCode(e){var t,n;const r=null===(t=this.containers.install)||void 0===t?void 0:t.querySelector("mm-install-modal");if(r)r.link=e;else{const t=null===(n=this.containers.select)||void 0===n?void 0:n.querySelector("mm-select-modal");t&&(t.link=e)}}unmount(){Object.entries(this.containers).forEach((([e,t])=>{var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.removeChild(t),this.containers[e]=void 0}))}}const op=({link:e,debug:t,installer:n,terminate:r,connectWithExtension:i,preferDesktop:o,onAnalyticsEvent:s})=>{let a=null,c=null;Wh("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] link=${e}`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --ios`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --android`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${e}"`);const l=e=>{var t;Wh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",e,c),(null==c?void 0:c.parentNode)&&(null===(t=c.parentNode)||void 0===t||t.removeChild(c)),c=null,a=null,!0===e&&(null==r||r())};return{mount:r=>{if(Wh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(null==a||a.updateQRCode(r));a=new ip({debug:t,sdkVersion:yf.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?a.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),null==i||i()},onClose:l,link:e,preferDesktop:null!=o&&o}).catch((e=>{console.error(e)})):a.renderInstallModal({parentElement:c,preferDesktop:null!=o&&o,link:e,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:s}).catch((e=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",e)}))},unmount:l}},sp=({onDisconnect:e,debug:t})=>{let n=null,r=null;const i=()=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),(null==n?void 0:n.parentNode)&&n.parentNode.removeChild(n),n=null,r=null},o=e=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",e),r&&r.updateOTPValue(e)},s=({displayOTP:s}={displayOTP:!0})=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new ip({debug:t,sdkVersion:yf.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:e,updateOTPValue:o,displayOTP:s}).catch((e=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",e)})))};return s(),{mount:s,unmount:i,updateOTPValue:o}};function ap(e,t){var n,r,i,o;e.connector||(Wh("[RemoteConnection: initializeConnector()] initialize connector"),e.connector=new Aa({platformType:t.platformManager.getPlatformType(),communicationLayerPreference:t.communicationLayerPreference,transports:t.transports,dappMetadata:Object.assign(Object.assign({},t.dappMetadata),{source:t._source}),analytics:t.enableAnalytics,communicationServerUrl:t.communicationServerUrl,sdkVersion:yf.version,context:"dapp",ecies:t.ecies,storage:t.storage,logging:t.logging}),t.timer&&(Wh("[RemoteConnection: initializeConnector()] reset background timer",t.timer),null===(r=null===(n=t.timer)||void 0===n?void 0:n.stopBackgroundTimer)||void 0===r||r.call(n),null===(o=null===(i=t.timer)||void 0===i?void 0:i.runBackgroundTimer)||void 0===o||o.call(i,(()=>!1),1e4)))}function cp(e){e.listeners.forEach((({event:t,handler:n})=>{var r;null===(r=e.connector)||void 0===r||r.off(t,n)})),e.listeners=[]}function lp(e,t){function n(t,n){var r;null===(r=e.connector)||void 0===r||r.on(t,n),e.listeners.push({event:t,handler:n})}e.connector&&(cp(e),n(Gs.WALLET_INIT,(({accounts:e,chainId:t})=>Be(this,void 0,void 0,(function*(){Wh(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${e} chainId=${t}`);const n=hf.getProvider();n._setConnected();const r={accounts:e,chainId:t,isUnlocked:!1};n._initializeState(r),n.emit("chainChanged",t),n.emit("accountsChanged",e)})))),n(Gs.AUTHORIZED,(()=>Be(this,void 0,void 0,(function*(){var t,n,r,i;try{Wh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",e.pendingModal,e.installModal);const o=hf.getProvider();o._setConnected(),null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!1),e.otpAnswer=void 0,e.authorized=!0,Wh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",o.getState()),yield o.forceInitializeState()}catch(e){}})))),n(Gs.TERMINATE,(()=>{var t,n,r,i,o;null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!0),e.pendingModal=void 0,e.installModal=void 0,e.otpAnswer=void 0,null===(o=e.connector)||void 0===o||o.disconnect({terminate:!0}),e.authorized=!1,hf.getProvider().handleDisconnect({terminate:!0}),cp(e),Wh("[RemoteConnection: setupListeners()] All listeners cleaned up")})))}function dp(e,t,{initialCheck:n,connectWith:r}={}){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C;return Be(this,void 0,void 0,(function*(){try{if(ap(e,t),!e.connector)throw new Error("no connector defined");lp(e);const _=hf.getProvider();e.authorized=!1,_.emit("connecting");const S=yield null===(i=e.connector)||void 0===i?void 0:i.originatorSessionConnect();Wh(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,S);let k=null!==(o=null==S?void 0:S.channelId)&&void 0!==o?o:"",x=null!==(a=null===(s=e.connector.getKeyInfo())||void 0===s?void 0:s.ecies.public)&&void 0!==a?a:"",A=null!==(l=null===(c=e.connector.getKeyInfo())||void 0===c?void 0:c.ecies.private)&&void 0!==l?l:"";if(n&&!S)return Promise.resolve();if(!S&&!n){const t=yield e.connector.generateChannelIdConnect();k=null!==(d=t.channelId)&&void 0!==d?d:"",x=null!==(u=t.pubKey)&&void 0!==u?u:"",A=null!==(h=t.privKey)&&void 0!==h?h:"";const n=Date.now();null===(f=e.connector.state.storageManager)||void 0===f||f.persistChannelConfig({channelId:k,localKey:A,lastActive:n,validUntil:n+Hs})}if(n&&(null==S?void 0:S.channelId))return(null===(p=e.connector)||void 0===p?void 0:p.isConnected())||(Wh(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,S),yield null===(g=e.connector)||void 0===g?void 0:g.connectToChannel({channelId:k})),Promise.resolve();S&&!(null===(m=e.connector)||void 0===m?void 0:m.isConnected())&&(Wh("[RemoteConnection: startConnection()] reconnecting to channel",S),yield null===(y=e.connector)||void 0===y?void 0:y.connectToChannel({channelId:k}));const M=(null===(v=e.platformManager)||void 0===v?void 0:v.isSecure())?"":"&t=q",L=yf.version,{iconUrl:O,name:T,url:R,scheme:P}=t.dappMetadata||{},I=null===(b=e.platformManager)||void 0===b?void 0:b.getPlatformType();let N="N/A";"undefined"!=typeof window&&window.location&&window.location.hostname?N=window.location.hostname:void 0!==T?N=T:void 0!==R&&(N=R);const B={url:null!=R?R:"",title:null!=T?T:"",icon:O,scheme:null!=P?P:"",apiVersion:L,dappId:N||R||"N/A",platform:null!=I?I:"",source:null!==(w=t._source)&&void 0!==w?w:""},D=jf(JSON.stringify(B));let $=`channelId=${k}&v=2&comm=${null!==(E=e.communicationLayerPreference)&&void 0!==E?E:""}&pubkey=${x}${M}&originatorInfo=${D}`;if(r){$+=`&rpc=${jf(JSON.stringify(r))}`;const t=e.connector.getRPCMethodTracker();t&&(t[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const j=encodeURI($),K=`${e.useDeeplink?wf:bf}?${$}`;return e.qrcodeLink=K,e.developerMode&&Wh(`[RemoteConnection: startConnection()] qrcodeLink=${j}`),_.emit("display_uri",K),(null===(C=e.platformManager)||void 0===C?void 0:C.isSecure())?(yield function(e,t){var n,r;return Be(this,void 0,void 0,(function*(){const i=`${bf}?${t}`,o=`${wf}?${t}`;null===(r=null===(n=e.platformManager)||void 0===n?void 0:n.openDeeplink)||void 0===r||r.call(n,i,o,"_self")}))}(e,j),new Promise(((t,n)=>{var r,i,o;(null===(r=e.connector)||void 0===r?void 0:r.isAuthorized())?t():(null===(i=e.connector)||void 0===i||i.once(Gs.AUTHORIZED,(()=>{t()})),null===(o=e.connector)||void 0===o||o.once(Gs.REJECTED,(()=>{n(Gs.REJECTED)})))}))):function(e,t,n){return Be(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(!e.connector)return void i(new Error("No connector available"));Wh("[RemoteConnection: connectWithModalInstaller()]",{state:e,options:t,linkParams:n});const o=`${e.useDeeplink?wf:bf}?${n}`;!function(e,t,n){var r,i,o,s;e.installModal=null===(i=(r=t.modals).install)||void 0===i?void 0:i.call(r,{link:n,preferDesktop:e.preferDesktop,installer:t.getMetaMaskInstaller(),terminate:()=>{Wh("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),t.sdk.terminate().catch((e=>{console.warn("[MMSDK] failed to terminate connection",e)}))},debug:e.developerMode,connectWithExtension:()=>{var e;return null===(e=t.connectWithExtensionProvider)||void 0===e||e.call(t),!1},onAnalyticsEvent:({event:n,params:r})=>{var i,o,s;const a=Object.assign(Object.assign({},r),{sdkVersion:t.sdk.getVersion(),dappId:null===(i=t.dappMetadata)||void 0===i?void 0:i.name,source:t._source,url:null===(o=t.dappMetadata)||void 0===o?void 0:o.url});null===(s=e.analytics)||void 0===s||s.send({event:n,params:a})}}),null===(s=null===(o=e.installModal)||void 0===o?void 0:o.mount)||void 0===s||s.call(o,n)}(e,t,o),t.sdk.once(Gs.PROVIDER_UPDATE,(e=>Be(this,void 0,void 0,(function*(){Wh("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),e!==Bf.TERMINATE?i(e):i({code:4001,message:"User rejected the request."})})))),e.connector.once(Gs.AUTHORIZED,(()=>{r()})),e.connector.once(Gs.REJECTED,(()=>{i(Gs.REJECTED)})),e.connector.once(Gs.CLIENTS_READY,(()=>Be(this,void 0,void 0,(function*(){Wh("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),r()}))))}))}))}(e,t,j)}catch(e){throw console.error("[startConnection] error",e),e}}))}class up{constructor(e){var t,n,r;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode)||!0===(null===(n=e.logging)||void 0===n?void 0:n.sdk);this.state.developerMode=i,this.state.analytics=e.analytics,this.state.preferDesktop=null!==(r=e.preferDesktop)&&void 0!==r&&r,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=op),e.modals.otp||(e.modals.otp=sp)}startConnection(e){return Be(this,void 0,void 0,(function*(){return dp(this.state,this.options,e)}))}initRemoteCommunication({sdkInstance:e}){var t,n,r;return Be(this,void 0,void 0,(function*(){const i=yield null===(n=null===(t=e.options.storage)||void 0===t?void 0:t.storageManager)||void 0===n?void 0:n.getPersistedChannelConfig();if(!this.options.ecies){const e={privateKey:null==i?void 0:i.localKey};this.options.ecies=e}ap(this.state,this.options),yield null===(r=this.getConnector())||void 0===r?void 0:r.initFromDappStorage(),lp(this.state,this.options)}))}showActiveModal(){return function(e){var t,n,r,i;e.authorized?Wh("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?null===(n=(t=e.pendingModal).mount)||void 0===n||n.call(t):e.installModal&&(null===(i=(r=e.installModal).mount)||void 0===i||i.call(r,e.qrcodeLink||""))}(this.state)}closeModal(){var e,t,n,r;null===(t=null===(e=this.state.pendingModal)||void 0===e?void 0:e.unmount)||void 0===t||t.call(e),null===(r=null===(n=this.state.installModal)||void 0===n?void 0:n.unmount)||void 0===r||r.call(n,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getChannelConfig()}getKeyInfo(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isReady())||!1}isAuthorized(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isAuthorized())||!1}isPaused(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.isPaused()}disconnect(e){var t,n,r;Wh("[RemoteConnection: disconnect()]",e),(null==e?void 0:e.terminate)&&(hf.getProvider().handleDisconnect({terminate:!0}),null===(n=null===(t=this.state.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),this.state.otpAnswer=void 0),null===(r=this.state.connector)||void 0===r||r.disconnect(e),function(e){Wh("[RemoteConnection: cleanupConnector()] cleaning up connector"),e.connector&&(cp(e),e.connector.disconnect({terminate:!0}).catch((e=>{Wh("[RemoteConnection: cleanupConnector()] error disconnecting connector",e)})))}(this.state)}}function hp(e){var t,n,r,i,o,s,a,c,l,d,h;return Be(this,void 0,void 0,(function*(){const{options:f}=e;if(f.logging=null!==(t=f.logging)&&void 0!==t?t:{},f.communicationLayerPreference=null!==(n=f.communicationLayerPreference)&&void 0!==n?n:ha.SOCKET,void 0!==f.enableDebug&&(u.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),f.enableAnalytics=null===(r=f.enableAnalytics)||void 0===r||r,f.injectProvider=null===(i=f.injectProvider)||void 0===i||i,f.shouldShimWeb3=null===(o=f.shouldShimWeb3)||void 0===o||o,f.extensionOnly=null===(s=f.extensionOnly)||void 0===s||s,f.useDeeplink=null===(a=f.useDeeplink)||void 0===a||a,f.storage=null!==(c=f.storage)&&void 0!==c?c:{enabled:!0},f.headless){u("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const e=()=>{},t={install:()=>({mount:e,unmount:e})},n={installer:e};f.modals=t,f.ui=n}const p=!0===(null===(l=f.logging)||void 0===l?void 0:l.developerMode);e.debug=(null===(d=f.logging)||void 0===d?void 0:d.sdk)||p,Wh("[MetaMaskSDK: performSDKInitialization()] options",e.options);const g=Object.assign({},f.logging);p&&(g.sdk=!0,g.eciesLayer=!0,g.keyExchangeLayer=!0,g.remoteLayer=!0,g.serviceLayer=!0,g.plaintext=!0),yield function(e){var t;return Be(this,void 0,void 0,(function*(){const{options:n}=e;e.platformManager=new ff({useDeepLink:null!==(t=n.useDeeplink)&&void 0!==t&&t,preferredOpenLink:n.openDeeplink,debug:e.debug})}))}(e),yield function(e){var t,n,r,i,o,s,a,c,l;return Be(this,void 0,void 0,(function*(){const{options:d}=e,u=null===(t=e.platformManager)||void 0===t?void 0:t.getPlatformType();e.analytics=new zf({serverUrl:null!==(n=d.communicationServerUrl)&&void 0!==n?n:Us,enabled:d.enableAnalytics,originatorInfo:{url:null!==(r=d.dappMetadata.url)&&void 0!==r?r:"",title:null!==(i=d.dappMetadata.name)&&void 0!==i?i:"",dappId:"undefined"==typeof window||void 0===window.location?null!==(c=null!==(s=null===(o=d.dappMetadata)||void 0===o?void 0:o.name)&&void 0!==s?s:null===(a=d.dappMetadata)||void 0===a?void 0:a.url)&&void 0!==c?c:"N/A":window.location.hostname,platform:null!=u?u:"",source:null!==(l=d._source)&&void 0!==l?l:""}})}))}(e),yield function(e){var t;return Be(this,void 0,void 0,(function*(){const{options:n}=e;!0!==(null===(t=n.storage)||void 0===t?void 0:t.enabled)||n.storage.storageManager||(n.storage.storageManager=yield pf(n.storage))}))}(e),yield function(e){return Be(this,void 0,void 0,(function*(){const{options:t}=e,n=/^(http|https):\/\/[^\s]*$/;if(t.dappMetadata){t.dappMetadata.iconUrl&&!n.test(t.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),t.dappMetadata.iconUrl=void 0),t.dappMetadata.base64Icon&&t.dappMetadata.base64Icon.length>163400&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),t.dappMetadata.base64Icon=void 0),t.dappMetadata.url&&!n.test(t.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const e=(()=>{if("undefined"==typeof document)return;let e;const t=document.getElementsByTagName("link");for(let n=0;n<t.length;n++)"icon"!==t[n].getAttribute("rel")&&"shortcut icon"!==t[n].getAttribute("rel")||(e=t[n].getAttribute("href"));return e})();if(e&&!t.dappMetadata.iconUrl&&!t.dappMetadata.base64Icon){const n=`${window.location.protocol}//${window.location.host}${e}`;t.dappMetadata.iconUrl=n}}e.dappMetadata=t.dappMetadata}))}(e),yield(e=>Be(void 0,void 0,void 0,(function*(){const{options:t}=e,{infuraAPIKey:n}=t;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};e.options.readonlyRPCMap?e.options.readonlyRPCMap=Object.assign(Object.assign({},e.options.readonlyRPCMap),r):e.options.readonlyRPCMap=r})))(e),yield(e=>Be(void 0,void 0,void 0,(function*(){const{options:t}=e,{readonlyRPCMap:n}=t;if(n)try{Wh("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),e.setReadOnlyRPCCalls(!0)}catch(e){throw new Error("Invalid Infura Settings")}})))(e);const{metamaskBrowserExtension:m,preferExtension:y,shouldReturn:v}=yield function(e){var t,n,r,i;return Be(this,void 0,void 0,(function*(){const{options:o}=e;let s,a=!1,c=!1;if("undefined"!=typeof window&&window.ethereum&&!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){a="extension"===localStorage.getItem(Mf);try{s=yield function({mustBeMetaMask:e,sdkInstance:t}){return Be(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw new Error("window not available");try{const e=yield new Promise(((e,t)=>{const n=setTimeout((()=>{t(new Error("eip6963RequestProvider timed out"))}),500);window.addEventListener(Wf.Announce,(t=>{const r=t,{detail:{info:i,provider:o}={}}=r,{name:s,rdns:a,uuid:c}=null!=i?i:{};Cf.test(c)&&s.startsWith(Ef.NAME)&&Ef.RDNS.includes(a)&&(clearTimeout(n),e(o))})),window.dispatchEvent(new Event(Wf.Request))}));return Vf({provider:e,sdkInstance:t})}catch(n){if(!e&&window.ethereum)return Vf({provider:window.ethereum,sdkInstance:t});throw new Error("Provider not found")}}))}({mustBeMetaMask:!0,sdkInstance:e}),window.extension=s,s.on(Tf,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Tf,t)})),s.on(Rf,(t=>Be(this,void 0,void 0,(function*(){var n;Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${t}`);const r=Boolean(e.sdkProvider),i=Boolean(e.extensionActive);if(r&&e.getMobileProvider().emit(Rf,t),i&&0===(null==t?void 0:t.length)&&0===(yield null===(n=e.getProvider())||void 0===n?void 0:n.request({method:_f.WALLET_GETPERMISSIONS,params:[]})).length)try{yield e.terminate()}catch(e){Wh("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",e)}})))),s.on(Pf,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Pf,t)})),s.on(If,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(If,t)})),s.on(Nf,(t=>{Wh("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",t),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Nf,t)}))}catch(e){window.extension=void 0}}else(null===(n=e.platformManager)||void 0===n?void 0:n.isMetaMaskMobileWebView())&&(null===(r=e.analytics)||void 0===r||r.send({event:Xs.SDK_USE_INAPP_BROWSER}),e.activeProvider=Vf({provider:window.ethereum,sdkInstance:e}),e._initialized=!0,c=!0);return s&&o.extensionOnly&&(Wh("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),null===(i=e.analytics)||void 0===i||i.send({event:Xs.SDK_USE_EXTENSION}),e.activeProvider=s,e.extensionActive=!0,e.extension=s,e._initialized=!0,c=!0),{preferExtension:a,shouldReturn:c,metamaskBrowserExtension:s}}))}(e);if(v)Wh("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield function(e,t){var n,r,i,o,s;return Be(this,void 0,void 0,(function*(){const{options:a}=e,c=Object.assign({},a.logging);e.remoteConnection=new up({preferDesktop:null!==(n=a.preferDesktop)&&void 0!==n&&n,communicationLayerPreference:null!==(r=a.communicationLayerPreference)&&void 0!==r?r:ha.SOCKET,analytics:e.analytics,dappMetadata:a.dappMetadata,_source:a._source,enableAnalytics:null===(i=a.enableAnalytics)||void 0===i||i,timer:a.timer,sdk:e,platformManager:e.platformManager,transports:a.transports,communicationServerUrl:a.communicationServerUrl,storage:null!==(o=a.storage)&&void 0!==o?o:{enabled:!0},getMetaMaskInstaller:()=>{if(!e.installer)throw new Error("Invalid SDK status -- installer not initialized");return e.installer},logging:c,connectWithExtensionProvider:void 0===t?void 0:()=>$f(e),modals:Object.assign(Object.assign({},a.modals),{onPendingModalDisconnect:e.terminate.bind(e)})}),yield e.remoteConnection.initRemoteCommunication({sdkInstance:e}),e.installer=new rp({remote:e.remoteConnection,preferDesktop:null!==(s=a.preferDesktop)&&void 0!==s&&s,platformManager:e.platformManager,debug:e.debug})}))}(e,m),yield function(e){var t,n,r,i;return Be(this,void 0,void 0,(function*(){const{options:o}=e,s={communicationLayerPreference:null!==(t=o.communicationLayerPreference)&&void 0!==t?t:ha.SOCKET,platformManager:e.platformManager,sdk:e,checkInstallationOnAllCalls:o.checkInstallationOnAllCalls,injectProvider:null===(n=o.injectProvider)||void 0===n||n,shouldShimWeb3:null===(r=o.shouldShimWeb3)||void 0===r||r,extensionOnly:null===(i=o.extensionOnly)||void 0===i||i,installer:e.installer,remoteConnection:e.remoteConnection,debug:e.debug},a=yield Hf(s);e.activeProvider=a,function(e){var t,n,r,i;null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n||n.on(uf.ConnectionStatus,(t=>{e.emit(uf.ConnectionStatus,t)})),null===(i=null===(r=e.remoteConnection)||void 0===r?void 0:r.getConnector())||void 0===i||i.on(uf.ServiceStatus,(t=>{e.emit(uf.ServiceStatus,t)}))}(e)}))}(e),yield function(e,t){var n,r;return Be(this,void 0,void 0,(function*(){const{options:i}=e;t?(Wh("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),null===(n=e.analytics)||void 0===n||n.send({event:Xs.SDK_EXTENSION_UTILIZED}),$f(e).catch((e=>{console.warn("Can't connect with MetaMask extension...",e),localStorage.removeItem(Mf)}))):i.checkInstallationImmediately&&((null===(r=e.platformManager)||void 0===r?void 0:r.isDesktopWeb())?(Wh("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),e.connect().catch((e=>{Wh(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${e}`)}))):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),e._initialized=!0}))}(e,y);try{yield null===(h=e.remoteConnection)||void 0===h?void 0:h.startConnection({initialCheck:!0})}catch(e){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",e)}e.emit(uf.ProviderUpdate,Bf.INITIALIZED)}}))}class fp extends f{constructor(e={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:vf,i18nOptions:{enabled:!1}}){var t,n,r;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],u.disable();const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode);if(((null===(n=e.logging)||void 0===n?void 0:n.sdk)||i)&&u.enable("MM_SDK"),Wh("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(null===(r=e.dappMetadata)||void 0===r?void 0:r.url)){if("undefined"==typeof window||"undefined"==typeof document)throw new Error("You must provide dAppMetadata url");e.dappMetadata=Object.assign(Object.assign({},e.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.options=e,this.options._source||(e._source=vf),this.init().then((()=>{Wh("[MetaMaskSDK: constructor()]: initialized successfully."),"undefined"!=typeof window&&(window.mmsdk=this)})).catch((e=>{console.error("[MetaMaskSDK: constructor()] error during initialization",e)}))}init(){return Be(this,void 0,void 0,(function*(){return function(e){var t;return Be(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&(null===(t=window.mmsdk)||void 0===t?void 0:t.isInitialized()))return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=hp(e),yield e.sdkInitPromise}catch(e){throw console.error(e),e}return e.sdkInitPromise}))}(this)}))}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return"undefined"!=typeof window&&Boolean(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}connect(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const t=e.activeProvider.getSelectedAddress();return t?[t]:e.activeProvider.request({method:_f.ETH_REQUESTACCOUNTS,params:[]})}))}(this)}))}connectAndSign({msg:e}){return Be(this,void 0,void 0,(function*(){return function({instance:e,msg:t}){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connectAndSign()] activeProvider=${e.activeProvider}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(t)?t:function(e){let t;if(void 0!==Xe)t=Xe.from(e,"utf8").toString("hex");else if("undefined"!=typeof TextEncoder){const n=(new TextEncoder).encode(e);t=Array.from(n).map((e=>e.toString(16).padStart(2,"0"))).join("")}else{if("object"!=typeof De||!("Buffer"in De))throw new Error("Unable to convert string to hex: No available method.");t=De.Buffer.from(e,"utf8").toString("hex")}return`0x${t}`}(t);return e.activeProvider.request({method:_f.METAMASK_CONNECTWITH,params:[{method:_f.PERSONAL_SIGN,params:[n]}]})}))}({instance:this,msg:e})}))}connectWith(e){return Be(this,void 0,void 0,(function*(){return function({instance:e,rpc:t}){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connectWith()] method: ${t.method} rpc=${t}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");return e.activeProvider.request({method:_f.METAMASK_CONNECTWITH,params:[t]})}))}({instance:this,rpc:e})}))}resume(){return function(e){var t,n,r;return Be(this,void 0,void 0,(function*(){if(!(null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n?void 0:n.isReady()))return Wh("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void(null===(r=e.remoteConnection)||void 0===r||r.startConnection());Wh("[MetaMaskSDK: resume()] channel is ready")}))}(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;null===(e=this.remoteConnection)||void 0===e||e.isAuthorized()}terminate(){return function(e){var t,n,r;return Be(this,void 0,void 0,(function*(){if(!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){if(Df&&(window.localStorage.removeItem(Mf),window.localStorage.removeItem(Of),window.localStorage.removeItem(Lf)),e.extensionActive){try{yield null===(n=e.activeProvider)||void 0===n?void 0:n.request({method:_f.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(e){Wh("[MetaMaskSDK: terminate()] error revoking permissions",e)}return e.options.extensionOnly?(e.emit(uf.ProviderUpdate,Bf.TERMINATE),void Wh("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(uf.ProviderUpdate,Bf.TERMINATE))}e.emit(uf.ProviderUpdate,Bf.TERMINATE),Wh(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),null===(r=e.remoteConnection)||void 0===r||r.disconnect({terminate:!0,sendMessage:!0})}}))}(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getUniversalLink();if(!t)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return t}getChannelId(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig())||void 0===t?void 0:t.channelId}getRPCHistory(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getRPCMethodTracker()}getVersion(){return yf.version}getWalletStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getConnectionStatus()}_getChannelConfig(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig()}_ping(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.ping()}_keyCheck(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.keyCheck()}_getServiceStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getKeyInfo()}_resetKeys(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,t){return super.emit(e,t)}on(e,t){return super.on(e,t)}}var pp=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:e}={enabled:!1}){this.enabled=!1,this.enabled=e}persistChannelConfig(e){return Be(this,void 0,void 0,(function*(){const t=JSON.stringify(e);Wh(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,e),localStorage.setItem(Af,t)}))}getPersistedChannelConfig(){return Be(this,void 0,void 0,(function*(){let e;try{if(Wh(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),e=localStorage.getItem(Af),Wh("[StorageManagerWeb: getPersistedChannelConfig()]",e),!e)return;const t=JSON.parse(e);return Wh("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",t),t}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}}))}persistAccounts(e){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,e);const t=JSON.stringify(e);localStorage.setItem(Lf,t)}))}getCachedAccounts(){return Be(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Lf);return e?JSON.parse(e):[]}catch(e){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",e),e}}))}persistChainId(e){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,e),localStorage.setItem(Of,e)}))}getCachedChainId(){return Be(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Of);return null!=e?e:void 0}catch(e){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",e),e}}))}terminate(){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(Af)}))}}});var gp=Object.defineProperty,mp=new WeakMap,yp=e=>mp.get(e),vp=(e,t)=>mp.set(t.$lazyInstance$=e,t),bp=(e,t)=>t in e,wp=(e,t)=>(0,console.error)(e,t),Ep=new Map,Cp=new Map,_p="slot-fb{display:contents}slot-fb[hidden]{display:none}",Sp="undefined"!=typeof window?window:{},kp=Sp.document||{head:{}},xp={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},Ap=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),Mp=!1,Lp=[],Op=[],Tp=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){wp(e)}e.length=0},Rp=()=>{Tp(Lp),Tp(Op),(Mp=Lp.length>0)&&xp.raf(Rp)},Pp=e=>Promise.resolve(void 0).then(e),Ip=((e,t)=>t=>{e.push(t),Mp||(Mp=!0,4&xp.$flags$?Pp(Rp):xp.raf(Rp))})(Op),Np={},Bp=e=>"object"==(e=typeof e)||"function"===e;function Dp(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}((e,t)=>{for(var n in t)gp(e,n,{get:t[n],enumerable:!0})})({},{err:()=>jp,map:()=>Kp,ok:()=>$p,unwrap:()=>Fp,unwrapErr:()=>Hp});var $p=e=>({isOk:!0,isErr:!1,value:e}),jp=e=>({isOk:!1,isErr:!0,value:e});function Kp(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then((e=>$p(e))):$p(n)}if(e.isErr){const t=e.value;return jp(t)}throw"should never get here"}var Up,Fp=e=>{if(e.isOk)return e.value;throw e.value},Hp=e=>{if(e.isErr)return e.value;throw e.value},zp=(e,t,...n)=>{let r=null,i=!1,o=!1;const s=[],a=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?a(r):null!=r&&"boolean"!=typeof r&&((i="function"!=typeof e&&!Bp(r))&&(r=String(r)),i&&o?s[s.length-1].$text$+=r:s.push(i?qp(null,r):r),o=i)};if(a(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}if("function"==typeof e)return e(null===t?{}:t,s,Wp);const c=qp(e,null);return c.$attrs$=t,s.length>0&&(c.$children$=s),c},qp=(e,t)=>({$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null}),Vp={},Wp={forEach:(e,t)=>e.map(Gp).forEach(t),map:(e,t)=>e.map(Gp).map(t).map(Yp)},Gp=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),Yp=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),zp(e.vtag,t,...e.vchildren||[])}const t=qp(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},Zp=e=>yp(e).$hostElement$,Jp=(e,t,n)=>{const r=Zp(e);return{emit:e=>Xp(r,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},Xp=(e,t,n)=>{const r=xp.ce(t,n);return e.dispatchEvent(r),r},Qp=new WeakMap,eg=(e,t)=>"sc-"+e.$tagName$,tg=(e,t,n,r,i,o)=>{if(n!==r){let s=bp(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,i=rg(n),o=rg(r);t.remove(...i.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!i.includes(e))))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if(s||"o"!==t[0]||"n"!==t[1]){const a=Bp(r);if((s||a&&null!==r)&&!i)try{if(e.tagName.includes("-"))e[t]=r;else{const i=null==r?"":r;"list"===t?s=!1:null!=n&&e[t]==i||("function"==typeof e.__lookupSetter__(t)?e[t]=i:e.setAttribute(t,i))}}catch(e){}null==r||!1===r?!1===r&&""!==e.getAttribute(t)||e.removeAttribute(t):(!s||4&o||i)&&!a&&(r=!0===r?"":r,e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):bp(Sp,a)?a.slice(2):a[2]+t.slice(3),n||r){const i=t.endsWith(ig);t=t.replace(og,""),n&&xp.rel(e,t,n,i),r&&xp.ael(e,t,r,i)}}},ng=/\s/,rg=e=>e?e.split(ng):[],ig="Capture",og=new RegExp(ig+"$"),sg=(e,t,n)=>{const r=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,i=e&&e.$attrs$||Np,o=t.$attrs$||Np;for(const e of ag(Object.keys(i)))e in o||tg(r,e,i[e],void 0,n,t.$flags$);for(const e of ag(Object.keys(o)))tg(r,e,i[e],o[e],n,t.$flags$)};function ag(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var cg=!1,lg=(e,t,n,r)=>{const i=t.$children$[n];let o,s,a=0;if(null!==i.$text$)o=i.$elm$=kp.createTextNode(i.$text$);else{if(cg||(cg="svg"===i.$tag$),o=i.$elm$=kp.createElementNS(cg?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),cg&&"foreignObject"===i.$tag$&&(cg=!1),sg(null,i,cg),o.getRootNode().querySelector("body"),i.$children$)for(a=0;a<i.$children$.length;++a)s=lg(e,i,a),s&&o.appendChild(s);"svg"===i.$tag$?cg=!1:"foreignObject"===o.tagName&&(cg=!0)}return o["s-hn"]=Up,o},dg=(e,t,n,r,i,o)=>{let s,a=e;for(a.shadowRoot&&a.tagName===Up&&(a=a.shadowRoot);i<=o;++i)r[i]&&(s=lg(null,n,i),s&&(r[i].$elm$=s,pg(a,s,t)))},ug=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;e&&e.remove()}}},hg=(e,t,n=!1)=>e.$tag$===t.$tag$,fg=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,i=e.$children$,o=t.$children$,s=t.$tag$,a=t.$text$;null===a?(sg(e,t,cg="svg"===s||"foreignObject"!==s&&cg),null!==i&&null!==o?((e,t,n,r,i=!1)=>{let o,s=0,a=0,c=t.length-1,l=t[0],d=t[c],u=r.length-1,h=r[0],f=r[u];for(;s<=c&&a<=u;)null==l?l=t[++s]:null==d?d=t[--c]:null==h?h=r[++a]:null==f?f=r[--u]:hg(l,h,i)?(fg(l,h,i),l=t[++s],h=r[++a]):hg(d,f,i)?(fg(d,f,i),d=t[--c],f=r[--u]):hg(l,f,i)?(fg(l,f,i),pg(e,l.$elm$,d.$elm$.nextSibling),l=t[++s],f=r[--u]):hg(d,h,i)?(fg(d,h,i),pg(e,d.$elm$,l.$elm$),d=t[--c],h=r[++a]):(o=lg(t&&t[a],n,a),h=r[++a],o&&pg(l.$elm$.parentNode,o,l.$elm$));s>c?dg(e,null==r[u+1]?null:r[u+1].$elm$,n,r,a,u):a>u&&ug(t,s,c)})(r,i,t,o,n):null!==o?(null!==e.$text$&&(r.textContent=""),dg(r,null,t,o,0,o.length-1)):!n&&null!==i&&ug(i,0,i.length-1),cg&&"svg"===s&&(cg=!1)):e.$text$!==a&&(r.data=a)},pg=(e,t,n)=>null==e?void 0:e.insertBefore(t,n),gg=(e,t)=>{t&&!e.$onRenderResolve$&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.$onRenderResolve$=t)))},mg=(e,t)=>{if(e.$flags$|=16,!(4&e.$flags$))return gg(e,e.$ancestorComponent$),Ip((()=>yg(e,t)));e.$flags$|=512},yg=(e,t)=>{const n=e.$hostElement$;e.$cmpMeta$.$tagName$;const r=e.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return vg(void 0,(()=>wg(e,r,t)))},vg=(e,t)=>bg(e)?e.then(t).catch((e=>{console.error(e),t()})):t(),bg=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,wg=async(e,t,n)=>{var r;const i=e.$hostElement$;e.$cmpMeta$.$tagName$;const o=i["s-rc"];n&&(e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$;t.$tagName$;const i=((e,t,n)=>{var r;const i=eg(t),o=Cp.get(i);if(e=11===e.nodeType?e:kp,o)if("string"==typeof o){e=e.head||e;let n,s=Qp.get(e);if(s||Qp.set(e,s=new Set),!s.has(i)){{n=kp.createElement("style"),n.innerHTML=o;const i=null!=(r=xp.$nonce$)?r:Dp(kp);if(null!=i&&n.setAttribute("nonce",i),!(1&t.$flags$))if("HEAD"===e.nodeName){const t=e.querySelectorAll("link[rel=preconnect]"),r=t.length>0?t[t.length-1].nextSibling:e.querySelector("style");e.insertBefore(n,r)}else if("host"in e)if(Ap){const t=new CSSStyleSheet;t.replaceSync(o),e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}else{const t=e.querySelector("style");t?t.innerHTML=o+t.innerHTML:e.prepend(n)}else e.append(n);1&t.$flags$&&"HEAD"!==e.nodeName&&e.insertBefore(n,null)}4&t.$flags$&&(n.innerHTML+=_p),s&&s.add(i)}}else e.adoptedStyleSheets.includes(o)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,o]);return i})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))})(e),e.$cmpMeta$.$tagName$,Eg(e,t,i,n),o&&(o.map((e=>e())),i["s-rc"]=void 0);{const t=null!=(r=i["s-p"])?r:[],n=()=>Cg(e);0===t.length?n():(Promise.all(t).then(n),e.$flags$|=4,t.length=0)}},Eg=(e,t,n,r)=>{try{t=t.render(),e.$flags$&=-17,e.$flags$|=2,((e,t,n=!1)=>{const r=e.$hostElement$,i=e.$cmpMeta$,o=e.$vnode$||qp(null,null),s=(a=t)&&a.$tag$===Vp?t:zp(null,null,t);var a;if(Up=r.tagName,n&&s.$attrs$)for(const e of Object.keys(s.$attrs$))r.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(s.$attrs$[e]=r[e]);s.$tag$=null,s.$flags$|=4,e.$vnode$=s,s.$elm$=o.$elm$=r.shadowRoot||r,r["s-sc"],0!=(1&i.$flags$),fg(o,s,n)})(e,t,r)}catch(t){wp(t,e.$hostElement$)}return null},Cg=e=>{e.$cmpMeta$.$tagName$;const t=e.$hostElement$,n=e.$lazyInstance$,r=e.$ancestorComponent$;64&e.$flags$||(e.$flags$|=64,kg(t),Sg(n,"componentDidLoad"),e.$onReadyResolve$(t),r||_g()),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),512&e.$flags$&&Pp((()=>mg(e,!1))),e.$flags$&=-517},_g=e=>{kg(kp.documentElement),Pp((()=>Xp(Sp,"appload",{detail:{namespace:"sdk-install-modal-web"}})))},Sg=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){wp(e)}},kg=e=>e.classList.add(("hydrated","hydrated")),xg=(e,t,n)=>{var r,i;const o=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const s=Object.entries(null!=(r=t.$members$)?r:{});if(s.map((([e,[r]])=>{(31&r||2&n&&32&r)&&Object.defineProperty(o,e,{get(){return t=e,yp(this).$instanceValues$.get(t);var t},set(n){((e,t,n,r)=>{const i=yp(e);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const o=i.$hostElement$,s=i.$instanceValues$.get(t),a=i.$flags$,c=i.$lazyInstance$;var l,d;l=n,d=r.$members$[t][0],n=null==l||Bp(l)?l:4&d?"false"!==l&&(""===l||!!l):1&d?String(l):l;const u=Number.isNaN(s)&&Number.isNaN(n);if((!(8&a)||void 0===s)&&n!==s&&!u&&(i.$instanceValues$.set(t,n),c)){if(r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{c[e](n,s,t)}catch(e){wp(e,o)}}))}2==(18&a)&&mg(i,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;o.attributeChangedCallback=function(e,r,i){xp.jmp((()=>{var s;const a=n.get(e);if(this.hasOwnProperty(a))i=this[a],delete this[a];else{if(o.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==i)return;if(null==a){const n=yp(this),o=null==n?void 0:n.$flags$;if(o&&!(8&o)&&128&o&&i!==r){const o=n.$lazyInstance$,a=null==(s=t.$watchers$)?void 0:s[e];null==a||a.forEach((t=>{null!=o[t]&&o[t].call(o,i,r,e)}))}return}}this[a]=(null!==i||"boolean"!=typeof this[a])&&i}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(i=t.$watchers$)?i:{}),...s.filter((([e,t])=>15&t[0])).map((([e,t])=>{const r=t[1]||e;return n.set(r,e),r}))]))}}return e},Ag=e=>{Sg(e,"connectedCallback")},Mg=e=>{Sg(e,"disconnectedCallback")},Lg=(e,t={})=>{var r;const i=[],o=t.exclude||[],s=Sp.customElements,a=kp.head,c=a.querySelector("meta[charset]"),l=kp.createElement("style"),d=[];let u,h=!0;Object.assign(xp,t),xp.$resourcesUrl$=new URL(t.resourcesUrl||"./",kp.baseURI).href;let f=!1;if(e.map((e=>{e[1].map((t=>{var r;const a={$flags$:t[0],$tagName$:t[1],$members$:t[2],$listeners$:t[3]};4&a.$flags$&&(f=!0),a.$members$=t[2],a.$watchers$=null!=(r=t[4])?r:{};const c=a.$tagName$,l=class extends HTMLElement{constructor(e){if(super(e),this.hasRegisteredEventListeners=!1,((e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map};n.$onReadyPromise$=new Promise((e=>n.$onReadyResolve$=e)),e["s-p"]=[],e["s-rc"]=[],mp.set(e,n)})(e=this,a),1&a.$flags$)if(e.shadowRoot){if("open"!==e.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${a.$tagName$}! Mode is set to ${e.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else e.attachShadow({mode:"open"})}connectedCallback(){yp(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),u&&(clearTimeout(u),u=null),h?d.push(this):xp.jmp((()=>(e=>{if(0==(1&xp.$flags$)){const t=yp(e),r=t.$cmpMeta$;if(r.$tagName$,1&t.$flags$)(null==t?void 0:t.$lazyInstance$)?Ag(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Ag(t.$lazyInstance$)));else{t.$flags$|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){gg(t,t.$ancestorComponent$=n);break}}r.$members$&&Object.entries(r.$members$).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,r,i)=>{let o;if(0==(32&t.$flags$)){if(t.$flags$|=32,r.$lazyBundleId$){const i=((e,t,r)=>{const i=e.$tagName$.replace(/-/g,"_"),o=e.$lazyBundleId$;if(!o)return;const s=Ep.get(o);if(s)return s[i];{const e=e=>(Ep.set(o,e),e[i]);if("mm-install-modal_3"===o)return Promise.resolve().then((function(){return pm})).then(e,wp)}return function(e){return Promise.resolve().then((function(){return n(require(e))}))}(`./${o}.entry.js`).then((e=>(Ep.set(o,e),e[i])),wp)})(r);if(o=i&&"then"in i?await i:i,!o)throw new Error(`Constructor for "${r.$tagName$}#${t.$modeName$}" was not found`);o.isProxied||(r.$watchers$=o.watchers,xg(o,r,2),o.isProxied=!0),r.$tagName$,t.$flags$|=8;try{new o(t)}catch(e){wp(e)}t.$flags$&=-9,t.$flags$|=128,Ag(t.$lazyInstance$)}else{o=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(o&&o.style){let e;"string"==typeof o.style&&(e=o.style);const t=eg(r);Cp.has(t)||(r.$tagName$,((e,t,n)=>{let r=Cp.get(e);Ap&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,Cp.set(e,r)})(t,e,!!(1&r.$flags$)))}}const s=t.$ancestorComponent$,a=()=>mg(t,!0);s&&s["s-rc"]?s["s-rc"].push(a):a()})(e,t,r)}}})(this)))}disconnectedCallback(){xp.jmp((()=>(async e=>{if(0==(1&xp.$flags$)){const t=yp(e);(null==t?void 0:t.$lazyInstance$)?Mg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Mg(t.$lazyInstance$)))}})(this)))}componentOnReady(){return yp(this).$onReadyPromise$}};a.$lazyBundleId$=e[0],o.includes(c)||s.get(c)||(i.push(c),s.define(c,xg(l,a,1)))}))})),i.length>0&&(f&&(l.textContent+=_p),l.textContent+=i.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",l.innerHTML.length)){l.setAttribute("data-styles","");const e=null!=(r=xp.$nonce$)?r:Dp(kp);null!=e&&l.setAttribute("nonce",e),a.insertBefore(l,c?c.nextSibling:a.firstChild)}h=!1,d.length?d.map((e=>e.connectedCallback())):xp.jmp((()=>u=setTimeout(_g,30)))};!function(){if("undefined"!=typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}}();var Og=Object.freeze({__proto__:null,defineCustomElements:async(e,t)=>{if("undefined"!=typeof window)return await void 0,Lg([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],t)},setNonce:e=>xp.$nonce$=e});const Tg={fontFamily:"Roboto, sans-serif"},Rg=({className:e},t)=>zp("div",{style:Tg,class:e},t),Pg=({Icon:e,text:t})=>zp("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},zp("div",{class:"flexItem1"},zp(e,null)),zp("div",{class:"flexItem11"},zp("span",{style:{lineHeight:"2",color:"black"}},t))),Ig=()=>zp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),zp("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Ng=()=>zp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),Bg=()=>zp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),Dg=()=>zp("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function $g({version:e}){return zp("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",e?`v${e}`:"unknown")}const jg=()=>zp("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("rect",{width:"16",height:"16",fill:"white"}),zp("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),Kg=()=>zp("svg",{width:"273",height:"51",viewBox:"0 0 273 51",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M240.882 25.9263C239.472 24.997 237.916 24.3361 236.443 23.5101C235.489 22.9731 234.473 22.4982 233.643 21.8167C232.233 20.6602 232.524 18.3885 233.996 17.3973C236.112 15.993 239.617 16.7777 239.99 19.6483C239.99 19.7102 240.052 19.7515 240.114 19.7515H243.308C243.391 19.7515 243.454 19.6896 243.433 19.607C243.267 17.6244 242.5 15.9723 241.089 14.9191C239.741 13.9072 238.206 13.3702 236.568 13.3702C228.127 13.3702 227.359 22.271 231.901 25.0796C232.42 25.41 236.879 27.6404 238.455 28.611C240.032 29.5816 240.529 31.3576 239.845 32.7619C239.223 34.0423 237.605 34.9303 235.987 34.8271C234.224 34.7238 232.855 33.7738 232.378 32.2869C232.295 32.0185 232.254 31.5022 232.254 31.275C232.254 31.2131 232.192 31.1511 232.129 31.1511H228.666C228.604 31.1511 228.541 31.2131 228.541 31.275C228.541 33.7738 229.164 35.1575 230.864 36.4172C232.461 37.615 234.203 38.1106 236.008 38.1106C240.737 38.1106 243.184 35.4466 243.682 32.6793C244.117 29.974 243.308 27.5371 240.882 25.9263Z",fill:"#24292E"}),zp("path",{d:"M90.4943 13.8246H88.9595H87.2795C87.2173 13.8246 87.1758 13.8659 87.1551 13.9072L84.3137 23.2416C84.2722 23.3655 84.1063 23.3655 84.0648 23.2416L81.2234 13.9072C81.2026 13.8452 81.1612 13.8246 81.0989 13.8246H79.419H77.8842H75.8102C75.748 13.8246 75.6857 13.8865 75.6857 13.9485V37.7802C75.6857 37.8422 75.748 37.9041 75.8102 37.9041H79.2738C79.336 37.9041 79.3982 37.8422 79.3982 37.7802V19.6689C79.3982 19.5244 79.6056 19.5037 79.6471 19.6276L82.5093 29.024L82.7167 29.6849C82.7374 29.7468 82.7789 29.7675 82.8411 29.7675H85.4959C85.5581 29.7675 85.5996 29.7262 85.6203 29.6849L85.8277 29.024L88.6899 19.6276C88.7313 19.4831 88.9387 19.5244 88.9387 19.6689V37.7802C88.9387 37.8422 89.001 37.9041 89.0632 37.9041H92.5268C92.589 37.9041 92.6513 37.8422 92.6513 37.7802V13.9485C92.6513 13.8865 92.589 13.8246 92.5268 13.8246H90.4943Z",fill:"#24292E"}),zp("path",{d:"M187.849 13.8246C187.787 13.8246 187.745 13.8659 187.725 13.9072L184.883 23.2416C184.842 23.3655 184.676 23.3655 184.634 23.2416L181.793 13.9072C181.772 13.8452 181.731 13.8246 181.668 13.8246H176.4C176.338 13.8246 176.276 13.8865 176.276 13.9485V37.7802C176.276 37.8422 176.338 37.9041 176.4 37.9041H179.864C179.926 37.9041 179.988 37.8422 179.988 37.7802V19.6689C179.988 19.5244 180.196 19.5037 180.237 19.6276L183.099 29.024L183.307 29.6849C183.328 29.7468 183.369 29.7675 183.431 29.7675H186.086C186.148 29.7675 186.19 29.7262 186.211 29.6849L186.418 29.024L189.28 19.6276C189.322 19.4831 189.529 19.5244 189.529 19.6689V37.7802C189.529 37.8422 189.591 37.9041 189.653 37.9041H193.117C193.179 37.9041 193.241 37.8422 193.241 37.7802V13.9485C193.241 13.8865 193.179 13.8246 193.117 13.8246H187.849Z",fill:"#24292E"}),zp("path",{d:"M143.174 13.8246H136.724H133.261H126.81C126.748 13.8246 126.686 13.8865 126.686 13.9485V16.9223C126.686 16.9843 126.748 17.0462 126.81 17.0462H133.136V37.7802C133.136 37.8422 133.198 37.9041 133.261 37.9041H136.724C136.786 37.9041 136.849 37.8422 136.849 37.7802V17.0462H143.174C143.237 17.0462 143.299 16.9843 143.299 16.9223V13.9485C143.299 13.8865 143.257 13.8246 143.174 13.8246Z",fill:"#24292E"}),zp("path",{d:"M163.604 37.9041H166.756C166.839 37.9041 166.901 37.8215 166.881 37.7389L160.368 13.8245C160.347 13.7626 160.306 13.7419 160.244 13.7419H159.041H156.925H155.722C155.66 13.7419 155.619 13.7832 155.598 13.8245L149.085 37.7389C149.065 37.8215 149.127 37.9041 149.21 37.9041H152.362C152.425 37.9041 152.466 37.8628 152.487 37.8215L154.374 30.862C154.395 30.8 154.436 30.7794 154.499 30.7794H161.467C161.53 30.7794 161.571 30.8207 161.592 30.862L163.479 37.8215C163.5 37.8628 163.562 37.9041 163.604 37.9041ZM155.328 27.3719L157.859 18.0581C157.9 17.9342 158.066 17.9342 158.107 18.0581L160.638 27.3719C160.659 27.4545 160.596 27.5371 160.513 27.5371H155.453C155.37 27.5371 155.308 27.4545 155.328 27.3719Z",fill:"#24292E"}),zp("path",{d:"M217.362 37.9041H220.515C220.598 37.9041 220.66 37.8215 220.639 37.7389L214.127 13.8245C214.106 13.7626 214.065 13.7419 214.002 13.7419H212.8H210.684H209.481C209.419 13.7419 209.377 13.7832 209.357 13.8245L202.844 37.7389C202.823 37.8215 202.886 37.9041 202.969 37.9041H206.121C206.183 37.9041 206.225 37.8628 206.246 37.8215L208.133 30.862C208.154 30.8 208.195 30.7794 208.257 30.7794H215.226C215.288 30.7794 215.33 30.8207 215.351 30.862L217.238 37.8215C217.259 37.8628 217.3 37.9041 217.362 37.9041ZM209.087 27.3719L211.617 18.0581C211.659 17.9342 211.825 17.9342 211.866 18.0581L214.397 27.3719C214.417 27.4545 214.355 27.5371 214.272 27.5371H209.211C209.129 27.5371 209.066 27.4545 209.087 27.3719Z",fill:"#24292E"}),zp("path",{d:"M106.713 34.3727V26.9795C106.713 26.9176 106.775 26.8556 106.837 26.8556H116.067C116.129 26.8556 116.191 26.7936 116.191 26.7317V23.7579C116.191 23.6959 116.129 23.634 116.067 23.634H106.837C106.775 23.634 106.713 23.572 106.713 23.5101V17.1907C106.713 17.1288 106.775 17.0668 106.837 17.0668H117.332C117.394 17.0668 117.457 17.0049 117.457 16.9429V13.9691C117.457 13.9072 117.394 13.8452 117.332 13.8452H106.713H103.125C103.063 13.8452 103.001 13.9072 103.001 13.9691V17.0668V23.6546V26.8763V34.5173V37.7802C103.001 37.8422 103.063 37.9041 103.125 37.9041H106.713H117.768C117.83 37.9041 117.892 37.8422 117.892 37.7802V34.6412C117.892 34.5792 117.83 34.5173 117.768 34.5173H106.817C106.755 34.4966 106.713 34.4553 106.713 34.3727Z",fill:"#24292E"}),zp("path",{d:"M272.532 37.6976L260.544 25.3687C260.502 25.3274 260.502 25.2448 260.544 25.2035L271.329 14.0517C271.412 13.9691 271.349 13.8452 271.246 13.8452H266.828C266.787 13.8452 266.766 13.8659 266.745 13.8865L257.599 23.3449C257.516 23.4275 257.391 23.3655 257.391 23.2623V13.9691C257.391 13.9072 257.329 13.8452 257.267 13.8452H253.803C253.741 13.8452 253.679 13.9072 253.679 13.9691V37.8009C253.679 37.8628 253.741 37.9248 253.803 37.9248H257.267C257.329 37.9248 257.391 37.8628 257.391 37.8009V27.3099C257.391 27.2067 257.536 27.1447 257.599 27.2273L267.969 37.8835C267.989 37.9041 268.031 37.9248 268.052 37.9248H272.469C272.552 37.9041 272.615 37.7596 272.532 37.6976Z",fill:"#24292E"}),zp("path",{d:"M52.021 1L31.0526 16.4886L34.9517 7.36063L52.021 1Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M3.65491 1L24.4366 16.6331L20.7241 7.36063L3.65491 1Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M44.4716 36.9127L38.8925 45.4211L50.8389 48.7047L54.261 37.0986L44.4716 36.9127Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M1.43555 37.0986L4.83695 48.7047L16.7626 45.4211L11.2042 36.9127L1.43555 37.0986Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.1197 22.5395L12.8013 27.5371L24.6232 28.074L24.2292 15.3734L16.1197 22.5395Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M39.5561 22.5394L31.3222 15.2288L31.0526 28.0739L42.8746 27.537L39.5561 22.5394Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7626 45.4212L23.918 41.9724L17.7582 37.1813L16.7626 45.4212Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.7578 41.9724L38.8925 45.4212L37.9177 37.1813L31.7578 41.9724Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M38.8923 45.4212L31.7577 41.9724L32.3384 46.5983L32.2762 48.5602L38.8923 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7625 45.4212L23.3994 48.5602L23.3579 46.5983L23.9179 41.9724L16.7625 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M23.5239 34.1249L17.5922 32.3902L21.7818 30.4696L23.5239 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.1517 34.1249L33.8939 30.4696L38.1042 32.3902L32.1517 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7626 45.4212L17.7996 36.9128L11.2042 37.0987L16.7626 45.4212Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M37.8761 36.9128L38.8924 45.4212L44.4715 37.0987L37.8761 36.9128Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M42.8745 27.5371L31.0526 28.074L32.1518 34.1249L33.894 30.4696L38.1042 32.3902L42.8745 27.5371Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M17.5922 32.3902L21.7817 30.4696L23.5239 34.1249L24.6232 28.074L12.8012 27.5371L17.5922 32.3902Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M12.8013 27.5371L17.7582 37.1813L17.5923 32.3902L12.8013 27.5371Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M38.1044 32.3902L37.9177 37.1813L42.8746 27.5371L38.1044 32.3902Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M24.6232 28.0741L23.524 34.125L24.9136 41.2703L25.2247 31.8533L24.6232 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.0526 28.0741L30.4719 31.8327L30.7623 41.2703L32.1519 34.125L31.0526 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.1519 34.1249L30.7623 41.2702L31.7578 41.9724L37.9177 37.1813L38.1043 32.3901L32.1519 34.1249Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M17.5922 32.3901L17.7581 37.1813L23.918 41.9724L24.9135 41.2702L23.5239 34.1249L17.5922 32.3901Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.2763 48.5602L32.3385 46.5983L31.7993 46.1439H23.8765L23.358 46.5983L23.3995 48.5602L16.7626 45.4211L19.0855 47.3211L23.7935 50.5633H31.8615L36.5903 47.3211L38.8924 45.4211L32.2763 48.5602Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.7578 41.9724L30.7622 41.2703H24.9135L23.918 41.9724L23.358 46.5983L23.8765 46.144H31.7993L32.3385 46.5983L31.7578 41.9724Z",fill:"#24292E",stroke:"#24292E","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M52.9128 17.5005L54.6757 8.95079L52.021 1L31.7578 15.9723L39.5561 22.5394L50.5692 25.7404L52.9958 22.9111L51.938 22.147L53.618 20.6188L52.3321 19.6276L54.0121 18.3472L52.9128 17.5005Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M1 8.95079L2.78366 17.5005L1.64295 18.3472L3.34365 19.6276L2.05775 20.6188L3.73771 22.147L2.67996 22.9111L5.10657 25.7404L16.1196 22.5394L23.918 15.9723L3.65475 1L1 8.95079Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M50.5692 25.7404L39.5561 22.5394L42.8746 27.5371L37.9177 37.1813L44.4716 37.0987H54.261L50.5692 25.7404Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.1196 22.5394L5.10651 25.7404L1.43549 37.0987H11.2041L17.7581 37.1813L12.8011 27.5371L16.1196 22.5394Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.0526 28.0741L31.7578 15.9724L34.9518 7.36072H20.7239L23.9179 15.9724L24.6231 28.0741L24.8927 31.8739L24.9135 41.2703H30.7622L30.783 31.8739L31.0526 28.0741Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Ug(e,t){return e.toString(2).padStart(t,"0")}function Fg(e,t){const n=e%t;return n>=0?n:t+n}function Hg(e,t){return new Array(e).fill(t)}function zg(...e){let t=0;for(const n of e)t=Math.max(t,n.length);const n=[];for(let r=0;r<t;r++)for(const t of e)r>=t.length||n.push(t[r]);return new Uint8Array(n)}function qg(e,t,n){if(n<0||n+t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[n+r])return!1;return!0}function Vg(e){return{has:t=>e.includes(t),decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))},encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(function(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))}}}class Wg{static size(e,t){if("number"==typeof e&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return void 0!==t&&(e={width:Math.min(e.width,t.width),height:Math.min(e.height,t.height)}),e}static fromString(e){const t=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split("\n"),n=t.length,r=new Array(n);let i;for(const e of t){const t=e.split("").map((e=>{if("X"===e)return!0;if(" "===e)return!1;if("?"!==e)throw new Error(`Bitmap.fromString: unknown symbol=${e}`)}));if(i&&t.length!==i)throw new Error(`Bitmap.fromString different row sizes: width=${i} cur=${t.length}`);i=t.length,r.push(t)}return i||(i=0),new Wg({height:n,width:i},r)}constructor(e,t){const{height:n,width:r}=Wg.size(e);this.data=t||Array.from({length:n},(()=>Hg(r,void 0))),this.height=n,this.width=r}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:t,y:n}=this.xy(e);return{height:this.height-n,width:this.width-t}}xy(e){if("number"==typeof e&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=Fg(e.x,this.width),e.y=Fg(e.y,this.height),e}rect(e,t,n){const{x:r,y:i}=this.xy(e),{height:o,width:s}=Wg.size(t,this.size({x:r,y:i}));for(let e=0;e<o;e++)for(let t=0;t<s;t++)this.data[i+e][r+t]="function"==typeof n?n({x:t,y:e},this.data[i+e][r+t]):n;return this}rectRead(e,t,n){return this.rect(e,t,((e,t)=>(n(e,t),t)))}hLine(e,t,n){return this.rect(e,{width:t,height:1},n)}vLine(e,t,n){return this.rect(e,{width:1,height:t},n)}border(e=2,t){const n=this.height+2*e,r=this.width+2*e,i=Hg(e,t),o=Array.from({length:e},(()=>Hg(r,t)));return new Wg({height:n,width:r},[...o,...this.data.map((e=>[...i,...e,...i])),...o])}embed(e,t){return this.rect(e,t.size(),(({x:e,y:n})=>t.data[n][e]))}rectSlice(e,t=this.size()){const n=new Wg(Wg.size(t,this.size(this.xy(e))));return this.rect(e,t,(({x:e,y:t},r)=>n.data[t][e]=r)),n}inverse(){const{height:e,width:t}=this;return new Wg({height:t,width:e}).rect({x:0,y:0},1/0,(({x:e,y:t})=>this.data[e][t]))}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:t,width:n}=this;return new Wg({height:e*t,width:e*n}).rect({x:0,y:0},1/0,(({x:t,y:n})=>this.data[Math.floor(n/e)][Math.floor(t/e)]))}clone(){return new Wg(this.size()).rect({x:0,y:0},this.size(),(({x:e,y:t})=>this.data[t][e]))}assertDrawn(){this.rectRead(0,1/0,((e,t)=>{if("boolean"!=typeof t)throw new Error("Invalid color type="+typeof t)}))}toString(){return this.data.map((e=>e.map((e=>void 0===e?"?":e?"X":" ")).join(""))).join("\n")}toASCII(){const{height:e,width:t,data:n}=this;let r="";for(let i=0;i<e;i+=2){for(let o=0;o<t;o++){const t=n[i][o],s=i+1>=e||n[i+1][o];t||s?!t&&s?r+="▀":t&&!s?r+="▄":t&&s&&(r+=" "):r+="█"}r+="\n"}return r}toTerm(){const e="[0m",t=`[1;47m ${e}`,n=`[40m ${e}`;return this.data.map((e=>e.map((e=>e?n:t)).join(""))).join("\n")}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,(({x:t,y:n},r)=>{r&&(e+=`<rect x="${t}" y="${n}" width="1" height="1" />`)})),e+="</svg>",e}toGIF(){const e=e=>[255&e,e>>>8&255],t=[...e(this.width),...e(this.height)],n=[];this.rectRead(0,1/0,((e,t)=>n.push(+(!0===t))));const r=126,i=[71,73,70,56,55,97,...t,246,0,0,255,255,255,...Hg(381,0),44,0,0,0,0,...t,0,7],o=Math.floor(n.length/r);for(let e=0;e<o;e++)i.push(127,128,...n.slice(r*e,r*(e+1)).map((e=>+e)));return i.push(n.length%r+1,128,...n.slice(o*r).map((e=>+e))),i.push(1,129,0,59),new Uint8Array(i)}toImage(e=!1){const{height:t,width:n}=this.size(),r=new Uint8Array(t*n*(e?3:4));let i=0;for(let o=0;o<t;o++)for(let t=0;t<n;t++){const n=this.data[o][t]?0:255;r[i++]=n,r[i++]=n,r[i++]=n,e||(r[i++]=255)}return{height:t,width:n,data:r}}}const Gg=["low","medium","quartile","high"],Yg=["numeric","alphanumeric","byte","kanji","eci"],Zg=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],Jg={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},Xg={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},Qg={size:{encode:e=>21+4*(e-1),decode:e=>(e-17)/4},sizeType:e=>Math.floor((e+7)/17),alignmentPatterns(e){if(1===e)return[];const t=Qg.size.encode(e)-6-1,n=t-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const o=[6];for(let e=1;e<r;e++)o.push(t-(r-e)*i);return o.push(t),o},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(e,t){const n=Qg.ECCode[e]<<3|t;let r=n;for(let e=0;e<10;e++)r=r<<1^1335*(r>>9);return(n<<10|r)^Qg.formatMask},versionBits(e){let t=e;for(let e=0;e<12;e++)t=t<<1^7973*(t>>11);return e<<12|t},alphabet:{numeric:Vg("0123456789"),alphanumerc:Vg("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(e,t)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[t][Qg.sizeType(e)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(e,t){const n=Zg[e-1],r=Jg[t][e-1],i=Xg[t][e-1],o=Math.floor(n/i)-r,s=i-n%i;return{words:r,numBlocks:i,shortBlocks:s,blockLen:o,capacity:8*(n-r*i),total:(r+o)*i+i-s}}},em=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,(e,t)=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(t/2)+Math.floor(e/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0],tm={tables:(e=>{const t=Hg(256,0),n=Hg(256,0);for(let e=0,r=1;e<256;e++)t[e]=r,n[r]=e,r<<=1,256&r&&(r^=285);return{exp:t,log:n}})(),exp:e=>tm.tables.exp[e],log(e){if(0===e)throw new Error(`GF.log: wrong arg=${e}`);return tm.tables.log[e]%255},mul:(e,t)=>0===e||0===t?0:tm.tables.exp[(tm.tables.log[e]+tm.tables.log[t])%255],add:(e,t)=>e^t,pow:(e,t)=>tm.tables.exp[tm.tables.log[e]*t%255],inv(e){if(0===e)throw new Error(`GF.inverse: wrong arg=${e}`);return tm.tables.exp[255-tm.tables.log[e]]},polynomial(e){if(0==e.length)throw new Error("GF.polymomial: wrong length");if(0!==e[0])return e;let t=0;for(;t<e.length-1&&0==e[t];t++);return e.slice(t)},monomial(e,t){if(e<0)throw new Error(`GF.monomial: wrong degree=${e}`);if(0==t)return[0];let n=Hg(e+1,0);return n[0]=t,tm.polynomial(n)},degree:e=>e.length-1,coefficient:(e,t)=>e[tm.degree(e)-t],mulPoly(e,t){if(0===e[0]||0===t[0])return[0];const n=Hg(e.length+t.length-1,0);for(let r=0;r<e.length;r++)for(let i=0;i<t.length;i++)n[r+i]=tm.add(n[r+i],tm.mul(e[r],t[i]));return tm.polynomial(n)},mulPolyScalar(e,t){if(0==t)return[0];if(1==t)return e;const n=Hg(e.length,0);for(let r=0;r<e.length;r++)n[r]=tm.mul(e[r],t);return tm.polynomial(n)},mulPolyMonomial(e,t,n){if(t<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(0==n)return[0];const r=Hg(e.length+t,0);for(let t=0;t<e.length;t++)r[t]=tm.mul(e[t],n);return tm.polynomial(r)},addPoly(e,t){if(0===e[0])return t;if(0===t[0])return e;let n=e,r=t;n.length>r.length&&([n,r]=[r,n]);let i=Hg(r.length,0),o=r.length-n.length,s=r.slice(0,o);for(let e=0;e<s.length;e++)i[e]=s[e];for(let e=o;e<r.length;e++)i[e]=tm.add(n[e-o],r[e]);return tm.polynomial(i)},remainderPoly(e,t){const n=Array.from(e);for(let r=0;r<e.length-t.length+1;r++){const e=n[r];if(0!==e)for(let i=1;i<t.length;i++)0!==t[i]&&(n[r+i]=tm.add(n[r+i],tm.mul(t[i],e)))}return n.slice(e.length-t.length+1,n.length)},divisorPoly(e){let t=[1];for(let n=0;n<e;n++)t=tm.mulPoly(t,[1,tm.pow(2,n)]);return t},evalPoly(e,t){if(0==t)return tm.coefficient(e,0);let n=e[0];for(let r=1;r<e.length;r++)n=tm.add(tm.mul(t,n),e[r]);return n},euclidian(e,t,n){tm.degree(e)<tm.degree(t)&&([e,t]=[t,e]);let r=e,i=t,o=[0],s=[1];for(;2*tm.degree(i)>=n;){let e=r,t=o;if(r=i,o=s,0===r[0])throw new Error("rLast[0] === 0");i=e;let n=[0];const a=tm.inv(r[0]);for(;tm.degree(i)>=tm.degree(r)&&0!==i[0];){const e=tm.degree(i)-tm.degree(r),t=tm.mul(i[0],a);n=tm.addPoly(n,tm.monomial(e,t)),i=tm.addPoly(i,tm.mulPolyMonomial(r,e,t))}if(n=tm.mulPoly(n,o),s=tm.addPoly(n,t),tm.degree(i)>=tm.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const a=tm.coefficient(s,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const c=tm.inv(a);return[tm.mulPolyScalar(s,c),tm.mulPolyScalar(i,c)]}};function nm(e,t,n,r){let i="",o=n.length;if("numeric"===r){const e=Qg.alphabet.numeric.decode(n.split("")),t=e.length;for(let n=0;n<t-2;n+=3)i+=Ug(100*e[n]+10*e[n+1]+e[n+2],10);t%3==1?i+=Ug(e[t-1],4):t%3==2&&(i+=Ug(10*e[t-2]+e[t-1],7))}else if("alphanumeric"===r){const e=Qg.alphabet.alphanumerc.decode(n.split("")),t=e.length;for(let n=0;n<t-1;n+=2)i+=Ug(45*e[n]+e[n+1],11);t%2==1&&(i+=Ug(e[t-1],6))}else{if("byte"!==r)throw new Error("encode: unsupported type");{const e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(n);o=e.length,i=Array.from(e).map((e=>Ug(e,8))).join("")}}const{capacity:s}=Qg.capacity(e,t),a=Ug(o,Qg.lengthBits(e,r));let c=Qg.modeBits[r]+a+i;if(c.length>s)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,s-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));for(let e=0;c.length!==s;e++)c+="1110110000010001"[e%16];const l=Uint8Array.from(c.match(/(.{8})/g).map((e=>Number(`0b${e}`))));return function(e,t){const{words:n,shortBlocks:r,numBlocks:i,blockLen:o,total:s}=Qg.capacity(e,t),a=(c=n,{encode(e){const t=tm.divisorPoly(c),n=Array.from(e);return n.push(...t.slice(0,-1).fill(0)),Uint8Array.from(tm.remainderPoly(n,t))},decode(e){const t=e.slice(),n=tm.polynomial(Array.from(e));let r=Hg(c,0),i=!1;for(let e=0;e<c;e++){const t=tm.evalPoly(n,tm.exp(e));r[r.length-1-e]=t,0!==t&&(i=!0)}if(!i)return t;r=tm.polynomial(r);const o=tm.monomial(c,1),[s,a]=tm.euclidian(o,r,c),l=Hg(tm.degree(s),0);let d=0;for(let e=1;e<256&&d<l.length;e++)0===tm.evalPoly(s,e)&&(l[d++]=tm.inv(e));if(d!==l.length)throw new Error("RS.decode: wrong errors number");for(let e=0;e<l.length;e++){const n=t.length-1-tm.log(l[e]);if(n<0)throw new Error("RS.decode: wrong error location");const r=tm.inv(l[e]);let i=1;for(let t=0;t<l.length;t++)e!==t&&(i=tm.mul(i,tm.add(1,tm.mul(l[t],r))));t[n]=tm.add(t[n],tm.mul(tm.evalPoly(a,r),tm.inv(i)))}return t}});var c;return{encode(e){const t=[],n=[];for(let s=0;s<i;s++){const i=o+(s<r?0:1);t.push(e.subarray(0,i)),n.push(a.encode(e.subarray(0,i))),e=e.subarray(i)}const s=zg(...t),c=zg(...n),l=new Uint8Array(s.length+c.length);return l.set(s),l.set(c,s.length),l},decode(e){if(e.length!==s)throw new Error(`interleave.decode: len(data)=${e.length}, total=${s}`);const t=[];for(let e=0;e<i;e++){const i=e<r;t.push(new Uint8Array(n+o+(i?0:1)))}let c=0;for(let n=0;n<o;n++)for(let r=0;r<i;r++)t[r][n]=e[c++];for(let n=r;n<i;n++)t[n][o]=e[c++];for(let s=o;s<o+n;s++)for(let n=0;n<i;n++){const i=n<r;t[n][s+(i?0:1)]=e[c++]}const l=[];for(const e of t)l.push(...Array.from(a.decode(e)).slice(0,-n));return Uint8Array.from(l)}}}(e,t).encode(l)}function rm(e,t,n,r,i=!1){const o=function(e,t,n,r=!1){const i=Qg.size.encode(e);let o=new Wg(i+2);const s=new Wg(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);o=o.embed(0,s).embed({x:-s.width,y:0},s).embed({x:0,y:-s.height},s),o=o.rectSlice(1,i);const a=new Wg(1).rect(0,1,!0).border(1,!1).border(1,!0),c=Qg.alignmentPatterns(e);for(const e of c)for(const t of c)void 0===o.data[e][t]&&o.embed({x:t-2,y:e-2},a);o=o.hLine({x:0,y:6},1/0,(({x:e},t)=>void 0===t?e%2==0:t)).vLine({x:6,y:0},1/0,(({y:e},t)=>void 0===t?e%2==0:t));{const e=Qg.formatBits(t,n),s=t=>!r&&1==(e>>t&1);for(let e=0;e<6;e++)o.data[e][8]=s(e);for(let e=6;e<8;e++)o.data[e+1][8]=s(e);for(let e=8;e<15;e++)o.data[i-15+e][8]=s(e);for(let e=0;e<8;e++)o.data[8][i-e-1]=s(e);for(let e=8;e<9;e++)o.data[8][15-e-1+1]=s(e);for(let e=9;e<15;e++)o.data[8][15-e-1]=s(e);o.data[i-8][8]=!r}if(e>=7){const t=Qg.versionBits(e);for(let e=0;e<18;e+=1){const n=!r&&1==(t>>e&1),s=Math.floor(e/3),a=e%3+i-8-3;o.data[s][a]=n,o.data[a][s]=n}}return o}(e,t,r,i);let s=0;const a=8*n.length;if(function(e,t,n){const r=e.height,i=em[t];let o=-1,s=r-1;for(let t=r-1;t>0;t-=2){for(6==t&&(t=5);;s+=o){for(let r=0;r<2;r+=1){const o=t-r;void 0===e.data[s][o]&&n(o,s,i(o,s))}if(s+o<0||s+o>=r)break}o=-o}}(o,r,((e,t,r)=>{let i=!1;s<a&&(i=0!=(n[s>>>3]>>(7-s&7)&1),s++),o.data[t][e]=i!==r})),s!==a)throw new Error("QR: bytes left after draw");return o}function im(e){const t=e.inverse(),n=e=>{let t=0;for(let n,r=0,i=1;r<e.length;r++)n===e[r]&&(i++,r!==e.length-1)||(i>=5&&(t+=i-5+3),n=e[r],i=1);return t};let r=0;e.data.forEach((e=>r+=n(e))),t.data.forEach((e=>r+=n(e)));let i=0,o=e.data;const s=e.width-1,a=e.height-1;for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=e+1,r=t+1;o[e][t]===o[n][t]&&o[n][t]===o[e][r]&&o[n][t]===o[n][r]&&(i+=3)}const c=e=>{const t=[!0,!1,!0,!0,!0,!1,!0],n=[!1,!1,!1,!1],r=[...t,...n],i=[...n,...t];let o=0;for(let t=0;t<e.length;t++)qg(e,r,t)&&(o+=40),qg(e,i,t)&&(o+=40);return o};let l=0;for(const t of e.data)l+=c(t);for(const e of t.data)l+=c(e);let d=0;e.rectRead(0,1/0,((e,t)=>d+=t?1:0));const u=d/(e.height*e.width)*100,h=10*Math.floor(Math.abs(u-50)/5);return r+i+l+h}function om(e,t="raw",n={}){const r=void 0!==n.ecc?n.ecc:"medium";!function(e){if(!Gg.includes(e))throw new Error(`Invalid error correction mode=${e}. Expected: ${Gg}`)}(r);const i=void 0!==n.encoding?n.encoding:function(e){let t="numeric";for(let n of e)if(!Qg.alphabet.numeric.has(n)&&(t="alphanumeric",!Qg.alphabet.alphanumerc.has(n)))return"byte";return t}(e);!function(e){if(!Yg.includes(e))throw new Error(`Encoding: invalid mode=${e}. Expected: ${Yg}`);if("kanji"===e||"eci"===e)throw new Error(`Encoding: ${e} is not supported (yet?).`)}(i),void 0!==n.mask&&function(e){if(![0,1,2,3,4,5,6,7].includes(e)||!em[e])throw new Error(`Invalid mask=${e}. Expected number [0..7]`)}(n.mask);let o,s=n.version,a=new Error("Unknown error");if(void 0!==s)!function(e){if(!Number.isSafeInteger(e)||e<1||e>40)throw new Error(`Invalid version=${e}. Expected number [1..40]`)}(s),o=nm(s,r,e,i);else for(let t=1;t<=40;t++)try{o=nm(t,r,e,i),s=t;break}catch(e){a=e}if(!s||!o)throw a;let c=function(e,t,n,r){if(void 0===r){const i=function(){let e,t=1/0;return{add(n,r){n>=t||(e=r,t=n)},get:()=>e,score:()=>t}}();for(let r=0;r<em.length;r++)i.add(im(rm(e,t,n,r,!0)),r);r=i.get()}if(void 0===r)throw new Error("Cannot find mask");return rm(e,t,n,r)}(s,r,o,n.mask);c.assertDrawn();const l=void 0===n.border?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),void 0!==n.scale&&(c=c.scale(n.scale)),"raw"===t)return c.data;if("ascii"===t)return c.toASCII();if("svg"===t)return c.toSVG();if("gif"===t)return c.toGIF();if("term"===t)return c.toTerm();throw new Error(`Unknown output: ${t}`)}const sm={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class am{constructor(e){var t;this.translations=sm,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some((e=>e.toLowerCase().startsWith("en"))))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const t=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(t)}async loadTranslations(e){const t=e.split("-")[0];if("en"!==t&&this.supportedLocales.includes(t))try{const e=`${this.baseUrl}/${t}.json`,n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);this.translations=await n.json()}catch(e){console.warn(`❌ Failed to load ${t} translations, falling back to English:`,e),this.translations=sm}else this.translations=sm}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,t){const n=e.split(".");let r=t;for(const e of n){if("object"!=typeof r)return"";r=r[e]}return"string"==typeof r?r:""}}var cm;!function(e){e.SDK_MODAL_VIEWED="sdk_modal_viewed",e.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",e.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"}(cm||(cm={}));const lm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.startDesktopOnboarding=Jp(this,"startDesktopOnboarding",7),this.trackAnalytics=Jp(this,"trackAnalytics",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new am}componentDidLoad(){this.trackAnalytics.emit({event:cm.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:1===this.tab?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}onClose(e=!1){this.close.emit({shouldTerminate:e})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:cm.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(e,t=!1){t&&this.trackAnalytics.emit({event:cm.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:1===this.tab?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=e,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=om(this.link,"svg",{ecc:"medium",scale:2});return zp(Rg,{className:"install-model"},zp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"tabcontainer"},zp("div",{class:"flexContainer"},zp("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(1===t?"tabactive":"")},e("DESKTOP")),zp("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(2===t?"tabactive":"")},e("MOBILE")))),zp("div",{style:{display:1===t?"none":"block"}},zp("div",{class:"flexContainer"},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&zp("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),zp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT")," ",zp("br",null),zp("span",{class:"blue"},zp("b",null,e("META_MASK_MOBILE_APP"))))))),zp("div",{style:{display:2===t?"none":"block"}},zp("div",{class:"item"},zp(Pg,{Icon:Ng,text:e("INSTALL_MODAL.TRUSTED_BY_USERS")})),zp("div",{class:"item"},zp(Pg,{Icon:Ig,text:e("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),zp("div",{class:"item"},zp(Pg,{Icon:Bg,text:e("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),zp("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},zp(Dg,null),zp("span",{class:"installExtensionText"},e("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),zp($g,{version:this.sdkVersion})))}get el(){return Zp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};lm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const dm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.disconnect=Jp(this,"disconnect",7),this.updateOTPValue=Jp(this,"updateOTPValue",7),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new am}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(e){this.updateOTPValue.emit({otpValue:e})}disconnectedCallback(){this.onClose()}render(){var e;if(!this.translationsLoaded)return null;const t=null===(e=this.displayOTP)||void 0===e||e,n=this.sdkVersion,r=e=>this.i18nInstance.t(e);return zp(Rg,{className:"pending-modal"},zp("div",{class:"backdrop",onClick:()=>this.onClose()}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose()},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(t?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),zp("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),t&&zp("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),zp("div",{style:{marginTop:"20px"}},zp("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),zp($g,{version:n})))}get el(){return Zp(this)}};dm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const um=()=>zp("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),hm=()=>zp("svg",{width:"400",height:"300",viewBox:"0 0 467 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M312.387 280.629C312.549 280.583 312.247 280.735 312.387 280.629L339.678 260.425C340.088 260.118 340.132 259.156 340.07 258.647C340.008 258.138 339.573 258.257 339.106 258.084L311.712 247.455C311.292 247.301 311.308 247.402 310.939 247.673C310.569 247.944 310.356 248.21 310.356 248.672L310.459 279.504C310.461 280.025 311.163 280.619 311.614 280.847C311.913 280.996 312.072 280.718 312.387 280.629ZM336.204 259.736L312.979 276.292L313.439 251.139L336.204 259.736Z",fill:"url(#paint0_linear_1356_14057)"}),zp("path",{d:"M324.639 260.342C324.358 259.547 323.485 258.91 322.707 259.215C319.6 260.432 318.17 262.313 317.287 264.066C316.482 265.665 316.197 267.482 314.188 268.269C312.178 269.055 310.763 268.663 309.162 268.007C307.406 267.287 305.504 266.182 302.397 267.399C299.289 268.616 297.859 270.497 296.976 272.25C296.171 273.849 295.697 274.886 293.685 275.673C291.675 276.459 290.261 276.067 288.659 275.411C286.903 274.691 284.999 273.587 281.894 274.803C278.789 276.019 277.549 278.681 276.666 280.434C275.861 282.034 275.386 283.07 273.374 283.857C272.596 284.161 271.931 285.055 272.211 285.849C272.492 286.644 273.365 287.281 274.143 286.977C277.25 285.76 278.68 283.879 279.563 282.125C280.368 280.526 280.65 278.71 282.662 277.923C284.672 277.136 286.087 277.528 287.688 278.184C289.444 278.904 291.348 280.009 294.453 278.793C297.561 277.576 298.991 275.695 299.874 273.941C300.679 272.342 301.153 271.306 303.165 270.519C305.175 269.732 306.589 270.124 308.191 270.78C309.947 271.5 311.849 272.605 314.956 271.388C318.063 270.172 319.301 267.511 320.184 265.757C320.989 264.158 321.466 263.121 323.476 262.335C324.254 262.032 324.919 261.137 324.639 260.342Z",fill:"url(#paint1_linear_1356_14057)"}),zp("path",{d:"M389.034 111.124C388.968 112.406 387.342 113.113 386.324 113.549C384.297 114.419 382.089 114.493 379.942 114.5C376.607 114.509 373.215 114.163 369.89 113.976C366.712 113.798 363.156 113.311 360.03 114.232C357.705 114.919 355.667 116.762 353.452 117.739C351.129 118.765 348.957 119.198 346.489 119.687C335.569 121.85 323.587 120.825 312.656 119.977C311.92 119.92 312.539 118.997 313.237 118.981C313.207 118.815 313.001 118.394 313.045 118.201C313.086 118.029 312.781 117.586 312.853 117.421C312.67 117.198 313.316 117.427 313.626 117.204C315.912 115.557 318.721 114.79 321.363 115.041C324.677 115.355 327.293 116.04 330.641 115.781C334.392 115.491 338.125 114.787 341.857 114.312C345.142 113.892 349.09 113.941 352.106 112.28C352.916 111.834 353.137 111.262 353.269 110.287C353.331 109.828 353.672 108.969 353.658 108.511C353.629 107.529 354.191 107.886 355.013 107.298C356.857 105.981 358.274 105.516 360.428 105.784C362.841 106.083 365.264 107.273 367.578 107.953C370.761 108.888 374.328 108.646 377.631 108.477C380.517 108.329 383.141 107.901 385.944 108.653C387.013 108.941 389.104 109.745 389.034 111.124Z",fill:"url(#paint2_linear_1356_14057)"}),zp("path",{d:"M278.118 85.4414C280.313 83.8186 283.302 83.9 285.853 83.2728C290.501 82.127 295.644 78.4476 300.549 79.1524C301.299 79.2595 300.904 81.0355 300.159 80.9295C300.131 80.9256 300.187 80.9333 300.159 80.9295C300.089 81.0185 299.516 81.1051 299.385 81.1463C294.999 82.515 292.895 87.5083 289.126 89.8598C287.799 90.688 286.771 90.8351 285.258 90.9441C283.515 91.0691 280.964 90.5775 279.269 90.1219C277.15 89.5532 275.965 87.034 278.118 85.4414Z",fill:"url(#paint3_linear_1356_14057)"}),zp("path",{d:"M122.567 166.093C113.597 172.832 104.535 179.836 99.517 190.092C98.5342 192.099 97.519 195.019 97.9533 197.204C98.9699 202.316 105.76 203.049 110.691 201.96C113.468 201.347 116.325 199.231 115.921 196.319C115.576 193.81 113.158 192.986 112.072 190.73C110.779 188.04 112.35 184.97 114.218 182.62C128.134 165.099 150.074 157.394 171.093 151.607C175.385 150.425 180.897 147.69 180.581 143.099C180.372 140.072 177.118 137.683 174.221 137.383C171.324 137.082 168.481 138.773 165.715 139.776C158.416 142.419 151.17 143.799 143.489 143.526C136.865 143.29 130.976 143.316 129.562 150.781C128.138 158.276 129.53 160.863 122.567 166.093Z",fill:"url(#paint4_linear_1356_14057)"}),zp("path",{d:"M79.1056 153.531C60.3932 164.378 43.7478 178.354 32.8214 197.415C30.3313 201.76 27.9216 206.554 27.1821 211.512C26.4448 216.47 27.7591 222.525 30.8133 226.337C34.908 231.446 41.6938 232.915 48.1811 233.125C50.7248 233.208 53.0035 233.066 55.3316 231.947C57.6602 230.83 59.7548 228.359 59.5978 225.742C59.3303 221.315 54.5491 219.665 50.9271 217.34C42.6566 212.037 40.4958 199.493 44.2381 190.032C47.9803 180.57 55.8228 173.173 63.2316 166.338C67.229 162.651 71.5194 158.372 76.777 157.522C79.9167 157.015 83.4706 157.589 86.6295 157.252C93.9004 156.479 99.64 151.404 105.588 146.912C115.048 139.765 126.045 134.283 137.501 132.093C141.913 131.248 146.293 130.493 149.682 127.831C151.37 126.507 150.803 123.567 148.726 123.93C138.542 125.713 128.652 131.135 119.142 134.758C105.627 139.914 91.7133 146.223 79.1056 153.531Z",fill:"url(#paint5_linear_1356_14057)"}),zp("path",{d:"M96.3677 117.321C96.0315 116.64 95.2914 116.612 94.6293 116.975C91.9858 118.417 91.5452 120.509 90.9466 122.178C90.4004 123.702 89.3647 124.67 87.6542 125.604C85.9437 126.538 85.0983 126.316 83.5956 125.91C81.9481 125.465 79.8603 125.424 77.2168 126.866C74.5734 128.309 74.1348 130.401 73.5341 132.07C72.9879 133.593 71.9522 134.562 70.2417 135.496C68.5313 136.43 67.6859 136.208 66.1832 135.801C64.5357 135.357 62.2569 134.538 59.6128 135.978C56.9694 137.42 56.5308 139.512 55.9301 141.181C55.3839 142.705 54.5398 144.454 52.8293 145.388C52.1667 145.748 52.1006 146.485 52.439 147.165C52.7752 147.845 53.5153 147.874 54.1773 147.511C56.8208 146.069 57.2594 143.977 57.86 142.307C58.4062 140.784 59.4419 139.815 61.1524 138.881C62.8629 137.948 63.7083 138.17 65.211 138.576C66.8585 139.021 68.9458 139.059 71.5898 137.619C74.2333 136.177 74.6718 134.085 75.2725 132.416C75.8187 130.892 76.8544 129.924 78.5649 128.99C80.2754 128.056 81.1207 128.278 82.6235 128.684C84.2709 129.129 86.5503 129.95 89.1938 128.507C91.8373 127.065 92.2779 124.973 92.8765 123.304C93.4227 121.78 94.2663 120.03 95.9773 119.098C96.6378 118.738 96.7039 118.001 96.3677 117.321Z",fill:"#FBC49D"}),zp("path",{d:"M391.827 164.699C392.04 164.639 392.39 164.573 392.6 164.481C393.87 163.921 395.363 162.429 395.893 161.051C396.421 159.673 396.237 158.321 395.712 156.931C394.629 154.061 391.777 152.62 389.155 153.775C386.531 154.931 384.962 158.455 386.042 161.325C387.038 163.963 389.369 165.392 391.827 164.699ZM394.166 157.367C394.529 158.332 394.52 159.751 394.156 160.706C393.792 161.662 393.1 162.534 392.218 162.921C390.398 163.723 388.338 162.878 387.589 160.889C387.226 159.925 387.234 158.506 387.599 157.55C387.963 156.594 388.654 155.723 389.536 155.336C391.356 154.534 393.416 155.376 394.166 157.367Z",fill:"#86E29B"}),zp("path",{d:"M62.7198 108.691C64.4912 108.191 66.6152 106.609 67.5596 104.824C68.4273 103.187 68.465 101.455 67.9609 99.7066C67.4547 97.9586 66.0792 96.5141 64.4963 95.6786C62.9135 94.843 61.2077 94.8578 59.4756 95.4255C57.7435 95.9933 56.2768 97.4364 55.409 99.074C53.6185 102.456 55.2032 106.494 58.4723 108.22C60.0142 109.035 61.1315 109.138 62.7198 108.691ZM60.6304 96.7682C61.819 96.4332 63.0232 96.8871 64.1048 97.4571C65.2463 98.0603 66.0495 98.8796 66.4145 100.142C66.7791 101.403 66.4488 103.299 65.8224 104.48C64.5299 106.919 61.2212 107.686 58.8638 106.441C56.5063 105.197 55.8538 101.858 57.1462 99.4185C57.7726 98.2375 58.6059 97.3957 59.8573 96.9862C59.9214 96.9635 60.5631 96.7872 60.6304 96.7682Z",fill:"#FFB0EB"}),zp("path",{d:"M77.0217 242.979C75.9542 243.28 75.1664 242.151 74.9029 241.074C74.6394 239.996 75 239.378 76.0676 239.077C77.1351 238.776 78.5053 238.907 78.7688 239.984C79.0323 241.061 78.0893 242.678 77.0217 242.979Z",fill:"url(#paint6_linear_1356_14057)"}),zp("path",{d:"M380.506 184.577C379.439 184.878 378.651 183.749 378.387 182.672C378.124 181.594 378.484 180.976 379.552 180.675C380.619 180.374 381.99 180.505 382.253 181.582C382.517 182.659 381.574 184.276 380.506 184.577Z",fill:"url(#paint7_linear_1356_14057)"}),zp("path",{d:"M348.82 246.969C347.752 247.27 346.382 247.14 346.119 246.063C345.855 244.985 346.798 243.369 347.866 243.068C348.933 242.767 349.721 243.896 349.985 244.973C350.248 246.05 349.888 246.669 348.82 246.969Z",fill:"url(#paint8_linear_1356_14057)"}),zp("path",{d:"M140.419 282.412C139.351 282.713 138.754 282.365 138.491 281.288C138.227 280.21 138.397 278.812 139.464 278.511C140.532 278.21 142.093 279.121 142.357 280.198C142.62 281.275 141.486 282.111 140.419 282.412Z",fill:"url(#paint9_linear_1356_14057)"}),zp("path",{d:"M121.462 101.679C120.395 101.979 119.798 101.631 119.534 100.554C119.271 99.4764 119.44 98.0779 120.508 97.777C121.575 97.4761 123.136 98.3868 123.4 99.4642C123.663 100.542 122.53 101.378 121.462 101.679Z",fill:"url(#paint10_linear_1356_14057)"}),zp("path",{d:"M370.749 159.005C369.682 159.306 368.311 159.175 368.048 158.098C367.784 157.021 368.727 155.404 369.795 155.103C370.863 154.802 371.65 155.931 371.914 157.008C372.177 158.086 371.817 158.704 370.749 159.005Z",fill:"url(#paint11_linear_1356_14057)"}),zp("path",{d:"M384.211 245.345C383.143 245.646 381.773 245.515 381.51 244.438C381.246 243.361 382.189 241.744 383.257 241.443C384.324 241.142 385.112 242.271 385.376 243.348C385.639 244.426 385.278 245.044 384.211 245.345Z",fill:"url(#paint12_linear_1356_14057)"}),zp("path",{d:"M364.771 41.3873C363.063 41.8687 361.337 40.8616 360.915 39.1378C360.493 37.414 361.536 35.6263 363.244 35.1449C364.953 34.6634 366.679 35.6706 367.101 37.3944C367.522 39.1182 366.479 40.9059 364.771 41.3873Z",fill:"url(#paint13_linear_1356_14057)"}),zp("path",{d:"M404.311 77.905C404.602 77.8231 404.875 77.9236 405.084 77.6871C405.437 77.2908 404.814 76.6385 404.703 76.1265L401.277 58.7418C401.149 58.163 400.687 57.5371 400.123 57.3991C399.558 57.2611 398.969 57.3812 398.576 57.835L385.784 73.1179C385.395 73.564 385.199 74.3453 385.393 74.8964C385.585 75.4481 385.978 76.1646 386.548 76.2391L403.538 78.123C403.744 78.1479 404.114 77.9607 404.311 77.905ZM398.948 62.7348L401.811 74.4394L389.841 72.8085L398.948 62.7348Z",fill:"#FFB0EB"}),zp("path",{d:"M97.5393 295.311C97.7108 295.263 97.4284 295.461 97.5393 295.311L108.785 280.464C108.975 280.211 108.718 279.972 108.594 279.684C108.47 279.396 108.124 279.917 107.821 279.902L88.5106 278.672C88.2101 278.659 87.895 278.62 87.7374 278.89C87.5798 279.159 87.7755 279.402 87.9283 279.67L96.5753 294.749C96.7102 294.99 97.2696 295.297 97.5393 295.311C97.6283 295.319 97.4556 295.335 97.5393 295.311ZM106.465 281.118L96.9667 292.97L90.6295 280.577L106.465 281.118Z",fill:"#86E29B"}),zp("path",{d:"M393.699 108.848C389.518 104.446 414.629 114.366 413.945 120.659C413.259 126.952 401.355 129.102 403.894 123.491C406.042 118.747 400.376 115.876 393.699 108.848Z",fill:"#FBC49D"}),zp("path",{d:"M139.414 115.959C139.434 115.953 139.392 115.965 139.414 115.959C141.963 115.2 143.436 111.976 142.717 109.189C142.37 107.839 141.526 107.199 140.408 106.504C139.289 105.808 138.171 105.449 136.933 105.815C135.698 106.182 134.85 107.033 134.222 108.247C133.595 109.461 133.282 111.234 133.63 112.585C133.978 113.935 134.821 114.574 135.94 115.27C137.04 115.952 138.199 116.301 139.414 115.959ZM137.315 107.375C138.222 107.12 139.005 106.994 139.825 107.502C140.661 108.02 140.912 108.618 141.171 109.625C141.708 111.704 140.935 113.834 139.032 114.398C138.11 114.675 137.356 114.791 136.522 114.272C135.686 113.753 135.436 113.155 135.176 112.149C134.917 111.142 134.718 109.714 135.186 108.81C135.654 107.905 136.394 107.649 137.315 107.375C137.329 107.371 137.299 107.38 137.315 107.375Z",fill:"#75C4FD"}),zp("path",{d:"M308.981 78.7519C310.052 78.4043 311.158 78.7096 312.265 78.6613C313.655 78.6006 314.936 78.517 316.323 78.3531C319.497 77.9795 322.798 77.4906 325.984 77.3012C329.309 77.1025 332.514 76.8551 335.836 77.0295C338.809 77.1842 342.163 77.3405 345.105 77.7558C352.129 78.7468 359.331 79.0578 366.347 80.1158C372.252 81.008 377.93 82.1319 383.722 83.5644C385.925 84.0054 388.267 85.0754 389.126 85.3792C389.421 85.4833 389.37 85.8347 389.317 86.1595C389.306 86.2271 389.353 86.1146 389.317 86.1595C388.269 87.414 386.564 86.8124 385.259 86.4677C384.406 86.241 381.488 85.9494 381.011 85.9957C380.14 86.0815 379.277 86.014 379.656 87.2114C380.122 88.6824 382.391 89.7375 383.704 90.2419C385.883 91.0803 388.771 91.2561 390.845 92.4015C392.968 92.821 395.425 93.5002 397.022 93.9986C402.83 95.8103 407.806 98.8678 413.033 102.002C415.503 103.482 417.829 104.764 419.973 106.72C421.647 108.248 423.771 109.882 424.595 112.091C425.113 113.482 424.451 115.471 422.848 115.085C420.353 114.488 419.638 111.665 418.227 109.714C415.003 105.251 410.067 102.067 405.118 100.06C402.64 99.0556 399.803 98.729 397.204 98.1176C394.411 97.4613 391.597 97.0442 388.707 97.1736C385.646 97.3097 382.846 97.5534 379.819 98.0078C377.027 98.4264 374.252 98.4441 371.514 97.8441C368.766 97.2421 366.276 96.7553 363.6 95.9021C361.662 95.2848 359.013 94.5583 357.232 93.5247C355.699 92.6339 355.631 91.2381 357.241 90.186C359.87 88.4656 362.778 89.8021 365.546 90.3497C365.561 90.3527 365.532 90.3468 365.546 90.3497C367.858 90.804 369.649 90.098 371.923 89.3884C372.489 89.2128 373.255 89.0482 373.47 88.953C374.383 88.5432 375.895 87.8227 375.407 86.7394C374.868 85.5457 372.659 84.8846 371.55 84.4891C369.74 83.8428 368.053 82.9215 366.147 82.6743C365.654 82.6095 365.109 83.1606 364.6 83.1097C363.36 83.1121 361.769 83.348 360.543 83.418C357.43 83.5916 354.583 83.6228 351.464 83.4719C348.714 83.3377 346.432 82.8542 343.741 82.3102C340.773 81.7101 337.52 81.5879 334.471 81.5839C331.393 81.5811 328.6 81.7214 325.583 82.4181C322.758 83.0702 319.757 83.6198 316.887 84.0326C314.698 84.3481 312.467 84.6054 310.319 84.2137C309.079 83.9871 306.994 83.3394 306.461 81.9635C305.846 80.3659 307.736 79.1556 308.981 78.7519Z",fill:"url(#paint14_linear_1356_14057)"}),zp("path",{d:"M242.269 242.95C242.295 242.947 242.244 242.955 242.269 242.95C244.934 242.606 247.53 241.858 250.2 241.574C253.133 241.264 256.006 240.56 258.906 239.982C263.26 239.117 268.026 238.52 272.254 237.097C274.429 236.365 276.067 235.298 278.251 234.592C280.361 233.909 283.058 233.12 285.216 232.652C289.317 231.764 293.049 231.66 297.016 230.198C301.109 228.69 305.088 226.673 308.819 224.409C312.645 222.086 316.282 219.769 320.622 218.62C322.381 218.154 323.919 218.219 325.65 218.886C327.016 219.413 327.739 220.337 327.196 221.79C326.557 223.504 324.659 224.7 323.131 225.423C320.854 226.5 319.53 227.184 317.134 227.927C314.619 228.707 311.888 229.24 309.395 230.083C308.226 230.947 307.17 232.522 306.105 233.501C303.996 235.441 301.666 237.03 298.945 237.996C292.934 240.129 286.354 238.602 280.183 239.056C279.661 239.095 279.162 239.442 278.635 239.487C275.592 240.135 272.2 240.63 269.156 241.294C264.546 242.299 260.456 243.409 255.808 244.179C251.971 244.814 243.815 245.854 243.815 245.854L242.074 245.505C240.575 245.281 240.751 243.152 242.269 242.95Z",fill:"url(#paint15_linear_1356_14057)"}),zp("path",{d:"M432.985 171.626C438.212 165.465 445.109 153.64 442.906 144.649C442.162 137.999 433.671 132.912 424.963 135.518C420.16 136.957 416.435 142.146 419.724 144.498C420.656 145.164 422.187 145.591 423.391 145.969C434.204 149.375 434.925 162.538 425.069 169.683C421.087 172.569 416.347 174.292 411.914 176.719C400.151 183.162 399.887 196.847 387.7 202.712C382.326 205.298 375.761 206.838 370.297 209.275C359.98 213.88 352.555 221.733 342.241 226.341C337.225 228.584 330.266 231.632 323.483 234.12C321.475 234.855 321.999 237.058 324.056 236.46C324.098 236.449 324.017 236.474 324.056 236.46C329.079 234.971 334.437 233.161 339.331 231.33C352.278 226.48 365.28 220.971 377.43 214.775C401.78 202.367 416.881 190.609 432.985 171.626Z",fill:"url(#paint16_linear_1356_14057)"}),zp("path",{d:"M343.644 241.104C348.002 234.144 357.126 232.455 364.343 231.134C368.176 230.431 372.406 229.878 376.137 228.662C380.691 227.175 384.558 224.095 388.327 221.077C389.452 220.177 391.204 218.466 392.393 217.436C393.185 216.748 393.644 216.026 394.33 215.225C396 213.275 399.599 209.812 401.687 208.16C403.263 206.914 407.779 204.758 408.259 207.986C408.611 210.359 406.379 213.087 404.961 214.747C402.224 217.953 398.998 221.079 395.475 223.243C391.749 225.531 387.701 227.439 383.674 229.051C381.672 229.853 379.519 230.073 377.486 230.785C376.001 231.307 374.486 232.236 373.037 232.866C371.034 233.738 368.99 234.28 367.041 235.38C364.436 236.849 361.782 238.783 359.108 240.105C356.331 241.477 353.823 242.691 350.791 243.27C348.6 243.687 345.501 243.641 343.836 241.884C343.526 241.554 343.389 241.51 343.644 241.104Z",fill:"url(#paint17_linear_1356_14057)"}),zp("path",{d:"M190.163 273.219C222.905 268.849 232.64 262.943 213.962 259.057C195.285 255.172 187.5 262.08 188.434 266.2C189.366 270.32 180.381 271.326 169.286 272.39C158.193 273.454 157.141 276.354 190.163 273.219Z",fill:"url(#paint18_linear_1356_14057)"}),zp("path",{d:"M295.952 95.4242L241.395 135.226L251.54 111.77L295.952 95.4242Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M170.111 95.4242L224.181 135.598L214.522 111.77L170.111 95.4242Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M276.309 187.712L261.793 209.576L292.876 218.014L301.78 188.189L276.309 187.712Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M164.336 188.189L173.186 218.014L204.215 209.576L189.753 187.712L164.336 188.189Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M202.542 150.776L193.908 163.618L224.667 164.998L223.642 132.36L202.542 150.776Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M263.52 150.775L242.097 131.989L241.395 164.998L272.154 163.618L263.52 150.775Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L222.832 200.714L206.805 188.402L204.215 209.576Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M243.23 200.714L261.793 209.576L259.257 188.402L243.23 200.714Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M261.793 209.576L243.23 200.714L244.741 212.601L244.579 217.643L261.793 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L221.483 217.643L221.375 212.601L222.832 200.714L204.215 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M221.807 180.547L206.373 176.09L217.274 171.154L221.807 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.255 180.547L248.788 171.154L259.742 176.09L244.255 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L206.913 187.712L189.753 188.189L204.215 209.576Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M259.149 187.712L261.793 209.576L276.309 188.189L259.149 187.712Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M272.154 163.618L241.395 164.998L244.255 180.547L248.788 171.154L259.742 176.09L272.154 163.618Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M206.373 176.09L217.274 171.154L221.807 180.547L224.667 164.998L193.908 163.618L206.373 176.09Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M193.908 163.618L206.805 188.402L206.373 176.09L193.908 163.618Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M259.743 176.09L259.257 188.402L272.154 163.618L259.743 176.09Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M224.667 164.998L221.807 180.548L225.422 198.909L226.232 174.71L224.667 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M241.395 164.998L239.884 174.657L240.64 198.909L244.255 180.548L241.395 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.255 180.547L240.64 198.909L243.23 200.714L259.257 188.402L259.743 176.09L244.255 180.547Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M206.373 176.09L206.805 188.402L222.832 200.714L225.422 198.909L221.807 180.547L206.373 176.09Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.579 217.643L244.741 212.601L243.338 211.434H222.724L221.375 212.601L221.483 217.643L204.215 209.576L210.259 214.459L222.508 222.791H243.5L255.803 214.459L261.793 209.576L244.579 217.643Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M243.23 200.714L240.64 198.909H225.422L222.832 200.714L221.375 212.601L222.724 211.434H243.338L244.741 212.601L243.23 200.714Z",fill:"#161616",stroke:"#161616","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M298.272 137.827L302.859 115.856L295.952 95.4242L243.23 133.899L263.52 150.775L292.174 159.001L298.488 151.731L295.736 149.767L300.107 145.84L296.761 143.293L301.132 140.002L298.272 137.827Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M163.203 115.856L167.844 137.827L164.876 140.002L169.301 143.293L165.955 145.84L170.326 149.767L167.574 151.731L173.888 159.001L202.542 150.775L222.832 133.899L170.11 95.4242L163.203 115.856Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M292.175 159.001L263.52 150.775L272.154 163.618L259.257 188.402L276.309 188.189H301.78L292.175 159.001Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M202.542 150.775L173.888 159.001L164.336 188.189H189.753L206.805 188.402L193.908 163.618L202.542 150.775Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M241.395 164.998L243.23 133.9L251.54 111.77H214.522L222.832 133.9L224.667 164.998L225.368 174.763L225.422 198.909H240.64L240.694 174.763L241.395 164.998Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("defs",null,zp("linearGradient",{id:"paint0_linear_1356_14057",x1:"335.991",y1:"250.487",x2:"303.873",y2:"266.801",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint1_linear_1356_14057",x1:"276.993",y1:"303.722",x2:"205.254",y2:"401.574",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint2_linear_1356_14057",x1:"271.074",y1:"119.924",x2:"553.077",y2:"104.53",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint3_linear_1356_14057",x1:"264.209",y1:"91.0943",x2:"357.834",y2:"72.8792",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint4_linear_1356_14057",x1:"212.46",y1:"121.997",x2:"92.6119",y2:"183.406",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint5_linear_1356_14057",x1:"23.0498",y1:"204.411",x2:"161.86",y2:"163.003",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint6_linear_1356_14057",x1:"78.8647",y1:"240.375",x2:"74.9655",y2:"241.328",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint7_linear_1356_14057",x1:"382.349",y1:"181.971",x2:"378.45",y2:"182.925",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint8_linear_1356_14057",x1:"349.889",y1:"244.583",x2:"345.99",y2:"245.537",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint9_linear_1356_14057",x1:"142.262",y1:"279.808",x2:"138.362",y2:"280.762",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint10_linear_1356_14057",x1:"123.305",y1:"99.0746",x2:"119.406",y2:"100.028",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint11_linear_1356_14057",x1:"371.818",y1:"156.617",x2:"367.919",y2:"157.571",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint12_linear_1356_14057",x1:"385.281",y1:"242.958",x2:"381.382",y2:"243.911",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint13_linear_1356_14057",x1:"367.125",y1:"37.5052",x2:"360.843",y2:"38.8076",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint14_linear_1356_14057",x1:"300.182",y1:"91.321",x2:"479.464",y2:"104.041",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint15_linear_1356_14057",x1:"363.434",y1:"201.232",x2:"102.977",y2:"302.269",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint16_linear_1356_14057",x1:"447.962",y1:"165.159",x2:"313.049",y2:"197.95",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint17_linear_1356_14057",x1:"410.211",y1:"215.859",x2:"341.378",y2:"232.788",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint18_linear_1356_14057",x1:"222.282",y1:"258.986",x2:"162.257",y2:"273.774",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})))),fm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.connectWithExtension=Jp(this,"connectWithExtension",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new am,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(e=!1){this.close.emit({shouldTerminate:e})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(e){this.tab=e,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=om(this.link,"svg",{ecc:"medium",scale:2});return zp(Rg,{className:"select-modal"},zp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"tabcontainer"},zp("div",{class:"flexContainer"},zp("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(1===n?"tabactive":"")},e("DESKTOP")),zp("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(2===n?"tabactive":"")},e("MOBILE")))),zp("div",{style:{display:1===n?"none":"block"}},zp("div",{class:"flexContainer"},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},zp("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),zp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT"),zp("br",null),zp("span",{class:"blue"},zp("b",null,e("META_MASK_MOBILE_APP"))))))),zp("div",{style:{display:2===n?"none":"block"}},zp("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},zp(hm,null)),zp("div",{class:"extensionLabel"},e("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),zp("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},zp(um,null),zp("span",{class:"installExtensionText"},e("CONNECT_WITH_EXTENSION"))))),zp($g,{version:t})))}get el(){return Zp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};fm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";var pm=Object.freeze({__proto__:null,mm_install_modal:lm,mm_pending_modal:dm,mm_select_modal:fm});function gm(e){const t=e.getProvider();try{t.on("connect",events.connect),t.on("disconnect",events.disconnect),t.on("accountsChanged",events.accountsChanged),t.on("chainChanged",events.chainChanged),t.on("message",events.message)}catch(e){}return t}exports.default=function(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const n={};t.rpc&&Object.entries(t.rpc).forEach((([e,t])=>{const r=`0x${Number(e).toString(16)}`;n[r]=t}));const r=new fp({useDeeplink:!0,enableAnalytics:!1,dappMetadata:{name:t.appName,iconUrl:t.appLogoUrl},readonlyRPCMap:n});r.isInitialized()||(yield r.init());let i=gm(r);yield r.connect(),i||(i=gm(r));return yield e.convertWeb3Provider(i)}))};
|
|
9
|
+
d=h,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof process&&"function"==typeof process.nextTick,i="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,a=i?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function u(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var h=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function f(t,n){for(var r={},i=t.length,o=n?n.length:0,s=0;s<i;s++)r[t[s]]=s<o?n[s]:e;return r}function p(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(n,r,i,o){var s=Object.assign({},r);if(!n)return s;if("object"!=typeof n)throw TypeError("options must be an object");var a,c,l,d=Object.keys(n),u=d.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<u;f++){if(a=d[f],!o&&!t.call(r,a))throw Error('Unknown "'+a+'" option');(c=n[a])!==e&&(l=i[a],s[a]=l?l(c,h):c)}return s}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var o=typeof e;if(o===r||o===i)return e;n(t)}:function(r,i){for(var o=typeof r,s=n;s-- >0;)if(o===e[s])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var r=h.apply(null,arguments),s={data:r,name:t,original:e};n?!1!==n.call(i,s)&&o.emit.apply(o,[s.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=a,r._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,s=this._emitter,c=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function d(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=E.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;c.call(l,e,t),delete o[e],--this._listenersCount||d()}else{for(r=(n=a(o)).length;r-- >0;)e=n[r],c.call(l,e,o[e]);this._listeners={},this._listenersCount=0,d()}}});var v=y(["function"]),b=y(["object","function"]);function w(e,t,n){var r,i,o,s=0,a=new e((function(c,l,d){function u(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=g(n,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof d;var h=function(e){u(),c(e)},f=function(e){u(),l(e)};r?t(h,f,d):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),l(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function E(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function C(e,t,n,r,i){if(!n)return null;if(0===r){var o=typeof t;if("string"===o){var s,c,l=0,d=0,u=this.delimiter,h=u.length;if(-1!==(c=t.indexOf(u))){s=new Array(5);do{s[l++]=t.slice(d,c),d=c+h}while(-1!==(c=t.indexOf(u,d)));s[l++]=t.slice(d),t=s,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,y,v,b,w=null,E=t[r],_=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===E){for(c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&(b=C(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===E){for((y=r+1===i||r+2===i&&"*"===_)&&n._listeners&&(w=C(e,t,n,i,i)),c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&("*"===f||"**"===f?(n[f]._listeners&&!y&&(b=C(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=C(e,t,n[f],r,i)):b=C(e,t,n[f],f===_?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[E]&&(w=C(e,t,n[E],r+1,i))}if((p=n["*"])&&C(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&C(e,t,g,i,i),c=(v=a(g)).length;c-- >0;)"_listeners"!==(f=v[c])&&(f===_?C(e,t,g[f],r+2,i):f===E?C(e,t,g[f],r+1,i):((m={})[f]=g[f],C(e,t,{"**":m},r+1,i)));else g._listeners?C(e,t,g,i,i):g["*"]&&g["*"]._listeners&&C(e,t,g["*"],i,i);return w}function _(e,t,n){var r,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,r),s=r+c}while(-1!==(r=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+1<o;r++)if("**"===i[r]&&"**"===i[r+1])return;var l,d=this.listenerTree;for(r=0;r<o;r++)if(d=d[l=i[r]]||(d[l]={}),r===o-1)return d._listeners?("function"==typeof d._listeners&&(d._listeners=[d._listeners]),n?d._listeners.unshift(t):d._listeners.push(t),!d._listeners.warned&&this._maxListeners>0&&d._listeners.length>this._maxListeners&&(d._listeners.warned=!0,u.call(this,d._listeners.length,l))):d._listeners=t,!0;return!0}function S(e,t,n,r){for(var i,o,s,c,l=a(e),d=l.length,u=e._listeners;d-- >0;)i=e[o=l[d]],s="_listeners"===o?n:n?n.concat(o):[o],c=r||"symbol"==typeof o,u&&t.push(c?s:s.join(this.delimiter)),"object"==typeof i&&S.call(this,i,t,s,c);return t}function k(e){for(var t,n,r,i=a(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,"_listeners"===n||k(t)||delete e[n]);return r}function x(e,t,n){this.emitter=e,this.event=t,this.listener=n}function A(t,n,i){if(!0===i)a=!0;else if(!1===i)o=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var o=i.async,a=i.promisify,c=i.nextTick,l=i.objectify}if(o||c||a){var d=n,u=n._origin||n;if(c&&!r)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?c?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?process.nextTick:s)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=u}return[n,l?new x(this,t,n):this]}function M(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},M.EventEmitter2=M,M.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,r=i.reducers,s=E.call(o,t);n=-1===s?new p(o,t,i):o._observers[s];for(var c,l=a(e),d=l.length,u="function"==typeof r,h=0;h<d;h++)c=l[h],n.subscribe(c,e[c]||c,u?r:r&&r[c])}return i=g(i,{on:e,off:e,reducers:e},{on:v,off:v,reducers:b}),n(r)?s(f(r)):s("string"==typeof r?f(r.split(/\s+/)):r),this},M.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},M.prototype.delimiter=".",M.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},M.prototype.getMaxListeners=function(){return this._maxListeners},M.prototype.event="",M.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},M.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},M.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},M.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},M.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},M.prototype._many=function(e,t,n,r,i){var o=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},M.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,i)for(r=0;r<n;r++)if("symbol"==typeof a[r]){s=!0;break}s||(a=a.join(this.delimiter))}var d,u=arguments.length;if(this._all&&this._all.length)for(r=0,n=(d=this._all.slice()).length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this,a);break;case 2:d[r].call(this,a,arguments[1]);break;case 3:d[r].call(this,a,arguments[1],arguments[2]);break;default:d[r].apply(this,arguments)}if(l)d=[],C.call(this,d,e,this.listenerTree,0,n);else{if("function"==typeof(d=this._events[a])){switch(this.event=a,u){case 1:d.call(this);break;case 2:d.call(this,arguments[1]);break;case 3:d.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];d.apply(this,t)}return!0}d&&(d=d.slice())}if(d&&d.length){if(u>3)for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];for(r=0,n=d.length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this);break;case 2:d[r].call(this,arguments[1]);break;case 3:d[r].call(this,arguments[1],arguments[2]);break;default:d[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},M.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,i)for(o=0;o<r;o++)if("symbol"==typeof a[o]){t=!0;break}t||(a=a.join(this.delimiter))}var d,u=[],h=arguments.length;if(this._all)for(o=0,r=this._all.length;o<r;o++)switch(this.event=a,h){case 1:u.push(this._all[o].call(this,a));break;case 2:u.push(this._all[o].call(this,a,arguments[1]));break;case 3:u.push(this._all[o].call(this,a,arguments[1],arguments[2]));break;default:u.push(this._all[o].apply(this,arguments))}if(l?(d=[],C.call(this,d,e,this.listenerTree,0)):d=this._events[a],"function"==typeof d)switch(this.event=a,h){case 1:u.push(d.call(this));break;case 2:u.push(d.call(this,arguments[1]));break;case 3:u.push(d.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];u.push(d.apply(this,n))}else if(d&&d.length){if(d=d.slice(),h>3)for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];for(o=0,r=d.length;o<r;o++)switch(this.event=a,h){case 1:u.push(d[o].call(this));break;case 2:u.push(d[o].call(this,arguments[1]));break;case 3:u.push(d[o].call(this,arguments[1],arguments[2]));break;default:u.push(d[o].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(u)},M.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},M.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},M.prototype.onAny=function(e){return this._onAny(e,!1)},M.prototype.prependAny=function(e){return this._onAny(e,!0)},M.prototype.addListener=M.prototype.on,M.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},M.prototype._on=function(t,n,r,i){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,s=this;return i!==e&&(n=(o=A.call(this,t,n,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(_.call(this,t,n,r),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),r?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,u.call(this,this._events[t].length,t))):this._events[t]=n,s)},M.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=C.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var c=-1,l=0,d=r.length;l<d;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&k(this.listenerTree),this},M.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},M.prototype.removeListener=M.prototype.off,M.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,r=C.call(this,null,t,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&k(this.listenerTree)}else this._events&&(this._events[t]=null);return this},M.prototype.listeners=function(t){var n,r,i,o,s,c=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!c)return[];for(o=(n=a(c)).length,i=[];o-- >0;)"function"==typeof(r=c[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],d="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,l,d,s,0),l}return c&&(r=c[t])?"function"==typeof r?[r]:r:[]},M.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?a(t):[]},M.prototype.listenerCount=function(e){return this.listeners(e).length},M.prototype.hasListeners=function(t){if(this.wildcard){var n=[],r="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?a(i).length:i[t]))},M.prototype.listenersAny=function(){return this._all?this._all:[]},M.prototype.waitFor=function(t,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),w((n=g(n,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:v,Promise:m})).Promise,(function(e,i,o){function s(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(t,s),n.handleError){var a=arguments[0];a?i(a):e(h.apply(null,arguments).slice(1))}else e(h.apply(null,arguments))}o((function(){r.off(t,s)})),r._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var L=M.prototype;Object.defineProperties(M,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=g(n,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,r,i){var o;if("function"==typeof e.addEventListener)return o=function(){n(h.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),n(h.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,a),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return M})):d.exports=M}();var f=h.exports;const p=Object.create(null);p.open="0",p.close="1",p.ping="2",p.pong="3",p.message="4",p.upgrade="5",p.noop="6";const g=Object.create(null);Object.keys(p).forEach((e=>{g[p[e]]=e}));const m={type:"error",data:"parser error"},y="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),v="function"==typeof ArrayBuffer,b=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,w=({type:e,data:t},n,r)=>y&&t instanceof Blob?n?r(t):E(t,r):v&&(t instanceof ArrayBuffer||b(t))?n?r(t):E(new Blob([t]),r):r(p[e]+(t||"")),E=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function C(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let _;const S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)k[S.charCodeAt(e)]=e;const x="function"==typeof ArrayBuffer,A=(e,t)=>{if("string"!=typeof e)return{type:"message",data:L(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:M(e.substring(1),t)};return g[n]?e.length>1?{type:g[n],data:e.substring(1)}:{type:g[n]}:m},M=(e,t)=>{if(x){const n=(e=>{let t,n,r,i,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),d=new Uint8Array(l);for(t=0;t<a;t+=4)n=k[e.charCodeAt(t)],r=k[e.charCodeAt(t+1)],i=k[e.charCodeAt(t+2)],o=k[e.charCodeAt(t+3)],d[c++]=n<<2|r>>4,d[c++]=(15&r)<<4|i>>2,d[c++]=(3&i)<<6|63&o;return l})(e);return L(n,t)}return{base64:!0,data:e}},L=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,O=String.fromCharCode(30);function T(){return new TransformStream({transform(e,t){!function(e,t){y&&e.data instanceof Blob?e.data.arrayBuffer().then(C).then(t):v&&(e.data instanceof ArrayBuffer||b(e.data))?t(C(e.data)):w(e,!1,(e=>{_||(_=new TextEncoder),t(_.encode(e))}))}(e,(n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)}))}})}let R;function P(e){return e.reduce(((e,t)=>e+t.length),0)}function I(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function N(e){if(e)return function(e){for(var t in N.prototype)e[t]=N.prototype[t];return e}(e)}N.prototype.on=N.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},N.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},N.prototype.off=N.prototype.removeListener=N.prototype.removeAllListeners=N.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},N.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},N.prototype.emitReserved=N.prototype.emit,N.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},N.prototype.hasListeners=function(e){return!!this.listeners(e).length};const B="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function D(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const $=B.setTimeout,j=B.clearTimeout;function K(e,t){t.useNativeTimers?(e.setTimeoutFn=$.bind(B),e.clearTimeoutFn=j.bind(B)):(e.setTimeoutFn=B.setTimeout.bind(B),e.clearTimeoutFn=B.clearTimeout.bind(B))}class U extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class F extends N{constructor(e){super(),this.writable=!1,K(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new U(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=A(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const H="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),z=64,q={};let V,W=0,G=0;function Y(e){let t="";do{t=H[e%z]+t,e=Math.floor(e/z)}while(e>0);return t}function Z(){const e=Y(+new Date);return e!==V?(W=0,V=e):e+"."+Y(W++)}for(;G<z;G++)q[H[G]]=G;let J=!1;try{J="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const X=J;function Q(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||X))return new XMLHttpRequest}catch(e){}if(!t)try{return new(B[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function ee(){}const te=null!=new Q({xdomain:!1}).responseType;class ne extends N{constructor(e,t){super(),K(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=D(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new Q(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ne.requestsCount++,ne.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=ee,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ne.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ne.requestsCount=0,ne.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",re);else if("function"==typeof addEventListener){addEventListener("onpagehide"in B?"pagehide":"unload",re,!1)}function re(){for(let e in ne.requests)ne.requests.hasOwnProperty(e)&&ne.requests[e].abort()}const ie="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),oe=B.WebSocket||B.MozWebSocket,se="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const ae={websocket:class extends F{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=se?{}:D(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=se?new oe(e,t,n):t?new oe(e,t):new oe(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;w(n,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}r&&ie((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!oe}},webtransport:class extends F{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){R||(R=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(P(n)<1)break;const e=I(n,1);o=128==(128&e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(P(n)<2)break;const e=I(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(P(n)<8)break;const e=I(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(m);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(P(n)<i)break;const e=I(n,i);a.enqueue(A(o?e:R.decode(e),t)),r=0}if(0===i||i>e){a.enqueue(m);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=T();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const i=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then((()=>{r&&ie((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends F{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=te&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(O),r=[];for(let e=0;e<n.length;e++){const i=A(n[e],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach(((e,o)=>{w(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(O))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Z()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ne(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},ce=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,le=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function de(e){if(e.length>2e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=ce.exec(e||""),o={},s=14;for(;s--;)o[le[s]]=i[s]||"";return-1!=n&&-1!=r&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,o.path),o.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,o.query),o}class ue extends N{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=de(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=de(t.host).host),K(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new ae[e](n)}open(){let e;if(this.opts.rememberUpgrade&&ue.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),n=!1;ue.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;ue.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&i()}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",ue.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let n=0;n<this.writeBuffer.length;n++){const r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}var t;return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){ue.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}ue.protocol=4;const he="function"==typeof ArrayBuffer,fe=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,pe=Object.prototype.toString,ge="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===pe.call(Blob),me="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===pe.call(File);function ye(e){return he&&(e instanceof ArrayBuffer||fe(e))||ge&&e instanceof Blob||me&&e instanceof File}function ve(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(ve(e[t]))return!0;return!1}if(ye(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ve(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&ve(e[t]))return!0;return!1}function be(e){const t=[],n=e.data,r=e;return r.data=we(n,t),r.attachments=t.length,{packet:r,buffers:t}}function we(e,t){if(!e)return e;if(ye(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=we(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=we(e[r],t));return n}return e}function Ee(e,t){return e.data=Ce(e.data,t),delete e.attachments,e}function Ce(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Ce(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Ce(e[n],t));return e}const _e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Se;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Se||(Se={}));function ke(e){return"[object Object]"===Object.prototype.toString.call(e)}class xe extends N{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===Se.BINARY_EVENT;n||t.type===Se.BINARY_ACK?(t.type=n?Se.EVENT:Se.ACK,this.reconstructor=new Ae(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!ye(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===Se[n.type])throw new Error("unknown packet type "+n.type);if(n.type===Se.BINARY_EVENT||n.type===Se.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!xe.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Se.CONNECT:return ke(t);case Se.DISCONNECT:return void 0===t;case Se.CONNECT_ERROR:return"string"==typeof t||ke(t);case Se.EVENT:case Se.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===_e.indexOf(t[0]));case Se.ACK:case Se.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ae{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Ee(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Me=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Se},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Se.EVENT&&e.type!==Se.ACK||!ve(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Se.EVENT?Se.BINARY_EVENT:Se.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Se.BINARY_EVENT&&e.type!==Se.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=be(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Decoder:xe});function Le(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Oe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Te extends N{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Le(e,"open",this.onopen.bind(this)),Le(e,"packet",this.onpacket.bind(this)),Le(e,"error",this.onerror.bind(this)),Le(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Oe.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:Se.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const n=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((r,i)=>{t.push(((e,t)=>n?e?i(e):r(t):r(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Se.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Se.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Se.EVENT:case Se.BINARY_EVENT:this.onevent(e);break;case Se.ACK:case Se.BINARY_ACK:this.onack(e);break;case Se.DISCONNECT:this.ondisconnect();break;case Se.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:Se.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Se.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function Re(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Re.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Re.prototype.reset=function(){this.attempts=0},Re.prototype.setMin=function(e){this.ms=e},Re.prototype.setMax=function(e){this.max=e},Re.prototype.setJitter=function(e){this.jitter=e};class Pe extends N{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,K(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new Re({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Me;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ue(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Le(t,"open",(function(){n.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=Le(t,"error",i);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn((()=>{r(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Le(e,"ping",this.onping.bind(this)),Le(e,"data",this.ondata.bind(this)),Le(e,"error",this.onerror.bind(this)),Le(e,"close",this.onclose.bind(this)),Le(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){ie((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Te(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ie={};function Ne(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=de(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=Ie[i]&&o in Ie[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Pe(r,t):(Ie[i]||(Ie[i]=new Pe(r,t)),a=Ie[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function Be(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}Object.assign(Ne,{Manager:Pe,Socket:Te,io:Ne,connect:Ne}),"function"==typeof SuppressedError&&SuppressedError;var De="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},$e=[],je=[],Ke="undefined"!=typeof Uint8Array?Uint8Array:Array,Ue=!1;function Fe(){Ue=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)$e[t]=e[t],je[e.charCodeAt(t)]=t;je["-".charCodeAt(0)]=62,je["_".charCodeAt(0)]=63}function He(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push($e[(i=r)>>18&63]+$e[i>>12&63]+$e[i>>6&63]+$e[63&i]);return o.join("")}function ze(e){var t;Ue||Fe();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,c=n-r;a<c;a+=s)o.push(He(e,a,a+s>c?c:a+s));return 1===r?(t=e[n-1],i+=$e[t>>2],i+=$e[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=$e[t>>10],i+=$e[t>>4&63],i+=$e[t<<2&63],i+="="),o.push(i),o.join("")}function qe(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=n?i-1:0,h=n?-1:1,f=e[t+u];for(u+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function Ve(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,d=(1<<l)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,i),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+f]=255&s,f+=p,s/=256,l-=8);e[n+f-p]|=128*g}var We={}.toString,Ge=Array.isArray||function(e){return"[object Array]"==We.call(e)};Xe.TYPED_ARRAY_SUPPORT=void 0===De.TYPED_ARRAY_SUPPORT||De.TYPED_ARRAY_SUPPORT;var Ye=Ze();function Ze(){return Xe.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Je(e,t){if(Ze()<t)throw new RangeError("Invalid typed array length");return Xe.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Xe.prototype:(null===e&&(e=new Xe(t)),e.length=t),e}function Xe(e,t,n){if(!(Xe.TYPED_ARRAY_SUPPORT||this instanceof Xe))return new Xe(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return tt(this,e)}return Qe(this,e,t,n)}function Qe(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Xe.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Xe.prototype:e=nt(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Xe.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ot(t,n),i=(e=Je(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(it(t)){var n=0|rt(t.length);return 0===(e=Je(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Je(e,0):nt(e,t);if("Buffer"===t.type&&Ge(t.data))return nt(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function et(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function tt(e,t){if(et(t),e=Je(e,t<0?0:0|rt(t)),!Xe.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function nt(e,t){var n=t.length<0?0:0|rt(t.length);e=Je(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function rt(e){if(e>=Ze())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ze().toString(16)+" bytes");return 0|e}function it(e){return!(null==e||!e._isBuffer)}function ot(e,t){if(it(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Rt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Pt(e).length;default:if(r)return Rt(e).length;t=(""+t).toLowerCase(),r=!0}}function st(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Et(this,t,n);case"utf8":case"utf-8":return yt(this,t,n);case"ascii":return bt(this,t,n);case"latin1":case"binary":return wt(this,t,n);case"base64":return mt(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ct(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function at(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function ct(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=Xe.from(t,r)),it(t))return 0===t.length?-1:lt(e,t,n,r,i);if("number"==typeof t)return t&=255,Xe.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):lt(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function lt(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var d=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function dt(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function ut(e,t,n,r){return It(Rt(t,e.length-n),e,n,r)}function ht(e,t,n,r){return It(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function ft(e,t,n,r){return ht(e,t,n,r)}function pt(e,t,n,r){return It(Pt(t),e,n,r)}function gt(e,t,n,r){return It(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function mt(e,t,n){return 0===t&&n===e.length?ze(e):ze(e.slice(t,n))}function yt(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],d=null,u=l>239?4:l>223?3:l>191?2:1;if(i+u<=n)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),i+=u}return function(e){var t=e.length;if(t<=vt)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=vt));return n}(r)}Xe.poolSize=8192,Xe._augment=function(e){return e.__proto__=Xe.prototype,e},Xe.from=function(e,t,n){return Qe(null,e,t,n)},Xe.TYPED_ARRAY_SUPPORT&&(Xe.prototype.__proto__=Uint8Array.prototype,Xe.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Xe[Symbol.species]),Xe.alloc=function(e,t,n){return function(e,t,n,r){return et(t),t<=0?Je(e,t):void 0!==n?"string"==typeof r?Je(e,t).fill(n,r):Je(e,t).fill(n):Je(e,t)}(null,e,t,n)},Xe.allocUnsafe=function(e){return tt(null,e)},Xe.allocUnsafeSlow=function(e){return tt(null,e)},Xe.isBuffer=Nt,Xe.compare=function(e,t){if(!it(e)||!it(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},Xe.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Xe.concat=function(e,t){if(!Ge(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Xe.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Xe.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!it(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},Xe.byteLength=ot,Xe.prototype._isBuffer=!0,Xe.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)at(this,t,t+1);return this},Xe.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)at(this,t,t+3),at(this,t+1,t+2);return this},Xe.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)at(this,t,t+7),at(this,t+1,t+6),at(this,t+2,t+5),at(this,t+3,t+4);return this},Xe.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?yt(this,0,e):st.apply(this,arguments)},Xe.prototype.equals=function(e){if(!it(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Xe.compare(this,e)},Xe.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Xe.prototype.compare=function(e,t,n,r,i){if(!it(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},Xe.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Xe.prototype.indexOf=function(e,t,n){return ct(this,e,t,n,!0)},Xe.prototype.lastIndexOf=function(e,t,n){return ct(this,e,t,n,!1)},Xe.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return dt(this,e,t,n);case"utf8":case"utf-8":return ut(this,e,t,n);case"ascii":return ht(this,e,t,n);case"latin1":case"binary":return ft(this,e,t,n);case"base64":return pt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gt(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},Xe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var vt=4096;function bt(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function wt(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function Et(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=Tt(e[o]);return i}function Ct(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function _t(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function St(e,t,n,r,i,o){if(!it(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function kt(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function xt(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function At(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Mt(e,t,n,r,i){return i||At(e,0,n,4),Ve(e,t,n,r,23,4),n+4}function Lt(e,t,n,r,i){return i||At(e,0,n,8),Ve(e,t,n,r,52,8),n+8}Xe.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Xe.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Xe.prototype;else{var i=t-e;n=new Xe(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},Xe.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},Xe.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},Xe.prototype.readUInt8=function(e,t){return t||_t(e,1,this.length),this[e]},Xe.prototype.readUInt16LE=function(e,t){return t||_t(e,2,this.length),this[e]|this[e+1]<<8},Xe.prototype.readUInt16BE=function(e,t){return t||_t(e,2,this.length),this[e]<<8|this[e+1]},Xe.prototype.readUInt32LE=function(e,t){return t||_t(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Xe.prototype.readUInt32BE=function(e,t){return t||_t(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Xe.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},Xe.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||_t(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Xe.prototype.readInt8=function(e,t){return t||_t(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Xe.prototype.readInt16LE=function(e,t){t||_t(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Xe.prototype.readInt16BE=function(e,t){t||_t(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Xe.prototype.readInt32LE=function(e,t){return t||_t(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Xe.prototype.readInt32BE=function(e,t){return t||_t(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Xe.prototype.readFloatLE=function(e,t){return t||_t(e,4,this.length),qe(this,e,!0,23,4)},Xe.prototype.readFloatBE=function(e,t){return t||_t(e,4,this.length),qe(this,e,!1,23,4)},Xe.prototype.readDoubleLE=function(e,t){return t||_t(e,8,this.length),qe(this,e,!0,52,8)},Xe.prototype.readDoubleBE=function(e,t){return t||_t(e,8,this.length),qe(this,e,!1,52,8)},Xe.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||St(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},Xe.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||St(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},Xe.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,1,255,0),Xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Xe.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,65535,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):kt(this,e,t,!0),t+2},Xe.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,65535,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):kt(this,e,t,!1),t+2},Xe.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,4294967295,0),Xe.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):xt(this,e,t,!0),t+4},Xe.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,4294967295,0),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):xt(this,e,t,!1),t+4},Xe.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);St(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},Xe.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);St(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},Xe.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,1,127,-128),Xe.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Xe.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,32767,-32768),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):kt(this,e,t,!0),t+2},Xe.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,2,32767,-32768),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):kt(this,e,t,!1),t+2},Xe.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,2147483647,-2147483648),Xe.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):xt(this,e,t,!0),t+4},Xe.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||St(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Xe.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):xt(this,e,t,!1),t+4},Xe.prototype.writeFloatLE=function(e,t,n){return Mt(this,e,t,!0,n)},Xe.prototype.writeFloatBE=function(e,t,n){return Mt(this,e,t,!1,n)},Xe.prototype.writeDoubleLE=function(e,t,n){return Lt(this,e,t,!0,n)},Xe.prototype.writeDoubleBE=function(e,t,n){return Lt(this,e,t,!1,n)},Xe.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!Xe.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},Xe.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Xe.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=it(e)?e:Rt(new Xe(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var Ot=/[^+\/0-9A-Za-z-_]/g;function Tt(e){return e<16?"0"+e.toString(16):e.toString(16)}function Rt(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Pt(e){return function(e){var t,n,r,i,o,s;Ue||Fe();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Ke(3*a/4-o),r=o>0?a-4:a;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=je[e.charCodeAt(t)]<<18|je[e.charCodeAt(t+1)]<<12|je[e.charCodeAt(t+2)]<<6|je[e.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=je[e.charCodeAt(t)]<<2|je[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=je[e.charCodeAt(t)]<<10|je[e.charCodeAt(t+1)]<<4|je[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ot,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function It(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Nt(e){return null!=e&&(!!e._isBuffer||Bt(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Bt(e.slice(0,0))}(e))}function Bt(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var Dt=Object.freeze({__proto__:null,Buffer:Xe,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),Xe.alloc(+e)},isBuffer:Nt,kMaxLength:Ye}),$t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function jt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Kt(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Ut={},Ft={},Ht={};function zt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function qt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Vt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Wt(e,...t){if(!Vt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Gt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");zt(e.outputLen),zt(e.blockLen)}function Yt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Zt(e,t){Wt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.isBytes=Vt,Ht.number=zt,Ht.bool=qt,Ht.bytes=Wt,Ht.hash=Gt,Ht.exists=Yt,Ht.output=Zt;const Jt={number:zt,bool:qt,bytes:Wt,hash:Gt,exists:Yt,output:Zt};Ht.default=Jt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=e.createView=e.u32=e.u16=e.u8=void 0,e.bytesToHex=r,e.hexToBytes=s,e.hexToNumber=a,e.bytesToNumberBE=function(e){return a(r(e))},e.numberToBytesBE=function(e,t){return s(e.toString(16).padStart(2*t,"0"))},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=c,e.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},e.toBytes=function(e){if("string"==typeof e)e=c(e);else{if(!(0,t.isBytes)(e))throw new Error("Uint8Array expected, got "+typeof e);e=d(e)}return e},e.concatBytes=function(...e){let n=0;for(let r=0;r<e.length;r++){const i=e[r];(0,t.bytes)(i),n+=i.length}const r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},e.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},e.setBigUint64=l,e.u64Lengths=function(t,n){const r=new Uint8Array(16),i=(0,e.createView)(r);return l(i,0,BigInt(n?n.length:0),!0),l(i,8,BigInt(t.length),!0),r},e.isAligned32=function(e){return e.byteOffset%4==0},e.copyBytes=d,e.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)};const t=Ht;if(e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u16=e=>new Uint16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2)),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function r(e){(0,t.bytes)(e);let r="";for(let t=0;t<e.length;t++)r+=n[e[t]];return r}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function a(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function c(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function l(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}function d(e){return Uint8Array.from(e)}e.nextTick=async()=>{},e.Hash=class{},e.wrapCipher=(e,t)=>(Object.assign(t,e),t)}(Ft);var Xt={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.AEAD_TAG_LENGTH=Qt.XCHACHA20_NONCE_LENGTH=Qt.CURVE25519_PUBLIC_KEY_SIZE=Qt.ETH_PUBLIC_KEY_SIZE=Qt.UNCOMPRESSED_PUBLIC_KEY_SIZE=Qt.COMPRESSED_PUBLIC_KEY_SIZE=Qt.SECRET_KEY_LENGTH=void 0,Qt.SECRET_KEY_LENGTH=32,Qt.COMPRESSED_PUBLIC_KEY_SIZE=33,Qt.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,Qt.ETH_PUBLIC_KEY_SIZE=64,Qt.CURVE25519_PUBLIC_KEY_SIZE=32,Qt.XCHACHA20_NONCE_LENGTH=24,Qt.AEAD_TAG_LENGTH=16,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=Qt;e.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},e.ellipticCurve=function(){return e.ECIES_CONFIG.ellipticCurve},e.isEphemeralKeyCompressed=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed},e.isHkdfKeyCompressed=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed},e.symmetricAlgorithm=function(){return e.ECIES_CONFIG.symmetricAlgorithm},e.symmetricNonceLength=function(){return e.ECIES_CONFIG.symmetricNonceLength},e.ephemeralKeySize=function(){var n={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in n)return n[e.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}}(Xt);var en={},tn={},nn={},rn={},on={},sn={};Object.defineProperty(sn,"__esModule",{value:!0}),sn.crypto=void 0,sn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=i,e.getWebcryptoSubtle=o,e.managedNonce=function(e){return(0,n.number)(e.nonceLength),(t,...n)=>({encrypt(o,...s){const{nonceLength:a}=e,c=i(a),l=e(t,c,...n).encrypt(o,...s),d=(0,r.concatBytes)(c,l);return l.fill(0),d},decrypt(r,...i){const{nonceLength:o}=e,s=r.subarray(0,o),a=r.subarray(o);return e(t,s,...n).decrypt(a,...i)}})};const t=sn,n=Ht,r=Ft;function i(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function o(){if(t.crypto&&"object"==typeof t.crypto.subtle&&null!=t.crypto.subtle)return t.crypto.subtle;throw new Error("crypto.subtle must be defined")}e.utils={async encrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["encrypt"]),a=await i.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["decrypt"]),a=await i.decrypt(n,s,r);return new Uint8Array(a)}};const s={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(t){return(r,i,o)=>{(0,n.bytes)(r),(0,n.bytes)(i);const a={name:t,length:8*r.length},c=function(e,t,n){if(e===s.CBC)return{name:s.CBC,iv:t};if(e===s.CTR)return{name:s.CTR,counter:t,length:64};if(e===s.GCM)return n?{name:s.GCM,iv:t,additionalData:n}:{name:s.GCM,iv:t};throw new Error("unknown aes block mode")}(t,i,o);return{encrypt:t=>((0,n.bytes)(t),e.utils.encrypt(r,a,c,t)),decrypt:t=>((0,n.bytes)(t),e.utils.decrypt(r,a,c,t))}}}e.cbc=a(s.CBC),e.ctr=a(s.CTR),e.gcm=a(s.GCM)}(on);var an={},cn={},ln={},dn={};function un(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function hn(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function fn(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function pn(e,...t){if(!fn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function gn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");un(e.outputLen),un(e.blockLen)}function mn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function yn(e,t){pn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(dn,"__esModule",{value:!0}),dn.isBytes=fn,dn.number=un,dn.bool=hn,dn.bytes=pn,dn.hash=gn,dn.exists=mn,dn.output=yn;const vn={number:un,bool:hn,bytes:pn,hash:gn,exists:mn,output:yn};dn.default=vn;var bn={},wn={};Object.defineProperty(wn,"__esModule",{value:!0}),wn.crypto=void 0,wn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},e.byteSwap32=function(t){for(let n=0;n<t.length;n++)t[n]=(0,e.byteSwap)(t[n])},e.bytesToHex=function(e){(0,n.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=r[e[n]];return t},e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=s,e.toBytes=a,e.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];(0,n.bytes)(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==c.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(a(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=wn,n=dn;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.rotr=(e,t)=>e<<32-t|e>>>t,e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t);const r=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){return"string"==typeof e&&(e=s(e)),(0,n.bytes)(e),e}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(bn),Object.defineProperty(ln,"__esModule",{value:!0}),ln.HashMD=ln.Maj=ln.Chi=void 0;const En=dn,Cn=bn;ln.Chi=(e,t,n)=>e&t^~e&n,ln.Maj=(e,t,n)=>e&t^e&n^t&n,ln.HashMD=class extends Cn.Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Cn.createView)(this.buffer)}update(e){(0,En.exists)(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=(0,Cn.toBytes)(e)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=(0,Cn.createView)(e);for(;r<=i-o;o+=r)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,En.exists)(this),(0,En.output)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=(0,Cn.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}};var _n={};Object.defineProperty(_n,"__esModule",{value:!0}),_n.add5L=_n.add5H=_n.add4H=_n.add4L=_n.add3H=_n.add3L=_n.rotlBL=_n.rotlBH=_n.rotlSL=_n.rotlSH=_n.rotr32L=_n.rotr32H=_n.rotrBL=_n.rotrBH=_n.rotrSL=_n.rotrSH=_n.shrSL=_n.shrSH=_n.toBig=void 0,_n.fromBig=xn,_n.split=An,_n.add=Un;const Sn=BigInt(2**32-1),kn=BigInt(32);function xn(e,t=!1){return t?{h:Number(e&Sn),l:Number(e>>kn&Sn)}:{h:0|Number(e>>kn&Sn),l:0|Number(e&Sn)}}function An(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=xn(e[i],t);[n[i],r[i]]=[o,s]}return[n,r]}const Mn=(e,t)=>BigInt(e>>>0)<<kn|BigInt(t>>>0);_n.toBig=Mn;const Ln=(e,t,n)=>e>>>n;_n.shrSH=Ln;const On=(e,t,n)=>e<<32-n|t>>>n;_n.shrSL=On;const Tn=(e,t,n)=>e>>>n|t<<32-n;_n.rotrSH=Tn;const Rn=(e,t,n)=>e<<32-n|t>>>n;_n.rotrSL=Rn;const Pn=(e,t,n)=>e<<64-n|t>>>n-32;_n.rotrBH=Pn;const In=(e,t,n)=>e>>>n-32|t<<64-n;_n.rotrBL=In;const Nn=(e,t)=>t;_n.rotr32H=Nn;const Bn=(e,t)=>e;_n.rotr32L=Bn;const Dn=(e,t,n)=>e<<n|t>>>32-n;_n.rotlSH=Dn;const $n=(e,t,n)=>t<<n|e>>>32-n;_n.rotlSL=$n;const jn=(e,t,n)=>t<<n-32|e>>>64-n;_n.rotlBH=jn;const Kn=(e,t,n)=>e<<n-32|t>>>64-n;function Un(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}_n.rotlBL=Kn;const Fn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);_n.add3L=Fn;const Hn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;_n.add3H=Hn;const zn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);_n.add4L=zn;const qn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;_n.add4H=qn;const Vn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);_n.add5L=Vn;const Wn=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;_n.add5H=Wn;const Gn={fromBig:xn,split:An,toBig:Mn,shrSH:Ln,shrSL:On,rotrSH:Tn,rotrSL:Rn,rotrBH:Pn,rotrBL:In,rotr32H:Nn,rotr32L:Bn,rotlSH:Dn,rotlSL:$n,rotlBH:jn,rotlBL:Kn,add:Un,add3L:Fn,add3H:Hn,add4L:zn,add4H:qn,add5H:Wn,add5L:Vn};_n.default=Gn,Object.defineProperty(cn,"__esModule",{value:!0}),cn.sha384=cn.sha512_256=cn.sha512_224=cn.sha512=cn.SHA384=cn.SHA512_256=cn.SHA512_224=cn.SHA512=void 0;const Yn=ln,Zn=_n,Jn=bn,[Xn,Qn]=Zn.default.split(["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","0xf40e35855771202a","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)))),er=new Uint32Array(80),tr=new Uint32Array(80);class nr extends Yn.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:d,Fl:u,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g]}set(e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|d,this.Fl=0|u,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)er[n]=e.getUint32(t),tr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|er[e-15],n=0|tr[e-15],r=Zn.default.rotrSH(t,n,1)^Zn.default.rotrSH(t,n,8)^Zn.default.shrSH(t,n,7),i=Zn.default.rotrSL(t,n,1)^Zn.default.rotrSL(t,n,8)^Zn.default.shrSL(t,n,7),o=0|er[e-2],s=0|tr[e-2],a=Zn.default.rotrSH(o,s,19)^Zn.default.rotrBH(o,s,61)^Zn.default.shrSH(o,s,6),c=Zn.default.rotrSL(o,s,19)^Zn.default.rotrBL(o,s,61)^Zn.default.shrSL(o,s,6),l=Zn.default.add4L(i,c,tr[e-7],tr[e-16]),d=Zn.default.add4H(l,r,a,er[e-7],er[e-16]);er[e]=0|d,tr[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:d,El:u,Fh:h,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){const t=Zn.default.rotrSH(d,u,14)^Zn.default.rotrSH(d,u,18)^Zn.default.rotrBH(d,u,41),v=Zn.default.rotrSL(d,u,14)^Zn.default.rotrSL(d,u,18)^Zn.default.rotrBL(d,u,41),b=d&h^~d&p,w=u&f^~u&g,E=Zn.default.add5L(y,v,w,Qn[e],tr[e]),C=Zn.default.add5H(E,m,t,b,Xn[e],er[e]),_=0|E,S=Zn.default.rotrSH(n,r,28)^Zn.default.rotrBH(n,r,34)^Zn.default.rotrBH(n,r,39),k=Zn.default.rotrSL(n,r,28)^Zn.default.rotrBL(n,r,34)^Zn.default.rotrBL(n,r,39),x=n&i^n&s^i&s,A=r&o^r&a^o&a;m=0|p,y=0|g,p=0|h,g=0|f,h=0|d,f=0|u,({h:d,l:u}=Zn.default.add(0|c,0|l,0|C,0|_)),c=0|s,l=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const M=Zn.default.add3L(_,k,A);n=Zn.default.add3H(M,C,S,x),r=0|M}({h:n,l:r}=Zn.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Zn.default.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Zn.default.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:l}=Zn.default.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:d,l:u}=Zn.default.add(0|this.Eh,0|this.El,0|d,0|u)),({h:h,l:f}=Zn.default.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=Zn.default.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Zn.default.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,o,s,a,c,l,d,u,h,f,p,g,m,y)}roundClean(){er.fill(0),tr.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)}}cn.SHA512=nr;class rr extends nr{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}cn.SHA512_224=rr;class ir extends nr{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}cn.SHA512_256=ir;class or extends nr{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}cn.SHA384=or,cn.sha512=(0,Jn.wrapConstructor)((()=>new nr)),cn.sha512_224=(0,Jn.wrapConstructor)((()=>new rr)),cn.sha512_256=(0,Jn.wrapConstructor)((()=>new ir)),cn.sha384=(0,Jn.wrapConstructor)((()=>new or));var sr={},ar={},cr={},lr={};Object.defineProperty(lr,"__esModule",{value:!0}),lr.notImplemented=lr.bitMask=void 0,lr.isBytes=fr,lr.abytes=pr,lr.abool=function(e,t){if("boolean"!=typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)},lr.bytesToHex=mr,lr.numberToHexUnpadded=yr,lr.hexToNumber=vr,lr.hexToBytes=Er,lr.bytesToNumberBE=function(e){return vr(mr(e))},lr.bytesToNumberLE=function(e){return pr(e),vr(mr(Uint8Array.from(e).reverse()))},lr.numberToBytesBE=Cr,lr.numberToBytesLE=function(e,t){return Cr(e,t).reverse()},lr.numberToVarBytesBE=function(e){return Er(yr(e))},lr.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=Er(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!fr(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},lr.concatBytes=_r,lr.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},lr.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},lr.inRange=kr,lr.aInRange=function(e,t,n,r){if(!kr(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)},lr.bitLen=function(e){let t;for(t=0;e>dr;e>>=ur,t+=1);return t},lr.bitGet=function(e,t){return e>>BigInt(t)&ur},lr.bitSet=function(e,t,n){return e|(n?ur:dr)<<BigInt(t)},lr.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=xr(e),i=xr(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=xr())=>{i=a(Ar([0]),e),r=a(),0!==e.length&&(i=a(Ar([1]),e),r=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return _r(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}},lr.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=Mr[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},lr.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}};const dr=BigInt(0),ur=BigInt(1),hr=BigInt(2);function fr(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function pr(e){if(!fr(e))throw new Error("Uint8Array expected")}const gr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function mr(e){pr(e);let t="";for(let n=0;n<e.length;n++)t+=gr[e[n]];return t}function yr(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function vr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const br={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function wr(e){return e>=br._0&&e<=br._9?e-br._0:e>=br._A&&e<=br._F?e-(br._A-10):e>=br._a&&e<=br._f?e-(br._a-10):void 0}function Er(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=wr(e.charCodeAt(i)),o=wr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Cr(e,t){return Er(e.toString(16).padStart(2*t,"0"))}function _r(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];pr(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}const Sr=e=>"bigint"==typeof e&&dr<=e;function kr(e,t,n){return Sr(e)&&Sr(t)&&Sr(n)&&t<=e&&e<n}lr.bitMask=e=>(hr<<BigInt(e-1))-ur;const xr=e=>new Uint8Array(e),Ar=e=>Uint8Array.from(e),Mr={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||fr(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)};lr.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(cr,"__esModule",{value:!0}),cr.isNegativeLE=void 0,cr.mod=Dr,cr.pow=$r,cr.pow2=function(e,t,n){let r=e;for(;t-- >Or;)r*=r,r%=n;return r},cr.invert=jr,cr.tonelliShanks=Kr,cr.FpSqrt=Ur,cr.validateField=function(e){const t=Fr.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,Lr.validateObject)(e,t)},cr.FpPow=Hr,cr.FpInvertBatch=zr,cr.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?jr(n,e.ORDER):e.inv(n))},cr.FpLegendre=qr,cr.FpIsSquare=function(e){const t=qr(e.ORDER);return n=>{const r=t(e,n);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},cr.nLength=Vr,cr.Field=function(e,t,n=!1,r={}){if(e<=Or)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Vr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ur(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,Lr.bitMask)(i),ZERO:Or,ONE:Tr,create:t=>Dr(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Or<=t&&t<e},is0:e=>e===Or,isOdd:e=>(e&Tr)===Tr,neg:t=>Dr(-t,e),eql:(e,t)=>e===t,sqr:t=>Dr(t*t,e),add:(t,n)=>Dr(t+n,e),sub:(t,n)=>Dr(t-n,e),mul:(t,n)=>Dr(t*n,e),pow:(e,t)=>Hr(a,e,t),div:(t,n)=>Dr(t*jr(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>jr(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>zr(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,Lr.numberToBytesLE)(e,o):(0,Lr.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?(0,Lr.bytesToNumberLE)(e):(0,Lr.bytesToNumberBE)(e)}});return Object.freeze(a)},cr.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},cr.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},cr.hashToPrivateScalar=function(e,t,n=!1){const r=(e=(0,Lr.ensureBytes)("privateHash",e)).length,i=Vr(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return Dr(n?(0,Lr.bytesToNumberLE)(e):(0,Lr.bytesToNumberBE)(e),t-Tr)+Tr},cr.getFieldBytesLength=Wr,cr.getMinHashLength=Gr,cr.mapHashToField=function(e,t,n=!1){const r=e.length,i=Wr(t),o=Gr(t);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=Dr(n?(0,Lr.bytesToNumberBE)(e):(0,Lr.bytesToNumberLE)(e),t-Tr)+Tr;return n?(0,Lr.numberToBytesLE)(s,i):(0,Lr.numberToBytesBE)(s,i)};const Lr=lr,Or=BigInt(0),Tr=BigInt(1),Rr=BigInt(2),Pr=BigInt(3),Ir=BigInt(4),Nr=BigInt(5),Br=BigInt(8);function Dr(e,t){const n=e%t;return n>=Or?n:t+n}function $r(e,t,n){if(n<=Or||t<Or)throw new Error("Expected power/modulo > 0");if(n===Tr)return Or;let r=Tr;for(;t>Or;)t&Tr&&(r=r*e%n),e=e*e%n,t>>=Tr;return r}function jr(e,t){if(e===Or||t<=Or)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Dr(e,t),r=t,i=Or,o=Tr;for(;n!==Or;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Tr)throw new Error("invert: does not exist");return Dr(i,t)}function Kr(e){const t=(e-Tr)/Rr;let n,r,i;for(n=e-Tr,r=0;n%Rr===Or;n/=Rr,r++);for(i=Rr;i<e&&$r(i,t,e)!==e-Tr;i++);if(1===r){const t=(e+Tr)/Ir;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const o=(n+Tr)/Rr;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(s,o),d=e.pow(s,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Tr<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),a=t}return l}}function Ur(e){if(e%Ir===Pr){const t=(e+Tr)/Ir;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%Br===Nr){const t=(e-Nr)/Br;return function(e,n){const r=e.mul(n,Rr),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Rr),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return Kr(e)}BigInt(9),BigInt(16),cr.isNegativeLE=(e,t)=>(Dr(e,t)&Tr)===Tr;const Fr=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hr(e,t,n){if(n<Or)throw new Error("Expected power > 0");if(n===Or)return e.ONE;if(n===Tr)return t;let r=e.ONE,i=t;for(;n>Or;)n&Tr&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Tr;return r}function zr(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function qr(e){const t=(e-Tr)/Rr;return(e,n)=>e.pow(n,t)}function Vr(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Wr(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Gr(e){const t=Wr(e);return t+Math.ceil(t/2)}Object.defineProperty(ar,"__esModule",{value:!0}),ar.wNAF=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>{if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error(`Wrong window size=${e}, should be [1..${t}]`)},i=e=>(r(e),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>Jr;)n&Xr&&(r=r.add(i)),i=i.double(),n>>=Xr;return r},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,r,o){const{windows:s,windowSize:a}=i(t);let c=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),u=2**t,h=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let i=Number(o&d);o>>=h,i>a&&(i-=u,o+=Xr);const s=t,f=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?l=l.add(n(p,r[s])):c=c.add(n(g,r[f]))}return{p:c,f:l}},wNAFCached(e,t,n){const r=ei.get(e)||1;let i=Qr.get(e);return i||(i=this.precomputeWindow(e,r),1!==r&&Qr.set(e,n(i))),this.wNAF(r,i,t)},setWindowSize(e,t){r(t),ei.set(e,t),Qr.delete(e)}}},ar.pippenger=function(e,t,n,r){if(!Array.isArray(n)||!Array.isArray(r)||r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");r.forEach(((e,n)=>{if(!t.isValid(e))throw new Error(`wrong scalar at index ${n}`)})),n.forEach(((t,n)=>{if(!(t instanceof e))throw new Error(`wrong point at index ${n}`)}));const i=(0,Zr.bitLen)(BigInt(n.length)),o=i>12?i-3:i>4?i-2:i?2:1,s=(1<<o)-1,a=new Array(s+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/o)*o;let l=e.ZERO;for(let t=c;t>=0;t-=o){a.fill(e.ZERO);for(let e=0;e<r.length;e++){const i=r[e],o=Number(i>>BigInt(t)&BigInt(s));a[o]=a[o].add(n[e])}let i=e.ZERO;for(let t=a.length-1,n=e.ZERO;t>0;t--)n=n.add(a[t]),i=i.add(n);if(l=l.add(i),0!==t)for(let e=0;e<o;e++)l=l.double()}return l},ar.validateBasic=function(e){return(0,Yr.validateField)(e.Fp),(0,Zr.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Yr.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};const Yr=cr,Zr=lr,Jr=BigInt(0),Xr=BigInt(1),Qr=new WeakMap,ei=new WeakMap;Object.defineProperty(sr,"__esModule",{value:!0}),sr.twistedEdwards=function(e){const t=function(e){const t=(0,ti.validateBasic)(e);return ri.validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,l=ai<<BigInt(8*a)-si,d=n.create,u=(0,ni.Field)(t.n,t.nBitLength),h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(e){return{isValid:!1,value:oi}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if((0,ii.abool)("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){ri.aInRange("coordinate "+e,t,oi,l)}function m(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const y=(0,ii.memoized)(((e,t)=>{const{ex:r,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?ci:n.inv(o));const a=d(r*t),c=d(i*t),l=d(o*t);if(s)return{x:oi,y:si};if(l!==si)throw new Error("invZ was invalid");return{x:a,y:c}})),v=(0,ii.memoized)((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=d(i*i),l=d(o*o),u=d(s*s),h=d(u*u),f=d(c*n);if(d(u*d(f+l))!==d(h+d(r*d(c*l))))throw new Error("bad point: equation left != right (1)");if(d(i*o)!==d(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{constructor(e,t,n,r){this.ex=e,this.ey=t,this.ez=n,this.et=r,g("x",e),g("y",t),g("z",n),g("t",r),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof b)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new b(t,n,si,d(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(b.fromAffine)}static msm(e,t){return(0,ti.pippenger)(b,u,e,t)}_setWindowSize(e){C.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){m(e);const{ex:t,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=e,a=d(t*s),c=d(i*r),l=d(n*s),u=d(o*r);return a===c&&l===u}is0(){return this.equals(b.ZERO)}negate(){return new b(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:i}=this,o=d(n*n),s=d(r*r),a=d(ai*d(i*i)),c=d(e*o),l=n+r,u=d(d(l*l)-o-s),h=c+s,f=h-a,p=c-s,g=d(u*f),m=d(h*p),y=d(u*p),v=d(f*h);return new b(g,m,v,y)}add(e){m(e);const{a:n,d:r}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:l,ez:u,et:h}=e;if(n===BigInt(-1)){const e=d((o-i)*(l+c)),t=d((o+i)*(l-c)),n=d(t-e);if(n===oi)return this.double();const r=d(s*ai*h),f=d(a*ai*u),p=f+r,g=t+e,m=f-r,y=d(p*n),v=d(g*m),w=d(p*m),E=d(n*g);return new b(y,v,E,w)}const f=d(i*c),p=d(o*l),g=d(a*r*h),y=d(s*u),v=d((i+o)*(c+l)-f-p),w=y-g,E=y+g,C=d(p-n*f),_=d(v*w),S=d(E*C),k=d(v*C),x=d(w*E);return new b(_,S,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return C.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;ri.aInRange("scalar",t,si,r);const{p:n,f:i}=this.wNAF(t);return b.normalizeZ([n,i])[0]}multiplyUnsafe(e){const t=e;return ri.aInRange("scalar",t,oi,r),t===oi?E:this.equals(E)||t===si?this:this.equals(w)?this.wNAF(t).p:C.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return C.unsafeLadder(this,r).is0()}toAffine(e){return y(this,e)}clearCofactor(){const{h:e}=t;return e===si?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:i,a:o}=t,s=n.BYTES;e=(0,ii.ensureBytes)("pointHex",e,s),(0,ii.abool)("zip215",r);const a=e.slice(),c=e[s-1];a[s-1]=-129&c;const u=ri.bytesToNumberLE(a),f=r?l:n.ORDER;ri.aInRange("pointHex.y",u,oi,f);const p=d(u*u),g=d(p-si),m=d(i*p-o);let{isValid:y,value:v}=h(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const w=(v&si)===si,E=0!=(128&c);if(!r&&v===oi&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==w&&(v=d(-v)),b.fromAffine({x:v,y:u})}static fromPrivateKey(e){return k(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=ri.numberToBytesLE(t,n.BYTES);return r[r.length-1]|=e&si?128:0,r}toHex(){return ri.bytesToHex(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,si,d(t.Gx*t.Gy)),b.ZERO=new b(oi,si,si,oi);const{BASE:w,ZERO:E}=b,C=(0,ti.wNAF)(b,8*a);function _(e){return(0,ni.mod)(e,r)}function S(e){return _(ri.bytesToNumberLE(e))}function k(e){const t=a;e=(0,ii.ensureBytes)("private key",e,t);const n=(0,ii.ensureBytes)("hashed private key",o(e),2*t),r=f(n.slice(0,t)),i=n.slice(t,2*t),s=S(r),c=w.multiply(s),l=c.toRawBytes();return{head:r,prefix:i,scalar:s,point:c,pointBytes:l}}function x(e=new Uint8Array,...t){const n=ri.concatBytes(...t);return S(o(p(n,(0,ii.ensureBytes)("context",e),!!i)))}const A=li;w._setWindowSize(8);const M={getExtendedPublicKey:k,randomPrivateKey:()=>s(n.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};return{CURVE:t,getPublicKey:function(e){return k(e).pointBytes},sign:function(e,t,o={}){e=(0,ii.ensureBytes)("message",e),i&&(e=i(e));const{prefix:s,scalar:c,pointBytes:l}=k(t),d=x(o.context,s,e),u=w.multiply(d).toRawBytes(),h=_(d+x(o.context,u,l,e)*c);ri.aInRange("signature.s",h,oi,r);const f=ri.concatBytes(u,ri.numberToBytesLE(h,n.BYTES));return(0,ii.ensureBytes)("result",f,2*a)},verify:function(e,t,r,o=A){const{context:s,zip215:a}=o,c=n.BYTES;e=(0,ii.ensureBytes)("signature",e,2*c),t=(0,ii.ensureBytes)("message",t),void 0!==a&&(0,ii.abool)("zip215",a),i&&(t=i(t));const l=ri.bytesToNumberLE(e.slice(c,2*c));let d,u,h;try{d=b.fromHex(r,a),u=b.fromHex(e.slice(0,c),a),h=w.multiplyUnsafe(l)}catch(e){return!1}if(!a&&d.isSmallOrder())return!1;const f=x(s,u.toRawBytes(),d.toRawBytes(),t);return u.add(d.multiplyUnsafe(f)).subtract(h).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:M}};const ti=ar,ni=cr,ri=lr,ii=lr,oi=BigInt(0),si=BigInt(1),ai=BigInt(2),ci=BigInt(8),li={zip215:!0};var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.expand_message_xmd=yi,di.expand_message_xof=vi,di.hash_to_field=bi,di.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},di.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=bi(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=bi(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error(`mapToCurve: expected array of bigints, got ${e} in array`);const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const ui=cr,hi=lr,fi=hi.bytesToNumberBE;function pi(e,t){if(mi(e),mi(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function gi(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function mi(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function yi(e,t,n,r){(0,hi.abytes)(e),(0,hi.abytes)(t),mi(n),t.length>255&&(t=r((0,hi.concatBytes)((0,hi.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=r,s=Math.ceil(n/i);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=(0,hi.concatBytes)(t,pi(t.length,1)),c=pi(0,o),l=pi(n,2),d=new Array(s),u=r((0,hi.concatBytes)(c,e,l,pi(0,1),a));d[0]=r((0,hi.concatBytes)(u,pi(1,1),a));for(let e=1;e<=s;e++){const t=[gi(u,d[e-1]),pi(e+1,1),a];d[e]=r((0,hi.concatBytes)(...t))}return(0,hi.concatBytes)(...d).slice(0,n)}function vi(e,t,n,r,i){if((0,hi.abytes)(e),(0,hi.abytes)(t),mi(n),t.length>255){const e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update((0,hi.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(e).update(pi(n,2)).update(t).update(pi(t.length,1)).digest()}function bi(e,t,n){(0,hi.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:o,hash:s,expand:a,DST:c}=n;(0,hi.abytes)(e),mi(t);const l="string"==typeof c?(0,hi.utf8ToBytes)(c):c,d=r.toString(2).length,u=Math.ceil((d+i)/8),h=t*o*u;let f;if("xmd"===a)f=yi(e,l,h,s);else if("xof"===a)f=vi(e,l,h,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');f=e}const p=new Array(t);for(let e=0;e<t;e++){const t=new Array(o);for(let n=0;n<o;n++){const i=u*(n+e*o),s=f.subarray(i,i+u);t[n]=(0,ui.mod)(fi(s),r)}p[e]=t}return p}var wi={};Object.defineProperty(wi,"__esModule",{value:!0}),wi.montgomery=function(e){const t=function(e){return(0,Ci.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:n}=t,r=e=>(0,Ei.mod)(e,n),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>(0,Ei.pow)(e,n-BigInt(2),n));function l(e,t,n){const i=r(e*(t-n));return[t=r(t-i),n=r(n+i)]}const d=(t.a-BigInt(2))/BigInt(4);function u(e){return(0,Ci.numberToBytesLE)(r(e),o)}function h(e,t){const h=function(e){const t=(0,Ci.ensureBytes)("u coordinate",e,o);return 32===s&&(t[31]&=127),(0,Ci.bytesToNumberLE)(t)}(t),f=function(e){const t=(0,Ci.ensureBytes)("scalar",e),n=t.length;if(n!==o&&n!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${n}`);return(0,Ci.bytesToNumberLE)(a(t))}(e),p=function(e,t){(0,Ci.aInRange)("u",e,_i,n),(0,Ci.aInRange)("scalar",t,_i,n);const o=t,s=e;let a,u=Si,h=_i,f=e,p=Si,g=_i;for(let e=BigInt(i-1);e>=_i;e--){const t=o>>e&Si;g^=t,a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1],g=t;const n=u+h,i=r(n*n),c=u-h,m=r(c*c),y=i-m,v=f+p,b=r((f-p)*n),w=r(v*c),E=b+w,C=b-w;f=r(E*E),p=r(s*r(C*C)),u=r(i*m),h=r(y*(i+r(d*y)))}a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1];const m=c(h);return r(u*m)}(h,f);if(p===_i)throw new Error("Invalid private or public key received");return u(p)}const f=u(t.Gu);function p(e){return h(e,f)}return{scalarMult:h,scalarMultBase:p,getSharedSecret:(e,t)=>h(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:f}};const Ei=cr,Ci=lr,_i=BigInt(0),Si=BigInt(1);!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.RistrettoPoint=e.encodeToCurve=e.hashToCurve=e.edwardsToMontgomery=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=e.ED25519_TORSION_SUBGROUP=void 0,e.edwardsToMontgomeryPub=C,e.edwardsToMontgomeryPriv=function(e){const t=w.hash(e.subarray(0,32));return w.adjustScalarBytes(t).subarray(0,32)};const t=cn,n=bn,r=sr,i=di,o=cr,s=wi,a=lr,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),d=BigInt(0),u=BigInt(1),h=BigInt(2),f=BigInt(3),p=BigInt(5),g=BigInt(8);function m(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),s=c,a=e*e%s*e%s,l=(0,o.pow2)(a,h,s)*a%s,d=(0,o.pow2)(l,u,s)*e%s,f=(0,o.pow2)(d,p,s)*d%s,g=(0,o.pow2)(f,t,s)*f%s,m=(0,o.pow2)(g,n,s)*g%s,y=(0,o.pow2)(m,r,s)*m%s,v=(0,o.pow2)(y,i,s)*y%s,b=(0,o.pow2)(v,i,s)*y%s,w=(0,o.pow2)(b,t,s)*f%s;return{pow_p_5_8:(0,o.pow2)(w,h,s)*e%s,b2:a}}function y(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const n=c,r=(0,o.mod)(t*t*t,n),i=m(e*(0,o.mod)(r*r*t,n)).pow_p_5_8;let s=(0,o.mod)(e*r*i,n);const a=(0,o.mod)(t*s*s,n),d=s,u=(0,o.mod)(s*l,n),h=a===e,f=a===(0,o.mod)(-e,n),p=a===(0,o.mod)(-e*l,n);return h&&(s=d),(f||p)&&(s=u),(0,o.isNegativeLE)(s,n)&&(s=(0,o.mod)(-s,n)),{isValid:h||f,value:s}}e.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const b=(0,o.Field)(c,void 0,!0),w={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:b,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:g,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:t.sha512,randomBytes:n.randomBytes,adjustScalarBytes:y,uvRatio:v};function E(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function C(t){const{y:n}=e.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return b.toBytes(b.create((r+n)*b.inv(r-n)))}e.ed25519=(0,r.twistedEdwards)(w),e.ed25519ctx=(0,r.twistedEdwards)({...w,domain:E}),e.ed25519ph=(0,r.twistedEdwards)(Object.assign({},w,{domain:E,prehash:t.sha512})),e.x25519=(0,s.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=c,{pow_p_5_8:n,b2:r}=m(e);return(0,o.mod)((0,o.pow2)(n,f,t)*r,t)},adjustScalarBytes:y,randomBytes:n.randomBytes}),e.edwardsToMontgomery=C;const _=(b.ORDER+f)/g,S=b.pow(h,_),k=b.sqrt(b.neg(b.ONE)),x=(0,o.FpSqrtEven)(b,b.neg(BigInt(486664)));const A=(0,i.createHasher)(e.ed25519.ExtendedPoint,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:i}=function(e){const t=(b.ORDER-p)/g,n=BigInt(486662);let r=b.sqr(e);r=b.mul(r,h);let i=b.add(r,b.ONE),o=b.neg(n),s=b.sqr(i),a=b.mul(s,i),c=b.mul(r,n);c=b.mul(c,o),c=b.add(c,s),c=b.mul(c,o);let l=b.sqr(a);s=b.sqr(l),l=b.mul(l,a),l=b.mul(l,c),s=b.mul(s,l);let d=b.pow(s,t);d=b.mul(d,l);let f=b.mul(d,k);s=b.sqr(d),s=b.mul(s,a);let m=b.eql(s,c),y=b.cmov(f,d,m),v=b.mul(o,r),w=b.mul(d,e);w=b.mul(w,S);let E=b.mul(w,k),C=b.mul(c,r);s=b.sqr(w),s=b.mul(s,a);let _=b.eql(s,C),x=b.cmov(E,w,_);s=b.sqr(y),s=b.mul(s,a);let A=b.eql(s,c),M=b.cmov(v,o,A),L=b.cmov(x,y,A),O=b.isOdd(L);return L=b.cmov(L,b.neg(L),A!==O),{xMn:M,xMd:i,yMn:L,yMd:u}}(e);let o=b.mul(t,i);o=b.mul(o,x);let s=b.mul(n,r),a=b.sub(t,n),c=b.add(t,n),l=b.mul(s,c),d=b.eql(l,b.ZERO);o=b.cmov(o,b.ZERO,d),s=b.cmov(s,b.ONE,d),a=b.cmov(a,b.ONE,d),c=b.cmov(c,b.ONE,d);const f=b.invertBatch([s,c]);return{x:b.mul(o,f[0]),y:b.mul(a,f[1])}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:t.sha512});function M(e){if(!(e instanceof $))throw new Error("RistrettoPoint expected")}e.hashToCurve=A.hashToCurve,e.encodeToCurve=A.encodeToCurve;const L=l,O=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),T=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),P=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),I=e=>v(u,e),N=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),B=t=>e.ed25519.CURVE.Fp.create((0,a.bytesToNumberLE)(t)&N);function D(t){const{d:n}=e.ed25519.CURVE,r=e.ed25519.CURVE.Fp.ORDER,i=e.ed25519.CURVE.Fp.create,s=i(L*t*t),a=i((s+u)*R);let c=BigInt(-1);const l=i((c-n*s)*i(s+n));let{isValid:d,value:h}=v(a,l),f=i(h*t);(0,o.isNegativeLE)(f,r)||(f=i(-f)),d||(h=f),d||(c=s);const p=i(c*(s-u)*P-l),g=h*h,m=i((h+h)*l),y=i(p*O),b=i(u-g),w=i(u+g);return new e.ed25519.ExtendedPoint(i(m*w),i(b*y),i(y*w),i(m*b))}class ${constructor(e){this.ep=e}static fromAffine(t){return new $(e.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(e){e=(0,a.ensureBytes)("ristrettoHash",e,64);const t=D(B(e.slice(0,32))),n=D(B(e.slice(32,64)));return new $(t.add(n))}static fromHex(t){t=(0,a.ensureBytes)("ristrettoHex",t,32);const{a:n,d:r}=e.ed25519.CURVE,i=e.ed25519.CURVE.Fp.ORDER,s=e.ed25519.CURVE.Fp.create,c="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",l=B(t);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(l,32),t)||(0,o.isNegativeLE)(l,i))throw new Error(c);const h=s(l*l),f=s(u+n*h),p=s(u-n*h),g=s(f*f),m=s(p*p),y=s(n*r*g-m),{isValid:v,value:b}=I(s(y*m)),w=s(b*p),E=s(b*w*y);let C=s((l+l)*w);(0,o.isNegativeLE)(C,i)&&(C=s(-C));const _=s(f*E),S=s(C*_);if(!v||(0,o.isNegativeLE)(S,i)||_===d)throw new Error(c);return new $(new e.ed25519.ExtendedPoint(C,_,u,S))}toRawBytes(){let{ex:t,ey:n,ez:r,et:i}=this.ep;const s=e.ed25519.CURVE.Fp.ORDER,c=e.ed25519.CURVE.Fp.create,l=c(c(r+n)*c(r-n)),d=c(t*n),u=c(d*d),{value:h}=I(c(l*u)),f=c(h*l),p=c(h*d),g=c(f*p*i);let m;if((0,o.isNegativeLE)(i*g,s)){let e=c(n*L),r=c(t*L);t=e,n=r,m=c(f*T)}else m=p;(0,o.isNegativeLE)(t*g,s)&&(n=c(-n));let y=c((r-n)*m);return(0,o.isNegativeLE)(y,s)&&(y=c(-y)),(0,a.numberToBytesLE)(y,32)}toHex(){return(0,a.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const{ex:n,ey:r}=this.ep,{ex:i,ey:o}=t.ep,s=e.ed25519.CURVE.Fp.create,a=s(n*o)===s(r*i),c=s(r*o)===s(n*i);return a||c}add(e){return M(e),new $(this.ep.add(e.ep))}subtract(e){return M(e),new $(this.ep.subtract(e.ep))}multiply(e){return new $(this.ep.multiply(e))}multiplyUnsafe(e){return new $(this.ep.multiplyUnsafe(e))}double(){return new $(this.ep.double())}negate(){return new $(this.ep.negate())}}e.RistrettoPoint=($.BASE||($.BASE=new $(e.ed25519.ExtendedPoint.BASE)),$.ZERO||($.ZERO=new $(e.ed25519.ExtendedPoint.ZERO)),$),e.hashToRistretto255=(e,r)=>{const o=r.DST,s="string"==typeof o?(0,n.utf8ToBytes)(o):o,a=(0,i.expand_message_xmd)(e,s,64,t.sha512);return $.hashToCurve(a)},e.hash_to_ristretto255=e.hashToRistretto255}(an);var ki={},xi={};Object.defineProperty(xi,"__esModule",{value:!0}),xi.sha224=xi.sha256=xi.SHA256=void 0;const Ai=ln,Mi=bn,Li=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ti=new Uint32Array(64);class Ri extends Ai.HashMD{constructor(){super(64,32,8,!1),this.A=0|Oi[0],this.B=0|Oi[1],this.C=0|Oi[2],this.D=0|Oi[3],this.E=0|Oi[4],this.F=0|Oi[5],this.G=0|Oi[6],this.H=0|Oi[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Ti[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ti[e-15],n=Ti[e-2],r=(0,Mi.rotr)(t,7)^(0,Mi.rotr)(t,18)^t>>>3,i=(0,Mi.rotr)(n,17)^(0,Mi.rotr)(n,19)^n>>>10;Ti[e]=i+Ti[e-7]+r+Ti[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+((0,Mi.rotr)(s,6)^(0,Mi.rotr)(s,11)^(0,Mi.rotr)(s,25))+(0,Ai.Chi)(s,a,c)+Li[e]+Ti[e]|0,d=((0,Mi.rotr)(n,2)^(0,Mi.rotr)(n,13)^(0,Mi.rotr)(n,22))+(0,Ai.Maj)(n,r,i)|0;l=c,c=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,o,s,a,c,l)}roundClean(){Ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}xi.SHA256=Ri;class Pi extends Ri{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}xi.sha256=(0,Mi.wrapConstructor)((()=>new Ri)),xi.sha224=(0,Mi.wrapConstructor)((()=>new Pi));var Ii={},Ni={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=dn,n=bn;class r extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,n.toBytes)(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);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(0,t.exists)(this),this.iHash.update(e),this}digestInto(e){(0,t.exists)(this),(0,t.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=r,e.hmac=(e,t,n)=>new r(e,t).update(n).digest(),e.hmac.create=(e,t)=>new r(e,t)}(Ni);var Bi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=f,e.weierstrass=function(s){const a=function(e){const n=(0,t.validateBasic)(e);return r.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}(s),{Fp:d,n:u}=a,h=d.BYTES+1,p=2*d.BYTES+1;function g(e){return n.mod(e,u)}function m(e){return n.invert(e,u)}const{ProjectivePoint:y,normPrivateKeyToScalar:v,weierstrassEquation:b,isWithinCurveOrder:w}=f({...a,toBytes(e,t,n){const o=t.toAffine(),s=d.toBytes(o.x),a=r.concatBytes;return(0,i.abool)("isCompressed",n),n?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,d.toBytes(o.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===p&&4===n)return{x:d.fromBytes(i.subarray(0,d.BYTES)),y:d.fromBytes(i.subarray(d.BYTES,2*d.BYTES))};throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${p} uncompressed bytes`)}{const t=r.bytesToNumberBE(i);if(!r.inRange(t,l,d.ORDER))throw new Error("Point is not on curve");const o=b(t);let s;try{s=d.sqrt(o)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&n)!=((s&l)===l)&&(s=d.neg(s)),{x:t,y:s}}}}),E=e=>r.bytesToHex(r.numberToBytesBE(e,a.nByteLength));function C(e){return e>u>>l}const _=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=a.nByteLength;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new S(_(e,0,t),_(e,t,2*t))}static fromDER(t){const{r:n,s:r}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new S(n,r)}assertValidity(){r.aInRange("r",this.r,l,u),r.aInRange("s",this.s,l,u)}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:n,recovery:r}=this,o=M((0,i.ensureBytes)("msgHash",e));if(null==r||![0,1,2,3].includes(r))throw new Error("recovery id invalid");const s=2===r||3===r?t+a.n:t;if(s>=d.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&r)?"02":"03",l=y.fromHex(c+E(s)),u=m(s),h=g(-o*u),f=g(n*u),p=y.BASE.multiplyAndAddUnsafe(l,h,f);if(!p)throw new Error("point at infinify");return p.assertValidity(),p}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,g(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const k={isValidPrivateKey(e){try{return v(e),!0}catch(e){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const e=n.getMinHashLength(a.n);return n.mapHashToField(a.randomBytes(e),a.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function x(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===h||i===p:n?i===2*h||i===2*p:e instanceof y}const A=a.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-a.nBitLength;return n>0?t>>BigInt(n):t},M=a.bits2int_modN||function(e){return g(A(e))},L=r.bitMask(a.nBitLength);function O(e){return r.aInRange(`num < 2^${a.nBitLength}`,e,c,L),r.numberToBytesBE(e,a.nByteLength)}function T(e,t,n=R){if(["recovered","canonical"].some((e=>e in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=a;let{lowS:h,prehash:f,extraEntropy:p}=n;null==h&&(h=!0),e=(0,i.ensureBytes)("msgHash",e),o(n),f&&(e=(0,i.ensureBytes)("prehashed msgHash",s(e)));const b=M(e),E=v(t),_=[O(E),O(b)];if(null!=p&&!1!==p){const e=!0===p?u(d.BYTES):p;_.push((0,i.ensureBytes)("extraEntropy",e))}const k=r.concatBytes(..._),x=b;return{seed:k,k2sig:function(e){const t=A(e);if(!w(t))return;const n=m(t),r=y.BASE.multiply(t).toAffine(),i=g(r.x);if(i===c)return;const o=g(n*g(x+i*E));if(o===c)return;let s=(r.x===i?0:2)|Number(r.y&l),a=o;return h&&C(o)&&(a=function(e){return C(e)?g(-e):e}(o),s^=1),new S(i,a,s)}}}const R={lowS:a.lowS,prehash:!1},P={lowS:a.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:a,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(x(e))throw new Error("first arg must be private key");if(!x(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(v(e)).toRawBytes(n)},sign:function(e,t,n=R){const{seed:i,k2sig:o}=T(e,t,n),s=a;return r.createHmacDrbg(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,n,s,c=P){const l=t;if(n=(0,i.ensureBytes)("msgHash",n),s=(0,i.ensureBytes)("publicKey",s),"strict"in c)throw new Error("options.strict was renamed to lowS");o(c);const{lowS:d,prehash:u}=c;let h,f;try{if("string"==typeof l||r.isBytes(l))try{h=S.fromDER(l)}catch(t){if(!(t instanceof e.DER.Err))throw t;h=S.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;h=new S(e,t)}}f=y.fromHex(s)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(d&&h.hasHighS())return!1;u&&(n=a.hash(n));const{r:p,s:v}=h,b=M(n),w=m(v),E=g(b*w),C=g(p*w),_=y.BASE.multiplyAndAddUnsafe(f,E,C)?.toAffine();if(!_)return!1;return g(_.x)===p},ProjectivePoint:y,Signature:S,utils:k}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(e,t){if(n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,c,l,d,u;i=e.sqr(n),i=e.mul(i,t.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(s),l=e.sqr(a),c=e.mul(l,t.A),o=e.add(o,c),o=e.mul(o,s),l=e.mul(l,a),c=e.mul(l,t.B),o=e.add(o,c),d=e.mul(i,s);const{isValid:h,value:f}=r(o,l);u=e.mul(i,n),u=e.mul(u,f),d=e.cmov(d,s,h),u=e.cmov(u,f,h);const p=e.isOdd(n)===e.isOdd(u);return u=e.cmov(e.neg(u),u,p),d=e.div(d,a),{x:d,y:u}}};const t=ar,n=cr,r=lr,i=lr;function o(e){void 0!==e.lowS&&(0,i.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,i.abool)("prehash",e.prehash)}const{bytesToNumberBE:s,hexToBytes:a}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,n)=>{const{Err:i}=e.DER;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(1&n.length)throw new i("tlv.encode: unpadded data");const o=n.length/2,s=r.numberToHexUnpadded(o);if(s.length/2&128)throw new i("tlv.encode: long form length too big");const a=o>127?r.numberToHexUnpadded(s.length/2|128):"";return`${r.numberToHexUnpadded(t)}${a}${s}${n}`},decode(t,n){const{Err:r}=e.DER;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[i++]!==t)throw new r("tlv.decode: wrong tlv");const o=n[i++];let s=0;if(128&o){const e=127&o;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");const t=n.subarray(i,i+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)s=s<<8|e;if(i+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const a=n.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(i+s)}}},_int:{encode(t){const{Err:n}=e.DER;if(t<c)throw new n("integer: negative integers are not allowed");let i=r.numberToHexUnpadded(t);if(8&Number.parseInt(i[0],16)&&(i="00"+i),1&i.length)throw new n("unexpected assertion");return i},decode(t){const{Err:n}=e.DER;if(128&t[0])throw new n("Invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new n("Invalid signature integer: unnecessary leading zero");return s(t)}},toSig(t){const{Err:n,_int:i,_tlv:o}=e.DER,s="string"==typeof t?a(t):t;r.abytes(s);const{v:c,l:l}=o.decode(48,s);if(l.length)throw new n("Invalid signature: left bytes after parsing");const{v:d,l:u}=o.decode(2,c),{v:h,l:f}=o.decode(2,u);if(f.length)throw new n("Invalid signature: left bytes after parsing");return{r:i.decode(d),s:i.decode(h)}},hexFromSig(t){const{_tlv:n,_int:r}=e.DER,i=`${n.encode(2,r.encode(t.r))}${n.encode(2,r.encode(t.s))}`;return n.encode(48,i)}};const c=BigInt(0),l=BigInt(1),d=BigInt(2),u=BigInt(3),h=BigInt(4);function f(e){const o=function(e){const n=(0,t.validateBasic)(e);r.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:i,Fp:o,a:s}=n;if(i){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof i||"bigint"!=typeof i.beta||"function"!=typeof i.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}(e),{Fp:s}=o,a=n.Field(o.n,o.nBitLength),d=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),h=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:n}=o,r=s.sqr(e),i=s.mul(r,e);return s.add(s.add(i,s.mul(e,t)),n)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function p(e){const{allowedPrivateKeyLengths:t,nByteLength:s,wrapPrivateKey:a,n:c}=o;if(t&&"bigint"!=typeof e){if(r.isBytes(e)&&(e=r.bytesToHex(e)),"string"!=typeof e||!t.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*s,"0")}let d;try{d="bigint"==typeof e?e:r.bytesToNumberBE((0,i.ensureBytes)("private key",e,s))}catch(t){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof e}`)}return a&&(d=n.mod(d,c)),r.aInRange("private key",d,l,c),d}function g(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const m=(0,i.memoized)(((e,t)=>{const{px:n,py:r,pz:i}=e;if(s.eql(i,s.ONE))return{x:n,y:r};const o=e.is0();null==t&&(t=o?s.ONE:s.inv(i));const a=s.mul(n,t),c=s.mul(r,t),l=s.mul(i,t);if(o)return{x:s.ZERO,y:s.ZERO};if(!s.eql(l,s.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),y=(0,i.memoized)((e=>{if(e.is0()){if(o.allowInfinityPoint&&!s.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=e.toAffine();if(!s.isValid(t)||!s.isValid(n))throw new Error("bad point: x or y not FE");const r=s.sqr(n),i=f(t);if(!s.eql(r,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!s.isValid(e))throw new Error("x required");if(null==t||!s.isValid(t))throw new Error("y required");if(null==n||!s.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!s.isValid(t)||!s.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const r=e=>s.eql(e,s.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(h((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(p(e))}static msm(e,n){return(0,t.pippenger)(v,a,e,n)}_setWindowSize(e){w.setWindowSize(this,e)}assertValidity(){y(this)}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,r)),l=s.eql(s.mul(n,a),s.mul(o,r));return c&&l}negate(){return new v(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,n=s.mul(t,u),{px:r,py:i,pz:a}=this;let c=s.ZERO,l=s.ZERO,d=s.ZERO,h=s.mul(r,r),f=s.mul(i,i),p=s.mul(a,a),g=s.mul(r,i);return g=s.add(g,g),d=s.mul(r,a),d=s.add(d,d),c=s.mul(e,d),l=s.mul(n,p),l=s.add(c,l),c=s.sub(f,l),l=s.add(f,l),l=s.mul(c,l),c=s.mul(g,c),d=s.mul(n,d),p=s.mul(e,p),g=s.sub(h,p),g=s.mul(e,g),g=s.add(g,d),d=s.add(h,h),h=s.add(d,h),h=s.add(h,p),h=s.mul(h,g),l=s.add(l,h),p=s.mul(i,a),p=s.add(p,p),h=s.mul(p,g),c=s.sub(c,h),d=s.mul(p,f),d=s.add(d,d),d=s.add(d,d),new v(c,l,d)}add(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:a,pz:c}=e;let l=s.ZERO,d=s.ZERO,h=s.ZERO;const f=o.a,p=s.mul(o.b,u);let m=s.mul(t,i),y=s.mul(n,a),b=s.mul(r,c),w=s.add(t,n),E=s.add(i,a);w=s.mul(w,E),E=s.add(m,y),w=s.sub(w,E),E=s.add(t,r);let C=s.add(i,c);return E=s.mul(E,C),C=s.add(m,b),E=s.sub(E,C),C=s.add(n,r),l=s.add(a,c),C=s.mul(C,l),l=s.add(y,b),C=s.sub(C,l),h=s.mul(f,E),l=s.mul(p,b),h=s.add(l,h),l=s.sub(y,h),h=s.add(y,h),d=s.mul(l,h),y=s.add(m,m),y=s.add(y,m),b=s.mul(f,b),E=s.mul(p,E),y=s.add(y,b),b=s.sub(m,b),b=s.mul(f,b),E=s.add(E,b),m=s.mul(y,E),d=s.add(d,m),m=s.mul(C,E),l=s.mul(w,l),l=s.sub(l,m),m=s.mul(w,y),h=s.mul(C,h),h=s.add(h,m),new v(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return w.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){r.aInRange("scalar",e,c,o.n);const t=v.ZERO;if(e===c)return t;if(e===l)return this;const{endo:n}=o;if(!n)return w.unsafeLadder(this,e);let{k1neg:i,k1:a,k2neg:d,k2:u}=n.splitScalar(e),h=t,f=t,p=this;for(;a>c||u>c;)a&l&&(h=h.add(p)),u&l&&(f=f.add(p)),p=p.double(),a>>=l,u>>=l;return i&&(h=h.negate()),d&&(f=f.negate()),f=new v(s.mul(f.px,n.beta),f.py,f.pz),h.add(f)}multiply(e){const{endo:t,n:n}=o;let i,a;if(r.aInRange("scalar",e,l,n),t){const{k1neg:n,k1:r,k2neg:o,k2:c}=t.splitScalar(e);let{p:l,f:d}=this.wNAF(r),{p:u,f:h}=this.wNAF(c);l=w.constTimeNegate(n,l),u=w.constTimeNegate(o,u),u=new v(s.mul(u.px,t.beta),u.py,u.pz),i=l.add(u),a=d.add(h)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return v.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=v.BASE,i=(e,t)=>t!==c&&t!==l&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){return m(this,e)}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===l)return!0;if(t)return t(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===l?this:t?t(v,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),d(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),r.bytesToHex(this.toRawBytes(e))}}v.BASE=new v(o.Gx,o.Gy,s.ONE),v.ZERO=new v(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,w=(0,t.wNAF)(v,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:v,normPrivateKeyToScalar:p,weierstrassEquation:f,isWithinCurveOrder:function(e){return r.inRange(e,l,o.n)}}}function p(e,t){const n=e.ORDER;let r=c;for(let e=n-l;e%d===c;e/=d)r+=l;const i=r,o=d<<i-l-l,s=o*d,a=(n-l)/s,f=(a-l)/d,p=s-l,g=o,m=e.pow(t,a),y=e.pow(t,(a+l)/d);let v=(t,n)=>{let r=m,o=e.pow(n,p),s=e.sqr(o);s=e.mul(s,n);let a=e.mul(t,s);a=e.pow(a,f),a=e.mul(a,o),o=e.mul(a,n),s=e.mul(a,t);let c=e.mul(s,o);a=e.pow(c,g);let u=e.eql(a,e.ONE);o=e.mul(s,y),a=e.mul(c,r),s=e.cmov(o,s,u),c=e.cmov(a,c,u);for(let t=i;t>l;t--){let n=t-d;n=d<<n-l;let i=e.pow(c,n);const a=e.eql(i,e.ONE);o=e.mul(s,r),r=e.mul(r,r),i=e.mul(c,r),s=e.cmov(o,s,a),c=e.cmov(i,c,a)}return{isValid:u,value:s}};if(e.ORDER%h===u){const n=(e.ORDER-u)/h,r=e.sqrt(e.neg(t));v=(t,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,n);a=e.mul(a,s);const c=e.mul(a,r),l=e.mul(e.sqr(a),i),d=e.eql(l,t);return{isValid:d,value:e.cmov(c,a,d)}}}return v}}(Bi),Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.getHash=Ki,Ii.createCurve=function(e,t){const n=t=>(0,ji.weierstrass)({...e,...Ki(t)});return Object.freeze({...n(t),create:n})};const Di=Ni,$i=bn,ji=Bi;function Ki(e){return{hash:e,hmac:(t,...n)=>(0,Di.hmac)(e,t,(0,$i.concatBytes)(...n)),randomBytes:$i.randomBytes}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const t=xi,n=bn,r=Ii,i=di,o=cr,s=lr,a=Bi,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(1),u=BigInt(2),h=(e,t)=>(e+t/u)/t;function f(e){const t=c,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),l=BigInt(44),d=BigInt(88),h=e*e*e%t,f=h*h*e%t,g=(0,o.pow2)(f,n,t)*f%t,m=(0,o.pow2)(g,n,t)*f%t,y=(0,o.pow2)(m,u,t)*h%t,v=(0,o.pow2)(y,i,t)*y%t,b=(0,o.pow2)(v,s,t)*v%t,w=(0,o.pow2)(b,l,t)*b%t,E=(0,o.pow2)(w,d,t)*w%t,C=(0,o.pow2)(E,l,t)*b%t,_=(0,o.pow2)(C,n,t)*f%t,S=(0,o.pow2)(_,a,t)*v%t,k=(0,o.pow2)(S,r,t)*h%t,x=(0,o.pow2)(k,u,t);if(!p.eql(p.sqr(x),e))throw new Error("Cannot find square root");return x}const p=(0,o.Field)(c,void 0,void 0,{sqrt:f});e.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=h(s*e,t),u=h(-r*e,t);let f=(0,o.mod)(e-c*n-u*i,t),p=(0,o.mod)(-c*r-u*s,t);const g=f>a,m=p>a;if(g&&(f=t-f),m&&(p=t-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:f,k2neg:m,k2:p}}}},t.sha256);const g=BigInt(0),m={};function y(e,...n){let r=m[e];if(void 0===r){const n=(0,t.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=(0,s.concatBytes)(n,n),m[e]=r}return(0,t.sha256)((0,s.concatBytes)(r,...n))}const v=e=>e.toRawBytes(!0).slice(1),b=e=>(0,s.numberToBytesBE)(e,32),w=e=>(0,o.mod)(e,c),E=e=>(0,o.mod)(e,l),C=e.secp256k1.ProjectivePoint,_=(e,t,n)=>C.BASE.multiplyAndAddUnsafe(e,t,n);function S(t){let n=e.secp256k1.utils.normPrivateKeyToScalar(t),r=C.fromPrivateKey(n);return{scalar:r.hasEvenY()?n:E(-n),bytes:v(r)}}function k(e){(0,s.aInRange)("x",e,d,c);const t=w(e*e);let n=f(w(t*e+BigInt(7)));n%u!==g&&(n=w(-n));const r=new C(e,n,d);return r.assertValidity(),r}const x=s.bytesToNumberBE;function A(...e){return E(x(y("BIP0340/challenge",...e)))}function M(e,t,n){const r=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),o=(0,s.ensureBytes)("publicKey",n,32);try{const e=k(x(o)),t=x(r.subarray(0,32));if(!(0,s.inRange)(t,d,c))return!1;const n=x(r.subarray(32,64));if(!(0,s.inRange)(n,d,l))return!1;const a=A(b(t),v(e),i),u=_(e,n,E(-a));return!(!u||!u.hasEvenY()||u.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:function(e){return S(e).bytes},sign:function(e,t,r=(0,n.randomBytes)(32)){const i=(0,s.ensureBytes)("message",e),{bytes:o,scalar:a}=S(t),c=(0,s.ensureBytes)("auxRand",r,32),l=b(a^x(y("BIP0340/aux",c))),d=y("BIP0340/nonce",l,o,i),u=E(x(d));if(u===g)throw new Error("sign failed: k is zero");const{bytes:h,scalar:f}=S(u),p=A(h,o,i),m=new Uint8Array(64);if(m.set(h,0),m.set(b(E(f+p*a)),32),!M(m,i,o))throw new Error("sign: Invalid signature produced");return m},verify:M,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:k,pointToBytes:v,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,taggedHash:y,mod:o.mod}};const L=(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),O=(0,a.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}),T=(0,i.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:n}=O(p.create(e[0]));return L(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256});e.hashToCurve=T.hashToCurve,e.encodeToCurve=T.encodeToCurve}(ki);var Ui={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeHex=e.remove0x=void 0;var t=Ft;e.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},e.decodeHex=function(n){return(0,t.hexToBytes)((0,e.remove0x)(n))}}(Ui),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=on,n=an,r=ki,i=Xt,o=Qt,s=Ui;function a(e,t,i,o){if("secp256k1"===e)return t(r.secp256k1);if("x25519"===e)return i(n.x25519);if("ed25519"===e)return o(n.ed25519);throw new Error("Not implemented")}e.getValidSecret=function(){var n;do{n=(0,t.randomBytes)(o.SECRET_KEY_LENGTH)}while(!(0,e.isValidPrivateKey)(n));return n},e.isValidPrivateKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.utils.isValidPrivateKey(e)}),(function(){return!0}),(function(){return!0}))},e.getPublicKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},e.getSharedPoint=function(e,t,n){return a((0,i.ellipticCurve)(),(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return l(n,e,t)}))},e.convertPublicKeyFormat=function(e,t){return a((0,i.ellipticCurve)(),(function(n){return n.getSharedSecret(BigInt(1),e,t)}),(function(){return e}),(function(){return e}))},e.hexToPublicKey=function(e){var t=(0,s.decodeHex)(e);return a((0,i.ellipticCurve)(),(function(){return c(t)}),(function(){return t}),(function(){return t}))};var c=function(e){if(e.length===o.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},l=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.ExtendedPoint.fromHex(n).multiply(r).toRawBytes()}}(rn);var Fi={},Hi={};Object.defineProperty(Hi,"__esModule",{value:!0}),Hi.hkdf=void 0,Hi.extract=Wi,Hi.expand=Zi;const zi=dn,qi=bn,Vi=Ni;function Wi(e,t,n){return(0,zi.hash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,Vi.hmac)(e,(0,qi.toBytes)(n),(0,qi.toBytes)(t))}const Gi=new Uint8Array([0]),Yi=new Uint8Array;function Zi(e,t,n,r=32){if((0,zi.hash)(e),(0,zi.number)(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=Yi);const o=new Uint8Array(i*e.outputLen),s=Vi.hmac.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let t=0;t<i;t++)Gi[0]=t+1,a.update(0===t?Yi:c).update(n).update(Gi).digestInto(c),o.set(c,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Gi.fill(0),o.slice(0,r)}Hi.hkdf=(e,t,n,r,i)=>Zi(e,Wi(e,t,n),r,i),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=Ft,n=Hi,r=xi;e.deriveKey=function(e,t,i){return(0,n.hkdf)(r.sha256,e,t,i,32)},e.getSharedKey=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0,e.deriveKey)(t.concatBytes.apply(void 0,n))}}(Fi);var Ji={},Xi={},Qi={},eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.polyval=eo.ghash=void 0,eo._toGHASHKey=ao;const to=Ht,no=Ft,ro=16,io=new Uint8Array(16),oo=(0,no.u32)(io),so=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function ao(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class co{constructor(e,t){this.blockLen=ro,this.outputLen=ro,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,no.toBytes)(e),(0,to.bytes)(e,16);const n=(0,no.createView)(e);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let e=0;e<128;e++)a.push({s0:so(r),s1:so(i),s2:so(o),s3:so(s)}),({s0:r,s1:i,s2:o,s3:s}={s3:(d=o)<<31|(u=s)>>>1,s2:(l=i)<<31|d>>>1,s1:(c=r)<<31|l>>>1,s0:c>>>1^225<<24&-(1&u)});var c,l,d,u;const h=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(h))throw new Error(`ghash: wrong window size=${h}, should be 2, 4 or 8`);this.W=h;const f=128/h,p=this.windowSize=2**h,g=[];for(let e=0;e<f;e++)for(let t=0;t<p;t++){let n=0,r=0,i=0,o=0;for(let s=0;s<h;s++){if(!(t>>>h-s-1&1))continue;const{s0:c,s1:l,s2:d,s3:u}=a[h*e+s];n^=c,r^=l,i^=d,o^=u}g.push({s0:n,s1:r,s2:i,s3:o})}this.t=g}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:o,windowSize:s}=this;let a=0,c=0,l=0,d=0;const u=(1<<i)-1;let h=0;for(const f of[e,t,n,r])for(let e=0;e<4;e++){const t=f>>>8*e&255;for(let e=8/i-1;e>=0;e--){const n=t>>>i*e&u,{s0:r,s1:f,s2:p,s3:g}=o[h*s+n];a^=r,c^=f,l^=p,d^=g,h+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=d}update(e){e=(0,no.toBytes)(e),(0,to.exists)(this);const t=(0,no.u32)(e),n=Math.floor(e.length/ro),r=e.length%ro;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return r&&(io.set(e.subarray(n*ro)),this._updateBlock(oo[0],oo[1],oo[2],oo[3]),(0,no.clean)(oo)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,to.exists)(this),(0,to.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,no.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e}digest(){const e=new Uint8Array(ro);return this.digestInto(e),this.destroy(),e}}class lo extends co{constructor(e,t){e=(0,no.toBytes)(e);const n=ao((0,no.copyBytes)(e));super(n,t),(0,no.clean)(n)}update(e){e=(0,no.toBytes)(e),(0,to.exists)(this);const t=(0,no.u32)(e),n=e.length%ro,r=Math.floor(e.length/ro);for(let e=0;e<r;e++)this._updateBlock(so(t[4*e+3]),so(t[4*e+2]),so(t[4*e+1]),so(t[4*e+0]));return n&&(io.set(e.subarray(r*ro)),this._updateBlock(so(oo[3]),so(oo[2]),so(oo[1]),so(oo[0])),(0,no.clean)(oo)),this}digestInto(e){(0,to.exists)(this),(0,to.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,no.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e.reverse()}}function uo(e){const t=(t,n)=>e(n,t.length).update((0,no.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}eo.ghash=uo(((e,t)=>new co(e,t))),eo.polyval=uo(((e,t)=>new lo(e,t))),Object.defineProperty(Qi,"__esModule",{value:!0}),Qi.unsafe=Qi.aeskwp=Qi.aeskw=Qi.siv=Qi.gcm=Qi.cfb=Qi.cbc=Qi.ecb=Qi.ctr=void 0,Qi.expandKeyLE=Lo,Qi.expandKeyDecLE=Oo;const ho=Ht,fo=eo,po=Ft,go=16,mo=new Uint8Array(go),yo=283;function vo(e){return e<<1^yo&-(e>>7)}function bo(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=vo(e);return n}const wo=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=vo(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,po.clean)(e),t})(),Eo=wo.map(((e,t)=>wo.indexOf(t))),Co=e=>e<<24|e>>>8,_o=e=>e<<8|e>>>24,So=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function ko(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(_o),i=r.map(_o),o=i.map(_o),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const d=256*t+l;s[d]=n[t]^r[l],a[d]=i[t]^o[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const xo=ko(wo,(e=>bo(e,3)<<24|e<<16|e<<8|bo(e,2))),Ao=ko(Eo,(e=>bo(e,11)<<24|bo(e,13)<<16|bo(e,9)<<8|bo(e,14))),Mo=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=vo(n))e[t]=n;return e})();function Lo(e){(0,ho.bytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=xo,r=[];(0,po.isAligned32)(e)||r.push(e=(0,po.copyBytes)(e));const i=(0,po.u32)(e),o=i.length,s=e=>Ro(n,e,e,e,e),a=new Uint32Array(t+28);a.set(i);for(let e=o;e<a.length;e++){let t=a[e-1];e%o==0?t=s(Co(t))^Mo[e/o-1]:o>6&&e%o==4&&(t=s(t)),a[e]=a[e-o]^t}return(0,po.clean)(...r),a}function Oo(e){const t=Lo(e),n=t.slice(),r=t.length,{sbox2:i}=xo,{T0:o,T1:s,T2:a,T3:c}=Ao;for(let e=0;e<r;e+=4)for(let i=0;i<4;i++)n[e+i]=t[r-e-4+i];(0,po.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=Ro(i,t,t,t,t);n[e]=o[255&r]^s[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function To(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Ro(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function Po(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=xo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^To(s,a,t,n,r,i),l=e[c++]^To(s,a,n,r,i,t),d=e[c++]^To(s,a,r,i,t,n),u=e[c++]^To(s,a,i,t,n,r);t=o,n=l,r=d,i=u}return{s0:e[c++]^Ro(o,t,n,r,i),s1:e[c++]^Ro(o,n,r,i,t),s2:e[c++]^Ro(o,r,i,t,n),s3:e[c++]^Ro(o,i,t,n,r)}}function Io(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Ao;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^To(s,a,t,i,r,n),l=e[c++]^To(s,a,n,t,i,r),d=e[c++]^To(s,a,r,n,t,i),u=e[c++]^To(s,a,i,r,n,t);t=o,n=l,r=d,i=u}return{s0:e[c++]^Ro(o,t,i,r,n),s1:e[c++]^Ro(o,n,t,i,r),s2:e[c++]^Ro(o,r,n,t,i),s3:e[c++]^Ro(o,i,r,n,t)}}function No(e,t){if(void 0===t)return new Uint8Array(e);if((0,ho.bytes)(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);if(!(0,po.isAligned32)(t))throw new Error("unaligned dst");return t}function Bo(e,t,n,r){(0,ho.bytes)(t,go),(0,ho.bytes)(n);const i=n.length;r=No(i,r);const o=t,s=(0,po.u32)(o);let{s0:a,s1:c,s2:l,s3:d}=Po(e,s[0],s[1],s[2],s[3]);const u=(0,po.u32)(n),h=(0,po.u32)(r);for(let t=0;t+4<=u.length;t+=4){h[t+0]=u[t+0]^a,h[t+1]=u[t+1]^c,h[t+2]=u[t+2]^l,h[t+3]=u[t+3]^d;let n=1;for(let e=o.length-1;e>=0;e--)n=n+(255&o[e])|0,o[e]=255&n,n>>>=8;({s0:a,s1:c,s2:l,s3:d}=Po(e,s[0],s[1],s[2],s[3]))}const f=go*Math.floor(u.length/4);if(f<i){const e=new Uint32Array([a,c,l,d]),t=(0,po.u8)(e);for(let e=f,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,po.clean)(e)}return r}function Do(e,t,n,r,i){(0,ho.bytes)(n,go),(0,ho.bytes)(r),i=No(r.length,i);const o=n,s=(0,po.u32)(o),a=(0,po.createView)(o),c=(0,po.u32)(r),l=(0,po.u32)(i),d=t?0:12,u=r.length;let h=a.getUint32(d,t),{s0:f,s1:p,s2:g,s3:m}=Po(e,s[0],s[1],s[2],s[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^f,l[n+1]=c[n+1]^p,l[n+2]=c[n+2]^g,l[n+3]=c[n+3]^m,h=h+1>>>0,a.setUint32(d,h,t),({s0:f,s1:p,s2:g,s3:m}=Po(e,s[0],s[1],s[2],s[3]));const y=go*Math.floor(c.length/4);if(y<u){const e=new Uint32Array([f,p,g,m]),t=(0,po.u8)(e);for(let e=y,n=0;e<u;e++,n++)i[e]=r[e]^t[n];(0,po.clean)(e)}return i}function $o(e){if((0,ho.bytes)(e),e.length%go!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function jo(e,t,n){(0,ho.bytes)(e);let r=e.length;const i=r%go;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,po.isAligned32)(e)||(e=(0,po.copyBytes)(e));const o=(0,po.u32)(e);if(t){let e=go-i;e||(e=go),r+=e}const s=No(r,n);return{b:o,o:(0,po.u32)(s),out:s}}function Ko(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function Uo(e){const t=new Uint8Array(16),n=(0,po.u32)(t);t.set(e);const r=go-e.length;for(let e=go-r;e<go;e++)t[e]=r;return n}function Fo(e,t,n,r,i){const o=null==i?0:i.length,s=e.create(n,r.length+o);i&&s.update(i),s.update(r);const a=new Uint8Array(16),c=(0,po.createView)(a);i&&(0,po.setBigUint64)(c,0,BigInt(8*o),t),(0,po.setBigUint64)(c,8,BigInt(8*r.length),t),s.update(a);const l=s.digest();return(0,po.clean)(a),l}Qi.ctr=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,ho.bytes)(n),void 0!==r&&((0,ho.bytes)(r),!(0,po.isAligned32)(r)))throw new Error("unaligned destination");const i=Lo(e),o=(0,po.copyBytes)(t),s=[i,o];(0,po.isAligned32)(n)||s.push(n=(0,po.copyBytes)(n));const a=Bo(i,o,n,r);return(0,po.clean)(...s),a}return(0,ho.bytes)(e),(0,ho.bytes)(t,go),{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),Qi.ecb=(0,po.wrapCipher)({blockSize:16},(function(e,t={}){(0,ho.bytes)(e);const n=!t.disablePadding;return{encrypt(t,r){const{b:i,o:o,out:s}=jo(t,n,r),a=Lo(e);let c=0;for(;c+4<=i.length;){const{s0:e,s1:t,s2:n,s3:r}=Po(a,i[c+0],i[c+1],i[c+2],i[c+3]);o[c++]=e,o[c++]=t,o[c++]=n,o[c++]=r}if(n){const e=Uo(t.subarray(4*c)),{s0:n,s1:r,s2:i,s3:s}=Po(a,e[0],e[1],e[2],e[3]);o[c++]=n,o[c++]=r,o[c++]=i,o[c++]=s}return(0,po.clean)(a),s},decrypt(t,r){$o(t);const i=Oo(e),o=No(t.length,r),s=[i];(0,po.isAligned32)(t)||s.push(t=(0,po.copyBytes)(t));const a=(0,po.u32)(t),c=(0,po.u32)(o);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=Io(i,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,po.clean)(...s),Ko(o,n)}}})),Qi.cbc=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){(0,ho.bytes)(e),(0,ho.bytes)(t,16);const r=!n.disablePadding;return{encrypt(n,i){const o=Lo(e),{b:s,o:a,out:c}=jo(n,r,i);let l=t;const d=[o];(0,po.isAligned32)(l)||d.push(l=(0,po.copyBytes)(l));const u=(0,po.u32)(l);let h=u[0],f=u[1],p=u[2],g=u[3],m=0;for(;m+4<=s.length;)h^=s[m+0],f^=s[m+1],p^=s[m+2],g^=s[m+3],({s0:h,s1:f,s2:p,s3:g}=Po(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g;if(r){const e=Uo(n.subarray(4*m));h^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:h,s1:f,s2:p,s3:g}=Po(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g}return(0,po.clean)(...d),c},decrypt(n,i){$o(n);const o=Oo(e);let s=t;const a=[o];(0,po.isAligned32)(s)||a.push(s=(0,po.copyBytes)(s));const c=(0,po.u32)(s),l=No(n.length,i);(0,po.isAligned32)(n)||a.push(n=(0,po.copyBytes)(n));const d=(0,po.u32)(n),u=(0,po.u32)(l);let h=c[0],f=c[1],p=c[2],g=c[3];for(let e=0;e+4<=d.length;){const t=h,n=f,r=p,i=g;h=d[e+0],f=d[e+1],p=d[e+2],g=d[e+3];const{s0:s,s1:a,s2:c,s3:l}=Io(o,h,f,p,g);u[e++]=s^t,u[e++]=a^n,u[e++]=c^r,u[e++]=l^i}return(0,po.clean)(...a),Ko(l,r)}}})),Qi.cfb=(0,po.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,ho.bytes)(n);const o=n.length;i=No(o,i);const s=Lo(e);let a=t;const c=[s];(0,po.isAligned32)(a)||c.push(a=(0,po.copyBytes)(a)),(0,po.isAligned32)(n)||c.push(n=(0,po.copyBytes)(n));const l=(0,po.u32)(n),d=(0,po.u32)(i),u=r?d:l,h=(0,po.u32)(a);let f=h[0],p=h[1],g=h[2],m=h[3];for(let e=0;e+4<=l.length;){const{s0:t,s1:n,s2:r,s3:i}=Po(s,f,p,g,m);d[e+0]=l[e+0]^t,d[e+1]=l[e+1]^n,d[e+2]=l[e+2]^r,d[e+3]=l[e+3]^i,f=u[e++],p=u[e++],g=u[e++],m=u[e++]}const y=go*Math.floor(l.length/4);if(y<o){({s0:f,s1:p,s2:g,s3:m}=Po(s,f,p,g,m));const e=(0,po.u8)(new Uint32Array([f,p,g,m]));for(let t=y,r=0;t<o;t++,r++)i[t]=n[t]^e[r];(0,po.clean)(e)}return(0,po.clean)(...c),i}return(0,ho.bytes)(e),(0,ho.bytes)(t,16),{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),Qi.gcm=(0,po.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){if((0,ho.bytes)(e),(0,ho.bytes)(t),void 0!==n&&(0,ho.bytes)(n),t.length<8)throw new Error("aes/gcm: invalid nonce length");function r(e,t,r){const i=Fo(fo.ghash,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){const n=Lo(e),r=mo.slice(),i=mo.slice();if(Do(n,!1,i,i,r),12===t.length)i.set(t);else{const e=mo.slice(),n=(0,po.createView)(e);(0,po.setBigUint64)(n,8,BigInt(8*t.length),!1);const o=fo.ghash.create(r).update(t).update(e);o.digestInto(i),o.destroy()}return{xk:n,authKey:r,counter:i,tagMask:Do(n,!1,i,mo)}}return{encrypt(e){(0,ho.bytes)(e);const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=new Uint8Array(e.length+16),c=[t,n,o,s];(0,po.isAligned32)(e)||c.push(e=(0,po.copyBytes)(e)),Do(t,!1,o,e,a);const l=r(n,s,a.subarray(0,a.length-16));return c.push(l),a.set(l,e.length),(0,po.clean)(...c),a},decrypt(e){if((0,ho.bytes)(e),e.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=[t,n,s,o];(0,po.isAligned32)(e)||a.push(e=(0,po.copyBytes)(e));const c=e.subarray(0,-16),l=e.subarray(-16),d=r(n,s,c);if(a.push(d),!(0,po.equalBytes)(d,l))throw new Error("aes/gcm: invalid ghash tag");const u=Do(t,!1,o,c);return(0,po.clean)(...a),u}}}));const Ho=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(`${e}: invalid value=${r}, must be [${t}..${n}]`)};function zo(e){return null!=e&&"object"==typeof e&&(e instanceof Uint32Array||"Uint32Array"===e.constructor.name)}function qo(e,t){if((0,ho.bytes)(t,16),!zo(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,po.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Po(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}function Vo(e,t){if((0,ho.bytes)(t,16),!zo(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,po.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Io(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}Qi.siv=(0,po.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){const r=Ho("AAD",0,2**36),i=Ho("plaintext",0,2**36),o=Ho("nonce",12,12),s=Ho("ciphertext",16,2**36+16);function a(){const n=Lo(e),r=new Uint8Array(e.length),i=new Uint8Array(16),o=[n,r];let s=t;(0,po.isAligned32)(s)||o.push(s=(0,po.copyBytes)(s));const a=(0,po.u32)(s);let c=0,l=a[0],d=a[1],u=a[2],h=0;for(const e of[i,r].map(po.u32)){const t=(0,po.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:i}=Po(n,c,l,d,u);t[e+0]=r,t[e+1]=i,c=++h}}const f={authKey:i,encKey:Lo(r)};return(0,po.clean)(...o),f}function c(e,r,i){const o=Fo(fo.polyval,!0,r,i,n);for(let e=0;e<12;e++)o[e]^=t[e];o[15]&=127;const s=(0,po.u32)(o);let a=s[0],c=s[1],l=s[2],d=s[3];return({s0:a,s1:c,s2:l,s3:d}=Po(e,a,c,l,d)),s[0]=a,s[1]=c,s[2]=l,s[3]=d,o}function l(e,t,n){let r=(0,po.copyBytes)(t);r[15]|=128;const i=Do(e,!0,r,n);return(0,po.clean)(r),i}return(0,ho.bytes)(e,16,24,32),(0,ho.bytes)(t),o(t.length),void 0!==n&&((0,ho.bytes)(n),r(n.length)),{encrypt(e){(0,ho.bytes)(e),i(e.length);const{encKey:t,authKey:n}=a(),r=c(t,n,e),o=[t,n,r];(0,po.isAligned32)(e)||o.push(e=(0,po.copyBytes)(e));const s=new Uint8Array(e.length+16);return s.set(r,e.length),s.set(l(t,r,e)),(0,po.clean)(...o),s},decrypt(e){(0,ho.bytes)(e),s(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=a(),i=[n,r];(0,po.isAligned32)(e)||i.push(e=(0,po.copyBytes)(e));const o=l(n,t,e.subarray(0,-16)),d=c(n,r,o);if(i.push(d),!(0,po.equalBytes)(t,d))throw(0,po.clean)(...i),new Error("invalid polyval tag");return(0,po.clean)(...i),o}}}));const Wo={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=Lo(e);if(16===t.length)qo(n,t);else{const e=(0,po.u32)(t);let r=e[0],i=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:s,s1:a,s2:c,s3:l}=Po(n,r,i,e[t],e[t+1]);r=s,i=a^So(o),e[t]=c,e[t+1]=l}e[0]=r,e[1]=i}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=Oo(e),r=t.length/8-1;if(1===r)Vo(n,t);else{const e=(0,po.u32)(t);let i=e[0],o=e[1];for(let t=0,s=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,s--){o^=So(s);const{s0:r,s1:a,s2:c,s3:l}=Io(n,i,o,e[t],e[t+1]);i=r,o=a,e[t]=c,e[t+1]=l}e[0]=i,e[1]=o}n.fill(0)}},Go=new Uint8Array(8).fill(166);Qi.aeskw=(0,po.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,ho.bytes)(t),!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,po.concatBytes)(Go,t);return Wo.encrypt(e,n),n},decrypt(t){if((0,ho.bytes)(t),t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,po.copyBytes)(t);if(Wo.decrypt(e,n),!(0,po.equalBytes)(n.subarray(0,8),Go))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const Yo=2790873510;Qi.aeskwp=(0,po.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,ho.bytes)(t),!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const i=(0,po.u32)(r);return i[0]=Yo,i[1]=So(t.length),Wo.encrypt(e,r),r},decrypt(t){if((0,ho.bytes)(t),t.length<16)throw new Error("invalid ciphertext length");const n=(0,po.copyBytes)(t),r=(0,po.u32)(n);Wo.decrypt(e,n);const i=So(r[1])>>>0,o=8*Math.ceil(i/8);if(r[0]!==Yo||n.length-8!==o)throw new Error("integrity check failed");for(let e=i;e<o;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}}))),Qi.unsafe={expandKeyLE:Lo,expandKeyDecLE:Oo,encrypt:Po,decrypt:Io,encryptBlock:qo,decryptBlock:Vo,ctrCounter:Bo,ctr32:Do},Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.aes256cbc=Xi.aes256gcm=void 0;var Zo=Qi;Xi.aes256gcm=function(e,t,n){return(0,Zo.gcm)(e,t,n)},Xi.aes256cbc=function(e,t,n){return(0,Zo.cbc)(e,t)};var Jo={},Xo={},Qo={};Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.sigma=void 0,Qo.rotl=function(e,t){return e<<t|e>>>32-t},Qo.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=(0,ts.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,es.number)(i),(0,es.number)(s),(0,es.bool)(o),(0,es.bool)(n),(t,a,c,l,d=0)=>{(0,es.bytes)(t),(0,es.bytes)(a),(0,es.bytes)(c);const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),(0,es.bytes)(l),(0,es.number)(d),d<0||d>=ds)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=(0,ts.copyBytes)(t)),p=ss;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=os,h.push(f)}as(a)||h.push(a=(0,ts.copyBytes)(a));const m=(0,ts.u32)(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,(0,ts.u32)(a.subarray(0,16)),m),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,h.push(a)}const v=(0,ts.u32)(a);return function(e,t,n,r,i,o,s,a){const c=i.length,l=new Uint8Array(cs),d=(0,ts.u32)(l),u=as(i)&&as(o),h=u?(0,ts.u32)(i):us,f=u?(0,ts.u32)(o):us;for(let p=0;p<c;s++){if(e(t,n,r,d,s,a),s>=ds)throw new Error("arx: counter overflow");const g=Math.min(cs,c-p);if(u&&g===cs){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<ls;n++)t=e+n,f[t]=h[t]^d[n];p+=cs}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^l[t];p+=g}}}(e,p,m,v,c,l,d,s),(0,ts.clean)(...h),l}};const es=Ht,ts=Ft,ns=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),rs=ns("expand 16-byte k"),is=ns("expand 32-byte k"),os=(0,ts.u32)(rs),ss=(0,ts.u32)(is);function as(e){return e.byteOffset%4==0}Qo.sigma=ss.slice();const cs=64,ls=16,ds=2**32-1,us=new Uint32Array;var hs={};Object.defineProperty(hs,"__esModule",{value:!0}),hs.poly1305=void 0,hs.wrapConstructorWithKey=ys;const fs=Ht,ps=Ft,gs=(e,t)=>255&e[t++]|(255&e[t++])<<8;class ms{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,e=(0,ps.toBytes)(e),(0,fs.bytes)(e,32);const t=gs(e,0),n=gs(e,2),r=gs(e,4),i=gs(e,6),o=gs(e,8),s=gs(e,10),a=gs(e,12),c=gs(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=gs(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],d=o[4],u=o[5],h=o[6],f=o[7],p=o[8],g=o[9],m=gs(e,t+0),y=gs(e,t+2),v=gs(e,t+4),b=gs(e,t+6),w=gs(e,t+8),E=gs(e,t+10),C=gs(e,t+12),_=gs(e,t+14);let S=i[0]+(8191&m),k=i[1]+(8191&(m>>>13|y<<3)),x=i[2]+(8191&(y>>>10|v<<6)),A=i[3]+(8191&(v>>>7|b<<9)),M=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),O=i[6]+(8191&(w>>>14|E<<2)),T=i[7]+(8191&(E>>>11|C<<5)),R=i[8]+(8191&(C>>>8|_<<8)),P=i[9]+(_>>>5|r),I=0,N=I+S*s+k*(5*g)+x*(5*p)+A*(5*f)+M*(5*h);I=N>>>13,N&=8191,N+=L*(5*u)+O*(5*d)+T*(5*l)+R*(5*c)+P*(5*a),I+=N>>>13,N&=8191;let B=I+S*a+k*s+x*(5*g)+A*(5*p)+M*(5*f);I=B>>>13,B&=8191,B+=L*(5*h)+O*(5*u)+T*(5*d)+R*(5*l)+P*(5*c),I+=B>>>13,B&=8191;let D=I+S*c+k*a+x*s+A*(5*g)+M*(5*p);I=D>>>13,D&=8191,D+=L*(5*f)+O*(5*h)+T*(5*u)+R*(5*d)+P*(5*l),I+=D>>>13,D&=8191;let $=I+S*l+k*c+x*a+A*s+M*(5*g);I=$>>>13,$&=8191,$+=L*(5*p)+O*(5*f)+T*(5*h)+R*(5*u)+P*(5*d),I+=$>>>13,$&=8191;let j=I+S*d+k*l+x*c+A*a+M*s;I=j>>>13,j&=8191,j+=L*(5*g)+O*(5*p)+T*(5*f)+R*(5*h)+P*(5*u),I+=j>>>13,j&=8191;let K=I+S*u+k*d+x*l+A*c+M*a;I=K>>>13,K&=8191,K+=L*s+O*(5*g)+T*(5*p)+R*(5*f)+P*(5*h),I+=K>>>13,K&=8191;let U=I+S*h+k*u+x*d+A*l+M*c;I=U>>>13,U&=8191,U+=L*a+O*s+T*(5*g)+R*(5*p)+P*(5*f),I+=U>>>13,U&=8191;let F=I+S*f+k*h+x*u+A*d+M*l;I=F>>>13,F&=8191,F+=L*c+O*a+T*s+R*(5*g)+P*(5*p),I+=F>>>13,F&=8191;let H=I+S*p+k*f+x*h+A*u+M*d;I=H>>>13,H&=8191,H+=L*l+O*c+T*a+R*s+P*(5*g),I+=H>>>13,H&=8191;let z=I+S*g+k*p+x*f+A*h+M*u;I=z>>>13,z&=8191,z+=L*d+O*l+T*c+R*a+P*s,I+=z>>>13,z&=8191,I=(I<<2)+I|0,I=I+N|0,N=8191&I,I>>>=13,B+=I,i[0]=N,i[1]=B,i[2]=D,i[3]=$,i[4]=j,i[5]=K,i[6]=U,i[7]=F,i[8]=H,i[9]=z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let o=e[0]+t[0];e[0]=65535&o;for(let n=1;n<8;n++)o=(e[n]+t[n]|0)+(o>>>16)|0,e[n]=65535&o;(0,ps.clean)(n)}update(e){(0,fs.exists)(this);const{buffer:t,blockLen:n}=this,r=(e=(0,ps.toBytes)(e)).length;for(let i=0;i<r;){const o=Math.min(n-this.pos,r-i);if(o!==n)t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){(0,ps.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,fs.exists)(this),(0,fs.output)(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function ys(e){const t=(t,n)=>e(n).update((0,ps.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}hs.poly1305=ys((e=>new ms(e))),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xchacha20poly1305=e.chacha20poly1305=e._poly1305_aead=e.chacha12=e.chacha8=e.xchacha20=e.chacha20=e.chacha20orig=void 0,e.hchacha=s;const t=Qo,n=Ht,r=hs,i=Ft;function o(e,n,r,i,o,s=20){let a=e[0],c=e[1],l=e[2],d=e[3],u=n[0],h=n[1],f=n[2],p=n[3],g=n[4],m=n[5],y=n[6],v=n[7],b=o,w=r[0],E=r[1],C=r[2],_=a,S=c,k=l,x=d,A=u,M=h,L=f,O=p,T=g,R=m,P=y,I=v,N=b,B=w,D=E,$=C;for(let e=0;e<s;e+=2)_=_+A|0,N=(0,t.rotl)(N^_,16),T=T+N|0,A=(0,t.rotl)(A^T,12),_=_+A|0,N=(0,t.rotl)(N^_,8),T=T+N|0,A=(0,t.rotl)(A^T,7),S=S+M|0,B=(0,t.rotl)(B^S,16),R=R+B|0,M=(0,t.rotl)(M^R,12),S=S+M|0,B=(0,t.rotl)(B^S,8),R=R+B|0,M=(0,t.rotl)(M^R,7),k=k+L|0,D=(0,t.rotl)(D^k,16),P=P+D|0,L=(0,t.rotl)(L^P,12),k=k+L|0,D=(0,t.rotl)(D^k,8),P=P+D|0,L=(0,t.rotl)(L^P,7),x=x+O|0,$=(0,t.rotl)($^x,16),I=I+$|0,O=(0,t.rotl)(O^I,12),x=x+O|0,$=(0,t.rotl)($^x,8),I=I+$|0,O=(0,t.rotl)(O^I,7),_=_+M|0,$=(0,t.rotl)($^_,16),P=P+$|0,M=(0,t.rotl)(M^P,12),_=_+M|0,$=(0,t.rotl)($^_,8),P=P+$|0,M=(0,t.rotl)(M^P,7),S=S+L|0,N=(0,t.rotl)(N^S,16),I=I+N|0,L=(0,t.rotl)(L^I,12),S=S+L|0,N=(0,t.rotl)(N^S,8),I=I+N|0,L=(0,t.rotl)(L^I,7),k=k+O|0,B=(0,t.rotl)(B^k,16),T=T+B|0,O=(0,t.rotl)(O^T,12),k=k+O|0,B=(0,t.rotl)(B^k,8),T=T+B|0,O=(0,t.rotl)(O^T,7),x=x+A|0,D=(0,t.rotl)(D^x,16),R=R+D|0,A=(0,t.rotl)(A^R,12),x=x+A|0,D=(0,t.rotl)(D^x,8),R=R+D|0,A=(0,t.rotl)(A^R,7);let j=0;i[j++]=a+_|0,i[j++]=c+S|0,i[j++]=l+k|0,i[j++]=d+x|0,i[j++]=u+A|0,i[j++]=h+M|0,i[j++]=f+L|0,i[j++]=p+O|0,i[j++]=g+T|0,i[j++]=m+R|0,i[j++]=y+P|0,i[j++]=v+I|0,i[j++]=b+N|0,i[j++]=w+B|0,i[j++]=E+D|0,i[j++]=C+$|0}function s(e,n,r,i){let o=e[0],s=e[1],a=e[2],c=e[3],l=n[0],d=n[1],u=n[2],h=n[3],f=n[4],p=n[5],g=n[6],m=n[7],y=r[0],v=r[1],b=r[2],w=r[3];for(let e=0;e<20;e+=2)o=o+l|0,y=(0,t.rotl)(y^o,16),f=f+y|0,l=(0,t.rotl)(l^f,12),o=o+l|0,y=(0,t.rotl)(y^o,8),f=f+y|0,l=(0,t.rotl)(l^f,7),s=s+d|0,v=(0,t.rotl)(v^s,16),p=p+v|0,d=(0,t.rotl)(d^p,12),s=s+d|0,v=(0,t.rotl)(v^s,8),p=p+v|0,d=(0,t.rotl)(d^p,7),a=a+u|0,b=(0,t.rotl)(b^a,16),g=g+b|0,u=(0,t.rotl)(u^g,12),a=a+u|0,b=(0,t.rotl)(b^a,8),g=g+b|0,u=(0,t.rotl)(u^g,7),c=c+h|0,w=(0,t.rotl)(w^c,16),m=m+w|0,h=(0,t.rotl)(h^m,12),c=c+h|0,w=(0,t.rotl)(w^c,8),m=m+w|0,h=(0,t.rotl)(h^m,7),o=o+d|0,w=(0,t.rotl)(w^o,16),g=g+w|0,d=(0,t.rotl)(d^g,12),o=o+d|0,w=(0,t.rotl)(w^o,8),g=g+w|0,d=(0,t.rotl)(d^g,7),s=s+u|0,y=(0,t.rotl)(y^s,16),m=m+y|0,u=(0,t.rotl)(u^m,12),s=s+u|0,y=(0,t.rotl)(y^s,8),m=m+y|0,u=(0,t.rotl)(u^m,7),a=a+h|0,v=(0,t.rotl)(v^a,16),f=f+v|0,h=(0,t.rotl)(h^f,12),a=a+h|0,v=(0,t.rotl)(v^a,8),f=f+v|0,h=(0,t.rotl)(h^f,7),c=c+l|0,b=(0,t.rotl)(b^c,16),p=p+b|0,l=(0,t.rotl)(l^p,12),c=c+l|0,b=(0,t.rotl)(b^c,8),p=p+b|0,l=(0,t.rotl)(l^p,7);let E=0;i[E++]=o,i[E++]=s,i[E++]=a,i[E++]=c,i[E++]=y,i[E++]=v,i[E++]=b,i[E++]=w}e.chacha20orig=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,allowShortKeys:!0}),e.chacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,allowShortKeys:!1}),e.xchacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,extendNonceFn:s,allowShortKeys:!1}),e.chacha8=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:8}),e.chacha12=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:12});const a=new Uint8Array(16),c=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(a.subarray(n))},l=new Uint8Array(32);function d(e,t,n,o,s){const a=e(t,n,l),d=r.poly1305.create(a);s&&c(d,s),c(d,o);const u=new Uint8Array(16),h=(0,i.createView)(u);(0,i.setBigUint64)(h,0,BigInt(s?s.length:0),!0),(0,i.setBigUint64)(h,8,BigInt(o.length),!0),d.update(u);const f=d.digest();return(0,i.clean)(a,u),f}e._poly1305_aead=e=>(t,r,o)=>((0,n.bytes)(t,32),(0,n.bytes)(r),{encrypt(s,a){const c=s.length,l=c+16;a?(0,n.bytes)(a,l):a=new Uint8Array(l),e(t,r,s,a,1);const u=d(e,t,r,a.subarray(0,-16),o);return a.set(u,c),(0,i.clean)(u),a},decrypt(s,a){const c=s.length,l=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");a?(0,n.bytes)(a,l):a=new Uint8Array(l);const u=s.subarray(0,-16),h=s.subarray(-16),f=d(e,t,r,u,o);if(!(0,i.equalBytes)(h,f))throw new Error("invalid tag");return e(t,r,u,a,1),(0,i.clean)(f),a}}),e.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,e._poly1305_aead)(e.chacha20)),e.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,e._poly1305_aead)(e.xchacha20))}(Xo),Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.xchacha20=void 0;var vs,bs,ws,Es=Xo;Jo.xchacha20=function(e,t,n){return(0,Es.xchacha20poly1305)(e,t,n)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=Ft,n=on,r=Xi,i=Jo,o=Xt,s=Qt;function a(e,t,n,a){var c=(0,o.symmetricAlgorithm)();if("aes-256-gcm"===c)return e(r.aes256gcm,t,n,(0,o.symmetricNonceLength)(),s.AEAD_TAG_LENGTH,a);if("xchacha20"===c)return e(i.xchacha20,t,n,s.XCHACHA20_NONCE_LENGTH,s.AEAD_TAG_LENGTH,a);if("aes-256-cbc"===c)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function c(e,r,i,o,s,a){var c=(0,n.randomBytes)(o),l=e(r,c,a).encrypt(i);if(0===s)return(0,t.concatBytes)(c,l);var d=l.length-s,u=l.subarray(0,d),h=l.subarray(d);return(0,t.concatBytes)(c,h,u)}function l(e,n,r,i,o,s){var a=r.subarray(0,i),c=e(n,Uint8Array.from(a),s),l=r.subarray(i);if(0===o)return c.decrypt(l);var d=l.subarray(0,o),u=l.subarray(o);return c.decrypt((0,t.concatBytes)(u,d))}e.symEncrypt=function(e,t,n){return a(c,e,t,n)},e.symDecrypt=function(e,t,n){return a(l,e,t,n)},e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt}(Ji),vs=nn,bs=$t&&$t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),ws=$t&&$t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||bs(t,e,n)},Object.defineProperty(vs,"__esModule",{value:!0}),ws(rn,vs),ws(Fi,vs),ws(Ui,vs),ws(Ji,vs);var Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.PublicKey=void 0;var _s=Ft,Ss=nn,ks=function(){function e(e){this.data=(0,Ss.convertPublicKeyFormat)(e,!0)}return e.fromHex=function(t){return new e((0,Ss.hexToPublicKey)(t))},Object.defineProperty(e.prototype,"uncompressed",{get:function(){return Xe.from((0,Ss.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return Xe.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,_s.bytesToHex)(e?this.data:this.uncompressed)},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.data:this.uncompressed,r=e.multiply(this,t);return(0,Ss.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,_s.equalBytes)(this.data,e.data)},e}();Cs.PublicKey=ks,Object.defineProperty(tn,"__esModule",{value:!0}),tn.PrivateKey=void 0;var xs=Ft,As=nn,Ms=Cs,Ls=function(){function e(e){if(void 0===e)this.data=(0,As.getValidSecret)();else{if(!(0,As.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new Ms.PublicKey((0,As.getPublicKey)(this.data))}return e.fromHex=function(t){return new e((0,As.decodeHex)(t))},Object.defineProperty(e.prototype,"secret",{get:function(){return Xe.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,xs.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.publicKey.compressed:this.publicKey.uncompressed,r=this.multiply(e,t);return(0,As.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,As.getSharedPoint)(this.data,e.compressed,t)},e.prototype.equals=function(e){return(0,xs.equalBytes)(this.data,e.data)},e}();tn.PrivateKey=Ls,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=tn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return t.PrivateKey}});var n=Cs;Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})}(en),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=function(e,o){var s=new r.PrivateKey,a=e instanceof Uint8Array?new r.PublicKey(e):r.PublicKey.fromHex(e),c=s.encapsulate(a,(0,n.isHkdfKeyCompressed)()),l=(0,n.isEphemeralKeyCompressed)()?s.publicKey.compressed:s.publicKey.uncompressed,d=(0,i.symEncrypt)(c,o);return Xe.from((0,t.concatBytes)(l,d))},e.decrypt=function(e,t){var o=e instanceof Uint8Array?new r.PrivateKey(e):r.PrivateKey.fromHex(e),s=(0,n.ephemeralKeySize)(),a=new r.PublicKey(t.subarray(0,s)),c=t.subarray(s),l=a.decapsulate(o,(0,n.isHkdfKeyCompressed)());return Xe.from((0,i.symDecrypt)(l,c))};var t=Ft,n=Xt,r=en,i=nn,o=Xt;Object.defineProperty(e,"ECIES_CONFIG",{enumerable:!0,get:function(){return o.ECIES_CONFIG}});var s=en;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return s.PrivateKey}}),Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return s.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}}(Ut);const Os=u("KeyExchange:Layer"),Ts=u("SocketService:Layer"),Rs=u("Ecies:Layer"),Ps=u("RemoteCommunication:Layer");Os.color="##95c44e",Ts.color="#f638d7",Rs.color="#465b9c",Ps.color="#47a2be";const Is={KeyExchange:Os,SocketService:Ts,Ecies:Rs,RemoteCommunication:Ps};let Ns,Bs=[],Ds=[];const $s=(e,t)=>Be(void 0,void 0,void 0,(function*(){Ns=t,Ds.push(e),function(e){return Be(this,void 0,void 0,(function*(){if(!Ns||!e)return;!function(){const e=Ds;Ds=Bs,Bs=e}();const t=Ns.endsWith("/")?`${Ns}evt`:`${Ns}/evt`,n=Object.assign({},e);if(delete n.params,e.params)for(const[t,r]of Object.entries(e.params))n[t]=r;const r=JSON.stringify(n);Is.RemoteCommunication(`[sendBufferedEvents] Sending ${Bs.length} analytics events to ${t}`);try{const e=yield s(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:r}),n=yield e.text();Is.RemoteCommunication(`[sendBufferedEvents] Response: ${n}`),Bs.length=0}catch(t){}}))}(e).catch((()=>{}))}));class js{constructor(e){this.enabled=!0,(null==e?void 0:e.debug)&&u.enable("Ecies:Layer"),this.ecies=(null==e?void 0:e.privateKey)?Ut.PrivateKey.fromHex(e.privateKey):new Ut.PrivateKey,Is.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),Is.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),Is.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new Ut.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,t){let n=e;if(this.enabled)try{Is.Ecies("[ECIES: encrypt()] using otherPublicKey",t);const r=Xe.from(e),i=Ut.encrypt(t,r);n=Xe.from(i).toString("base64")}catch(n){throw Is.Ecies("[ECIES: encrypt()] error encrypt:",n),Is.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),Is.Ecies("[ECIES: encrypt()] data: ",e),Is.Ecies("[ECIES: encrypt()] otherkey: ",t),n}return n}decrypt(e){let t=e;if(this.enabled)try{Is.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const n=Xe.from(e.toString(),"base64");t=Ut.decrypt(this.ecies.toHex(),n).toString()}catch(t){throw Is.Ecies("[ECIES: decrypt()] error decrypt",t),Is.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),Is.Ecies("[ECIES: decrypt()] encryptedData: ",e),t}return t}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){Is.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var Ks={name:"@metamask/sdk-communication-layer",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk.git",directory:"packages/sdk-communication-layer"},main:"dist/node/cjs/metamask-sdk-communication-layer.js",unpkg:"dist/browser/umd/metamask-sdk-communication-layer.js",module:"dist/node/es/metamask-sdk-communication-layer.js",browser:"dist/browser/es/metamask-sdk-communication-layer.js","react-native":"dist/react-native/es/metamask-sdk-communication-layer.js",types:"dist/types/src/index.d.ts",files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types","build:clean":"yarn clean && yarn build",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",dev:'concurrently "tsc --watch" "rollup -c --bundleConfigAsCjs -w"',"build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",size:"size-limit",clean:"rimraf ./dist",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk-communication-layer","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore","publish:preview":"yarn npm publish --tag preview",prepack:"../../scripts/prepack.sh",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:coverage":"jest --coverage","test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":"jest",watch:"rollup -c --bundleConfigAsCjs -w"},dependencies:{bufferutil:"^4.0.8","date-fns":"^2.29.3",debug:"^4.3.4","utf-8-validate":"^5.0.2",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@size-limit/preset-big-lib":"^11.0.2","@types/jest":"^29.2.4","@types/node":"^20.1.3","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0",concurrently:"^9.1.2","cross-fetch":"^4.0.0",eciesjs:"^0.4.11",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0",eventemitter2:"^6.4.9",jest:"^29.3.1",prettier:"^2.3.0",rimraf:"^3.0.2",rollup:"^4.26.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.4.0","rollup-plugin-peer-deps-external":"^2.2.4","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.1.6","socket.io-client":"^4.5.1","stream-browserify":"^3.0.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^5.6.3"},peerDependencies:{"cross-fetch":"^4.0.0",eciesjs:"*",eventemitter2:"^6.4.9","readable-stream":"^3.6.2","socket.io-client":"^4.5.1"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"@lavamoat/preinstall-always-fail":!1,canvas:!0,"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,bufferutil:!1,"utf-8-validate":!1}}};const Us="https://metamask-sdk.api.cx.metamask.io/",Fs=["websocket"],Hs=6048e5,zs=3e3,qs={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",ETH_REQUESTACCOUNTS:"eth_requestAccounts"};function Vs(e){const{context:t}=e;Is.RemoteCommunication(`[RemoteCommunication: clean()] context=${t}`),e.channelConfig=void 0,e.ready=!1,e.originatorConnectStarted=!1}var Ws,Gs,Ys,Zs,Js,Xs,Qs;(Qs=Ws||(Ws={})).DISCONNECTED="disconnected",Qs.WAITING="waiting",Qs.TIMEOUT="timeout",Qs.LINKED="linked",Qs.PAUSED="paused",Qs.TERMINATED="terminated",function(e){e.KEY_INFO="key_info",e.SERVICE_STATUS="service_status",e.PROVIDER_UPDATE="provider_update",e.RPC_UPDATE="rpc_update",e.KEYS_EXCHANGED="keys_exchanged",e.JOIN_CHANNEL="join_channel",e.PUBLIC_KEY="public_key",e.CHANNEL_CREATED="channel_created",e.CLIENTS_CONNECTED="clients_connected",e.CLIENTS_DISCONNECTED="clients_disconnected",e.CLIENTS_WAITING="clients_waiting",e.CLIENTS_READY="clients_ready",e.REJECTED="rejected",e.WALLET_INIT="wallet_init",e.CHANNEL_PERSISTENCE="channel_persistence",e.CONFIG="config",e.MESSAGE_ACK="ack",e.SOCKET_DISCONNECTED="socket_disconnected",e.SOCKET_RECONNECT="socket_reconnect",e.OTP="otp",e.SDK_RPC_CALL="sdk_rpc_call",e.AUTHORIZED="authorized",e.CONNECTION_STATUS="connection_status",e.MESSAGE="message",e.TERMINATE="terminate"}(Gs||(Gs={})),(Ys||(Ys={})).KEY_EXCHANGE="key_exchange",function(e){e.KEY_HANDSHAKE_START="key_handshake_start",e.KEY_HANDSHAKE_CHECK="key_handshake_check",e.KEY_HANDSHAKE_SYN="key_handshake_SYN",e.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",e.KEY_HANDSHAKE_ACK="key_handshake_ACK",e.KEY_HANDSHAKE_WALLET="key_handshake_wallet",e.KEY_HANDSHAKE_NONE="none"}(Zs||(Zs={}));class ea extends h.exports.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:t,context:n,ecies:r,logging:i}){super(),this.keysExchanged=!1,this.step=Zs.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=n,this.communicationLayer=e,(null==r?void 0:r.privateKey)&&t&&(Is.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${t} set keysExchanged to true!`,r),this.keysExchanged=!0),this.myECIES=new js(Object.assign(Object.assign({},r),{debug:null==i?void 0:i.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=!0===(null==i?void 0:i.keyExchangeLayer),t&&this.setOtherPublicKey(t),this.communicationLayer.on(Ys.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:t}=this.communicationLayer.remote.state;if(Is.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${t}`,e),t)return void Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:n}=e;this.keysExchanged&&Is.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(Gs.KEY_INFO,n.type),n.type===Zs.KEY_HANDSHAKE_SYN?(this.checkStep([Zs.KEY_HANDSHAKE_NONE,Zs.KEY_HANDSHAKE_ACK]),Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",n),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((e=>{Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",e)})),this.setStep(Zs.KEY_HANDSHAKE_ACK)):n.type===Zs.KEY_HANDSHAKE_SYNACK?(this.checkStep([Zs.KEY_HANDSHAKE_SYNACK,Zs.KEY_HANDSHAKE_ACK,Zs.KEY_HANDSHAKE_NONE]),Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}).catch((e=>{Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",e)})),this.keysExchanged=!0,this.setStep(Zs.KEY_HANDSHAKE_ACK),this.emit(Gs.KEYS_EXCHANGED)):n.type===Zs.KEY_HANDSHAKE_ACK&&(Is.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Zs.KEY_HANDSHAKE_ACK,Zs.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Zs.KEY_HANDSHAKE_ACK),this.emit(Gs.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new js(e)}clean(){Is.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Zs.KEY_HANDSHAKE_NONE),this.emit(Gs.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:t}){const{relayPersistence:n,protocolVersion:r}=this.communicationLayer.remote.state,i=r>=2;n?Is.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(Is.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${r} isOriginator=${e} step=${this.step} force=${t} relayPersistence=${n} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Zs.KEY_HANDSHAKE_NONE&&this.step!==Zs.KEY_HANDSHAKE_SYNACK)||t?(Is.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${t}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Zs.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",e)}))):Is.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&!0!==t?Is.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):i?this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",e)})):(this.communicationLayer.sendMessage({type:Zs.KEY_HANDSHAKE_START}).catch((e=>{Is.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",e)})),this.clean()))}setStep(e){this.step=e,this.emit(Gs.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:t}){this.otherPublicKey=t,this.myECIES=new js({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){Is.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}!function(e){e.TERMINATE="terminate",e.ANSWER="answer",e.OFFER="offer",e.CANDIDATE="candidate",e.JSONRPC="jsonrpc",e.WALLET_INFO="wallet_info",e.WALLET_INIT="wallet_init",e.ORIGINATOR_INFO="originator_info",e.PAUSE="pause",e.OTP="otp",e.AUTHORIZED="authorized",e.PING="ping",e.READY="ready"}(Js||(Js={})),function(e){e.REQUEST="sdk_connect_request_started",e.REQUEST_MOBILE="sdk_connect_request_started_mobile",e.RECONNECT="sdk_reconnect_request_started",e.CONNECTED="sdk_connection_established",e.CONNECTED_MOBILE="sdk_connection_established_mobile",e.AUTHORIZED="sdk_connection_authorized",e.REJECTED="sdk_connection_rejected",e.TERMINATED="sdk_connection_terminated",e.DISCONNECTED="sdk_disconnected",e.SDK_USE_EXTENSION="sdk_use_extension",e.SDK_RPC_REQUEST="sdk_rpc_request",e.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",e.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",e.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",e.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"}(Xs||(Xs={}));const ta=(e,t,n)=>Be(void 0,void 0,void 0,(function*(){var r,i,o,s,a,c;const{remote:l,state:d}=e,{channelId:u,isOriginator:h}=d;if("error_terminated"===t)return Is.SocketService(`handleJoinChannelResults: Channel ${u} terminated`),void e.emit(Gs.TERMINATE);if(!n)return void Is.SocketService(`handleJoinChannelResults: No result for channel ${u}`);const{persistence:f,walletKey:p,rejected:g}=n;if(Is.SocketService(`handleJoinChannelResults: Channel ${u} persistence=${f} walletKey=${p} rejected=${g}`),g)return Is.SocketService(`handleJoinChannelResults: Channel ${u} rejected`),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Gs.REJECTED,{channelId:u}),void e.remote.emitServiceStatusEvent();if(p&&!(null===(r=l.state.channelConfig)||void 0===r?void 0:r.otherKey)){e.getKeyExchange().setOtherPublicKey(p),null===(i=e.state.keyExchange)||void 0===i||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Gs.AUTHORIZED);const{communicationLayer:t,storageManager:n}=l.state,r=Object.assign(Object.assign({},l.state.channelConfig),{channelId:null!==(o=l.state.channelId)&&void 0!==o?o:"",validUntil:Date.now()+Hs,localKey:null==t?void 0:t.getKeyInfo().ecies.private,otherKey:p});e.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}).catch((e=>{})),null===(s=e.state.socket)||void 0===s||s.emit(Js.PING,{id:u,clientType:h?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield null==n?void 0:n.persistChannelConfig(r),l.emitServiceStatusEvent(),l.setConnectionStatus(Ws.LINKED)}f&&(e.emit(Gs.CHANNEL_PERSISTENCE),null===(a=e.state.keyExchange)||void 0===a||a.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Gs.AUTHORIZED),$s(Object.assign(Object.assign({id:null!=u?u:"",event:h?Xs.CONNECTED:Xs.CONNECTED_MOBILE},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Ks.version,walletVersion:null===(c=e.remote.state.walletInfo)||void 0===c?void 0:c.version}),d.communicationServerUrl).catch((e=>{})))})),na=e=>new Promise((t=>{setTimeout(t,e)})),ra=(e,t,...n)=>Be(void 0,[e,t,...n],void 0,(function*(e,t,n=200){let r;const i=Date.now();let o=!1;for(;!o;){if(o=Date.now()-i>3e5,r=t[e],void 0!==r.elapsedTime)return r;yield na(n)}throw new Error(`RPC ${e} timed out`)})),ia=e=>Be(void 0,void 0,void 0,(function*(){const{state:t}=e,{socket:n,channelId:r,context:i,isOriginator:o,isReconnecting:s}=t;if(s)return Is.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",e),!1;if(!n)return Is.SocketService("[SocketService: reconnectSocket()] socket is not defined",e),!1;if(!r)return!1;const{connected:a}=n;t.isReconnecting=!0,t.reconnectionAttempts=0,Is.SocketService(`[SocketService: reconnectSocket()] connected=${a} trying to reconnect after socketio disconnection`,e);try{for(;3>t.reconnectionAttempts;){if(Is.SocketService(`[SocketService: reconnectSocket()] Attempt ${t.reconnectionAttempts+1} of 3`,e),yield na(200),n.connected)return Is.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(Js.PING,{id:r,clientType:o?"dapp":"wallet",context:"on_channel_config",message:""}),!0;t.resumed=!0,n.connect(),e.emit(Gs.SOCKET_RECONNECT);try{if(yield new Promise(((t,s)=>{n.emit(Gs.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:o?"dapp":"wallet"},((n,r)=>Be(void 0,void 0,void 0,(function*(){try{yield ta(e,n,r),t()}catch(e){s(e)}}))))})),yield na(100),n.connected)return Is.SocketService(`Reconnection successful on attempt ${t.reconnectionAttempts+1}`),!0}catch(e){Is.SocketService(`Error during reconnection attempt ${t.reconnectionAttempts+1}:`,e)}t.reconnectionAttempts+=1,3>t.reconnectionAttempts&&(yield na(200))}return Is.SocketService("Failed to reconnect after 3 attempts"),!1}finally{t.isReconnecting=!1,t.reconnectionAttempts=0}}));function oa(e,t){return Be(this,void 0,void 0,(function*(){var n;const r=null===(n=e.state.keyExchange)||void 0===n?void 0:n.encryptMessage(JSON.stringify(t)),i={id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:r,plaintext:e.state.hasPlaintext?JSON.stringify(t):void 0};return Is.SocketService(`[SocketService: encryptAndSendMessage()] context=${e.state.context}`,i),t.type===Js.TERMINATE&&(e.state.manualDisconnect=!0),new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Gs.MESSAGE,i,((e,r)=>{var i;e&&(Is.SocketService(`[SocketService: encryptAndSendMessage()] error=${e}`),n(e)),Is.SocketService("[encryptAndSendMessage] response",r),t(null!==(i=null==r?void 0:r.success)&&void 0!==i&&i)}))}))}))}var sa;!function(e){e.RPC_CHECK="rpcCheck",e.SKIPPED_RPC="skippedRpc"}(sa||(sa={}));const aa=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map((e=>e.toLowerCase())),ca=[{event:Gs.CLIENTS_CONNECTED,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var n,r,i,o,s,a,c,l,d,u,h;const f=null!==(r=null===(n=e.remote.state.channelConfig)||void 0===n?void 0:n.relayPersistence)&&void 0!==r&&r;if(Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected-${t}' relayPersistence=${f} resumed=${e.state.resumed} clientsPaused=${e.state.clientsPaused} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()} isOriginator=${e.state.isOriginator}`),e.emit(Gs.CLIENTS_CONNECTED,{isOriginator:e.state.isOriginator,keysExchanged:null===(o=e.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged(),context:e.state.context}),e.state.resumed)e.state.isOriginator||(Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} 'clients_connected' / keysExchanged=${null===(s=e.state.keyExchange)||void 0===s?void 0:s.areKeysExchanged()} -- backward compatibility`),null===(a=e.state.keyExchange)||void 0===a||a.start({isOriginator:null!==(c=e.state.isOriginator)&&void 0!==c&&c})),e.state.resumed=!1;else if(e.state.clientsPaused)Is.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!e.state.isOriginator){const t=!f;Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(l=e.state.keyExchange)||void 0===l?void 0:l.areKeysExchanged()} -- force=${t} -- backward compatibility`),Is.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(d=e.state.keyExchange)||void 0===d?void 0:d.areKeysExchanged()} -- force=${t} -- backward compatibility`),null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h,force:t})}e.state.clientsConnected=!0,e.state.clientsPaused=!1}))}},{event:Gs.CHANNEL_CREATED,handler:function(e,t){return n=>{Is.SocketService(`[SocketService: handleChannelCreated()] context=${e.state.context} on 'channel_created-${t}'`,n),e.emit(Gs.CHANNEL_CREATED,n)}}},{event:Gs.CLIENTS_DISCONNECTED,handler:function(e,t){return()=>{var n;e.state.clientsConnected=!1,Is.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}'`),e.remote.state.relayPersistence?Is.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}' - relayPersistence enabled, skipping key exchange cleanup.`):(e.state.isOriginator&&!e.state.clientsPaused&&(null===(n=e.state.keyExchange)||void 0===n||n.clean()),e.emit(Gs.CLIENTS_DISCONNECTED,t))}}},{event:Gs.CONFIG,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var r,i,o;Is.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${t}'`,n);const{persistence:s,walletKey:a}=n;e.state.isOriginator&&e.remote.state.channelConfig?(n.walletKey&&!e.remote.state.channelConfig.otherKey&&(Is.SocketService(`Setting wallet key ${a}`),e.remote.state.channelConfig.otherKey=a,e.getKeyExchange().setOtherPublicKey(n.walletKey),null===(r=e.state.keyExchange)||void 0===r||r.setKeysExchanged(!0),yield e.remote.sendMessage({type:Zs.KEY_HANDSHAKE_ACK}),yield e.remote.sendMessage({type:Js.PING}),yield null===(i=e.remote.state.storageManager)||void 0===i?void 0:i.persistChannelConfig(e.remote.state.channelConfig)),!0!==s||e.remote.state.channelConfig.relayPersistence||(Is.SocketService(`Setting relay persistence ${s}`),e.remote.state.channelConfig.relayPersistence=s,e.remote.state.relayPersistence=!0,e.remote.emit(Gs.CHANNEL_PERSISTENCE),e.remote.state.authorized=!0,e.remote.state.ready=!0,e.remote.emit(Gs.AUTHORIZED),yield null===(o=e.remote.state.storageManager)||void 0===o?void 0:o.persistChannelConfig(e.remote.state.channelConfig))):e.state.isOriginator||n.persistence&&(e.remote.state.relayPersistence=!0,e.remote.emit(Gs.CHANNEL_PERSISTENCE))}))}},{event:Gs.MESSAGE,handler:function(e,t){return n=>{var r,i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w;const{ackId:E,message:C,error:_}=n,S=null!==(r=e.remote.state.relayPersistence)&&void 0!==r&&r;if(Is.SocketService(`[SocketService handleMessage()] relayPersistence=${S} context=${e.state.context} on 'message' ${t} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()}`,n),_)throw Is.SocketService(`\n [SocketService handleMessage()] context=${e.state.context}::on 'message' error=${_}`),new Error(_);const k="string"==typeof C;if(!k&&(null==C?void 0:C.type)===Zs.KEY_HANDSHAKE_START){if(S)return;return Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received HANDSHAKE_START isOriginator=${e.state.isOriginator}`,C),void(null===(o=e.state.keyExchange)||void 0===o||o.start({isOriginator:null!==(s=e.state.isOriginator)&&void 0!==s&&s,force:!0}))}if(!k&&(null===(a=null==C?void 0:C.type)||void 0===a?void 0:a.startsWith("key_handshake"))){if(S)return;return Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' emit KEY_EXCHANGE`,C),void e.emit(Ys.KEY_EXCHANGE,{message:C,context:e.state.context})}if(k&&!(null===(c=e.state.keyExchange)||void 0===c?void 0:c.areKeysExchanged())){let t=!1;try{Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' trying to decrypt message`),null===(l=e.state.keyExchange)||void 0===l||l.decryptMessage(C),t=!0}catch(t){Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' error`,t)}if(!t)return e.state.isOriginator?null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h}):e.sendMessage({type:Zs.KEY_HANDSHAKE_START}).catch((e=>{})),void Is.SocketService(`Message ignored because invalid key exchange status. step=${null===(f=e.state.keyExchange)||void 0===f?void 0:f.getKeyInfo().step}`,null===(p=e.state.keyExchange)||void 0===p?void 0:p.getKeyInfo(),C);Is.SocketService("Invalid key exchange status detected --- updating it."),null===(d=e.state.keyExchange)||void 0===d||d.setKeysExchanged(!0)}else if(!k&&(null==C?void 0:C.type))return void e.emit(Gs.MESSAGE,C);if(!k)return void e.emit(Gs.MESSAGE,C);const x=null===(g=e.state.keyExchange)||void 0===g?void 0:g.decryptMessage(C),A=JSON.parse(null!=x?x:"{}");if(E&&(null==E?void 0:E.length)>0&&(Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' ackid=${E} channelId=${t}`),null===(m=e.state.socket)||void 0===m||m.emit(Gs.MESSAGE_ACK,{ackId:E,channelId:t,clientType:e.state.isOriginator?"dapp":"wallet"})),e.state.clientsPaused=(null==A?void 0:A.type)===Js.PAUSE,e.state.isOriginator&&A.data){const t=A.data,n=e.state.rpcMethodTracker[t.id];if(n){const r=Date.now()-n.timestamp;Is.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received answer for id=${t.id} method=${n.method} responseTime=${r}`,A),e.remote.state.analytics&&aa.includes(n.method.toLowerCase())&&$s(Object.assign(Object.assign({id:null!==(y=e.remote.state.channelId)&&void 0!==y?y:"",event:Xs.SDK_RPC_REQUEST_DONE,sdkVersion:e.remote.state.sdkVersion,commLayerVersion:Ks.version},e.remote.state.originatorInfo),{walletVersion:null===(v=e.remote.state.walletInfo)||void 0===v?void 0:v.version,params:{method:n.method,from:"mobile"}}),e.remote.state.communicationServerUrl).catch((e=>{}));const i=Object.assign(Object.assign({},n),{result:t.result,error:t.error?{code:null===(b=t.error)||void 0===b?void 0:b.code,message:null===(w=t.error)||void 0===w?void 0:w.message}:void 0,elapsedTime:r});e.state.rpcMethodTracker[t.id]=i,e.emit(Gs.RPC_UPDATE,i)}}e.emit(Gs.MESSAGE,{message:A})}}},{event:Gs.REJECTED,handler:function(e,t){return n=>Be(this,void 0,void 0,(function*(){var n;e.state.isOriginator&&!e.remote.state.ready?(Is.SocketService(`[SocketService: handleChannelRejected()] context=${e.state.context} channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`,e.remote.state.originatorInfo),$s(Object.assign(Object.assign({id:t,event:Xs.REJECTED},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Ks.version,walletVersion:null===(n=e.remote.state.walletInfo)||void 0===n?void 0:n.version}),e.remote.state.communicationServerUrl).catch((e=>{})),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Gs.REJECTED,{channelId:t}),e.remote.setConnectionStatus(Ws.DISCONNECTED)):Is.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`)}))}},{event:"clients_waiting_to_join",handler:function(e,t){return n=>{Is.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${e.state.context} on 'clients_waiting_to_join-${t}'`,n),e.emit(Gs.CLIENTS_WAITING,n)}}}],la=[{event:Gs.KEY_INFO,handler:function(e){return t=>{Is.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",t),e.emit(Gs.KEY_INFO,t)}}},{event:Gs.KEYS_EXCHANGED,handler:function(e){return()=>{var t,n,r;Is.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`);const{channelConfig:i}=e.remote.state;if(i){const t=e.getKeyExchange().getKeyInfo().ecies;i.localKey=t.private,i.otherKey=t.otherPubKey,e.remote.state.channelConfig=i,null===(n=e.remote.state.storageManager)||void 0===n||n.persistChannelConfig(i).catch((e=>{}))}e.emit(Gs.KEYS_EXCHANGED,{keysExchanged:null===(r=e.state.keyExchange)||void 0===r?void 0:r.areKeysExchanged(),isOriginator:e.state.isOriginator});const o={keyInfo:e.getKeyInfo()};e.emit(Gs.SERVICE_STATUS,o)}}}];function da(e,t){Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} setting socket listeners for channel ${t}...`);const{socket:n}=e.state,{keyExchange:r}=e.state;n&&e.state.isOriginator&&(e.state.debug&&(null==n||n.io.on("error",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=error`,t)})),null==n||n.io.on("reconnect",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect`,t),ia(e).catch((e=>{}))})),null==n||n.io.on("reconnect_error",(t=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_error`,t)})),null==n||n.io.on("reconnect_failed",(()=>{Is.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_failed`)}))),null==n||n.on("disconnect",(t=>(Is.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${t}' begin recovery...`),function(e){return t=>{Is.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${e.state.manualDisconnect}`,t),e.state.manualDisconnect||(e.emit(Gs.SOCKET_DISCONNECTED),ia(e).catch((e=>{})))}}(e)(t))))),ca.forEach((({event:r,handler:i})=>{null==n||n.on(`${r}-${t}`,i(e,t))})),la.forEach((({event:t,handler:n})=>{null==r||r.on(t,n(e))})),e.state.setupChannelListeners=!0}class ua extends h.exports.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:t,communicationLayerPreference:n,communicationServerUrl:r,context:i,remote:o,logging:s}=e;this.state.resumed=t,this.state.context=i,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=n,this.state.debug=!0===(null==s?void 0:s.serviceLayer),this.remote=o,!0===(null==s?void 0:s.serviceLayer)&&u.enable("SocketService:Layer"),this.state.communicationServerUrl=r,this.state.hasPlaintext=this.state.communicationServerUrl!==Us&&!0===(null==s?void 0:s.plaintext),Is.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:t,ecies:n,logging:r}=this.options,i={autoConnect:!1,transports:Fs,withCredentials:!0},o=this.state.communicationServerUrl;Is.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=Ne(o,i),function(e){if("undefined"!=typeof window&&"undefined"!=typeof document&&(Is.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,e),!e.state.focusListenerAdded)){const t=()=>{Is.SocketService("Document has focus --- reconnecting socket"),ia(e).catch((e=>{}))};window.addEventListener("focus",t),e.state.focusListenerAdded=!0,e.state.removeFocusListener=()=>{window.removeEventListener("focus",t),e.state.focusListenerAdded=!1}}}(this);const s={communicationLayer:this,otherPublicKey:t,sendPublicKey:!1,context:null!==(e=this.state.context)&&void 0!==e?e:"",ecies:n,logging:r};this.state.keyExchange=new ea(s)}resetKeys(){return Is.SocketService("[SocketService: resetKeys()] Resetting keys."),void(null===(e=this.state.keyExchange)||void 0===e||e.resetKeys());var e}createChannel(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var n,r,i;if(Is.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),null===(n=e.state.socket)||void 0===n?void 0:n.connected)throw new Error("socket already connected");null===(r=e.state.socket)||void 0===r||r.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const o=t.v4();e.state.channelId=o,da(e,o),yield new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Gs.JOIN_CHANNEL,{channelId:o,context:`${e.state.context}createChannel`,clientType:"dapp"},((r,i)=>Be(this,void 0,void 0,(function*(){try{yield ta(e,r,i),t()}catch(e){n(e)}}))))}));const s=null===(i=e.state.keyExchange)||void 0===i?void 0:i.getKeyInfo();return{channelId:o,pubKey:(null==s?void 0:s.ecies.public)||"",privKey:(null==s?void 0:s.ecies.private)||""}}))}(this)}))}connectToChannel({channelId:e,withKeyExchange:t=!1,authorized:n}){return function(e){return Be(this,arguments,void 0,(function*({options:e,instance:t}){const{channelId:n,authorized:r,withKeyExchange:i}=e,{state:o,remote:s}=t,{isOriginator:a=!1,socket:c,keyExchange:l}=o,{channelConfig:d}=s.state;if(null==c?void 0:c.connected)throw new Error("socket already connected");if(a&&(null==d?void 0:d.relayPersistence)){const{localKey:e,otherKey:t}=d;e&&t&&(null==l||l.setRelayPersistence({localKey:e,otherKey:t}))}return Object.assign(o,{manualDisconnect:!1,withKeyExchange:i,isOriginator:a,channelId:n}),null==c||c.connect(),da(t,n),!a&&r&&(null==l||l.setKeysExchanged(!0),Object.assign(s.state,{ready:!0,authorized:!0})),new Promise((e=>{var i;const s=null===(i=null==l?void 0:l.getKeyInfo())||void 0===i?void 0:i.ecies.public;null==c||c.emit(Gs.JOIN_CHANNEL,{channelId:n,context:`${o.context}_connectToChannel`,clientType:a?"dapp":"wallet",publicKey:r&&!a?s:void 0},((n,r)=>Be(this,void 0,void 0,(function*(){yield ta(t,n,r),e()}))))}))}))}({options:{channelId:e,withKeyExchange:t,authorized:n},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,t;null===(t=(e=this).state.socket)||void 0===t||t.emit(Gs.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Zs.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return Be(this,void 0,void 0,(function*(){return function(e,t){return Be(this,void 0,void 0,(function*(){var n,r,i;if(!e.state.channelId)throw Is.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(Is.SocketService(`[SocketService: handleSendMessage()] context=${e.state.context} areKeysExchanged=${null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`,t),null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.startsWith("key_handshake"))return function(e,t){var n;Is.SocketService(`[SocketService: handleKeyHandshake()] context=${e.state.context}`,t),null===(n=e.state.socket)||void 0===n||n.emit(Gs.MESSAGE,{id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:t})}(e,t),!0;!function(e,t){var n;if(!(null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&!e.remote.state.relayPersistence)throw Is.SocketService(`[SocketService: validateKeyExchange()] context=${e.state.context} ERROR keys not exchanged`,t),new Error("Keys not exchanged BBB")}(e,t),function(e,t){var n;const r=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"",i=null==t?void 0:t.id;e.state.isOriginator&&i&&(e.state.rpcMethodTracker[i]={id:i,timestamp:Date.now(),method:r},e.emit(Gs.RPC_UPDATE,e.state.rpcMethodTracker[i]))}(e,t);const o=yield oa(e,t);return e.remote.state.analytics&&e.remote.state.isOriginator&&t.method&&aa.includes(t.method.toLowerCase())&&$s({id:null!==(i=e.remote.state.channelId)&&void 0!==i?i:"",event:Xs.SDK_RPC_REQUEST,params:{method:t.method,from:"mobile"}},e.remote.state.communicationServerUrl).catch((e=>{})),function(e,t){return Be(this,void 0,void 0,(function*(){var n;const r=null==t?void 0:t.id,i=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"";if(e.state.isOriginator&&r)try{const n=ra(r,e.state.rpcMethodTracker,200).then((e=>({type:sa.RPC_CHECK,result:e}))),o=(()=>Be(this,void 0,void 0,(function*(){const t=yield(e=>Be(void 0,[e],void 0,(function*({rpcId:e,instance:t}){for(;t.state.lastRpcId===e||void 0===t.state.lastRpcId;)yield na(200);return t.state.lastRpcId})))({instance:e,rpcId:r}),n=yield ra(t,e.state.rpcMethodTracker,200);return{type:sa.SKIPPED_RPC,result:n}})))(),s=yield Promise.race([n,o]);if(s.type===sa.RPC_CHECK){const e=s.result;Is.SocketService(`[SocketService:handleRpcReplies()] id=${t.id} ${i} ( ${e.elapsedTime} ms)`,e.result)}else{if(s.type!==sa.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${r}`);{const t=Object.assign(Object.assign({},e.state.rpcMethodTracker[r]),{error:new Error("SDK_CONNECTION_ISSUE")});e.emit(Gs.RPC_UPDATE,t);const n={data:Object.assign(Object.assign({},t),{jsonrpc:"2.0"}),name:"metamask-provider"};e.emit(Gs.MESSAGE,{message:n})}}}catch(e){throw e}}))}(e,t).catch((e=>{})),o}))}(this,e)}))}ping(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n;Is.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`),null===(n=e.state.socket)||void 0===n||n.emit(Js.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})}))}(this)}pause(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n;Is.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,(null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged())&&(yield e.sendMessage({type:Js.PAUSE})),null===(n=e.state.socket)||void 0===n||n.disconnect()}))}(this)}isConnected(){var e;return null===(e=this.state.socket)||void 0===e?void 0:e.connected}resume(){return function(e){return Be(this,void 0,void 0,(function*(){const{state:t,remote:n}=e,{socket:r,channelId:i,context:o,keyExchange:s,isOriginator:a}=t,{isOriginator:c}=n.state;if(Is.SocketService(`[SocketService: resume()] channelId=${i} context=${o} connected=${null==r?void 0:r.connected} manualDisconnect=${t.manualDisconnect} resumed=${t.resumed} keysExchanged=${null==s?void 0:s.areKeysExchanged()}`),!i)throw Is.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");(null==r?void 0:r.connected)?(Is.SocketService("[SocketService: resume()] already connected."),r.emit(Js.PING,{id:i,clientType:c?"dapp":"wallet",context:"on_channel_config",message:""}),n.hasRelayPersistence()||(null==s?void 0:s.areKeysExchanged())||(a?yield e.sendMessage({type:Js.READY}):null==s||s.start({isOriginator:!1}))):(null==r||r.connect(),Is.SocketService(`[SocketService: resume()] after connecting socket --\x3e connected=${null==r?void 0:r.connected}`),null==r||r.emit(Gs.JOIN_CHANNEL,{channelId:i,context:`${o}_resume`,clientType:c?"dapp":"wallet"},((t,n)=>Be(this,void 0,void 0,(function*(){try{yield ta(e,t,n)}catch(e){}}))))),t.manualDisconnect=!1,t.resumed=!0}))}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(e,t){var n,r,i,o,s;Is.SocketService(`[SocketService: disconnect()] context=${e.state.context}`,t),(null==t?void 0:t.terminate)&&(null===(r=(n=e.state).removeFocusListener)||void 0===r||r.call(n),e.state.channelId=t.channelId,null===(i=e.state.socket)||void 0===i||i.removeAllListeners(),null===(o=e.state.keyExchange)||void 0===o||o.clean(),e.remote.state.ready=!1,e.state.socket=void 0,e.state.rpcMethodTracker={}),e.state.manualDisconnect=!0,null===(s=e.state.socket)||void 0===s||s.disconnect()}(this,e)}}var ha,fa,pa;function ga(e){return()=>Be(this,void 0,void 0,(function*(){var t,n,r;const{state:i}=e;if(i.authorized)return;yield(()=>Be(this,void 0,void 0,(function*(){for(;!i.walletInfo;)yield na(500)})))();const o="7.3".localeCompare((null===(t=i.walletInfo)||void 0===t?void 0:t.version)||"");if(Is.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${null===(n=i.walletInfo)||void 0===n?void 0:n.version} compareValue=${o}`),1!==o)return;const s=i.platformType===fa.MobileWeb||i.platformType===fa.ReactNative||i.platformType===fa.MetaMaskMobileWebview;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${s} channel=${i.channelId} walletVersion=${null===(r=i.walletInfo)||void 0===r?void 0:r.version}`),s&&(i.authorized=!0,e.emit(Gs.AUTHORIZED))}))}function ma(e){return t=>{const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${t}`),e.emit(Gs.CHANNEL_CREATED,t)}}function ya(e,t){return()=>{var n,r,i,o;const{state:s}=e;Is.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${s.channelId} keysExchanged=${null===(r=null===(n=s.communicationLayer)||void 0===n?void 0:n.getKeyInfo())||void 0===r?void 0:r.keysExchanged}`),s.analytics&&$s(Object.assign(Object.assign({id:null!==(i=s.channelId)&&void 0!==i?i:"",event:s.reconnection?Xs.RECONNECT:s.isOriginator?Xs.REQUEST:Xs.REQUEST_MOBILE},s.originatorInfo),{commLayer:t,sdkVersion:s.sdkVersion,walletVersion:null===(o=s.walletInfo)||void 0===o?void 0:o.version,commLayerVersion:Ks.version}),s.communicationServerUrl).catch((e=>{})),s.clientsConnected=!0,s.originatorInfoSent=!1,e.emit(Gs.CLIENTS_CONNECTED)}}function va(e){return t=>{const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${t}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),e.emit(Gs.CLIENTS_DISCONNECTED,n.channelId),e.setConnectionStatus(Ws.DISCONNECTED)}}function ba(e){return t=>{var n;const{state:r}=e;if(Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${t} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),e.setConnectionStatus(Ws.WAITING),e.emit(Gs.CLIENTS_WAITING,t),r.originatorConnectStarted){Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const t=(null===(n=r.autoConnectOptions)||void 0===n?void 0:n.timeout)||3e3,i=setTimeout((()=>{Is.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${t}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||e.setConnectionStatus(Ws.TIMEOUT),clearTimeout(i)}),t)}}}function wa(e,t){return n=>{var r,i,o,s,a,c,l,d;const{state:u}=e;if(Is.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${u.context} on commLayer.'keys_exchanged' channel=${u.channelId}`,n),null===(i=null===(r=u.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.keysExchanged){const t=Object.assign(Object.assign({},u.channelConfig),{channelId:null!==(o=u.channelId)&&void 0!==o?o:"",validUntil:(null===(s=u.channelConfig)||void 0===s?void 0:s.validUntil)||Hs,localKey:u.communicationLayer.getKeyInfo().ecies.private,otherKey:u.communicationLayer.getKeyInfo().ecies.otherPubKey});null===(a=u.storageManager)||void 0===a||a.persistChannelConfig(t).catch((e=>{})),e.setConnectionStatus(Ws.LINKED)}!function(e,t){var n,r,i,o,s,a,c,l;const{state:d}=e;Is.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${d.channelId}`,t);const u=Object.assign(Object.assign({},d.channelConfig),{channelId:null!==(n=d.channelId)&&void 0!==n?n:"",validUntil:null!==(i=null===(r=d.channelConfig)||void 0===r?void 0:r.validUntil)&&void 0!==i?i:0,relayPersistence:d.relayPersistence,localKey:null===(s=null===(o=d.communicationLayer)||void 0===o?void 0:o.state.keyExchange)||void 0===s?void 0:s.getKeyInfo().ecies.private,otherKey:null===(c=null===(a=d.communicationLayer)||void 0===a?void 0:a.state.keyExchange)||void 0===c?void 0:c.getKeyInfo().ecies.otherPubKey,lastActive:t.getTime()});null===(l=d.storageManager)||void 0===l||l.persistChannelConfig(u)}(e,new Date),u.analytics&&u.channelId&&$s(Object.assign(Object.assign({id:u.channelId,event:n.isOriginator?Xs.CONNECTED:Xs.CONNECTED_MOBILE},u.originatorInfo),{sdkVersion:u.sdkVersion,commLayer:t,commLayerVersion:Ks.version,walletVersion:null===(c=u.walletInfo)||void 0===c?void 0:c.version}),u.communicationServerUrl).catch((e=>{})),u.isOriginator=n.isOriginator,n.isOriginator||(null===(l=u.communicationLayer)||void 0===l||l.sendMessage({type:Js.READY}),u.ready=!0,u.paused=!1),n.isOriginator&&!u.originatorInfoSent&&(null===(d=u.communicationLayer)||void 0===d||d.sendMessage({type:Js.ORIGINATOR_INFO,originatorInfo:u.originatorInfo,originator:u.originatorInfo}),u.originatorInfoSent=!0)}}function Ea(e){return t=>{let n=t;t.message&&(n=n.message),function(e,t){const{state:n}=t;if(Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${n.context} on 'message' typeof=${typeof e}`,e),t.state.ready=!0,n.isOriginator||e.type!==Js.ORIGINATOR_INFO)if(n.isOriginator&&e.type===Js.WALLET_INFO)!function(e,t){const{state:n}=e;n.walletInfo=t.walletInfo,n.paused=!1}(t,e);else{if(n.isOriginator&&e.type===Js.WALLET_INIT)(function(e,t){return Be(this,void 0,void 0,(function*(){var n,r,i;const{state:o}=e;if(o.isOriginator){const o=t.data||{};if("object"==typeof o&&"accounts"in o&&"chainId"in o&&"walletKey"in o)try{const{channelConfig:t}=e.state;if(Is.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(t,null,2)),t){const s=o.accounts,a=o.chainId,c=o.walletKey;let l,d=!1;"deeplinkProtocol"in o&&(d=Boolean(o.deeplinkProtocol),e.state.deeplinkProtocolAvailable=d),"walletVersion"in o&&(l=o.walletVersion),yield null===(n=e.state.storageManager)||void 0===n?void 0:n.persistChannelConfig(Object.assign(Object.assign({},t),{otherKey:c,walletVersion:l,deeplinkProtocolAvailable:d,relayPersistence:!0})),yield null===(r=e.state.storageManager)||void 0===r?void 0:r.persistAccounts(s),yield null===(i=e.state.storageManager)||void 0===i?void 0:i.persistChainId(a)}e.emit(Gs.WALLET_INIT,{accounts:o.accounts,chainId:o.chainId})}catch(n){}}}))})(t,e).catch((e=>{Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Js.TERMINATE)(function(e){return Be(this,void 0,void 0,(function*(){const{state:t}=e;t.isOriginator&&(yield xa({options:{terminate:!0,sendMessage:!1},instance:e}),e.emit(Gs.TERMINATE))}))})(t).catch((e=>{Is.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Js.PAUSE)!function(e){const{state:t}=e;t.paused=!0,e.setConnectionStatus(Ws.PAUSED)}(t);else if(e.type===Js.READY&&n.isOriginator)!function(e){const{state:t}=e;e.setConnectionStatus(Ws.LINKED);const n=t.paused;t.paused=!1,e.emit(Gs.CLIENTS_READY,{isOriginator:t.isOriginator,walletInfo:t.walletInfo}),n&&(t.authorized=!0,e.emit(Gs.AUTHORIZED))}(t);else{if(e.type===Js.OTP&&n.isOriginator)return void function(e,t){var n;const{state:r}=e;e.emit(Gs.OTP,t.otpAnswer),1==="6.6".localeCompare((null===(n=r.walletInfo)||void 0===n?void 0:n.version)||"")&&e.emit(Gs.SDK_RPC_CALL,{method:qs.ETH_REQUESTACCOUNTS,params:[]})}(t,e);e.type===Js.AUTHORIZED&&n.isOriginator&&function(e){const{state:t}=e;t.authorized=!0,e.emit(Gs.AUTHORIZED)}(t)}t.emit(Gs.MESSAGE,e)}else!function(e,t){var n;const{state:r}=e;null===(n=r.communicationLayer)||void 0===n||n.sendMessage({type:Js.WALLET_INFO,walletInfo:r.walletInfo}),r.originatorInfo=t.originatorInfo||t.originator,e.emit(Gs.CLIENTS_READY,{isOriginator:r.isOriginator,originatorInfo:r.originatorInfo}),r.paused=!1}(t,e)}(n,e)}}function Ca(e){return()=>{const{state:t}=e;Is.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),t.ready=!1,t.authorized=!1,Vs(t),e.emitServiceStatusEvent({context:"socket_reconnect"})}}function _a(e){return()=>{const{state:t}=e;Is.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),t.ready=!1}}function Sa(e){return()=>Be(this,void 0,void 0,(function*(){var t,n,r,i,o,s,a;const{state:c}=e;Is.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),e.state.ready=!0,e.state.clientsConnected=!0,e.state.authorized=!0,e.state.relayPersistence=!0,null===(t=e.state.communicationLayer)||void 0===t||t.getKeyExchange().setKeysExchanged(!0),e.emit(Gs.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),e.emit(Gs.AUTHORIZED),e.emit(Gs.CLIENTS_READY),e.emit(Gs.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:null===(n=c.communicationLayer)||void 0===n?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:null===(r=c.communicationLayer)||void 0===r?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:null!==(i=c.channelId)&&void 0!==i?i:"",validUntil:null!==(s=null===(o=c.channelConfig)||void 0===o?void 0:o.validUntil)&&void 0!==s?s:Hs,relayPersistence:!0}),yield null===(a=c.storageManager)||void 0===a?void 0:a.persistChannelConfig(c.channelConfig)}catch(t){}}))}function ka({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,ecies:r,communicationServerUrl:i=Us,instance:o}){var s,a,c,l,d,u,h,f,p,g,m;const{state:y}=o;if(Is.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(y,null,2)),e!==ha.SOCKET)throw new Error("Invalid communication protocol");y.communicationLayer=new ua({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,transports:y.transports,communicationServerUrl:i,context:y.context,ecies:r,logging:y.logging,remote:o});let v="undefined"!=typeof document&&document.URL||"",b="undefined"!=typeof document&&document.title||"";(null===(s=y.dappMetadata)||void 0===s?void 0:s.url)&&(v=y.dappMetadata.url),(null===(a=y.dappMetadata)||void 0===a?void 0:a.name)&&(b=y.dappMetadata.name);const w=null!==(u=null!==(l=null===(c=y.dappMetadata)||void 0===c?void 0:c.name)&&void 0!==l?l:null===(d=y.dappMetadata)||void 0===d?void 0:d.url)&&void 0!==u?u:"N/A",E="undefined"!=typeof window&&void 0!==window.location&&null!==(h=window.location.hostname)&&void 0!==h?h:w,C={url:v,title:b,source:null===(f=y.dappMetadata)||void 0===f?void 0:f.source,dappId:E,icon:(null===(p=y.dappMetadata)||void 0===p?void 0:p.iconUrl)||(null===(g=y.dappMetadata)||void 0===g?void 0:g.base64Icon),platform:y.platformType,apiVersion:Ks.version,connector:null===(m=y.dappMetadata)||void 0===m?void 0:m.connector};y.originatorInfo=C;const _={[Gs.AUTHORIZED]:ga(o),[Gs.MESSAGE]:Ea(o),[Gs.CHANNEL_PERSISTENCE]:Sa(o),[Gs.CLIENTS_CONNECTED]:ya(o,e),[Gs.KEYS_EXCHANGED]:wa(o,e),[Gs.SOCKET_DISCONNECTED]:_a(o),[Gs.SOCKET_RECONNECT]:Ca(o),[Gs.CLIENTS_DISCONNECTED]:va(o),[Gs.KEY_INFO]:()=>{},[Gs.CHANNEL_CREATED]:ma(o),[Gs.CLIENTS_WAITING]:ba(o),[Gs.RPC_UPDATE]:e=>{o.emit(Gs.RPC_UPDATE,e)}};for(const[t,n]of Object.entries(_))try{y.communicationLayer.on(t,n)}catch(e){}}function xa(e){return Be(this,arguments,void 0,(function*({options:e,instance:n}){const{state:r}=n;return Is.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${r.channelId}`,e),new Promise(((i,o)=>{var s,a,c,l,d,u;(null==e?void 0:e.terminate)?(n.state.ready&&$s({id:null!==(s=n.state.channelId)&&void 0!==s?s:"",event:Xs.TERMINATED},n.state.communicationServerUrl).catch((e=>{})),r.ready=!1,r.paused=!1,null===(a=r.storageManager)||void 0===a||a.terminate(null!==(c=r.channelId)&&void 0!==c?c:""),n.state.terminated=!0,e.sendMessage?(null===(l=r.communicationLayer)||void 0===l?void 0:l.getKeyInfo().keysExchanged)&&n.state.communicationLayer&&oa(n.state.communicationLayer,{type:Js.TERMINATE}).then((()=>{i(!0)})).catch((e=>{o(e)})):i(!0),r.authorized=!1,r.relayPersistence=!1,r.channelId=t.v4(),e.channelId=r.channelId,r.channelConfig=void 0,r.originatorConnectStarted=!1,null===(d=r.communicationLayer)||void 0===d||d.disconnect(e),n.setConnectionStatus(Ws.TERMINATED)):(null===(u=r.communicationLayer)||void 0===u||u.disconnect(e),n.setConnectionStatus(Ws.DISCONNECTED),i(!0))}))}))}(ha||(ha={})).SOCKET="socket",function(e){e.NonBrowser="nodejs",e.MetaMaskMobileWebview="in-app-browser",e.DesktopWeb="web-desktop",e.MobileWeb="web-mobile",e.ReactNative="react-native"}(fa||(fa={}));class Aa extends h.exports.EventEmitter2{constructor(e){super(),this.state={ready:!1,authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:Us,context:"",persist:!1,clientsConnected:!1,sessionDuration:Hs,originatorConnectStarted:!1,debug:!1,_connectionStatus:Ws.DISCONNECTED},this._options=e;const{platformType:t,communicationLayerPreference:n,otherPublicKey:r,reconnect:i,walletInfo:o,dappMetadata:s,protocolVersion:a,transports:c,context:l,relayPersistence:d,ecies:h,analytics:f=!1,storage:p,sdkVersion:g,communicationServerUrl:m=Us,logging:y,autoConnect:v={timeout:zs}}=e;this.state.otherPublicKey=r,this.state.dappMetadata=s,this.state.walletInfo=o,this.state.transports=c,this.state.platformType=t,this.state.analytics=f,this.state.protocolVersion=null!=a?a:1,this.state.isOriginator=!r,this.state.relayPersistence=d,this.state.communicationServerUrl=m,this.state.context=l,this.state.terminated=!1,this.state.sdkVersion=g,this.setMaxListeners(50),this.setConnectionStatus(Ws.DISCONNECTED),(null==p?void 0:p.duration)&&(this.state.sessionDuration=Hs),this.state.storageOptions=p,this.state.autoConnectOptions=v,this.state.debug=!0===(null==y?void 0:y.remoteLayer),!0===(null==y?void 0:y.remoteLayer)&&u.enable("RemoteCommunication:Layer"),!0===(null==y?void 0:y.serviceLayer)&&u.enable("SocketService:Layer"),!0===(null==y?void 0:y.eciesLayer)&&u.enable("ECIES:Layer"),!0===(null==y?void 0:y.keyExchangeLayer)&&u.enable("KeyExchange:Layer"),this.state.logging=y,(null==p?void 0:p.storageManager)&&(this.state.storageManager=p.storageManager),Is.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${a} relayPersistence=${d} isOriginator=${this.state.isOriginator} communicationLayerPreference=${n} otherPublicKey=${r} reconnect=${i}`),this.state.isOriginator||ka({communicationLayerPreference:n,otherPublicKey:r,reconnect:i,ecies:h,communicationServerUrl:m,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return Be(this,void 0,void 0,(function*(){var e;if(this.state.storageManager){const t=yield this.state.storageManager.getPersistedChannelConfig({});t&&(this.state.channelConfig=t,this.state.channelId=t.channelId,this.state.deeplinkProtocolAvailable=null!==(e=t.deeplinkProtocolAvailable)&&void 0!==e&&e,t.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(Ws.LINKED),yield this.connectToChannel({channelId:t.channelId})))}ka({communicationLayerPreference:ha.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return Be(this,void 0,void 0,(function*(){return yield function(e){return Be(this,void 0,void 0,(function*(){var t;const{state:n}=e;if(!n.storageManager)return void Is.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const r=yield n.storageManager.getPersistedChannelConfig({});if(Is.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${n.originatorConnectStarted} channelConfig`,r),null===(t=n.communicationLayer)||void 0===t?void 0:t.isConnected())return Is.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),r;if(r){if(r.validUntil>Date.now())return n.channelConfig=r,n.originatorConnectStarted=!0,n.channelId=null==r?void 0:r.channelId,n.reconnection=!0,r;Is.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}n.originatorConnectStarted=!1}))}(this)}))}generateChannelIdConnect(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t,n,r,i,o,s;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(null===(t=e.communicationLayer)||void 0===t?void 0:t.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),null===(n=e.storageManager)||void 0===n||n.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:null===(i=null===(r=e.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.ecies.private,pubKey:null===(s=null===(o=e.communicationLayer)||void 0===o?void 0:o.getKeyInfo())||void 0===s?void 0:s.ecies.public};Is.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const a=yield e.communicationLayer.createChannel();Is.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",a);const c=Object.assign(Object.assign({},e.channelConfig),{channelId:a.channelId,localKey:a.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=a.channelId,e.channelConfig=c,{channelId:e.channelId,pubKey:a.pubKey,privKey:a.privKey}}))}(this.state)}))}clean(){return Vs(this.state)}connectToChannel({channelId:e,withKeyExchange:n,authorized:r}){return function(e){return Be(this,arguments,void 0,(function*({channelId:e,withKeyExchange:n,authorized:r,state:i}){var o,s,a;if(!t.validate(e))throw Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} channelId=${e} withKeyExchange=${n}`),null===(o=i.communicationLayer)||void 0===o?void 0:o.isConnected())return void Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} already connected - interrupt connection.`);i.channelId=e,yield null===(s=i.communicationLayer)||void 0===s?void 0:s.connectToChannel({channelId:e,authorized:r,withKeyExchange:n});const c=Object.assign(Object.assign({},i.channelConfig),{channelId:e,validUntil:Date.now()+i.sessionDuration});i.channelConfig=c,null===(a=i.storageManager)||void 0===a||a.persistChannelConfig(c)}))}({channelId:e,authorized:r,withKeyExchange:n,state:this.state})}sendMessage(e){return function(e,t){return Be(this,void 0,void 0,(function*(){var n,r;const{state:i}=e;Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} paused=${i.paused} ready=${i.ready} relayPersistence=${i.relayPersistence} authorized=${i.authorized} socket=${null===(n=i.communicationLayer)||void 0===n?void 0:n.isConnected()} clientsConnected=${i.clientsConnected} status=${i._connectionStatus}`,t),i.relayPersistence||i.ready&&(null===(r=i.communicationLayer)||void 0===r?void 0:r.isConnected())&&i.clientsConnected||(Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((t=>{e.once(Gs.CLIENTS_READY,t)})),Is.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} AFTER SKIP / READY -- sending pending message`));try{const n=yield function(e,t){return Be(this,void 0,void 0,(function*(){return new Promise((n=>{var r;const{state:i}=e;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} ready=${i.ready} authorized=${i.authorized} method=${t.method}`),!i.isOriginator||i.authorized||i.relayPersistence?null===(r=i.communicationLayer)||void 0===r||r.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)})):e.once(Gs.AUTHORIZED,(()=>{var e;Is.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} AFTER SKIP / AUTHORIZED -- sending pending message`),null===(e=i.communicationLayer)||void 0===e||e.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)}))}))}))}))}(e,t);return n}catch(e){throw e}}))}(this,e)}testStorage(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t;const n=yield null===(t=e.storageManager)||void 0===t?void 0:t.getPersistedChannelConfig();Is.RemoteCommunication("[RemoteCommunication: testStorage()] res",n)}))}(this.state)}))}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return Be(this,void 0,void 0,(function*(){var e;Is.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.ping()}))}testLogger(){Is.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),Is.SocketService(`testLogger() channel=${this.state.channelId}`),Is.Ecies(`testLogger() channel=${this.state.channelId}`),Is.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;Is.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),null===(e=this.state.communicationLayer)||void 0===e||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(Gs.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(Gs.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getKeyInfo()}resetKeys(){var e;null===(e=this.state.communicationLayer)||void 0===e||e.resetKeys()}setOtherPublicKey(e){var t;const n=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange();if(!n)throw new Error("KeyExchange is not initialized.");n.getOtherPublicKey()!==e&&n.setOtherPublicKey(e)}pause(){return Be(this,void 0,void 0,(function*(){var e;Is.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.pause(),this.setConnectionStatus(Ws.PAUSED)}))}getVersion(){return Ks.version}hasRelayPersistence(){var e;return null!==(e=this.state.relayPersistence)&&void 0!==e&&e}resume(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){var t;const{state:n}=e;Is.RemoteCommunication(`[RemoteCommunication: resume()] channel=${n.channelId}`),yield null===(t=n.communicationLayer)||void 0===t?void 0:t.resume(),e.setConnectionStatus(Ws.LINKED)}))}(this)}))}encrypt(e){var t,n,r;const i=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange(),o=null==i?void 0:i.getOtherPublicKey();if(!o)throw new Error("KeyExchange not completed");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.encrypt(e,o)}decrypt(e){var t,n,r;if(!(null===(t=this.state.communicationLayer)||void 0===t?void 0:t.state.eciesInstance))throw new Error("ECIES instance is not initialized");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return function(e){return Be(this,arguments,void 0,(function*({channelId:e,state:n}){var r,i,o;if(!t.validate(e))throw Is.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${n.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(n.isOriginator)return void Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} isOriginator=${n.isOriginator} channelId=${e}`);const{socket:s}=null!==(i=null===(r=n.communicationLayer)||void 0===r?void 0:r.state)&&void 0!==i?i:{};(null==s?void 0:s.connected)||(Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket already connected`),null==s||s.connect()),$s(Object.assign(Object.assign({id:e,event:Xs.REJECTED},n.originatorInfo),{sdkVersion:n.sdkVersion,commLayerVersion:Ks.version,walletVersion:null===(o=n.walletInfo)||void 0===o?void 0:o.version}),n.communicationServerUrl).catch((e=>{})),yield new Promise(((t,r)=>{null==s||s.emit(Gs.REJECTED,{channelId:e},((e,i)=>{Is.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket=${null==s?void 0:s.id}`,{error:e,response:i}),e?r(e):t(i)}))}))}))}({channelId:e,state:this.state})}disconnect(e){return Be(this,void 0,void 0,(function*(){return xa({options:e,instance:this})}))}}!function(e){e.RENEW="renew",e.LINK="link"}(pa||(pa={}));var Ma="ERC721",La="ERC1155",Oa={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`MetaMask: Connected to chain with ID "${e}".`},warnings:{chainIdDeprecation:"MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",networkVersionDeprecation:"MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",selectedAddressDeprecation:"MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",enableDeprecation:"MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102",sendDeprecation:"MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193",events:{close:"MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect",data:"MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message",networkChanged:"MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged",notification:"MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message"},rpc:{ethDecryptDeprecation:"MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",ethGetEncryptionPublicKeyDeprecation:"MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",walletWatchAssetNFTExperimental:"MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle"},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function Ta(e){const t={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{t.ethDecryptDeprecation||"eth_decrypt"!==n.method?t.ethGetEncryptionPublicKeyDeprecation||"eth_getEncryptionPublicKey"!==n.method?!t.walletWatchAssetNFTExperimental&&"wallet_watchAsset"===n.method&&[Ma,La].includes(n.params?.type||"")&&(e.warn(Oa.warnings.rpc.walletWatchAssetNFTExperimental),t.walletWatchAssetNFTExperimental=!0):(e.warn(Oa.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),t.ethGetEncryptionPublicKeyDeprecation=!0):(e.warn(Oa.warnings.rpc.ethDecryptDeprecation),t.ethDecryptDeprecation=!0),i()}}var Ra=4294967295,Pa=Math.floor(Math.random()*Ra);var Ia=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Na=(e,t,n)=>(Ia(e,t,"read from private field"),n?n.call(e):t.get(e)),Ba=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Da=(e,t,n,r)=>(Ia(e,t,"write to private field"),t.set(e,n),n),$a=(e,t,n)=>(Ia(e,t,"access private method"),n),ja=-32600,Ka=-32603,Ua={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function Fa(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}var Ha=(e,t)=>Object.hasOwnProperty.call(e,t);class za extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...o}=e,{path:s}=e,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function qa(e){return"object"==typeof e&&null!=e}function Va(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Wa(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=n,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Va(r)}\``}=e;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Ga(e,t,n,r){(function(e){return qa(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Wa(i,t,n,r);e&&(yield e)}}function*Ya(e,t,n={}){const{path:r=[],branch:i=[e],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&qa(t.schema)&&qa(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,a))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[l,d,u]of t.entries(e,a)){const t=Ya(d,u,{path:void 0===l?r:[...r,l],branch:void 0===l?i:[...i,d],coerce:o,mask:s,message:n.message});for(const n of t)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):o&&(d=n[1],void 0===l?e=d:e instanceof Map?e.set(l,d):e instanceof Set?e.add(d):qa(e)&&(void 0!==d||l in e)&&(e[l]=d))}if("not_valid"!==c)for(const r of t.refiner(e,a))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class Za{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:s=function*(){}}=e;this.type=t,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(e,t)=>Ga(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Ga(i(e,t),t,this,e):()=>[]}assert(e,t){return Ja(e,this,t)}create(e,t){return Xa(e,this,t)}is(e){return Qa(e,this)}mask(e,t){return function(e,t,n){const r=ec(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return ec(e,this,t)}}function Ja(e,t,n){const r=ec(e,t,{message:n});if(r[0])throw r[0]}function Xa(e,t,n){const r=ec(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function Qa(e,t){return!ec(e,t)[0]}function ec(e,t,n={}){const r=Ya(e,t,n),i=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(i[0]){return[new za(i[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}function tc(e,t){return new Za({type:e,schema:null,validator:t})}function nc(e){let t;return new Za({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function rc(e){return new Za({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Va(e)}`})}function ic(e){const t=Va(e),n=typeof e;return new Za({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${Va(n)}`})}function oc(){return tc("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Va(e)}`))}function sc(e){const t=e?Object.keys(e):[],n=tc("never",(()=>!1));return new Za({type:"object",schema:e||null,*entries(r){if(e&&qa(r)){const i=new Set(Object.keys(r));for(const n of t)i.delete(n),yield[n,r[n],e[n]];for(const e of i)yield[e,r[e],n]}},validator:e=>qa(e)||`Expected an object, but received: ${Va(e)}`,coercer:e=>qa(e)?{...e}:e})}function ac(e){return new Za({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function cc(e,t){return new Za({type:"record",schema:null,*entries(n){if(qa(n))for(const r in n){const i=n[r];yield[r,r,e],yield[r,i,t]}},validator:e=>qa(e)||`Expected an object, but received: ${Va(e)}`})}function lc(){return tc("string",(e=>"string"==typeof e||`Expected a string, but received: ${Va(e)}`))}function dc(e){const t=e.map((e=>e.type)).join(" | ");return new Za({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const i=[];for(const t of e){const[...e]=Ya(n,t,r),[o]=e;if(!o[0])return[];for(const[t]of e)t&&i.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Va(n)}`,...i]}})}var uc=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};function hc(){throw new Error("setTimeout has not been defined")}function fc(){throw new Error("clearTimeout has not been defined")}var pc=hc,gc=fc;function mc(e){if(pc===setTimeout)return setTimeout(e,0);if((pc===hc||!pc)&&setTimeout)return pc=setTimeout,setTimeout(e,0);try{return pc(e,0)}catch(t){try{return pc.call(null,e,0)}catch(t){return pc.call(this,e,0)}}}"function"==typeof De.setTimeout&&(pc=setTimeout),"function"==typeof De.clearTimeout&&(gc=clearTimeout);var yc,vc=[],bc=!1,wc=-1;function Ec(){bc&&yc&&(bc=!1,yc.length?vc=yc.concat(vc):wc=-1,vc.length&&Cc())}function Cc(){if(!bc){var e=mc(Ec);bc=!0;for(var t=vc.length;t;){for(yc=vc,vc=[];++wc<t;)yc&&yc[wc].run();wc=-1,t=vc.length}yc=null,bc=!1,function(e){if(gc===clearTimeout)return clearTimeout(e);if((gc===fc||!gc)&&clearTimeout)return gc=clearTimeout,clearTimeout(e);try{return gc(e)}catch(t){try{return gc.call(null,e)}catch(t){return gc.call(this,e)}}}(e)}}function _c(e,t){this.fun=e,this.array=t}function Sc(){}_c.prototype.run=function(){this.fun.apply(null,this.array)};var kc=Sc,xc=Sc,Ac=Sc,Mc=Sc,Lc=Sc,Oc=Sc,Tc=Sc,Rc=De.performance||{},Pc=Rc.now||Rc.mozNow||Rc.msNow||Rc.oNow||Rc.webkitNow||function(){return(new Date).getTime()},Ic=new Date,Nc={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];vc.push(new _c(e,t)),1!==vc.length||bc||mc(Cc)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:kc,addListener:xc,once:Ac,off:Mc,removeListener:Lc,removeAllListeners:Oc,emit:Tc,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Pc.call(Rc),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ic)/1e3}},Bc=e=>sc(e);function Dc({path:e,branch:t}){const n=e[e.length-1];return Ha(t[t.length-2],n)}function $c(e){return new Za({...e,type:`optional ${e.type}`,validator:(t,n)=>!Dc(n)||e.validator(t,n),refiner:(t,n)=>!Dc(n)||e.refiner(t,n)})}var jc,Kc,Uc,Fc=dc([ic(null),tc("boolean",(e=>"boolean"==typeof e)),tc("finite number",(e=>Qa(e,oc())&&Number.isFinite(e))),lc(),rc(nc((()=>Fc))),cc(lc(),nc((()=>Fc)))]),Hc=(jc=Fc,Kc=tc("any",(()=>!0)),Uc=e=>(function(e,t,n="Assertion failed",r=uc){try{Ja(e,t)}catch(e){throw function(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}(r,`${n}: ${function(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}(e)}.`)}}(e,Fc),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))),new Za({...jc,coercer:(e,t)=>Qa(e,Kc)?jc.coercer(Uc(e),t):jc.coercer(e,t)}));function zc(e){try{return function(e){Xa(e,Hc)}(e),!0}catch{return!1}}var qc=ic("2.0"),Vc=function(e){return new Za({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}(dc([oc(),lc()])),Wc=Bc({code:tc("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${Va(e)}`)),message:lc(),data:$c(Hc),stack:$c(lc())}),Gc=dc([cc(lc(),Hc),rc(Hc)]),Yc=Bc({id:Vc,jsonrpc:qc,method:lc(),params:$c(Gc)}),Zc=Bc({jsonrpc:qc,method:lc(),params:$c(Gc)});function Jc(e){return Qa(e,Yc)}function Xc(e){return Qa(e,Wc)}sc({id:Vc,jsonrpc:qc,result:ac(tc("unknown",(()=>!0))),error:ac(Wc)}),dc([Bc({id:Vc,jsonrpc:qc,result:Hc}),Bc({id:Vc,jsonrpc:qc,error:Wc})]);var Qc="Unspecified error message. This is a bug, please report it.",el={code:Ka,message:nl(Ka)},tl="Unspecified server error.";function nl(e,t=Qc){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(Ha(Ua,t))return Ua[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return tl}return t}function rl(e,{fallbackError:t=el,shouldIncludeStack:n=!0}={}){if(!Xc(t))throw new Error("Must provide fallback error with integer number code and string message.");const r=function(e,t){if(e&&"object"==typeof e&&"serialize"in e&&"function"==typeof e.serialize)return e.serialize();if(Xc(e))return e;return{...t,data:{cause:il(e)}}}(e,t);return n||delete r.stack,r}function il(e){return Array.isArray(e)?e.map((e=>zc(e)?e:Fa(e)?ol(e):null)):Fa(e)?ol(e):zc(e)?e:null}function ol(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return zc(r)&&(t[n]=r),t}),{})}var sl=hl;hl.default=hl,hl.stable=ml,hl.stableStringify=ml;var al="[...]",cl="[Circular]",ll=[],dl=[];function ul(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function hl(e,t,n,r){var i;void 0===r&&(r=ul()),pl(e,"",0,[],void 0,0,r);try{i=0===dl.length?JSON.stringify(e,t,n):JSON.stringify(e,vl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ll.length;){var o=ll.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function fl(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:e}),ll.push([r,n,t,i])):dl.push([t,n,e]):(r[n]=e,ll.push([r,n,t]))}function pl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void fl(cl,e,t,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void fl(al,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void fl(al,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)pl(e[a],a,a,r,e,o,s);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var l=c[a];pl(e[l],l,a,r,e,o,s)}}r.pop()}}function gl(e,t){return e<t?-1:e>t?1:0}function ml(e,t,n,r){void 0===r&&(r=ul());var i,o=yl(e,"",0,[],void 0,0,r)||e;try{i=0===dl.length?JSON.stringify(o,t,n):JSON.stringify(o,vl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ll.length;){var s=ll.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function yl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void fl(cl,e,t,i);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void fl(al,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void fl(al,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)yl(e[a],a,a,r,e,o,s);else{var c={},l=Object.keys(e).sort(gl);for(a=0;a<l.length;a++){var d=l[a];yl(e[d],d,a,r,e,o,s),c[d]=e[d]}if(void 0===i)return c;ll.push([i,t,e]),i[t]=c}r.pop()}}function vl(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(dl.length>0)for(var r=0;r<dl.length;r++){var i=dl[r];if(i[1]===t&&i[0]===n){n=i[2],dl.splice(r,1);break}}return e.call(this,t,n)}}var bl=jt(sl),wl=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}}(this.data)&&(e.data.cause=il(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return bl(this.serialize(),El,2)}};function El(e,t){if("[Circular]"!==t)return t}var Cl=e=>function(e,t){const[n,r]=function(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}(t);return new wl(e,n??nl(e),r)}(ja,e);var _l={};function Sl(){}function kl(){kl.init.call(this)}function xl(e){return void 0===e._maxListeners?kl.defaultMaxListeners:e._maxListeners}function Al(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new Sl,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=xl(e))&&i>0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(a)}}else s=o[t]=n,++e._eventsCount;return e}function Ml(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Ll(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Ol(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}Sl.prototype=Object.create(null),kl.EventEmitter=kl,kl.usingDomains=!1,kl.prototype.domain=void 0,kl.prototype._events=void 0,kl.prototype._maxListeners=void 0,kl.defaultMaxListeners=10,kl.init=function(){this.domain=null,kl.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Sl,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kl.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},kl.prototype.getMaxListeners=function(){return xl(this)},kl.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var d="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Ol(e,r),o=0;o<r;++o)i[o].call(n)}(n,d,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=Ol(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,d,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=Ol(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=Ol(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=Ol(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,d,this,i)}return!0},kl.prototype.addListener=function(e,t){return Al(this,e,t,!1)},kl.prototype.on=kl.prototype.addListener,kl.prototype.prependListener=function(e,t){return Al(this,e,t,!0)},kl.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ml(this,e,t)),this},kl.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ml(this,e,t)),this},kl.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Sl:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Sl,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},kl.prototype.off=function(e,t){return this.removeListener(e,t)},kl.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Sl,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Sl:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Sl,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},kl.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},kl.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ll.call(e,t)},kl.prototype.listenerCount=Ll,kl.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Tl=Kt(Object.freeze({__proto__:null,EventEmitter:kl,default:kl}));Object.defineProperty(_l,"__esModule",{value:!0});const Rl=Tl;function Pl(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}let Il=class extends Rl.EventEmitter{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)Pl(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)Pl(n[r],this,t)}return!0}};var Nl,Bl,Dl,$l,jl,Kl,Ul,Fl,Hl,zl,ql,Vl,Wl,Gl,Yl,Zl,Jl,Xl,Ql,ed=_l.default=Il,td=class e extends ed{constructor({notificationHandler:e}={}){super(),Ba(this,$l),Ba(this,Kl),Ba(this,Fl),Ba(this,Nl,!1),Ba(this,Bl,void 0),Ba(this,Dl,void 0),Da(this,Bl,[]),Da(this,Dl,e)}destroy(){Na(this,Bl).forEach((e=>{"destroy"in e&&"function"==typeof e.destroy&&e.destroy()})),Da(this,Bl,[]),Da(this,Nl,!0)}push(e){$a(this,$l,jl).call(this),Na(this,Bl).push(e)}handle(e,t){if($a(this,$l,jl).call(this),t&&"function"!=typeof t)throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?t?$a(this,Kl,Ul).call(this,e,t):$a(this,Kl,Ul).call(this,e):t?$a(this,Fl,Hl).call(this,e,t):this._promiseHandle(e)}asMiddleware(){return $a(this,$l,jl).call(this),async(t,n,r,i)=>{var o,s;try{const[a,c,l]=await $a(o=e,Vl,Wl).call(o,t,n,Na(this,Bl));return c?(await $a(s=e,Zl,Jl).call(s,l),i(a)):r((async t=>{var n;try{await $a(n=e,Zl,Jl).call(n,l)}catch(e){return t(e)}return t()}))}catch(e){return i(e)}}}async _promiseHandle(e){return new Promise(((t,n)=>{$a(this,Fl,Hl).call(this,e,((e,r)=>{e&&void 0===r?n(e):t(r)})).catch(n)}))}};Nl=new WeakMap,Bl=new WeakMap,Dl=new WeakMap,$l=new WeakSet,jl=function(){if(Na(this,Nl))throw new Error("This engine is destroyed and can no longer be used.")},Kl=new WeakSet,Ul=async function(e,t){try{if(0===e.length){const e=[{id:null,jsonrpc:"2.0",error:new wl(ja,"Request batch must contain plain objects. Received an empty array")}];return t?t(null,e):e}const n=(await Promise.all(e.map(this._promiseHandle.bind(this)))).filter((e=>void 0!==e));return t?t(null,n):n}catch(e){if(t)return t(e);throw e}},Fl=new WeakSet,Hl=async function(e,t){var n;if(!e||Array.isArray(e)||"object"!=typeof e){const n=new wl(ja,"Requests must be plain objects. Received: "+typeof e,{request:e});return t(n,{id:null,jsonrpc:"2.0",error:n})}if("string"!=typeof e.method){const n=new wl(ja,"Must specify a string method. Received: "+typeof e.method,{request:e});return Na(this,Dl)&&!Jc(e)?t(null):t(n,{id:e.id??null,jsonrpc:"2.0",error:n})}if(Na(this,Dl)&&Qa(e,Zc)&&!Jc(e)){try{await Na(this,Dl).call(this,e)}catch(e){return t(e)}return t(null)}let r=null;const i={...e},o={id:i.id,jsonrpc:i.jsonrpc};try{await $a(n=td,zl,ql).call(n,i,o,Na(this,Bl))}catch(e){r=e}return r&&(delete o.result,o.error||(o.error=rl(r))),t(r,o)},zl=new WeakSet,ql=async function(e,t,n){var r,i,o;const[s,a,c]=await $a(r=td,Vl,Wl).call(r,e,t,n);if($a(i=td,Xl,Ql).call(i,e,t,a),await $a(o=td,Zl,Jl).call(o,c),s)throw s},Vl=new WeakSet,Wl=async function(e,t,n){var r;const i=[];let o=null,s=!1;for(const a of n)if([o,s]=await $a(r=td,Gl,Yl).call(r,e,t,a,i),s)break;return[o,s,i.reverse()]},Gl=new WeakSet,Yl=async function(e,t,n,r){return new Promise((i=>{const o=e=>{const n=e||t.error;n&&(t.error=rl(n)),i([n,!0])},s=n=>{t.error?o(t.error):(n&&("function"!=typeof n&&o(new wl(Ka,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof n}" for request:\n${rd(e)}`,{request:e})),r.push(n)),i([null,!1]))};try{n(e,t,s,o)}catch(e){o(e)}}))},Zl=new WeakSet,Jl=async function(e){for(const t of e)await new Promise(((e,n)=>{t((t=>t?n(t):e()))}))},Xl=new WeakSet,Ql=function(e,t,n){if(!Ha(t,"result")&&!Ha(t,"error"))throw new wl(Ka,`JsonRpcEngine: Response has no error or result for request:\n${rd(e)}`,{request:e});if(!n)throw new wl(Ka,`JsonRpcEngine: Nothing ended request:\n${rd(e)}`,{request:e})},Ba(td,zl),Ba(td,Vl),Ba(td,Gl),Ba(td,Zl),Ba(td,Xl);var nd=td;function rd(e){return JSON.stringify(e,null,2)}var id=Object.freeze(["eth_subscription"]),od=(e=console)=>[(e,t,n,r)=>{const i=e.id,o=Pa=(Pa+1)%Ra;e.id=o,t.id=o,n((n=>{e.id=i,t.id=i,n()}))},sd(e),Ta(e)];function sd(e){return(t,n,r)=>{"string"==typeof t.method&&t.method||(n.error=Cl({message:"The request 'method' must be a non-empty string.",data:t})),r((t=>{const{error:r}=n;return r?(e.error(`MetaMask - RPC Error: ${r.message}`,r),t()):t()}))}}var ad=(e,t,n=!0)=>(r,i)=>{r||i.error?t(r||i.error):!n||Array.isArray(i)?e(i):e(i.result)},cd=e=>Boolean(e)&&"string"==typeof e&&e.startsWith("0x"),ld=()=>{};async function dd(e,t){try{const t=await async function(){return{name:ud(window),icon:await hd(window)}}();e.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:t},ld)}catch(e){t.error({message:Oa.errors.sendSiteMetadata(),originalError:e})}}function ud(e){const{document:t}=e,n=t.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=t.querySelector('head > meta[name="title"]');return r?r.content:t.title&&t.title.length>0?t.title:window.location.hostname}async function hd(e){const{document:t}=e,n=t.querySelectorAll('head > link[rel~="icon"]');for(const e of Array.from(n))if(e&&await fd(e.href))return e.href;return null}async function fd(e){return new Promise(((t,n)=>{try{const n=document.createElement("img");n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e}catch(e){n(e)}}))}var pd=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},gd=(e,t,n)=>(pd(e,t,"read from private field"),n?n.call(e):t.get(e)),md=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},yd=(e,t,n,r)=>(pd(e,t,"write to private field"),t.set(e,n),n);function vd(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}class bd extends kl{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)vd(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)vd(n[r],this,t)}return!0}}var wd,Ed,Cd=jt((function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n})),_d=class e extends bd{constructor({logger:t=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),md(this,wd,void 0),md(this,Ed,void 0),this._log=t,this.setMaxListeners(n),this._state={...e._defaultState},yd(this,Ed,null),yd(this,wd,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new nd;r.forEach((e=>i.push(e))),this._rpcEngine=i}get chainId(){return gd(this,wd)}get selectedAddress(){return gd(this,Ed)}isConnected(){return this._state.isConnected}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw Cl({message:Oa.errors.invalidRequestArgs(),data:e});const{method:t,params:n}=e;if("string"!=typeof t||0===t.length)throw Cl({message:Oa.errors.invalidRequestMethod(),data:e});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw Cl({message:Oa.errors.invalidRequestParams(),data:e});const r=null==n?{method:t}:{method:t,params:n};return new Promise(((e,t)=>{this._rpcRequest(r,ad(e,t))}))}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:t,chainId:n,isUnlocked:r,networkVersion:i}=e;this._handleConnect(n),this._handleChainChanged({chainId:n,networkVersion:i}),this._handleUnlockStateChanged({accounts:t,isUnlocked:r}),this._handleAccountsChanged(t)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,t){let n=t;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),"eth_accounts"!==e.method&&"eth_requestAccounts"!==e.method||(n=(n,r)=>{this._handleAccountsChanged(r.result??[],"eth_accounts"===e.method),t(n,r)})),this._rpcEngine.handle(e,n)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(Oa.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let n;this._state.isConnected=!1,e?(n=new wl(1013,t??Oa.errors.disconnected()),this._log.debug(n)):(n=new wl(1011,t??Oa.errors.permanentlyDisconnected()),this._log.error(n),yd(this,wd,null),this._state.accounts=null,yd(this,Ed,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",n)}}_handleChainChanged({chainId:e}={}){cd(e)?(this._handleConnect(e),e!==gd(this,wd)&&(yd(this,wd,e),this._state.initialized&&this.emit("chainChanged",gd(this,wd)))):this._log.error(Oa.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,t=!1){let n=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),n=[]);for(const t of e)if("string"!=typeof t){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),n=[];break}if(!Cd(this._state.accounts,n)&&(t&&null!==this._state.accounts&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",n),this._state.accounts=n,gd(this,Ed)!==n[0]&&yd(this,Ed,n[0]||null),this._state.initialized)){const e=[...n];this.emit("accountsChanged",e)}}_handleUnlockStateChanged({accounts:e,isUnlocked:t}={}){"boolean"==typeof t?t!==this._state.isUnlocked&&(this._state.isUnlocked=t,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};wd=new WeakMap,Ed=new WeakMap,_d._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var Sd,kd,xd=_d,Ad={exports:{}};function Md(){return kd?Sd:(kd=1,Sd=Tl.EventEmitter)}var Ld,Od=Kt(Dt);Ld="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var Td=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},Rd=/%[sdj%]/g;function Pd(e){if(!Yd(e)){for(var t=[],n=0;n<arguments.length;n++)t.push($d(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(Rd,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])Vd(s)||!Qd(s)?o+=" "+s:o+=" "+$d(s);return o}function Id(e,t){if(Jd(De.process))return function(){return Id(e,t).apply(this,arguments)};if(!0===Nc.noDeprecation)return e;var n=!1;return function(){if(!n){if(Nc.throwDeprecation)throw new Error(t);Nc.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var Nd,Bd={};function Dd(e){return Jd(Nd)&&(Nd=Nc.env.NODE_DEBUG||""),e=e.toUpperCase(),Bd[e]||(new RegExp("\\b"+e+"\\b","i").test(Nd)?Bd[e]=function(){var t=Pd.apply(null,arguments);console.error("%s %d: %s",e,0,t)}:Bd[e]=function(){}),Bd[e]}function $d(e,t){var n={seen:[],stylize:Kd};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),qd(t)?n.showHidden=t:t&&lu(n,t),Jd(n.showHidden)&&(n.showHidden=!1),Jd(n.depth)&&(n.depth=2),Jd(n.colors)&&(n.colors=!1),Jd(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=jd),Ud(n,e,n.depth)}function jd(e,t){var n=$d.styles[t];return n?"["+$d.colors[n][0]+"m"+e+"["+$d.colors[n][1]+"m":e}function Kd(e,t){return e}function Ud(e,t,n){if(e.customInspect&&t&&nu(t.inspect)&&t.inspect!==$d&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return Yd(r)||(r=Ud(e,r,n)),r}var i=function(e,t){if(Jd(t))return e.stylize("undefined","undefined");if(Yd(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return Gd(t)?e.stylize(""+t,"number"):qd(t)?e.stylize(""+t,"boolean"):Vd(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),tu(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Fd(t);if(0===o.length){if(nu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Xd(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(eu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(tu(t))return Fd(t)}var c,l="",d=!1,u=["{","}"];return zd(t)&&(d=!0,u=["[","]"]),nu(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),Xd(t)&&(l=" "+RegExp.prototype.toString.call(t)),eu(t)&&(l=" "+Date.prototype.toUTCString.call(t)),tu(t)&&(l=" "+Fd(t)),0!==o.length||d&&0!=t.length?n<0?Xd(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)du(t,String(s))?o.push(Hd(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(Hd(e,t,n,r,i,!0))})),o}(e,t,n,s,o):o.map((function(r){return Hd(e,t,n,s,r,d)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,u)):u[0]+l+u[1]}function Fd(e){return"["+Error.prototype.toString.call(e)+"]"}function Hd(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),du(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Vd(n)?Ud(e,c.value,null):Ud(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),Jd(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function zd(e){return Array.isArray(e)}function qd(e){return"boolean"==typeof e}function Vd(e){return null===e}function Wd(e){return null==e}function Gd(e){return"number"==typeof e}function Yd(e){return"string"==typeof e}function Zd(e){return"symbol"==typeof e}function Jd(e){return void 0===e}function Xd(e){return Qd(e)&&"[object RegExp]"===ou(e)}function Qd(e){return"object"==typeof e&&null!==e}function eu(e){return Qd(e)&&"[object Date]"===ou(e)}function tu(e){return Qd(e)&&("[object Error]"===ou(e)||e instanceof Error)}function nu(e){return"function"==typeof e}function ru(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function iu(e){return Xe.isBuffer(e)}function ou(e){return Object.prototype.toString.call(e)}function su(e){return e<10?"0"+e.toString(10):e.toString(10)}$d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},$d.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var au=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function cu(){console.log("%s - %s",function(){var e=new Date,t=[su(e.getHours()),su(e.getMinutes()),su(e.getSeconds())].join(":");return[e.getDate(),au[e.getMonth()],t].join(" ")}(),Pd.apply(null,arguments))}function lu(e,t){if(!t||!Qd(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function du(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var uu="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function hu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(uu&&e[uu]){var t;if("function"!=typeof(t=e[uu]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,uu,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),uu&&Object.defineProperty(t,uu,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,Td(e))}function fu(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}function pu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if("function"!=typeof r)throw new TypeError("The last argument must be of type Function");var i=this,o=function(){return r.apply(i,arguments)};e.apply(this,t).then((function(e){Nc.nextTick(o.bind(null,null,e))}),(function(e){Nc.nextTick(fu.bind(null,e,o))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Td(e)),t}hu.custom=uu;var gu,mu,yu,vu,bu={inherits:Ld,_extend:lu,log:cu,isBuffer:iu,isPrimitive:ru,isFunction:nu,isError:tu,isDate:eu,isObject:Qd,isRegExp:Xd,isUndefined:Jd,isSymbol:Zd,isString:Yd,isNumber:Gd,isNullOrUndefined:Wd,isNull:Vd,isBoolean:qd,isArray:zd,inspect:$d,deprecate:Id,format:Pd,debuglog:Dd,promisify:hu,callbackify:pu},wu=Kt(Object.freeze({__proto__:null,_extend:lu,callbackify:pu,debuglog:Dd,default:bu,deprecate:Id,format:Pd,inherits:Ld,inspect:$d,isArray:zd,isBoolean:qd,isBuffer:iu,isDate:eu,isError:tu,isFunction:nu,isNull:Vd,isNullOrUndefined:Wd,isNumber:Gd,isObject:Qd,isPrimitive:ru,isRegExp:Xd,isString:Yd,isSymbol:Zd,isUndefined:Jd,log:cu,promisify:hu}));function Eu(){if(mu)return gu;function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}mu=1;var i=Od.Buffer,o=wu.inspect,s=o&&o.custom||"inspect";return gu=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return function(e,t,n){t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,o=i.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,r=a,i.prototype.copy.call(t,n,r),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=i.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,s),0==(e-=s)){s===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(s));break}++r}return this.length-=r,t}},{key:s,value:function(e,n){return o(this,t(t({},n),{},{depth:0,customInspect:!1}))}}]),e}(),gu}function Cu(){if(vu)return yu;function e(e,r){n(e,r),t(e)}function t(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}return vu=1,yu={destroy:function(r,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Nc.nextTick(n,this,r)):Nc.nextTick(n,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(n){!i&&n?o._writableState?o._writableState.errorEmitted?Nc.nextTick(t,o):(o._writableState.errorEmitted=!0,Nc.nextTick(e,o,n)):Nc.nextTick(e,o,n):i?(Nc.nextTick(t,o),i(n)):Nc.nextTick(t,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},yu}var _u,Su,ku={},xu={};function Au(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,xu[e]=r}function Mu(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function Lu(){if(Su)return _u;Su=1;var e=ku.codes.ERR_INVALID_OPT_VALUE;return _u={getHighWaterMark:function(t,n,r,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(n,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new e(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}}Au("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),Au("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,i,o;if("string"==typeof t&&(i="not ",t.substr(0,4)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))o="The ".concat(e," ").concat(r," ").concat(Mu(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+1>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(Mu(t,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),Au("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Au("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),Au("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Au("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),Au("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Au("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Au("ERR_STREAM_WRITE_AFTER_END","write after end"),Au("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Au("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),Au("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),ku.codes=xu;var Ou,Tu,Ru,Pu,Iu,Nu,Bu="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},Du=Kt(Object.freeze({__proto__:null,default:Bu}));function $u(){if(Tu)return Ou;function e(e){try{if(!$t.localStorage)return!1}catch(e){return!1}var t=$t.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}return Tu=1,Ou=function(t,n){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),r=!0}return t.apply(this,arguments)}},Ou}function ju(){if(Pu)return Ru;function e(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var t;Pu=1,Ru=E,E.WritableState=w;var n,r={deprecate:$u()},i=Md(),o=Od.Buffer,s=(void 0!==$t?$t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},a=Cu(),c=Lu().getHighWaterMark,l=ku.codes,d=l.ERR_INVALID_ARG_TYPE,u=l.ERR_METHOD_NOT_IMPLEMENTED,h=l.ERR_MULTIPLE_CALLBACK,f=l.ERR_STREAM_CANNOT_PIPE,p=l.ERR_STREAM_DESTROYED,g=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,y=l.ERR_UNKNOWN_ENCODING,v=a.errorOrDestroy;function b(){}function w(n,r,i){t=t||Ku(),n=n||{},"boolean"!=typeof i&&(i=r instanceof t),this.objectMode=!!n.objectMode,i&&(this.objectMode=this.objectMode||!!n.writableObjectMode),this.highWaterMark=c(this,n,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===n.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=n.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new h;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Nc.nextTick(i,r),Nc.nextTick(A,e,t),e._writableState.errorEmitted=!0,v(e,r)):(i(r),e._writableState.errorEmitted=!0,v(e,r),A(e,t))}(e,n,r,t,i);else{var o=k(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),r?Nc.nextTick(_,e,n,o,i):_(e,n,o,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==n.emitClose,this.autoDestroy=!!n.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function E(e){var r=this instanceof(t=t||Ku());if(!r&&!n.call(E,this))return new E(e);this._writableState=new w(e,this,r),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),i.call(this)}function C(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new p("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function _(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function S(t,n){n.bufferProcessing=!0;var r=n.bufferedRequest;if(t._writev&&r&&r.next){var i=n.bufferedRequestCount,o=new Array(i),s=n.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,C(t,n,!0,n.length,o,"",s.finish),n.pendingcb++,n.lastBufferedRequest=null,s.next?(n.corkedRequestsFree=s.next,s.next=null):n.corkedRequestsFree=new e(n),n.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,d=r.encoding,u=r.callback;if(C(t,n,!1,n.objectMode?1:l.length,l,d,u),r=r.next,n.bufferedRequestCount--,n.writing)break}null===r&&(n.lastBufferedRequest=null)}n.bufferedRequest=r,n.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&v(e,n),t.prefinished=!0,e.emit("prefinish"),A(e,t)}))}function A(e,t){var n=k(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Nc.nextTick(x,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}return Du(E,i),w.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(w.prototype,"buffer",{get:r.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!n.call(this,e)||this===E&&e&&e._writableState instanceof w}})):n=function(e){return e instanceof this},E.prototype.pipe=function(){v(this,new f)},E.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,c=!i.objectMode&&(r=e,o.isBuffer(r)||r instanceof s);return c&&!o.isBuffer(e)&&(e=function(e){return o.from(e)}(e)),"function"==typeof t&&(n=t,t=null),c?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=b),i.ending?function(e,t){var n=new m;v(e,n),Nc.nextTick(t,n)}(this,n):(c||function(e,t,n,r){var i;return null===n?i=new g:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(v(e,i),Nc.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,s){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var c=t.objectMode?1:r.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,c,r,i,s);return l}(this,i,c,e,t,n)),a},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||S(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new y(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,n){n(new u("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,A(e,t),n&&(t.finished?Nc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=a.destroy,E.prototype._undestroy=a.undestroy,E.prototype._destroy=function(e,t){t(e)},Ru}function Ku(){if(Nu)return Iu;Nu=1;var e=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};Iu=s;var t=nh(),n=ju();Du(s,t);for(var r=e(n.prototype),i=0;i<r.length;i++){var o=r[i];s.prototype[o]||(s.prototype[o]=n.prototype[o])}function s(e){if(!(this instanceof s))return new s(e);t.call(this,e),n.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",a)))}function a(){this._writableState.ended||Nc.nextTick(c,this)}function c(e){e.end()}return Object.defineProperty(s.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(s.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(s.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),Iu}var Uu=Xe.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Fu(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Uu(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=zu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=qu;break;default:return void(this.write=Hu)}this.charBuffer=new Xe(6),this.charReceived=0,this.charLength=0}function Hu(e){return e.toString(this.encoding)}function zu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function qu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Fu.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(e=e.slice(n,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),i=(t+=e.toString(this.encoding,0,i)).length-1,(r=t.charCodeAt(i))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},Fu.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},Fu.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};var Vu=Kt(Object.freeze({__proto__:null,StringDecoder:Fu})),Wu=ku.codes.ERR_STREAM_PREMATURE_CLOSE;function Gu(){}var Yu,Zu,Ju,Xu,Qu,eh,th=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||Gu);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){o=!1,a=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,d=function(){i=!1,l=!0,o||r.call(t)},u=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new Wu),r.call(t,e)):o&&!a?(t._writableState&&t._writableState.ended||(e=new Wu),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",c),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",s),t.on("close",s)),t.on("end",d),t.on("finish",c),!1!==n.error&&t.on("error",u),t.on("close",h),function(){t.removeListener("complete",c),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",d),t.removeListener("error",u),t.removeListener("close",h)}};function nh(){if(eh)return Qu;var e;eh=1,Qu=E,E.ReadableState=w,Tl.EventEmitter;var t,n=function(e,t){return e.listeners(t).length},r=Md(),i=Od.Buffer,o=(void 0!==$t?$t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},s=wu;t=s&&s.debuglog?s.debuglog("stream"):function(){};var a,c,l,d=Eu(),u=Cu(),h=Lu().getHighWaterMark,f=ku.codes,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_STREAM_PUSH_AFTER_EOF,m=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Du(E,r);var v=u.errorOrDestroy,b=["error","close","destroy","pause","resume"];function w(t,n,r){e=e||Ku(),t=t||{},"boolean"!=typeof r&&(r=n instanceof e),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=h(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(a||(a=Vu.StringDecoder),this.decoder=new a(t.encoding),this.encoding=t.encoding)}function E(t){if(e=e||Ku(),!(this instanceof E))return new E(t);var n=this instanceof e;this._readableState=new w(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),r.call(this)}function C(e,n,r,s,a){t("readableAddChunk",n);var c,l=e._readableState;if(null===n)l.reading=!1,function(e,n){if(t("onEofChunk"),!n.ended){if(n.decoder){var r=n.decoder.end();r&&r.length&&(n.buffer.push(r),n.length+=n.objectMode?1:r.length)}n.ended=!0,n.sync?x(e):(n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,A(e)))}}(e,l);else if(a||(c=function(e,t){var n,r;return r=t,i.isBuffer(r)||r instanceof o||"string"==typeof t||void 0===t||e.objectMode||(n=new p("chunk",["string","Buffer","Uint8Array"],t)),n}(l,n)),c)v(e,c);else if(l.objectMode||n&&n.length>0)if("string"==typeof n||l.objectMode||Object.getPrototypeOf(n)===i.prototype||(n=function(e){return i.from(e)}(n)),s)l.endEmitted?v(e,new y):_(e,l,n,!0);else if(l.ended)v(e,new g);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(n=l.decoder.write(n),l.objectMode||0!==n.length?_(e,l,n,!1):M(e,l)):_(e,l,n,!1)}else s||(l.reading=!1,M(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function _(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),M(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=u.destroy,E.prototype._undestroy=u.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=i.from(e,t),t=""),n=!0),C(this,e,t,!1,n)},E.prototype.unshift=function(e){return C(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){a||(a=Vu.StringDecoder);var t=new a(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var S=1073741824;function k(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var n=e._readableState;t("emitReadable",n.needReadable,n.emittedReadable),n.needReadable=!1,n.emittedReadable||(t("emitReadable",n.flowing),n.emittedReadable=!0,Nc.nextTick(A,e))}function A(e){var n=e._readableState;t("emitReadable_",n.destroyed,n.length,n.ended),n.destroyed||!n.length&&!n.ended||(e.emit("readable"),n.emittedReadable=!1),n.needReadable=!n.flowing&&!n.ended&&n.length<=n.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,Nc.nextTick(L,e,t))}function L(e,n){for(;!n.reading&&!n.ended&&(n.length<n.highWaterMark||n.flowing&&0===n.length);){var r=n.length;if(t("maybeReadMore read 0"),e.read(0),r===n.length)break}n.readingMore=!1}function O(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function T(e){t("readable nexttick read 0"),e.read(0)}function R(e,n){t("resume",n.reading),n.reading||e.read(0),n.resumeScheduled=!1,e.emit("resume"),P(e),n.flowing&&!n.reading&&e.read(0)}function P(e){var n=e._readableState;for(t("flow",n.flowing);n.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function N(e){var n=e._readableState;t("endReadable",n.endEmitted),n.endEmitted||(n.ended=!0,Nc.nextTick(B,n,e))}function B(e,n){if(t("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,n.readable=!1,n.emit("end"),e.autoDestroy)){var r=n._writableState;(!r||r.autoDestroy&&r.finished)&&n.destroy()}}function D(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}return E.prototype.read=function(e){t("read",e),e=parseInt(e,10);var n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&((0!==n.highWaterMark?n.length>=n.highWaterMark:n.length>0)||n.ended))return t("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?N(this):x(this),null;if(0===(e=k(e,n))&&n.ended)return 0===n.length&&N(this),null;var i,o=n.needReadable;return t("need readable",o),(0===n.length||n.length-e<n.highWaterMark)&&t("length less than watermark",o=!0),n.ended||n.reading?t("reading or ended",o=!1):o&&(t("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=k(r,n))),null===(i=e>0?I(e,n):null)?(n.needReadable=n.length<=n.highWaterMark,e=0):(n.length-=e,n.awaitDrain=0),0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&N(this)),null!==i&&this.emit("data",i),i},E.prototype._read=function(e){v(this,new m("_read()"))},E.prototype.pipe=function(e,r){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,t("pipe count=%d opts=%j",o.pipesCount,r);var s=r&&!1===r.end||e===Nc.stdout||e===Nc.stderr?p:a;function a(){t("onend"),e.end()}o.endEmitted?Nc.nextTick(s):i.once("end",s),e.on("unpipe",(function n(r,s){t("onunpipe"),r===i&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,t("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",n),i.removeListener("end",a),i.removeListener("end",p),i.removeListener("data",d),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}));var c=function(e){return function(){var r=e._readableState;t("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,0===r.awaitDrain&&n(e,"data")&&(r.flowing=!0,P(e))}}(i);e.on("drain",c);var l=!1;function d(n){t("ondata");var r=e.write(n);t("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==D(o.pipes,e))&&!l&&(t("false write response, pause",o.awaitDrain),o.awaitDrain++),i.pause())}function u(r){t("onerror",r),p(),e.removeListener("error",u),0===n(e,"error")&&v(e,r)}function h(){e.removeListener("finish",f),p()}function f(){t("onfinish"),e.removeListener("close",h),p()}function p(){t("unpipe"),i.unpipe(e)}return i.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",u),e.once("close",h),e.once("finish",f),e.emit("pipe",i),o.flowing||(t("pipe resume"),i.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},E.prototype.on=function(e,n){var i=r.prototype.on.call(this,e,n),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,t("on readable",o.length,o.reading),o.length?x(this):o.reading||Nc.nextTick(T,this))),i},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var n=r.prototype.removeListener.call(this,e,t);return"readable"===e&&Nc.nextTick(O,this),n},E.prototype.removeAllListeners=function(e){var t=r.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Nc.nextTick(O,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(t("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Nc.nextTick(R,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return t("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(t("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var n=this,r=this._readableState,i=!1;for(var o in e.on("end",(function(){if(t("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&n.push(e)}n.push(null)})),e.on("data",(function(o){t("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(n.push(o)||(i=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<b.length;s++)e.on(b[s],this.emit.bind(this,b[s]));return this._read=function(n){t("wrapped _read",n),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===c&&(c=function(){if(Zu)return Yu;var e;function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Zu=1;var n=th,r=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),s=Symbol("ended"),a=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function u(e){var t=e[r];if(null!==t){var n=e[l].read();null!==n&&(e[a]=null,e[r]=null,e[i]=null,t(d(n,!1)))}}function h(e){Nc.nextTick(u,e)}var f=Object.getPrototypeOf((function(){})),p=Object.setPrototypeOf((t(e={get stream(){return this[l]},next:function(){var e=this,t=this[o];if(null!==t)return Promise.reject(t);if(this[s])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise((function(t,n){Nc.nextTick((function(){e[o]?n(e[o]):t(d(void 0,!0))}))}));var n,r=this[a];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[s]?n(d(void 0,!0)):t[c](n,r)}),r)}}(r,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[c])}return this[a]=n,n}},Symbol.asyncIterator,(function(){return this})),t(e,"return",(function(){var e=this;return new Promise((function(t,n){e[l].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),e),f);return Yu=function(e){var u,f=Object.create(p,(t(u={},l,{value:e,writable:!0}),t(u,r,{value:null,writable:!0}),t(u,i,{value:null,writable:!0}),t(u,o,{value:null,writable:!0}),t(u,s,{value:e._readableState.endEmitted,writable:!0}),t(u,c,{value:function(e,t){var n=f[l].read();n?(f[a]=null,f[r]=null,f[i]=null,e(d(n,!1))):(f[r]=e,f[i]=t)},writable:!0}),u));return f[a]=null,n(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=f[i];return null!==t&&(f[a]=null,f[r]=null,f[i]=null,t(e)),void(f[o]=e)}var n=f[r];null!==n&&(f[a]=null,f[r]=null,f[i]=null,n(d(void 0,!0))),f[s]=!0})),e.on("readable",h.bind(null,f)),f},Yu}()),c(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=I,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===l&&(l=Xu?Ju:(Xu=1,Ju=function(){throw new Error("Readable.from is not available in the browser")})),l(E,e,t)}),Qu}var rh=uh,ih=ku.codes,oh=ih.ERR_METHOD_NOT_IMPLEMENTED,sh=ih.ERR_MULTIPLE_CALLBACK,ah=ih.ERR_TRANSFORM_ALREADY_TRANSFORMING,ch=ih.ERR_TRANSFORM_WITH_LENGTH_0,lh=Ku();function dh(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new sh);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function uh(e){if(!(this instanceof uh))return new uh(e);lh.call(this,e),this._transformState={afterTransform:dh.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",hh)}function hh(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?fh(this,null,null):this._flush((function(t,n){fh(e,t,n)}))}function fh(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new ch;if(e._transformState.transforming)throw new ah;return e.push(null)}Du(uh,lh),uh.prototype.push=function(e,t){return this._transformState.needTransform=!1,lh.prototype.push.call(this,e,t)},uh.prototype._transform=function(e,t,n){n(new oh("_transform()"))},uh.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},uh.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},uh.prototype._destroy=function(e,t){lh.prototype._destroy.call(this,e,(function(e){t(e)}))};var ph,gh=yh,mh=rh;function yh(e){if(!(this instanceof yh))return new yh(e);mh.call(this,e)}Du(yh,mh),yh.prototype._transform=function(e,t,n){n(null,e)};var vh=ku.codes,bh=vh.ERR_MISSING_ARGS,wh=vh.ERR_STREAM_DESTROYED;function Eh(e){if(e)throw e}function Ch(e){e()}function _h(e,t){return e.pipe(t)}var Sh=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=function(e){return e.length?"function"!=typeof e[e.length-1]?Eh:e.pop():Eh}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new bh("streams");var o=t.map((function(e,n){var s=n<t.length-1;return function(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===ph&&(ph=th),ph(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new wh("pipe"))}}(e,s,n>0,(function(e){r||(r=e),e&&o.forEach(Ch),s||(o.forEach(Ch),i(r))}))}));return t.reduce(_h)};!function(e,t){(t=Ad.exports=nh()).Stream=t,t.Readable=t,t.Writable=ju(),t.Duplex=Ku(),t.Transform=rh,t.PassThrough=gh,t.finished=th,t.pipeline=Sh}(0,Ad.exports);var kh=Ad.exports;var xh={},Ah={exports:{}},Mh=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}};function Lh(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Oh(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}Ah.exports=Mh(Lh),Ah.exports.strict=Mh(Oh),Lh.proto=Lh((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Lh(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Oh(this)},configurable:!0})}));var Th=Ah.exports,Rh={};Object.defineProperty(Rh,"__esModule",{value:!0}),Rh.Substream=void 0;const Ph=kh;class Ih extends Ph.Duplex{constructor({parent:e,name:t}){super({objectMode:!0}),this._parent=e,this._name=t}_read(){}_write(e,t,n){this._parent.push({name:this._name,data:e}),n()}}Rh.Substream=Ih;var Nh=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xh,"__esModule",{value:!0}),xh.ObjectMultiplex=void 0;const Bh=kh,Dh=Nh(Th),$h=Rh,jh=Symbol("IGNORE_SUBSTREAM");let Kh=class extends Bh.Duplex{constructor(e={}){super(Object.assign(Object.assign({},e),{objectMode:!0})),this._substreams={}}createStream(e){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already ended`);if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);const t=new $h.Substream({parent:this,name:e});return this._substreams[e]=t,function(e,t){const n=(0,Dh.default)(t);(0,Bh.finished)(e,{readable:!1},n),(0,Bh.finished)(e,{writable:!1},n)}(this,(e=>t.destroy(e||void 0))),t}ignoreStream(e){if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);this._substreams[e]=jh}_read(){}_write(e,t,n){const{name:r,data:i}=e;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${e}"`),n();const o=this._substreams[r];return o?(o!==jh&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};xh.ObjectMultiplex=Kh;var Uh=jt(xh.ObjectMultiplex);const Fh=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;Fh.writable=e=>Fh(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState,Fh.readable=e=>Fh(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState,Fh.duplex=e=>Fh.writable(e)&&Fh.readable(e),Fh.transform=e=>Fh.duplex(e)&&"function"==typeof e._transform;var Hh,zh=Fh,qh=class extends xd{constructor(e,{jsonRpcStreamName:t,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!zh.duplex(e))throw new Error(Oa.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new Uh;kh.pipeline(e,o,e,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=function(e={}){const t={},n=new kh.Duplex({objectMode:!0,read:()=>{},write:function(n,o,s){let a=null;try{n.id?function(e){const{id:n}=e;if(null===n)return;const r=t[n];r?(delete t[n],Object.assign(r.res,e),setTimeout(r.end)):console.warn(`StreamMiddleware - Unknown response id "${n}"`)}(n):function(n){e?.retryOnMessage&&n.method===e.retryOnMessage&&Object.values(t).forEach((({req:e,retryCount:n=0})=>{if(!e.id)return;if(n>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${e.id}"`);const r=t[e.id];r&&(r.retryCount=n+1),i(e)})),r.emit("notification",n)}(n)}catch(e){a=e}s(a)}}),r=new ed;return{events:r,middleware:(e,n,r,o)=>{t[e.id]={req:e,res:n,next:r,end:o},i(e)},stream:n};function i(e){n.push(e)}}({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),kh.pipeline(this._jsonRpcConnection.stream,o.createStream(t),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",(t=>{const{method:n,params:r}=t;"metamask_accountsChanged"===n?this._handleAccountsChanged(r):"metamask_unlockStateChanged"===n?this._handleUnlockStateChanged(r):"metamask_chainChanged"===n?this._handleChainChanged(r):id.includes(n)?this.emit("message",{type:n,data:r}):"METAMASK_STREAM_FAILURE"===n&&e.destroy(new Error(Oa.errors.permanentlyDisconnected()))}))}async _initializeStateAsync(){let e;try{e=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(e)}_handleStreamDisconnect(e,t){let n=`MetaMask: Lost connection to "${e}".`;t?.stack&&(n+=`\n${t.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,t?t.message:void 0)}_handleChainChanged({chainId:e,networkVersion:t}={}){cd(e)&&(e=>Boolean(e)&&"string"==typeof e)(t)?"loading"===t?this._handleDisconnect(!0):super._handleChainChanged({chainId:e}):this._log.error(Oa.errors.invalidNetworkParams(),{chainId:e,networkVersion:t})}},Vh=class extends qh{constructor(e,{jsonRpcStreamName:t="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(e,{jsonRpcStreamName:t,logger:n,maxEventListeners:r,rpcMiddleware:od(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},md(this,Hh,void 0),this._initializeStateAsync(),yd(this,Hh,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",(e=>{const{method:t}=e;id.includes(t)&&(this.emit("data",e),this.emit("notification",e.params.result))})),i)if("complete"===document.readyState)dd(this._rpcEngine,this._log);else{const e=()=>{dd(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",e)};window.addEventListener("DOMContentLoaded",e)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Oa.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Oa.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),gd(this,Hh)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Oa.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(e,t){this._rpcRequest(e,t)}addListener(e,t){return this._warnOfDeprecation(e),super.addListener(e,t)}on(e,t){return this._warnOfDeprecation(e),super.on(e,t)}once(e,t){return this._warnOfDeprecation(e),super.once(e,t)}prependListener(e,t){return this._warnOfDeprecation(e),super.prependListener(e,t)}prependOnceListener(e,t){return this._warnOfDeprecation(e),super.prependOnceListener(e,t)}_handleDisconnect(e,t){super._handleDisconnect(e,t),gd(this,Hh)&&!e&&yd(this,Hh,null)}_warnOfDeprecation(e){!1===this._sentWarnings?.events[e]&&(this._log.warn(Oa.warnings.events[e]),this._sentWarnings.events[e]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Oa.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((e,t)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},ad(e,t))}catch(e){t(e)}}))}send(e,t){return this._sentWarnings.send||(this._log.warn(Oa.warnings.sendDeprecation),this._sentWarnings.send=!0),"string"!=typeof e||t&&!Array.isArray(t)?e&&"object"==typeof e&&"function"==typeof t?this._rpcRequest(e,t):this._sendSync(e):new Promise(((n,r)=>{try{this._rpcRequest({method:e,params:t},ad(n,r,!1))}catch(e){r(e)}}))}_sendSync(e){let t;switch(e.method){case"eth_accounts":t=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":t=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(e,ld),t=!0;break;case"net_version":t=gd(this,Hh)??null;break;default:throw new Error(Oa.errors.unsupportedSync(e.method))}return{id:e.id,jsonrpc:e.jsonrpc,result:t}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise((e=>{this.on("_initialized",(()=>e()))})),this._state.isUnlocked),requestBatch:async e=>{if(!Array.isArray(e))throw Cl({message:"Batch requests must be made with an array of request objects.",data:e});return new Promise(((t,n)=>{this._rpcRequest(e,ad(t,n))}))}},{get:(e,t,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Oa.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(e,t,...n))})}_handleChainChanged({chainId:e,networkVersion:t}={}){super._handleChainChanged({chainId:e,networkVersion:t}),this._state.isConnected&&t!==gd(this,Hh)&&(yd(this,Hh,t),this._state.initialized&&this.emit("networkChanged",gd(this,Hh)))}};Hh=new WeakMap;const Wh=u("MM_SDK");Wh.color="#FFAC1C";var Gh={},Yh={};Object.defineProperty(Yh,"__esModule",{value:!0}),Yh.EthereumProviderError=Yh.EthereumRpcError=void 0;const Zh=sl;class Jh extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return Zh.default(this.serialize(),Xh,2)}}function Xh(e,t){if("[Circular]"!==t)return t}Yh.EthereumRpcError=Jh,Yh.EthereumProviderError=class extends Jh{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};var Qh={},ef={};Object.defineProperty(ef,"__esModule",{value:!0}),ef.errorValues=ef.errorCodes=void 0,ef.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},ef.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=ef,n=Yh,r=t.errorCodes.rpc.internal,i={code:r,message:o(r)};function o(n,r="Unspecified error message. This is a bug, please report it."){if(Number.isInteger(n)){const r=n.toString();if(l(t.errorValues,r))return t.errorValues[r].message;if(a(n))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function s(e){if(!Number.isInteger(e))return!1;const n=e.toString();return!!t.errorValues[n]||!!a(e)}function a(e){return e>=-32099&&e<=-32e3}function c(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function l(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=o,e.isValidCode=s,e.serializeError=function(e,{fallbackError:t=i,shouldIncludeStack:r=!1}={}){var a,d;if(!t||!Number.isInteger(t.code)||"string"!=typeof t.message)throw new Error("Must provide fallback error with integer number code and string message.");if(e instanceof n.EthereumRpcError)return e.serialize();const u={};if(e&&"object"==typeof e&&!Array.isArray(e)&&l(e,"code")&&s(e.code)){const t=e;u.code=t.code,t.message&&"string"==typeof t.message?(u.message=t.message,l(t,"data")&&(u.data=t.data)):(u.message=o(u.code),u.data={originalError:c(e)})}else{u.code=t.code;const n=null===(a=e)||void 0===a?void 0:a.message;u.message=n&&"string"==typeof n?n:t.message,u.data={originalError:c(e)}}const h=null===(d=e)||void 0===d?void 0:d.stack;return r&&e&&h&&"string"==typeof h&&(u.stack=h),u}}(Qh);var tf={};Object.defineProperty(tf,"__esModule",{value:!0}),tf.ethErrors=void 0;const nf=Yh,rf=Qh,of=ef;function sf(e,t){const[n,r]=cf(t);return new nf.EthereumRpcError(e,n||rf.getMessageFromCode(e),r)}function af(e,t){const[n,r]=cf(t);return new nf.EthereumProviderError(e,n||rf.getMessageFromCode(e),r)}function cf(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}tf.ethErrors={rpc:{parse:e=>sf(of.errorCodes.rpc.parse,e),invalidRequest:e=>sf(of.errorCodes.rpc.invalidRequest,e),invalidParams:e=>sf(of.errorCodes.rpc.invalidParams,e),methodNotFound:e=>sf(of.errorCodes.rpc.methodNotFound,e),internal:e=>sf(of.errorCodes.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return sf(t,e)},invalidInput:e=>sf(of.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>sf(of.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>sf(of.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>sf(of.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>sf(of.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>sf(of.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>af(of.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>af(of.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>af(of.errorCodes.provider.unsupportedMethod,e),disconnected:e=>af(of.errorCodes.provider.disconnected,e),chainDisconnected:e=>af(of.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new nf.EthereumProviderError(t,n,r)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=Yh;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const n=Qh;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=tf;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=ef;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Gh);var lf={exports:{}};lf.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=n(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,r){void 0===r&&(r=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(n),s=Math.max(i,o),a=0,c=e.map([t,n],(function(t){var n=s-e.getVersionPrecision(t),r=t+new Array(n+1).join(".0");return e.map(r.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(r&&(a=s-Math.min(i,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)r.push(t(e[n]));return r},e.find=function(e,t){var n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){var i=e[n];if(t(i,n))return i}},e.assign=function(e){for(var t,n,r=e,i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){r[t]=e[t]}))};for(t=0,n=o.length;t<n;t+=1)a();return e},e.getBrowserAlias=function(e){return r.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return r.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},o=n(18);function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=function(){function e(){}var t,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],null&&s(t.prototype,null),n&&s(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=c(n(92)),i=c(n(93)),o=c(n(94)),s=c(n(95)),a=c(n(17));function c(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(r.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},r=0,i={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(i[t]=s,o+=1):"object"==typeof s&&(n[t]=s,r+=1)})),r>0){var s=Object.keys(n),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var l=this.satisfies(n[c]);if(void 0!==l)return l}var d=a.default.find(s,(function(e){return t.isPlatform(e)}));if(d){var u=this.satisfies(n[d]);if(void 0!==u)return u}}if(o>0){var h=Object.keys(i),f=a.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(i[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n},t.compareVersion=function(e){var t=[0],n=e,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(a.default.compareVersions(i,n,r))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},n=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=i.default.getMacOSVersionName(t),r={name:o.OS_MAP.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=i.default.getAndroidVersionName(t),r={name:o.OS_MAP.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:o.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},n=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},n=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},n=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},n=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=s,e.exports=t.default}});var df=jt(lf.exports);const uf={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class hf{constructor({shouldSetOnWindow:e,connectionStream:t,shouldSendMetadata:n=!1,shouldShimWeb3:r,sdkInstance:i}){const o=new gf({connectionStream:t,shouldSendMetadata:n,shouldSetOnWindow:e,shouldShimWeb3:r,autoRequestAccounts:!1}),s=new Proxy(o,{deleteProperty:()=>!0});if(this.provider=s,this.sdkInstance=i,e&&"undefined"!=typeof window)try{a=o,window.ethereum=a,window.dispatchEvent(new Event("ethereum#initialized"))}catch(e){Wh("[Ethereum] Unable to set global provider - window.ethereum may be read-only",e)}var a;if(r&&"undefined"!=typeof window)try{!function(e,t=console){let n=!1,r=!1;if(!window.web3){const i="__isMetaMaskShim__";let o={currentProvider:e};Object.defineProperty(o,i,{value:!0,enumerable:!0,configurable:!1,writable:!1}),o=new Proxy(o,{get:(o,s,...a)=>("currentProvider"!==s||n?"currentProvider"===s||s===i||r||(r=!0,t.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),e.request({method:"metamask_logWeb3ShimUsage"}).catch((e=>{t.debug("MetaMask: Failed to log web3 shim usage.",e)}))):(n=!0,t.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(o,s,...a)),set:(...e)=>(t.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...e))}),Object.defineProperty(window,"web3",{value:o,enumerable:!1,configurable:!0,writable:!0})}}(this.provider)}catch(e){Wh("[Ethereum] Unable to shim web3 - window.web3 may be read-only",e)}this.provider.on("display_uri",(e=>{this.sdkInstance.emit(uf.DisplayURI,e)})),this.provider.on("_initialized",(()=>{const e={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(uf.Initialized,e),Wh("[Ethereum: constructor()] provider initialized",e)}))}static init(e){var t;return Wh("[Ethereum: init()] Initializing Ethereum service"),this.instance=new hf(e),null===(t=this.instance)||void 0===t?void 0:t.provider}static destroy(){}static getInstance(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class ff{constructor({useDeepLink:e,preferredOpenLink:t,debug:n=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=t,this.state.debug=n}openDeeplink(e,t,n){return function(e,t,n,r){const{state:i}=e;Wh(`[PlatfformManager: openDeeplink()] universalLink --\x3e ${t}`),Wh(`[PlatfformManager: openDeeplink()] deepLink --\x3e ${n}`);try{if(i.preferredOpenLink)return void i.preferredOpenLink(i.useDeeplink?n:t,r);if(Wh(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${i.useDeeplink} link=${i.useDeeplink?n:t}`),i.useDeeplink)"undefined"!=typeof window&&(window.location.href=n);else if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.target="_self",e.rel="noreferrer noopener",e.click()}}catch(e){console.log("[PlatfformManager: openDeeplink()] can't open link",e)}}(this,e,t,n)}isReactNative(){var e;return this.isNotBrowser()&&"undefined"!=typeof window&&(null===window||void 0===window?void 0:window.navigator)&&"ReactNative"===(null===(e=window.navigator)||void 0===e?void 0:e.product)}isMetaMaskInstalled(){return function(){const e=hf.getProvider()||(null===window||void 0===window?void 0:window.ethereum);return Wh(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${null==e?void 0:e.isMetaMask} isConnected=${null==e?void 0:e.isConnected()}`),(null==e?void 0:e.isMetaMask)&&(null==e?void 0:e.isConnected())}()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,t;const n=df.parse(window.navigator.userAgent);return"mobile"===(null===(e=null==n?void 0:n.platform)||void 0===e?void 0:e.type)||"tablet"===(null===(t=null==n?void 0:n.platform)||void 0===t?void 0:t.type)}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return"undefined"!=typeof window&&Boolean(window.ReactNativeWebView)&&Boolean(navigator.userAgent.endsWith("MetaMaskMobile"))}isMobileWeb(){return this.state.platformType===fa.MobileWeb}static isNotBrowser(){var e;return"undefined"==typeof window||!(null===window||void 0===window?void 0:window.navigator)||void 0!==De&&"ReactNative"===(null===(e=null==De?void 0:De.navigator)||void 0===e?void 0:e.product)||"ReactNative"===(null===navigator||void 0===navigator?void 0:navigator.product)}isNotBrowser(){return ff.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return ff.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(e){const{state:t}=e;return t.platformType?t.platformType:e.isReactNative()?fa.ReactNative:e.isNotBrowser()?fa.NonBrowser:e.isMetaMaskMobileWebView()?fa.MetaMaskMobileWebview:e.isMobile()?fa.MobileWeb:fa.DesktopWeb}(this)}}const pf=e=>Be(void 0,void 0,void 0,(function*(){if(ff.isBrowser()){const{StorageManagerWeb:t}=yield Promise.resolve().then((function(){return pp}));return new t(e)}const t={persistChannelConfig:()=>Be(void 0,void 0,void 0,(function*(){})),getPersistedChannelConfig:()=>Be(void 0,void 0,void 0,(function*(){})),persistAccounts:()=>Be(void 0,void 0,void 0,(function*(){})),getCachedAccounts:()=>Be(void 0,void 0,void 0,(function*(){return[]})),persistChainId:()=>Be(void 0,void 0,void 0,(function*(){})),getCachedChainId:()=>Be(void 0,void 0,void 0,(function*(){})),terminate:()=>Be(void 0,void 0,void 0,(function*(){}))};return Promise.resolve(t)}));class gf extends Vh{constructor({connectionStream:e,shouldSendMetadata:t,autoRequestAccounts:n=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:t}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},Wh(`[SDKProvider: constructor()] autoRequestAccounts=${n}`),this.state.autoRequestAccounts=n}forceInitializeState(){return Be(this,void 0,void 0,(function*(){return Wh(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){Wh("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:t}=this._state;return t&&0!==t.length?(null===(e=t[0])||void 0===e?void 0:e.toLowerCase())||"":(Wh("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,t){return this._handleAccountsChanged(e,t)}handleDisconnect({terminate:e=!1}){!function({terminate:e=!1,instance:t}){const{state:n}=t;Wh(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${e}`,t),e&&(t._state.accounts=null,t._state.isUnlocked=!1,t._state.isPermanentlyDisconnected=!0,t._state.initialized=!1),t._handleAccountsChanged([]),t._state.isConnected=!1,t.emit("disconnect",Gh.ethErrors.provider.disconnected()),n.providerStateRequested=!1}({terminate:e,instance:this})}_initializeStateAsync(){return Be(this,void 0,void 0,(function*(){return function(e){var t,n;return Be(this,void 0,void 0,(function*(){void 0===e.state&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:r}=e;let i;if(r.providerStateRequested)Wh("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let o;r.providerStateRequested=!0;let s=null,a=!1,c=!1;const l=yield pf({enabled:!0});if(l){const e=yield l.getPersistedChannelConfig({});a=null!==(t=null==e?void 0:e.relayPersistence)&&void 0!==t&&t,o=yield l.getCachedChainId();const n=yield l.getCachedAccounts();n.length>0&&(s=n[0])}if(Wh(`[SDKProvider: initializeStateAsync()] relayPersistence=${a}`,{relayPersistence:a,cachedChainId:o,cachedSelectedAddress:s}),a)if(o&&s)i={accounts:[s],chainId:o,isUnlocked:!1},c=!0;else try{i=yield e.request({method:"metamask_getProviderState"})}catch(t){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",t),void(r.providerStateRequested=!1)}if(0===(null===(n=null==i?void 0:i.accounts)||void 0===n?void 0:n.length))if(e.getSelectedAddress())i.accounts=[e.getSelectedAddress()];else{Wh("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const t=yield e.request({method:"eth_requestAccounts",params:[]});i.accounts=t}e._initializeState(i),r.providerStateRequested=!1,c&&(e._state.isConnected=!0,e.emit("connect",{chainId:null==i?void 0:i.chainId}))}}))}(this)}))}_initializeState(e){return Wh("[SDKProvider: _initializeState()]",e),function(e,t,n){return Wh("[SDKProvider: initializeState()] set state._initialized to false"),e._state.initialized=!1,t(n)}(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:t}={}){this.state.chainId=e,this.state.networkVersion=t,function({instance:e,chainId:t,networkVersion:n,superHandleChainChanged:r}){Wh(`[SDKProvider: handleChainChanged()] chainId=${t} networkVersion=${n}`);let i=n;n||(Wh("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),i="1"),e._state.isConnected=!0,e.emit("connect",{chainId:t}),r({chainId:t,networkVersion:i})}({instance:this,chainId:e,networkVersion:t,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var mf,yf={name:"@metamask/sdk",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"^4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};!function(e){e.INPAGE="metamask-inpage",e.CONTENT_SCRIPT="metamask-contentscript",e.PROVIDER="metamask-provider"}(mf||(mf={}));const vf="direct",bf="https://metamask.app.link/connect",wf="metamask://connect",Ef={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},Cf=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,_f={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},Sf={[_f.ETH_REQUESTACCOUNTS]:!0,[_f.ETH_SENDTRANSACTION]:!0,[_f.ETH_SIGNTRANSACTION]:!0,[_f.ETH_SIGN]:!0,[_f.PERSONAL_SIGN]:!0,[_f.ETH_ACCOUNTS]:!1,[_f.ETH_CHAINID]:!1,[_f.PERSONAL_SIGN]:!0,[_f.ETH_SIGNTYPEDDATA]:!0,[_f.ETH_SIGNTYPEDDATA_V3]:!0,[_f.ETH_SIGNTYPEDDATA_V4]:!0,[_f.WALLET_REQUESTPERMISSIONS]:!0,[_f.WALLET_GETPERMISSIONS]:!0,[_f.WALLET_WATCHASSET]:!0,[_f.WALLET_ADDETHEREUMCHAIN]:!0,[_f.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[_f.METAMASK_CONNECTSIGN]:!0,[_f.METAMASK_CONNECTWITH]:!0,[_f.PERSONAL_EC_RECOVER]:!0,[_f.METAMASK_BATCH]:!0,[_f.METAMASK_OPEN]:!0},kf=Object.keys(Sf).map((e=>e.toLowerCase())),xf=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map((e=>e.toLowerCase())),Af=".sdk-comm",Mf="providerType",Lf=".MMSDK_cached_address",Of=".MMSDK_cached_chainId",Tf="chainChanged",Rf="accountsChanged",Pf="disconnect",If="connect",Nf="connected";var Bf;!function(e){e.TERMINATE="terminate",e.EXTENSION="extension",e.INITIALIZED="initialized"}(Bf||(Bf={}));const Df="undefined"!=typeof window&&window.localStorage;function $f(e){var t,n;return Be(this,void 0,void 0,(function*(){Wh("[MetaMaskSDK: connectWithExtensionProvider()] ",e),e.sdkProvider=e.activeProvider,e.activeProvider=window.extension,window.ethereum=window.extension;try{const e=yield null===(t=window.extension)||void 0===t?void 0:t.request({method:"eth_requestAccounts"});Wh(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${e}`)}catch(e){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",e)}localStorage.setItem(Mf,"extension"),e.extensionActive=!0,e.emit(uf.ProviderUpdate,Bf.EXTENSION),e.options.enableAnalytics&&(null===(n=e.analytics)||void 0===n||n.send({event:Xs.SDK_USE_EXTENSION}))}))}function jf(e){let t;if(void 0!==Xe)t=Xe.from(e,"utf8").toString("base64");else if("function"==typeof btoa)t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/gu,((e,t)=>String.fromCharCode(parseInt(t,16)))));else{if("object"!=typeof De||!("Buffer"in De))throw new Error("Unable to base64 encode: No available method.");t=De.Buffer.from(e,"utf8").toString("base64")}return t}class Kf extends kh.Duplex{constructor({name:e,remote:t,deeplinkProtocol:n,platformManager:r}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=e,this.state.remote=t,this.state.deeplinkProtocol=n,this.state.platformManager=r,this._onMessage=this._onMessage.bind(this),this.state.remote.on(Gs.MESSAGE,this._onMessage)}_write(e,t,n){return Be(this,void 0,void 0,(function*(){return function(e,t,n,r){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C,_;return Be(this,void 0,void 0,(function*(){const n=null===(i=e.state.remote)||void 0===i?void 0:i.isReady(),S=null===(o=e.state.remote)||void 0===o?void 0:o.isConnected(),k=null===(s=e.state.remote)||void 0===s?void 0:s.isPaused(),x=hf.getProvider(),A=null===(a=e.state.remote)||void 0===a?void 0:a.getChannelId(),M=null===(c=e.state.remote)||void 0===c?void 0:c.isAuthorized(),{deeplinkProtocol:L}=e.state,{method:O,data:T,triggeredInstaller:R}=(e=>{var t,n,r,i;let o;Xe.isBuffer(e)?(o=e.toJSON(),o._isBuffer=!0):o=e;const s=null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.method;let a=!1;return"object"==typeof(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.params)&&!0===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.params)||void 0===i?void 0:i.__triggeredInstaller)&&(a=!0,o.data.params=o.data.params.wrappedParams),{method:s,data:o,triggeredInstaller:a}})(t);if(Wh(`[RCPMS: write()] method='${O}' isRemoteReady=${n} channelId=${A} isSocketConnected=${S} isRemotePaused=${k} providerConnected=${x.isConnected()}`,t),!A)return O!==_f.METAMASK_GETPROVIDERSTATE&&Wh(`[RCPMS: write()] ${O} --\x3e channelId is undefined`),r(new Error("disconnected"));Wh(`[RCPMS: write()] remote.isPaused()=${null===(l=e.state.remote)||void 0===l?void 0:l.isPaused()} authorized=${M} ready=${n} socketConnected=${S}`,t);const P=null===(d=e.state.platformManager)||void 0===d?void 0:d.isSecure(),I=null!==(h=null===(u=e.state.platformManager)||void 0===u?void 0:u.isMobileWeb())&&void 0!==h&&h,N=null!==(p=null===(f=e.state.remote)||void 0===f?void 0:f.hasDeeplinkProtocol())&&void 0!==p&&p&&I&&M;try{if(!R){const t=JSON.stringify(null==T?void 0:T.data);if(t.length>1e6)return r(new Error(`Message size ${t.length} exceeds maximum allowed size of 1000000 bytes`));null===(g=e.state.remote)||void 0===g||g.sendMessage(null==T?void 0:T.data).then((()=>{Wh(`[RCPMS: _write()] ${O} sent successfully`)})).catch((e=>{Wh("[RCPMS: _write()] error sending message",e)}))}if(!P)return Wh(`[RCPMS: _write()] unsecure platform for method ${O} -- return callback`),r();if(R)return Wh("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const t=null!==(v=null===(y=null===(m=e.state.remote)||void 0===m?void 0:m.getKeyInfo())||void 0===y?void 0:y.ecies.public)&&void 0!==v?v:"";let n=encodeURI(`channelId=${A}&pubkey=${t}&comm=socket&t=d&v=2`);if(N){const t=JSON.stringify(null==T?void 0:T.data),i=null===(b=e.state.remote)||void 0===b?void 0:b.encrypt(t);if(!i)return Wh("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));n+=`&scheme=${L}&rpc=${jf(i)}`}if(!(null===(w=e.state.platformManager)||void 0===w?void 0:w.isMetaMaskInstalled()))return Wh("[RCPMS: _write()] prevent deeplink until installation is completed."),r();Sf[O]?(Wh(`[RCPMS: _write()] redirect link for '${O}' socketConnected=${S} connect?${n}`),null===(E=e.state.platformManager)||void 0===E||E.openDeeplink(`${bf}?${n}`,`${wf}?${n}`,"_self")):(null===(C=e.state.remote)||void 0===C?void 0:C.isPaused())?(Wh(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${O}`),null===(_=e.state.platformManager)||void 0===_||_.openDeeplink(`${bf}?redirect=true&${n}`,`${wf}?redirect=true&${n}`,"_self")):Wh(`[RCPMS: _write()] method ${O} doesn't need redirect.`)}catch(e){return Wh("[RCPMS: _write()] error sending message",e),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()}))}(this,e,0,n)}))}_read(){}_onMessage(e){return function(e,t){try{if(Wh("[RCPMS: onMessage()] message",t),!t||"object"!=typeof t)return;if("object"!=typeof(null==t?void 0:t.data))return;if(!(null==t?void 0:t.name))return void Wh("[RCPMS: onMessage()] ignore message without name",t);if((null==t?void 0:t.name)!==mf.PROVIDER)return void Wh(`[RCPMS: onMessage()] ignore message with wrong name message=${t}`);if(Xe.isBuffer(t)){const n=Xe.from(t);e.push(n)}else e.push(t)}catch(e){Wh(`[RCPMS: onMessage()] ignore message error err=${e}`)}}(this,e)}start(){}}let Uf=1;const Ff=e=>new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),Hf=({checkInstallationOnAllCalls:e=!1,communicationLayerPreference:t,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:o,sdk:a,remoteConnection:c,debug:l})=>Be(void 0,void 0,void 0,(function*(){var d,u;const h=(({name:e,remoteConnection:t})=>{if(!t||!(null==t?void 0:t.getConnector()))throw new Error("Missing remote connection parameter");return new Kf({name:e,remote:null==t?void 0:t.getConnector(),deeplinkProtocol:null==t?void 0:t.state.deeplinkProtocol,platformManager:null==t?void 0:t.getPlatformManager()})})({name:mf.INPAGE,target:mf.CONTENT_SCRIPT,platformManager:i,communicationLayerPreference:t,remoteConnection:c}),f=i.getPlatformType(),p=a.options.dappMetadata,g=`Sdk/Javascript SdkVersion/${yf.version} Platform/${f} dApp/${null!==(d=p.url)&&void 0!==d?d:p.name} dAppTitle/${p.name}`;let m=null,y=null;const v=null===(u=a.options.storage)||void 0===u?void 0:u.storageManager;if(v){try{const e=yield v.getCachedAccounts();e.length>0&&(m=e[0])}catch(e){console.error(`[initializeMobileProvider] failed to get cached addresses: ${e}`)}try{const e=yield v.getCachedChainId();e&&(y=e)}catch(e){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${e}`)}}Wh(`[initializeMobileProvider] cachedAccountAddress: ${m}, cachedChainId: ${y}`);const b=!(!n||f===fa.NonBrowser||f===fa.ReactNative),w=hf.init({shouldSetOnWindow:b,connectionStream:h,shouldShimWeb3:r,sdkInstance:a});let E=!1;const C=e=>{E=e},_=()=>E,S=(t,n,r,l)=>Be(void 0,void 0,void 0,(function*(){var d,u,h,f,p,b,w,S,k;const x=hf.getProvider();if(E){x.emit("display_uri",(null==c?void 0:c.state.qrcodeLink)||""),null==c||c.showActiveModal();let e=_();for(;e;){const t=_(),n=null==c?void 0:c.isAuthorized();e=t&&!n,Wh(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${t} authorized: ${n}`),yield Ff(1e3)}return Wh("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),r(...n)}const A=i.isMetaMaskInstalled(),M=null==c?void 0:c.isConnected();let L=null,O=null,T=null;if(L=null!==(d=x.getSelectedAddress())&&void 0!==d?d:m,T=x.getChainId()||y,L&&v&&L!==m&&v.persistAccounts([L]).catch((e=>{console.error(`[initializeMobileProvider] failed to persist account: ${e}`)})),T&&(y=T,v&&v.persistChainId(T).catch((e=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${e}`)}))),Wh("[initializeMobileProvider: sendRequest()]",{selectedAddress:L,chainId:T}),l&&Wh(`[initializeMobileProvider: sendRequest()] method=${t} ongoing=${E} selectedAddress=${L} isInstalled=${A} checkInstallationOnAllCalls=${e} socketConnected=${M}`),L&&t.toLowerCase()===_f.ETH_ACCOUNTS.toLowerCase())return[L];if(T&&t.toLowerCase()===_f.ETH_CHAINID.toLowerCase())return T;const R=[_f.ETH_REQUESTACCOUNTS,_f.WALLET_REQUESTPERMISSIONS,_f.METAMASK_CONNECTSIGN,_f.METAMASK_CONNECTWITH],P=!Sf[t],I=null===(u=a.options.readonlyRPCMap)||void 0===u?void 0:u[T];if(I&&P)try{const e=null===(h=null==n?void 0:n[0])||void 0===h?void 0:h.params,r=yield(({rpcEndpoint:e,method:t,sdkInfo:n,params:r})=>Be(void 0,void 0,void 0,(function*(){const i=JSON.stringify({jsonrpc:"2.0",method:t,params:r,id:(Uf+=1,Uf)}),o={Accept:"application/json","Content-Type":"application/json"};let a;e.includes("infura")&&(o["Metamask-Sdk-Info"]=n);try{a=yield s(e,{method:"POST",headers:o,body:i})}catch(e){throw e instanceof Error?new Error(`Failed to fetch from RPC: ${e.message}`):new Error(`Failed to fetch from RPC: ${e}`)}if(!a.ok)throw new Error(`Server responded with a status of ${a.status}`);return(yield a.json()).result})))({rpcEndpoint:I,sdkInfo:g,method:t,params:e||[]});return l&&Wh(`initializeProvider::ReadOnlyRPCResponse ${r}`),r}catch(e){console.warn(`[initializeMobileProvider: sendRequest()] method=${t} readOnlyRPCRequest failed:`,e)}if((!A||A&&!M)&&t!==_f.METAMASK_GETPROVIDERSTATE){const s=(null===(f=null==n?void 0:n[0])||void 0===f?void 0:f.params)||[];if(-1!==R.indexOf(t)||e){C(!0);const e=t===_f.METAMASK_CONNECTWITH,i=`${Date.now()}`;try{yield o.start({wait:!1,connectWith:e?{method:t,id:i,params:s}:void 0}),yield new Promise(((e,t)=>{(null==c?void 0:c.isAuthorized())&&(Wh("[initializeMobileProvider: sendRequest()] already authorized"),e(!0)),null==c||c.getConnector().once(Gs.AUTHORIZED,(()=>{e(!0)})),a.once(Gs.PROVIDER_UPDATE,(e=>{Wh(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${e}`),e===Bf.EXTENSION?t(Gs.PROVIDER_UPDATE):t(new Error("Connection Terminated"))}))}))}catch(e){if(Bf.EXTENSION===e){if(Wh(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${t} on the active provider`),t.toLowerCase()===_f.METAMASK_CONNECTSIGN.toLowerCase()){const e=yield null===(p=a.getProvider())||void 0===p?void 0:p.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!e.length)throw new Error("SDK state invalid -- undefined accounts");const t=yield null===(b=a.getProvider())||void 0===b?void 0:b.request({method:_f.PERSONAL_SIGN,params:[s[0],e[0]]});return a.emit(uf.ConnectWithResponse,t),t}if(t.toLowerCase()===_f.METAMASK_CONNECTWITH.toLowerCase()){const[e]=s,t=yield(({method:e,sdk:t,params:n})=>Be(void 0,void 0,void 0,(function*(){var r,i,o,s;if(!t.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");Wh("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",e,n);const a=yield null===(r=t.getProvider())||void 0===r?void 0:r.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!a.length)throw new Error("SDK state invalid -- undefined accounts");if((null==e?void 0:e.toLowerCase())===_f.PERSONAL_SIGN.toLowerCase()){const r={method:e,params:[n[0],a[0]]};return yield null===(i=t.getProvider())||void 0===i?void 0:i.request(r)}if((null==e?void 0:e.toLowerCase())===_f.ETH_SENDTRANSACTION.toLowerCase()){const r={method:e,params:[Object.assign(Object.assign({},n[0]),{from:a[0]})]};return yield null===(o=t.getProvider())||void 0===o?void 0:o.request(r)}return xf.includes(e.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${e} -- not handled by the extension -- call separately`),a):yield null===(s=t.getProvider())||void 0===s?void 0:s.request({method:e,params:n})})))({method:e.method,sdk:a,params:e.params});return a.emit(uf.ConnectWithResponse,t),t}return Wh(`[initializeMobileProvider: sendRequest()] sending '${t}' on active provider`,s),yield null===(w=a.getProvider())||void 0===w?void 0:w.request({method:t,params:s})}if(e===Gs.REJECTED)throw null==c||c.closeModal(),null===(S=a.getProvider())||void 0===S||S.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001});throw Wh(`[initializeMobileProvider: sendRequest()] failed to start installer: ${e}`),e}finally{C(!1)}if(t===_f.ETH_REQUESTACCOUNTS)return O=yield new Promise((e=>{const t=setInterval((()=>{const{accounts:n}=x.getState();n&&(clearInterval(t),e(n))}),100)})),Wh(`[initializeMobileProvider: sendRequest()] selectedAddress: ${L} --- SKIP rpc call`),O;if(t===_f.METAMASK_CONNECTWITH)try{let e=0;const t=5,n=({resolve:n,reject:r})=>{e+=1;const o=null==c?void 0:c.getConnector().getRPCMethodTracker(),s=null==o?void 0:o[i];return Wh(`TRACKER: update method ${i}`,s),(null==s?void 0:s.result)?(Wh("[initializeMobileProvider: sendRequest()] found result",s.result),a.emit(uf.ConnectWithResponse,s.result),void n(s.result)):(null==s?void 0:s.error)?(Wh("[initializeMobileProvider: sendRequest()] found error",s.error),void r(s.error)):e>=t?(Wh("[initializeMobileProvider: sendRequest()] max message count reached without result"),void r(new Error("Max message count reached without result"))):void Wh("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let r,o;const s=yield new Promise(((e,t)=>{const s=null==c?void 0:c.getConnector().getRPCMethodTracker();Wh(`TRACKER: method ${i}`,s),(null==s?void 0:s[i].result)?(Wh("[initializeMobileProvider: sendRequest()] found result",null==s?void 0:s[i].result),e(null==s?void 0:s[i].result)):(null==s?void 0:s[i].error)&&(Wh("[initializeMobileProvider: sendRequest()] found error",null==s?void 0:s[i].error),t(null==s?void 0:s[i].error)),o=()=>n({resolve:e,reject:t}),r=null==c?void 0:c.getConnector().on(Gs.RPC_UPDATE,o)}));return o&&(null==r||r.off(Gs.RPC_UPDATE,o)),Wh("TRACKER: result",s),s}catch(e){throw Wh("[initializeMobileProvider: sendRequest()] error:",e),e}return n[0]&&"object"==typeof n[0]&&(n[0].params={__triggeredInstaller:!0,wrappedParams:n[0].params}),r(...n)}if(i.isSecure()&&Sf[t])return r(...n);if(a.isExtensionActive())return Wh(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${t}' to it`,n,s),yield null===(k=a.getProvider())||void 0===k?void 0:k.request({method:t,params:s});throw Wh(`[initializeMobileProvider: sendRequest()] method=${t} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const e=yield r(...n);if(Wh(`[initializeMobileProvider: sendRequest()] method=${t} rpcResponse`,e),t===_f.WALLET_REQUESTPERMISSIONS){const t=e.reduce(((e,t)=>{var n;if("eth_accounts"===t.parentCapability){const r=null===(n=t.caveats.find((e=>"restrictReturnedAccounts"===e.type)))||void 0===n?void 0:n.value;r&&e.push(...r)}return e}),[]);Wh("[initializeMobileProvider: sendRequest()] accountsToPersist:",t),t.length>0&&(x.handleAccountsChanged(t,!1),null==v||v.persistAccounts(t))}return e}catch(e){throw console.error("[initializeMobileProvider: sendRequest()] error:",e),e}})),{request:k}=w;w.request=(...e)=>Be(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0].method,e,k,l)}));const{send:x}=w;return w.send=(...e)=>Be(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0],e,x,l)})),Wh("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),h.start(),w}));class zf{constructor({serverUrl:e,enabled:t,originatorInfo:n}){this.serverURL=Us,this.serverURL=e,this.originatorInfo=n,this.enabled=null==t||t}send({event:e,params:t}){if(!this.enabled)return;const n=Object.assign(Object.assign({id:"sdk",event:e,sdkVersion:yf.version},this.originatorInfo),{params:t});Wh(`[Analytics: send()] event: ${e}`,n),$s(n,this.serverURL).catch((e=>{Wh(`[Analytics: send()] error: ${e}`)}))}}function qf(e){var n,r,i;const{dappMetadata:o}=e,s=function({url:e,name:n}){var r;const i=jf(e+n);if(!localStorage)return"";let o=null!==(r=localStorage.getItem(i))&&void 0!==r?r:"";if(!o){o=t.v4();try{localStorage.setItem(i,o)}catch(e){return""}}return o}({url:null!==(n=null==o?void 0:o.url)&&void 0!==n?n:"no_url",name:null!==(r=null==o?void 0:o.name)&&void 0!==r?r:"no_name"}),a=null===(i=e.platformManager)||void 0===i?void 0:i.getPlatformType(),c=a===fa.DesktopWeb,l=a===fa.MetaMaskMobileWebview;let d="N/A";return c?d="extension":l&&(d="mobile"),{id:s,from:d}}const Vf=({provider:e,sdkInstance:t})=>{if("state"in e)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(e,{get:(n,r)=>"request"===r?function(e){var r,i;return Be(this,void 0,void 0,(function*(){Wh("[wrapExtensionProvider()] Overwriting request method",e);const{method:o,params:s}=e,a=kf.includes(o.toLowerCase()),{id:c,from:l}=qf(t);if(a&&(null===(r=t.analytics)||void 0===r||r.send({event:Xs.SDK_RPC_REQUEST,params:{method:o,from:l,id:c}})),o===_f.METAMASK_BATCH&&Array.isArray(s))return(({target:e,args:t,trackEvent:n,sdkInstance:r})=>Be(void 0,void 0,void 0,(function*(){var i,o;if("metamask_batch"!==t.method)throw new Error("Invalid usage");const s=[],a=null!==(i=null==t?void 0:t.params)&&void 0!==i?i:[];for(const t of a){const n=yield null==e?void 0:e.request({method:t.method,params:t.params});s.push(n)}const{id:c,from:l}=qf(r);return n&&(null===(o=r.analytics)||void 0===o||o.send({event:Xs.SDK_RPC_REQUEST_DONE,params:{method:t.method,from:l,id:c}})),s})))({target:n,args:e,trackEvent:a,sdkInstance:t});if(o.toLowerCase()===_f.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>Be(void 0,void 0,void 0,(function*(){const n=yield e.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!n.length)throw new Error("SDK state invalid -- undefined accounts");return yield e.request({method:_f.PERSONAL_SIGN,params:[t[0],n[0]]})})))({target:n,params:s});if(o.toLowerCase()===_f.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>Be(void 0,void 0,void 0,(function*(){const[n]=t,r=n.method,i=n.params,o=yield e.request({method:_f.ETH_REQUESTACCOUNTS,params:[]});if(!o.length)throw new Error("SDK state invalid -- undefined accounts");return(null==r?void 0:r.toLowerCase())===_f.PERSONAL_SIGN.toLowerCase()?yield e.request({method:r,params:[i[0],o[0]]}):(null==r?void 0:r.toLowerCase())===_f.ETH_SENDTRANSACTION.toLowerCase()?yield e.request({method:r,params:[Object.assign(Object.assign({},i[0]),{from:o[0]})]}):xf.includes(r.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${r} -- not handled by the extension -- call separately`),o):yield e.request({method:r,params:i})})))({target:n,params:s});let d;try{return d=yield n.request(e),d}finally{a&&(null===(i=t.analytics)||void 0===i||i.send({event:Xs.SDK_RPC_REQUEST_DONE,params:{method:o,from:l,id:c}}))}}))}:"getChainId"===r?function(){return e.chainId}:"getNetworkVersion"===r?function(){return e.networkVersion}:"getSelectedAddress"===r?function(){return e.selectedAddress}:"isConnected"===r?function(){return e._state.isConnected}:n[r]})};var Wf;!function(e){e.Announce="eip6963:announceProvider",e.Request="eip6963:requestProvider"}(Wf||(Wf={}));var Gf="INSTALLED",Yf="NOT_INSTALLED",Zf="REGISTERED",Jf="REGISTERING",Xf="RELOADING",Qf={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},ep="REGISTRATION_IN_PROGRESS",tp="FORWARDER_ID",np=function(){function e(t){var n=void 0===t?{}:t,r=n.forwarderOrigin,i=void 0===r?"https://fwd.metamask.io":r,o=n.forwarderMode,s=void 0===o?e.FORWARDER_MODE.INJECT:o;this.forwarderOrigin=i,this.forwarderMode=s,this.state=e.isMetaMaskInstalled()?Gf:Yf;var a=e._detectBrowser();this.downloadUrl=a?Qf[a]:Qf.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),s===e.FORWARDER_MODE.INJECT&&"true"===sessionStorage.getItem(ep)&&e._injectForwarder(this.forwarderOrigin)}return e.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return"metamask:reload"===e.data.type?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},e.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},e.prototype._onMessageFromForwarder=function(t){return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(n){switch(n.label){case 0:switch(this.state){case Xf:return[3,1];case Yf:return[3,2];case Gf:return[3,3];case Jf:return[3,5];case Zf:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=Xf,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=Jf,[4,e._register()];case 4:return n.sent(),this.state=Zf,t.source.postMessage({type:"metamask:registrationCompleted"},t.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}}))}))},e.prototype.startOnboarding=function(){sessionStorage.setItem(ep,"true"),this._openDownloadPage(),this._openForwarder()},e.prototype.stopOnboarding=function(){"true"===sessionStorage.getItem(ep)&&(this.forwarderMode===e.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),e._removeForwarder()),sessionStorage.setItem(ep,"false"))},e.prototype._openForwarder=function(){this.forwarderMode===e.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):e._injectForwarder(this.forwarderOrigin)},e.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},e.isMetaMaskInstalled=function(){return Boolean(window.ethereum&&window.ethereum.isMetaMask)},e._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},e._injectForwarder=function(e){var t=document.body,n=document.createElement("iframe");n.setAttribute("height","0"),n.setAttribute("width","0"),n.setAttribute("style","display: none;"),n.setAttribute("src",e),n.setAttribute("id",tp),t.insertBefore(n,t.children[0])},e._removeForwarder=function(){var e;null===(e=document.getElementById(tp))||void 0===e||e.remove()},e._detectBrowser=function(){var e=df.parse(window.navigator.userAgent);return"Firefox"===e.browser.name?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},e.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},e}();class rp{constructor({remote:e,preferDesktop:t,platformManager:n,debug:r=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=t,this.state.platformManager=n,this.state.debug=r}startDesktopOnboarding(){return function(){return Be(this,void 0,void 0,(function*(){Wh("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),(new np).startOnboarding()}))}()}redirectToProperInstall(){return Be(this,void 0,void 0,(function*(){return function(e){var t,n;return Be(this,void 0,void 0,(function*(){const{state:r}=e,i=null===(t=r.platformManager)||void 0===t?void 0:t.getPlatformType();if(Wh(`[MetamaskInstaller: redirectToProperInstall()] platform=${i}`),i===fa.MetaMaskMobileWebview)return!1;r.isInstalling=!0;try{yield null===(n=r.remote)||void 0===n?void 0:n.startConnection({connectWith:r.connectWith}),r.isInstalling=!1,r.hasInstalled=!0}catch(e){throw r.isInstalling=!1,e}return!0}))}(this)}))}checkInstallation(){return Be(this,void 0,void 0,(function*(){return function(e){var t;return Be(this,void 0,void 0,(function*(){const{state:n}=e,r=null===(t=n.platformManager)||void 0===t?void 0:t.isMetaMaskInstalled();return Wh(`[MetamaskInstaller: checkInstallation()] isInstalled=${r}`),!!r||(yield e.redirectToProperInstall())}))}(this)}))}start({wait:e=!1,connectWith:t}){return Be(this,void 0,void 0,(function*(){this.state.connectWith=t,Wh(`[MetaMaskInstaller: start()] wait=${e}`,t),yield function(e,{wait:t=!1}){return Be(this,void 0,void 0,(function*(){return Wh(`[MetamaskInstaller: startInstaller()] wait=${t}`),t&&(yield Ff(1e3)),yield e.checkInstallation()}))}(this,{wait:e})}))}}class ip{constructor({debug:e,sdkVersion:t}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=null!=e&&e,this.sdkVersion=t}loadComponent(e){return Be(this,void 0,void 0,(function*(){if(!this.defined[e]){this.defined[e]=!0;try{const e=yield Promise.resolve().then((function(){return Og}));console.log("loader",e),e.defineCustomElements()}catch(t){console.error(`Failed to load ${e} modal:`,t)}}}))}renderInstallModal(e){var t;return Be(this,void 0,void 0,(function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const n=document.createElement("mm-install-modal");n.link=e.link,n.preferDesktop=e.preferDesktop,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),n.addEventListener("trackAnalytics",(t=>{var n;return null===(n=e.onAnalyticsEvent)||void 0===n?void 0:n.call(e,t.detail)})),e.parentElement.appendChild(n)}))}renderSelectModal(e){var t;return Be(this,void 0,void 0,(function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const n=document.createElement("mm-select-modal");n.link=e.link,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.preferDesktop=e.preferDesktop,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(n),setTimeout((()=>this.updateQRCode(e.link)),100)}))}renderPendingModal(e){var t;return Be(this,void 0,void 0,(function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const n=document.createElement("mm-pending-modal");n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.displayOTP=e.displayOTP,n.addEventListener("close",e.onClose),n.addEventListener("updateOTPValue",(({detail:{otpValue:t}})=>e.updateOTPValue(t))),e.onDisconnect&&n.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(n)}))}updateOTPValue(e){const t=()=>{var t;const n=null===(t=this.containers.pending)||void 0===t?void 0:t.querySelector("mm-pending-modal");return!!n&&(n.otpCode=e,!0)};setTimeout((()=>{t()}),800)}updateQRCode(e){var t,n;const r=null===(t=this.containers.install)||void 0===t?void 0:t.querySelector("mm-install-modal");if(r)r.link=e;else{const t=null===(n=this.containers.select)||void 0===n?void 0:n.querySelector("mm-select-modal");t&&(t.link=e)}}unmount(){Object.entries(this.containers).forEach((([e,t])=>{var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.removeChild(t),this.containers[e]=void 0}))}}const op=({link:e,debug:t,installer:n,terminate:r,connectWithExtension:i,preferDesktop:o,onAnalyticsEvent:s})=>{let a=null,c=null;Wh("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] link=${e}`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --ios`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --android`),Wh(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${e}"`);const l=e=>{var t;Wh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",e,c),(null==c?void 0:c.parentNode)&&(null===(t=c.parentNode)||void 0===t||t.removeChild(c)),c=null,a=null,!0===e&&(null==r||r())};return{mount:r=>{if(Wh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(null==a||a.updateQRCode(r));a=new ip({debug:t,sdkVersion:yf.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?a.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),null==i||i()},onClose:l,link:e,preferDesktop:null!=o&&o}).catch((e=>{console.error(e)})):a.renderInstallModal({parentElement:c,preferDesktop:null!=o&&o,link:e,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:s}).catch((e=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",e)}))},unmount:l}},sp=({onDisconnect:e,debug:t})=>{let n=null,r=null;const i=()=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),(null==n?void 0:n.parentNode)&&n.parentNode.removeChild(n),n=null,r=null},o=e=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",e),r&&r.updateOTPValue(e)},s=({displayOTP:s}={displayOTP:!0})=>{Wh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new ip({debug:t,sdkVersion:yf.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:e,updateOTPValue:o,displayOTP:s}).catch((e=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",e)})))};return s(),{mount:s,unmount:i,updateOTPValue:o}};function ap(e,t){var n,r,i,o;e.connector||(Wh("[RemoteConnection: initializeConnector()] initialize connector"),e.connector=new Aa({platformType:t.platformManager.getPlatformType(),communicationLayerPreference:t.communicationLayerPreference,transports:t.transports,dappMetadata:Object.assign(Object.assign({},t.dappMetadata),{source:t._source}),analytics:t.enableAnalytics,communicationServerUrl:t.communicationServerUrl,sdkVersion:yf.version,context:"dapp",ecies:t.ecies,storage:t.storage,logging:t.logging}),t.timer&&(Wh("[RemoteConnection: initializeConnector()] reset background timer",t.timer),null===(r=null===(n=t.timer)||void 0===n?void 0:n.stopBackgroundTimer)||void 0===r||r.call(n),null===(o=null===(i=t.timer)||void 0===i?void 0:i.runBackgroundTimer)||void 0===o||o.call(i,(()=>!1),1e4)))}function cp(e){e.listeners.forEach((({event:t,handler:n})=>{var r;null===(r=e.connector)||void 0===r||r.off(t,n)})),e.listeners=[]}function lp(e,t){function n(t,n){var r;null===(r=e.connector)||void 0===r||r.on(t,n),e.listeners.push({event:t,handler:n})}e.connector&&(cp(e),n(Gs.WALLET_INIT,(({accounts:e,chainId:t})=>Be(this,void 0,void 0,(function*(){Wh(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${e} chainId=${t}`);const n=hf.getProvider();n._setConnected();const r={accounts:e,chainId:t,isUnlocked:!1};n._initializeState(r),n.emit("chainChanged",t),n.emit("accountsChanged",e)})))),n(Gs.AUTHORIZED,(()=>Be(this,void 0,void 0,(function*(){var t,n,r,i;try{Wh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",e.pendingModal,e.installModal);const o=hf.getProvider();o._setConnected(),null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!1),e.otpAnswer=void 0,e.authorized=!0,Wh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",o.getState()),yield o.forceInitializeState()}catch(e){}})))),n(Gs.TERMINATE,(()=>{var t,n,r,i,o;null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!0),e.pendingModal=void 0,e.installModal=void 0,e.otpAnswer=void 0,null===(o=e.connector)||void 0===o||o.disconnect({terminate:!0}),e.authorized=!1,hf.getProvider().handleDisconnect({terminate:!0}),cp(e),Wh("[RemoteConnection: setupListeners()] All listeners cleaned up")})))}function dp(e,t,{initialCheck:n,connectWith:r}={}){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C;return Be(this,void 0,void 0,(function*(){try{if(ap(e,t),!e.connector)throw new Error("no connector defined");lp(e);const _=hf.getProvider();e.authorized=!1,_.emit("connecting");const S=yield null===(i=e.connector)||void 0===i?void 0:i.originatorSessionConnect();Wh(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,S);let k=null!==(o=null==S?void 0:S.channelId)&&void 0!==o?o:"",x=null!==(a=null===(s=e.connector.getKeyInfo())||void 0===s?void 0:s.ecies.public)&&void 0!==a?a:"",A=null!==(l=null===(c=e.connector.getKeyInfo())||void 0===c?void 0:c.ecies.private)&&void 0!==l?l:"";if(n&&!S)return Promise.resolve();if(!S&&!n){const t=yield e.connector.generateChannelIdConnect();k=null!==(d=t.channelId)&&void 0!==d?d:"",x=null!==(u=t.pubKey)&&void 0!==u?u:"",A=null!==(h=t.privKey)&&void 0!==h?h:"";const n=Date.now();null===(f=e.connector.state.storageManager)||void 0===f||f.persistChannelConfig({channelId:k,localKey:A,lastActive:n,validUntil:n+Hs})}if(n&&(null==S?void 0:S.channelId))return(null===(p=e.connector)||void 0===p?void 0:p.isConnected())||(Wh(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,S),yield null===(g=e.connector)||void 0===g?void 0:g.connectToChannel({channelId:k})),Promise.resolve();S&&!(null===(m=e.connector)||void 0===m?void 0:m.isConnected())&&(Wh("[RemoteConnection: startConnection()] reconnecting to channel",S),yield null===(y=e.connector)||void 0===y?void 0:y.connectToChannel({channelId:k}));const M=(null===(v=e.platformManager)||void 0===v?void 0:v.isSecure())?"":"&t=q",L=yf.version,{iconUrl:O,name:T,url:R,scheme:P}=t.dappMetadata||{},I=null===(b=e.platformManager)||void 0===b?void 0:b.getPlatformType();let N="N/A";"undefined"!=typeof window&&window.location&&window.location.hostname?N=window.location.hostname:void 0!==T?N=T:void 0!==R&&(N=R);const B={url:null!=R?R:"",title:null!=T?T:"",icon:O,scheme:null!=P?P:"",apiVersion:L,dappId:N||R||"N/A",platform:null!=I?I:"",source:null!==(w=t._source)&&void 0!==w?w:""},D=jf(JSON.stringify(B));let $=`channelId=${k}&v=2&comm=${null!==(E=e.communicationLayerPreference)&&void 0!==E?E:""}&pubkey=${x}${M}&originatorInfo=${D}`;if(r){$+=`&rpc=${jf(JSON.stringify(r))}`;const t=e.connector.getRPCMethodTracker();t&&(t[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const j=encodeURI($),K=`${e.useDeeplink?wf:bf}?${$}`;return e.qrcodeLink=K,e.developerMode&&Wh(`[RemoteConnection: startConnection()] qrcodeLink=${j}`),_.emit("display_uri",K),(null===(C=e.platformManager)||void 0===C?void 0:C.isSecure())?(yield function(e,t){var n,r;return Be(this,void 0,void 0,(function*(){const i=`${bf}?${t}`,o=`${wf}?${t}`;null===(r=null===(n=e.platformManager)||void 0===n?void 0:n.openDeeplink)||void 0===r||r.call(n,i,o,"_self")}))}(e,j),new Promise(((t,n)=>{var r,i,o;(null===(r=e.connector)||void 0===r?void 0:r.isAuthorized())?t():(null===(i=e.connector)||void 0===i||i.once(Gs.AUTHORIZED,(()=>{t()})),null===(o=e.connector)||void 0===o||o.once(Gs.REJECTED,(()=>{n(Gs.REJECTED)})))}))):function(e,t,n){return Be(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(!e.connector)return void i(new Error("No connector available"));Wh("[RemoteConnection: connectWithModalInstaller()]",{state:e,options:t,linkParams:n});const o=`${e.useDeeplink?wf:bf}?${n}`;!function(e,t,n){var r,i,o,s;e.installModal=null===(i=(r=t.modals).install)||void 0===i?void 0:i.call(r,{link:n,preferDesktop:e.preferDesktop,installer:t.getMetaMaskInstaller(),terminate:()=>{Wh("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),t.sdk.terminate().catch((e=>{console.warn("[MMSDK] failed to terminate connection",e)}))},debug:e.developerMode,connectWithExtension:()=>{var e;return null===(e=t.connectWithExtensionProvider)||void 0===e||e.call(t),!1},onAnalyticsEvent:({event:n,params:r})=>{var i,o,s;const a=Object.assign(Object.assign({},r),{sdkVersion:t.sdk.getVersion(),dappId:null===(i=t.dappMetadata)||void 0===i?void 0:i.name,source:t._source,url:null===(o=t.dappMetadata)||void 0===o?void 0:o.url});null===(s=e.analytics)||void 0===s||s.send({event:n,params:a})}}),null===(s=null===(o=e.installModal)||void 0===o?void 0:o.mount)||void 0===s||s.call(o,n)}(e,t,o),t.sdk.once(Gs.PROVIDER_UPDATE,(e=>Be(this,void 0,void 0,(function*(){Wh("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),e!==Bf.TERMINATE?i(e):i({code:4001,message:"User rejected the request."})})))),e.connector.once(Gs.AUTHORIZED,(()=>{r()})),e.connector.once(Gs.REJECTED,(()=>{i(Gs.REJECTED)})),e.connector.once(Gs.CLIENTS_READY,(()=>Be(this,void 0,void 0,(function*(){Wh("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),r()}))))}))}))}(e,t,j)}catch(e){throw console.error("[startConnection] error",e),e}}))}class up{constructor(e){var t,n,r;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode)||!0===(null===(n=e.logging)||void 0===n?void 0:n.sdk);this.state.developerMode=i,this.state.analytics=e.analytics,this.state.preferDesktop=null!==(r=e.preferDesktop)&&void 0!==r&&r,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=op),e.modals.otp||(e.modals.otp=sp)}startConnection(e){return Be(this,void 0,void 0,(function*(){return dp(this.state,this.options,e)}))}initRemoteCommunication({sdkInstance:e}){var t,n,r;return Be(this,void 0,void 0,(function*(){const i=yield null===(n=null===(t=e.options.storage)||void 0===t?void 0:t.storageManager)||void 0===n?void 0:n.getPersistedChannelConfig();if(!this.options.ecies){const e={privateKey:null==i?void 0:i.localKey};this.options.ecies=e}ap(this.state,this.options),yield null===(r=this.getConnector())||void 0===r?void 0:r.initFromDappStorage(),lp(this.state,this.options)}))}showActiveModal(){return function(e){var t,n,r,i;e.authorized?Wh("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?null===(n=(t=e.pendingModal).mount)||void 0===n||n.call(t):e.installModal&&(null===(i=(r=e.installModal).mount)||void 0===i||i.call(r,e.qrcodeLink||""))}(this.state)}closeModal(){var e,t,n,r;null===(t=null===(e=this.state.pendingModal)||void 0===e?void 0:e.unmount)||void 0===t||t.call(e),null===(r=null===(n=this.state.installModal)||void 0===n?void 0:n.unmount)||void 0===r||r.call(n,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getChannelConfig()}getKeyInfo(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isReady())||!1}isAuthorized(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isAuthorized())||!1}isPaused(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.isPaused()}disconnect(e){var t,n,r;Wh("[RemoteConnection: disconnect()]",e),(null==e?void 0:e.terminate)&&(hf.getProvider().handleDisconnect({terminate:!0}),null===(n=null===(t=this.state.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),this.state.otpAnswer=void 0),null===(r=this.state.connector)||void 0===r||r.disconnect(e),function(e){Wh("[RemoteConnection: cleanupConnector()] cleaning up connector"),e.connector&&(cp(e),e.connector.disconnect({terminate:!0}).catch((e=>{Wh("[RemoteConnection: cleanupConnector()] error disconnecting connector",e)})))}(this.state)}}function hp(e){var t,n,r,i,o,s,a,c,l,d,h;return Be(this,void 0,void 0,(function*(){const{options:f}=e;if(f.logging=null!==(t=f.logging)&&void 0!==t?t:{},f.communicationLayerPreference=null!==(n=f.communicationLayerPreference)&&void 0!==n?n:ha.SOCKET,void 0!==f.enableDebug&&(u.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),f.enableAnalytics=null===(r=f.enableAnalytics)||void 0===r||r,f.injectProvider=null===(i=f.injectProvider)||void 0===i||i,f.shouldShimWeb3=null===(o=f.shouldShimWeb3)||void 0===o||o,f.extensionOnly=null===(s=f.extensionOnly)||void 0===s||s,f.useDeeplink=null===(a=f.useDeeplink)||void 0===a||a,f.storage=null!==(c=f.storage)&&void 0!==c?c:{enabled:!0},f.headless){u("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const e=()=>{},t={install:()=>({mount:e,unmount:e})},n={installer:e};f.modals=t,f.ui=n}const p=!0===(null===(l=f.logging)||void 0===l?void 0:l.developerMode);e.debug=(null===(d=f.logging)||void 0===d?void 0:d.sdk)||p,Wh("[MetaMaskSDK: performSDKInitialization()] options",e.options);const g=Object.assign({},f.logging);p&&(g.sdk=!0,g.eciesLayer=!0,g.keyExchangeLayer=!0,g.remoteLayer=!0,g.serviceLayer=!0,g.plaintext=!0),yield function(e){var t;return Be(this,void 0,void 0,(function*(){const{options:n}=e;e.platformManager=new ff({useDeepLink:null!==(t=n.useDeeplink)&&void 0!==t&&t,preferredOpenLink:n.openDeeplink,debug:e.debug})}))}(e),yield function(e){var t,n,r,i,o,s,a,c,l;return Be(this,void 0,void 0,(function*(){const{options:d}=e,u=null===(t=e.platformManager)||void 0===t?void 0:t.getPlatformType();e.analytics=new zf({serverUrl:null!==(n=d.communicationServerUrl)&&void 0!==n?n:Us,enabled:d.enableAnalytics,originatorInfo:{url:null!==(r=d.dappMetadata.url)&&void 0!==r?r:"",title:null!==(i=d.dappMetadata.name)&&void 0!==i?i:"",dappId:"undefined"==typeof window||void 0===window.location?null!==(c=null!==(s=null===(o=d.dappMetadata)||void 0===o?void 0:o.name)&&void 0!==s?s:null===(a=d.dappMetadata)||void 0===a?void 0:a.url)&&void 0!==c?c:"N/A":window.location.hostname,platform:null!=u?u:"",source:null!==(l=d._source)&&void 0!==l?l:""}})}))}(e),yield function(e){var t;return Be(this,void 0,void 0,(function*(){const{options:n}=e;!0!==(null===(t=n.storage)||void 0===t?void 0:t.enabled)||n.storage.storageManager||(n.storage.storageManager=yield pf(n.storage))}))}(e),yield function(e){return Be(this,void 0,void 0,(function*(){const{options:t}=e,n=/^(http|https):\/\/[^\s]*$/;if(t.dappMetadata){t.dappMetadata.iconUrl&&!n.test(t.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),t.dappMetadata.iconUrl=void 0),t.dappMetadata.base64Icon&&t.dappMetadata.base64Icon.length>163400&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),t.dappMetadata.base64Icon=void 0),t.dappMetadata.url&&!n.test(t.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const e=(()=>{if("undefined"==typeof document)return;let e;const t=document.getElementsByTagName("link");for(let n=0;n<t.length;n++)"icon"!==t[n].getAttribute("rel")&&"shortcut icon"!==t[n].getAttribute("rel")||(e=t[n].getAttribute("href"));return e})();if(e&&!t.dappMetadata.iconUrl&&!t.dappMetadata.base64Icon){const n=`${window.location.protocol}//${window.location.host}${e}`;t.dappMetadata.iconUrl=n}}e.dappMetadata=t.dappMetadata}))}(e),yield(e=>Be(void 0,void 0,void 0,(function*(){const{options:t}=e,{infuraAPIKey:n}=t;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};e.options.readonlyRPCMap?e.options.readonlyRPCMap=Object.assign(Object.assign({},e.options.readonlyRPCMap),r):e.options.readonlyRPCMap=r})))(e),yield(e=>Be(void 0,void 0,void 0,(function*(){const{options:t}=e,{readonlyRPCMap:n}=t;if(n)try{Wh("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),e.setReadOnlyRPCCalls(!0)}catch(e){throw new Error("Invalid Infura Settings")}})))(e);const{metamaskBrowserExtension:m,preferExtension:y,shouldReturn:v}=yield function(e){var t,n,r,i;return Be(this,void 0,void 0,(function*(){const{options:o}=e;let s,a=!1,c=!1;if("undefined"!=typeof window&&window.ethereum&&!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){a="extension"===localStorage.getItem(Mf);try{s=yield function({mustBeMetaMask:e,sdkInstance:t}){return Be(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw new Error("window not available");try{const e=yield new Promise(((e,t)=>{const n=setTimeout((()=>{t(new Error("eip6963RequestProvider timed out"))}),500);window.addEventListener(Wf.Announce,(t=>{const r=t,{detail:{info:i,provider:o}={}}=r,{name:s,rdns:a,uuid:c}=null!=i?i:{};Cf.test(c)&&s.startsWith(Ef.NAME)&&Ef.RDNS.includes(a)&&(clearTimeout(n),e(o))})),window.dispatchEvent(new Event(Wf.Request))}));return Vf({provider:e,sdkInstance:t})}catch(n){if(!e&&window.ethereum)return Vf({provider:window.ethereum,sdkInstance:t});throw new Error("Provider not found")}}))}({mustBeMetaMask:!0,sdkInstance:e}),window.extension=s,s.on(Tf,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Tf,t)})),s.on(Rf,(t=>Be(this,void 0,void 0,(function*(){var n;Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${t}`);const r=Boolean(e.sdkProvider),i=Boolean(e.extensionActive);if(r&&e.getMobileProvider().emit(Rf,t),i&&0===(null==t?void 0:t.length)&&0===(yield null===(n=e.getProvider())||void 0===n?void 0:n.request({method:_f.WALLET_GETPERMISSIONS,params:[]})).length)try{yield e.terminate()}catch(e){Wh("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",e)}})))),s.on(Pf,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Pf,t)})),s.on(If,(t=>{Wh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(If,t)})),s.on(Nf,(t=>{Wh("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",t),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Nf,t)}))}catch(e){window.extension=void 0}}else(null===(n=e.platformManager)||void 0===n?void 0:n.isMetaMaskMobileWebView())&&(null===(r=e.analytics)||void 0===r||r.send({event:Xs.SDK_USE_INAPP_BROWSER}),e.activeProvider=Vf({provider:window.ethereum,sdkInstance:e}),e._initialized=!0,c=!0);return s&&o.extensionOnly&&(Wh("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),null===(i=e.analytics)||void 0===i||i.send({event:Xs.SDK_USE_EXTENSION}),e.activeProvider=s,e.extensionActive=!0,e.extension=s,e._initialized=!0,c=!0),{preferExtension:a,shouldReturn:c,metamaskBrowserExtension:s}}))}(e);if(v)Wh("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield function(e,t){var n,r,i,o,s;return Be(this,void 0,void 0,(function*(){const{options:a}=e,c=Object.assign({},a.logging);e.remoteConnection=new up({preferDesktop:null!==(n=a.preferDesktop)&&void 0!==n&&n,communicationLayerPreference:null!==(r=a.communicationLayerPreference)&&void 0!==r?r:ha.SOCKET,analytics:e.analytics,dappMetadata:a.dappMetadata,_source:a._source,enableAnalytics:null===(i=a.enableAnalytics)||void 0===i||i,timer:a.timer,sdk:e,platformManager:e.platformManager,transports:a.transports,communicationServerUrl:a.communicationServerUrl,storage:null!==(o=a.storage)&&void 0!==o?o:{enabled:!0},getMetaMaskInstaller:()=>{if(!e.installer)throw new Error("Invalid SDK status -- installer not initialized");return e.installer},logging:c,connectWithExtensionProvider:void 0===t?void 0:()=>$f(e),modals:Object.assign(Object.assign({},a.modals),{onPendingModalDisconnect:e.terminate.bind(e)})}),yield e.remoteConnection.initRemoteCommunication({sdkInstance:e}),e.installer=new rp({remote:e.remoteConnection,preferDesktop:null!==(s=a.preferDesktop)&&void 0!==s&&s,platformManager:e.platformManager,debug:e.debug})}))}(e,m),yield function(e){var t,n,r,i;return Be(this,void 0,void 0,(function*(){const{options:o}=e,s={communicationLayerPreference:null!==(t=o.communicationLayerPreference)&&void 0!==t?t:ha.SOCKET,platformManager:e.platformManager,sdk:e,checkInstallationOnAllCalls:o.checkInstallationOnAllCalls,injectProvider:null===(n=o.injectProvider)||void 0===n||n,shouldShimWeb3:null===(r=o.shouldShimWeb3)||void 0===r||r,extensionOnly:null===(i=o.extensionOnly)||void 0===i||i,installer:e.installer,remoteConnection:e.remoteConnection,debug:e.debug},a=yield Hf(s);e.activeProvider=a,function(e){var t,n,r,i;null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n||n.on(uf.ConnectionStatus,(t=>{e.emit(uf.ConnectionStatus,t)})),null===(i=null===(r=e.remoteConnection)||void 0===r?void 0:r.getConnector())||void 0===i||i.on(uf.ServiceStatus,(t=>{e.emit(uf.ServiceStatus,t)}))}(e)}))}(e),yield function(e,t){var n,r;return Be(this,void 0,void 0,(function*(){const{options:i}=e;t?(Wh("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),null===(n=e.analytics)||void 0===n||n.send({event:Xs.SDK_EXTENSION_UTILIZED}),$f(e).catch((e=>{console.warn("Can't connect with MetaMask extension...",e),localStorage.removeItem(Mf)}))):i.checkInstallationImmediately&&((null===(r=e.platformManager)||void 0===r?void 0:r.isDesktopWeb())?(Wh("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),e.connect().catch((e=>{Wh(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${e}`)}))):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),e._initialized=!0}))}(e,y);try{yield null===(h=e.remoteConnection)||void 0===h?void 0:h.startConnection({initialCheck:!0})}catch(e){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",e)}e.emit(uf.ProviderUpdate,Bf.INITIALIZED)}}))}class fp extends f{constructor(e={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:vf,i18nOptions:{enabled:!1}}){var t,n,r;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],u.disable();const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode);if(((null===(n=e.logging)||void 0===n?void 0:n.sdk)||i)&&u.enable("MM_SDK"),Wh("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(null===(r=e.dappMetadata)||void 0===r?void 0:r.url)){if("undefined"==typeof window||"undefined"==typeof document)throw new Error("You must provide dAppMetadata url");e.dappMetadata=Object.assign(Object.assign({},e.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.options=e,this.options._source||(e._source=vf),this.init().then((()=>{Wh("[MetaMaskSDK: constructor()]: initialized successfully."),"undefined"!=typeof window&&(window.mmsdk=this)})).catch((e=>{console.error("[MetaMaskSDK: constructor()] error during initialization",e)}))}init(){return Be(this,void 0,void 0,(function*(){return function(e){var t;return Be(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&(null===(t=window.mmsdk)||void 0===t?void 0:t.isInitialized()))return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return Wh("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=hp(e),yield e.sdkInitPromise}catch(e){throw console.error(e),e}return e.sdkInitPromise}))}(this)}))}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return"undefined"!=typeof window&&Boolean(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}connect(){return Be(this,void 0,void 0,(function*(){return function(e){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const t=e.activeProvider.getSelectedAddress();return t?[t]:e.activeProvider.request({method:_f.ETH_REQUESTACCOUNTS,params:[]})}))}(this)}))}connectAndSign({msg:e}){return Be(this,void 0,void 0,(function*(){return function({instance:e,msg:t}){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connectAndSign()] activeProvider=${e.activeProvider}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(t)?t:function(e){let t;if(void 0!==Xe)t=Xe.from(e,"utf8").toString("hex");else if("undefined"!=typeof TextEncoder){const n=(new TextEncoder).encode(e);t=Array.from(n).map((e=>e.toString(16).padStart(2,"0"))).join("")}else{if("object"!=typeof De||!("Buffer"in De))throw new Error("Unable to convert string to hex: No available method.");t=De.Buffer.from(e,"utf8").toString("hex")}return`0x${t}`}(t);return e.activeProvider.request({method:_f.METAMASK_CONNECTWITH,params:[{method:_f.PERSONAL_SIGN,params:[n]}]})}))}({instance:this,msg:e})}))}connectWith(e){return Be(this,void 0,void 0,(function*(){return function({instance:e,rpc:t}){return Be(this,void 0,void 0,(function*(){if(e._initialized||(Wh("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield e.init()),Wh(`[MetaMaskSDK: connectWith()] method: ${t.method} rpc=${t}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");return e.activeProvider.request({method:_f.METAMASK_CONNECTWITH,params:[t]})}))}({instance:this,rpc:e})}))}resume(){return function(e){var t,n,r;return Be(this,void 0,void 0,(function*(){if(!(null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n?void 0:n.isReady()))return Wh("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void(null===(r=e.remoteConnection)||void 0===r||r.startConnection());Wh("[MetaMaskSDK: resume()] channel is ready")}))}(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;null===(e=this.remoteConnection)||void 0===e||e.isAuthorized()}terminate(){return function(e){var t,n,r;return Be(this,void 0,void 0,(function*(){if(!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){if(Df&&(window.localStorage.removeItem(Mf),window.localStorage.removeItem(Of),window.localStorage.removeItem(Lf)),e.extensionActive){try{yield null===(n=e.activeProvider)||void 0===n?void 0:n.request({method:_f.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(e){Wh("[MetaMaskSDK: terminate()] error revoking permissions",e)}return e.options.extensionOnly?(e.emit(uf.ProviderUpdate,Bf.TERMINATE),void Wh("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(uf.ProviderUpdate,Bf.TERMINATE))}e.emit(uf.ProviderUpdate,Bf.TERMINATE),Wh(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),null===(r=e.remoteConnection)||void 0===r||r.disconnect({terminate:!0,sendMessage:!0})}}))}(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getUniversalLink();if(!t)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return t}getChannelId(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig())||void 0===t?void 0:t.channelId}getRPCHistory(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getRPCMethodTracker()}getVersion(){return yf.version}getWalletStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getConnectionStatus()}_getChannelConfig(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig()}_ping(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.ping()}_keyCheck(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.keyCheck()}_getServiceStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getKeyInfo()}_resetKeys(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,t){return super.emit(e,t)}on(e,t){return super.on(e,t)}}var pp=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:e}={enabled:!1}){this.enabled=!1,this.enabled=e}persistChannelConfig(e){return Be(this,void 0,void 0,(function*(){const t=JSON.stringify(e);Wh(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,e),localStorage.setItem(Af,t)}))}getPersistedChannelConfig(){return Be(this,void 0,void 0,(function*(){let e;try{if(Wh(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),e=localStorage.getItem(Af),Wh("[StorageManagerWeb: getPersistedChannelConfig()]",e),!e)return;const t=JSON.parse(e);return Wh("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",t),t}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}}))}persistAccounts(e){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,e);const t=JSON.stringify(e);localStorage.setItem(Lf,t)}))}getCachedAccounts(){return Be(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Lf);return e?JSON.parse(e):[]}catch(e){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",e),e}}))}persistChainId(e){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,e),localStorage.setItem(Of,e)}))}getCachedChainId(){return Be(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Of);return null!=e?e:void 0}catch(e){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",e),e}}))}terminate(){return Be(this,void 0,void 0,(function*(){Wh(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(Af)}))}}});var gp=Object.defineProperty,mp=new WeakMap,yp=e=>mp.get(e),vp=(e,t)=>mp.set(t.$lazyInstance$=e,t),bp=(e,t)=>t in e,wp=(e,t)=>(0,console.error)(e,t),Ep=new Map,Cp=new Map,_p="slot-fb{display:contents}slot-fb[hidden]{display:none}",Sp="undefined"!=typeof window?window:{},kp=Sp.document||{head:{}},xp={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},Ap=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),Mp=!1,Lp=[],Op=[],Tp=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){wp(e)}e.length=0},Rp=()=>{Tp(Lp),Tp(Op),(Mp=Lp.length>0)&&xp.raf(Rp)},Pp=e=>Promise.resolve(void 0).then(e),Ip=((e,t)=>t=>{e.push(t),Mp||(Mp=!0,4&xp.$flags$?Pp(Rp):xp.raf(Rp))})(Op),Np={},Bp=e=>"object"==(e=typeof e)||"function"===e;function Dp(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}((e,t)=>{for(var n in t)gp(e,n,{get:t[n],enumerable:!0})})({},{err:()=>jp,map:()=>Kp,ok:()=>$p,unwrap:()=>Fp,unwrapErr:()=>Hp});var $p=e=>({isOk:!0,isErr:!1,value:e}),jp=e=>({isOk:!1,isErr:!0,value:e});function Kp(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then((e=>$p(e))):$p(n)}if(e.isErr){const t=e.value;return jp(t)}throw"should never get here"}var Up,Fp=e=>{if(e.isOk)return e.value;throw e.value},Hp=e=>{if(e.isErr)return e.value;throw e.value},zp=(e,t,...n)=>{let r=null,i=!1,o=!1;const s=[],a=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?a(r):null!=r&&"boolean"!=typeof r&&((i="function"!=typeof e&&!Bp(r))&&(r=String(r)),i&&o?s[s.length-1].$text$+=r:s.push(i?qp(null,r):r),o=i)};if(a(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}if("function"==typeof e)return e(null===t?{}:t,s,Wp);const c=qp(e,null);return c.$attrs$=t,s.length>0&&(c.$children$=s),c},qp=(e,t)=>({$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null}),Vp={},Wp={forEach:(e,t)=>e.map(Gp).forEach(t),map:(e,t)=>e.map(Gp).map(t).map(Yp)},Gp=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),Yp=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),zp(e.vtag,t,...e.vchildren||[])}const t=qp(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},Zp=e=>yp(e).$hostElement$,Jp=(e,t,n)=>{const r=Zp(e);return{emit:e=>Xp(r,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},Xp=(e,t,n)=>{const r=xp.ce(t,n);return e.dispatchEvent(r),r},Qp=new WeakMap,eg=(e,t)=>"sc-"+e.$tagName$,tg=(e,t,n,r,i,o)=>{if(n!==r){let s=bp(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,i=rg(n),o=rg(r);t.remove(...i.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!i.includes(e))))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if(s||"o"!==t[0]||"n"!==t[1]){const a=Bp(r);if((s||a&&null!==r)&&!i)try{if(e.tagName.includes("-"))e[t]=r;else{const i=null==r?"":r;"list"===t?s=!1:null!=n&&e[t]==i||("function"==typeof e.__lookupSetter__(t)?e[t]=i:e.setAttribute(t,i))}}catch(e){}null==r||!1===r?!1===r&&""!==e.getAttribute(t)||e.removeAttribute(t):(!s||4&o||i)&&!a&&(r=!0===r?"":r,e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):bp(Sp,a)?a.slice(2):a[2]+t.slice(3),n||r){const i=t.endsWith(ig);t=t.replace(og,""),n&&xp.rel(e,t,n,i),r&&xp.ael(e,t,r,i)}}},ng=/\s/,rg=e=>e?e.split(ng):[],ig="Capture",og=new RegExp(ig+"$"),sg=(e,t,n)=>{const r=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,i=e&&e.$attrs$||Np,o=t.$attrs$||Np;for(const e of ag(Object.keys(i)))e in o||tg(r,e,i[e],void 0,n,t.$flags$);for(const e of ag(Object.keys(o)))tg(r,e,i[e],o[e],n,t.$flags$)};function ag(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var cg=!1,lg=(e,t,n,r)=>{const i=t.$children$[n];let o,s,a=0;if(null!==i.$text$)o=i.$elm$=kp.createTextNode(i.$text$);else{if(cg||(cg="svg"===i.$tag$),o=i.$elm$=kp.createElementNS(cg?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),cg&&"foreignObject"===i.$tag$&&(cg=!1),sg(null,i,cg),o.getRootNode().querySelector("body"),i.$children$)for(a=0;a<i.$children$.length;++a)s=lg(e,i,a),s&&o.appendChild(s);"svg"===i.$tag$?cg=!1:"foreignObject"===o.tagName&&(cg=!0)}return o["s-hn"]=Up,o},dg=(e,t,n,r,i,o)=>{let s,a=e;for(a.shadowRoot&&a.tagName===Up&&(a=a.shadowRoot);i<=o;++i)r[i]&&(s=lg(null,n,i),s&&(r[i].$elm$=s,pg(a,s,t)))},ug=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;e&&e.remove()}}},hg=(e,t,n=!1)=>e.$tag$===t.$tag$,fg=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,i=e.$children$,o=t.$children$,s=t.$tag$,a=t.$text$;null===a?(sg(e,t,cg="svg"===s||"foreignObject"!==s&&cg),null!==i&&null!==o?((e,t,n,r,i=!1)=>{let o,s=0,a=0,c=t.length-1,l=t[0],d=t[c],u=r.length-1,h=r[0],f=r[u];for(;s<=c&&a<=u;)null==l?l=t[++s]:null==d?d=t[--c]:null==h?h=r[++a]:null==f?f=r[--u]:hg(l,h,i)?(fg(l,h,i),l=t[++s],h=r[++a]):hg(d,f,i)?(fg(d,f,i),d=t[--c],f=r[--u]):hg(l,f,i)?(fg(l,f,i),pg(e,l.$elm$,d.$elm$.nextSibling),l=t[++s],f=r[--u]):hg(d,h,i)?(fg(d,h,i),pg(e,d.$elm$,l.$elm$),d=t[--c],h=r[++a]):(o=lg(t&&t[a],n,a),h=r[++a],o&&pg(l.$elm$.parentNode,o,l.$elm$));s>c?dg(e,null==r[u+1]?null:r[u+1].$elm$,n,r,a,u):a>u&&ug(t,s,c)})(r,i,t,o,n):null!==o?(null!==e.$text$&&(r.textContent=""),dg(r,null,t,o,0,o.length-1)):!n&&null!==i&&ug(i,0,i.length-1),cg&&"svg"===s&&(cg=!1)):e.$text$!==a&&(r.data=a)},pg=(e,t,n)=>null==e?void 0:e.insertBefore(t,n),gg=(e,t)=>{t&&!e.$onRenderResolve$&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.$onRenderResolve$=t)))},mg=(e,t)=>{if(e.$flags$|=16,!(4&e.$flags$))return gg(e,e.$ancestorComponent$),Ip((()=>yg(e,t)));e.$flags$|=512},yg=(e,t)=>{const n=e.$hostElement$;e.$cmpMeta$.$tagName$;const r=e.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return vg(void 0,(()=>wg(e,r,t)))},vg=(e,t)=>bg(e)?e.then(t).catch((e=>{console.error(e),t()})):t(),bg=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,wg=async(e,t,n)=>{var r;const i=e.$hostElement$;e.$cmpMeta$.$tagName$;const o=i["s-rc"];n&&(e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$;t.$tagName$;const i=((e,t,n)=>{var r;const i=eg(t),o=Cp.get(i);if(e=11===e.nodeType?e:kp,o)if("string"==typeof o){e=e.head||e;let n,s=Qp.get(e);if(s||Qp.set(e,s=new Set),!s.has(i)){{n=kp.createElement("style"),n.innerHTML=o;const i=null!=(r=xp.$nonce$)?r:Dp(kp);if(null!=i&&n.setAttribute("nonce",i),!(1&t.$flags$))if("HEAD"===e.nodeName){const t=e.querySelectorAll("link[rel=preconnect]"),r=t.length>0?t[t.length-1].nextSibling:e.querySelector("style");e.insertBefore(n,r)}else if("host"in e)if(Ap){const t=new CSSStyleSheet;t.replaceSync(o),e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}else{const t=e.querySelector("style");t?t.innerHTML=o+t.innerHTML:e.prepend(n)}else e.append(n);1&t.$flags$&&"HEAD"!==e.nodeName&&e.insertBefore(n,null)}4&t.$flags$&&(n.innerHTML+=_p),s&&s.add(i)}}else e.adoptedStyleSheets.includes(o)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,o]);return i})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))})(e),e.$cmpMeta$.$tagName$,Eg(e,t,i,n),o&&(o.map((e=>e())),i["s-rc"]=void 0);{const t=null!=(r=i["s-p"])?r:[],n=()=>Cg(e);0===t.length?n():(Promise.all(t).then(n),e.$flags$|=4,t.length=0)}},Eg=(e,t,n,r)=>{try{t=t.render(),e.$flags$&=-17,e.$flags$|=2,((e,t,n=!1)=>{const r=e.$hostElement$,i=e.$cmpMeta$,o=e.$vnode$||qp(null,null),s=(a=t)&&a.$tag$===Vp?t:zp(null,null,t);var a;if(Up=r.tagName,n&&s.$attrs$)for(const e of Object.keys(s.$attrs$))r.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(s.$attrs$[e]=r[e]);s.$tag$=null,s.$flags$|=4,e.$vnode$=s,s.$elm$=o.$elm$=r.shadowRoot||r,r["s-sc"],0!=(1&i.$flags$),fg(o,s,n)})(e,t,r)}catch(t){wp(t,e.$hostElement$)}return null},Cg=e=>{e.$cmpMeta$.$tagName$;const t=e.$hostElement$,n=e.$lazyInstance$,r=e.$ancestorComponent$;64&e.$flags$||(e.$flags$|=64,kg(t),Sg(n,"componentDidLoad"),e.$onReadyResolve$(t),r||_g()),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),512&e.$flags$&&Pp((()=>mg(e,!1))),e.$flags$&=-517},_g=e=>{kg(kp.documentElement),Pp((()=>Xp(Sp,"appload",{detail:{namespace:"sdk-install-modal-web"}})))},Sg=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){wp(e)}},kg=e=>e.classList.add(("hydrated","hydrated")),xg=(e,t,n)=>{var r,i;const o=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const s=Object.entries(null!=(r=t.$members$)?r:{});if(s.map((([e,[r]])=>{(31&r||2&n&&32&r)&&Object.defineProperty(o,e,{get(){return t=e,yp(this).$instanceValues$.get(t);var t},set(n){((e,t,n,r)=>{const i=yp(e);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const o=i.$hostElement$,s=i.$instanceValues$.get(t),a=i.$flags$,c=i.$lazyInstance$;var l,d;l=n,d=r.$members$[t][0],n=null==l||Bp(l)?l:4&d?"false"!==l&&(""===l||!!l):1&d?String(l):l;const u=Number.isNaN(s)&&Number.isNaN(n);if((!(8&a)||void 0===s)&&n!==s&&!u&&(i.$instanceValues$.set(t,n),c)){if(r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{c[e](n,s,t)}catch(e){wp(e,o)}}))}2==(18&a)&&mg(i,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;o.attributeChangedCallback=function(e,r,i){xp.jmp((()=>{var s;const a=n.get(e);if(this.hasOwnProperty(a))i=this[a],delete this[a];else{if(o.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==i)return;if(null==a){const n=yp(this),o=null==n?void 0:n.$flags$;if(o&&!(8&o)&&128&o&&i!==r){const o=n.$lazyInstance$,a=null==(s=t.$watchers$)?void 0:s[e];null==a||a.forEach((t=>{null!=o[t]&&o[t].call(o,i,r,e)}))}return}}this[a]=(null!==i||"boolean"!=typeof this[a])&&i}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(i=t.$watchers$)?i:{}),...s.filter((([e,t])=>15&t[0])).map((([e,t])=>{const r=t[1]||e;return n.set(r,e),r}))]))}}return e},Ag=e=>{Sg(e,"connectedCallback")},Mg=e=>{Sg(e,"disconnectedCallback")},Lg=(e,t={})=>{var r;const i=[],o=t.exclude||[],s=Sp.customElements,a=kp.head,c=a.querySelector("meta[charset]"),l=kp.createElement("style"),d=[];let u,h=!0;Object.assign(xp,t),xp.$resourcesUrl$=new URL(t.resourcesUrl||"./",kp.baseURI).href;let f=!1;if(e.map((e=>{e[1].map((t=>{var r;const a={$flags$:t[0],$tagName$:t[1],$members$:t[2],$listeners$:t[3]};4&a.$flags$&&(f=!0),a.$members$=t[2],a.$watchers$=null!=(r=t[4])?r:{};const c=a.$tagName$,l=class extends HTMLElement{constructor(e){if(super(e),this.hasRegisteredEventListeners=!1,((e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map};n.$onReadyPromise$=new Promise((e=>n.$onReadyResolve$=e)),e["s-p"]=[],e["s-rc"]=[],mp.set(e,n)})(e=this,a),1&a.$flags$)if(e.shadowRoot){if("open"!==e.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${a.$tagName$}! Mode is set to ${e.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else e.attachShadow({mode:"open"})}connectedCallback(){yp(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),u&&(clearTimeout(u),u=null),h?d.push(this):xp.jmp((()=>(e=>{if(0==(1&xp.$flags$)){const t=yp(e),r=t.$cmpMeta$;if(r.$tagName$,1&t.$flags$)(null==t?void 0:t.$lazyInstance$)?Ag(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Ag(t.$lazyInstance$)));else{t.$flags$|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){gg(t,t.$ancestorComponent$=n);break}}r.$members$&&Object.entries(r.$members$).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,r,i)=>{let o;if(0==(32&t.$flags$)){if(t.$flags$|=32,r.$lazyBundleId$){const i=((e,t,r)=>{const i=e.$tagName$.replace(/-/g,"_"),o=e.$lazyBundleId$;if(!o)return;const s=Ep.get(o);if(s)return s[i];{const e=e=>(Ep.set(o,e),e[i]);if("mm-install-modal_3"===o)return Promise.resolve().then((function(){return pm})).then(e,wp)}return function(e){return Promise.resolve().then((function(){return n(require(e))}))}(`./${o}.entry.js`).then((e=>(Ep.set(o,e),e[i])),wp)})(r);if(o=i&&"then"in i?await i:i,!o)throw new Error(`Constructor for "${r.$tagName$}#${t.$modeName$}" was not found`);o.isProxied||(r.$watchers$=o.watchers,xg(o,r,2),o.isProxied=!0),r.$tagName$,t.$flags$|=8;try{new o(t)}catch(e){wp(e)}t.$flags$&=-9,t.$flags$|=128,Ag(t.$lazyInstance$)}else{o=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(o&&o.style){let e;"string"==typeof o.style&&(e=o.style);const t=eg(r);Cp.has(t)||(r.$tagName$,((e,t,n)=>{let r=Cp.get(e);Ap&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,Cp.set(e,r)})(t,e,!!(1&r.$flags$)))}}const s=t.$ancestorComponent$,a=()=>mg(t,!0);s&&s["s-rc"]?s["s-rc"].push(a):a()})(e,t,r)}}})(this)))}disconnectedCallback(){xp.jmp((()=>(async e=>{if(0==(1&xp.$flags$)){const t=yp(e);(null==t?void 0:t.$lazyInstance$)?Mg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Mg(t.$lazyInstance$)))}})(this)))}componentOnReady(){return yp(this).$onReadyPromise$}};a.$lazyBundleId$=e[0],o.includes(c)||s.get(c)||(i.push(c),s.define(c,xg(l,a,1)))}))})),i.length>0&&(f&&(l.textContent+=_p),l.textContent+=i.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",l.innerHTML.length)){l.setAttribute("data-styles","");const e=null!=(r=xp.$nonce$)?r:Dp(kp);null!=e&&l.setAttribute("nonce",e),a.insertBefore(l,c?c.nextSibling:a.firstChild)}h=!1,d.length?d.map((e=>e.connectedCallback())):xp.jmp((()=>u=setTimeout(_g,30)))};!function(){if("undefined"!=typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}}();var Og=Object.freeze({__proto__:null,defineCustomElements:async(e,t)=>{if("undefined"!=typeof window)return await void 0,Lg([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],t)},setNonce:e=>xp.$nonce$=e});const Tg={fontFamily:"Roboto, sans-serif"},Rg=({className:e},t)=>zp("div",{style:Tg,class:e},t),Pg=({Icon:e,text:t})=>zp("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},zp("div",{class:"flexItem1"},zp(e,null)),zp("div",{class:"flexItem11"},zp("span",{style:{lineHeight:"2",color:"black"}},t))),Ig=()=>zp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),zp("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Ng=()=>zp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),Bg=()=>zp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),Dg=()=>zp("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function $g({version:e}){return zp("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",e?`v${e}`:"unknown")}const jg=()=>zp("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("rect",{width:"16",height:"16",fill:"white"}),zp("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),Kg=()=>zp("svg",{width:"273",height:"51",viewBox:"0 0 273 51",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M240.882 25.9263C239.472 24.997 237.916 24.3361 236.443 23.5101C235.489 22.9731 234.473 22.4982 233.643 21.8167C232.233 20.6602 232.524 18.3885 233.996 17.3973C236.112 15.993 239.617 16.7777 239.99 19.6483C239.99 19.7102 240.052 19.7515 240.114 19.7515H243.308C243.391 19.7515 243.454 19.6896 243.433 19.607C243.267 17.6244 242.5 15.9723 241.089 14.9191C239.741 13.9072 238.206 13.3702 236.568 13.3702C228.127 13.3702 227.359 22.271 231.901 25.0796C232.42 25.41 236.879 27.6404 238.455 28.611C240.032 29.5816 240.529 31.3576 239.845 32.7619C239.223 34.0423 237.605 34.9303 235.987 34.8271C234.224 34.7238 232.855 33.7738 232.378 32.2869C232.295 32.0185 232.254 31.5022 232.254 31.275C232.254 31.2131 232.192 31.1511 232.129 31.1511H228.666C228.604 31.1511 228.541 31.2131 228.541 31.275C228.541 33.7738 229.164 35.1575 230.864 36.4172C232.461 37.615 234.203 38.1106 236.008 38.1106C240.737 38.1106 243.184 35.4466 243.682 32.6793C244.117 29.974 243.308 27.5371 240.882 25.9263Z",fill:"#24292E"}),zp("path",{d:"M90.4943 13.8246H88.9595H87.2795C87.2173 13.8246 87.1758 13.8659 87.1551 13.9072L84.3137 23.2416C84.2722 23.3655 84.1063 23.3655 84.0648 23.2416L81.2234 13.9072C81.2026 13.8452 81.1612 13.8246 81.0989 13.8246H79.419H77.8842H75.8102C75.748 13.8246 75.6857 13.8865 75.6857 13.9485V37.7802C75.6857 37.8422 75.748 37.9041 75.8102 37.9041H79.2738C79.336 37.9041 79.3982 37.8422 79.3982 37.7802V19.6689C79.3982 19.5244 79.6056 19.5037 79.6471 19.6276L82.5093 29.024L82.7167 29.6849C82.7374 29.7468 82.7789 29.7675 82.8411 29.7675H85.4959C85.5581 29.7675 85.5996 29.7262 85.6203 29.6849L85.8277 29.024L88.6899 19.6276C88.7313 19.4831 88.9387 19.5244 88.9387 19.6689V37.7802C88.9387 37.8422 89.001 37.9041 89.0632 37.9041H92.5268C92.589 37.9041 92.6513 37.8422 92.6513 37.7802V13.9485C92.6513 13.8865 92.589 13.8246 92.5268 13.8246H90.4943Z",fill:"#24292E"}),zp("path",{d:"M187.849 13.8246C187.787 13.8246 187.745 13.8659 187.725 13.9072L184.883 23.2416C184.842 23.3655 184.676 23.3655 184.634 23.2416L181.793 13.9072C181.772 13.8452 181.731 13.8246 181.668 13.8246H176.4C176.338 13.8246 176.276 13.8865 176.276 13.9485V37.7802C176.276 37.8422 176.338 37.9041 176.4 37.9041H179.864C179.926 37.9041 179.988 37.8422 179.988 37.7802V19.6689C179.988 19.5244 180.196 19.5037 180.237 19.6276L183.099 29.024L183.307 29.6849C183.328 29.7468 183.369 29.7675 183.431 29.7675H186.086C186.148 29.7675 186.19 29.7262 186.211 29.6849L186.418 29.024L189.28 19.6276C189.322 19.4831 189.529 19.5244 189.529 19.6689V37.7802C189.529 37.8422 189.591 37.9041 189.653 37.9041H193.117C193.179 37.9041 193.241 37.8422 193.241 37.7802V13.9485C193.241 13.8865 193.179 13.8246 193.117 13.8246H187.849Z",fill:"#24292E"}),zp("path",{d:"M143.174 13.8246H136.724H133.261H126.81C126.748 13.8246 126.686 13.8865 126.686 13.9485V16.9223C126.686 16.9843 126.748 17.0462 126.81 17.0462H133.136V37.7802C133.136 37.8422 133.198 37.9041 133.261 37.9041H136.724C136.786 37.9041 136.849 37.8422 136.849 37.7802V17.0462H143.174C143.237 17.0462 143.299 16.9843 143.299 16.9223V13.9485C143.299 13.8865 143.257 13.8246 143.174 13.8246Z",fill:"#24292E"}),zp("path",{d:"M163.604 37.9041H166.756C166.839 37.9041 166.901 37.8215 166.881 37.7389L160.368 13.8245C160.347 13.7626 160.306 13.7419 160.244 13.7419H159.041H156.925H155.722C155.66 13.7419 155.619 13.7832 155.598 13.8245L149.085 37.7389C149.065 37.8215 149.127 37.9041 149.21 37.9041H152.362C152.425 37.9041 152.466 37.8628 152.487 37.8215L154.374 30.862C154.395 30.8 154.436 30.7794 154.499 30.7794H161.467C161.53 30.7794 161.571 30.8207 161.592 30.862L163.479 37.8215C163.5 37.8628 163.562 37.9041 163.604 37.9041ZM155.328 27.3719L157.859 18.0581C157.9 17.9342 158.066 17.9342 158.107 18.0581L160.638 27.3719C160.659 27.4545 160.596 27.5371 160.513 27.5371H155.453C155.37 27.5371 155.308 27.4545 155.328 27.3719Z",fill:"#24292E"}),zp("path",{d:"M217.362 37.9041H220.515C220.598 37.9041 220.66 37.8215 220.639 37.7389L214.127 13.8245C214.106 13.7626 214.065 13.7419 214.002 13.7419H212.8H210.684H209.481C209.419 13.7419 209.377 13.7832 209.357 13.8245L202.844 37.7389C202.823 37.8215 202.886 37.9041 202.969 37.9041H206.121C206.183 37.9041 206.225 37.8628 206.246 37.8215L208.133 30.862C208.154 30.8 208.195 30.7794 208.257 30.7794H215.226C215.288 30.7794 215.33 30.8207 215.351 30.862L217.238 37.8215C217.259 37.8628 217.3 37.9041 217.362 37.9041ZM209.087 27.3719L211.617 18.0581C211.659 17.9342 211.825 17.9342 211.866 18.0581L214.397 27.3719C214.417 27.4545 214.355 27.5371 214.272 27.5371H209.211C209.129 27.5371 209.066 27.4545 209.087 27.3719Z",fill:"#24292E"}),zp("path",{d:"M106.713 34.3727V26.9795C106.713 26.9176 106.775 26.8556 106.837 26.8556H116.067C116.129 26.8556 116.191 26.7936 116.191 26.7317V23.7579C116.191 23.6959 116.129 23.634 116.067 23.634H106.837C106.775 23.634 106.713 23.572 106.713 23.5101V17.1907C106.713 17.1288 106.775 17.0668 106.837 17.0668H117.332C117.394 17.0668 117.457 17.0049 117.457 16.9429V13.9691C117.457 13.9072 117.394 13.8452 117.332 13.8452H106.713H103.125C103.063 13.8452 103.001 13.9072 103.001 13.9691V17.0668V23.6546V26.8763V34.5173V37.7802C103.001 37.8422 103.063 37.9041 103.125 37.9041H106.713H117.768C117.83 37.9041 117.892 37.8422 117.892 37.7802V34.6412C117.892 34.5792 117.83 34.5173 117.768 34.5173H106.817C106.755 34.4966 106.713 34.4553 106.713 34.3727Z",fill:"#24292E"}),zp("path",{d:"M272.532 37.6976L260.544 25.3687C260.502 25.3274 260.502 25.2448 260.544 25.2035L271.329 14.0517C271.412 13.9691 271.349 13.8452 271.246 13.8452H266.828C266.787 13.8452 266.766 13.8659 266.745 13.8865L257.599 23.3449C257.516 23.4275 257.391 23.3655 257.391 23.2623V13.9691C257.391 13.9072 257.329 13.8452 257.267 13.8452H253.803C253.741 13.8452 253.679 13.9072 253.679 13.9691V37.8009C253.679 37.8628 253.741 37.9248 253.803 37.9248H257.267C257.329 37.9248 257.391 37.8628 257.391 37.8009V27.3099C257.391 27.2067 257.536 27.1447 257.599 27.2273L267.969 37.8835C267.989 37.9041 268.031 37.9248 268.052 37.9248H272.469C272.552 37.9041 272.615 37.7596 272.532 37.6976Z",fill:"#24292E"}),zp("path",{d:"M52.021 1L31.0526 16.4886L34.9517 7.36063L52.021 1Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M3.65491 1L24.4366 16.6331L20.7241 7.36063L3.65491 1Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M44.4716 36.9127L38.8925 45.4211L50.8389 48.7047L54.261 37.0986L44.4716 36.9127Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M1.43555 37.0986L4.83695 48.7047L16.7626 45.4211L11.2042 36.9127L1.43555 37.0986Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.1197 22.5395L12.8013 27.5371L24.6232 28.074L24.2292 15.3734L16.1197 22.5395Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M39.5561 22.5394L31.3222 15.2288L31.0526 28.0739L42.8746 27.537L39.5561 22.5394Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7626 45.4212L23.918 41.9724L17.7582 37.1813L16.7626 45.4212Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.7578 41.9724L38.8925 45.4212L37.9177 37.1813L31.7578 41.9724Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M38.8923 45.4212L31.7577 41.9724L32.3384 46.5983L32.2762 48.5602L38.8923 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7625 45.4212L23.3994 48.5602L23.3579 46.5983L23.9179 41.9724L16.7625 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M23.5239 34.1249L17.5922 32.3902L21.7818 30.4696L23.5239 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.1517 34.1249L33.8939 30.4696L38.1042 32.3902L32.1517 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.7626 45.4212L17.7996 36.9128L11.2042 37.0987L16.7626 45.4212Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M37.8761 36.9128L38.8924 45.4212L44.4715 37.0987L37.8761 36.9128Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M42.8745 27.5371L31.0526 28.074L32.1518 34.1249L33.894 30.4696L38.1042 32.3902L42.8745 27.5371Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M17.5922 32.3902L21.7817 30.4696L23.5239 34.1249L24.6232 28.074L12.8012 27.5371L17.5922 32.3902Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M12.8013 27.5371L17.7582 37.1813L17.5923 32.3902L12.8013 27.5371Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M38.1044 32.3902L37.9177 37.1813L42.8746 27.5371L38.1044 32.3902Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M24.6232 28.0741L23.524 34.125L24.9136 41.2703L25.2247 31.8533L24.6232 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.0526 28.0741L30.4719 31.8327L30.7623 41.2703L32.1519 34.125L31.0526 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.1519 34.1249L30.7623 41.2702L31.7578 41.9724L37.9177 37.1813L38.1043 32.3901L32.1519 34.1249Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M17.5922 32.3901L17.7581 37.1813L23.918 41.9724L24.9135 41.2702L23.5239 34.1249L17.5922 32.3901Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M32.2763 48.5602L32.3385 46.5983L31.7993 46.1439H23.8765L23.358 46.5983L23.3995 48.5602L16.7626 45.4211L19.0855 47.3211L23.7935 50.5633H31.8615L36.5903 47.3211L38.8924 45.4211L32.2763 48.5602Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.7578 41.9724L30.7622 41.2703H24.9135L23.918 41.9724L23.358 46.5983L23.8765 46.144H31.7993L32.3385 46.5983L31.7578 41.9724Z",fill:"#24292E",stroke:"#24292E","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M52.9128 17.5005L54.6757 8.95079L52.021 1L31.7578 15.9723L39.5561 22.5394L50.5692 25.7404L52.9958 22.9111L51.938 22.147L53.618 20.6188L52.3321 19.6276L54.0121 18.3472L52.9128 17.5005Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M1 8.95079L2.78366 17.5005L1.64295 18.3472L3.34365 19.6276L2.05775 20.6188L3.73771 22.147L2.67996 22.9111L5.10657 25.7404L16.1196 22.5394L23.918 15.9723L3.65475 1L1 8.95079Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M50.5692 25.7404L39.5561 22.5394L42.8746 27.5371L37.9177 37.1813L44.4716 37.0987H54.261L50.5692 25.7404Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M16.1196 22.5394L5.10651 25.7404L1.43549 37.0987H11.2041L17.7581 37.1813L12.8011 27.5371L16.1196 22.5394Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M31.0526 28.0741L31.7578 15.9724L34.9518 7.36072H20.7239L23.9179 15.9724L24.6231 28.0741L24.8927 31.8739L24.9135 41.2703H30.7622L30.783 31.8739L31.0526 28.0741Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Ug(e,t){return e.toString(2).padStart(t,"0")}function Fg(e,t){const n=e%t;return n>=0?n:t+n}function Hg(e,t){return new Array(e).fill(t)}function zg(...e){let t=0;for(const n of e)t=Math.max(t,n.length);const n=[];for(let r=0;r<t;r++)for(const t of e)r>=t.length||n.push(t[r]);return new Uint8Array(n)}function qg(e,t,n){if(n<0||n+t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[n+r])return!1;return!0}function Vg(e){return{has:t=>e.includes(t),decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))},encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(function(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))}}}class Wg{static size(e,t){if("number"==typeof e&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return void 0!==t&&(e={width:Math.min(e.width,t.width),height:Math.min(e.height,t.height)}),e}static fromString(e){const t=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split("\n"),n=t.length,r=new Array(n);let i;for(const e of t){const t=e.split("").map((e=>{if("X"===e)return!0;if(" "===e)return!1;if("?"!==e)throw new Error(`Bitmap.fromString: unknown symbol=${e}`)}));if(i&&t.length!==i)throw new Error(`Bitmap.fromString different row sizes: width=${i} cur=${t.length}`);i=t.length,r.push(t)}return i||(i=0),new Wg({height:n,width:i},r)}constructor(e,t){const{height:n,width:r}=Wg.size(e);this.data=t||Array.from({length:n},(()=>Hg(r,void 0))),this.height=n,this.width=r}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:t,y:n}=this.xy(e);return{height:this.height-n,width:this.width-t}}xy(e){if("number"==typeof e&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=Fg(e.x,this.width),e.y=Fg(e.y,this.height),e}rect(e,t,n){const{x:r,y:i}=this.xy(e),{height:o,width:s}=Wg.size(t,this.size({x:r,y:i}));for(let e=0;e<o;e++)for(let t=0;t<s;t++)this.data[i+e][r+t]="function"==typeof n?n({x:t,y:e},this.data[i+e][r+t]):n;return this}rectRead(e,t,n){return this.rect(e,t,((e,t)=>(n(e,t),t)))}hLine(e,t,n){return this.rect(e,{width:t,height:1},n)}vLine(e,t,n){return this.rect(e,{width:1,height:t},n)}border(e=2,t){const n=this.height+2*e,r=this.width+2*e,i=Hg(e,t),o=Array.from({length:e},(()=>Hg(r,t)));return new Wg({height:n,width:r},[...o,...this.data.map((e=>[...i,...e,...i])),...o])}embed(e,t){return this.rect(e,t.size(),(({x:e,y:n})=>t.data[n][e]))}rectSlice(e,t=this.size()){const n=new Wg(Wg.size(t,this.size(this.xy(e))));return this.rect(e,t,(({x:e,y:t},r)=>n.data[t][e]=r)),n}inverse(){const{height:e,width:t}=this;return new Wg({height:t,width:e}).rect({x:0,y:0},1/0,(({x:e,y:t})=>this.data[e][t]))}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:t,width:n}=this;return new Wg({height:e*t,width:e*n}).rect({x:0,y:0},1/0,(({x:t,y:n})=>this.data[Math.floor(n/e)][Math.floor(t/e)]))}clone(){return new Wg(this.size()).rect({x:0,y:0},this.size(),(({x:e,y:t})=>this.data[t][e]))}assertDrawn(){this.rectRead(0,1/0,((e,t)=>{if("boolean"!=typeof t)throw new Error("Invalid color type="+typeof t)}))}toString(){return this.data.map((e=>e.map((e=>void 0===e?"?":e?"X":" ")).join(""))).join("\n")}toASCII(){const{height:e,width:t,data:n}=this;let r="";for(let i=0;i<e;i+=2){for(let o=0;o<t;o++){const t=n[i][o],s=i+1>=e||n[i+1][o];t||s?!t&&s?r+="▀":t&&!s?r+="▄":t&&s&&(r+=" "):r+="█"}r+="\n"}return r}toTerm(){const e="[0m",t=`[1;47m ${e}`,n=`[40m ${e}`;return this.data.map((e=>e.map((e=>e?n:t)).join(""))).join("\n")}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,(({x:t,y:n},r)=>{r&&(e+=`<rect x="${t}" y="${n}" width="1" height="1" />`)})),e+="</svg>",e}toGIF(){const e=e=>[255&e,e>>>8&255],t=[...e(this.width),...e(this.height)],n=[];this.rectRead(0,1/0,((e,t)=>n.push(+(!0===t))));const r=126,i=[71,73,70,56,55,97,...t,246,0,0,255,255,255,...Hg(381,0),44,0,0,0,0,...t,0,7],o=Math.floor(n.length/r);for(let e=0;e<o;e++)i.push(127,128,...n.slice(r*e,r*(e+1)).map((e=>+e)));return i.push(n.length%r+1,128,...n.slice(o*r).map((e=>+e))),i.push(1,129,0,59),new Uint8Array(i)}toImage(e=!1){const{height:t,width:n}=this.size(),r=new Uint8Array(t*n*(e?3:4));let i=0;for(let o=0;o<t;o++)for(let t=0;t<n;t++){const n=this.data[o][t]?0:255;r[i++]=n,r[i++]=n,r[i++]=n,e||(r[i++]=255)}return{height:t,width:n,data:r}}}const Gg=["low","medium","quartile","high"],Yg=["numeric","alphanumeric","byte","kanji","eci"],Zg=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],Jg={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},Xg={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},Qg={size:{encode:e=>21+4*(e-1),decode:e=>(e-17)/4},sizeType:e=>Math.floor((e+7)/17),alignmentPatterns(e){if(1===e)return[];const t=Qg.size.encode(e)-6-1,n=t-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const o=[6];for(let e=1;e<r;e++)o.push(t-(r-e)*i);return o.push(t),o},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(e,t){const n=Qg.ECCode[e]<<3|t;let r=n;for(let e=0;e<10;e++)r=r<<1^1335*(r>>9);return(n<<10|r)^Qg.formatMask},versionBits(e){let t=e;for(let e=0;e<12;e++)t=t<<1^7973*(t>>11);return e<<12|t},alphabet:{numeric:Vg("0123456789"),alphanumerc:Vg("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(e,t)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[t][Qg.sizeType(e)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(e,t){const n=Zg[e-1],r=Jg[t][e-1],i=Xg[t][e-1],o=Math.floor(n/i)-r,s=i-n%i;return{words:r,numBlocks:i,shortBlocks:s,blockLen:o,capacity:8*(n-r*i),total:(r+o)*i+i-s}}},em=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,(e,t)=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(t/2)+Math.floor(e/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0],tm={tables:(e=>{const t=Hg(256,0),n=Hg(256,0);for(let e=0,r=1;e<256;e++)t[e]=r,n[r]=e,r<<=1,256&r&&(r^=285);return{exp:t,log:n}})(),exp:e=>tm.tables.exp[e],log(e){if(0===e)throw new Error(`GF.log: wrong arg=${e}`);return tm.tables.log[e]%255},mul:(e,t)=>0===e||0===t?0:tm.tables.exp[(tm.tables.log[e]+tm.tables.log[t])%255],add:(e,t)=>e^t,pow:(e,t)=>tm.tables.exp[tm.tables.log[e]*t%255],inv(e){if(0===e)throw new Error(`GF.inverse: wrong arg=${e}`);return tm.tables.exp[255-tm.tables.log[e]]},polynomial(e){if(0==e.length)throw new Error("GF.polymomial: wrong length");if(0!==e[0])return e;let t=0;for(;t<e.length-1&&0==e[t];t++);return e.slice(t)},monomial(e,t){if(e<0)throw new Error(`GF.monomial: wrong degree=${e}`);if(0==t)return[0];let n=Hg(e+1,0);return n[0]=t,tm.polynomial(n)},degree:e=>e.length-1,coefficient:(e,t)=>e[tm.degree(e)-t],mulPoly(e,t){if(0===e[0]||0===t[0])return[0];const n=Hg(e.length+t.length-1,0);for(let r=0;r<e.length;r++)for(let i=0;i<t.length;i++)n[r+i]=tm.add(n[r+i],tm.mul(e[r],t[i]));return tm.polynomial(n)},mulPolyScalar(e,t){if(0==t)return[0];if(1==t)return e;const n=Hg(e.length,0);for(let r=0;r<e.length;r++)n[r]=tm.mul(e[r],t);return tm.polynomial(n)},mulPolyMonomial(e,t,n){if(t<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(0==n)return[0];const r=Hg(e.length+t,0);for(let t=0;t<e.length;t++)r[t]=tm.mul(e[t],n);return tm.polynomial(r)},addPoly(e,t){if(0===e[0])return t;if(0===t[0])return e;let n=e,r=t;n.length>r.length&&([n,r]=[r,n]);let i=Hg(r.length,0),o=r.length-n.length,s=r.slice(0,o);for(let e=0;e<s.length;e++)i[e]=s[e];for(let e=o;e<r.length;e++)i[e]=tm.add(n[e-o],r[e]);return tm.polynomial(i)},remainderPoly(e,t){const n=Array.from(e);for(let r=0;r<e.length-t.length+1;r++){const e=n[r];if(0!==e)for(let i=1;i<t.length;i++)0!==t[i]&&(n[r+i]=tm.add(n[r+i],tm.mul(t[i],e)))}return n.slice(e.length-t.length+1,n.length)},divisorPoly(e){let t=[1];for(let n=0;n<e;n++)t=tm.mulPoly(t,[1,tm.pow(2,n)]);return t},evalPoly(e,t){if(0==t)return tm.coefficient(e,0);let n=e[0];for(let r=1;r<e.length;r++)n=tm.add(tm.mul(t,n),e[r]);return n},euclidian(e,t,n){tm.degree(e)<tm.degree(t)&&([e,t]=[t,e]);let r=e,i=t,o=[0],s=[1];for(;2*tm.degree(i)>=n;){let e=r,t=o;if(r=i,o=s,0===r[0])throw new Error("rLast[0] === 0");i=e;let n=[0];const a=tm.inv(r[0]);for(;tm.degree(i)>=tm.degree(r)&&0!==i[0];){const e=tm.degree(i)-tm.degree(r),t=tm.mul(i[0],a);n=tm.addPoly(n,tm.monomial(e,t)),i=tm.addPoly(i,tm.mulPolyMonomial(r,e,t))}if(n=tm.mulPoly(n,o),s=tm.addPoly(n,t),tm.degree(i)>=tm.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const a=tm.coefficient(s,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const c=tm.inv(a);return[tm.mulPolyScalar(s,c),tm.mulPolyScalar(i,c)]}};function nm(e,t,n,r){let i="",o=n.length;if("numeric"===r){const e=Qg.alphabet.numeric.decode(n.split("")),t=e.length;for(let n=0;n<t-2;n+=3)i+=Ug(100*e[n]+10*e[n+1]+e[n+2],10);t%3==1?i+=Ug(e[t-1],4):t%3==2&&(i+=Ug(10*e[t-2]+e[t-1],7))}else if("alphanumeric"===r){const e=Qg.alphabet.alphanumerc.decode(n.split("")),t=e.length;for(let n=0;n<t-1;n+=2)i+=Ug(45*e[n]+e[n+1],11);t%2==1&&(i+=Ug(e[t-1],6))}else{if("byte"!==r)throw new Error("encode: unsupported type");{const e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(n);o=e.length,i=Array.from(e).map((e=>Ug(e,8))).join("")}}const{capacity:s}=Qg.capacity(e,t),a=Ug(o,Qg.lengthBits(e,r));let c=Qg.modeBits[r]+a+i;if(c.length>s)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,s-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));for(let e=0;c.length!==s;e++)c+="1110110000010001"[e%16];const l=Uint8Array.from(c.match(/(.{8})/g).map((e=>Number(`0b${e}`))));return function(e,t){const{words:n,shortBlocks:r,numBlocks:i,blockLen:o,total:s}=Qg.capacity(e,t),a=(c=n,{encode(e){const t=tm.divisorPoly(c),n=Array.from(e);return n.push(...t.slice(0,-1).fill(0)),Uint8Array.from(tm.remainderPoly(n,t))},decode(e){const t=e.slice(),n=tm.polynomial(Array.from(e));let r=Hg(c,0),i=!1;for(let e=0;e<c;e++){const t=tm.evalPoly(n,tm.exp(e));r[r.length-1-e]=t,0!==t&&(i=!0)}if(!i)return t;r=tm.polynomial(r);const o=tm.monomial(c,1),[s,a]=tm.euclidian(o,r,c),l=Hg(tm.degree(s),0);let d=0;for(let e=1;e<256&&d<l.length;e++)0===tm.evalPoly(s,e)&&(l[d++]=tm.inv(e));if(d!==l.length)throw new Error("RS.decode: wrong errors number");for(let e=0;e<l.length;e++){const n=t.length-1-tm.log(l[e]);if(n<0)throw new Error("RS.decode: wrong error location");const r=tm.inv(l[e]);let i=1;for(let t=0;t<l.length;t++)e!==t&&(i=tm.mul(i,tm.add(1,tm.mul(l[t],r))));t[n]=tm.add(t[n],tm.mul(tm.evalPoly(a,r),tm.inv(i)))}return t}});var c;return{encode(e){const t=[],n=[];for(let s=0;s<i;s++){const i=o+(s<r?0:1);t.push(e.subarray(0,i)),n.push(a.encode(e.subarray(0,i))),e=e.subarray(i)}const s=zg(...t),c=zg(...n),l=new Uint8Array(s.length+c.length);return l.set(s),l.set(c,s.length),l},decode(e){if(e.length!==s)throw new Error(`interleave.decode: len(data)=${e.length}, total=${s}`);const t=[];for(let e=0;e<i;e++){const i=e<r;t.push(new Uint8Array(n+o+(i?0:1)))}let c=0;for(let n=0;n<o;n++)for(let r=0;r<i;r++)t[r][n]=e[c++];for(let n=r;n<i;n++)t[n][o]=e[c++];for(let s=o;s<o+n;s++)for(let n=0;n<i;n++){const i=n<r;t[n][s+(i?0:1)]=e[c++]}const l=[];for(const e of t)l.push(...Array.from(a.decode(e)).slice(0,-n));return Uint8Array.from(l)}}}(e,t).encode(l)}function rm(e,t,n,r,i=!1){const o=function(e,t,n,r=!1){const i=Qg.size.encode(e);let o=new Wg(i+2);const s=new Wg(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);o=o.embed(0,s).embed({x:-s.width,y:0},s).embed({x:0,y:-s.height},s),o=o.rectSlice(1,i);const a=new Wg(1).rect(0,1,!0).border(1,!1).border(1,!0),c=Qg.alignmentPatterns(e);for(const e of c)for(const t of c)void 0===o.data[e][t]&&o.embed({x:t-2,y:e-2},a);o=o.hLine({x:0,y:6},1/0,(({x:e},t)=>void 0===t?e%2==0:t)).vLine({x:6,y:0},1/0,(({y:e},t)=>void 0===t?e%2==0:t));{const e=Qg.formatBits(t,n),s=t=>!r&&1==(e>>t&1);for(let e=0;e<6;e++)o.data[e][8]=s(e);for(let e=6;e<8;e++)o.data[e+1][8]=s(e);for(let e=8;e<15;e++)o.data[i-15+e][8]=s(e);for(let e=0;e<8;e++)o.data[8][i-e-1]=s(e);for(let e=8;e<9;e++)o.data[8][15-e-1+1]=s(e);for(let e=9;e<15;e++)o.data[8][15-e-1]=s(e);o.data[i-8][8]=!r}if(e>=7){const t=Qg.versionBits(e);for(let e=0;e<18;e+=1){const n=!r&&1==(t>>e&1),s=Math.floor(e/3),a=e%3+i-8-3;o.data[s][a]=n,o.data[a][s]=n}}return o}(e,t,r,i);let s=0;const a=8*n.length;if(function(e,t,n){const r=e.height,i=em[t];let o=-1,s=r-1;for(let t=r-1;t>0;t-=2){for(6==t&&(t=5);;s+=o){for(let r=0;r<2;r+=1){const o=t-r;void 0===e.data[s][o]&&n(o,s,i(o,s))}if(s+o<0||s+o>=r)break}o=-o}}(o,r,((e,t,r)=>{let i=!1;s<a&&(i=0!=(n[s>>>3]>>(7-s&7)&1),s++),o.data[t][e]=i!==r})),s!==a)throw new Error("QR: bytes left after draw");return o}function im(e){const t=e.inverse(),n=e=>{let t=0;for(let n,r=0,i=1;r<e.length;r++)n===e[r]&&(i++,r!==e.length-1)||(i>=5&&(t+=i-5+3),n=e[r],i=1);return t};let r=0;e.data.forEach((e=>r+=n(e))),t.data.forEach((e=>r+=n(e)));let i=0,o=e.data;const s=e.width-1,a=e.height-1;for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=e+1,r=t+1;o[e][t]===o[n][t]&&o[n][t]===o[e][r]&&o[n][t]===o[n][r]&&(i+=3)}const c=e=>{const t=[!0,!1,!0,!0,!0,!1,!0],n=[!1,!1,!1,!1],r=[...t,...n],i=[...n,...t];let o=0;for(let t=0;t<e.length;t++)qg(e,r,t)&&(o+=40),qg(e,i,t)&&(o+=40);return o};let l=0;for(const t of e.data)l+=c(t);for(const e of t.data)l+=c(e);let d=0;e.rectRead(0,1/0,((e,t)=>d+=t?1:0));const u=d/(e.height*e.width)*100,h=10*Math.floor(Math.abs(u-50)/5);return r+i+l+h}function om(e,t="raw",n={}){const r=void 0!==n.ecc?n.ecc:"medium";!function(e){if(!Gg.includes(e))throw new Error(`Invalid error correction mode=${e}. Expected: ${Gg}`)}(r);const i=void 0!==n.encoding?n.encoding:function(e){let t="numeric";for(let n of e)if(!Qg.alphabet.numeric.has(n)&&(t="alphanumeric",!Qg.alphabet.alphanumerc.has(n)))return"byte";return t}(e);!function(e){if(!Yg.includes(e))throw new Error(`Encoding: invalid mode=${e}. Expected: ${Yg}`);if("kanji"===e||"eci"===e)throw new Error(`Encoding: ${e} is not supported (yet?).`)}(i),void 0!==n.mask&&function(e){if(![0,1,2,3,4,5,6,7].includes(e)||!em[e])throw new Error(`Invalid mask=${e}. Expected number [0..7]`)}(n.mask);let o,s=n.version,a=new Error("Unknown error");if(void 0!==s)!function(e){if(!Number.isSafeInteger(e)||e<1||e>40)throw new Error(`Invalid version=${e}. Expected number [1..40]`)}(s),o=nm(s,r,e,i);else for(let t=1;t<=40;t++)try{o=nm(t,r,e,i),s=t;break}catch(e){a=e}if(!s||!o)throw a;let c=function(e,t,n,r){if(void 0===r){const i=function(){let e,t=1/0;return{add(n,r){n>=t||(e=r,t=n)},get:()=>e,score:()=>t}}();for(let r=0;r<em.length;r++)i.add(im(rm(e,t,n,r,!0)),r);r=i.get()}if(void 0===r)throw new Error("Cannot find mask");return rm(e,t,n,r)}(s,r,o,n.mask);c.assertDrawn();const l=void 0===n.border?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),void 0!==n.scale&&(c=c.scale(n.scale)),"raw"===t)return c.data;if("ascii"===t)return c.toASCII();if("svg"===t)return c.toSVG();if("gif"===t)return c.toGIF();if("term"===t)return c.toTerm();throw new Error(`Unknown output: ${t}`)}const sm={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class am{constructor(e){var t;this.translations=sm,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some((e=>e.toLowerCase().startsWith("en"))))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const t=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(t)}async loadTranslations(e){const t=e.split("-")[0];if("en"!==t&&this.supportedLocales.includes(t))try{const e=`${this.baseUrl}/${t}.json`,n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);this.translations=await n.json()}catch(e){console.warn(`❌ Failed to load ${t} translations, falling back to English:`,e),this.translations=sm}else this.translations=sm}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,t){const n=e.split(".");let r=t;for(const e of n){if("object"!=typeof r)return"";r=r[e]}return"string"==typeof r?r:""}}var cm;!function(e){e.SDK_MODAL_VIEWED="sdk_modal_viewed",e.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",e.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"}(cm||(cm={}));const lm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.startDesktopOnboarding=Jp(this,"startDesktopOnboarding",7),this.trackAnalytics=Jp(this,"trackAnalytics",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new am}componentDidLoad(){this.trackAnalytics.emit({event:cm.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:1===this.tab?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}onClose(e=!1){this.close.emit({shouldTerminate:e})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:cm.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(e,t=!1){t&&this.trackAnalytics.emit({event:cm.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:1===this.tab?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=e,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=om(this.link,"svg",{ecc:"medium",scale:2});return zp(Rg,{className:"install-model"},zp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"tabcontainer"},zp("div",{class:"flexContainer"},zp("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(1===t?"tabactive":"")},e("DESKTOP")),zp("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(2===t?"tabactive":"")},e("MOBILE")))),zp("div",{style:{display:1===t?"none":"block"}},zp("div",{class:"flexContainer"},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&zp("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),zp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT")," ",zp("br",null),zp("span",{class:"blue"},zp("b",null,e("META_MASK_MOBILE_APP"))))))),zp("div",{style:{display:2===t?"none":"block"}},zp("div",{class:"item"},zp(Pg,{Icon:Ng,text:e("INSTALL_MODAL.TRUSTED_BY_USERS")})),zp("div",{class:"item"},zp(Pg,{Icon:Ig,text:e("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),zp("div",{class:"item"},zp(Pg,{Icon:Bg,text:e("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),zp("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},zp(Dg,null),zp("span",{class:"installExtensionText"},e("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),zp($g,{version:this.sdkVersion})))}get el(){return Zp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};lm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const dm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.disconnect=Jp(this,"disconnect",7),this.updateOTPValue=Jp(this,"updateOTPValue",7),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new am}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(e){this.updateOTPValue.emit({otpValue:e})}disconnectedCallback(){this.onClose()}render(){var e;if(!this.translationsLoaded)return null;const t=null===(e=this.displayOTP)||void 0===e||e,n=this.sdkVersion,r=e=>this.i18nInstance.t(e);return zp(Rg,{className:"pending-modal"},zp("div",{class:"backdrop",onClick:()=>this.onClose()}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose()},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(t?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),zp("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),t&&zp("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),zp("div",{style:{marginTop:"20px"}},zp("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),zp($g,{version:n})))}get el(){return Zp(this)}};dm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const um=()=>zp("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),hm=()=>zp("svg",{width:"400",height:"300",viewBox:"0 0 467 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},zp("path",{d:"M312.387 280.629C312.549 280.583 312.247 280.735 312.387 280.629L339.678 260.425C340.088 260.118 340.132 259.156 340.07 258.647C340.008 258.138 339.573 258.257 339.106 258.084L311.712 247.455C311.292 247.301 311.308 247.402 310.939 247.673C310.569 247.944 310.356 248.21 310.356 248.672L310.459 279.504C310.461 280.025 311.163 280.619 311.614 280.847C311.913 280.996 312.072 280.718 312.387 280.629ZM336.204 259.736L312.979 276.292L313.439 251.139L336.204 259.736Z",fill:"url(#paint0_linear_1356_14057)"}),zp("path",{d:"M324.639 260.342C324.358 259.547 323.485 258.91 322.707 259.215C319.6 260.432 318.17 262.313 317.287 264.066C316.482 265.665 316.197 267.482 314.188 268.269C312.178 269.055 310.763 268.663 309.162 268.007C307.406 267.287 305.504 266.182 302.397 267.399C299.289 268.616 297.859 270.497 296.976 272.25C296.171 273.849 295.697 274.886 293.685 275.673C291.675 276.459 290.261 276.067 288.659 275.411C286.903 274.691 284.999 273.587 281.894 274.803C278.789 276.019 277.549 278.681 276.666 280.434C275.861 282.034 275.386 283.07 273.374 283.857C272.596 284.161 271.931 285.055 272.211 285.849C272.492 286.644 273.365 287.281 274.143 286.977C277.25 285.76 278.68 283.879 279.563 282.125C280.368 280.526 280.65 278.71 282.662 277.923C284.672 277.136 286.087 277.528 287.688 278.184C289.444 278.904 291.348 280.009 294.453 278.793C297.561 277.576 298.991 275.695 299.874 273.941C300.679 272.342 301.153 271.306 303.165 270.519C305.175 269.732 306.589 270.124 308.191 270.78C309.947 271.5 311.849 272.605 314.956 271.388C318.063 270.172 319.301 267.511 320.184 265.757C320.989 264.158 321.466 263.121 323.476 262.335C324.254 262.032 324.919 261.137 324.639 260.342Z",fill:"url(#paint1_linear_1356_14057)"}),zp("path",{d:"M389.034 111.124C388.968 112.406 387.342 113.113 386.324 113.549C384.297 114.419 382.089 114.493 379.942 114.5C376.607 114.509 373.215 114.163 369.89 113.976C366.712 113.798 363.156 113.311 360.03 114.232C357.705 114.919 355.667 116.762 353.452 117.739C351.129 118.765 348.957 119.198 346.489 119.687C335.569 121.85 323.587 120.825 312.656 119.977C311.92 119.92 312.539 118.997 313.237 118.981C313.207 118.815 313.001 118.394 313.045 118.201C313.086 118.029 312.781 117.586 312.853 117.421C312.67 117.198 313.316 117.427 313.626 117.204C315.912 115.557 318.721 114.79 321.363 115.041C324.677 115.355 327.293 116.04 330.641 115.781C334.392 115.491 338.125 114.787 341.857 114.312C345.142 113.892 349.09 113.941 352.106 112.28C352.916 111.834 353.137 111.262 353.269 110.287C353.331 109.828 353.672 108.969 353.658 108.511C353.629 107.529 354.191 107.886 355.013 107.298C356.857 105.981 358.274 105.516 360.428 105.784C362.841 106.083 365.264 107.273 367.578 107.953C370.761 108.888 374.328 108.646 377.631 108.477C380.517 108.329 383.141 107.901 385.944 108.653C387.013 108.941 389.104 109.745 389.034 111.124Z",fill:"url(#paint2_linear_1356_14057)"}),zp("path",{d:"M278.118 85.4414C280.313 83.8186 283.302 83.9 285.853 83.2728C290.501 82.127 295.644 78.4476 300.549 79.1524C301.299 79.2595 300.904 81.0355 300.159 80.9295C300.131 80.9256 300.187 80.9333 300.159 80.9295C300.089 81.0185 299.516 81.1051 299.385 81.1463C294.999 82.515 292.895 87.5083 289.126 89.8598C287.799 90.688 286.771 90.8351 285.258 90.9441C283.515 91.0691 280.964 90.5775 279.269 90.1219C277.15 89.5532 275.965 87.034 278.118 85.4414Z",fill:"url(#paint3_linear_1356_14057)"}),zp("path",{d:"M122.567 166.093C113.597 172.832 104.535 179.836 99.517 190.092C98.5342 192.099 97.519 195.019 97.9533 197.204C98.9699 202.316 105.76 203.049 110.691 201.96C113.468 201.347 116.325 199.231 115.921 196.319C115.576 193.81 113.158 192.986 112.072 190.73C110.779 188.04 112.35 184.97 114.218 182.62C128.134 165.099 150.074 157.394 171.093 151.607C175.385 150.425 180.897 147.69 180.581 143.099C180.372 140.072 177.118 137.683 174.221 137.383C171.324 137.082 168.481 138.773 165.715 139.776C158.416 142.419 151.17 143.799 143.489 143.526C136.865 143.29 130.976 143.316 129.562 150.781C128.138 158.276 129.53 160.863 122.567 166.093Z",fill:"url(#paint4_linear_1356_14057)"}),zp("path",{d:"M79.1056 153.531C60.3932 164.378 43.7478 178.354 32.8214 197.415C30.3313 201.76 27.9216 206.554 27.1821 211.512C26.4448 216.47 27.7591 222.525 30.8133 226.337C34.908 231.446 41.6938 232.915 48.1811 233.125C50.7248 233.208 53.0035 233.066 55.3316 231.947C57.6602 230.83 59.7548 228.359 59.5978 225.742C59.3303 221.315 54.5491 219.665 50.9271 217.34C42.6566 212.037 40.4958 199.493 44.2381 190.032C47.9803 180.57 55.8228 173.173 63.2316 166.338C67.229 162.651 71.5194 158.372 76.777 157.522C79.9167 157.015 83.4706 157.589 86.6295 157.252C93.9004 156.479 99.64 151.404 105.588 146.912C115.048 139.765 126.045 134.283 137.501 132.093C141.913 131.248 146.293 130.493 149.682 127.831C151.37 126.507 150.803 123.567 148.726 123.93C138.542 125.713 128.652 131.135 119.142 134.758C105.627 139.914 91.7133 146.223 79.1056 153.531Z",fill:"url(#paint5_linear_1356_14057)"}),zp("path",{d:"M96.3677 117.321C96.0315 116.64 95.2914 116.612 94.6293 116.975C91.9858 118.417 91.5452 120.509 90.9466 122.178C90.4004 123.702 89.3647 124.67 87.6542 125.604C85.9437 126.538 85.0983 126.316 83.5956 125.91C81.9481 125.465 79.8603 125.424 77.2168 126.866C74.5734 128.309 74.1348 130.401 73.5341 132.07C72.9879 133.593 71.9522 134.562 70.2417 135.496C68.5313 136.43 67.6859 136.208 66.1832 135.801C64.5357 135.357 62.2569 134.538 59.6128 135.978C56.9694 137.42 56.5308 139.512 55.9301 141.181C55.3839 142.705 54.5398 144.454 52.8293 145.388C52.1667 145.748 52.1006 146.485 52.439 147.165C52.7752 147.845 53.5153 147.874 54.1773 147.511C56.8208 146.069 57.2594 143.977 57.86 142.307C58.4062 140.784 59.4419 139.815 61.1524 138.881C62.8629 137.948 63.7083 138.17 65.211 138.576C66.8585 139.021 68.9458 139.059 71.5898 137.619C74.2333 136.177 74.6718 134.085 75.2725 132.416C75.8187 130.892 76.8544 129.924 78.5649 128.99C80.2754 128.056 81.1207 128.278 82.6235 128.684C84.2709 129.129 86.5503 129.95 89.1938 128.507C91.8373 127.065 92.2779 124.973 92.8765 123.304C93.4227 121.78 94.2663 120.03 95.9773 119.098C96.6378 118.738 96.7039 118.001 96.3677 117.321Z",fill:"#FBC49D"}),zp("path",{d:"M391.827 164.699C392.04 164.639 392.39 164.573 392.6 164.481C393.87 163.921 395.363 162.429 395.893 161.051C396.421 159.673 396.237 158.321 395.712 156.931C394.629 154.061 391.777 152.62 389.155 153.775C386.531 154.931 384.962 158.455 386.042 161.325C387.038 163.963 389.369 165.392 391.827 164.699ZM394.166 157.367C394.529 158.332 394.52 159.751 394.156 160.706C393.792 161.662 393.1 162.534 392.218 162.921C390.398 163.723 388.338 162.878 387.589 160.889C387.226 159.925 387.234 158.506 387.599 157.55C387.963 156.594 388.654 155.723 389.536 155.336C391.356 154.534 393.416 155.376 394.166 157.367Z",fill:"#86E29B"}),zp("path",{d:"M62.7198 108.691C64.4912 108.191 66.6152 106.609 67.5596 104.824C68.4273 103.187 68.465 101.455 67.9609 99.7066C67.4547 97.9586 66.0792 96.5141 64.4963 95.6786C62.9135 94.843 61.2077 94.8578 59.4756 95.4255C57.7435 95.9933 56.2768 97.4364 55.409 99.074C53.6185 102.456 55.2032 106.494 58.4723 108.22C60.0142 109.035 61.1315 109.138 62.7198 108.691ZM60.6304 96.7682C61.819 96.4332 63.0232 96.8871 64.1048 97.4571C65.2463 98.0603 66.0495 98.8796 66.4145 100.142C66.7791 101.403 66.4488 103.299 65.8224 104.48C64.5299 106.919 61.2212 107.686 58.8638 106.441C56.5063 105.197 55.8538 101.858 57.1462 99.4185C57.7726 98.2375 58.6059 97.3957 59.8573 96.9862C59.9214 96.9635 60.5631 96.7872 60.6304 96.7682Z",fill:"#FFB0EB"}),zp("path",{d:"M77.0217 242.979C75.9542 243.28 75.1664 242.151 74.9029 241.074C74.6394 239.996 75 239.378 76.0676 239.077C77.1351 238.776 78.5053 238.907 78.7688 239.984C79.0323 241.061 78.0893 242.678 77.0217 242.979Z",fill:"url(#paint6_linear_1356_14057)"}),zp("path",{d:"M380.506 184.577C379.439 184.878 378.651 183.749 378.387 182.672C378.124 181.594 378.484 180.976 379.552 180.675C380.619 180.374 381.99 180.505 382.253 181.582C382.517 182.659 381.574 184.276 380.506 184.577Z",fill:"url(#paint7_linear_1356_14057)"}),zp("path",{d:"M348.82 246.969C347.752 247.27 346.382 247.14 346.119 246.063C345.855 244.985 346.798 243.369 347.866 243.068C348.933 242.767 349.721 243.896 349.985 244.973C350.248 246.05 349.888 246.669 348.82 246.969Z",fill:"url(#paint8_linear_1356_14057)"}),zp("path",{d:"M140.419 282.412C139.351 282.713 138.754 282.365 138.491 281.288C138.227 280.21 138.397 278.812 139.464 278.511C140.532 278.21 142.093 279.121 142.357 280.198C142.62 281.275 141.486 282.111 140.419 282.412Z",fill:"url(#paint9_linear_1356_14057)"}),zp("path",{d:"M121.462 101.679C120.395 101.979 119.798 101.631 119.534 100.554C119.271 99.4764 119.44 98.0779 120.508 97.777C121.575 97.4761 123.136 98.3868 123.4 99.4642C123.663 100.542 122.53 101.378 121.462 101.679Z",fill:"url(#paint10_linear_1356_14057)"}),zp("path",{d:"M370.749 159.005C369.682 159.306 368.311 159.175 368.048 158.098C367.784 157.021 368.727 155.404 369.795 155.103C370.863 154.802 371.65 155.931 371.914 157.008C372.177 158.086 371.817 158.704 370.749 159.005Z",fill:"url(#paint11_linear_1356_14057)"}),zp("path",{d:"M384.211 245.345C383.143 245.646 381.773 245.515 381.51 244.438C381.246 243.361 382.189 241.744 383.257 241.443C384.324 241.142 385.112 242.271 385.376 243.348C385.639 244.426 385.278 245.044 384.211 245.345Z",fill:"url(#paint12_linear_1356_14057)"}),zp("path",{d:"M364.771 41.3873C363.063 41.8687 361.337 40.8616 360.915 39.1378C360.493 37.414 361.536 35.6263 363.244 35.1449C364.953 34.6634 366.679 35.6706 367.101 37.3944C367.522 39.1182 366.479 40.9059 364.771 41.3873Z",fill:"url(#paint13_linear_1356_14057)"}),zp("path",{d:"M404.311 77.905C404.602 77.8231 404.875 77.9236 405.084 77.6871C405.437 77.2908 404.814 76.6385 404.703 76.1265L401.277 58.7418C401.149 58.163 400.687 57.5371 400.123 57.3991C399.558 57.2611 398.969 57.3812 398.576 57.835L385.784 73.1179C385.395 73.564 385.199 74.3453 385.393 74.8964C385.585 75.4481 385.978 76.1646 386.548 76.2391L403.538 78.123C403.744 78.1479 404.114 77.9607 404.311 77.905ZM398.948 62.7348L401.811 74.4394L389.841 72.8085L398.948 62.7348Z",fill:"#FFB0EB"}),zp("path",{d:"M97.5393 295.311C97.7108 295.263 97.4284 295.461 97.5393 295.311L108.785 280.464C108.975 280.211 108.718 279.972 108.594 279.684C108.47 279.396 108.124 279.917 107.821 279.902L88.5106 278.672C88.2101 278.659 87.895 278.62 87.7374 278.89C87.5798 279.159 87.7755 279.402 87.9283 279.67L96.5753 294.749C96.7102 294.99 97.2696 295.297 97.5393 295.311C97.6283 295.319 97.4556 295.335 97.5393 295.311ZM106.465 281.118L96.9667 292.97L90.6295 280.577L106.465 281.118Z",fill:"#86E29B"}),zp("path",{d:"M393.699 108.848C389.518 104.446 414.629 114.366 413.945 120.659C413.259 126.952 401.355 129.102 403.894 123.491C406.042 118.747 400.376 115.876 393.699 108.848Z",fill:"#FBC49D"}),zp("path",{d:"M139.414 115.959C139.434 115.953 139.392 115.965 139.414 115.959C141.963 115.2 143.436 111.976 142.717 109.189C142.37 107.839 141.526 107.199 140.408 106.504C139.289 105.808 138.171 105.449 136.933 105.815C135.698 106.182 134.85 107.033 134.222 108.247C133.595 109.461 133.282 111.234 133.63 112.585C133.978 113.935 134.821 114.574 135.94 115.27C137.04 115.952 138.199 116.301 139.414 115.959ZM137.315 107.375C138.222 107.12 139.005 106.994 139.825 107.502C140.661 108.02 140.912 108.618 141.171 109.625C141.708 111.704 140.935 113.834 139.032 114.398C138.11 114.675 137.356 114.791 136.522 114.272C135.686 113.753 135.436 113.155 135.176 112.149C134.917 111.142 134.718 109.714 135.186 108.81C135.654 107.905 136.394 107.649 137.315 107.375C137.329 107.371 137.299 107.38 137.315 107.375Z",fill:"#75C4FD"}),zp("path",{d:"M308.981 78.7519C310.052 78.4043 311.158 78.7096 312.265 78.6613C313.655 78.6006 314.936 78.517 316.323 78.3531C319.497 77.9795 322.798 77.4906 325.984 77.3012C329.309 77.1025 332.514 76.8551 335.836 77.0295C338.809 77.1842 342.163 77.3405 345.105 77.7558C352.129 78.7468 359.331 79.0578 366.347 80.1158C372.252 81.008 377.93 82.1319 383.722 83.5644C385.925 84.0054 388.267 85.0754 389.126 85.3792C389.421 85.4833 389.37 85.8347 389.317 86.1595C389.306 86.2271 389.353 86.1146 389.317 86.1595C388.269 87.414 386.564 86.8124 385.259 86.4677C384.406 86.241 381.488 85.9494 381.011 85.9957C380.14 86.0815 379.277 86.014 379.656 87.2114C380.122 88.6824 382.391 89.7375 383.704 90.2419C385.883 91.0803 388.771 91.2561 390.845 92.4015C392.968 92.821 395.425 93.5002 397.022 93.9986C402.83 95.8103 407.806 98.8678 413.033 102.002C415.503 103.482 417.829 104.764 419.973 106.72C421.647 108.248 423.771 109.882 424.595 112.091C425.113 113.482 424.451 115.471 422.848 115.085C420.353 114.488 419.638 111.665 418.227 109.714C415.003 105.251 410.067 102.067 405.118 100.06C402.64 99.0556 399.803 98.729 397.204 98.1176C394.411 97.4613 391.597 97.0442 388.707 97.1736C385.646 97.3097 382.846 97.5534 379.819 98.0078C377.027 98.4264 374.252 98.4441 371.514 97.8441C368.766 97.2421 366.276 96.7553 363.6 95.9021C361.662 95.2848 359.013 94.5583 357.232 93.5247C355.699 92.6339 355.631 91.2381 357.241 90.186C359.87 88.4656 362.778 89.8021 365.546 90.3497C365.561 90.3527 365.532 90.3468 365.546 90.3497C367.858 90.804 369.649 90.098 371.923 89.3884C372.489 89.2128 373.255 89.0482 373.47 88.953C374.383 88.5432 375.895 87.8227 375.407 86.7394C374.868 85.5457 372.659 84.8846 371.55 84.4891C369.74 83.8428 368.053 82.9215 366.147 82.6743C365.654 82.6095 365.109 83.1606 364.6 83.1097C363.36 83.1121 361.769 83.348 360.543 83.418C357.43 83.5916 354.583 83.6228 351.464 83.4719C348.714 83.3377 346.432 82.8542 343.741 82.3102C340.773 81.7101 337.52 81.5879 334.471 81.5839C331.393 81.5811 328.6 81.7214 325.583 82.4181C322.758 83.0702 319.757 83.6198 316.887 84.0326C314.698 84.3481 312.467 84.6054 310.319 84.2137C309.079 83.9871 306.994 83.3394 306.461 81.9635C305.846 80.3659 307.736 79.1556 308.981 78.7519Z",fill:"url(#paint14_linear_1356_14057)"}),zp("path",{d:"M242.269 242.95C242.295 242.947 242.244 242.955 242.269 242.95C244.934 242.606 247.53 241.858 250.2 241.574C253.133 241.264 256.006 240.56 258.906 239.982C263.26 239.117 268.026 238.52 272.254 237.097C274.429 236.365 276.067 235.298 278.251 234.592C280.361 233.909 283.058 233.12 285.216 232.652C289.317 231.764 293.049 231.66 297.016 230.198C301.109 228.69 305.088 226.673 308.819 224.409C312.645 222.086 316.282 219.769 320.622 218.62C322.381 218.154 323.919 218.219 325.65 218.886C327.016 219.413 327.739 220.337 327.196 221.79C326.557 223.504 324.659 224.7 323.131 225.423C320.854 226.5 319.53 227.184 317.134 227.927C314.619 228.707 311.888 229.24 309.395 230.083C308.226 230.947 307.17 232.522 306.105 233.501C303.996 235.441 301.666 237.03 298.945 237.996C292.934 240.129 286.354 238.602 280.183 239.056C279.661 239.095 279.162 239.442 278.635 239.487C275.592 240.135 272.2 240.63 269.156 241.294C264.546 242.299 260.456 243.409 255.808 244.179C251.971 244.814 243.815 245.854 243.815 245.854L242.074 245.505C240.575 245.281 240.751 243.152 242.269 242.95Z",fill:"url(#paint15_linear_1356_14057)"}),zp("path",{d:"M432.985 171.626C438.212 165.465 445.109 153.64 442.906 144.649C442.162 137.999 433.671 132.912 424.963 135.518C420.16 136.957 416.435 142.146 419.724 144.498C420.656 145.164 422.187 145.591 423.391 145.969C434.204 149.375 434.925 162.538 425.069 169.683C421.087 172.569 416.347 174.292 411.914 176.719C400.151 183.162 399.887 196.847 387.7 202.712C382.326 205.298 375.761 206.838 370.297 209.275C359.98 213.88 352.555 221.733 342.241 226.341C337.225 228.584 330.266 231.632 323.483 234.12C321.475 234.855 321.999 237.058 324.056 236.46C324.098 236.449 324.017 236.474 324.056 236.46C329.079 234.971 334.437 233.161 339.331 231.33C352.278 226.48 365.28 220.971 377.43 214.775C401.78 202.367 416.881 190.609 432.985 171.626Z",fill:"url(#paint16_linear_1356_14057)"}),zp("path",{d:"M343.644 241.104C348.002 234.144 357.126 232.455 364.343 231.134C368.176 230.431 372.406 229.878 376.137 228.662C380.691 227.175 384.558 224.095 388.327 221.077C389.452 220.177 391.204 218.466 392.393 217.436C393.185 216.748 393.644 216.026 394.33 215.225C396 213.275 399.599 209.812 401.687 208.16C403.263 206.914 407.779 204.758 408.259 207.986C408.611 210.359 406.379 213.087 404.961 214.747C402.224 217.953 398.998 221.079 395.475 223.243C391.749 225.531 387.701 227.439 383.674 229.051C381.672 229.853 379.519 230.073 377.486 230.785C376.001 231.307 374.486 232.236 373.037 232.866C371.034 233.738 368.99 234.28 367.041 235.38C364.436 236.849 361.782 238.783 359.108 240.105C356.331 241.477 353.823 242.691 350.791 243.27C348.6 243.687 345.501 243.641 343.836 241.884C343.526 241.554 343.389 241.51 343.644 241.104Z",fill:"url(#paint17_linear_1356_14057)"}),zp("path",{d:"M190.163 273.219C222.905 268.849 232.64 262.943 213.962 259.057C195.285 255.172 187.5 262.08 188.434 266.2C189.366 270.32 180.381 271.326 169.286 272.39C158.193 273.454 157.141 276.354 190.163 273.219Z",fill:"url(#paint18_linear_1356_14057)"}),zp("path",{d:"M295.952 95.4242L241.395 135.226L251.54 111.77L295.952 95.4242Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M170.111 95.4242L224.181 135.598L214.522 111.77L170.111 95.4242Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M276.309 187.712L261.793 209.576L292.876 218.014L301.78 188.189L276.309 187.712Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M164.336 188.189L173.186 218.014L204.215 209.576L189.753 187.712L164.336 188.189Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M202.542 150.776L193.908 163.618L224.667 164.998L223.642 132.36L202.542 150.776Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M263.52 150.775L242.097 131.989L241.395 164.998L272.154 163.618L263.52 150.775Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L222.832 200.714L206.805 188.402L204.215 209.576Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M243.23 200.714L261.793 209.576L259.257 188.402L243.23 200.714Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M261.793 209.576L243.23 200.714L244.741 212.601L244.579 217.643L261.793 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L221.483 217.643L221.375 212.601L222.832 200.714L204.215 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M221.807 180.547L206.373 176.09L217.274 171.154L221.807 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.255 180.547L248.788 171.154L259.742 176.09L244.255 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M204.215 209.576L206.913 187.712L189.753 188.189L204.215 209.576Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M259.149 187.712L261.793 209.576L276.309 188.189L259.149 187.712Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M272.154 163.618L241.395 164.998L244.255 180.547L248.788 171.154L259.742 176.09L272.154 163.618Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M206.373 176.09L217.274 171.154L221.807 180.547L224.667 164.998L193.908 163.618L206.373 176.09Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M193.908 163.618L206.805 188.402L206.373 176.09L193.908 163.618Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M259.743 176.09L259.257 188.402L272.154 163.618L259.743 176.09Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M224.667 164.998L221.807 180.548L225.422 198.909L226.232 174.71L224.667 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M241.395 164.998L239.884 174.657L240.64 198.909L244.255 180.548L241.395 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.255 180.547L240.64 198.909L243.23 200.714L259.257 188.402L259.743 176.09L244.255 180.547Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M206.373 176.09L206.805 188.402L222.832 200.714L225.422 198.909L221.807 180.547L206.373 176.09Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M244.579 217.643L244.741 212.601L243.338 211.434H222.724L221.375 212.601L221.483 217.643L204.215 209.576L210.259 214.459L222.508 222.791H243.5L255.803 214.459L261.793 209.576L244.579 217.643Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M243.23 200.714L240.64 198.909H225.422L222.832 200.714L221.375 212.601L222.724 211.434H243.338L244.741 212.601L243.23 200.714Z",fill:"#161616",stroke:"#161616","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M298.272 137.827L302.859 115.856L295.952 95.4242L243.23 133.899L263.52 150.775L292.174 159.001L298.488 151.731L295.736 149.767L300.107 145.84L296.761 143.293L301.132 140.002L298.272 137.827Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M163.203 115.856L167.844 137.827L164.876 140.002L169.301 143.293L165.955 145.84L170.326 149.767L167.574 151.731L173.888 159.001L202.542 150.775L222.832 133.899L170.11 95.4242L163.203 115.856Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M292.175 159.001L263.52 150.775L272.154 163.618L259.257 188.402L276.309 188.189H301.78L292.175 159.001Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M202.542 150.775L173.888 159.001L164.336 188.189H189.753L206.805 188.402L193.908 163.618L202.542 150.775Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("path",{d:"M241.395 164.998L243.23 133.9L251.54 111.77H214.522L222.832 133.9L224.667 164.998L225.368 174.763L225.422 198.909H240.64L240.694 174.763L241.395 164.998Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),zp("defs",null,zp("linearGradient",{id:"paint0_linear_1356_14057",x1:"335.991",y1:"250.487",x2:"303.873",y2:"266.801",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint1_linear_1356_14057",x1:"276.993",y1:"303.722",x2:"205.254",y2:"401.574",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint2_linear_1356_14057",x1:"271.074",y1:"119.924",x2:"553.077",y2:"104.53",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint3_linear_1356_14057",x1:"264.209",y1:"91.0943",x2:"357.834",y2:"72.8792",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint4_linear_1356_14057",x1:"212.46",y1:"121.997",x2:"92.6119",y2:"183.406",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint5_linear_1356_14057",x1:"23.0498",y1:"204.411",x2:"161.86",y2:"163.003",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint6_linear_1356_14057",x1:"78.8647",y1:"240.375",x2:"74.9655",y2:"241.328",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint7_linear_1356_14057",x1:"382.349",y1:"181.971",x2:"378.45",y2:"182.925",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint8_linear_1356_14057",x1:"349.889",y1:"244.583",x2:"345.99",y2:"245.537",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint9_linear_1356_14057",x1:"142.262",y1:"279.808",x2:"138.362",y2:"280.762",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint10_linear_1356_14057",x1:"123.305",y1:"99.0746",x2:"119.406",y2:"100.028",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint11_linear_1356_14057",x1:"371.818",y1:"156.617",x2:"367.919",y2:"157.571",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint12_linear_1356_14057",x1:"385.281",y1:"242.958",x2:"381.382",y2:"243.911",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint13_linear_1356_14057",x1:"367.125",y1:"37.5052",x2:"360.843",y2:"38.8076",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"1","stop-color":"#75C3FC"})),zp("linearGradient",{id:"paint14_linear_1356_14057",x1:"300.182",y1:"91.321",x2:"479.464",y2:"104.041",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint15_linear_1356_14057",x1:"363.434",y1:"201.232",x2:"102.977",y2:"302.269",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})),zp("linearGradient",{id:"paint16_linear_1356_14057",x1:"447.962",y1:"165.159",x2:"313.049",y2:"197.95",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint17_linear_1356_14057",x1:"410.211",y1:"215.859",x2:"341.378",y2:"232.788",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#75C3FC"}),zp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),zp("stop",{offset:"1","stop-color":"#F0B8BD"})),zp("linearGradient",{id:"paint18_linear_1356_14057",x1:"222.282",y1:"258.986",x2:"162.257",y2:"273.774",gradientUnits:"userSpaceOnUse"},zp("stop",{"stop-color":"#FFE466"}),zp("stop",{offset:"1","stop-color":"#FFAFEA"})))),fm=class{constructor(e){vp(this,e),this.close=Jp(this,"close",7),this.connectWithExtension=Jp(this,"connectWithExtension",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new am,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(e=!1){this.close.emit({shouldTerminate:e})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(e){this.tab=e,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=om(this.link,"svg",{ecc:"medium",scale:2});return zp(Rg,{className:"select-modal"},zp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),zp("div",{class:"modal"},zp("div",{class:"closeButtonContainer"},zp("div",{class:"right"},zp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},zp(jg,null)))),zp("div",{class:"logoContainer"},zp(Kg,null)),zp("div",null,zp("div",{class:"tabcontainer"},zp("div",{class:"flexContainer"},zp("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(1===n?"tabactive":"")},e("DESKTOP")),zp("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(2===n?"tabactive":"")},e("MOBILE")))),zp("div",{style:{display:1===n?"none":"block"}},zp("div",{class:"flexContainer"},zp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},zp("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),zp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT"),zp("br",null),zp("span",{class:"blue"},zp("b",null,e("META_MASK_MOBILE_APP"))))))),zp("div",{style:{display:2===n?"none":"block"}},zp("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},zp(hm,null)),zp("div",{class:"extensionLabel"},e("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),zp("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},zp(um,null),zp("span",{class:"installExtensionText"},e("CONNECT_WITH_EXTENSION"))))),zp($g,{version:t})))}get el(){return Zp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};fm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";var pm=Object.freeze({__proto__:null,mm_install_modal:lm,mm_pending_modal:dm,mm_select_modal:fm});function gm(e,t){const n=e.getProvider();try{n.on("connect",t.connect),n.on("disconnect",t.disconnect),n.on("accountsChanged",t.accountsChanged),n.on("chainChanged",t.chainChanged),n.on("message",t.message)}catch(e){}return n}exports.default=function(t,n){return e.__awaiter(this,void 0,void 0,(function*(){const r={};t.rpc&&Object.entries(t.rpc).forEach((([e,t])=>{const n=`0x${Number(e).toString(16)}`;r[n]=t}));const i=new fp({useDeeplink:!0,enableAnalytics:!1,dappMetadata:{name:t.appName,iconUrl:t.appLogoUrl},readonlyRPCMap:r});i.isInitialized()||(yield i.init());let o=gm(i,n);yield i.connect(),o||(o=gm(i,n));return yield e.convertWeb3Provider(o)}))};
|