{"version":3,"file":"metamask-sdk-Brhtv9I7.js","sources":["../../../../node_modules/@metamask/sdk/dist/browser/umd/metamask-sdk.js"],"sourcesContent":["!function(e,t){\"object\"==typeof exports&&\"undefined\"!=typeof module?t(exports):\"function\"==typeof define&&define.amd?define([\"exports\"],t):t((e=\"undefined\"!=typeof globalThis?globalThis:e||self).browser={})}(this,(function(e){\"use strict\";var t=\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{},n=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,\"default\")?e.default:e}function i(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 o={exports:{}};!function(e,t){var r=\"undefined\"!=typeof globalThis&&globalThis||\"undefined\"!=typeof self&&self||void 0!==n&&n,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=\"URLSearchParams\"in n,i=\"Symbol\"in n&&\"iterator\"in Symbol,o=\"FileReader\"in n&&\"Blob\"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),a=\"FormData\"in n,s=\"ArrayBuffer\"in n;if(s)var u=[\"[object Int8Array]\",\"[object Uint8Array]\",\"[object Uint8ClampedArray]\",\"[object Int16Array]\",\"[object Uint16Array]\",\"[object Int32Array]\",\"[object Uint32Array]\",\"[object Float32Array]\",\"[object Float64Array]\"],l=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function c(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 d(e){return\"string\"!=typeof e&&(e=String(e)),e}function f(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError(\"Already read\"));e.bodyUsed=!0}function m(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function g(e){var t=new FileReader,n=m(t);return t.readAsArrayBuffer(e),n}function v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?\"string\"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=v(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&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set(\"content-type\",\"application/x-www-form-urlencoded;charset=UTF-8\"))},o&&(this.blob=function(){var e=p(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=p(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(g)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=m(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-1?t:e}(t.method||this.method||\"GET\"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(\"GET\"===this.method||\"HEAD\"===this.method)&&n)throw new TypeError(\"Body not allowed for GET or HEAD requests\");if(this._initBody(n),!(\"GET\"!==this.method&&\"HEAD\"!==this.method||\"no-store\"!==t.cache&&\"no-cache\"!==t.cache)){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,\"$1_=\"+(new Date).getTime());else{this.url+=(/\\?/.test(this.url)?\"&\":\"?\")+\"_=\"+(new Date).getTime()}}}function _(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 S(e,t){if(!(this instanceof S))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 h(t.headers),this.url=t.url||\"\",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:\"\"});return e.type=\"error\",e};var E=[301,302,303,307,308];S.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError(\"Invalid status code\");return new S(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 k(e,r){return new Promise((function(i,a){var u=new w(e,r);if(u.signal&&u.signal.aborted)return a(new t.DOMException(\"Aborted\",\"AbortError\"));var l=new XMLHttpRequest;function c(){l.abort()}l.onload=function(){var e,t,n={status:l.status,statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||\"\",t=new h,e.replace(/\\r?\\n[\\t ]+/g,\" \").split(\"\\r\").map((function(e){return 0===e.indexOf(\"\\n\")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(\":\"),r=n.shift().trim();if(r){var i=n.join(\":\").trim();t.append(r,i)}})),t)};n.url=\"responseURL\"in l?l.responseURL:n.headers.get(\"X-Request-URL\");var r=\"response\"in l?l.response:l.responseText;setTimeout((function(){i(new S(r,n))}),0)},l.onerror=function(){setTimeout((function(){a(new TypeError(\"Network request failed\"))}),0)},l.ontimeout=function(){setTimeout((function(){a(new TypeError(\"Network request failed\"))}),0)},l.onabort=function(){setTimeout((function(){a(new t.DOMException(\"Aborted\",\"AbortError\"))}),0)},l.open(u.method,function(e){try{return\"\"===e&&n.location.href?n.location.href:e}catch(t){return e}}(u.url),!0),\"include\"===u.credentials?l.withCredentials=!0:\"omit\"===u.credentials&&(l.withCredentials=!1),\"responseType\"in l&&(o?l.responseType=\"blob\":s&&u.headers.get(\"Content-Type\")&&-1!==u.headers.get(\"Content-Type\").indexOf(\"application/octet-stream\")&&(l.responseType=\"arraybuffer\")),!r||\"object\"!=typeof r.headers||r.headers instanceof h?u.headers.forEach((function(e,t){l.setRequestHeader(t,e)})):Object.getOwnPropertyNames(r.headers).forEach((function(e){l.setRequestHeader(e,d(r.headers[e]))})),u.signal&&(u.signal.addEventListener(\"abort\",c),l.onreadystatechange=function(){4===l.readyState&&u.signal.removeEventListener(\"abort\",c)}),l.send(void 0===u._bodyInit?null:u._bodyInit)}))}k.polyfill=!0,n.fetch||(n.fetch=k,n.Headers=h,n.Request=w,n.Response=S),t.Headers=h,t.Request=w,t.Response=S,t.fetch=k}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t}(o,o.exports);var a=r(o.exports),s=[],u=[],l=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,c=!1;function d(){c=!0;for(var e=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",t=0;t<64;++t)s[t]=e[t],u[e.charCodeAt(t)]=t;u[\"-\".charCodeAt(0)]=62,u[\"_\".charCodeAt(0)]=63}function f(e,t,n){for(var r,i,o=[],a=t;a>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join(\"\")}function h(e){var t;c||d();for(var n=e.length,r=n%3,i=\"\",o=[],a=16383,u=0,l=n-r;ul?l:u+a));return 1===r?(t=e[n-1],i+=s[t>>2],i+=s[t<<4&63],i+=\"==\"):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+=\"=\"),o.push(i),o.join(\"\")}function p(e,t,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,c=-7,d=n?i-1:0,f=n?-1:1,h=e[t+d];for(d+=f,o=h&(1<<-c)-1,h>>=-c,c+=s;c>0;o=256*o+e[t+d],d+=f,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+d],d+=f,c-=8);if(0===o)o=1-l;else{if(o===u)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),o-=l}return(h?-1:1)*a*Math.pow(2,o-r)}function m(e,t,n,r,i,o){var a,s,u,l=8*o-i-1,c=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+d>=1?f/u:f*Math.pow(2,1-d))*u>=2&&(a++,u/=2),a+d>=c?(s=0,a=c):a+d>=1?(s=(t*u-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[n+h]=255&s,h+=p,s/=256,i-=8);for(a=a<0;e[n+h]=255&a,h+=p,a/=256,l-=8);e[n+h-p]|=128*m}var g={}.toString,v=Array.isArray||function(e){return\"[object Array]\"==g.call(e)};_.TYPED_ARRAY_SUPPORT=void 0===t.TYPED_ARRAY_SUPPORT||t.TYPED_ARRAY_SUPPORT;var b=y();function y(){return _.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function w(e,t){if(y()=y())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+y().toString(16)+\" bytes\");return 0|e}function x(e){return!(null==e||!e._isBuffer)}function A(e,t){if(x(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 te(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*n;case\"hex\":return n>>>1;case\"base64\":return ne(e).length;default:if(r)return te(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function R(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 H(this,t,n);case\"utf8\":case\"utf-8\":return U(this,t,n);case\"ascii\":return K(this,t,n);case\"latin1\":case\"binary\":return q(this,t,n);case\"base64\":return z(this,t,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return W(this,t,n);default:if(r)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),r=!0}}function T(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function P(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=_.from(t,r)),x(t))return 0===t.length?-1:L(e,t,n,r,i);if(\"number\"==typeof t)return t&=255,_.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):L(e,[t],n,r,i);throw new TypeError(\"val must be string, number or Buffer\")}function L(e,t,n,r,i){var o,a=1,s=e.length,u=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;a=2,s/=2,u/=2,n/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=n;os&&(n=s-u),o=n;o>=0;o--){for(var d=!0,f=0;fi&&(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 a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function z(e,t,n){return 0===t&&n===e.length?h(e):h(e.slice(t,n))}function U(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(c=l);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&l)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,d=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=d}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);var n=\"\",r=0;for(;r0&&(e=this.toString(\"hex\",0,50).match(/.{2}/g).join(\" \"),this.length>50&&(e+=\" ... \")),\"\"},_.prototype.compare=function(e,t,n,r,i){if(!x(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),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(r,i),l=e.slice(t,n),c=0;ci)&&(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 I(this,e,t,n);case\"utf8\":case\"utf-8\":return O(this,e,t,n);case\"ascii\":return N(this,e,t,n);case\"latin1\":case\"binary\":return D(this,e,t,n);case\"base64\":return j(this,e,t,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return B(this,e,t,n);default:if(o)throw new TypeError(\"Unknown encoding: \"+r);r=(\"\"+r).toLowerCase(),o=!0}},_.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function K(e,t,n){var r=\"\";n=Math.min(e.length,n);for(var i=t;ir)&&(n=r);for(var i=\"\",o=t;on)throw new RangeError(\"Trying to access beyond buffer length\")}function V(e,t,n,r,i,o){if(!x(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError(\"Index out of range\")}function Y(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function G(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function Z(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 Q(e,t,n,r,i){return i||Z(e,0,n,4),m(e,t,n,r,23,4),n+4}function J(e,t,n,r,i){return i||Z(e,0,n,8),m(e,t,n,r,52,8),n+8}_.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),t0&&(i*=256);)r+=this[e+--t]*i;return r},_.prototype.readUInt8=function(e,t){return t||$(e,1,this.length),this[e]},_.prototype.readUInt16LE=function(e,t){return t||$(e,2,this.length),this[e]|this[e+1]<<8},_.prototype.readUInt16BE=function(e,t){return t||$(e,2,this.length),this[e]<<8|this[e+1]},_.prototype.readUInt32LE=function(e,t){return t||$(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},_.prototype.readUInt32BE=function(e,t){return t||$(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},_.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||$(e,t,this.length);for(var r=this[e],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*t)),r},_.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||$(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},_.prototype.readInt8=function(e,t){return t||$(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},_.prototype.readInt16LE=function(e,t){t||$(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},_.prototype.readInt16BE=function(e,t){t||$(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},_.prototype.readInt32LE=function(e,t){return t||$(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},_.prototype.readInt32BE=function(e,t){return t||$(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},_.prototype.readFloatLE=function(e,t){return t||$(e,4,this.length),p(this,e,!0,23,4)},_.prototype.readFloatBE=function(e,t){return t||$(e,4,this.length),p(this,e,!1,23,4)},_.prototype.readDoubleLE=function(e,t){return t||$(e,8,this.length),p(this,e,!0,52,8)},_.prototype.readDoubleBE=function(e,t){return t||$(e,8,this.length),p(this,e,!1,52,8)},_.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||V(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},_.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,1,255,0),_.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},_.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,2,65535,0),_.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},_.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,2,65535,0),_.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},_.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,4,4294967295,0),_.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):G(this,e,t,!0),t+4},_.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,4,4294967295,0),_.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):G(this,e,t,!1),t+4},_.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);V(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+n},_.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);V(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},_.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,1,127,-128),_.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},_.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,2,32767,-32768),_.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},_.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,2,32767,-32768),_.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},_.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,4,2147483647,-2147483648),_.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):G(this,e,t,!0),t+4},_.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||V(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),_.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):G(this,e,t,!1),t+4},_.prototype.writeFloatLE=function(e,t,n){return Q(this,e,t,!0,n)},_.prototype.writeFloatBE=function(e,t,n){return Q(this,e,t,!1,n)},_.prototype.writeDoubleLE=function(e,t,n){return J(this,e,t,!0,n)},_.prototype.writeDoubleBE=function(e,t,n){return J(this,e,t,!1,n)},_.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=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=0;--i)e[i+t]=this[i+n];else if(o<1e3||!_.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),\"number\"==typeof e)for(o=t;o55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+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 ne(e){return function(e){var t,n,r,i,o,a;c||d();var s=e.length;if(s%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");o=\"=\"===e[s-2]?2:\"=\"===e[s-1]?1:0,a=new l(3*s/4-o),r=o>0?s-4:s;var f=0;for(t=0,n=0;t>16&255,a[f++]=i>>8&255,a[f++]=255&i;return 2===o?(i=u[e.charCodeAt(t)]<<2|u[e.charCodeAt(t+1)]>>4,a[f++]=255&i):1===o&&(i=u[e.charCodeAt(t)]<<10|u[e.charCodeAt(t+1)]<<4|u[e.charCodeAt(t+2)]>>2,a[f++]=i>>8&255,a[f++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\\s+|\\s+$/g,\"\")}(e).replace(X,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function re(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function ie(e){return null!=e&&(!!e._isBuffer||oe(e)||function(e){return\"function\"==typeof e.readFloatLE&&\"function\"==typeof e.slice&&oe(e.slice(0,0))}(e))}function oe(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ae=Object.freeze({__proto__:null,Buffer:_,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),_.alloc(+e)},isBuffer:ie,kMaxLength:b}),se={},ue={},le={},ce=i(ae),de={};function fe(){throw new Error(\"setTimeout has not been defined\")}function he(){throw new Error(\"clearTimeout has not been defined\")}var pe=fe,me=he;function ge(e){if(pe===setTimeout)return setTimeout(e,0);if((pe===fe||!pe)&&setTimeout)return pe=setTimeout,setTimeout(e,0);try{return pe(e,0)}catch(t){try{return pe.call(null,e,0)}catch(t){return pe.call(this,e,0)}}}\"function\"==typeof t.setTimeout&&(pe=setTimeout),\"function\"==typeof t.clearTimeout&&(me=clearTimeout);var ve,be=[],ye=!1,we=-1;function _e(){ye&&ve&&(ye=!1,ve.length?be=ve.concat(be):we=-1,be.length&&Se())}function Se(){if(!ye){var e=ge(_e);ye=!0;for(var t=be.length;t;){for(ve=be,be=[];++we1)for(var n=1;nKe)throw new RangeError(\"requested too many random bytes\");var n=qe.allocUnsafe(e);if(e>0)if(e>Fe)for(var r=0;r0&&a.length>i){a.warned=!0;var s=new Error(\"Possible EventEmitter memory leak detected. \"+a.length+\" \"+t+\" listeners added. Use emitter.setMaxListeners() to increase limit\");s.name=\"MaxListenersExceededWarning\",s.emitter=e,s.type=t,s.count=a.length,function(e){\"function\"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else a=o[t]=n,++e._eventsCount;return e}function Xe(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 et(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 tt(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}Ge.prototype=Object.create(null),Ze.EventEmitter=Ze,Ze.usingDomains=!1,Ze.prototype.domain=void 0,Ze.prototype._events=void 0,Ze.prototype._maxListeners=void 0,Ze.defaultMaxListeners=10,Ze.init=function(){this.domain=null,Ze.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ge,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ze.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},Ze.prototype.getMaxListeners=function(){return Qe(this)},Ze.prototype.emit=function(e){var t,n,r,i,o,a,s,u=\"error\"===e;if(a=this._events)u=u&&null==a.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){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=s,t.domainThrown=!1,s.emit(\"error\",t),!1}if(!(n=a[e]))return!1;var c=\"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=tt(e,r),o=0;o0;)if(n[o]===t||n[o].listener&&n[o].listener===t){a=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 Ge,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r0?Reflect.ownKeys(this._events):[]};var nt=i(Object.freeze({__proto__:null,EventEmitter:Ze,default:Ze})),rt=nt.EventEmitter,it=\"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},ot=/%[sdj%]/g;function at(e){if(!St(e)){for(var t=[],n=0;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}})),a=r[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),bt(t)?n.showHidden=t:t&&Dt(n,t),kt(n.showHidden)&&(n.showHidden=!1),kt(n.depth)&&(n.depth=2),kt(n.colors)&&(n.colors=!1),kt(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=ft),pt(n,e,n.depth)}function ft(e,t){var n=dt.styles[t];return n?\"\u001b[\"+dt.colors[n][0]+\"m\"+e+\"\u001b[\"+dt.colors[n][1]+\"m\":e}function ht(e,t){return e}function pt(e,t,n){if(e.customInspect&&t&&Rt(t.inspect)&&t.inspect!==dt&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return St(r)||(r=pt(e,r,n)),r}var i=function(e,t){if(kt(t))return e.stylize(\"undefined\",\"undefined\");if(St(t)){var n=\"'\"+JSON.stringify(t).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return e.stylize(n,\"string\")}if(_t(t))return e.stylize(\"\"+t,\"number\");if(bt(t))return e.stylize(\"\"+t,\"boolean\");if(yt(t))return e.stylize(\"null\",\"null\")}(e,t);if(i)return i;var o=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),At(t)&&(o.indexOf(\"message\")>=0||o.indexOf(\"description\")>=0))return mt(t);if(0===o.length){if(Rt(t)){var s=t.name?\": \"+t.name:\"\";return e.stylize(\"[Function\"+s+\"]\",\"special\")}if(Mt(t))return e.stylize(RegExp.prototype.toString.call(t),\"regexp\");if(xt(t))return e.stylize(Date.prototype.toString.call(t),\"date\");if(At(t))return mt(t)}var u,l=\"\",c=!1,d=[\"{\",\"}\"];(vt(t)&&(c=!0,d=[\"[\",\"]\"]),Rt(t))&&(l=\" [Function\"+(t.name?\": \"+t.name:\"\")+\"]\");return Mt(t)&&(l=\" \"+RegExp.prototype.toString.call(t)),xt(t)&&(l=\" \"+Date.prototype.toUTCString.call(t)),At(t)&&(l=\" \"+mt(t)),0!==o.length||c&&0!=t.length?n<0?Mt(t)?e.stylize(RegExp.prototype.toString.call(t),\"regexp\"):e.stylize(\"[Object]\",\"special\"):(e.seen.push(t),u=c?function(e,t,n,r,i){for(var o=[],a=0,s=t.length;a60)return n[0]+(\"\"===t?\"\":t+\"\\n \")+\" \"+e.join(\",\\n \")+\" \"+n[1];return n[0]+t+\" \"+e.join(\", \")+\" \"+n[1]}(u,l,d)):d[0]+l+d[1]}function mt(e){return\"[\"+Error.prototype.toString.call(e)+\"]\"}function gt(e,t,n,r,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize(\"[Getter/Setter]\",\"special\"):e.stylize(\"[Getter]\",\"special\"):u.set&&(s=e.stylize(\"[Setter]\",\"special\")),jt(r,i)||(a=\"[\"+i+\"]\"),s||(e.seen.indexOf(u.value)<0?(s=yt(n)?pt(e,u.value,null):pt(e,u.value,n-1)).indexOf(\"\\n\")>-1&&(s=o?s.split(\"\\n\").map((function(e){return\" \"+e})).join(\"\\n\").substr(2):\"\\n\"+s.split(\"\\n\").map((function(e){return\" \"+e})).join(\"\\n\")):s=e.stylize(\"[Circular]\",\"special\")),kt(a)){if(o&&i.match(/^\\d+$/))return s;(a=JSON.stringify(\"\"+i)).match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,\"name\")):(a=a.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),a=e.stylize(a,\"string\"))}return a+\": \"+s}function vt(e){return Array.isArray(e)}function bt(e){return\"boolean\"==typeof e}function yt(e){return null===e}function wt(e){return null==e}function _t(e){return\"number\"==typeof e}function St(e){return\"string\"==typeof e}function Et(e){return\"symbol\"==typeof e}function kt(e){return void 0===e}function Mt(e){return Ct(e)&&\"[object RegExp]\"===Lt(e)}function Ct(e){return\"object\"==typeof e&&null!==e}function xt(e){return Ct(e)&&\"[object Date]\"===Lt(e)}function At(e){return Ct(e)&&(\"[object Error]\"===Lt(e)||e instanceof Error)}function Rt(e){return\"function\"==typeof e}function Tt(e){return null===e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e||\"symbol\"==typeof e||void 0===e}function Pt(e){return ie(e)}function Lt(e){return Object.prototype.toString.call(e)}function It(e){return e<10?\"0\"+e.toString(10):e.toString(10)}dt.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]},dt.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"};var Ot=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];function Nt(){console.log(\"%s - %s\",function(){var e=new Date,t=[It(e.getHours()),It(e.getMinutes()),It(e.getSeconds())].join(\":\");return[e.getDate(),Ot[e.getMonth()],t].join(\" \")}(),at.apply(null,arguments))}function Dt(e,t){if(!t||!Ct(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function jt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Bt,zt,Ut={inherits:it,_extend:Dt,log:Nt,isBuffer:Pt,isPrimitive:Tt,isFunction:Rt,isError:At,isDate:xt,isObject:Ct,isRegExp:Mt,isUndefined:kt,isSymbol:Et,isString:St,isNumber:_t,isNullOrUndefined:wt,isNull:yt,isBoolean:bt,isArray:vt,inspect:dt,deprecate:st,format:at,debuglog:ct},Ft=i(Object.freeze({__proto__:null,_extend:Dt,debuglog:ct,default:Ut,deprecate:st,format:at,inherits:it,inspect:dt,isArray:vt,isBoolean:bt,isBuffer:Pt,isDate:xt,isError:At,isFunction:Rt,isNull:yt,isNullOrUndefined:wt,isNumber:_t,isObject:Ct,isPrimitive:Tt,isRegExp:Mt,isString:St,isSymbol:Et,isUndefined:kt,log:Nt}));function Kt(){if(zt)return Bt;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;r0?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 o.alloc(0);for(var t,n,r,i=o.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=i,r=s,o.prototype.copy.call(t,n,r),s+=a.data.length,a=a.next;return i}},{key:\"consume\",value:function(e,t){var n;return ei.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=o.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),0==(e-=a)){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:s,value:function(e,n){return a(this,t(t({},n),{},{depth:0,customInspect:!1}))}}],i&&r(n.prototype,i),u&&r(n,u),Object.defineProperty(n,\"prototype\",{writable:!1}),e}(),Bt}function qt(e,t){Wt(e,t),Ht(e)}function Ht(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(\"close\")}function Wt(e,t){e.emit(\"error\",t)}var $t={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Ee(Wt,this,e)):Ee(Wt,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted?Ee(Ht,n):(n._writableState.errorEmitted=!0,Ee(qt,n,e)):Ee(qt,n,e):t?(Ee(Ht,n),t(e)):Ee(Ht,n)})),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)}},Vt={};var Yt={};function Gt(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,Yt[e]=r}function Zt(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))}Gt(\"ERR_INVALID_OPT_VALUE\",(function(e,t){return'The value \"'+t+'\" is invalid for option \"'+e+'\"'}),TypeError),Gt(\"ERR_INVALID_ARG_TYPE\",(function(e,t,n){var r,i,o,a;if(\"string\"==typeof t&&(i=\"not \",t.substr(!o||o<0?0:+o,i.length)===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-t.length,n)===t}(e,\" argument\"))a=\"The \".concat(e,\" \").concat(r,\" \").concat(Zt(t,\"type\"));else{var s=function(e,t,n){return\"number\"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,\".\")?\"property\":\"argument\";a='The \"'.concat(e,'\" ').concat(s,\" \").concat(r,\" \").concat(Zt(t,\"type\"))}return a+=\". Received type \".concat(typeof n)}),TypeError),Gt(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),Gt(\"ERR_METHOD_NOT_IMPLEMENTED\",(function(e){return\"The \"+e+\" method is not implemented\"})),Gt(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),Gt(\"ERR_STREAM_DESTROYED\",(function(e){return\"Cannot call \"+e+\" after a stream was destroyed\"})),Gt(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),Gt(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),Gt(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),Gt(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),Gt(\"ERR_UNKNOWN_ENCODING\",(function(e){return\"Unknown encoding: \"+e}),TypeError),Gt(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),Vt.codes=Yt;var Qt=Vt.codes.ERR_INVALID_OPT_VALUE;var Jt,Xt,en,tn,nn={getHighWaterMark:function(e,t,n,r){var i=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new Qt(r?n:\"highWaterMark\",i);return Math.floor(i)}return e.objectMode?16:16384}},rn=function(e,t){if(on(\"noDeprecation\"))return e;var n=!1;return function(){if(!n){if(on(\"throwDeprecation\"))throw new Error(t);on(\"traceDeprecation\")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}};function on(e){try{if(!n.localStorage)return!1}catch(e){return!1}var t=n.localStorage[e];return null!=t&&\"true\"===String(t).toLowerCase()}function an(){if(Xt)return Jt;function e(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var t;Xt=1,Jt=S,S.WritableState=_;var r={deprecate:rn},i=rt,o=ce.Buffer,a=(void 0!==n?n:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var s,u=$t,l=nn.getHighWaterMark,c=Vt.codes,d=c.ERR_INVALID_ARG_TYPE,f=c.ERR_METHOD_NOT_IMPLEMENTED,h=c.ERR_MULTIPLE_CALLBACK,p=c.ERR_STREAM_CANNOT_PIPE,m=c.ERR_STREAM_DESTROYED,g=c.ERR_STREAM_NULL_VALUES,v=c.ERR_STREAM_WRITE_AFTER_END,b=c.ERR_UNKNOWN_ENCODING,y=u.errorOrDestroy;function w(){}function _(n,r,i){t=t||sn(),n=n||{},\"boolean\"!=typeof i&&(i=r instanceof t),this.objectMode=!!n.objectMode,i&&(this.objectMode=this.objectMode||!!n.writableObjectMode),this.highWaterMark=l(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?(Ee(i,r),Ee(A,e,t),e._writableState.errorEmitted=!0,y(e,r)):(i(r),e._writableState.errorEmitted=!0,y(e,r),A(e,t))}(e,n,r,t,i);else{var o=C(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||M(e,n),r?Ee(k,e,n,o,i):k(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 S(e){var n=this instanceof(t=t||sn());if(!n&&!s.call(S,this))return new S(e);this._writableState=new _(e,this,n),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 E(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new m(\"write\")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function k(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 M(t,n){n.bufferProcessing=!0;var r=n.bufferedRequest;if(t._writev&&r&&r.next){var i=n.bufferedRequestCount,o=new Array(i),a=n.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)o[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;o.allBuffers=u,E(t,n,!0,n.length,o,\"\",a.finish),n.pendingcb++,n.lastBufferedRequest=null,a.next?(n.corkedRequestsFree=a.next,a.next=null):n.corkedRequestsFree=new e(n),n.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,c=r.encoding,d=r.callback;if(E(t,n,!1,n.objectMode?1:l.length,l,c,d),r=r.next,n.bufferedRequestCount--,n.writing)break}null===r&&(n.lastBufferedRequest=null)}n.bufferedRequest=r,n.bufferProcessing=!1}function C(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&&y(e,n),t.prefinished=!0,e.emit(\"prefinish\"),A(e,t)}))}function A(e,t){var n=C(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,Ee(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 Ve(S,i),_.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(_.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]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(S,Symbol.hasInstance,{value:function(e){return!!s.call(this,e)||this===S&&(e&&e._writableState instanceof _)}})):s=function(e){return e instanceof this},S.prototype.pipe=function(){y(this,new p)},S.prototype.write=function(e,t,n){var r,i=this._writableState,s=!1,u=!i.objectMode&&(r=e,o.isBuffer(r)||r instanceof a);return u&&!o.isBuffer(e)&&(e=function(e){return o.from(e)}(e)),\"function\"==typeof t&&(n=t,t=null),u?t=\"buffer\":t||(t=i.defaultEncoding),\"function\"!=typeof n&&(n=w),i.ending?function(e,t){var n=new v;y(e,n),Ee(t,n)}(this,n):(u||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||(y(e,i),Ee(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,s=function(e,t,n,r,i,a){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||\"string\"!=typeof t||(t=o.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i=\"buffer\",r=s)}var u=t.objectMode?1:r.length;t.length+=u;var l=t.length-1))throw new b(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(S.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(e,t,n){n(new f(\"_write()\"))},S.prototype._writev=null,S.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?Ee(n):e.once(\"finish\",n));t.ended=!0,e.writable=!1}(this,r,n),this},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._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),S.prototype.destroy=u.destroy,S.prototype._undestroy=u.undestroy,S.prototype._destroy=function(e,t){t(e)},Jt}function sn(){if(tn)return en;tn=1;var e=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};en=a;var t=_n(),n=an();Ve(a,t);for(var r=e(n.prototype),i=0;i>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function i(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,\"�\";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,\"�\";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,\"�\"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function o(e,t){if((e.length-t)%2==0){var n=e.toString(\"utf16le\",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(\"utf16le\",t,e.length-1)}function a(e){var t=e&&e.length?this.write(e):\"\";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(\"utf16le\",0,n)}return t}function s(e,t){var n=(e.length-t)%3;return 0===n?e.toString(\"base64\",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(\"base64\",t,e.length-n))}function u(e){var t=e&&e.length?this.write(e):\"\";return this.lastNeed?t+this.lastChar.toString(\"base64\",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function c(e){return e&&e.length?this.write(e):\"\"}return ln.StringDecoder=n,n.prototype.write=function(e){if(0===e.length)return\"\";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return\"\";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return o>0&&(e.lastNeed=o-1),o;if(--i=0)return o>0&&(e.lastNeed=o-2),o;if(--i=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString(\"utf8\",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString(\"utf8\",t,i)},n.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},ln}var dn=Vt.codes.ERR_STREAM_PREMATURE_CLOSE;function fn(){}var hn,pn,mn,gn,vn,bn,yn=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;i0)if(\"string\"==typeof t||l.objectMode||Object.getPrototypeOf(t)===i.prototype||(t=function(e){return i.from(e)}(t)),r)l.endEmitted?y(e,new b):k(e,l,t,!0);else if(l.ended)y(e,new g);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!n?(t=l.decoder.write(t),l.objectMode||0!==t.length?k(e,l,t,!1):R(e,l)):k(e,l,t,!1)}else r||(l.reading=!1,R(e,l));return!l.ended&&(l.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=M?e=M:(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 t=e._readableState;a(\"emitReadable\",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(a(\"emitReadable\",t.flowing),t.emittedReadable=!0,Ee(A,e))}function A(e){var t=e._readableState;a(\"emitReadable_\",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit(\"readable\"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,O(e)}function R(e,t){t.readingMore||(t.readingMore=!0,Ee(T,e,t))}function T(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(\"data\")>0&&e.resume()}function L(e){a(\"readable nexttick read 0\"),e.read(0)}function I(e,t){a(\"resume\",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(\"resume\"),O(e),t.flowing&&!t.reading&&e.read(0)}function O(e){var t=e._readableState;for(a(\"flow\",t.flowing);t.flowing&&null!==e.read(););}function N(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 D(e){var t=e._readableState;a(\"endReadable\",t.endEmitted),t.endEmitted||(t.ended=!0,Ee(j,t,e))}function j(e,t){if(a(\"endReadableNT\",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit(\"end\"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function B(e,t){for(var n=0,r=e.length;n=t.highWaterMark:t.length>0)||t.ended))return a(\"read: emitReadable\",t.length,t.ended),0===t.length&&t.ended?D(this):x(this),null;if(0===(e=C(e,t))&&t.ended)return 0===t.length&&D(this),null;var r,i=t.needReadable;return a(\"need readable\",i),(0===t.length||t.length-e0?N(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&D(this)),null!==r&&this.emit(\"data\",r),r},S.prototype._read=function(e){y(this,new v(\"_read()\"))},S.prototype.pipe=function(e,n){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,a(\"pipe count=%d opts=%j\",i.pipesCount,n);var o=(!n||!1!==n.end)&&e!==je.stdout&&e!==je.stderr?u:m;function s(t,n){a(\"onunpipe\"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,a(\"cleanup\"),e.removeListener(\"close\",h),e.removeListener(\"finish\",p),e.removeListener(\"drain\",l),e.removeListener(\"error\",f),e.removeListener(\"unpipe\",s),r.removeListener(\"end\",u),r.removeListener(\"end\",m),r.removeListener(\"data\",d),c=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){a(\"onend\"),e.end()}i.endEmitted?Ee(o):r.once(\"end\",o),e.on(\"unpipe\",s);var l=function(e){return function(){var n=e._readableState;a(\"pipeOnDrain\",n.awaitDrain),n.awaitDrain&&n.awaitDrain--,0===n.awaitDrain&&t(e,\"data\")&&(n.flowing=!0,O(e))}}(r);e.on(\"drain\",l);var c=!1;function d(t){a(\"ondata\");var n=e.write(t);a(\"dest.write\",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==B(i.pipes,e))&&!c&&(a(\"false write response, pause\",i.awaitDrain),i.awaitDrain++),r.pause())}function f(n){a(\"onerror\",n),m(),e.removeListener(\"error\",f),0===t(e,\"error\")&&y(e,n)}function h(){e.removeListener(\"finish\",p),m()}function p(){a(\"onfinish\"),e.removeListener(\"close\",h),m()}function m(){a(\"unpipe\"),r.unpipe(e)}return r.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\",f),e.once(\"close\",h),e.once(\"finish\",p),e.emit(\"pipe\",r),i.flowing||(a(\"pipe resume\"),r.resume()),e},S.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;o0,!1!==i.flowing&&this.resume()):\"readable\"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,a(\"on readable\",i.length,i.reading),i.length?x(this):i.reading||Ee(L,this))),n},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(e,t){var n=r.prototype.removeListener.call(this,e,t);return\"readable\"===e&&Ee(P,this),n},S.prototype.removeAllListeners=function(e){var t=r.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==e&&void 0!==e||Ee(P,this),t},S.prototype.resume=function(){var e=this._readableState;return e.flowing||(a(\"resume\"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Ee(I,e,t))}(this,e)),e.paused=!1,this},S.prototype.pause=function(){return a(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(a(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},S.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(\"end\",(function(){if(a(\"wrapped end\"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on(\"data\",(function(i){(a(\"wrapped data\"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))})),e)void 0===this[i]&&\"function\"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o0,(function(e){r||(r=e),e&&o.forEach(Fn),a||(o.forEach(Fn),i(r))}))}));return t.reduce(Kn)};!function(e,t){(t=e.exports=_n()).Stream=t,t.Readable=t,t.Writable=an(),t.Duplex=sn(),t.Transform=Sn,t.PassThrough=On,t.finished=yn,t.pipeline=qn}(Ye,Ye.exports);var Hn=Ye.exports,Wn=Ue().Buffer,$n=Hn.Transform;function Vn(e){$n.call(this),this._block=Wn.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Ve(Vn,$n),Vn.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},Vn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},Vn.prototype.update=function(e,t){if(function(e,t){if(!Wn.isBuffer(e)&&\"string\"!=typeof e)throw new TypeError(t+\" must be a string or a buffer\")}(e,\"Data\"),this._finalized)throw new Error(\"Digest already called\");Wn.isBuffer(e)||(e=Wn.from(e,t));for(var n=this._block,r=0;this._blockOffset+e.length-r>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},Vn.prototype._update=function(){throw new Error(\"_update is not implemented\")},Vn.prototype.digest=function(e){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},Vn.prototype._digest=function(){throw new Error(\"_digest is not implemented\")};var Yn=Vn,Gn=Ve,Zn=Yn,Qn=Ue().Buffer,Jn=new Array(16);function Xn(){Zn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function er(e,t){return e<>>32-t}function tr(e,t,n,r,i,o,a){return er(e+(t&n|~t&r)+i+o|0,a)+t|0}function nr(e,t,n,r,i,o,a){return er(e+(t&r|n&~r)+i+o|0,a)+t|0}function rr(e,t,n,r,i,o,a){return er(e+(t^n^r)+i+o|0,a)+t|0}function ir(e,t,n,r,i,o,a){return er(e+(n^(t|~r))+i+o|0,a)+t|0}Gn(Xn,Zn),Xn.prototype._update=function(){for(var e=Jn,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=tr(n,r,i,o,e[0],3614090360,7),o=tr(o,n,r,i,e[1],3905402710,12),i=tr(i,o,n,r,e[2],606105819,17),r=tr(r,i,o,n,e[3],3250441966,22),n=tr(n,r,i,o,e[4],4118548399,7),o=tr(o,n,r,i,e[5],1200080426,12),i=tr(i,o,n,r,e[6],2821735955,17),r=tr(r,i,o,n,e[7],4249261313,22),n=tr(n,r,i,o,e[8],1770035416,7),o=tr(o,n,r,i,e[9],2336552879,12),i=tr(i,o,n,r,e[10],4294925233,17),r=tr(r,i,o,n,e[11],2304563134,22),n=tr(n,r,i,o,e[12],1804603682,7),o=tr(o,n,r,i,e[13],4254626195,12),i=tr(i,o,n,r,e[14],2792965006,17),n=nr(n,r=tr(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=nr(o,n,r,i,e[6],3225465664,9),i=nr(i,o,n,r,e[11],643717713,14),r=nr(r,i,o,n,e[0],3921069994,20),n=nr(n,r,i,o,e[5],3593408605,5),o=nr(o,n,r,i,e[10],38016083,9),i=nr(i,o,n,r,e[15],3634488961,14),r=nr(r,i,o,n,e[4],3889429448,20),n=nr(n,r,i,o,e[9],568446438,5),o=nr(o,n,r,i,e[14],3275163606,9),i=nr(i,o,n,r,e[3],4107603335,14),r=nr(r,i,o,n,e[8],1163531501,20),n=nr(n,r,i,o,e[13],2850285829,5),o=nr(o,n,r,i,e[2],4243563512,9),i=nr(i,o,n,r,e[7],1735328473,14),n=rr(n,r=nr(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=rr(o,n,r,i,e[8],2272392833,11),i=rr(i,o,n,r,e[11],1839030562,16),r=rr(r,i,o,n,e[14],4259657740,23),n=rr(n,r,i,o,e[1],2763975236,4),o=rr(o,n,r,i,e[4],1272893353,11),i=rr(i,o,n,r,e[7],4139469664,16),r=rr(r,i,o,n,e[10],3200236656,23),n=rr(n,r,i,o,e[13],681279174,4),o=rr(o,n,r,i,e[0],3936430074,11),i=rr(i,o,n,r,e[3],3572445317,16),r=rr(r,i,o,n,e[6],76029189,23),n=rr(n,r,i,o,e[9],3654602809,4),o=rr(o,n,r,i,e[12],3873151461,11),i=rr(i,o,n,r,e[15],530742520,16),n=ir(n,r=rr(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=ir(o,n,r,i,e[7],1126891415,10),i=ir(i,o,n,r,e[14],2878612391,15),r=ir(r,i,o,n,e[5],4237533241,21),n=ir(n,r,i,o,e[12],1700485571,6),o=ir(o,n,r,i,e[3],2399980690,10),i=ir(i,o,n,r,e[10],4293915773,15),r=ir(r,i,o,n,e[1],2240044497,21),n=ir(n,r,i,o,e[8],1873313359,6),o=ir(o,n,r,i,e[15],4264355552,10),i=ir(i,o,n,r,e[6],2734768916,15),r=ir(r,i,o,n,e[13],1309151649,21),n=ir(n,r,i,o,e[4],4149444226,6),o=ir(o,n,r,i,e[11],3174756917,10),i=ir(i,o,n,r,e[2],718787259,15),r=ir(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},Xn.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Qn.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};var or=Xn,ar=ce.Buffer,sr=Ve,ur=Yn,lr=new Array(16),cr=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],dr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],fr=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],hr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],pr=[0,1518500249,1859775393,2400959708,2840853838],mr=[1352829926,1548603684,1836072691,2053994217,0];function gr(){ur.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function vr(e,t){return e<>>32-t}function br(e,t,n,r,i,o,a,s){return vr(e+(t^n^r)+o+a|0,s)+i|0}function yr(e,t,n,r,i,o,a,s){return vr(e+(t&n|~t&r)+o+a|0,s)+i|0}function wr(e,t,n,r,i,o,a,s){return vr(e+((t|~n)^r)+o+a|0,s)+i|0}function _r(e,t,n,r,i,o,a,s){return vr(e+(t&r|n&~r)+o+a|0,s)+i|0}function Sr(e,t,n,r,i,o,a,s){return vr(e+(t^(n|~r))+o+a|0,s)+i|0}sr(gr,ur),gr.prototype._update=function(){for(var e=lr,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._a,u=0|this._b,l=0|this._c,c=0|this._d,d=0|this._e,f=0;f<80;f+=1){var h,p;f<16?(h=br(n,r,i,o,a,e[cr[f]],pr[0],fr[f]),p=Sr(s,u,l,c,d,e[dr[f]],mr[0],hr[f])):f<32?(h=yr(n,r,i,o,a,e[cr[f]],pr[1],fr[f]),p=_r(s,u,l,c,d,e[dr[f]],mr[1],hr[f])):f<48?(h=wr(n,r,i,o,a,e[cr[f]],pr[2],fr[f]),p=wr(s,u,l,c,d,e[dr[f]],mr[2],hr[f])):f<64?(h=_r(n,r,i,o,a,e[cr[f]],pr[3],fr[f]),p=yr(s,u,l,c,d,e[dr[f]],mr[3],hr[f])):(h=Sr(n,r,i,o,a,e[cr[f]],pr[4],fr[f]),p=br(s,u,l,c,d,e[dr[f]],mr[4],hr[f])),n=a,a=o,o=vr(i,10),i=r,r=h,s=d,d=c,c=vr(l,10),l=u,u=p}var m=this._b+i+c|0;this._b=this._c+o+d|0,this._c=this._d+a+s|0,this._d=this._e+n+u|0,this._e=this._a+r+l|0,this._a=m},gr.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=ar.alloc?ar.alloc(20):new ar(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};var Er=gr,kr={exports:{}},Mr=Ue().Buffer;function Cr(e,t){this._block=Mr.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Cr.prototype.update=function(e,t){\"string\"==typeof e&&(t=t||\"utf8\",e=Mr.from(e,t));for(var n=this._block,r=this._blockSize,i=e.length,o=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(4294967295&n)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},Cr.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")};var xr=Cr,Ar=Ve,Rr=xr,Tr=Ue().Buffer,Pr=[1518500249,1859775393,-1894007588,-899497514],Lr=new Array(80);function Ir(){this.init(),this._w=Lr,Rr.call(this,64,56)}function Or(e){return e<<30|e>>>2}function Nr(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}Ar(Ir,Rr),Ir.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ir.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=n[u-3]^n[u-8]^n[u-14]^n[u-16];for(var l=0;l<80;++l){var c=~~(l/20),d=0|((t=r)<<5|t>>>27)+Nr(c,i,o,a)+s+n[l]+Pr[c];s=a,a=o,o=Or(i),i=r,r=d}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},Ir.prototype._hash=function(){var e=Tr.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var Dr=Ir,jr=Ve,Br=xr,zr=Ue().Buffer,Ur=[1518500249,1859775393,-1894007588,-899497514],Fr=new Array(80);function Kr(){this.init(),this._w=Fr,Br.call(this,64,56)}function qr(e){return e<<5|e>>>27}function Hr(e){return e<<30|e>>>2}function Wr(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}jr(Kr,Br),Kr.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Kr.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=(t=n[u-3]^n[u-8]^n[u-14]^n[u-16])<<1|t>>>31;for(var l=0;l<80;++l){var c=~~(l/20),d=qr(r)+Wr(c,i,o,a)+s+n[l]+Ur[c]|0;s=a,a=o,o=Hr(i),i=r,r=d}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},Kr.prototype._hash=function(){var e=zr.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var $r=Kr,Vr=Ve,Yr=xr,Gr=Ue().Buffer,Zr=[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],Qr=new Array(64);function Jr(){this.init(),this._w=Qr,Yr.call(this,64,56)}function Xr(e,t,n){return n^e&(t^n)}function ei(e,t,n){return e&t|n&(e|t)}function ti(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function ni(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function ri(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ii(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Vr(Jr,Yr),Jr.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Jr.prototype._update=function(e){for(var t=this._w,n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._f,u=0|this._g,l=0|this._h,c=0;c<16;++c)t[c]=e.readInt32BE(4*c);for(;c<64;++c)t[c]=ii(t[c-2])+t[c-7]+ri(t[c-15])+t[c-16]|0;for(var d=0;d<64;++d){var f=l+ni(a)+Xr(a,s,u)+Zr[d]+t[d]|0,h=ti(n)+ei(n,r,i)|0;l=u,u=s,s=a,a=o+f|0,o=i,i=r,r=n,n=f+h|0}this._a=n+this._a|0,this._b=r+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=s+this._f|0,this._g=u+this._g|0,this._h=l+this._h|0},Jr.prototype._hash=function(){var e=Gr.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var oi=Jr,ai=Ve,si=oi,ui=xr,li=Ue().Buffer,ci=new Array(64);function di(){this.init(),this._w=ci,ui.call(this,64,56)}ai(di,si),di.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},di.prototype._hash=function(){var e=li.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var fi=di,hi=Ve,pi=xr,mi=Ue().Buffer,gi=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],vi=new Array(160);function bi(){this.init(),this._w=vi,pi.call(this,128,112)}function yi(e,t,n){return n^e&(t^n)}function wi(e,t,n){return e&t|n&(e|t)}function _i(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Si(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Ei(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function ki(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Mi(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Ci(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function xi(e,t){return e>>>0>>0?1:0}hi(bi,pi),bi.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},bi.prototype._update=function(e){for(var t=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,s=0|this._fh,u=0|this._gh,l=0|this._hh,c=0|this._al,d=0|this._bl,f=0|this._cl,h=0|this._dl,p=0|this._el,m=0|this._fl,g=0|this._gl,v=0|this._hl,b=0;b<32;b+=2)t[b]=e.readInt32BE(4*b),t[b+1]=e.readInt32BE(4*b+4);for(;b<160;b+=2){var y=t[b-30],w=t[b-30+1],_=Ei(y,w),S=ki(w,y),E=Mi(y=t[b-4],w=t[b-4+1]),k=Ci(w,y),M=t[b-14],C=t[b-14+1],x=t[b-32],A=t[b-32+1],R=S+C|0,T=_+M+xi(R,S)|0;T=(T=T+E+xi(R=R+k|0,k)|0)+x+xi(R=R+A|0,A)|0,t[b]=T,t[b+1]=R}for(var P=0;P<160;P+=2){T=t[P],R=t[P+1];var L=wi(n,r,i),I=wi(c,d,f),O=_i(n,c),N=_i(c,n),D=Si(a,p),j=Si(p,a),B=gi[P],z=gi[P+1],U=yi(a,s,u),F=yi(p,m,g),K=v+j|0,q=l+D+xi(K,v)|0;q=(q=(q=q+U+xi(K=K+F|0,F)|0)+B+xi(K=K+z|0,z)|0)+T+xi(K=K+R|0,R)|0;var H=N+I|0,W=O+L+xi(H,N)|0;l=u,v=g,u=s,g=m,s=a,m=p,a=o+q+xi(p=h+K|0,h)|0,o=i,h=f,i=r,f=d,r=n,d=c,n=q+W+xi(c=K+H|0,K)|0}this._al=this._al+c|0,this._bl=this._bl+d|0,this._cl=this._cl+f|0,this._dl=this._dl+h|0,this._el=this._el+p|0,this._fl=this._fl+m|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+n+xi(this._al,c)|0,this._bh=this._bh+r+xi(this._bl,d)|0,this._ch=this._ch+i+xi(this._cl,f)|0,this._dh=this._dh+o+xi(this._dl,h)|0,this._eh=this._eh+a+xi(this._el,p)|0,this._fh=this._fh+s+xi(this._fl,m)|0,this._gh=this._gh+u+xi(this._gl,g)|0,this._hh=this._hh+l+xi(this._hl,v)|0},bi.prototype._hash=function(){var e=mi.allocUnsafe(64);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Ai=bi,Ri=Ve,Ti=Ai,Pi=xr,Li=Ue().Buffer,Ii=new Array(160);function Oi(){this.init(),this._w=Ii,Pi.call(this,128,112)}Ri(Oi,Ti),Oi.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Oi.prototype._hash=function(){var e=Li.allocUnsafe(48);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Ni=Oi,Di=kr.exports=function(e){e=e.toLowerCase();var t=Di[e];if(!t)throw new Error(e+\" is not supported (we accept pull requests)\");return new t};Di.sha=Dr,Di.sha1=$r,Di.sha224=fi,Di.sha256=oi,Di.sha384=Ni,Di.sha512=Ai;var ji=kr.exports;function Bi(){this.head=null,this.tail=null,this.length=0}Bi.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Bi.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Bi.prototype.shift=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}},Bi.prototype.clear=function(){this.head=this.tail=null,this.length=0},Bi.prototype.join=function(e){if(0===this.length)return\"\";for(var t=this.head,n=\"\"+t.data;t=t.next;)n+=e+t.data;return n},Bi.prototype.concat=function(e){if(0===this.length)return _.alloc(0);if(1===this.length)return this.head.data;for(var t=_.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t};var zi=_.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 Ui(e){switch(this.encoding=(e||\"utf8\").toLowerCase().replace(/[-_]/,\"\"),function(e){if(e&&!zi(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=Ki;break;case\"base64\":this.surrogateSize=3,this.detectIncompleteChar=qi;break;default:return void(this.write=Fi)}this.charBuffer=new _(6),this.charReceived=0,this.charLength=0}function Fi(e){return e.toString(this.encoding)}function Ki(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function qi(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Ui.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=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=\"\"}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived);var i;r=(t+=e.toString(this.encoding,0,r)).length-1;if((i=t.charCodeAt(r))>=55296&&i<=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,r)}return t},Ui.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},Ui.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 Hi=Object.freeze({__proto__:null,StringDecoder:Ui});Vi.ReadableState=$i;var Wi=ct(\"stream\");function $i(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof So&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new Bi,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.defaultEncoding=e.defaultEncoding||\"utf8\",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new Ui(e.encoding),this.encoding=e.encoding)}function Vi(e){if(!(this instanceof Vi))return new Vi(e);this._readableState=new $i(e,this),this.readable=!0,e&&\"function\"==typeof e.read&&(this._read=e.read),Ze.call(this)}function Yi(e,t,n,r,i){var o=function(e,t){var n=null;ie(t)||\"string\"==typeof t||null==t||e.objectMode||(n=new TypeError(\"Invalid non-string/buffer chunk\"));return n}(t,n);if(o)e.emit(\"error\",o);else if(null===n)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,Qi(e)}(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var a=new Error(\"stream.push() after EOF\");e.emit(\"error\",a)}else if(t.endEmitted&&i){var s=new Error(\"stream.unshift() after end event\");e.emit(\"error\",s)}else{var u;!t.decoder||i||r||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit(\"data\",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&Qi(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ee(Xi,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=Gi?e=Gi:(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 Qi(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Wi(\"emitReadable\",t.flowing),t.emittedReadable=!0,t.sync?Ee(Ji,e):Ji(e))}function Ji(e){Wi(\"emit readable\"),e.emit(\"readable\"),no(e)}function Xi(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(\"\"):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=_.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),0===(e-=a)){a===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function io(e){var t=e._readableState;if(t.length>0)throw new Error('\"endReadable()\" called on non-empty stream');t.endEmitted||(t.ended=!0,Ee(oo,t,e))}function oo(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit(\"end\"))}function ao(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return Wi(\"read: emitReadable\",t.length,t.ended),0===t.length&&t.ended?io(this):Qi(this),null;if(0===(e=Zi(e,t))&&t.ended)return 0===t.length&&io(this),null;var r,i=t.needReadable;return Wi(\"need readable\",i),(0===t.length||t.length-e0?ro(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&io(this)),null!==r&&this.emit(\"data\",r),r},Vi.prototype._read=function(e){this.emit(\"error\",new Error(\"not implemented\"))},Vi.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,Wi(\"pipe count=%d opts=%j\",r.pipesCount,t);var i=!t||!1!==t.end?a:l;function o(e){Wi(\"onunpipe\"),e===n&&l()}function a(){Wi(\"onend\"),e.end()}r.endEmitted?Ee(i):n.once(\"end\",i),e.on(\"unpipe\",o);var s=function(e){return function(){var t=e._readableState;Wi(\"pipeOnDrain\",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners(\"data\").length&&(t.flowing=!0,no(e))}}(n);e.on(\"drain\",s);var u=!1;function l(){Wi(\"cleanup\"),e.removeListener(\"close\",h),e.removeListener(\"finish\",p),e.removeListener(\"drain\",s),e.removeListener(\"error\",f),e.removeListener(\"unpipe\",o),n.removeListener(\"end\",a),n.removeListener(\"end\",l),n.removeListener(\"data\",d),u=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||s()}var c=!1;function d(t){Wi(\"ondata\"),c=!1,!1!==e.write(t)||c||((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==ao(r.pipes,e))&&!u&&(Wi(\"false write response, pause\",n._readableState.awaitDrain),n._readableState.awaitDrain++,c=!0),n.pause())}function f(t){var n;Wi(\"onerror\",t),m(),e.removeListener(\"error\",f),0===(n=\"error\",e.listeners(n).length)&&e.emit(\"error\",t)}function h(){e.removeListener(\"finish\",p),m()}function p(){Wi(\"onfinish\"),e.removeListener(\"close\",h),m()}function m(){Wi(\"unpipe\"),n.unpipe(e)}return n.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\",f),e.once(\"close\",h),e.once(\"finish\",p),e.emit(\"pipe\",n),r.flowing||(Wi(\"pipe resume\"),n.resume()),e},Vi.prototype.unpipe=function(e){var t=this._readableState;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)),this;if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError(\"Unknown encoding: \"+e);return this._writableState.defaultEncoding=e,this},co.prototype._write=function(e,t,n){n(new Error(\"not implemented\"))},co.prototype._writev=null,co.prototype.end=function(e,t,n){var r=this._writableState;\"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||r.finished||function(e,t,n){t.ending=!0,vo(e,t),n&&(t.finished?Ee(n):e.once(\"finish\",n));t.ended=!0,e.writable=!1}(this,r,n)},it(So,Vi);for(var yo=Object.keys(co.prototype),wo=0;woVo?t=e(t):t.lengthn)?t=(\"rmd160\"===e?new na:ra(e)).update(t).digest():t.lengthda||t!=t)throw new TypeError(\"Bad key length\")};if(n.process&&n.process.browser)aa=\"utf-8\";else if(n.process&&n.process.version){aa=parseInt(je.version.split(\".\")[0].slice(1),10)>=6?\"utf-8\":\"binary\"}else aa=\"utf-8\";var ha=aa,pa=Ue().Buffer,ma=function(e,t,n){if(pa.isBuffer(e))return e;if(\"string\"==typeof e)return pa.from(e,t);if(ArrayBuffer.isView(e))return pa.from(e.buffer);throw new TypeError(n+\" must be a string, a Buffer, a typed array or a DataView\")},ga=Zo,va=Er,ba=ji,ya=Ue().Buffer,wa=fa,_a=ha,Sa=ma,Ea=ya.alloc(128),ka={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Ma(e,t,n){var r=function(e){function t(t){return ba(e).update(t).digest()}function n(e){return(new va).update(e).digest()}return\"rmd160\"===e||\"ripemd160\"===e?n:\"md5\"===e?ga:t}(e),i=\"sha512\"===e||\"sha384\"===e?128:64;t.length>i?t=r(t):t.length>>0},writeUInt32BE:function(e,t,n){e[0+n]=t>>>24,e[1+n]=t>>>16&255,e[2+n]=t>>>8&255,e[3+n]=255&t},ip:function(e,t,n,r){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}n[r+0]=i>>>0,n[r+1]=o>>>0},rip:function(e,t,n,r){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;n[r+0]=i>>>0,n[r+1]=o>>>0},pc1:function(e,t,n,r){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;n[r+0]=i>>>0,n[r+1]=o>>>0},r28shl:function(e,t){return e<>>28-t}},Ka=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Fa.pc2=function(e,t,n,r){for(var i=0,o=0,a=Ka.length>>>1,s=0;s>>Ka[s]&1;for(s=a;s>>Ka[s]&1;n[r+0]=i>>>0,n[r+1]=o>>>0},Fa.expand=function(e,t,n){var r=0,i=0;r=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)r<<=6,r|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[n+0]=r>>>0,t[n+1]=i>>>0};var qa=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Fa.substitute=function(e,t){for(var n=0,r=0;r<4;r++){n<<=4,n|=qa[64*r+(e>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=qa[256+64*r+(t>>>18-6*r&63)]}return n>>>0};var Ha=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Fa.permute=function(e){for(var t=0,n=0;n>>Ha[n]&1;return t>>>0},Fa.padSplit=function(e,t,n){for(var r=e.toString(2);r.length0;r--)t+=this._buffer(e,t),n+=this._flushBuffer(i,n);return t+=this._buffer(e,t),i},Ya.prototype.final=function(e){var t,n;return e&&(t=this.update(e)),n=\"encrypt\"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(n):n},Ya.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];n=Qa.r28shl(n,o),r=Qa.r28shl(r,o),Qa.pc2(n,r,e.keys,i)}},es.prototype._update=function(e,t,n,r){var i=this._desState,o=Qa.readUInt32BE(e,t),a=Qa.readUInt32BE(e,t+4);Qa.ip(o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],\"encrypt\"===this.type?this._encrypt(i,o,a,i.tmp,0):this._decrypt(i,o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],Qa.writeUInt32BE(n,o,r),Qa.writeUInt32BE(n,a,r+4)},es.prototype._pad=function(e,t){if(!1===this.padding)return!1;for(var n=e.length-t,r=t;r>>0,o=d}Qa.rip(a,o,r,i)},es.prototype._decrypt=function(e,t,n,r,i){for(var o=n,a=t,s=e.keys.length-2;s>=0;s-=2){var u=e.keys[s],l=e.keys[s+1];Qa.expand(o,e.tmp,0),u^=e.tmp[0],l^=e.tmp[1];var c=Qa.substitute(u,l),d=o;o=(a^Qa.permute(c))>>>0,a=d}Qa.rip(o,a,r,i)};var rs={},is=Wa,os=Ve,as={};function ss(e){is.equal(e.length,8,\"Invalid IV length\"),this.iv=new Array(8);for(var t=0;t>o%8,e._prev=js(e._prev,n?r:i);return a}function js(e,t){var n=e.length,r=-1,i=Ns.allocUnsafe(e.length);for(e=Ns.concat([e,Ns.from([t])]);++r>7;return i}Os.encrypt=function(e,t,n){for(var r=t.length,i=Ns.allocUnsafe(r),o=-1;++o>>24]^c[p>>>16&255]^d[m>>>8&255]^f[255&g]^t[v++],a=l[p>>>24]^c[m>>>16&255]^d[g>>>8&255]^f[255&h]^t[v++],s=l[m>>>24]^c[g>>>16&255]^d[h>>>8&255]^f[255&p]^t[v++],u=l[g>>>24]^c[h>>>16&255]^d[p>>>8&255]^f[255&m]^t[v++],h=o,p=a,m=s,g=u;return o=(r[h>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^t[v++],a=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&h])^t[v++],s=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[h>>>8&255]<<8|r[255&p])^t[v++],u=(r[g>>>24]<<24|r[h>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^t[v++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var ru=[0,1,2,4,8,16,32,64,128,27,54],iu=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var n=[],r=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var l=s^s<<1^s<<2^s<<3^s<<4;l=l>>>8^255&l^99,n[a]=l,r[l]=a;var c=e[a],d=e[c],f=e[d],h=257*e[l]^16843008*l;i[0][a]=h<<24|h>>>8,i[1][a]=h<<16|h>>>16,i[2][a]=h<<8|h>>>24,i[3][a]=h,h=16843009*f^65537*d^257*c^16843008*a,o[0][l]=h<<24|h>>>8,o[1][l]=h<<16|h>>>16,o[2][l]=h<<8|h>>>24,o[3][l]=h,0===a?a=s=1:(a=c^e[e[e[f^c]]],s^=e[e[s]])}return{SBOX:n,INV_SBOX:r,SUB_MIX:i,INV_SUB_MIX:o}}();function ou(e){this._key=eu(e),this._reset()}ou.blockSize=16,ou.keySize=32,ou.prototype.blockSize=ou.blockSize,ou.prototype.keySize=ou.keySize,ou.prototype._reset=function(){for(var e=this._key,t=e.length,n=t+6,r=4*(n+1),i=[],o=0;o>>24,a=iu.SBOX[a>>>24]<<24|iu.SBOX[a>>>16&255]<<16|iu.SBOX[a>>>8&255]<<8|iu.SBOX[255&a],a^=ru[o/t|0]<<24):t>6&&o%t==4&&(a=iu.SBOX[a>>>24]<<24|iu.SBOX[a>>>16&255]<<16|iu.SBOX[a>>>8&255]<<8|iu.SBOX[255&a]),i[o]=i[o-t]^a}for(var s=[],u=0;u>>24]]^iu.INV_SUB_MIX[1][iu.SBOX[c>>>16&255]]^iu.INV_SUB_MIX[2][iu.SBOX[c>>>8&255]]^iu.INV_SUB_MIX[3][iu.SBOX[255&c]]}this._nRounds=n,this._keySchedule=i,this._invKeySchedule=s},ou.prototype.encryptBlockRaw=function(e){return nu(e=eu(e),this._keySchedule,iu.SUB_MIX,iu.SBOX,this._nRounds)},ou.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),n=Xs.allocUnsafe(16);return n.writeUInt32BE(t[0],0),n.writeUInt32BE(t[1],4),n.writeUInt32BE(t[2],8),n.writeUInt32BE(t[3],12),n},ou.prototype.decryptBlock=function(e){var t=(e=eu(e))[1];e[1]=e[3],e[3]=t;var n=nu(e,this._invKeySchedule,iu.INV_SUB_MIX,iu.INV_SBOX,this._nRounds),r=Xs.allocUnsafe(16);return r.writeUInt32BE(n[0],0),r.writeUInt32BE(n[3],4),r.writeUInt32BE(n[2],8),r.writeUInt32BE(n[1],12),r},ou.prototype.scrub=function(){tu(this._keySchedule),tu(this._invKeySchedule),tu(this._key)},Js.AES=ou;var au=Ue().Buffer,su=au.alloc(16,0);function uu(e){var t=au.allocUnsafe(16);return t.writeUInt32BE(e[0]>>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function lu(e){this.h=e,this.state=au.alloc(16,0),this.cache=au.allocUnsafe(0)}lu.prototype.ghash=function(e){for(var t=-1;++t0;t--)r[t]=r[t]>>>1|(1&r[t-1])<<31;r[0]=r[0]>>>1,n&&(r[0]=r[0]^225<<24)}this.state=uu(i)},lu.prototype.update=function(e){var t;for(this.cache=au.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},lu.prototype.final=function(e,t){return this.cache.length&&this.ghash(au.concat([this.cache,su],16)),this.ghash(uu([0,e,0,t])),this.state};var cu=lu,du=Js,fu=Ue().Buffer,hu=Do,pu=cu,mu=Ms,gu=Ks;function vu(e,t,n,r){hu.call(this);var i=fu.alloc(4,0);this._cipher=new du.AES(t);var o=this._cipher.encryptBlock(i);this._ghash=new pu(o),n=function(e,t,n){if(12===t.length)return e._finID=fu.concat([t,fu.from([0,0,0,1])]),fu.concat([t,fu.from([0,0,0,2])]);var r=new pu(n),i=t.length,o=i%16;r.update(t),o&&(o=16-o,r.update(fu.alloc(o,0))),r.update(fu.alloc(8,0));var a=8*i,s=fu.alloc(8);s.writeUIntBE(a,0,8),r.update(s),e._finID=r.state;var u=fu.from(e._finID);return gu(u),u}(this,n,o),this._prev=fu.from(n),this._cache=fu.allocUnsafe(0),this._secCache=fu.allocUnsafe(0),this._decrypt=r,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}Ve(vu,hu),vu.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=fu.alloc(t,0),this._ghash.update(t))}this._called=!0;var n=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(n),this._len+=e.length,n},vu.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error(\"Unsupported state or unable to authenticate data\");var e=mu(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var n=0;e.length!==t.length&&n++;for(var r=Math.min(e.length,t.length),i=0;i0||r>0;){var u=new Mu;u.update(s),u.update(e),t&&u.update(t),s=u.digest();var l=0;if(i>0){var c=o.length-i;l=Math.min(i,s.length),s.copy(o,c,0,l),i-=l}if(l0){var d=a.length-r,f=Math.min(r,s.length-l);s.copy(a,d,l,l+f),r-=f}}return s.fill(0),{key:o,iv:a}},xu=Qs,Au=bu,Ru=Ue().Buffer,Tu=Eu,Pu=Do,Lu=Js,Iu=Cu;function Ou(e,t,n){Pu.call(this),this._cache=new Du,this._cipher=new Lu.AES(t),this._prev=Ru.from(n),this._mode=e,this._autopadding=!0}Ve(Ou,Pu),Ou.prototype._update=function(e){var t,n;this._cache.add(e);for(var r=[];t=this._cache.get();)n=this._mode.encrypt(this,t),r.push(n);return Ru.concat(r)};var Nu=Ru.alloc(16,16);function Du(){this.cache=Ru.allocUnsafe(0)}function ju(e,t,n){var r=xu[e.toLowerCase()];if(!r)throw new TypeError(\"invalid suite type\");if(\"string\"==typeof t&&(t=Ru.from(t)),t.length!==r.key/8)throw new TypeError(\"invalid key length \"+t.length);if(\"string\"==typeof n&&(n=Ru.from(n)),\"GCM\"!==r.mode&&n.length!==r.iv)throw new TypeError(\"invalid iv length \"+n.length);return\"stream\"===r.type?new Tu(r.module,t,n):\"auth\"===r.type?new Au(r.module,t,n):new Ou(r.module,t,n)}Ou.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(Nu))throw this._cipher.scrub(),new Error(\"data not multiple of block length\")},Ou.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},Du.prototype.add=function(e){this.cache=Ru.concat([this.cache,e])},Du.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},Du.prototype.flush=function(){for(var e=16-this.cache.length,t=Ru.allocUnsafe(e),n=-1;++n16)throw new Error(\"unable to decrypt data\");var n=-1;for(;++n16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},Vu.prototype.flush=function(){if(this.cache.length)return this.cache},Bu.createDecipher=function(e,t){var n=Fu[e.toLowerCase()];if(!n)throw new TypeError(\"invalid suite type\");var r=Wu(t,!1,n.key,n.iv);return Yu(e,r.key,r.iv)},Bu.createDecipheriv=Yu;var Gu=Ss,Zu=Bu,Qu=Vs;_s.createCipher=_s.Cipher=Gu.createCipher,_s.createCipheriv=_s.Cipheriv=Gu.createCipheriv,_s.createDecipher=_s.Decipher=Zu.createDecipher,_s.createDecipheriv=_s.Decipheriv=Zu.createDecipheriv,_s.listCiphers=_s.getCiphers=function(){return Object.keys(Qu)};var Ju={};!function(e){e[\"des-ecb\"]={key:8,iv:0},e[\"des-cbc\"]=e.des={key:8,iv:8},e[\"des-ede3-cbc\"]=e.des3={key:24,iv:8},e[\"des-ede3\"]={key:24,iv:0},e[\"des-ede-cbc\"]={key:16,iv:8},e[\"des-ede\"]={key:16,iv:0}}(Ju);var Xu=ys,el=_s,tl=Qs,nl=Ju,rl=Cu;function il(e,t,n){if(e=e.toLowerCase(),tl[e])return el.createCipheriv(e,t,n);if(nl[e])return new Xu({key:t,iv:n,mode:e});throw new TypeError(\"invalid suite type\")}function ol(e,t,n){if(e=e.toLowerCase(),tl[e])return el.createDecipheriv(e,t,n);if(nl[e])return new Xu({key:t,iv:n,mode:e,decrypt:!0});throw new TypeError(\"invalid suite type\")}za.createCipher=za.Cipher=function(e,t){var n,r;if(e=e.toLowerCase(),tl[e])n=tl[e].key,r=tl[e].iv;else{if(!nl[e])throw new TypeError(\"invalid suite type\");n=8*nl[e].key,r=nl[e].iv}var i=rl(t,!1,n,r);return il(e,i.key,i.iv)},za.createCipheriv=za.Cipheriv=il,za.createDecipher=za.Decipher=function(e,t){var n,r;if(e=e.toLowerCase(),tl[e])n=tl[e].key,r=tl[e].iv;else{if(!nl[e])throw new TypeError(\"invalid suite type\");n=8*nl[e].key,r=nl[e].iv}var i=rl(t,!1,n,r);return ol(e,i.key,i.iv)},za.createDecipheriv=za.Decipheriv=ol,za.listCiphers=za.getCiphers=function(){return Object.keys(nl).concat(el.getCiphers())};var al={},sl={exports:{}};!function(e){!function(e,t){function n(e,t){if(!e)throw new Error(t||\"Assertion failed\")}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&(\"le\"!==t&&\"be\"!==t||(n=t,t=10),this._init(e||0,t||10,n||\"be\"))}var o;\"object\"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:ce.Buffer}catch(e){}function a(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function s(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function u(e,t,n,r){for(var i=0,o=Math.min(e.length,n),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&\"object\"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(\"number\"==typeof e)return this._initNumber(e,t,r);if(\"object\"==typeof e)return this._initArray(e,t,r);\"hex\"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;\"-\"===(e=e.toString().replace(/\\s+/g,\"\"))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if(\"le\"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)i=s(e,t,r)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,a=o%r,s=Math.min(o,o-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?\"\"};var l=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;n.words[0]=s;for(var l=1;l>>26,d=67108863&u,f=Math.min(l,t.length-1),h=Math.max(0,l-e.length+1);h<=f;h++){var p=l-h|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[h])+d)/67108864|0,d=67108863&a}n.words[l]=0|d,u=0|c}return 0!==u?n.words[l]=0|u:n.length--,n.strip()}i.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||\"hex\"===e){r=\"\";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?l[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=c[e],h=d[e];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(h).toString(e);r=(p=p.idivn(h)).isZero()?m+r:l[f-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}n(!1,\"Base should be between 2 and 36\")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return n(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,\"byte array longer than desired length\"),n(o>0,\"Requested array length <= 0\"),this.strip();var a,s,u=\"le\"===t,l=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),l[s]=a;for(;s=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(\"number\"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(\"number\"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,m=h>>>13,g=0|a[2],v=8191&g,b=g>>>13,y=0|a[3],w=8191&y,_=y>>>13,S=0|a[4],E=8191&S,k=S>>>13,M=0|a[5],C=8191&M,x=M>>>13,A=0|a[6],R=8191&A,T=A>>>13,P=0|a[7],L=8191&P,I=P>>>13,O=0|a[8],N=8191&O,D=O>>>13,j=0|a[9],B=8191&j,z=j>>>13,U=0|s[0],F=8191&U,K=U>>>13,q=0|s[1],H=8191&q,W=q>>>13,$=0|s[2],V=8191&$,Y=$>>>13,G=0|s[3],Z=8191&G,Q=G>>>13,J=0|s[4],X=8191&J,ee=J>>>13,te=0|s[5],ne=8191&te,re=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,le=se>>>13,ce=0|s[8],de=8191&ce,fe=ce>>>13,he=0|s[9],pe=8191&he,me=he>>>13;n.negative=e.negative^t.negative,n.length=19;var ge=(l+(r=Math.imul(d,F))|0)+((8191&(i=(i=Math.imul(d,K))+Math.imul(f,F)|0))<<13)|0;l=((o=Math.imul(f,K))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(p,F),i=(i=Math.imul(p,K))+Math.imul(m,F)|0,o=Math.imul(m,K);var ve=(l+(r=r+Math.imul(d,H)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(f,H)|0))<<13)|0;l=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(v,F),i=(i=Math.imul(v,K))+Math.imul(b,F)|0,o=Math.imul(b,K),r=r+Math.imul(p,H)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,W)|0;var be=(l+(r=r+Math.imul(d,V)|0)|0)+((8191&(i=(i=i+Math.imul(d,Y)|0)+Math.imul(f,V)|0))<<13)|0;l=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,F),i=(i=Math.imul(w,K))+Math.imul(_,F)|0,o=Math.imul(_,K),r=r+Math.imul(v,H)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0,r=r+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,Y)|0;var ye=(l+(r=r+Math.imul(d,Z)|0)|0)+((8191&(i=(i=i+Math.imul(d,Q)|0)+Math.imul(f,Z)|0))<<13)|0;l=((o=o+Math.imul(f,Q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(E,F),i=(i=Math.imul(E,K))+Math.imul(k,F)|0,o=Math.imul(k,K),r=r+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,r=r+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,Y)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var we=(l+(r=r+Math.imul(d,X)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(f,X)|0))<<13)|0;l=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(C,F),i=(i=Math.imul(C,K))+Math.imul(x,F)|0,o=Math.imul(x,K),r=r+Math.imul(E,H)|0,i=(i=i+Math.imul(E,W)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,W)|0,r=r+Math.imul(w,V)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Y)|0,r=r+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,Q)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Q)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,ee)|0;var _e=(l+(r=r+Math.imul(d,ne)|0)|0)+((8191&(i=(i=i+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;l=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(R,F),i=(i=Math.imul(R,K))+Math.imul(T,F)|0,o=Math.imul(T,K),r=r+Math.imul(C,H)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,W)|0,r=r+Math.imul(E,V)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,Y)|0,r=r+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,Q)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,Q)|0,r=r+Math.imul(v,X)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(m,ne)|0,o=o+Math.imul(m,re)|0;var Se=(l+(r=r+Math.imul(d,oe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ae)|0)+Math.imul(f,oe)|0))<<13)|0;l=((o=o+Math.imul(f,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(L,F),i=(i=Math.imul(L,K))+Math.imul(I,F)|0,o=Math.imul(I,K),r=r+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,W)|0,r=r+Math.imul(C,V)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Y)|0,r=r+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,Q)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,ee)|0,r=r+Math.imul(v,ne)|0,i=(i=i+Math.imul(v,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Ee=(l+(r=r+Math.imul(d,ue)|0)|0)+((8191&(i=(i=i+Math.imul(d,le)|0)+Math.imul(f,ue)|0))<<13)|0;l=((o=o+Math.imul(f,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(N,F),i=(i=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),r=r+Math.imul(L,H)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,W)|0,r=r+Math.imul(R,V)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,Y)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,Q)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Q)|0,r=r+Math.imul(E,X)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(_,ne)|0,o=o+Math.imul(_,re)|0,r=r+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,le)|0;var ke=(l+(r=r+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;l=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,F),i=(i=Math.imul(B,K))+Math.imul(z,F)|0,o=Math.imul(z,K),r=r+Math.imul(N,H)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(D,H)|0,o=o+Math.imul(D,W)|0,r=r+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,Y)|0,r=r+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,Q)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Q)|0,r=r+Math.imul(C,X)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(E,ne)|0,i=(i=i+Math.imul(E,re)|0)+Math.imul(k,ne)|0,o=o+Math.imul(k,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,r=r+Math.imul(v,ue)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,le)|0,r=r+Math.imul(p,de)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,de)|0,o=o+Math.imul(m,fe)|0;var Me=(l+(r=r+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,me)|0)+Math.imul(f,pe)|0))<<13)|0;l=((o=o+Math.imul(f,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,H),i=(i=Math.imul(B,W))+Math.imul(z,H)|0,o=Math.imul(z,W),r=r+Math.imul(N,V)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(D,V)|0,o=o+Math.imul(D,Y)|0,r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,Q)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,Q)|0,r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(x,ne)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,le)|0,r=r+Math.imul(v,de)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(b,de)|0,o=o+Math.imul(b,fe)|0;var Ce=(l+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;l=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,V),i=(i=Math.imul(B,Y))+Math.imul(z,V)|0,o=Math.imul(z,Y),r=r+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,Q)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,Q)|0,r=r+Math.imul(L,X)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,ee)|0,r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,r=r+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,le)|0,r=r+Math.imul(w,de)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,de)|0,o=o+Math.imul(_,fe)|0;var xe=(l+(r=r+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,me)|0)+Math.imul(b,pe)|0))<<13)|0;l=((o=o+Math.imul(b,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,Z),i=(i=Math.imul(B,Q))+Math.imul(z,Z)|0,o=Math.imul(z,Q),r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(D,X)|0,o=o+Math.imul(D,ee)|0,r=r+Math.imul(L,ne)|0,i=(i=i+Math.imul(L,re)|0)+Math.imul(I,ne)|0,o=o+Math.imul(I,re)|0,r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,r=r+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,le)|0,r=r+Math.imul(E,de)|0,i=(i=i+Math.imul(E,fe)|0)+Math.imul(k,de)|0,o=o+Math.imul(k,fe)|0;var Ae=(l+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;l=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,X),i=(i=Math.imul(B,ee))+Math.imul(z,X)|0,o=Math.imul(z,ee),r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(D,ne)|0,o=o+Math.imul(D,re)|0,r=r+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,le)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,le)|0,r=r+Math.imul(C,de)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(x,de)|0,o=o+Math.imul(x,fe)|0;var Re=(l+(r=r+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,me)|0)+Math.imul(k,pe)|0))<<13)|0;l=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,r=Math.imul(B,ne),i=(i=Math.imul(B,re))+Math.imul(z,ne)|0,o=Math.imul(z,re),r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,r=r+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,le)|0,r=r+Math.imul(R,de)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(T,de)|0,o=o+Math.imul(T,fe)|0;var Te=(l+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;l=((o=o+Math.imul(x,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(z,oe)|0,o=Math.imul(z,ae),r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,le)|0,r=r+Math.imul(L,de)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(I,de)|0,o=o+Math.imul(I,fe)|0;var Pe=(l+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(T,pe)|0))<<13)|0;l=((o=o+Math.imul(T,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ue),i=(i=Math.imul(B,le))+Math.imul(z,ue)|0,o=Math.imul(z,le),r=r+Math.imul(N,de)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(D,de)|0,o=o+Math.imul(D,fe)|0;var Le=(l+(r=r+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,me)|0)+Math.imul(I,pe)|0))<<13)|0;l=((o=o+Math.imul(I,me)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,r=Math.imul(B,de),i=(i=Math.imul(B,fe))+Math.imul(z,de)|0,o=Math.imul(z,fe);var Ie=(l+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,me)|0)+Math.imul(D,pe)|0))<<13)|0;l=((o=o+Math.imul(D,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Oe=(l+(r=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,me))+Math.imul(z,pe)|0))<<13)|0;return l=((o=Math.imul(z,me))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,u[0]=ge,u[1]=ve,u[2]=be,u[3]=ye,u[4]=we,u[5]=_e,u[6]=Se,u[7]=Ee,u[8]=ke,u[9]=Me,u[10]=Ce,u[11]=xe,u[12]=Ae,u[13]=Re,u[14]=Te,u[15]=Pe,u[16]=Le,u[17]=Ie,u[18]=Oe,0!==l&&(u[19]=l,n.length++),n};function p(e,t,n){return(new m).mulp(e,t,n)}function m(e,t){this.x=e,this.y=t}Math.imul||(h=f),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?f(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}n.words[o]=s,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n.strip()}(this,e,t):p(this,e,t),n},m.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r>=1;return r},m.prototype.permute=function(e,t,n,r,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>i}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=i);l--){var d=0|this.words[l];this.words[l]=c<<26-o|d>>>o,c=d&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(\"number\"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(\"number\"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,u=r.length-o.length;if(\"mod\"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),\"div\"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),\"mod\"!==t&&(o=s.div.neg()),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),\"mod\"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?\"div\"===t?{div:this.divn(e.words[0]),mod:null}:\"mod\"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,\"div\",!1).div},i.prototype.mod=function(e){return this.divmod(e,\"mod\",!1).mod},i.prototype.umod=function(e){return this.divmod(e,\"mod\",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},i.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var c=r.clone(),d=t.clone();!t.isZero();){for(var f=0,h=1;0==(t.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(d)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(s),a.isub(u)):(r.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,c=1;0==(t.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(t.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(\"number\"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,\"Number is too big\");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){ri&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return n(!this.red,\"Already a number in reduction context\"),n(0===this.negative,\"red works only with positives\"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,\"Already a number in reduction context\"),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,\"redAdd works only with red numbers\"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,\"redSub works only with red numbers\"),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,\"redISub works only with red numbers\"),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,\"redShl works only with red numbers\"),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function y(){v.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function w(){v.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function _(){v.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(e){if(\"string\"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),\"modulus must be greater than 1\"),this.m=e,this.prime=null}function E(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},r(b,v),b.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i>>22,o=a}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},b.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if(\"k256\"===e)t=new b;else if(\"p224\"===e)t=new y;else if(\"p192\"===e)t=new w;else{if(\"p25519\"!==e)throw new Error(\"Unknown prime \"+e);t=new _}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,\"red works only with positives\"),n(e.red,\"red works only with red numbers\")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),\"red works only with positives\"),n(e.red&&e.red===t.red,\"red works only with red numbers\")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);n(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,l).cmp(u);)c.redIAdd(u);for(var d=this.pow(c,o),f=this.pow(e,o.addn(1).iushrn(1)),h=this.pow(e,o),p=a;0!==h.cmp(s);){for(var m=h,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;r--){for(var l=t.words[r],c=u-1;c>=0;c--){var d=l>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}u=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new E(e)},r(E,S),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)}(sl);var ul,ll,cl,dl,fl,hl=sl.exports,pl={exports:{}};function ml(){if(ul)return pl.exports;var e;function t(e){this.rand=e}if(ul=1,pl.exports=function(n){return e||(e=new t(null)),e.generate(n)},pl.exports.Rand=t,t.prototype.generate=function(e){return this._rand(e)},t.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n=0);return i},n.prototype._randrange=function(e,t){var n=t.sub(e);return e.add(this._randbelow(n))},n.prototype.test=function(t,n,r){var i=t.bitLength(),o=e.mont(t),a=new e(1).toRed(o);n||(n=Math.max(1,i/48|0));for(var s=t.subn(1),u=0;!s.testn(u);u++);for(var l=t.shrn(u),c=s.toRed(o);n>0;n--){var d=this._randrange(new e(2),s);r&&r(d);var f=d.toRed(o).redPow(l);if(0!==f.cmp(a)&&0!==f.cmp(c)){for(var h=1;h0;n--){var c=this._randrange(new e(2),a),d=t.gcd(c);if(0!==d.cmpn(1))return d;var f=c.toRed(i).redPow(u);if(0!==f.cmp(o)&&0!==f.cmp(l)){for(var h=1;hd;)m.ishrn(1);if(m.isEven()&&m.iadd(i),m.testn(1)||m.iadd(o),f.cmp(o)){if(!f.cmp(a))for(;m.mod(s).cmp(u);)m.iadd(c)}else for(;m.mod(n).cmp(l);)m.iadd(c);if(h(g=m.shrn(1))&&h(m)&&p(g)&&p(m)&&r.test(g)&&r.test(m))return m}}return dl}var bl,yl,wl,_l={modp1:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff\"},modp2:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff\"},modp5:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff\"},modp14:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff\"},modp15:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff\"},modp16:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff\"},modp17:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff\"},modp18:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff\"}};function Sl(){if(yl)return bl;yl=1;var e=hl,t=new(gl()),n=new e(24),r=new e(11),i=new e(10),o=new e(3),a=new e(7),s=vl(),u=We;function l(t,n){return n=n||\"utf8\",ie(t)||(t=new _(t,n)),this._pub=new e(t),this}function c(t,n){return n=n||\"utf8\",ie(t)||(t=new _(t,n)),this._priv=new e(t),this}bl=f;var d={};function f(t,n,r){this.setGenerator(n),this.__prime=new e(t),this._prime=e.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=l,this.setPrivateKey=c):this._primeCode=8}function h(e,t){var n=new _(e.toArray());return t?n.toString(t):n}return Object.defineProperty(f.prototype,\"verifyError\",{enumerable:!0,get:function(){return\"number\"!=typeof this._primeCode&&(this._primeCode=function(e,u){var l=u.toString(\"hex\"),c=[l,e.toString(16)].join(\"_\");if(c in d)return d[c];var f,h=0;if(e.isEven()||!s.simpleSieve||!s.fermatTest(e)||!t.test(e))return h+=1,h+=\"02\"===l||\"05\"===l?8:4,d[c]=h,h;switch(t.test(e.shrn(1))||(h+=2),l){case\"02\":e.mod(n).cmp(r)&&(h+=8);break;case\"05\":(f=e.mod(i)).cmp(o)&&f.cmp(a)&&(h+=8);break;default:h+=4}return d[c]=h,h}(this.__prime,this.__gen)),this._primeCode}}),f.prototype.generateKeys=function(){return this._priv||(this._priv=new e(u(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},f.prototype.computeSecret=function(t){var n=new _((t=(t=new e(t)).toRed(this._prime)).redPow(this._priv).fromRed().toArray()),r=this.getPrime();if(n.length=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,\"Invalid character in \"+e)}function s(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function u(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&a0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(\"number\"==typeof e)return this._initNumber(e,t,r);if(\"object\"==typeof e)return this._initArray(e,t,r);\"hex\"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;\"-\"===(e=e.toString().replace(/\\s+/g,\"\"))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if(\"le\"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)i=s(e,t,r)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,a=o%r,s=Math.min(o,o-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},\"undefined\"!=typeof Symbol&&\"function\"==typeof Symbol.for)try{i.prototype[Symbol.for(\"nodejs.util.inspect.custom\")]=c}catch(e){i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?\"\"}var d=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||\"hex\"===e){r=\"\";for(var i=0,o=0,a=0;a>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],c=h[e];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(c).toString(e);r=(p=p.idivn(c)).isZero()?m+r:d[l-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}n(!1,\"Base should be between 2 and 36\")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;n.words[0]=s;for(var l=1;l>>26,d=67108863&u,f=Math.min(l,t.length-1),h=Math.max(0,l-e.length+1);h<=f;h++){var p=l-h|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[h])+d)/67108864|0,d=67108863&a}n.words[l]=0|d,u=0|c}return 0!==u?n.words[l]=0|u:n.length--,n._strip()}i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,\"byte array longer than desired length\"),n(o>0,\"Requested array length <= 0\");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this[\"_toArrayLike\"+(\"le\"===t?\"LE\":\"BE\")](a,i),a},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,o=0;i>8&255),n>16&255),6===o?(n>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n=0&&(e[n--]=a>>8&255),n>=0&&(e[n--]=a>>16&255),6===o?(n>=0&&(e[n--]=a>>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(\"number\"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(\"number\"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,m=h>>>13,g=0|a[2],v=8191&g,b=g>>>13,y=0|a[3],w=8191&y,_=y>>>13,S=0|a[4],E=8191&S,k=S>>>13,M=0|a[5],C=8191&M,x=M>>>13,A=0|a[6],R=8191&A,T=A>>>13,P=0|a[7],L=8191&P,I=P>>>13,O=0|a[8],N=8191&O,D=O>>>13,j=0|a[9],B=8191&j,z=j>>>13,U=0|s[0],F=8191&U,K=U>>>13,q=0|s[1],H=8191&q,W=q>>>13,$=0|s[2],V=8191&$,Y=$>>>13,G=0|s[3],Z=8191&G,Q=G>>>13,J=0|s[4],X=8191&J,ee=J>>>13,te=0|s[5],ne=8191&te,re=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,le=se>>>13,ce=0|s[8],de=8191&ce,fe=ce>>>13,he=0|s[9],pe=8191&he,me=he>>>13;n.negative=e.negative^t.negative,n.length=19;var ge=(l+(r=Math.imul(d,F))|0)+((8191&(i=(i=Math.imul(d,K))+Math.imul(f,F)|0))<<13)|0;l=((o=Math.imul(f,K))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(p,F),i=(i=Math.imul(p,K))+Math.imul(m,F)|0,o=Math.imul(m,K);var ve=(l+(r=r+Math.imul(d,H)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(f,H)|0))<<13)|0;l=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(v,F),i=(i=Math.imul(v,K))+Math.imul(b,F)|0,o=Math.imul(b,K),r=r+Math.imul(p,H)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,W)|0;var be=(l+(r=r+Math.imul(d,V)|0)|0)+((8191&(i=(i=i+Math.imul(d,Y)|0)+Math.imul(f,V)|0))<<13)|0;l=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,F),i=(i=Math.imul(w,K))+Math.imul(_,F)|0,o=Math.imul(_,K),r=r+Math.imul(v,H)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0,r=r+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,Y)|0;var ye=(l+(r=r+Math.imul(d,Z)|0)|0)+((8191&(i=(i=i+Math.imul(d,Q)|0)+Math.imul(f,Z)|0))<<13)|0;l=((o=o+Math.imul(f,Q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(E,F),i=(i=Math.imul(E,K))+Math.imul(k,F)|0,o=Math.imul(k,K),r=r+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,r=r+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,Y)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var we=(l+(r=r+Math.imul(d,X)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(f,X)|0))<<13)|0;l=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(C,F),i=(i=Math.imul(C,K))+Math.imul(x,F)|0,o=Math.imul(x,K),r=r+Math.imul(E,H)|0,i=(i=i+Math.imul(E,W)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,W)|0,r=r+Math.imul(w,V)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Y)|0,r=r+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,Q)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Q)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,ee)|0;var _e=(l+(r=r+Math.imul(d,ne)|0)|0)+((8191&(i=(i=i+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;l=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(R,F),i=(i=Math.imul(R,K))+Math.imul(T,F)|0,o=Math.imul(T,K),r=r+Math.imul(C,H)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,W)|0,r=r+Math.imul(E,V)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,Y)|0,r=r+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,Q)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,Q)|0,r=r+Math.imul(v,X)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(m,ne)|0,o=o+Math.imul(m,re)|0;var Se=(l+(r=r+Math.imul(d,oe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ae)|0)+Math.imul(f,oe)|0))<<13)|0;l=((o=o+Math.imul(f,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(L,F),i=(i=Math.imul(L,K))+Math.imul(I,F)|0,o=Math.imul(I,K),r=r+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,W)|0,r=r+Math.imul(C,V)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Y)|0,r=r+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,Q)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,ee)|0,r=r+Math.imul(v,ne)|0,i=(i=i+Math.imul(v,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Ee=(l+(r=r+Math.imul(d,ue)|0)|0)+((8191&(i=(i=i+Math.imul(d,le)|0)+Math.imul(f,ue)|0))<<13)|0;l=((o=o+Math.imul(f,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(N,F),i=(i=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),r=r+Math.imul(L,H)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,W)|0,r=r+Math.imul(R,V)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,Y)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,Q)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Q)|0,r=r+Math.imul(E,X)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(_,ne)|0,o=o+Math.imul(_,re)|0,r=r+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,le)|0;var ke=(l+(r=r+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;l=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,F),i=(i=Math.imul(B,K))+Math.imul(z,F)|0,o=Math.imul(z,K),r=r+Math.imul(N,H)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(D,H)|0,o=o+Math.imul(D,W)|0,r=r+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,Y)|0,r=r+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,Q)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Q)|0,r=r+Math.imul(C,X)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(E,ne)|0,i=(i=i+Math.imul(E,re)|0)+Math.imul(k,ne)|0,o=o+Math.imul(k,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,r=r+Math.imul(v,ue)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,le)|0,r=r+Math.imul(p,de)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,de)|0,o=o+Math.imul(m,fe)|0;var Me=(l+(r=r+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,me)|0)+Math.imul(f,pe)|0))<<13)|0;l=((o=o+Math.imul(f,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,H),i=(i=Math.imul(B,W))+Math.imul(z,H)|0,o=Math.imul(z,W),r=r+Math.imul(N,V)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(D,V)|0,o=o+Math.imul(D,Y)|0,r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,Q)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,Q)|0,r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(x,ne)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,le)|0,r=r+Math.imul(v,de)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(b,de)|0,o=o+Math.imul(b,fe)|0;var Ce=(l+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;l=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,V),i=(i=Math.imul(B,Y))+Math.imul(z,V)|0,o=Math.imul(z,Y),r=r+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,Q)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,Q)|0,r=r+Math.imul(L,X)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,ee)|0,r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,r=r+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,le)|0,r=r+Math.imul(w,de)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,de)|0,o=o+Math.imul(_,fe)|0;var xe=(l+(r=r+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,me)|0)+Math.imul(b,pe)|0))<<13)|0;l=((o=o+Math.imul(b,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,Z),i=(i=Math.imul(B,Q))+Math.imul(z,Z)|0,o=Math.imul(z,Q),r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(D,X)|0,o=o+Math.imul(D,ee)|0,r=r+Math.imul(L,ne)|0,i=(i=i+Math.imul(L,re)|0)+Math.imul(I,ne)|0,o=o+Math.imul(I,re)|0,r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,r=r+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,le)|0,r=r+Math.imul(E,de)|0,i=(i=i+Math.imul(E,fe)|0)+Math.imul(k,de)|0,o=o+Math.imul(k,fe)|0;var Ae=(l+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;l=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,X),i=(i=Math.imul(B,ee))+Math.imul(z,X)|0,o=Math.imul(z,ee),r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(D,ne)|0,o=o+Math.imul(D,re)|0,r=r+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,le)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,le)|0,r=r+Math.imul(C,de)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(x,de)|0,o=o+Math.imul(x,fe)|0;var Re=(l+(r=r+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,me)|0)+Math.imul(k,pe)|0))<<13)|0;l=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,r=Math.imul(B,ne),i=(i=Math.imul(B,re))+Math.imul(z,ne)|0,o=Math.imul(z,re),r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,r=r+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,le)|0,r=r+Math.imul(R,de)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(T,de)|0,o=o+Math.imul(T,fe)|0;var Te=(l+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;l=((o=o+Math.imul(x,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(z,oe)|0,o=Math.imul(z,ae),r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,le)|0,r=r+Math.imul(L,de)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(I,de)|0,o=o+Math.imul(I,fe)|0;var Pe=(l+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(T,pe)|0))<<13)|0;l=((o=o+Math.imul(T,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ue),i=(i=Math.imul(B,le))+Math.imul(z,ue)|0,o=Math.imul(z,le),r=r+Math.imul(N,de)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(D,de)|0,o=o+Math.imul(D,fe)|0;var Le=(l+(r=r+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,me)|0)+Math.imul(I,pe)|0))<<13)|0;l=((o=o+Math.imul(I,me)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,r=Math.imul(B,de),i=(i=Math.imul(B,fe))+Math.imul(z,de)|0,o=Math.imul(z,fe);var Ie=(l+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,me)|0)+Math.imul(D,pe)|0))<<13)|0;l=((o=o+Math.imul(D,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Oe=(l+(r=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,me))+Math.imul(z,pe)|0))<<13)|0;return l=((o=Math.imul(z,me))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,u[0]=ge,u[1]=ve,u[2]=be,u[3]=ye,u[4]=we,u[5]=_e,u[6]=Se,u[7]=Ee,u[8]=ke,u[9]=Me,u[10]=Ce,u[11]=xe,u[12]=Ae,u[13]=Re,u[14]=Te,u[15]=Pe,u[16]=Le,u[17]=Ie,u[18]=Oe,0!==l&&(u[19]=l,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}n.words[o]=s,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function v(e,t,n){return g(e,t,n)}Math.imul||(m=p),i.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):n<63?p(this,e,t):n<1024?g(this,e,t):v(this,e,t)},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),v(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(\"number\"==typeof e),n(e<67108864);for(var r=0,i=0;i>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>i&1}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=i);l--){var d=0|this.words[l];this.words[l]=c<<26-o|d>>>o,c=d&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(\"number\"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(\"number\"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,u=r.length-o.length;if(\"mod\"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s._strip(),r._strip(),\"div\"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),\"mod\"!==t&&(o=s.div.neg()),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),\"mod\"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?\"div\"===t?{div:this.divn(e.words[0]),mod:null}:\"mod\"===t?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,\"div\",!1).div},i.prototype.mod=function(e){return this.divmod(e,\"mod\",!1).mod},i.prototype.umod=function(e){return this.divmod(e,\"mod\",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var c=r.clone(),d=t.clone();!t.isZero();){for(var f=0,h=1;0==(t.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(d)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(s),a.isub(u)):(r.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,c=1;0==(t.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(t.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(\"number\"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,\"Number is too big\");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){ri&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new k(e)},i.prototype.toRed=function(e){return n(!this.red,\"Already a number in reduction context\"),n(0===this.negative,\"red works only with positives\"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,\"Already a number in reduction context\"),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,\"redAdd works only with red numbers\"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,\"redSub works only with red numbers\"),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,\"redISub works only with red numbers\"),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,\"redShl works only with red numbers\"),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){y.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function _(){y.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function S(){y.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function E(){y.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function k(e){if(\"string\"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),\"modulus must be greater than 1\"),this.m=e,this.prime=null}function M(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},r(w,y),w.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i>>22,o=a}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(b[e])return b[e];var t;if(\"k256\"===e)t=new w;else if(\"p224\"===e)t=new _;else if(\"p192\"===e)t=new S;else{if(\"p25519\"!==e)throw new Error(\"Unknown prime \"+e);t=new E}return b[e]=t,t},k.prototype._verify1=function(e){n(0===e.negative,\"red works only with positives\"),n(e.red,\"red works only with red numbers\")},k.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),\"red works only with positives\"),n(e.red&&e.red===t.red,\"red works only with red numbers\")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},k.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);n(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,l).cmp(u);)c.redIAdd(u);for(var d=this.pow(c,o),f=this.pow(e,o.addn(1).iushrn(1)),h=this.pow(e,o),p=a;0!==h.cmp(s);){for(var m=h,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;r--){for(var l=t.words[r],c=u-1;c>=0;c--){var d=l>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}u=26}return o},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new M(e)},r(M,k),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)}(kl);var Ml=kl.exports,Cl=We;function xl(e){var t,n=e.modulus.byteLength();do{t=new Ml(Cl(n))}while(t.cmp(e.modulus)>=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function Al(e,t){var n=function(e){var t=xl(e);return{blinder:t.toRed(Ml.mont(e.modulus)).redPow(new Ml(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),r=t.modulus.byteLength(),i=new Ml(e).mul(n.blinder).umod(t.modulus),o=i.toRed(Ml.mont(t.prime1)),a=i.toRed(Ml.mont(t.prime2)),s=t.coefficient,u=t.prime1,l=t.prime2,c=o.redPow(t.exponent1).fromRed(),d=a.redPow(t.exponent2).fromRed(),f=c.isub(d).imul(s).umod(u).imul(l);return d.iadd(f).imul(n.unblinder).umod(t.modulus).toArrayLike(_,\"be\",r)}Al.getr=xl;var Rl=Al,Tl={},Pl={name:\"elliptic\",version:\"6.5.4\",description:\"EC cryptography\",main:\"lib/elliptic.js\",files:[\"lib\"],scripts:{lint:\"eslint lib test\",\"lint:fix\":\"npm run lint -- --fix\",unit:\"istanbul test _mocha --reporter=spec test/index.js\",test:\"npm run lint && npm run unit\",version:\"grunt dist && git add dist/\"},repository:{type:\"git\",url:\"git@github.com:indutny/elliptic\"},keywords:[\"EC\",\"Elliptic\",\"curve\",\"Cryptography\"],author:\"Fedor Indutny \",license:\"MIT\",bugs:{url:\"https://github.com/indutny/elliptic/issues\"},homepage:\"https://github.com/indutny/elliptic\",devDependencies:{brfs:\"^2.0.2\",coveralls:\"^3.1.0\",eslint:\"^7.6.0\",grunt:\"^1.2.1\",\"grunt-browserify\":\"^5.3.0\",\"grunt-cli\":\"^1.3.2\",\"grunt-contrib-connect\":\"^3.0.0\",\"grunt-contrib-copy\":\"^1.0.0\",\"grunt-contrib-uglify\":\"^5.0.0\",\"grunt-mocha-istanbul\":\"^5.0.2\",\"grunt-saucelabs\":\"^9.0.1\",istanbul:\"^0.4.5\",mocha:\"^8.0.1\"},dependencies:{\"bn.js\":\"^4.11.9\",brorand:\"^1.1.0\",\"hash.js\":\"^1.0.0\",\"hmac-drbg\":\"^1.0.1\",inherits:\"^2.0.4\",\"minimalistic-assert\":\"^1.0.1\",\"minimalistic-crypto-utils\":\"^1.0.1\"}},Ll={},Il={};!function(e){var t=e;function n(e){return 1===e.length?\"0\"+e:e}function r(e){for(var t=\"\",r=0;r>8,a=255&i;o?n.push(o,a):n.push(a)}return n},t.zero2=n,t.toHex=r,t.encode=function(e,t){return\"hex\"===t?r(e):e}}(Il),function(e){var t=e,n=hl,r=Wa,i=Il;t.assert=r,t.toArray=i.toArray,t.zero2=i.zero2,t.toHex=i.toHex,t.encode=i.encode,t.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,r[a]=s,o.iushrn(1)}return r},t.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var a,s,u=e.andln(3)+i&3,l=t.andln(3)+o&3;3===u&&(u=-1),3===l&&(l=-1),a=0==(1&u)?0:3!==(r=e.andln(7)+i&7)&&5!==r||2!==l?u:-u,n[0].push(a),s=0==(1&l)?0:3!==(r=t.andln(7)+o&7)&&5!==r||2!==u?l:-l,n[1].push(s),2*i===a+1&&(i=1-i),2*o===s+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return n},t.cachedProperty=function(e,t,n){var r=\"_\"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},t.parseBytes=function(e){return\"string\"==typeof e?t.toArray(e,\"hex\"):e},t.intFromLE=function(e){return new n(e,\"hex\",\"le\")}}(Ll);var Ol={},Nl=hl,Dl=Ll,jl=Dl.getNAF,Bl=Dl.getJSF,zl=Dl.assert;function Ul(e,t){this.type=e,this.p=new Nl(t.p,16),this.red=t.prime?Nl.red(t.prime):Nl.mont(this.p),this.zero=new Nl(0).toRed(this.red),this.one=new Nl(1).toRed(this.red),this.two=new Nl(2).toRed(this.red),this.n=t.n&&new Nl(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Fl=Ul;function Kl(e,t){this.curve=e,this.type=t,this.precomputed=null}Ul.prototype.point=function(){throw new Error(\"Not implemented\")},Ul.prototype.validate=function(){throw new Error(\"Not implemented\")},Ul.prototype._fixedNafMul=function(e,t){zl(e.precomputed);var n=e._getDoubles(),r=jl(t,1,this._bitLength),i=(1<=o;u--)a=(a<<1)+r[u];s.push(a)}for(var l=this.jpoint(null,null,null),c=this.jpoint(null,null,null),d=i;d>0;d--){for(o=0;o=0;s--){for(var u=0;s>=0&&0===o[s];s--)u++;if(s>=0&&u++,a=a.dblp(u),s<0)break;var l=o[s];zl(0!==l),a=\"affine\"===e.type?l>0?a.mixedAdd(i[l-1>>1]):a.mixedAdd(i[-l-1>>1].neg()):l>0?a.add(i[l-1>>1]):a.add(i[-l-1>>1].neg())}return\"affine\"===e.type?a.toP():a},Ul.prototype._wnafMulAdd=function(e,t,n,r,i){var o,a,s,u=this._wnafT1,l=this._wnafT2,c=this._wnafT3,d=0;for(o=0;o=1;o-=2){var h=o-1,p=o;if(1===u[h]&&1===u[p]){var m=[t[h],null,null,t[p]];0===t[h].y.cmp(t[p].y)?(m[1]=t[h].add(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg())):0===t[h].y.cmp(t[p].y.redNeg())?(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].add(t[p].neg())):(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=Bl(n[h],n[p]);for(d=Math.max(v[0].length,d),c[h]=new Array(d),c[p]=new Array(d),a=0;a=0;o--){for(var S=0;o>=0;){var E=!0;for(a=0;a=0&&S++,w=w.dblp(S),o<0)break;for(a=0;a0?s=l[a][k-1>>1]:k<0&&(s=l[a][-k-1>>1].neg()),w=\"affine\"===s.type?w.mixedAdd(s):w.add(s))}}for(o=0;o=Math.ceil((e.bitLength()+1)/t.step)},Kl.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i=0&&(o=t,a=n),r.negative&&(r=r.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:r,b:i},{a:o,b:a}]},Vl.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],i=r.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=i.mul(n.a),s=o.mul(r.a),u=i.mul(n.b),l=o.mul(r.b);return{k1:e.sub(a).sub(s),k2:u.add(l).neg()}},Vl.prototype.pointFromX=function(e,t){(e=new ql(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error(\"invalid point\");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},Vl.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(i).cmpn(0)},Vl.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,o=0;o\":\"\"},Gl.prototype.isInfinity=function(){return this.inf},Gl.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},Gl.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),r=e.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Gl.prototype.getX=function(){return this.x.fromRed()},Gl.prototype.getY=function(){return this.y.fromRed()},Gl.prototype.mul=function(e){return e=new ql(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Gl.prototype.mulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i):this.curve._wnafMulAdd(1,r,i,2)},Gl.prototype.jmulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i,!0):this.curve._wnafMulAdd(1,r,i,2,!0)},Gl.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Gl.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},Gl.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Hl(Zl,Wl.BasePoint),Vl.prototype.jpoint=function(e,t,n){return new Zl(this,e,t,n)},Zl.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},Zl.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Zl.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),i=e.x.redMul(n),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=s.redSqr(),c=l.redMul(s),d=r.redMul(l),f=u.redSqr().redIAdd(c).redISub(d).redISub(d),h=u.redMul(d.redISub(f)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,h,p)},Zl.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),c=n.redMul(u),d=s.redSqr().redIAdd(l).redISub(c).redISub(c),f=s.redMul(c.redISub(d)).redISub(i.redMul(l)),h=this.z.redMul(a);return this.curve.jpoint(d,f,h)},Zl.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},Zl.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},Zl.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ql=hl,Jl=Ve,Xl=Fl,ec=Ll;function tc(e){Xl.call(this,\"mont\",e),this.a=new Ql(e.a,16).toRed(this.red),this.b=new Ql(e.b,16).toRed(this.red),this.i4=new Ql(4).toRed(this.red).redInvm(),this.two=new Ql(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Jl(tc,Xl);var nc=tc;function rc(e,t,n){Xl.BasePoint.call(this,e,\"projective\"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Ql(t,16),this.z=new Ql(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}tc.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},Jl(rc,Xl.BasePoint),tc.prototype.decodePoint=function(e,t){return this.point(ec.toArray(e,t),1)},tc.prototype.point=function(e,t){return new rc(this,e,t)},tc.prototype.pointFromJSON=function(e){return rc.fromJSON(this,e)},rc.prototype.precompute=function(){},rc.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},rc.fromJSON=function(e,t){return new rc(e,t[0],t[1]||e.one)},rc.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},rc.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},rc.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),i=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,i)},rc.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},rc.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(n),a=i.redMul(r),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},rc.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},rc.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},rc.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},rc.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},rc.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},rc.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var ic=hl,oc=Ve,ac=Fl,sc=Ll.assert;function uc(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,ac.call(this,\"edwards\",e),this.a=new ic(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ic(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ic(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),sc(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}oc(uc,ac);var lc=uc;function cc(e,t,n,r,i){ac.BasePoint.call(this,e,\"projective\"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new ic(t,16),this.y=new ic(n,16),this.z=r?new ic(r,16):this.curve.one,this.t=i&&new ic(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}uc.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},uc.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},uc.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},uc.prototype.pointFromX=function(e,t){(e=new ic(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),o=r.redMul(i.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");var s=a.fromRed().isOdd();return(t&&!s||!t&&s)&&(a=a.redNeg()),this.point(e,a)},uc.prototype.pointFromY=function(e,t){(e=new ic(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),o=r.redMul(i.redInvm());if(0===o.cmp(this.zero)){if(t)throw new Error(\"invalid point\");return this.point(this.zero,e)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},uc.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(i)},oc(cc,ac.BasePoint),uc.prototype.pointFromJSON=function(e){return cc.fromJSON(this,e)},uc.prototype.point=function(e,t,n,r){return new cc(this,e,t,n,r)},cc.fromJSON=function(e,t){return new cc(e,t[0],t[1],t[2])},cc.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},cc.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},cc.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=r.redAdd(t),a=o.redSub(n),s=r.redSub(t),u=i.redMul(a),l=o.redMul(s),c=i.redMul(s),d=a.redMul(o);return this.curve.point(u,l,d,c)},cc.prototype._projDbl=function(){var e,t,n,r,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var l=(r=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(l.redSub(this.curve.two)),t=l.redMul(r.redSub(u)),n=l.redSqr().redSub(l).redSub(l)):(i=this.z.redSqr(),o=l.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=l.redMul(r.redSub(u)),n=l.redMul(o))}else r=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=r.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(r)).redMul(o),t=this.curve._mulC(r).redMul(s.redISub(u)),n=r.redMul(o);return this.curve.point(e,t,n)},cc.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},cc.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=n.redSub(t),a=i.redSub(r),s=i.redAdd(r),u=n.redAdd(t),l=o.redMul(a),c=s.redMul(u),d=o.redMul(u),f=a.redMul(s);return this.curve.point(l,c,f,d)},cc.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),i=r.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),l=i.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),d=r.redMul(u).redMul(c);return this.curve.twisted?(t=r.redMul(l).redMul(a.redSub(this.curve._mulA(o))),n=u.redMul(l)):(t=r.redMul(l).redMul(a.redSub(o)),n=this.curve._mulC(u).redMul(l)),this.curve.point(d,t,n)},cc.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},cc.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},cc.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},cc.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},cc.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},cc.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},cc.prototype.getX=function(){return this.normalize(),this.x.fromRed()},cc.prototype.getY=function(){return this.normalize(),this.y.fromRed()},cc.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},cc.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},cc.prototype.toP=cc.prototype.normalize,cc.prototype.mixedAdd=cc.prototype.add,function(e){var t=e;t.base=Fl,t.short=Yl,t.mont=nc,t.edwards=lc}(Ol);var dc={},fc={},hc={},pc=Wa,mc=Ve;function gc(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function vc(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function bc(e){return 1===e.length?\"0\"+e:e}function yc(e){return 7===e.length?\"0\"+e:6===e.length?\"00\"+e:5===e.length?\"000\"+e:4===e.length?\"0000\"+e:3===e.length?\"00000\"+e:2===e.length?\"000000\"+e:1===e.length?\"0000000\"+e:e}hc.inherits=mc,hc.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if(\"string\"==typeof e)if(t){if(\"hex\"===t)for((e=e.replace(/[^a-z0-9]+/gi,\"\")).length%2!=0&&(e=\"0\"+e),i=0;i>6|192,n[r++]=63&o|128):gc(e,i)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++i)),n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128):(n[r++]=o>>12|224,n[r++]=o>>6&63|128,n[r++]=63&o|128)}else for(i=0;i>>0}return o},hc.split32=function(e,t){for(var n=new Array(4*e.length),r=0,i=0;r>>24,n[i+1]=o>>>16&255,n[i+2]=o>>>8&255,n[i+3]=255&o):(n[i+3]=o>>>24,n[i+2]=o>>>16&255,n[i+1]=o>>>8&255,n[i]=255&o)}return n},hc.rotr32=function(e,t){return e>>>t|e<<32-t},hc.rotl32=function(e,t){return e<>>32-t},hc.sum32=function(e,t){return e+t>>>0},hc.sum32_3=function(e,t,n){return e+t+n>>>0},hc.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},hc.sum32_5=function(e,t,n,r,i){return e+t+n+r+i>>>0},hc.sum64=function(e,t,n,r){var i=e[t],o=r+e[t+1]>>>0,a=(o>>0,e[t+1]=o},hc.sum64_hi=function(e,t,n,r){return(t+r>>>0>>0},hc.sum64_lo=function(e,t,n,r){return t+r>>>0},hc.sum64_4_hi=function(e,t,n,r,i,o,a,s){var u=0,l=t;return u+=(l=l+r>>>0)>>0)>>0)>>0},hc.sum64_4_lo=function(e,t,n,r,i,o,a,s){return t+r+o+s>>>0},hc.sum64_5_hi=function(e,t,n,r,i,o,a,s,u,l){var c=0,d=t;return c+=(d=d+r>>>0)>>0)>>0)>>0)>>0},hc.sum64_5_lo=function(e,t,n,r,i,o,a,s,u,l){return t+r+o+s+l>>>0},hc.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},hc.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},hc.shr64_hi=function(e,t,n){return e>>>n},hc.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0};var wc={},_c=hc,Sc=Wa;function Ec(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}wc.BlockHash=Ec,Ec.prototype.update=function(e,t){if(e=_c.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=_c.join32(e,0,e.length-n,this.endian);for(var r=0;r>>24&255,r[i++]=e>>>16&255,r[i++]=e>>>8&255,r[i++]=255&e}else for(r[i++]=255&e,r[i++]=e>>>8&255,r[i++]=e>>>16&255,r[i++]=e>>>24&255,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,o=8;o>>3},Mc.g1_256=function(e){return Cc(e,17)^Cc(e,19)^e>>>10};var Tc=hc,Pc=wc,Lc=Mc,Ic=Tc.rotl32,Oc=Tc.sum32,Nc=Tc.sum32_5,Dc=Lc.ft_1,jc=Pc.BlockHash,Bc=[1518500249,1859775393,2400959708,3395469782];function zc(){if(!(this instanceof zc))return new zc;jc.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Tc.inherits(zc,jc);var Uc=zc;zc.blockSize=512,zc.outSize=160,zc.hmacStrength=80,zc.padLength=64,zc.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;rthis.blockSize&&(e=(new this.Hash).update(e).digest()),af(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(t,n,r)}var mf=pf;pf.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(e.concat(n||[])),this._reseed=1},pf.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");\"string\"!=typeof t&&(r=n,n=t,t=null),n&&(n=ff.toArray(n,r||\"hex\"),this._update(n));for(var i=[];i.length\"};var wf=hl,_f=Ll,Sf=_f.assert;function Ef(e,t){if(e instanceof Ef)return e;this._importDER(e,t)||(Sf(e.r&&e.s,\"Signature without r or s\"),this.r=new wf(e.r,16),this.s=new wf(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var kf,Mf,Cf=Ef;function xf(){this.place=0}function Af(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function Rf(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}Ef.prototype._importDER=function(e,t){e=_f.toArray(e,t);var n=new xf;if(48!==e[n.place++])return!1;var r=Af(e,n);if(!1===r)return!1;if(r+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var i=Af(e,n);if(!1===i)return!1;var o=e.slice(n.place,i+n.place);if(n.place+=i,2!==e[n.place++])return!1;var a=Af(e,n);if(!1===a)return!1;if(e.length!==a+n.place)return!1;var s=e.slice(n.place,a+n.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new wf(o),this.s=new wf(s),this.recoveryParam=null,!0},Ef.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=Rf(t),n=Rf(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];Tf(r,t.length),(r=r.concat(t)).push(2),Tf(r,n.length);var i=r.concat(n),o=[48];return Tf(o,i.length),o=o.concat(i),_f.encode(o,e)};var Pf=Ll,Lf=Pf.assert,If=Pf.parseBytes,Of=Pf.cachedProperty;function Nf(e,t){this.eddsa=e,this._secret=If(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=If(t.pub)}Nf.fromPublic=function(e,t){return t instanceof Nf?t:new Nf(e,{pub:t})},Nf.fromSecret=function(e,t){return t instanceof Nf?t:new Nf(e,{secret:t})},Nf.prototype.secret=function(){return this._secret},Of(Nf,\"pubBytes\",(function(){return this.eddsa.encodePoint(this.pub())})),Of(Nf,\"pub\",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),Of(Nf,\"privBytes\",(function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r})),Of(Nf,\"priv\",(function(){return this.eddsa.decodeInt(this.privBytes())})),Of(Nf,\"hash\",(function(){return this.eddsa.hash().update(this.secret()).digest()})),Of(Nf,\"messagePrefix\",(function(){return this.hash().slice(this.eddsa.encodingLength)})),Nf.prototype.sign=function(e){return Lf(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(e,this)},Nf.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},Nf.prototype.getSecret=function(e){return Lf(this._secret,\"KeyPair is public only\"),Pf.encode(this.secret(),e)},Nf.prototype.getPublic=function(e){return Pf.encode(this.pubBytes(),e)};var Df=Nf,jf=hl,Bf=Ll,zf=Bf.assert,Uf=Bf.cachedProperty,Ff=Bf.parseBytes;function Kf(e,t){this.eddsa=e,\"object\"!=typeof t&&(t=Ff(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),zf(t.R&&t.S,\"Signature without R or S\"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof jf&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}Uf(Kf,\"S\",(function(){return this.eddsa.decodeInt(this.Sencoded())})),Uf(Kf,\"R\",(function(){return this.eddsa.decodePoint(this.Rencoded())})),Uf(Kf,\"Rencoded\",(function(){return this.eddsa.encodePoint(this.R())})),Uf(Kf,\"Sencoded\",(function(){return this.eddsa.encodeInt(this.S())})),Kf.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Kf.prototype.toHex=function(){return Bf.encode(this.toBytes(),\"hex\").toUpperCase()};var qf=Kf,Hf=fc,Wf=dc,$f=Ll,Vf=$f.assert,Yf=$f.parseBytes,Gf=Df,Zf=qf;function Qf(e){if(Vf(\"ed25519\"===e,\"only tested with ed25519 so far\"),!(this instanceof Qf))return new Qf(e);e=Wf[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=Hf.sha512}var Jf,Xf=Qf;function eh(){return Jf||(Jf=1,function(e){var t=e;t.version=Pl.version,t.utils=Ll,t.rand=ml(),t.curve=Ol,t.curves=dc,t.ec=function(){if(Mf)return kf;Mf=1;var e=hl,t=mf,n=Ll,r=dc,i=ml(),o=n.assert,a=yf,s=Cf;function u(e){if(!(this instanceof u))return new u(e);\"string\"==typeof e&&(o(Object.prototype.hasOwnProperty.call(r,e),\"Unknown curve \"+e),e=r[e]),e instanceof r.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}return kf=u,u.prototype.keyPair=function(e){return new a(this,e)},u.prototype.keyFromPrivate=function(e,t){return a.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return a.fromPublic(this,e,t)},u.prototype.genKeyPair=function(n){n||(n={});for(var r=new t({hash:this.hash,pers:n.pers,persEnc:n.persEnc||\"utf8\",entropy:n.entropy||i(this.hash.hmacStrength),entropyEnc:n.entropy&&n.entropyEnc||\"utf8\",nonce:this.n.toArray()}),o=this.n.byteLength(),a=this.n.sub(new e(2));;){var s=new e(r.generate(o));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},u.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.prototype.sign=function(n,r,i,o){\"object\"==typeof i&&(o=i,i=null),o||(o={}),r=this.keyFromPrivate(r,i),n=this._truncateToN(new e(n,16));for(var a=this.n.byteLength(),u=r.getPrivate().toArray(\"be\",a),l=n.toArray(\"be\",a),c=new t({hash:this.hash,entropy:u,nonce:l,pers:o.pers,persEnc:o.persEnc||\"utf8\"}),d=this.n.sub(new e(1)),f=0;;f++){var h=o.k?o.k(f):new e(c.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(d)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var m=p.getX(),g=m.umod(this.n);if(0!==g.cmpn(0)){var v=h.invm(this.n).mul(g.mul(r.getPrivate()).iadd(n));if(0!==(v=v.umod(this.n)).cmpn(0)){var b=(p.getY().isOdd()?1:0)|(0!==m.cmp(g)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),b^=1),new s({r:g,s:v,recoveryParam:b})}}}}}},u.prototype.verify=function(t,n,r,i){t=this._truncateToN(new e(t,16)),r=this.keyFromPublic(r,i);var o=(n=new s(n,\"hex\")).r,a=n.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u,l=a.invm(this.n),c=l.mul(t).umod(this.n),d=l.mul(o).umod(this.n);return this.curve._maxwellTrick?!(u=this.g.jmulAdd(c,r.getPublic(),d)).isInfinity()&&u.eqXToP(o):!(u=this.g.mulAdd(c,r.getPublic(),d)).isInfinity()&&0===u.getX().umod(this.n).cmp(o)},u.prototype.recoverPubKey=function(t,n,r,i){o((3&r)===r,\"The recovery param is more than two bits\"),n=new s(n,i);var a=this.n,u=new e(t),l=n.r,c=n.s,d=1&r,f=r>>1;if(l.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error(\"Unable to find sencond key candinate\");l=f?this.curve.pointFromX(l.add(this.curve.n),d):this.curve.pointFromX(l,d);var h=n.r.invm(a),p=a.sub(u).mul(h).umod(a),m=c.mul(h).umod(a);return this.g.mulAdd(p,l,m)},u.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new s(t,r)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(n))return i}throw new Error(\"Unable to find valid recovery factor\")},kf}(),t.eddsa=Xf}(Tl)),Tl}Qf.prototype.sign=function(e,t){e=Yf(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),i=this.g.mul(r),o=this.encodePoint(i),a=this.hashInt(o,n.pubBytes(),e).mul(n.priv()),s=r.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:o})},Qf.prototype.verify=function(e,t,n){e=Yf(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),i=this.hashInt(t.Rencoded(),r.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(r.pub().mul(i)).eq(o)},Qf.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,\"Invalid character in \"+e)}function s(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function u(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&a0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(\"number\"==typeof e)return this._initNumber(e,t,r);if(\"object\"==typeof e)return this._initArray(e,t,r);\"hex\"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;\"-\"===(e=e.toString().replace(/\\s+/g,\"\"))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if(\"le\"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)i=s(e,t,r)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,a=o%r,s=Math.min(o,o-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},\"undefined\"!=typeof Symbol&&\"function\"==typeof Symbol.for)try{i.prototype[Symbol.for(\"nodejs.util.inspect.custom\")]=c}catch(e){i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?\"\"}var d=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||\"hex\"===e){r=\"\";for(var i=0,o=0,a=0;a>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=f[e],c=h[e];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(c).toString(e);r=(p=p.idivn(c)).isZero()?m+r:d[l-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}n(!1,\"Base should be between 2 and 36\")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;n.words[0]=s;for(var l=1;l>>26,d=67108863&u,f=Math.min(l,t.length-1),h=Math.max(0,l-e.length+1);h<=f;h++){var p=l-h|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[h])+d)/67108864|0,d=67108863&a}n.words[l]=0|d,u=0|c}return 0!==u?n.words[l]=0|u:n.length--,n._strip()}i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,\"byte array longer than desired length\"),n(o>0,\"Requested array length <= 0\");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this[\"_toArrayLike\"+(\"le\"===t?\"LE\":\"BE\")](a,i),a},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,o=0;i>8&255),n>16&255),6===o?(n>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n=0&&(e[n--]=a>>8&255),n>=0&&(e[n--]=a>>16&255),6===o?(n>=0&&(e[n--]=a>>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(\"number\"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(\"number\"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,m=h>>>13,g=0|a[2],v=8191&g,b=g>>>13,y=0|a[3],w=8191&y,_=y>>>13,S=0|a[4],E=8191&S,k=S>>>13,M=0|a[5],C=8191&M,x=M>>>13,A=0|a[6],R=8191&A,T=A>>>13,P=0|a[7],L=8191&P,I=P>>>13,O=0|a[8],N=8191&O,D=O>>>13,j=0|a[9],B=8191&j,z=j>>>13,U=0|s[0],F=8191&U,K=U>>>13,q=0|s[1],H=8191&q,W=q>>>13,$=0|s[2],V=8191&$,Y=$>>>13,G=0|s[3],Z=8191&G,Q=G>>>13,J=0|s[4],X=8191&J,ee=J>>>13,te=0|s[5],ne=8191&te,re=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,le=se>>>13,ce=0|s[8],de=8191&ce,fe=ce>>>13,he=0|s[9],pe=8191&he,me=he>>>13;n.negative=e.negative^t.negative,n.length=19;var ge=(l+(r=Math.imul(d,F))|0)+((8191&(i=(i=Math.imul(d,K))+Math.imul(f,F)|0))<<13)|0;l=((o=Math.imul(f,K))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(p,F),i=(i=Math.imul(p,K))+Math.imul(m,F)|0,o=Math.imul(m,K);var ve=(l+(r=r+Math.imul(d,H)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(f,H)|0))<<13)|0;l=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(v,F),i=(i=Math.imul(v,K))+Math.imul(b,F)|0,o=Math.imul(b,K),r=r+Math.imul(p,H)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,W)|0;var be=(l+(r=r+Math.imul(d,V)|0)|0)+((8191&(i=(i=i+Math.imul(d,Y)|0)+Math.imul(f,V)|0))<<13)|0;l=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,F),i=(i=Math.imul(w,K))+Math.imul(_,F)|0,o=Math.imul(_,K),r=r+Math.imul(v,H)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0,r=r+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,Y)|0;var ye=(l+(r=r+Math.imul(d,Z)|0)|0)+((8191&(i=(i=i+Math.imul(d,Q)|0)+Math.imul(f,Z)|0))<<13)|0;l=((o=o+Math.imul(f,Q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(E,F),i=(i=Math.imul(E,K))+Math.imul(k,F)|0,o=Math.imul(k,K),r=r+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,r=r+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,Y)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var we=(l+(r=r+Math.imul(d,X)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(f,X)|0))<<13)|0;l=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(C,F),i=(i=Math.imul(C,K))+Math.imul(x,F)|0,o=Math.imul(x,K),r=r+Math.imul(E,H)|0,i=(i=i+Math.imul(E,W)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,W)|0,r=r+Math.imul(w,V)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Y)|0,r=r+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,Q)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Q)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,ee)|0;var _e=(l+(r=r+Math.imul(d,ne)|0)|0)+((8191&(i=(i=i+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;l=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(R,F),i=(i=Math.imul(R,K))+Math.imul(T,F)|0,o=Math.imul(T,K),r=r+Math.imul(C,H)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,W)|0,r=r+Math.imul(E,V)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,Y)|0,r=r+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,Q)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,Q)|0,r=r+Math.imul(v,X)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(m,ne)|0,o=o+Math.imul(m,re)|0;var Se=(l+(r=r+Math.imul(d,oe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ae)|0)+Math.imul(f,oe)|0))<<13)|0;l=((o=o+Math.imul(f,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(L,F),i=(i=Math.imul(L,K))+Math.imul(I,F)|0,o=Math.imul(I,K),r=r+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,W)|0,r=r+Math.imul(C,V)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Y)|0,r=r+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,Q)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,ee)|0,r=r+Math.imul(v,ne)|0,i=(i=i+Math.imul(v,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Ee=(l+(r=r+Math.imul(d,ue)|0)|0)+((8191&(i=(i=i+Math.imul(d,le)|0)+Math.imul(f,ue)|0))<<13)|0;l=((o=o+Math.imul(f,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(N,F),i=(i=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),r=r+Math.imul(L,H)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,W)|0,r=r+Math.imul(R,V)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,Y)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,Q)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Q)|0,r=r+Math.imul(E,X)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(_,ne)|0,o=o+Math.imul(_,re)|0,r=r+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,le)|0;var ke=(l+(r=r+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;l=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,F),i=(i=Math.imul(B,K))+Math.imul(z,F)|0,o=Math.imul(z,K),r=r+Math.imul(N,H)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(D,H)|0,o=o+Math.imul(D,W)|0,r=r+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,Y)|0,r=r+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,Q)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Q)|0,r=r+Math.imul(C,X)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(E,ne)|0,i=(i=i+Math.imul(E,re)|0)+Math.imul(k,ne)|0,o=o+Math.imul(k,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,r=r+Math.imul(v,ue)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,le)|0,r=r+Math.imul(p,de)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,de)|0,o=o+Math.imul(m,fe)|0;var Me=(l+(r=r+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,me)|0)+Math.imul(f,pe)|0))<<13)|0;l=((o=o+Math.imul(f,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,H),i=(i=Math.imul(B,W))+Math.imul(z,H)|0,o=Math.imul(z,W),r=r+Math.imul(N,V)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(D,V)|0,o=o+Math.imul(D,Y)|0,r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,Q)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,Q)|0,r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(x,ne)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,le)|0,r=r+Math.imul(v,de)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(b,de)|0,o=o+Math.imul(b,fe)|0;var Ce=(l+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;l=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,V),i=(i=Math.imul(B,Y))+Math.imul(z,V)|0,o=Math.imul(z,Y),r=r+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,Q)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,Q)|0,r=r+Math.imul(L,X)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,ee)|0,r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,r=r+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,le)|0,r=r+Math.imul(w,de)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,de)|0,o=o+Math.imul(_,fe)|0;var xe=(l+(r=r+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,me)|0)+Math.imul(b,pe)|0))<<13)|0;l=((o=o+Math.imul(b,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,Z),i=(i=Math.imul(B,Q))+Math.imul(z,Z)|0,o=Math.imul(z,Q),r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(D,X)|0,o=o+Math.imul(D,ee)|0,r=r+Math.imul(L,ne)|0,i=(i=i+Math.imul(L,re)|0)+Math.imul(I,ne)|0,o=o+Math.imul(I,re)|0,r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,r=r+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,le)|0,r=r+Math.imul(E,de)|0,i=(i=i+Math.imul(E,fe)|0)+Math.imul(k,de)|0,o=o+Math.imul(k,fe)|0;var Ae=(l+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;l=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,X),i=(i=Math.imul(B,ee))+Math.imul(z,X)|0,o=Math.imul(z,ee),r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(D,ne)|0,o=o+Math.imul(D,re)|0,r=r+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,le)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,le)|0,r=r+Math.imul(C,de)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(x,de)|0,o=o+Math.imul(x,fe)|0;var Re=(l+(r=r+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,me)|0)+Math.imul(k,pe)|0))<<13)|0;l=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,r=Math.imul(B,ne),i=(i=Math.imul(B,re))+Math.imul(z,ne)|0,o=Math.imul(z,re),r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,r=r+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,le)|0,r=r+Math.imul(R,de)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(T,de)|0,o=o+Math.imul(T,fe)|0;var Te=(l+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;l=((o=o+Math.imul(x,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(z,oe)|0,o=Math.imul(z,ae),r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,le)|0,r=r+Math.imul(L,de)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(I,de)|0,o=o+Math.imul(I,fe)|0;var Pe=(l+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(T,pe)|0))<<13)|0;l=((o=o+Math.imul(T,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ue),i=(i=Math.imul(B,le))+Math.imul(z,ue)|0,o=Math.imul(z,le),r=r+Math.imul(N,de)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(D,de)|0,o=o+Math.imul(D,fe)|0;var Le=(l+(r=r+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,me)|0)+Math.imul(I,pe)|0))<<13)|0;l=((o=o+Math.imul(I,me)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,r=Math.imul(B,de),i=(i=Math.imul(B,fe))+Math.imul(z,de)|0,o=Math.imul(z,fe);var Ie=(l+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,me)|0)+Math.imul(D,pe)|0))<<13)|0;l=((o=o+Math.imul(D,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Oe=(l+(r=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,me))+Math.imul(z,pe)|0))<<13)|0;return l=((o=Math.imul(z,me))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,u[0]=ge,u[1]=ve,u[2]=be,u[3]=ye,u[4]=we,u[5]=_e,u[6]=Se,u[7]=Ee,u[8]=ke,u[9]=Me,u[10]=Ce,u[11]=xe,u[12]=Ae,u[13]=Re,u[14]=Te,u[15]=Pe,u[16]=Le,u[17]=Ie,u[18]=Oe,0!==l&&(u[19]=l,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}n.words[o]=s,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function v(e,t,n){return g(e,t,n)}Math.imul||(m=p),i.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):n<63?p(this,e,t):n<1024?g(this,e,t):v(this,e,t)},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),v(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(\"number\"==typeof e),n(e<67108864);for(var r=0,i=0;i>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>i&1}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=i);l--){var d=0|this.words[l];this.words[l]=c<<26-o|d>>>o,c=d&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(\"number\"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(\"number\"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,u=r.length-o.length;if(\"mod\"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s._strip(),r._strip(),\"div\"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),\"mod\"!==t&&(o=s.div.neg()),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),\"mod\"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?\"div\"===t?{div:this.divn(e.words[0]),mod:null}:\"mod\"===t?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,\"div\",!1).div},i.prototype.mod=function(e){return this.divmod(e,\"mod\",!1).mod},i.prototype.umod=function(e){return this.divmod(e,\"mod\",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var c=r.clone(),d=t.clone();!t.isZero();){for(var f=0,h=1;0==(t.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(d)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(s),a.isub(u)):(r.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,c=1;0==(t.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(t.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(\"number\"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,\"Number is too big\");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){ri&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new k(e)},i.prototype.toRed=function(e){return n(!this.red,\"Already a number in reduction context\"),n(0===this.negative,\"red works only with positives\"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,\"Already a number in reduction context\"),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,\"redAdd works only with red numbers\"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,\"redSub works only with red numbers\"),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,\"redISub works only with red numbers\"),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,\"redShl works only with red numbers\"),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){y.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function _(){y.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function S(){y.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function E(){y.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function k(e){if(\"string\"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),\"modulus must be greater than 1\"),this.m=e,this.prime=null}function M(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},r(w,y),w.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i>>22,o=a}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(b[e])return b[e];var t;if(\"k256\"===e)t=new w;else if(\"p224\"===e)t=new _;else if(\"p192\"===e)t=new S;else{if(\"p25519\"!==e)throw new Error(\"Unknown prime \"+e);t=new E}return b[e]=t,t},k.prototype._verify1=function(e){n(0===e.negative,\"red works only with positives\"),n(e.red,\"red works only with red numbers\")},k.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),\"red works only with positives\"),n(e.red&&e.red===t.red,\"red works only with red numbers\")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},k.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);n(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,l).cmp(u);)c.redIAdd(u);for(var d=this.pow(c,o),f=this.pow(e,o.addn(1).iushrn(1)),h=this.pow(e,o),p=a;0!==h.cmp(s);){for(var m=h,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;r--){for(var l=t.words[r],c=u-1;c>=0;c--){var d=l>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}u=26}return o},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new M(e)},r(M,k),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)}(th);var nh,rh=th.exports,ih={},oh={},ah={},sh={},uh=ce,lh=uh.Buffer,ch={};for(nh in uh)uh.hasOwnProperty(nh)&&\"SlowBuffer\"!==nh&&\"Buffer\"!==nh&&(ch[nh]=uh[nh]);var dh=ch.Buffer={};for(nh in lh)lh.hasOwnProperty(nh)&&\"allocUnsafe\"!==nh&&\"allocUnsafeSlow\"!==nh&&(dh[nh]=lh[nh]);if(ch.Buffer.prototype=lh.prototype,dh.from&&dh.from!==Uint8Array.from||(dh.from=function(e,t,n){if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);return lh(e,t,n)}),dh.alloc||(dh.alloc=function(e,t,n){if(\"number\"!=typeof e)throw new TypeError('The \"size\" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');var r=lh(e);return t&&0!==t.length?\"string\"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r}),!ch.kStringMaxLength)try{ch.kStringMaxLength=je.binding(\"buffer\").kStringMaxLength}catch(a){}ch.constants||(ch.constants={MAX_LENGTH:ch.kMaxLength},ch.kStringMaxLength&&(ch.constants.MAX_STRING_LENGTH=ch.kStringMaxLength));var fh=ch,hh={};const ph=Ve;function mh(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function gh(e,t){this.path=e,this.rethrow(t)}hh.Reporter=mh,mh.prototype.isError=function(e){return e instanceof gh},mh.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},mh.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},mh.prototype.enterKey=function(e){return this._reporterState.path.push(e)},mh.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},mh.prototype.leaveKey=function(e,t,n){const r=this._reporterState;this.exitKey(e),null!==r.obj&&(r.obj[t]=n)},mh.prototype.path=function(){return this._reporterState.path.join(\"/\")},mh.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},mh.prototype.leaveObject=function(e){const t=this._reporterState,n=t.obj;return t.obj=e,n},mh.prototype.error=function(e){let t;const n=this._reporterState,r=e instanceof gh;if(t=r?e:new gh(n.path.map((function(e){return\"[\"+JSON.stringify(e)+\"]\"})).join(\"\"),e.message||e,e.stack),!n.options.partial)throw t;return r||n.errors.push(t),t},mh.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},ph(gh,Error),gh.prototype.rethrow=function(e){if(this.message=e+\" at: \"+(this.path||\"(shallow)\"),Error.captureStackTrace&&Error.captureStackTrace(this,gh),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this};var vh={};const bh=Ve,yh=hh.Reporter,wh=fh.Buffer;function _h(e,t){yh.call(this,t),wh.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error(\"Input not Buffer\")}function Sh(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return Sh.isEncoderBuffer(e)||(e=new Sh(e,t)),this.length+=e.length,e}),this);else if(\"number\"==typeof e){if(!(0<=e&&e<=255))return t.error(\"non-byte EncoderBuffer value\");this.value=e,this.length=1}else if(\"string\"==typeof e)this.value=e,this.length=wh.byteLength(e);else{if(!wh.isBuffer(e))return t.error(\"Unsupported type: \"+typeof e);this.value=e,this.length=e.length}}bh(_h,yh),vh.DecoderBuffer=_h,_h.isDecoderBuffer=function(e){if(e instanceof _h)return!0;return\"object\"==typeof e&&wh.isBuffer(e.base)&&\"DecoderBuffer\"===e.constructor.name&&\"number\"==typeof e.offset&&\"number\"==typeof e.length&&\"function\"==typeof e.save&&\"function\"==typeof e.restore&&\"function\"==typeof e.isEmpty&&\"function\"==typeof e.readUInt8&&\"function\"==typeof e.skip&&\"function\"==typeof e.raw},_h.prototype.save=function(){return{offset:this.offset,reporter:yh.prototype.save.call(this)}},_h.prototype.restore=function(e){const t=new _h(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,yh.prototype.restore.call(this,e.reporter),t},_h.prototype.isEmpty=function(){return this.offset===this.length},_h.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||\"DecoderBuffer overrun\")},_h.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||\"DecoderBuffer overrun\");const n=new _h(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},_h.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},vh.EncoderBuffer=Sh,Sh.isEncoderBuffer=function(e){if(e instanceof Sh)return!0;return\"object\"==typeof e&&\"EncoderBuffer\"===e.constructor.name&&\"number\"==typeof e.length&&\"function\"==typeof e.join},Sh.prototype.join=function(e,t){return e||(e=wh.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):(\"number\"==typeof this.value?e[t]=this.value:\"string\"==typeof this.value?e.write(this.value,t):wh.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e};const Eh=hh.Reporter,kh=vh.EncoderBuffer,Mh=vh.DecoderBuffer,Ch=Wa,xh=[\"seq\",\"seqof\",\"set\",\"setof\",\"objid\",\"bool\",\"gentime\",\"utctime\",\"null_\",\"enum\",\"int\",\"objDesc\",\"bitstr\",\"bmpstr\",\"charstr\",\"genstr\",\"graphstr\",\"ia5str\",\"iso646str\",\"numstr\",\"octstr\",\"printstr\",\"t61str\",\"unistr\",\"utf8str\",\"videostr\"],Ah=[\"key\",\"obj\",\"use\",\"optional\",\"explicit\",\"implicit\",\"def\",\"choice\",\"any\",\"contains\"].concat(xh);function Rh(e,t,n){const r={};this._baseState=r,r.name=n,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var Th=Rh;const Ph=[\"enc\",\"parent\",\"children\",\"tag\",\"args\",\"reverseArgs\",\"choice\",\"optional\",\"any\",\"obj\",\"use\",\"alteredUse\",\"key\",\"default\",\"explicit\",\"implicit\",\"contains\"];Rh.prototype.clone=function(){const e=this._baseState,t={};Ph.forEach((function(n){t[n]=e[n]}));const n=new this.constructor(t.parent);return n._baseState=t,n},Rh.prototype._wrap=function(){const e=this._baseState;Ah.forEach((function(t){this[t]=function(){const n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},Rh.prototype._init=function(e){const t=this._baseState;Ch(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),Ch.equal(t.children.length,1,\"Root node can have only one child\")},Rh.prototype._useArgs=function(e){const t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(Ch(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(Ch(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if(\"object\"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);const r=e[n];t[r]=n})),t})))},[\"_peekTag\",\"_decodeTag\",\"_use\",\"_decodeStr\",\"_decodeObjid\",\"_decodeTime\",\"_decodeNull\",\"_decodeInt\",\"_decodeBool\",\"_decodeList\",\"_encodeComposite\",\"_encodeStr\",\"_encodeObjid\",\"_encodeTime\",\"_encodeNull\",\"_encodeInt\",\"_encodeBool\"].forEach((function(e){Rh.prototype[e]=function(){const t=this._baseState;throw new Error(e+\" not implemented for encoding: \"+t.enc)}})),xh.forEach((function(e){Rh.prototype[e]=function(){const t=this._baseState,n=Array.prototype.slice.call(arguments);return Ch(null===t.tag),t.tag=e,this._useArgs(n),this}})),Rh.prototype.use=function(e){Ch(e);const t=this._baseState;return Ch(null===t.use),t.use=e,this},Rh.prototype.optional=function(){return this._baseState.optional=!0,this},Rh.prototype.def=function(e){const t=this._baseState;return Ch(null===t.default),t.default=e,t.optional=!0,this},Rh.prototype.explicit=function(e){const t=this._baseState;return Ch(null===t.explicit&&null===t.implicit),t.explicit=e,this},Rh.prototype.implicit=function(e){const t=this._baseState;return Ch(null===t.explicit&&null===t.implicit),t.implicit=e,this},Rh.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},Rh.prototype.key=function(e){const t=this._baseState;return Ch(null===t.key),t.key=e,this},Rh.prototype.any=function(){return this._baseState.any=!0,this},Rh.prototype.choice=function(e){const t=this._baseState;return Ch(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},Rh.prototype.contains=function(e){const t=this._baseState;return Ch(null===t.use),t.contains=e,this},Rh.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let r,i=n.default,o=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(o=this._peekTag(e,r,n.any),e.isError(o))return o}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(r)}}if(n.obj&&o&&(r=e.enterObject()),o){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const r=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),r,e.length,\"tagged\"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,\"content\"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&(\"octstr\"===n.tag||\"bitstr\"===n.tag)){const r=new Mh(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(r,t)}}return n.obj&&o&&(i=e.leaveObject(r)),null===n.key||null===i&&!0!==o?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},Rh.prototype._decodeGeneric=function(e,t,n){const r=this._baseState;return\"seq\"===e||\"set\"===e?null:\"seqof\"===e||\"setof\"===e?this._decodeList(t,e,r.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):\"objid\"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],n):\"objid\"===e?this._decodeObjid(t,null,null,n):\"gentime\"===e||\"utctime\"===e?this._decodeTime(t,e,n):\"null_\"===e?this._decodeNull(t,n):\"bool\"===e?this._decodeBool(t,n):\"objDesc\"===e?this._decodeStr(t,e,n):\"int\"===e||\"enum\"===e?this._decodeInt(t,r.args&&r.args[0],n):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,n):t.error(\"unknown tag: \"+e)},Rh.prototype._getUse=function(e,t){const n=this._baseState;return n.useDecoder=this._use(e,t),Ch(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},Rh.prototype._decodeChoice=function(e,t){const n=this._baseState;let r=null,i=!1;return Object.keys(n.choice).some((function(o){const a=e.save(),s=n.choice[o];try{const n=s._decode(e,t);if(e.isError(n))return!1;r={type:o,value:n},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?r:e.error(\"Choice not matched\")},Rh.prototype._createEncoderBuffer=function(e){return new kh(e,this.reporter)},Rh.prototype._encode=function(e,t,n){const r=this._baseState;if(null!==r.default&&r.default===e)return;const i=this._encodeValue(e,t,n);return void 0===i||this._skipDefault(i,t,n)?void 0:i},Rh.prototype._encodeValue=function(e,t,n){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(e,t||new Eh);let i=null;if(this.reporter=t,r.optional&&void 0===e){if(null===r.default)return;e=r.default}let o=null,a=!1;if(r.any)i=this._createEncoderBuffer(e);else if(r.choice)i=this._encodeChoice(e,t);else if(r.contains)o=this._getUse(r.contains,n)._encode(e,t),a=!0;else if(r.children)o=r.children.map((function(n){if(\"null_\"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error(\"Child should have a key\");const r=t.enterKey(n._baseState.key);if(\"object\"!=typeof e)return t.error(\"Child expected, but input is not object\");const i=n._encode(e[n._baseState.key],t,e);return t.leaveKey(r),i}),this).filter((function(e){return e})),o=this._createEncoderBuffer(o);else if(\"seqof\"===r.tag||\"setof\"===r.tag){if(!r.args||1!==r.args.length)return t.error(\"Too many args for : \"+r.tag);if(!Array.isArray(e))return t.error(\"seqof/setof, but data is not Array\");const n=this.clone();n._baseState.implicit=null,o=this._createEncoderBuffer(e.map((function(n){const r=this._baseState;return this._getUse(r.args[0],e)._encode(n,t)}),n))}else null!==r.use?i=this._getUse(r.use,n)._encode(e,t):(o=this._encodePrimitive(r.tag,e),a=!0);if(!r.any&&null===r.choice){const e=null!==r.implicit?r.implicit:r.tag,n=null===r.implicit?\"universal\":\"context\";null===e?null===r.use&&t.error(\"Tag could be omitted only for .use()\"):null===r.use&&(i=this._encodeComposite(e,a,n,o))}return null!==r.explicit&&(i=this._encodeComposite(r.explicit,!1,\"context\",i)),i},Rh.prototype._encodeChoice=function(e,t){const n=this._baseState,r=n.choice[e.type];return r||Ch(!1,e.type+\" not found in \"+JSON.stringify(Object.keys(n.choice))),r._encode(e.value,t)},Rh.prototype._encodePrimitive=function(e,t){const n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if(\"objid\"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if(\"objid\"===e)return this._encodeObjid(t,null,null);if(\"gentime\"===e||\"utctime\"===e)return this._encodeTime(t,e);if(\"null_\"===e)return this._encodeNull();if(\"int\"===e||\"enum\"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if(\"bool\"===e)return this._encodeBool(t);if(\"objDesc\"===e)return this._encodeStr(t,e);throw new Error(\"Unsupported tag: \"+e)},Rh.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},Rh.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)};var Lh={};!function(e){function t(e){const t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);const r=e[n];t[r]=n})),t}e.tagClass={0:\"universal\",1:\"application\",2:\"context\",3:\"private\"},e.tagClassByName=t(e.tagClass),e.tag={0:\"end\",1:\"bool\",2:\"int\",3:\"bitstr\",4:\"octstr\",5:\"null_\",6:\"objid\",7:\"objDesc\",8:\"external\",9:\"real\",10:\"enum\",11:\"embed\",12:\"utf8str\",13:\"relativeOid\",16:\"seq\",17:\"set\",18:\"numstr\",19:\"printstr\",20:\"t61str\",21:\"videostr\",22:\"ia5str\",23:\"utctime\",24:\"gentime\",25:\"graphstr\",26:\"iso646str\",27:\"genstr\",28:\"unistr\",29:\"charstr\",30:\"bmpstr\"},e.tagByName=t(e.tag)}(Lh);const Ih=Ve,Oh=fh.Buffer,Nh=Th,Dh=Lh;function jh(e){this.enc=\"der\",this.name=e.name,this.entity=e,this.tree=new zh,this.tree._init(e.body)}var Bh=jh;function zh(e){Nh.call(this,\"der\",e)}function Uh(e){return e<10?\"0\"+e:e}jh.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},Ih(zh,Nh),zh.prototype._encodeComposite=function(e,t,n,r){const i=function(e,t,n,r){let i;\"seqof\"===e?e=\"seq\":\"setof\"===e&&(e=\"set\");if(Dh.tagByName.hasOwnProperty(e))i=Dh.tagByName[e];else{if(\"number\"!=typeof e||(0|e)!==e)return r.error(\"Unknown tag: \"+e);i=e}if(i>=31)return r.error(\"Multi-octet tag encoding unsupported\");t||(i|=32);return i|=Dh.tagClassByName[n||\"universal\"]<<6,i}(e,t,n,this.reporter);if(r.length<128){const e=Oh.alloc(2);return e[0]=i,e[1]=r.length,this._createEncoderBuffer([e,r])}let o=1;for(let e=r.length;e>=256;e>>=8)o++;const a=Oh.alloc(2+o);a[0]=i,a[1]=128|o;for(let e=1+o,t=r.length;t>0;e--,t>>=8)a[e]=255&t;return this._createEncoderBuffer([a,r])},zh.prototype._encodeStr=function(e,t){if(\"bitstr\"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if(\"bmpstr\"===t){const t=Oh.alloc(2*e.length);for(let n=0;n=40)return this.reporter.error(\"Second objid identifier OOB\");e.splice(0,2,40*e[0]+e[1])}let r=0;for(let t=0;t=128;n>>=7)r++}const i=Oh.alloc(r);let o=i.length-1;for(let t=e.length-1;t>=0;t--){let n=e[t];for(i[o--]=127&n;(n>>=7)>0;)i[o--]=128|127&n}return this._createEncoderBuffer(i)},zh.prototype._encodeTime=function(e,t){let n;const r=new Date(e);return\"gentime\"===t?n=[Uh(r.getUTCFullYear()),Uh(r.getUTCMonth()+1),Uh(r.getUTCDate()),Uh(r.getUTCHours()),Uh(r.getUTCMinutes()),Uh(r.getUTCSeconds()),\"Z\"].join(\"\"):\"utctime\"===t?n=[Uh(r.getUTCFullYear()%100),Uh(r.getUTCMonth()+1),Uh(r.getUTCDate()),Uh(r.getUTCHours()),Uh(r.getUTCMinutes()),Uh(r.getUTCSeconds()),\"Z\"].join(\"\"):this.reporter.error(\"Encoding \"+t+\" time is not supported yet\"),this._encodeStr(n,\"octstr\")},zh.prototype._encodeNull=function(){return this._createEncoderBuffer(\"\")},zh.prototype._encodeInt=function(e,t){if(\"string\"==typeof e){if(!t)return this.reporter.error(\"String int or enum given, but no values map\");if(!t.hasOwnProperty(e))return this.reporter.error(\"Values map doesn't contain: \"+JSON.stringify(e));e=t[e]}if(\"number\"!=typeof e&&!Oh.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=Oh.from(t)}if(Oh.isBuffer(e)){let t=e.length;0===e.length&&t++;const n=Oh.alloc(t);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const r=new Array(n);for(let t=r.length-1;t>=0;t--)r[t]=255&e,e>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(Oh.from(r))},zh.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},zh.prototype._use=function(e,t){return\"function\"==typeof e&&(e=e(t)),e._getEncoder(\"der\").tree},zh.prototype._skipDefault=function(e,t,n){const r=this._baseState;let i;if(null===r.default)return!1;const o=e.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,t,n).join()),o.length!==r.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&n);if(31==(31&n)){let r=n;for(n=0;128==(128&r);){if(r=e.readUInt8(t),e.isError(r))return r;n<<=7,n|=127&r}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:Gh.tag[n]}}function ep(e,t,n){let r=e.readUInt8(n);if(e.isError(r))return r;if(!t&&128===r)return null;if(0==(128&r))return r;const i=127&r;if(i>4)return e.error(\"length octect is too long\");r=0;for(let t=0;t0&&n.ishrn(r),n}function l(n,r,i){var o,a;do{for(o=e.alloc(0);8*o.length=t)throw new Error(\"invalid sig\")}return Wp=function(a,s,u,l,c){var d=r(u);if(\"ec\"===d.type){if(\"ecdsa\"!==l&&\"ecdsa/rsa\"!==l)throw new Error(\"wrong public key type\");return function(e,t,r){var o=i[r.data.algorithm.curve.join(\".\")];if(!o)throw new Error(\"unknown curve \"+r.data.algorithm.curve.join(\".\"));var a=new n(o),s=r.data.subjectPrivateKey.data;return a.verify(t,e,s)}(a,s,d)}if(\"dsa\"===d.type){if(\"dsa\"!==l)throw new Error(\"wrong public key type\");return function(e,n,i){var a=i.data.p,s=i.data.q,u=i.data.g,l=i.data.pub_key,c=r.signature.decode(e,\"der\"),d=c.s,f=c.r;o(d,s),o(f,s);var h=t.mont(a),p=d.invm(s),m=u.toRed(h).redPow(new t(n).mul(p).mod(s)).fromRed().mul(l.toRed(h).redPow(f.mul(p).mod(s)).fromRed()).mod(a).mod(s);return 0===m.cmp(f)}(a,s,d)}if(\"rsa\"!==l&&\"ecdsa/rsa\"!==l)throw new Error(\"wrong public key type\");s=e.concat([c,s]);for(var f=d.modulus.byteLength(),h=[1],p=0;s.length+h.length+2n-a-2)throw new Error(\"message too long\");var s=vm.alloc(n-r-a-2),u=n-o-1,l=cm(o),c=hm(vm.concat([i,s,vm.alloc(1,1),t],u),fm(l,u)),d=hm(l,fm(c,o));return new pm(vm.concat([vm.alloc(1),d,c],n))}(o,t);else if(1===r)i=function(e,t,n){var r,i=t.length,o=e.modulus.byteLength();if(i>o-11)throw new Error(\"message too long\");r=n?vm.alloc(o-i-3,255):function(e){var t,n=vm.allocUnsafe(e),r=0,i=cm(2*e),o=0;for(;r=0)throw new Error(\"data too long for modulus\")}return n?gm(i,o):mm(i,o)};var ym=Kp,wm=rm,_m=om,Sm=hl,Em=Rl,km=Ko,Mm=um,Cm=Ue().Buffer,xm=function(e,t,n){var r;r=e.padding?e.padding:n?1:4;var i,o=ym(e),a=o.modulus.byteLength();if(t.length>a||new Sm(t).cmp(o.modulus)>=0)throw new Error(\"decryption error\");i=n?Mm(new Sm(t),o):Em(t,o);var s=Cm.alloc(a-i.length);if(i=Cm.concat([s,i],a),4===r)return function(e,t){var n=e.modulus.byteLength(),r=km(\"sha1\").update(Cm.alloc(0)).digest(),i=r.length;if(0!==t[0])throw new Error(\"decryption error\");var o=t.slice(1,i+1),a=t.slice(i+1),s=_m(o,wm(a,i)),u=_m(a,wm(s,n-i-1));if(function(e,t){e=Cm.from(e),t=Cm.from(t);var n=0,r=e.length;e.length!==t.length&&(n++,r=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var a=t.slice(2,i-1);(\"0002\"!==r.toString(\"hex\")&&!n||\"0001\"!==r.toString(\"hex\")&&n)&&o++;a.length<8&&o++;if(o)throw new Error(\"decryption error\");return t.slice(i)}(0,i,n);if(3===r)return i;throw new Error(\"unknown padding\")};!function(e){e.publicEncrypt=bm,e.privateDecrypt=xm,e.privateEncrypt=function(t,n){return e.publicEncrypt(t,n,!0)},e.publicDecrypt=function(t,n){return e.privateDecrypt(t,n,!0)}}(em);var Am={};function Rm(){throw new Error(\"secure random number generation not supported by this browser\\nuse chrome, FireFox or Internet Explorer 11\")}var Tm,Pm=Ue(),Lm=Pm.Buffer,Im=Pm.kMaxLength,Om=n.crypto||n.msCrypto,Nm=Math.pow(2,32)-1;function Dm(e,t){if(\"number\"!=typeof e||e!=e)throw new TypeError(\"offset must be a number\");if(e>Nm||e<0)throw new TypeError(\"offset must be a uint32\");if(e>Im||e>t)throw new RangeError(\"offset out of range\")}function jm(e,t,n){if(\"number\"!=typeof e||e!=e)throw new TypeError(\"size must be a number\");if(e>Nm||e<0)throw new TypeError(\"size must be a uint32\");if(e+t>n||e>Im)throw new RangeError(\"buffer too small\")}function Bm(e,t,n,r){var i=e.buffer,o=new Uint8Array(i,t,n);return Om.getRandomValues(o),r?void Ee((function(){r(null,e)})):e}function zm(){if(Tm)return de;Tm=1,de.randomBytes=de.rng=de.pseudoRandomBytes=de.prng=We,de.createHash=de.Hash=Ko,de.createHmac=de.Hmac=sa;var e=la,t=Object.keys(e),n=[\"sha1\",\"sha224\",\"sha256\",\"sha384\",\"sha512\",\"md5\",\"rmd160\"].concat(t);de.getHashes=function(){return n};var r=ca;de.pbkdf2=r.pbkdf2,de.pbkdf2Sync=r.pbkdf2Sync;var i=za;de.Cipher=i.Cipher,de.createCipher=i.createCipher,de.Cipheriv=i.Cipheriv,de.createCipheriv=i.createCipheriv,de.Decipher=i.Decipher,de.createDecipher=i.createDecipher,de.Decipheriv=i.Decipheriv,de.createDecipheriv=i.createDecipheriv,de.getCiphers=i.getCiphers,de.listCiphers=i.listCiphers;var o=function(){if(wl)return al;wl=1;var e=vl(),t=_l,n=Sl(),r={binary:!0,hex:!0,base64:!0};return al.DiffieHellmanGroup=al.createDiffieHellmanGroup=al.getDiffieHellman=function(e){var r=new _(t[e].prime,\"hex\"),i=new _(t[e].gen,\"hex\");return new n(r,i)},al.createDiffieHellman=al.DiffieHellman=function t(i,o,a,s){return ie(o)||void 0===r[o]?t(i,\"binary\",o,a):(o=o||\"binary\",s=s||\"binary\",ie(a=a||new _([2]))||(a=new _(a,s)),\"number\"==typeof i?new n(e(i,a),a,!0):(ie(i)||(i=new _(i,o)),new n(i,a,!0)))},al}();de.DiffieHellmanGroup=o.DiffieHellmanGroup,de.createDiffieHellmanGroup=o.createDiffieHellmanGroup,de.getDiffieHellman=o.getDiffieHellman,de.createDiffieHellman=o.createDiffieHellman,de.DiffieHellman=o.DiffieHellman;var a=function(){if(Yp)return Vp;Yp=1;var e=Ue().Buffer,t=Ko,n=Hn,r=Ve,i=Jp(),o=Xp(),a=ua;function s(e){n.Writable.call(this);var r=a[e];if(!r)throw new Error(\"Unknown message digest\");this._hashType=r.hash,this._hash=t(r.hash),this._tag=r.id,this._signType=r.sign}function u(e){n.Writable.call(this);var r=a[e];if(!r)throw new Error(\"Unknown message digest\");this._hash=t(r.hash),this._tag=r.id,this._signType=r.sign}function l(e){return new s(e)}function c(e){return new u(e)}return Object.keys(a).forEach((function(t){a[t].id=e.from(a[t].id,\"hex\"),a[t.toLowerCase()]=a[t]})),r(s,n.Writable),s.prototype._write=function(e,t,n){this._hash.update(e),n()},s.prototype.update=function(t,n){return\"string\"==typeof t&&(t=e.from(t,n)),this._hash.update(t),this},s.prototype.sign=function(e,t){this.end();var n=this._hash.digest(),r=i(n,e,this._hashType,this._signType,this._tag);return t?r.toString(t):r},r(u,n.Writable),u.prototype._write=function(e,t,n){this._hash.update(e),n()},u.prototype.update=function(t,n){return\"string\"==typeof t&&(t=e.from(t,n)),this._hash.update(t),this},u.prototype.verify=function(t,n,r){\"string\"==typeof n&&(n=e.from(n,r)),this.end();var i=this._hash.digest();return o(n,i,t,this._signType,this._tag)},Vp={Sign:l,Verify:c,createSign:l,createVerify:c}}();de.createSign=a.createSign,de.Sign=a.Sign,de.createVerify=a.createVerify,de.Verify=a.Verify,de.createECDH=function(){if(Zp)return Gp;Zp=1;var e=eh(),t=hl;Gp=function(e){return new r(e)};var n={secp256k1:{name:\"secp256k1\",byteLength:32},secp224r1:{name:\"p224\",byteLength:28},prime256v1:{name:\"p256\",byteLength:32},prime192v1:{name:\"p192\",byteLength:24},ed25519:{name:\"ed25519\",byteLength:32},secp384r1:{name:\"p384\",byteLength:48},secp521r1:{name:\"p521\",byteLength:66}};function r(t){this.curveType=n[t],this.curveType||(this.curveType={name:t}),this.curve=new e.ec(this.curveType.name),this.keys=void 0}function i(e,t,n){Array.isArray(e)||(e=e.toArray());var r=new _(e);if(n&&r.length{switch(e){case\"sha256\":case\"sha3-256\":case\"blake2s256\":return 32;case\"sha512\":case\"sha3-512\":case\"blake2b512\":return 64;case\"sha224\":case\"sha3-224\":return 28;case\"sha384\":case\"sha3-384\":return 48;case\"sha1\":return 20;case\"md5\":return 16;default:{let t=qm[e];return void 0===t&&(t=Fm(e).digest().length,qm[e]=t),t}}},Wm=(e,t,n,r)=>{const i=Um.isBuffer(n)?n:Um.from(n),o=r&&r.length?Um.from(r):Um.alloc(t,0);return Km(e,o).update(i).digest()},$m=(e,t,n,r,i)=>{const o=Um.isBuffer(i)?i:Um.from(i||\"\"),a=o.length,s=Math.ceil(r/t);if(s>255)throw new Error(`OKM length ${r} is too long for ${e} hash`);const u=Um.alloc(t*s+a+1);for(let r=1,i=0,l=0;r<=s;++r)o.copy(u,l),u[l+a]=r,Km(e,n).update(u.slice(i,l+a+1)).digest().copy(u,l),i=l,l+=t;return u.slice(0,r)};function Vm(e,t,{salt:n=\"\",info:r=\"\",hash:i=\"SHA-256\"}={}){i=i.toLowerCase().replace(\"-\",\"\");const o=Hm(i),a=Wm(i,o,e,n);return $m(i,o,a,t,r)}Object.defineProperties(Vm,{hash_length:{configurable:!1,enumerable:!1,writable:!1,value:Hm},extract:{configurable:!1,enumerable:!1,writable:!1,value:Wm},expand:{configurable:!1,enumerable:!1,writable:!1,value:$m}});var Ym=Vm;const Gm=\"Impossible case. Please create issue.\",Zm=\"The tweak was out of range or the resulted private key is invalid\",Qm=\"The tweak was out of range or equal to zero\",Jm=\"Unknow error on context randomization\",Xm=\"Private Key is invalid\",eg=\"Public Key could not be parsed\",tg=\"Public Key serialization error\",ng=\"The sum of the public keys is not valid\",rg=\"Signature could not be parsed\",ig=\"The nonce generation function failed, or the private key was invalid\",og=\"Public key could not be recover\",ag=\"Scalar was invalid (zero or overflow)\";function sg(e,t){if(!e)throw new Error(t)}function ug(e,t,n){if(sg(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==n)if(Array.isArray(n)){const r=`Expected ${e} to be an Uint8Array with length [${n.join(\", \")}]`;sg(n.includes(t.length),r)}else{const r=`Expected ${e} to be an Uint8Array with length ${n}`;sg(t.length===n,r)}}function lg(e){sg(\"Boolean\"===dg(e),\"Expected compressed to be a Boolean\")}function cg(e=(e=>new Uint8Array(e)),t){return\"function\"==typeof e&&(e=e(t)),ug(\"output\",e,t),e}function dg(e){return Object.prototype.toString.call(e).slice(8,-1)}var fg={},hg=\"6.5.4\",pg={},mg={exports:{}};!function(e){!function(e,t){function n(e,t){if(!e)throw new Error(t||\"Assertion failed\")}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&(\"le\"!==t&&\"be\"!==t||(n=t,t=10),this._init(e||0,t||10,n||\"be\"))}var o;\"object\"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:ce.Buffer}catch(e){}function a(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function s(e,t,n){var r=a(e,n);return n-1>=t&&(r|=a(e,n-1)<<4),r}function u(e,t,n,r){for(var i=0,o=Math.min(e.length,n),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&\"object\"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(\"number\"==typeof e)return this._initNumber(e,t,r);if(\"object\"==typeof e)return this._initArray(e,t,r);\"hex\"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;\"-\"===(e=e.toString().replace(/\\s+/g,\"\"))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if(\"le\"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)i=s(e,t,r)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,a=o%r,s=Math.min(o,o-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?\"\"};var l=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;n.words[0]=s;for(var l=1;l>>26,d=67108863&u,f=Math.min(l,t.length-1),h=Math.max(0,l-e.length+1);h<=f;h++){var p=l-h|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[h])+d)/67108864|0,d=67108863&a}n.words[l]=0|d,u=0|c}return 0!==u?n.words[l]=0|u:n.length--,n.strip()}i.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||\"hex\"===e){r=\"\";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?l[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=c[e],h=d[e];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(h).toString(e);r=(p=p.idivn(h)).isZero()?m+r:l[f-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%t!=0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}n(!1,\"Base should be between 2 and 36\")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return n(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,\"byte array longer than desired length\"),n(o>0,\"Requested array length <= 0\"),this.strip();var a,s,u=\"le\"===t,l=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),l[s]=a;for(;s=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(\"number\"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(\"number\"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,m=h>>>13,g=0|a[2],v=8191&g,b=g>>>13,y=0|a[3],w=8191&y,_=y>>>13,S=0|a[4],E=8191&S,k=S>>>13,M=0|a[5],C=8191&M,x=M>>>13,A=0|a[6],R=8191&A,T=A>>>13,P=0|a[7],L=8191&P,I=P>>>13,O=0|a[8],N=8191&O,D=O>>>13,j=0|a[9],B=8191&j,z=j>>>13,U=0|s[0],F=8191&U,K=U>>>13,q=0|s[1],H=8191&q,W=q>>>13,$=0|s[2],V=8191&$,Y=$>>>13,G=0|s[3],Z=8191&G,Q=G>>>13,J=0|s[4],X=8191&J,ee=J>>>13,te=0|s[5],ne=8191&te,re=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,le=se>>>13,ce=0|s[8],de=8191&ce,fe=ce>>>13,he=0|s[9],pe=8191&he,me=he>>>13;n.negative=e.negative^t.negative,n.length=19;var ge=(l+(r=Math.imul(d,F))|0)+((8191&(i=(i=Math.imul(d,K))+Math.imul(f,F)|0))<<13)|0;l=((o=Math.imul(f,K))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(p,F),i=(i=Math.imul(p,K))+Math.imul(m,F)|0,o=Math.imul(m,K);var ve=(l+(r=r+Math.imul(d,H)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(f,H)|0))<<13)|0;l=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(v,F),i=(i=Math.imul(v,K))+Math.imul(b,F)|0,o=Math.imul(b,K),r=r+Math.imul(p,H)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,W)|0;var be=(l+(r=r+Math.imul(d,V)|0)|0)+((8191&(i=(i=i+Math.imul(d,Y)|0)+Math.imul(f,V)|0))<<13)|0;l=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(w,F),i=(i=Math.imul(w,K))+Math.imul(_,F)|0,o=Math.imul(_,K),r=r+Math.imul(v,H)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0,r=r+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,Y)|0;var ye=(l+(r=r+Math.imul(d,Z)|0)|0)+((8191&(i=(i=i+Math.imul(d,Q)|0)+Math.imul(f,Z)|0))<<13)|0;l=((o=o+Math.imul(f,Q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(E,F),i=(i=Math.imul(E,K))+Math.imul(k,F)|0,o=Math.imul(k,K),r=r+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,r=r+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,Y)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var we=(l+(r=r+Math.imul(d,X)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(f,X)|0))<<13)|0;l=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(C,F),i=(i=Math.imul(C,K))+Math.imul(x,F)|0,o=Math.imul(x,K),r=r+Math.imul(E,H)|0,i=(i=i+Math.imul(E,W)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,W)|0,r=r+Math.imul(w,V)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Y)|0,r=r+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,Q)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Q)|0,r=r+Math.imul(p,X)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,ee)|0;var _e=(l+(r=r+Math.imul(d,ne)|0)|0)+((8191&(i=(i=i+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;l=((o=o+Math.imul(f,re)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(R,F),i=(i=Math.imul(R,K))+Math.imul(T,F)|0,o=Math.imul(T,K),r=r+Math.imul(C,H)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,W)|0,r=r+Math.imul(E,V)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,Y)|0,r=r+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,Q)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,Q)|0,r=r+Math.imul(v,X)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(m,ne)|0,o=o+Math.imul(m,re)|0;var Se=(l+(r=r+Math.imul(d,oe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ae)|0)+Math.imul(f,oe)|0))<<13)|0;l=((o=o+Math.imul(f,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(L,F),i=(i=Math.imul(L,K))+Math.imul(I,F)|0,o=Math.imul(I,K),r=r+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,W)|0,r=r+Math.imul(C,V)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Y)|0,r=r+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,Q)|0,r=r+Math.imul(w,X)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,ee)|0,r=r+Math.imul(v,ne)|0,i=(i=i+Math.imul(v,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Ee=(l+(r=r+Math.imul(d,ue)|0)|0)+((8191&(i=(i=i+Math.imul(d,le)|0)+Math.imul(f,ue)|0))<<13)|0;l=((o=o+Math.imul(f,le)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(N,F),i=(i=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),r=r+Math.imul(L,H)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,W)|0,r=r+Math.imul(R,V)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,Y)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,Q)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Q)|0,r=r+Math.imul(E,X)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,ee)|0,r=r+Math.imul(w,ne)|0,i=(i=i+Math.imul(w,re)|0)+Math.imul(_,ne)|0,o=o+Math.imul(_,re)|0,r=r+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,r=r+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,le)|0;var ke=(l+(r=r+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;l=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,F),i=(i=Math.imul(B,K))+Math.imul(z,F)|0,o=Math.imul(z,K),r=r+Math.imul(N,H)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(D,H)|0,o=o+Math.imul(D,W)|0,r=r+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,Y)|0,r=r+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,Q)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Q)|0,r=r+Math.imul(C,X)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,ee)|0,r=r+Math.imul(E,ne)|0,i=(i=i+Math.imul(E,re)|0)+Math.imul(k,ne)|0,o=o+Math.imul(k,re)|0,r=r+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,r=r+Math.imul(v,ue)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,le)|0,r=r+Math.imul(p,de)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,de)|0,o=o+Math.imul(m,fe)|0;var Me=(l+(r=r+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,me)|0)+Math.imul(f,pe)|0))<<13)|0;l=((o=o+Math.imul(f,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,H),i=(i=Math.imul(B,W))+Math.imul(z,H)|0,o=Math.imul(z,W),r=r+Math.imul(N,V)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(D,V)|0,o=o+Math.imul(D,Y)|0,r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,Q)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,Q)|0,r=r+Math.imul(R,X)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(x,ne)|0,o=o+Math.imul(x,re)|0,r=r+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,r=r+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,le)|0,r=r+Math.imul(v,de)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(b,de)|0,o=o+Math.imul(b,fe)|0;var Ce=(l+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;l=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,V),i=(i=Math.imul(B,Y))+Math.imul(z,V)|0,o=Math.imul(z,Y),r=r+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,Q)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,Q)|0,r=r+Math.imul(L,X)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,ee)|0,r=r+Math.imul(R,ne)|0,i=(i=i+Math.imul(R,re)|0)+Math.imul(T,ne)|0,o=o+Math.imul(T,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,r=r+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,le)|0,r=r+Math.imul(w,de)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,de)|0,o=o+Math.imul(_,fe)|0;var xe=(l+(r=r+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,me)|0)+Math.imul(b,pe)|0))<<13)|0;l=((o=o+Math.imul(b,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,Z),i=(i=Math.imul(B,Q))+Math.imul(z,Z)|0,o=Math.imul(z,Q),r=r+Math.imul(N,X)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(D,X)|0,o=o+Math.imul(D,ee)|0,r=r+Math.imul(L,ne)|0,i=(i=i+Math.imul(L,re)|0)+Math.imul(I,ne)|0,o=o+Math.imul(I,re)|0,r=r+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,r=r+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,le)|0,r=r+Math.imul(E,de)|0,i=(i=i+Math.imul(E,fe)|0)+Math.imul(k,de)|0,o=o+Math.imul(k,fe)|0;var Ae=(l+(r=r+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;l=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,X),i=(i=Math.imul(B,ee))+Math.imul(z,X)|0,o=Math.imul(z,ee),r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(D,ne)|0,o=o+Math.imul(D,re)|0,r=r+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,r=r+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,le)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,le)|0,r=r+Math.imul(C,de)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(x,de)|0,o=o+Math.imul(x,fe)|0;var Re=(l+(r=r+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,me)|0)+Math.imul(k,pe)|0))<<13)|0;l=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,r=Math.imul(B,ne),i=(i=Math.imul(B,re))+Math.imul(z,ne)|0,o=Math.imul(z,re),r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,r=r+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,le)|0,r=r+Math.imul(R,de)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(T,de)|0,o=o+Math.imul(T,fe)|0;var Te=(l+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(x,pe)|0))<<13)|0;l=((o=o+Math.imul(x,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(z,oe)|0,o=Math.imul(z,ae),r=r+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,le)|0,r=r+Math.imul(L,de)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(I,de)|0,o=o+Math.imul(I,fe)|0;var Pe=(l+(r=r+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(T,pe)|0))<<13)|0;l=((o=o+Math.imul(T,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ue),i=(i=Math.imul(B,le))+Math.imul(z,ue)|0,o=Math.imul(z,le),r=r+Math.imul(N,de)|0,i=(i=i+Math.imul(N,fe)|0)+Math.imul(D,de)|0,o=o+Math.imul(D,fe)|0;var Le=(l+(r=r+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,me)|0)+Math.imul(I,pe)|0))<<13)|0;l=((o=o+Math.imul(I,me)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,r=Math.imul(B,de),i=(i=Math.imul(B,fe))+Math.imul(z,de)|0,o=Math.imul(z,fe);var Ie=(l+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,me)|0)+Math.imul(D,pe)|0))<<13)|0;l=((o=o+Math.imul(D,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863;var Oe=(l+(r=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,me))+Math.imul(z,pe)|0))<<13)|0;return l=((o=Math.imul(z,me))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,u[0]=ge,u[1]=ve,u[2]=be,u[3]=ye,u[4]=we,u[5]=_e,u[6]=Se,u[7]=Ee,u[8]=ke,u[9]=Me,u[10]=Ce,u[11]=xe,u[12]=Ae,u[13]=Re,u[14]=Te,u[15]=Pe,u[16]=Le,u[17]=Ie,u[18]=Oe,0!==l&&(u[19]=l,n.length++),n};function p(e,t,n){return(new m).mulp(e,t,n)}function m(e,t){this.x=e,this.y=t}Math.imul||(h=f),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?f(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}n.words[o]=s,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n.strip()}(this,e,t):p(this,e,t),n},m.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r>=1;return r},m.prototype.permute=function(e,t,n,r,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>i}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=i);l--){var d=0|this.words[l];this.words[l]=c<<26-o|d>>>o,c=d&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(\"number\"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(\"number\"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,u=r.length-o.length;if(\"mod\"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),\"div\"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),\"mod\"!==t&&(o=s.div.neg()),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),\"mod\"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),\"div\"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?\"div\"===t?{div:this.divn(e.words[0]),mod:null}:\"mod\"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,\"div\",!1).div},i.prototype.mod=function(e){return this.divmod(e,\"mod\",!1).mod},i.prototype.umod=function(e){return this.divmod(e,\"mod\",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},i.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var c=r.clone(),d=t.clone();!t.isZero();){for(var f=0,h=1;0==(t.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(d)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(s),a.isub(u)):(r.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,c=1;0==(t.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(t.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(\"number\"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,\"Number is too big\");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){ri&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return n(!this.red,\"Already a number in reduction context\"),n(0===this.negative,\"red works only with positives\"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,\"Already a number in reduction context\"),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,\"redAdd works only with red numbers\"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,\"redSub works only with red numbers\"),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,\"redISub works only with red numbers\"),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,\"redShl works only with red numbers\"),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function y(){v.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function w(){v.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function _(){v.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(e){if(\"string\"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),\"modulus must be greater than 1\"),this.m=e,this.prime=null}function E(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},r(b,v),b.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i>>22,o=a}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},b.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if(\"k256\"===e)t=new b;else if(\"p224\"===e)t=new y;else if(\"p192\"===e)t=new w;else{if(\"p25519\"!==e)throw new Error(\"Unknown prime \"+e);t=new _}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,\"red works only with positives\"),n(e.red,\"red works only with red numbers\")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),\"red works only with positives\"),n(e.red&&e.red===t.red,\"red works only with red numbers\")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);n(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,l).cmp(u);)c.redIAdd(u);for(var d=this.pow(c,o),f=this.pow(e,o.addn(1).iushrn(1)),h=this.pow(e,o),p=a;0!==h.cmp(s);){for(var m=h,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;r--){for(var l=t.words[r],c=u-1;c>=0;c--){var d=l>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}u=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new E(e)},r(E,S),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,n)}(mg);var gg=mg.exports,vg=bg;function bg(e,t){if(!e)throw new Error(t||\"Assertion failed\")}bg.equal=function(e,t,n){if(e!=t)throw new Error(n||\"Assertion failed: \"+e+\" != \"+t)};var yg={};!function(e){var t=e;function n(e){return 1===e.length?\"0\"+e:e}function r(e){for(var t=\"\",r=0;r>8,a=255&i;o?n.push(o,a):n.push(a)}return n},t.zero2=n,t.toHex=r,t.encode=function(e,t){return\"hex\"===t?r(e):e}}(yg),function(e){var t=e,n=gg,r=vg,i=yg;t.assert=r,t.toArray=i.toArray,t.zero2=i.zero2,t.toHex=i.toHex,t.encode=i.encode,t.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,r[a]=s,o.iushrn(1)}return r},t.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var a,s,u=e.andln(3)+i&3,l=t.andln(3)+o&3;3===u&&(u=-1),3===l&&(l=-1),a=0==(1&u)?0:3!==(r=e.andln(7)+i&7)&&5!==r||2!==l?u:-u,n[0].push(a),s=0==(1&l)?0:3!==(r=t.andln(7)+o&7)&&5!==r||2!==u?l:-l,n[1].push(s),2*i===a+1&&(i=1-i),2*o===s+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return n},t.cachedProperty=function(e,t,n){var r=\"_\"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},t.parseBytes=function(e){return\"string\"==typeof e?t.toArray(e,\"hex\"):e},t.intFromLE=function(e){return new n(e,\"hex\",\"le\")}}(pg);var wg,_g={exports:{}};function Sg(e){this.rand=e}if(_g.exports=function(e){return wg||(wg=new Sg(null)),wg.generate(e)},_g.exports.Rand=Sg,Sg.prototype.generate=function(e){return this._rand(e)},Sg.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Lg=Pg;function Ig(e,t){this.curve=e,this.type=t,this.precomputed=null}Pg.prototype.point=function(){throw new Error(\"Not implemented\")},Pg.prototype.validate=function(){throw new Error(\"Not implemented\")},Pg.prototype._fixedNafMul=function(e,t){Tg(e.precomputed);var n=e._getDoubles(),r=Ag(t,1,this._bitLength),i=(1<=o;u--)a=(a<<1)+r[u];s.push(a)}for(var l=this.jpoint(null,null,null),c=this.jpoint(null,null,null),d=i;d>0;d--){for(o=0;o=0;s--){for(var u=0;s>=0&&0===o[s];s--)u++;if(s>=0&&u++,a=a.dblp(u),s<0)break;var l=o[s];Tg(0!==l),a=\"affine\"===e.type?l>0?a.mixedAdd(i[l-1>>1]):a.mixedAdd(i[-l-1>>1].neg()):l>0?a.add(i[l-1>>1]):a.add(i[-l-1>>1].neg())}return\"affine\"===e.type?a.toP():a},Pg.prototype._wnafMulAdd=function(e,t,n,r,i){var o,a,s,u=this._wnafT1,l=this._wnafT2,c=this._wnafT3,d=0;for(o=0;o=1;o-=2){var h=o-1,p=o;if(1===u[h]&&1===u[p]){var m=[t[h],null,null,t[p]];0===t[h].y.cmp(t[p].y)?(m[1]=t[h].add(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg())):0===t[h].y.cmp(t[p].y.redNeg())?(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].add(t[p].neg())):(m[1]=t[h].toJ().mixedAdd(t[p]),m[2]=t[h].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=Rg(n[h],n[p]);for(d=Math.max(v[0].length,d),c[h]=new Array(d),c[p]=new Array(d),a=0;a=0;o--){for(var S=0;o>=0;){var E=!0;for(a=0;a=0&&S++,w=w.dblp(S),o<0)break;for(a=0;a0?s=l[a][k-1>>1]:k<0&&(s=l[a][-k-1>>1].neg()),w=\"affine\"===s.type?w.mixedAdd(s):w.add(s))}}for(o=0;o=Math.ceil((e.bitLength()+1)/t.step)},Ig.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i=0&&(o=t,a=n),r.negative&&(r=r.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:r,b:i},{a:o,b:a}]},Ug.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],i=r.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=i.mul(n.a),s=o.mul(r.a),u=i.mul(n.b),l=o.mul(r.b);return{k1:e.sub(a).sub(s),k2:u.add(l).neg()}},Ug.prototype.pointFromX=function(e,t){(e=new Dg(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error(\"invalid point\");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},Ug.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(i).cmpn(0)},Ug.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,o=0;o\":\"\"},Kg.prototype.isInfinity=function(){return this.inf},Kg.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},Kg.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),r=e.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Kg.prototype.getX=function(){return this.x.fromRed()},Kg.prototype.getY=function(){return this.y.fromRed()},Kg.prototype.mul=function(e){return e=new Dg(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Kg.prototype.mulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i):this.curve._wnafMulAdd(1,r,i,2)},Kg.prototype.jmulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i,!0):this.curve._wnafMulAdd(1,r,i,2,!0)},Kg.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Kg.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},Kg.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},jg(qg,Bg.BasePoint),Ug.prototype.jpoint=function(e,t,n){return new qg(this,e,t,n)},qg.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},qg.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},qg.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),i=e.x.redMul(n),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=s.redSqr(),c=l.redMul(s),d=r.redMul(l),f=u.redSqr().redIAdd(c).redISub(d).redISub(d),h=u.redMul(d.redISub(f)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,h,p)},qg.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),c=n.redMul(u),d=s.redSqr().redIAdd(l).redISub(c).redISub(c),f=s.redMul(c.redISub(d)).redISub(i.redMul(l)),h=this.z.redMul(a);return this.curve.jpoint(d,f,h)},qg.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},qg.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},qg.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Hg=gg,Wg=Ng,$g=Lg,Vg=pg;function Yg(e){$g.call(this,\"mont\",e),this.a=new Hg(e.a,16).toRed(this.red),this.b=new Hg(e.b,16).toRed(this.red),this.i4=new Hg(4).toRed(this.red).redInvm(),this.two=new Hg(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Wg(Yg,$g);var Gg=Yg;function Zg(e,t,n){$g.BasePoint.call(this,e,\"projective\"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Hg(t,16),this.z=new Hg(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Yg.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},Wg(Zg,$g.BasePoint),Yg.prototype.decodePoint=function(e,t){return this.point(Vg.toArray(e,t),1)},Yg.prototype.point=function(e,t){return new Zg(this,e,t)},Yg.prototype.pointFromJSON=function(e){return Zg.fromJSON(this,e)},Zg.prototype.precompute=function(){},Zg.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},Zg.fromJSON=function(e,t){return new Zg(e,t[0],t[1]||e.one)},Zg.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},Zg.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Zg.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),i=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,i)},Zg.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},Zg.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(n),a=i.redMul(r),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},Zg.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},Zg.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Zg.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Zg.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Zg.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Zg.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Qg=gg,Jg=Ng,Xg=Lg,ev=pg.assert;function tv(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,Xg.call(this,\"edwards\",e),this.a=new Qg(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Qg(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Qg(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),ev(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}Jg(tv,Xg);var nv=tv;function rv(e,t,n,r,i){Xg.BasePoint.call(this,e,\"projective\"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Qg(t,16),this.y=new Qg(n,16),this.z=r?new Qg(r,16):this.curve.one,this.t=i&&new Qg(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}tv.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},tv.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},tv.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},tv.prototype.pointFromX=function(e,t){(e=new Qg(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),o=r.redMul(i.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");var s=a.fromRed().isOdd();return(t&&!s||!t&&s)&&(a=a.redNeg()),this.point(e,a)},tv.prototype.pointFromY=function(e,t){(e=new Qg(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),o=r.redMul(i.redInvm());if(0===o.cmp(this.zero)){if(t)throw new Error(\"invalid point\");return this.point(this.zero,e)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},tv.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(i)},Jg(rv,Xg.BasePoint),tv.prototype.pointFromJSON=function(e){return rv.fromJSON(this,e)},tv.prototype.point=function(e,t,n,r){return new rv(this,e,t,n,r)},rv.fromJSON=function(e,t){return new rv(e,t[0],t[1],t[2])},rv.prototype.inspect=function(){return this.isInfinity()?\"\":\"\"},rv.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},rv.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=r.redAdd(t),a=o.redSub(n),s=r.redSub(t),u=i.redMul(a),l=o.redMul(s),c=i.redMul(s),d=a.redMul(o);return this.curve.point(u,l,d,c)},rv.prototype._projDbl=function(){var e,t,n,r,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var l=(r=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(l.redSub(this.curve.two)),t=l.redMul(r.redSub(u)),n=l.redSqr().redSub(l).redSub(l)):(i=this.z.redSqr(),o=l.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=l.redMul(r.redSub(u)),n=l.redMul(o))}else r=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=r.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(r)).redMul(o),t=this.curve._mulC(r).redMul(s.redISub(u)),n=r.redMul(o);return this.curve.point(e,t,n)},rv.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},rv.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=n.redSub(t),a=i.redSub(r),s=i.redAdd(r),u=n.redAdd(t),l=o.redMul(a),c=s.redMul(u),d=o.redMul(u),f=a.redMul(s);return this.curve.point(l,c,f,d)},rv.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),i=r.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),l=i.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),d=r.redMul(u).redMul(c);return this.curve.twisted?(t=r.redMul(l).redMul(a.redSub(this.curve._mulA(o))),n=u.redMul(l)):(t=r.redMul(l).redMul(a.redSub(o)),n=this.curve._mulC(u).redMul(l)),this.curve.point(d,t,n)},rv.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},rv.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},rv.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},rv.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},rv.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},rv.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},rv.prototype.getX=function(){return this.normalize(),this.x.fromRed()},rv.prototype.getY=function(){return this.normalize(),this.y.fromRed()},rv.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},rv.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},rv.prototype.toP=rv.prototype.normalize,rv.prototype.mixedAdd=rv.prototype.add,function(e){var t=e;t.base=Lg,t.short=Fg,t.mont=Gg,t.edwards=nv}(Mg);var iv={},ov={},av={},sv=vg,uv=Ng;function lv(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function cv(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function dv(e){return 1===e.length?\"0\"+e:e}function fv(e){return 7===e.length?\"0\"+e:6===e.length?\"00\"+e:5===e.length?\"000\"+e:4===e.length?\"0000\"+e:3===e.length?\"00000\"+e:2===e.length?\"000000\"+e:1===e.length?\"0000000\"+e:e}av.inherits=uv,av.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if(\"string\"==typeof e)if(t){if(\"hex\"===t)for((e=e.replace(/[^a-z0-9]+/gi,\"\")).length%2!=0&&(e=\"0\"+e),i=0;i>6|192,n[r++]=63&o|128):lv(e,i)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++i)),n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128):(n[r++]=o>>12|224,n[r++]=o>>6&63|128,n[r++]=63&o|128)}else for(i=0;i>>0}return o},av.split32=function(e,t){for(var n=new Array(4*e.length),r=0,i=0;r>>24,n[i+1]=o>>>16&255,n[i+2]=o>>>8&255,n[i+3]=255&o):(n[i+3]=o>>>24,n[i+2]=o>>>16&255,n[i+1]=o>>>8&255,n[i]=255&o)}return n},av.rotr32=function(e,t){return e>>>t|e<<32-t},av.rotl32=function(e,t){return e<>>32-t},av.sum32=function(e,t){return e+t>>>0},av.sum32_3=function(e,t,n){return e+t+n>>>0},av.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},av.sum32_5=function(e,t,n,r,i){return e+t+n+r+i>>>0},av.sum64=function(e,t,n,r){var i=e[t],o=r+e[t+1]>>>0,a=(o>>0,e[t+1]=o},av.sum64_hi=function(e,t,n,r){return(t+r>>>0>>0},av.sum64_lo=function(e,t,n,r){return t+r>>>0},av.sum64_4_hi=function(e,t,n,r,i,o,a,s){var u=0,l=t;return u+=(l=l+r>>>0)>>0)>>0)>>0},av.sum64_4_lo=function(e,t,n,r,i,o,a,s){return t+r+o+s>>>0},av.sum64_5_hi=function(e,t,n,r,i,o,a,s,u,l){var c=0,d=t;return c+=(d=d+r>>>0)>>0)>>0)>>0)>>0},av.sum64_5_lo=function(e,t,n,r,i,o,a,s,u,l){return t+r+o+s+l>>>0},av.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},av.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},av.shr64_hi=function(e,t,n){return e>>>n},av.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0};var hv={},pv=av,mv=vg;function gv(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}hv.BlockHash=gv,gv.prototype.update=function(e,t){if(e=pv.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=pv.join32(e,0,e.length-n,this.endian);for(var r=0;r>>24&255,r[i++]=e>>>16&255,r[i++]=e>>>8&255,r[i++]=255&e}else for(r[i++]=255&e,r[i++]=e>>>8&255,r[i++]=e>>>16&255,r[i++]=e>>>24&255,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,o=8;o>>3},bv.g1_256=function(e){return yv(e,17)^yv(e,19)^e>>>10};var Ev=av,kv=hv,Mv=bv,Cv=Ev.rotl32,xv=Ev.sum32,Av=Ev.sum32_5,Rv=Mv.ft_1,Tv=kv.BlockHash,Pv=[1518500249,1859775393,2400959708,3395469782];function Lv(){if(!(this instanceof Lv))return new Lv;Tv.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ev.inherits(Lv,Tv);var Iv=Lv;Lv.blockSize=512,Lv.outSize=160,Lv.hmacStrength=80,Lv.padLength=64,Lv.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;rthis.blockSize&&(e=(new this.Hash).update(e).digest()),Jb(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(t,n,r)}var sy=ay;ay.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(e.concat(n||[])),this._reseed=1},ay.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");\"string\"!=typeof t&&(r=n,n=t,t=null),n&&(n=iy.toArray(n,r||\"hex\"),this._update(n));for(var i=[];i.length\"};var fy=gg,hy=pg,py=hy.assert;function my(e,t){if(e instanceof my)return e;this._importDER(e,t)||(py(e.r&&e.s,\"Signature without r or s\"),this.r=new fy(e.r,16),this.s=new fy(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var gy=my;function vy(){this.place=0}function by(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function yy(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}my.prototype._importDER=function(e,t){e=hy.toArray(e,t);var n=new vy;if(48!==e[n.place++])return!1;var r=by(e,n);if(!1===r)return!1;if(r+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var i=by(e,n);if(!1===i)return!1;var o=e.slice(n.place,i+n.place);if(n.place+=i,2!==e[n.place++])return!1;var a=by(e,n);if(!1===a)return!1;if(e.length!==a+n.place)return!1;var s=e.slice(n.place,a+n.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new fy(o),this.s=new fy(s),this.recoveryParam=null,!0},my.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=yy(t),n=yy(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];wy(r,t.length),(r=r.concat(t)).push(2),wy(r,n.length);var i=r.concat(n),o=[48];return wy(o,i.length),o=o.concat(i),hy.encode(o,e)};var _y=gg,Sy=sy,Ey=iv,ky=kg,My=pg.assert,Cy=dy,xy=gy;function Ay(e){if(!(this instanceof Ay))return new Ay(e);\"string\"==typeof e&&(My(Object.prototype.hasOwnProperty.call(Ey,e),\"Unknown curve \"+e),e=Ey[e]),e instanceof Ey.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var Ry=Ay;Ay.prototype.keyPair=function(e){return new Cy(this,e)},Ay.prototype.keyFromPrivate=function(e,t){return Cy.fromPrivate(this,e,t)},Ay.prototype.keyFromPublic=function(e,t){return Cy.fromPublic(this,e,t)},Ay.prototype.genKeyPair=function(e){e||(e={});for(var t=new Sy({hash:this.hash,pers:e.pers,persEnc:e.persEnc||\"utf8\",entropy:e.entropy||ky(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||\"utf8\",nonce:this.n.toArray()}),n=this.n.byteLength(),r=this.n.sub(new _y(2));;){var i=new _y(t.generate(n));if(!(i.cmp(r)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Ay.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},Ay.prototype.sign=function(e,t,n,r){\"object\"==typeof n&&(r=n,n=null),r||(r={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new _y(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray(\"be\",i),a=e.toArray(\"be\",i),s=new Sy({hash:this.hash,entropy:o,nonce:a,pers:r.pers,persEnc:r.persEnc||\"utf8\"}),u=this.n.sub(new _y(1)),l=0;;l++){var c=r.k?r.k(l):new _y(s.generate(this.n.byteLength()));if(!((c=this._truncateToN(c,!0)).cmpn(1)<=0||c.cmp(u)>=0)){var d=this.g.mul(c);if(!d.isInfinity()){var f=d.getX(),h=f.umod(this.n);if(0!==h.cmpn(0)){var p=c.invm(this.n).mul(h.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(d.getY().isOdd()?1:0)|(0!==f.cmp(h)?2:0);return r.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new xy({r:h,s:p,recoveryParam:m})}}}}}},Ay.prototype.verify=function(e,t,n,r){e=this._truncateToN(new _y(e,16)),n=this.keyFromPublic(n,r);var i=(t=new xy(t,\"hex\")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,s=o.invm(this.n),u=s.mul(e).umod(this.n),l=s.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,n.getPublic(),l)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(u,n.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Ay.prototype.recoverPubKey=function(e,t,n,r){My((3&n)===n,\"The recovery param is more than two bits\"),t=new xy(t,r);var i=this.n,o=new _y(e),a=t.r,s=t.s,u=1&n,l=n>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error(\"Unable to find sencond key candinate\");a=l?this.curve.pointFromX(a.add(this.curve.n),u):this.curve.pointFromX(a,u);var c=t.r.invm(i),d=i.sub(o).mul(c).umod(i),f=s.mul(c).umod(i);return this.g.mulAdd(d,a,f)},Ay.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new xy(t,r)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(n))return i}throw new Error(\"Unable to find valid recovery factor\")};var Ty=pg,Py=Ty.assert,Ly=Ty.parseBytes,Iy=Ty.cachedProperty;function Oy(e,t){this.eddsa=e,this._secret=Ly(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=Ly(t.pub)}Oy.fromPublic=function(e,t){return t instanceof Oy?t:new Oy(e,{pub:t})},Oy.fromSecret=function(e,t){return t instanceof Oy?t:new Oy(e,{secret:t})},Oy.prototype.secret=function(){return this._secret},Iy(Oy,\"pubBytes\",(function(){return this.eddsa.encodePoint(this.pub())})),Iy(Oy,\"pub\",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),Iy(Oy,\"privBytes\",(function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r})),Iy(Oy,\"priv\",(function(){return this.eddsa.decodeInt(this.privBytes())})),Iy(Oy,\"hash\",(function(){return this.eddsa.hash().update(this.secret()).digest()})),Iy(Oy,\"messagePrefix\",(function(){return this.hash().slice(this.eddsa.encodingLength)})),Oy.prototype.sign=function(e){return Py(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(e,this)},Oy.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},Oy.prototype.getSecret=function(e){return Py(this._secret,\"KeyPair is public only\"),Ty.encode(this.secret(),e)},Oy.prototype.getPublic=function(e){return Ty.encode(this.pubBytes(),e)};var Ny=Oy,Dy=gg,jy=pg,By=jy.assert,zy=jy.cachedProperty,Uy=jy.parseBytes;function Fy(e,t){this.eddsa=e,\"object\"!=typeof t&&(t=Uy(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),By(t.R&&t.S,\"Signature without R or S\"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof Dy&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}zy(Fy,\"S\",(function(){return this.eddsa.decodeInt(this.Sencoded())})),zy(Fy,\"R\",(function(){return this.eddsa.decodePoint(this.Rencoded())})),zy(Fy,\"Rencoded\",(function(){return this.eddsa.encodePoint(this.R())})),zy(Fy,\"Sencoded\",(function(){return this.eddsa.encodeInt(this.S())})),Fy.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Fy.prototype.toHex=function(){return jy.encode(this.toBytes(),\"hex\").toUpperCase()};var Ky=Fy,qy=ov,Hy=iv,Wy=pg,$y=Wy.assert,Vy=Wy.parseBytes,Yy=Ny,Gy=Ky;function Zy(e){if($y(\"ed25519\"===e,\"only tested with ed25519 so far\"),!(this instanceof Zy))return new Zy(e);e=Hy[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=qy.sha512}var Qy=Zy;Zy.prototype.sign=function(e,t){e=Vy(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),i=this.g.mul(r),o=this.encodePoint(i),a=this.hashInt(o,n.pubBytes(),e).mul(n.priv()),s=r.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:o})},Zy.prototype.verify=function(e,t,n){e=Vy(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),i=this.hashInt(t.Rencoded(),r.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(r.pub().mul(i)).eq(o)},Zy.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0)return null;n=n.toRed(Xy.red);let r=n.redSqr().redIMul(n).redIAdd(Xy.b).redSqrt();return 3===e!==r.isOdd()&&(r=r.redNeg()),Jy.keyPair({pub:{x:n,y:r}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,n){let r=new ew(t),i=new ew(n);if(r.cmp(Xy.p)>=0||i.cmp(Xy.p)>=0)return null;if(r=r.toRed(Xy.red),i=i.toRed(Xy.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;const o=r.redSqr().redIMul(r);return i.redSqr().redISub(o.redIAdd(Xy.b)).isZero()?Jy.keyPair({pub:{x:r,y:i}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function nw(e,t){const n=t.encode(null,33===e.length);for(let t=0;t0,privateKeyVerify(e){const t=new ew(e);return t.cmp(Xy.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new ew(e),n=Xy.n.sub(t).umod(Xy.n).toArrayLike(Uint8Array,\"be\",32);return e.set(n),0},privateKeyTweakAdd(e,t){const n=new ew(t);if(n.cmp(Xy.n)>=0)return 1;if(n.iadd(new ew(e)),n.cmp(Xy.n)>=0&&n.isub(Xy.n),n.isZero())return 1;const r=n.toArrayLike(Uint8Array,\"be\",32);return e.set(r),0},privateKeyTweakMul(e,t){let n=new ew(t);if(n.cmp(Xy.n)>=0||n.isZero())return 1;n.imul(new ew(e)),n.cmp(Xy.n)>=0&&(n=n.umod(Xy.n));const r=n.toArrayLike(Uint8Array,\"be\",32);return e.set(r),0},publicKeyVerify:e=>null===tw(e)?1:0,publicKeyCreate(e,t){const n=new ew(t);if(n.cmp(Xy.n)>=0||n.isZero())return 1;return nw(e,Jy.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const n=tw(t);if(null===n)return 1;return nw(e,n.getPublic()),0},publicKeyNegate(e,t){const n=tw(t);if(null===n)return 1;const r=n.getPublic();return r.y=r.y.redNeg(),nw(e,r),0},publicKeyCombine(e,t){const n=new Array(t.length);for(let e=0;e=0)return 2;const i=r.getPublic().add(Xy.g.mul(n));return i.isInfinity()?2:(nw(e,i),0)},publicKeyTweakMul(e,t,n){const r=tw(t);if(null===r)return 1;if((n=new ew(n)).cmp(Xy.n)>=0||n.isZero())return 2;return nw(e,r.getPublic().mul(n)),0},signatureNormalize(e){const t=new ew(e.subarray(0,32)),n=new ew(e.subarray(32,64));return t.cmp(Xy.n)>=0||n.cmp(Xy.n)>=0?1:(1===n.cmp(Jy.nh)&&e.set(Xy.n.sub(n).toArrayLike(Uint8Array,\"be\",32),32),0)},signatureExport(e,t){const n=t.subarray(0,32),r=t.subarray(32,64);if(new ew(n).cmp(Xy.n)>=0)return 1;if(new ew(r).cmp(Xy.n)>=0)return 1;const{output:i}=e;let o=i.subarray(4,37);o[0]=0,o.set(n,1);let a=33,s=0;for(;a>1&&0===o[s]&&!(128&o[s+1]);--a,++s);if(o=o.subarray(s),128&o[0])return 1;if(a>1&&0===o[0]&&!(128&o[1]))return 1;let u=i.subarray(39,72);u[0]=0,u.set(r,1);let l=33,c=0;for(;l>1&&0===u[c]&&!(128&u[c+1]);--l,++c);return u=u.subarray(c),128&u[0]||l>1&&0===u[0]&&!(128&u[1])?1:(e.outputlen=6+a+l,i[0]=48,i[1]=e.outputlen-2,i[2]=2,i[3]=o.length,i.set(o,4),i[4+a]=2,i[5+a]=u.length,i.set(u,6+a),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const n=t[3];if(0===n)return 1;if(5+n>=t.length)return 1;if(2!==t[4+n])return 1;const r=t[5+n];if(0===r)return 1;if(6+n+r!==t.length)return 1;if(128&t[4])return 1;if(n>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[n+6])return 1;if(r>1&&0===t[n+6]&&!(128&t[n+7]))return 1;let i=t.subarray(4,4+n);if(33===i.length&&0===i[0]&&(i=i.subarray(1)),i.length>32)return 1;let o=t.subarray(6+n);if(33===o.length&&0===o[0]&&(o=o.slice(1)),o.length>32)throw new Error(\"S length is too long\");let a=new ew(i);a.cmp(Xy.n)>=0&&(a=new ew(0));let s=new ew(t.subarray(6+n));return s.cmp(Xy.n)>=0&&(s=new ew(0)),e.set(a.toArrayLike(Uint8Array,\"be\",32),0),e.set(s.toArrayLike(Uint8Array,\"be\",32),32),0},ecdsaSign(e,t,n,r,i){if(i){const e=i;i=i=>{const o=e(t,n,null,r,i);if(!(o instanceof Uint8Array&&32===o.length))throw new Error(\"This is the way\");return new ew(o)}}const o=new ew(n);if(o.cmp(Xy.n)>=0||o.isZero())return 1;let a;try{a=Jy.sign(t,n,{canonical:!0,k:i,pers:r})}catch(e){return 1}return e.signature.set(a.r.toArrayLike(Uint8Array,\"be\",32),0),e.signature.set(a.s.toArrayLike(Uint8Array,\"be\",32),32),e.recid=a.recoveryParam,0},ecdsaVerify(e,t,n){const r={r:e.subarray(0,32),s:e.subarray(32,64)},i=new ew(r.r),o=new ew(r.s);if(i.cmp(Xy.n)>=0||o.cmp(Xy.n)>=0)return 1;if(1===o.cmp(Jy.nh)||i.isZero()||o.isZero())return 3;const a=tw(n);if(null===a)return 2;const s=a.getPublic();return Jy.verify(t,r,s)?0:3},ecdsaRecover(e,t,n,r){const i={r:t.slice(0,32),s:t.slice(32,64)},o=new ew(i.r),a=new ew(i.s);if(o.cmp(Xy.n)>=0||a.cmp(Xy.n)>=0)return 1;if(o.isZero()||a.isZero())return 2;let s;try{s=Jy.recoverPubKey(r,i,n)}catch(e){return 2}return nw(e,s),0},ecdh(e,t,n,r,i,o,a){const s=tw(t);if(null===s)return 1;const u=new ew(n);if(u.cmp(Xy.n)>=0||u.isZero())return 2;const l=s.getPublic().mul(u);if(void 0===i){const t=l.encode(null,!0),n=Jy.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=n[t]}else{o||(o=new Uint8Array(32));const t=l.getX().toArray(\"be\",32);for(let e=0;e<32;++e)o[e]=t[e];a||(a=new Uint8Array(32));const n=l.getY().toArray(\"be\",32);for(let e=0;e<32;++e)a[e]=n[e];const s=i(o,a,r);if(!(s instanceof Uint8Array&&s.length===e.length))return 2;e.set(s)}return 0}},iw=(e=>({contextRandomize(t){if(sg(null===t||t instanceof Uint8Array,\"Expected seed to be an Uint8Array or null\"),null!==t&&ug(\"seed\",t,32),1===e.contextRandomize(t))throw new Error(Jm)},privateKeyVerify:t=>(ug(\"private key\",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(ug(\"private key\",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(Gm)}},privateKeyTweakAdd(t,n){switch(ug(\"private key\",t,32),ug(\"tweak\",n,32),e.privateKeyTweakAdd(t,n)){case 0:return t;case 1:throw new Error(Zm)}},privateKeyTweakMul(t,n){switch(ug(\"private key\",t,32),ug(\"tweak\",n,32),e.privateKeyTweakMul(t,n)){case 0:return t;case 1:throw new Error(Qm)}},publicKeyVerify:t=>(ug(\"public key\",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,n=!0,r){switch(ug(\"private key\",t,32),lg(n),r=cg(r,n?33:65),e.publicKeyCreate(r,t)){case 0:return r;case 1:throw new Error(Xm);case 2:throw new Error(tg)}},publicKeyConvert(t,n=!0,r){switch(ug(\"public key\",t,[33,65]),lg(n),r=cg(r,n?33:65),e.publicKeyConvert(r,t)){case 0:return r;case 1:throw new Error(eg);case 2:throw new Error(tg)}},publicKeyNegate(t,n=!0,r){switch(ug(\"public key\",t,[33,65]),lg(n),r=cg(r,n?33:65),e.publicKeyNegate(r,t)){case 0:return r;case 1:throw new Error(eg);case 2:throw new Error(Gm);case 3:throw new Error(tg)}},publicKeyCombine(t,n=!0,r){sg(Array.isArray(t),\"Expected public keys to be an Array\"),sg(t.length>0,\"Expected public keys array will have more than zero items\");for(const e of t)ug(\"public key\",e,[33,65]);switch(lg(n),r=cg(r,n?33:65),e.publicKeyCombine(r,t)){case 0:return r;case 1:throw new Error(eg);case 2:throw new Error(ng);case 3:throw new Error(tg)}},publicKeyTweakAdd(t,n,r=!0,i){switch(ug(\"public key\",t,[33,65]),ug(\"tweak\",n,32),lg(r),i=cg(i,r?33:65),e.publicKeyTweakAdd(i,t,n)){case 0:return i;case 1:throw new Error(eg);case 2:throw new Error(Zm)}},publicKeyTweakMul(t,n,r=!0,i){switch(ug(\"public key\",t,[33,65]),ug(\"tweak\",n,32),lg(r),i=cg(i,r?33:65),e.publicKeyTweakMul(i,t,n)){case 0:return i;case 1:throw new Error(eg);case 2:throw new Error(Qm)}},signatureNormalize(t){switch(ug(\"signature\",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(rg)}},signatureExport(t,n){ug(\"signature\",t,64);const r={output:n=cg(n,72),outputlen:72};switch(e.signatureExport(r,t)){case 0:return n.slice(0,r.outputlen);case 1:throw new Error(rg);case 2:throw new Error(Gm)}},signatureImport(t,n){switch(ug(\"signature\",t),n=cg(n,64),e.signatureImport(n,t)){case 0:return n;case 1:throw new Error(rg);case 2:throw new Error(Gm)}},ecdsaSign(t,n,r={},i){ug(\"message\",t,32),ug(\"private key\",n,32),sg(\"Object\"===dg(r),\"Expected options to be an Object\"),void 0!==r.data&&ug(\"options.data\",r.data),void 0!==r.noncefn&&sg(\"Function\"===dg(r.noncefn),\"Expected options.noncefn to be a Function\");const o={signature:i=cg(i,64),recid:null};switch(e.ecdsaSign(o,t,n,r.data,r.noncefn)){case 0:return o;case 1:throw new Error(ig);case 2:throw new Error(Gm)}},ecdsaVerify(t,n,r){switch(ug(\"signature\",t,64),ug(\"message\",n,32),ug(\"public key\",r,[33,65]),e.ecdsaVerify(t,n,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(rg);case 2:throw new Error(eg)}},ecdsaRecover(t,n,r,i=!0,o){switch(ug(\"signature\",t,64),sg(\"Number\"===dg(n)&&n>=0&&n<=3,\"Expected recovery id to be a Number within interval [0, 3]\"),ug(\"message\",r,32),lg(i),o=cg(o,i?33:65),e.ecdsaRecover(o,t,n,r)){case 0:return o;case 1:throw new Error(rg);case 2:throw new Error(og);case 3:throw new Error(Gm)}},ecdh(t,n,r={},i){switch(ug(\"public key\",t,[33,65]),ug(\"private key\",n,32),sg(\"Object\"===dg(r),\"Expected options to be an Object\"),void 0!==r.data&&ug(\"options.data\",r.data),void 0!==r.hashfn?(sg(\"Function\"===dg(r.hashfn),\"Expected options.hashfn to be a Function\"),void 0!==r.xbuf&&ug(\"options.xbuf\",r.xbuf,32),void 0!==r.ybuf&&ug(\"options.ybuf\",r.ybuf,32),ug(\"output\",i)):i=cg(i,32),e.ecdh(i,t,n,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return i;case 1:throw new Error(eg);case 2:throw new Error(ag)}}}))(rw),ow={},aw={};!function(e){Object.defineProperty(e,\"__esModule\",{value:!0}),e.SECRET_KEY_LENGTH=e.AES_IV_PLUS_TAG_LENGTH=e.AES_TAG_LENGTH=e.AES_IV_LENGTH=e.UNCOMPRESSED_PUBLIC_KEY_SIZE=void 0,e.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,e.AES_IV_LENGTH=16,e.AES_TAG_LENGTH=16,e.AES_IV_PLUS_TAG_LENGTH=e.AES_IV_LENGTH+e.AES_TAG_LENGTH,e.SECRET_KEY_LENGTH=32}(aw);var sw=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ow,\"__esModule\",{value:!0}),ow.aesDecrypt=ow.aesEncrypt=ow.getValidSecret=ow.decodeHex=ow.remove0x=void 0;var uw=zm(),lw=sw(iw),cw=aw;function dw(e){return e.startsWith(\"0x\")||e.startsWith(\"0X\")?e.slice(2):e}ow.remove0x=dw,ow.decodeHex=function(e){return _.from(dw(e),\"hex\")},ow.getValidSecret=function(){var e;do{e=(0,uw.randomBytes)(cw.SECRET_KEY_LENGTH)}while(!lw.default.privateKeyVerify(e));return e},ow.aesEncrypt=function(e,t){var n=(0,uw.randomBytes)(cw.AES_IV_LENGTH),r=(0,uw.createCipheriv)(\"aes-256-gcm\",e,n),i=_.concat([r.update(t),r.final()]),o=r.getAuthTag();return _.concat([n,o,i])},ow.aesDecrypt=function(e,t){var n=t.slice(0,cw.AES_IV_LENGTH),r=t.slice(cw.AES_IV_LENGTH,cw.AES_IV_PLUS_TAG_LENGTH),i=t.slice(cw.AES_IV_PLUS_TAG_LENGTH),o=(0,uw.createDecipheriv)(\"aes-256-gcm\",e,n);return o.setAuthTag(r),_.concat([o.update(i),o.final()])};var fw={},hw=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(fw,\"__esModule\",{value:!0});var pw=hw(Ym),mw=hw(iw),gw=ow,vw=aw,bw=function(){function e(e){this.uncompressed=_.from(mw.default.publicKeyConvert(e,!1)),this.compressed=_.from(mw.default.publicKeyConvert(e,!0))}return e.fromHex=function(t){var n=(0,gw.decodeHex)(t);if(n.length===vw.UNCOMPRESSED_PUBLIC_KEY_SIZE-1){var r=_.from([4]);return new e(_.concat([r,n]))}return new e(n)},e.prototype.toHex=function(e){return void 0===e&&(e=!0),e?this.compressed.toString(\"hex\"):this.uncompressed.toString(\"hex\")},e.prototype.decapsulate=function(e){var t=_.concat([this.uncompressed,e.multiply(this)]);return(0,pw.default)(t,32,{hash:\"SHA-256\"})},e.prototype.equals=function(e){return this.uncompressed.equals(e.uncompressed)},e}();fw.default=bw;var yw=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(le,\"__esModule\",{value:!0});var ww=yw(Ym),_w=yw(iw),Sw=ow,Ew=yw(fw),kw=function(){function e(e){if(this.secret=e||(0,Sw.getValidSecret)(),!_w.default.privateKeyVerify(this.secret))throw new Error(\"Invalid private key\");this.publicKey=new Ew.default(_.from(_w.default.publicKeyCreate(this.secret)))}return e.fromHex=function(t){return new e((0,Sw.decodeHex)(t))},e.prototype.toHex=function(){return\"0x\".concat(this.secret.toString(\"hex\"))},e.prototype.encapsulate=function(e){var t=_.concat([this.publicKey.uncompressed,this.multiply(e)]);return(0,ww.default)(t,32,{hash:\"SHA-256\"})},e.prototype.multiply=function(e){return _.from(_w.default.publicKeyTweakMul(e.compressed,this.secret,!1))},e.prototype.equals=function(e){return this.secret.equals(e.secret)},e}();le.default=kw,function(e){var t=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,\"__esModule\",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var r=le;Object.defineProperty(e,\"PrivateKey\",{enumerable:!0,get:function(){return t(r).default}});var i=fw;Object.defineProperty(e,\"PublicKey\",{enumerable:!0,get:function(){return t(i).default}})}(ue),function(e){Object.defineProperty(e,\"__esModule\",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.decrypt=e.encrypt=void 0;var t=ue,n=ow,r=aw;e.encrypt=function(e,r){var i=new t.PrivateKey,o=e instanceof _?new t.PublicKey(e):t.PublicKey.fromHex(e),a=i.encapsulate(o),s=(0,n.aesEncrypt)(a,r);return _.concat([i.publicKey.uncompressed,s])},e.decrypt=function(e,i){var o=e instanceof _?new t.PrivateKey(e):t.PrivateKey.fromHex(e),a=new t.PublicKey(i.slice(0,r.UNCOMPRESSED_PUBLIC_KEY_SIZE)),s=i.slice(r.UNCOMPRESSED_PUBLIC_KEY_SIZE),u=a.decapsulate(o);return(0,n.aesDecrypt)(u,s)};var i=ue;Object.defineProperty(e,\"PrivateKey\",{enumerable:!0,get:function(){return i.PrivateKey}}),Object.defineProperty(e,\"PublicKey\",{enumerable:!0,get:function(){return i.PublicKey}}),e.utils={aesDecrypt:n.aesDecrypt,aesEncrypt:n.aesEncrypt,decodeHex:n.decodeHex,getValidSecret:n.getValidSecret,remove0x:n.remove0x}}(se);var Mw={exports:{}};!function(e,t){!function(t){var n=Object.hasOwnProperty,r=Array.isArray?Array.isArray:function(e){return\"[object Array]\"===Object.prototype.toString.call(e)},i=\"object\"==typeof je&&!0,o=\"function\"==typeof Symbol,a=\"object\"==typeof Reflect,s=\"function\"==typeof setImmediate?setImmediate:setTimeout,u=o?a&&\"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 l(){this._events={},this._conf&&c.call(this,this._conf)}function c(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(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+\".\"),void 0!==je&&je.emitWarning){var r=new Error(n);r.name=\"MaxListenersExceededWarning\",r.emitter=this,r.count=e,je.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var f=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 h(e,n){for(var r={},i=e.length,o=n?n.length:0,a=0;a0;)if(o===e[a])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,a=this._listeners,s=function(){var r=f.apply(null,arguments),a={data:r,name:t,original:e};n?!1!==n.call(i,a)&&o.emit.apply(o,[a.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(a[e])throw Error(\"Event '\"+e+\"' is already listening\");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===a[e]&&(a[e]=s,r._on.call(i,e,s))},o.on(\"newListener\",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&a[e]&&(a[e]=null,r._off.call(i,e,s))},a[e]=null,o.on(\"removeListener\",this._onRemoveListener)):(a[e]=s,r._on.call(i,e,s))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,a=this._emitter,s=this._off,l=this._target;if(e&&\"string\"!=typeof e)throw TypeError(\"event must be a string\");function c(){i._onNewListener&&(a.off(\"newListener\",i._onNewListener),a.off(\"removeListener\",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=o[e]))return;s.call(l,e,t),delete o[e],--this._listenersCount||c()}else{for(r=(n=u(o)).length;r-- >0;)e=n[r],s.call(l,e,o[e]);this._listeners={},this._listenersCount=0,c()}}});var b=v([\"function\"]),y=v([\"object\",\"function\"]);function w(e,t,n){var r,i,o,a=0,s=new e((function(u,l,c){function d(){i&&(i=null),a&&(clearTimeout(a),a=0)}n=m(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 c;var f=function(e){d(),u(e)},h=function(e){d(),l(e)};r?t(f,h,c):(i=[function(e){h(e||Error(\"canceled\"))}],t(f,h,(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&&(a=setTimeout((function(){var e=Error(\"timeout\");e.code=\"ETIMEDOUT\",a=0,s.cancel(e),l(e)}),n.timeout))}));return r||(s.cancel=function(e){if(i){for(var t=i.length,n=1;n0;)\"_listeners\"!==(h=b[s])&&(y=S(e,t,n[h],r+1,i))&&(w?w.push.apply(w,y):w=y);return w}if(\"**\"===_){for((v=r+1===i||r+2===i&&\"*\"===E)&&n._listeners&&(w=S(e,t,n,i,i)),s=(b=u(n)).length;s-- >0;)\"_listeners\"!==(h=b[s])&&(\"*\"===h||\"**\"===h?(n[h]._listeners&&!v&&(y=S(e,t,n[h],i,i))&&(w?w.push.apply(w,y):w=y),y=S(e,t,n[h],r,i)):y=S(e,t,n[h],h===E?r+2:r,i),y&&(w?w.push.apply(w,y):w=y));return w}n[_]&&(w=S(e,t,n[_],r+1,i))}if((p=n[\"*\"])&&S(e,t,p,r+1,i),m=n[\"**\"])if(r0;)\"_listeners\"!==(h=b[s])&&(h===E?S(e,t,m[h],r+2,i):h===_?S(e,t,m[h],r+1,i):((g={})[h]=m[h],S(e,t,{\"**\":g},r+1,i)));else m._listeners?S(e,t,m,i,i):m[\"*\"]&&m[\"*\"]._listeners&&S(e,t,m[\"*\"],i,i);return w}function E(e,t,n){var r,i,o=0,a=0,s=this.delimiter,u=s.length;if(\"string\"==typeof e)if(-1!==(r=e.indexOf(s))){i=new Array(5);do{i[o++]=e.slice(a,r),a=r+u}while(-1!==(r=e.indexOf(s,a)));i[o++]=e.slice(a)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+10&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,d.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}function k(e,t,n,r){for(var i,o,a,s,l=u(e),c=l.length,d=e._listeners;c-- >0;)i=e[o=l[c]],a=\"_listeners\"===o?n:n?n.concat(o):[o],s=r||\"symbol\"==typeof o,d&&t.push(s?a:a.join(this.delimiter)),\"object\"==typeof i&&k.call(this,i,t,a,s);return t}function M(e){for(var t,n,r,i=u(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,\"_listeners\"===n||M(t)||delete e[n]);return r}function C(e,t,n){this.emitter=e,this.event=t,this.listener=n}function x(e,n,r){if(!0===r)a=!0;else if(!1===r)o=!0;else{if(!r||\"object\"!=typeof r)throw TypeError(\"options should be an object or true\");var o=r.async,a=r.promisify,u=r.nextTick,l=r.objectify}if(o||u||a){var c=n,d=n._origin||n;if(u&&!i)throw Error(\"process.nextTick is not supported\");a===t&&(a=\"AsyncFunction\"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?u?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,c.apply(t,e)})):(u?Ee:s)((function(){t.event=n,c.apply(t,e)}))},n._async=!0,n._origin=d}return[n,l?new C(this,e,n):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,e)}C.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},A.EventEmitter2=A,A.prototype.listenTo=function(e,n,i){if(\"object\"!=typeof e)throw TypeError(\"target musts be an object\");var o=this;function a(t){if(\"object\"!=typeof t)throw TypeError(\"events must be an object\");var n,r=i.reducers,a=_.call(o,e);n=-1===a?new p(o,e,i):o._observers[a];for(var s,l=u(t),c=l.length,d=\"function\"==typeof r,f=0;f0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},A.prototype.delimiter=\".\",A.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event=\"\",A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.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 a(){return 0==--t&&o.off(e,a),n.apply(this,arguments)}return a._origin=n,this._on(e,a,r,i)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var e,t,n,r,i,a,s=arguments[0],u=this.wildcard;if(\"newListener\"===s&&!this._newListener&&!this._events.newListener)return!1;if(u&&(e=s,\"newListener\"!==s&&\"removeListener\"!==s&&\"object\"==typeof s)){if(n=s.length,o)for(r=0;r3)for(t=new Array(d-1),i=1;i3)for(n=new Array(f-1),a=1;a0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=n,a)},A.prototype.off=function(e,t){if(\"function\"!=typeof t)throw new Error(\"removeListener only takes instances of Function\");var n,i=[];if(this.wildcard){var o=\"string\"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var a=0;a0){for(n=0,r=(t=this._all).length;n0;)\"function\"==typeof(r=s[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var l=[],c=\"string\"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,l,c,a,0),l}return s&&(r=s[e])?\"function\"==typeof r?[r]:r:[]},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?k.call(this,this.listenerTree,[],null,e):t?u(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(e){if(this.wildcard){var n=[],r=\"string\"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?u(i).length:i[e]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(e,n){var r=this,i=typeof n;return\"number\"===i?n={timeout:n}:\"function\"===i&&(n={filter:n}),w((n=m(n,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:b,Promise:g})).Promise,(function(t,i,o){function a(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(e,a),n.handleError){var s=arguments[0];s?i(s):t(f.apply(null,arguments).slice(1))}else t(f.apply(null,arguments))}o((function(){r.off(e,a)})),r._on(e,a,!1)}),{timeout:n.timeout,overload:n.overload})};var R=A.prototype;Object.defineProperties(A,{defaultMaxListeners:{get:function(){return R._maxListeners},set:function(e){if(\"number\"!=typeof e||e<0||Number.isNaN(e))throw TypeError(\"n must be a non-negative number\");R._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=m(n,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,(function(n,r,i){var o;if(\"function\"==typeof e.addEventListener)return o=function(){n(f.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var a,s=function(){a&&e.removeListener(\"error\",a),n(f.apply(null,arguments))};\"error\"!==t&&(a=function(n){e.removeListener(t,s),r(n)},e.once(\"error\",a)),i((function(){a&&e.removeListener(\"error\",a),e.removeListener(t,s)})),e.once(t,s)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(R,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),\"function\"==typeof t&&t.amd?t((function(){return A})):e.exports=A}()}(Mw);var Cw,xw=Mw.exports,Aw=new Uint8Array(16);function Rw(){if(!Cw&&!(Cw=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||\"undefined\"!=typeof msCrypto&&\"function\"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return Cw(Aw)}var Tw=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Pw(e){return\"string\"==typeof e&&Tw.test(e)}for(var Lw=[],Iw=0;Iw<256;++Iw)Lw.push((Iw+256).toString(16).substr(1));function Ow(e,t,n){var r=(e=e||{}).random||(e.rng||Rw)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Lw[e[t+0]]+Lw[e[t+1]]+Lw[e[t+2]]+Lw[e[t+3]]+\"-\"+Lw[e[t+4]]+Lw[e[t+5]]+\"-\"+Lw[e[t+6]]+Lw[e[t+7]]+\"-\"+Lw[e[t+8]]+Lw[e[t+9]]+\"-\"+Lw[e[t+10]]+Lw[e[t+11]]+Lw[e[t+12]]+Lw[e[t+13]]+Lw[e[t+14]]+Lw[e[t+15]]).toLowerCase();if(!Pw(n))throw TypeError(\"Stringified UUID is invalid\");return n}(r)}const Nw=Object.create(null);Nw.open=\"0\",Nw.close=\"1\",Nw.ping=\"2\",Nw.pong=\"3\",Nw.message=\"4\",Nw.upgrade=\"5\",Nw.noop=\"6\";const Dw=Object.create(null);Object.keys(Nw).forEach((e=>{Dw[Nw[e]]=e}));const jw={type:\"error\",data:\"parser error\"},Bw=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),zw=\"function\"==typeof ArrayBuffer,Uw=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Fw=({type:e,data:t},n,r)=>Bw&&t instanceof Blob?n?r(t):Kw(t,r):zw&&(t instanceof ArrayBuffer||Uw(t))?n?r(t):Kw(new Blob([t]),r):r(Nw[e]+(t||\"\")),Kw=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(\",\")[1];t(\"b\"+(e||\"\"))},n.readAsDataURL(e)};function qw(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Hw;function Ww(e,t){return Bw&&e.data instanceof Blob?e.data.arrayBuffer().then(qw).then(t):zw&&(e.data instanceof ArrayBuffer||Uw(e.data))?t(qw(e.data)):void Fw(e,!1,(e=>{Hw||(Hw=new TextEncoder),t(Hw.encode(e))}))}const $w=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Vw=\"undefined\"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)Vw[$w.charCodeAt(e)]=e;const Yw=\"function\"==typeof ArrayBuffer,Gw=(e,t)=>{if(\"string\"!=typeof e)return{type:\"message\",data:Qw(e,t)};const n=e.charAt(0);if(\"b\"===n)return{type:\"message\",data:Zw(e.substring(1),t)};return Dw[n]?e.length>1?{type:Dw[n],data:e.substring(1)}:{type:Dw[n]}:jw},Zw=(e,t)=>{if(Yw){const n=(e=>{let t,n,r,i,o,a=.75*e.length,s=e.length,u=0;\"=\"===e[e.length-1]&&(a--,\"=\"===e[e.length-2]&&a--);const l=new ArrayBuffer(a),c=new Uint8Array(l);for(t=0;t>4,c[u++]=(15&r)<<4|i>>2,c[u++]=(3&i)<<6|63&o;return l})(e);return Qw(n,t)}return{base64:!0,data:e}},Qw=(e,t)=>\"blob\"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,Jw=String.fromCharCode(30);let Xw;function e_(e){if(e)return function(e){for(var t in e_.prototype)e[t]=e_.prototype[t];return e}(e)}e_.prototype.on=e_.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+e]=this._callbacks[\"$\"+e]||[]).push(t),this},e_.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},e_.prototype.off=e_.prototype.removeListener=e_.prototype.removeAllListeners=e_.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(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const r_=t_.setTimeout,i_=t_.clearTimeout;function o_(e,t){t.useNativeTimers?(e.setTimeoutFn=r_.bind(t_),e.clearTimeoutFn=i_.bind(t_)):(e.setTimeoutFn=t_.setTimeout.bind(t_),e.clearTimeoutFn=t_.clearTimeout.bind(t_))}class a_ extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=\"TransportError\"}}class s_ extends e_{constructor(e){super(),this.writable=!1,o_(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved(\"error\",new a_(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=Gw(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 u_=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),l_=64,c_={};let d_,f_=0,h_=0;function p_(e){let t=\"\";do{t=u_[e%l_]+t,e=Math.floor(e/l_)}while(e>0);return t}function m_(){const e=p_(+new Date);return e!==d_?(f_=0,d_=e):e+\".\"+p_(f_++)}for(;h_{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=__.requestsCount++,__.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=y_,e)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete __.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(__.requestsCount=0,__.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",S_);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in t_?\"pagehide\":\"unload\",S_,!1)}function S_(){for(let e in __.requests)__.requests.hasOwnProperty(e)&&__.requests[e].abort()}const E_=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),k_=t_.WebSocket||t_.MozWebSocket,M_=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();function C_(e,t){return\"message\"===e.type&&\"string\"!=typeof e.data&&t[0]>=48&&t[0]<=54}const x_={websocket:class extends s_{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=M_?{}:n_(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=M_?new k_(e,t,n):t?new k_(e,t):new k_(e)}catch(e){return this.emitReserved(\"error\",e)}this.ws.binaryType=this.socket.binaryType||\"arraybuffer\",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{try{this.ws.send(e)}catch(e){}r&&E_((()=>{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]=m_()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!k_}},webtransport:class extends s_{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=e.readable.getReader();let n;this.writer=e.writable.getWriter();const r=()=>{t.read().then((({done:e,value:t})=>{e||(n||1!==t.byteLength||54!==t[0]?(this.onPacket(function(e,t,n){Xw||(Xw=new TextDecoder);const r=t||e[0]<48||e[0]>54;return Gw(r?e:Xw.decode(e),n)}(t,n,\"arraybuffer\")),n=!1):n=!0,r())})).catch((e=>{}))};r();const i=this.query.sid?`0{\"sid\":\"${this.query.sid}\"}`:\"0\";this.writer.write((new TextEncoder).encode(i)).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t{C_(n,e)&&this.writer.write(Uint8Array.of(54)),this.writer.write(e).then((()=>{r&&E_((()=>{this.writable=!0,this.emitReserved(\"drain\")}),this.setTimeoutFn)}))}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends s_{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=w_&&!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(Jw),r=[];for(let e=0;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)=>{Fw(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(Jw))}))}))})(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]=m_()),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 __(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}}},A_=/^(?:(?![^:@\\/?#]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@\\/?#]*)(?::([^:@\\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,R_=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function T_(e){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=A_.exec(e||\"\"),o={},a=14;for(;a--;)o[R_[a]]=i[a]||\"\";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}let P_=class e extends e_{constructor(e,t={}){super(),this.writeBuffer=[],e&&\"object\"==typeof e&&(t=e,e=null),e?(e=T_(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=T_(t.host).host),o_(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{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 x_[e](n)}open(){let t;if(this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved(\"error\",\"No transports available\")}),0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}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(t){let n=this.createTransport(t),r=!1;e.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:\"ping\",data:\"probe\"}]),n.once(\"packet\",(t=>{if(!r)if(\"pong\"===t.type&&\"probe\"===t.data){if(this.upgrading=!0,this.emitReserved(\"upgrading\",n),!n)return;e.priorWebsocketSuccess=\"websocket\"===n.name,this.transport.pause((()=>{r||\"closed\"!==this.readyState&&(c(),this.setTransport(n),n.send([{type:\"upgrade\"}]),this.emitReserved(\"upgrade\",n),n=null,this.upgrading=!1,this.flush())}))}else{const e=new Error(\"probe error\");e.transport=n.name,this.emitReserved(\"upgradeError\",e)}})))};function o(){r||(r=!0,c(),n.close(),n=null)}const a=e=>{const t=new Error(\"probe error: \"+e);t.transport=n.name,o(),this.emitReserved(\"upgradeError\",t)};function s(){a(\"transport closed\")}function u(){a(\"socket closed\")}function l(e){n&&e.name!==n.name&&o()}const c=()=>{n.removeListener(\"open\",i),n.removeListener(\"error\",a),n.removeListener(\"close\",s),this.off(\"close\",u),this.off(\"upgrading\",l)};n.once(\"open\",i),n.once(\"error\",a),n.once(\"close\",s),this.once(\"close\",u),this.once(\"upgrading\",l),-1!==this.upgrades.indexOf(\"webtransport\")&&\"webtransport\"!==t?this.setTimeoutFn((()=>{r||n.open()}),200):n.open()}onOpen(){if(this.readyState=\"open\",e.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{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=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(t){e.priorWebsocketSuccess=!1,this.emitReserved(\"error\",t),this.onClose(\"transport error\",t)}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\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,O_=Object.prototype.toString,N_=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===O_.call(Blob),D_=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===O_.call(File);function j_(e){return L_&&(e instanceof ArrayBuffer||I_(e))||N_&&e instanceof Blob||D_&&e instanceof File}function B_(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t=0&&e.num{delete this.acks[e];for(let t=0;t{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:H_.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 H_.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 H_.EVENT:case H_.BINARY_EVENT:this.onevent(e);break;case H_.ACK:case H_.BINARY_ACK:this.onack(e);break;case H_.DISCONNECT:this.ondisconnect();break;case H_.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:H_.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:H_.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;n0&&e.jitter<=1?e.jitter:0,this.attempts=0}J_.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)},J_.prototype.reset=function(){this.attempts=0},J_.prototype.setMin=function(e){this.ms=e},J_.prototype.setMax=function(e){this.max=e},J_.prototype.setJitter=function(e){this.jitter=e};class X_ extends e_{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,o_(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 J_({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||Y_;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 P_(this.uri,this.opts);const t=this.engine,n=this;this._readyState=\"opening\",this.skipReconnect=!1;const r=G_(t,\"open\",(function(){n.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState=\"closed\",this.emitReserved(\"error\",t),e?e(t):this.maybeReconnectOnOpen()},o=G_(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(G_(e,\"ping\",this.onping.bind(this)),G_(e,\"data\",this.ondata.bind(this)),G_(e,\"error\",this.onerror.bind(this)),G_(e,\"close\",this.onclose.bind(this)),G_(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){E_((()=>{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 Q_(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;ne())),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 eS={};function tS(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=T_(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,a=eS[i]&&o in eS[i].nsps;let s;return t.forceNew||t[\"force new connection\"]||!1===t.multiplex||a?s=new X_(r,t):(eS[i]||(eS[i]=new X_(r,t)),s=eS[i]),n.query&&!t.query&&(t.query=n.queryKey),s.socket(n.path,t)}function nS(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}Object.assign(tS,{Manager:X_,Socket:Q_,io:tS,connect:tS}),\"function\"==typeof SuppressedError&&SuppressedError;var rS=void 0!==t?t:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{};function iS(){throw new Error(\"setTimeout has not been defined\")}function oS(){throw new Error(\"clearTimeout has not been defined\")}var aS=iS,sS=oS;function uS(e){if(aS===setTimeout)return setTimeout(e,0);if((aS===iS||!aS)&&setTimeout)return aS=setTimeout,setTimeout(e,0);try{return aS(e,0)}catch(t){try{return aS.call(null,e,0)}catch(t){return aS.call(this,e,0)}}}\"function\"==typeof rS.setTimeout&&(aS=setTimeout),\"function\"==typeof rS.clearTimeout&&(sS=clearTimeout);var lS,cS=[],dS=!1,fS=-1;function hS(){dS&&lS&&(dS=!1,lS.length?cS=lS.concat(cS):fS=-1,cS.length&&pS())}function pS(){if(!dS){var e=uS(hS);dS=!0;for(var t=cS.length;t;){for(lS=cS,cS=[];++fS1)for(var n=1;n{if(\"%%\"===r)return\"%\";a++;const o=t.formatters[i];if(\"function\"==typeof o){const t=e[a];r=o.call(n,t),e.splice(a,1),a--}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof t.init&&t.init(s),s}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){return e instanceof Error?e.stack||e.message: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=1.5*n;return Math.round(e/n)+\" \"+r+(i?\"s\":\"\")}return AS=function(o,a){a=a||{};var s=typeof o;if(\"string\"===s&&o.length>0)return function(i){if(!((i=String(i)).length>100)){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){var a=parseFloat(o[1]);switch((o[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return 315576e5*a;case\"weeks\":case\"week\":case\"w\":return 6048e5*a;case\"days\":case\"day\":case\"d\":return a*r;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return a*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return a*t;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return a*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return a;default:return}}}}(o);if(\"number\"===s&&isFinite(o))return a.long?function(o){var a=Math.abs(o);return a>=r?i(o,a,r,\"day\"):a>=n?i(o,a,n,\"hour\"):a>=t?i(o,a,t,\"minute\"):a>=e?i(o,a,e,\"second\"):o+\" ms\"}(o):function(i){var o=Math.abs(i);return o>=r?Math.round(i/r)+\"d\":o>=n?Math.round(i/n)+\"h\":o>=t?Math.round(i/t)+\"m\":o>=e?Math.round(i/e)+\"s\":i+\"ms\"}(o);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(o))}}(),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&&(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){}return!e&&void 0!==xS&&\"env\"in xS&&(e=xS.env.DEBUG),e},t.useColors=function(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"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=PS(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}}(TS,TS.exports);var LS=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,\"default\")?e.default:e}(TS.exports);const IS=LS(\"KeyExchange:Layer\"),OS=LS(\"SocketService:Layer\"),NS=LS(\"Ecies:Layer\"),DS=LS(\"RemoteCommunication:Layer\");IS.color=\"##95c44e\",OS.color=\"#f638d7\",NS.color=\"#465b9c\",DS.color=\"#47a2be\";const jS={KeyExchange:IS,SocketService:OS,Ecies:NS,RemoteCommunication:DS};let BS,zS=[],US=[];function FS(e){return nS(this,void 0,void 0,(function*(){if(!BS||!e)return;!function(){const e=US;US=zS,zS=e}();const t=BS.endsWith(\"/\")?`${BS}evt`:`${BS}/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);jS.RemoteCommunication(`[sendBufferedEvents] Sending ${zS.length} analytics events to ${t}`);try{const e=yield a(t,{method:\"POST\",headers:{Accept:\"application/json\",\"Content-Type\":\"application/json\"},body:r}),n=yield e.text();jS.RemoteCommunication(`[sendBufferedEvents] Response: ${n}`),zS.length=0}catch(e){console.warn(\"Error sending analytics\",e)}}))}const KS=(e,t)=>nS(void 0,void 0,void 0,(function*(){var n;BS=t,n=e,US.push(n),FS(e).catch((()=>{}))}));var qS=[],HS=[],WS=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,$S=!1;function VS(){$S=!0;for(var e=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",t=0;t<64;++t)qS[t]=e[t],HS[e.charCodeAt(t)]=t;HS[\"-\".charCodeAt(0)]=62,HS[\"_\".charCodeAt(0)]=63}function YS(e,t,n){for(var r,i,o=[],a=t;a>18&63]+qS[i>>12&63]+qS[i>>6&63]+qS[63&i]);return o.join(\"\")}function GS(e){var t;$S||VS();for(var n=e.length,r=n%3,i=\"\",o=[],a=16383,s=0,u=n-r;su?u:s+a));return 1===r?(t=e[n-1],i+=qS[t>>2],i+=qS[t<<4&63],i+=\"==\"):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=qS[t>>10],i+=qS[t>>4&63],i+=qS[t<<2&63],i+=\"=\"),o.push(i),o.join(\"\")}function ZS(e,t,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,c=-7,d=n?i-1:0,f=n?-1:1,h=e[t+d];for(d+=f,o=h&(1<<-c)-1,h>>=-c,c+=s;c>0;o=256*o+e[t+d],d+=f,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+d],d+=f,c-=8);if(0===o)o=1-l;else{if(o===u)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),o-=l}return(h?-1:1)*a*Math.pow(2,o-r)}function QS(e,t,n,r,i,o){var a,s,u,l=8*o-i-1,c=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+d>=1?f/u:f*Math.pow(2,1-d))*u>=2&&(a++,u/=2),a+d>=c?(s=0,a=c):a+d>=1?(s=(t*u-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[n+h]=255&s,h+=p,s/=256,i-=8);for(a=a<0;e[n+h]=255&a,h+=p,a/=256,l-=8);e[n+h-p]|=128*m}var JS={}.toString,XS=Array.isArray||function(e){return\"[object Array]\"==JS.call(e)};function eE(){return nE.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function tE(e,t){if(eE()=eE())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+eE().toString(16)+\" bytes\");return 0|e}function uE(e){return!(null==e||!e._isBuffer)}function lE(e,t){if(uE(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 DE(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*n;case\"hex\":return n>>>1;case\"base64\":return jE(e).length;default:if(r)return DE(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function cE(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 ME(this,t,n);case\"utf8\":case\"utf-8\":return _E(this,t,n);case\"ascii\":return EE(this,t,n);case\"latin1\":case\"binary\":return kE(this,t,n);case\"base64\":return wE(this,t,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return CE(this,t,n);default:if(r)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),r=!0}}function dE(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function fE(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=nE.from(t,r)),uE(t))return 0===t.length?-1:hE(e,t,n,r,i);if(\"number\"==typeof t)return t&=255,nE.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):hE(e,[t],n,r,i);throw new TypeError(\"val must be string, number or Buffer\")}function hE(e,t,n,r,i){var o,a=1,s=e.length,u=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;a=2,s/=2,u/=2,n/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=n;os&&(n=s-u),o=n;o>=0;o--){for(var d=!0,f=0;fi&&(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 a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function wE(e,t,n){return 0===t&&n===e.length?GS(e):GS(e.slice(t,n))}function _E(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(c=l);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&l)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,d=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=d}return function(e){var t=e.length;if(t<=SE)return String.fromCharCode.apply(String,e);for(var n=\"\",r=0;r0&&(e=this.toString(\"hex\",0,50).match(/.{2}/g).join(\" \"),this.length>50&&(e+=\" ... \")),\"\"},nE.prototype.compare=function(e,t,n,r,i){if(!uE(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),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(r,i),l=e.slice(t,n),c=0;ci)&&(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 pE(this,e,t,n);case\"utf8\":case\"utf-8\":return mE(this,e,t,n);case\"ascii\":return gE(this,e,t,n);case\"latin1\":case\"binary\":return vE(this,e,t,n);case\"base64\":return bE(this,e,t,n);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return yE(this,e,t,n);default:if(o)throw new TypeError(\"Unknown encoding: \"+r);r=(\"\"+r).toLowerCase(),o=!0}},nE.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var SE=4096;function EE(e,t,n){var r=\"\";n=Math.min(e.length,n);for(var i=t;ir)&&(n=r);for(var i=\"\",o=t;on)throw new RangeError(\"Trying to access beyond buffer length\")}function AE(e,t,n,r,i,o){if(!uE(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError(\"Index out of range\")}function RE(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function TE(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function PE(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 LE(e,t,n,r,i){return i||PE(e,0,n,4),QS(e,t,n,r,23,4),n+4}function IE(e,t,n,r,i){return i||PE(e,0,n,8),QS(e,t,n,r,52,8),n+8}nE.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),t0&&(i*=256);)r+=this[e+--t]*i;return r},nE.prototype.readUInt8=function(e,t){return t||xE(e,1,this.length),this[e]},nE.prototype.readUInt16LE=function(e,t){return t||xE(e,2,this.length),this[e]|this[e+1]<<8},nE.prototype.readUInt16BE=function(e,t){return t||xE(e,2,this.length),this[e]<<8|this[e+1]},nE.prototype.readUInt32LE=function(e,t){return t||xE(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},nE.prototype.readUInt32BE=function(e,t){return t||xE(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},nE.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||xE(e,t,this.length);for(var r=this[e],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*t)),r},nE.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||xE(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},nE.prototype.readInt8=function(e,t){return t||xE(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},nE.prototype.readInt16LE=function(e,t){t||xE(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},nE.prototype.readInt16BE=function(e,t){t||xE(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},nE.prototype.readInt32LE=function(e,t){return t||xE(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},nE.prototype.readInt32BE=function(e,t){return t||xE(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},nE.prototype.readFloatLE=function(e,t){return t||xE(e,4,this.length),ZS(this,e,!0,23,4)},nE.prototype.readFloatBE=function(e,t){return t||xE(e,4,this.length),ZS(this,e,!1,23,4)},nE.prototype.readDoubleLE=function(e,t){return t||xE(e,8,this.length),ZS(this,e,!0,52,8)},nE.prototype.readDoubleBE=function(e,t){return t||xE(e,8,this.length),ZS(this,e,!1,52,8)},nE.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||AE(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},nE.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,1,255,0),nE.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},nE.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,2,65535,0),nE.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):RE(this,e,t,!0),t+2},nE.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,2,65535,0),nE.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):RE(this,e,t,!1),t+2},nE.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,4,4294967295,0),nE.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):TE(this,e,t,!0),t+4},nE.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,4,4294967295,0),nE.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):TE(this,e,t,!1),t+4},nE.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);AE(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+n},nE.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);AE(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},nE.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,1,127,-128),nE.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},nE.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,2,32767,-32768),nE.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):RE(this,e,t,!0),t+2},nE.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,2,32767,-32768),nE.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):RE(this,e,t,!1),t+2},nE.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,4,2147483647,-2147483648),nE.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):TE(this,e,t,!0),t+4},nE.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||AE(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),nE.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):TE(this,e,t,!1),t+4},nE.prototype.writeFloatLE=function(e,t,n){return LE(this,e,t,!0,n)},nE.prototype.writeFloatBE=function(e,t,n){return LE(this,e,t,!1,n)},nE.prototype.writeDoubleLE=function(e,t,n){return IE(this,e,t,!0,n)},nE.prototype.writeDoubleBE=function(e,t,n){return IE(this,e,t,!1,n)},nE.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=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=0;--i)e[i+t]=this[i+n];else if(o<1e3||!nE.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),\"number\"==typeof e)for(o=t;o55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+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 jE(e){return function(e){var t,n,r,i,o,a;$S||VS();var s=e.length;if(s%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");o=\"=\"===e[s-2]?2:\"=\"===e[s-1]?1:0,a=new WS(3*s/4-o),r=o>0?s-4:s;var u=0;for(t=0,n=0;t>16&255,a[u++]=i>>8&255,a[u++]=255&i;return 2===o?(i=HS[e.charCodeAt(t)]<<2|HS[e.charCodeAt(t+1)]>>4,a[u++]=255&i):1===o&&(i=HS[e.charCodeAt(t)]<<10|HS[e.charCodeAt(t+1)]<<4|HS[e.charCodeAt(t+2)]>>2,a[u++]=i>>8&255,a[u++]=255&i),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\\s+|\\s+$/g,\"\")}(e).replace(OE,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function BE(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function zE(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}class UE{constructor(e){this.enabled=!0,(null==e?void 0:e.debug)&&LS.enable(\"Ecies:Layer\"),(null==e?void 0:e.privateKey)?this.ecies=se.PrivateKey.fromHex(e.privateKey):this.ecies=new se.PrivateKey,jS.Ecies(\"[ECIES constructor()] initialized secret: \",this.ecies.toHex()),jS.Ecies(\"[ECIES constructor()] initialized public: \",this.ecies.publicKey.toHex()),jS.Ecies(\"[ECIES constructor()] init with\",this)}generateECIES(){this.ecies=new se.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,t){let n=e;if(this.enabled)try{jS.Ecies(\"[ECIES: encrypt()] using otherPublicKey\",t);const r=nE.from(e),i=se.encrypt(t,r);n=nE.from(i).toString(\"base64\")}catch(n){throw jS.Ecies(\"[ECIES: encrypt()] error encrypt:\",n),jS.Ecies(\"[ECIES: encrypt()] private: \",this.ecies.toHex()),jS.Ecies(\"[ECIES: encrypt()] data: \",e),jS.Ecies(\"[ECIES: encrypt()] otherkey: \",t),n}return n}decrypt(e){let t=e;if(this.enabled)try{jS.Ecies(\"[ECIES: decrypt()] using privateKey\",this.ecies.toHex());const n=nE.from(e.toString(),\"base64\");t=se.decrypt(this.ecies.toHex(),n).toString()}catch(t){throw jS.Ecies(\"[ECIES: decrypt()] error decrypt\",t),jS.Ecies(\"[ECIES: decrypt()] private: \",this.ecies.toHex()),jS.Ecies(\"[ECIES: decrypt()] encryptedData: \",e),t}return t}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){jS.Ecies(\"[ECIES: toString()]\",this.getKeyInfo())}}var FE={name:\"@metamask/sdk-communication-layer\",version:\"0.30.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/browser/es/src/index.d.ts\",files:[\"/dist\"],scripts:{build:\"rimraf dist && rollup -c --bundleConfigAsCjs\",\"build:tsc\":\"tsc\",\"build:dev\":\"rimraf dist && NODE_ENV=dev rollup -c --bundleConfigAsCjs\",\"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-terser\":\"^0.4.1\",\"@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\",\"cross-fetch\":\"^4.0.0\",eciesjs:\"^0.3.16\",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.7\",jest:\"^29.3.1\",prettier:\"^2.3.0\",rimraf:\"^3.0.2\",rollup:\"^3.21.7\",\"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-sizes\":\"^1.0.6\",\"rollup-plugin-typescript2\":\"^0.31.2\",\"rollup-plugin-visualizer\":\"^5.9.2\",\"size-limit\":\"^11.0.2\",\"socket.io-client\":\"^4.5.1\",\"stream-browserify\":\"^3.0.0\",\"ts-jest\":\"^29.0.3\",\"ts-node\":\"^10.9.1\",typescript:\"^4.3.2\"},peerDependencies:{\"cross-fetch\":\"^4.0.0\",eciesjs:\"^0.3.16\",eventemitter2:\"^6.4.7\",\"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 KE=\"https://metamask-sdk.api.cx.metamask.io/\",qE=[\"websocket\"],HE=6048e5,WE=3e3,$E={METAMASK_GETPROVIDERSTATE:\"metamask_getProviderState\",ETH_REQUESTACCOUNTS:\"eth_requestAccounts\"};function VE(e){const{context:t}=e;jS.RemoteCommunication(`[RemoteCommunication: clean()] context=${t}`),e.channelConfig=void 0,e.ready=!1,e.originatorConnectStarted=!1}var YE,GE,ZE;e.ConnectionStatus=void 0,e.EventType=void 0,e.MessageType=void 0,function(e){e.DISCONNECTED=\"disconnected\",e.WAITING=\"waiting\",e.TIMEOUT=\"timeout\",e.LINKED=\"linked\",e.PAUSED=\"paused\",e.TERMINATED=\"terminated\"}(e.ConnectionStatus||(e.ConnectionStatus={})),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\"}(e.EventType||(e.EventType={})),function(e){e.KEY_EXCHANGE=\"key_exchange\"}(YE||(YE={})),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\"}(GE||(GE={}));class QE extends xw.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:t,context:n,ecies:r,logging:i}){super(),this.keysExchanged=!1,this.step=GE.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=n,this.communicationLayer=e,(null==r?void 0:r.privateKey)&&t&&(jS.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${t} set keysExchanged to true!`,r),this.keysExchanged=!0),this.myECIES=new UE(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(YE.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(t){const{relayPersistence:n}=this.communicationLayer.remote.state;if(jS.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${n}`,t),n)return void jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated\");const{message:r}=t;this.keysExchanged&&jS.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(e.EventType.KEY_INFO,r.type),r.type===GE.KEY_HANDSHAKE_SYN?(this.checkStep([GE.KEY_HANDSHAKE_NONE,GE.KEY_HANDSHAKE_ACK]),jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN\",r),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:GE.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((e=>{jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK\",e)})),this.setStep(GE.KEY_HANDSHAKE_ACK)):r.type===GE.KEY_HANDSHAKE_SYNACK?(this.checkStep([GE.KEY_HANDSHAKE_SYNACK,GE.KEY_HANDSHAKE_ACK,GE.KEY_HANDSHAKE_NONE]),jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK\"),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:GE.KEY_HANDSHAKE_ACK}).catch((e=>{jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK\",e)})),this.keysExchanged=!0,this.setStep(GE.KEY_HANDSHAKE_ACK),this.emit(e.EventType.KEYS_EXCHANGED)):r.type===GE.KEY_HANDSHAKE_ACK&&(jS.KeyExchange(\"[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!\"),this.checkStep([GE.KEY_HANDSHAKE_ACK,GE.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(GE.KEY_HANDSHAKE_ACK),this.emit(e.EventType.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new UE(e)}clean(){jS.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(GE.KEY_HANDSHAKE_NONE),this.emit(e.EventType.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:t}){const{relayPersistence:n,protocolVersion:r}=this.communicationLayer.remote.state,i=r>=2;if(n)return jS.KeyExchange(\"[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated\"),void console.log(`[KeyExchange: start()] relayPersistence=${n}`);jS.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!==GE.KEY_HANDSHAKE_NONE&&this.step!==GE.KEY_HANDSHAKE_SYNACK)||t?(jS.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${t}) -- step=${this.step}`,this.step),this.clean(),this.setStep(GE.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:GE.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((e=>{jS.KeyExchange(\"[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN\",e)}))):jS.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?\"done\":\"in progress\"} -- aborted.`,this.step):this.keysExchanged&&!0!==t?jS.KeyExchange(\"[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done.\"):i?this.communicationLayer.sendMessage({type:GE.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((e=>{jS.KeyExchange(\"[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK\",e)})):(this.communicationLayer.sendMessage({type:GE.KEY_HANDSHAKE_START}).catch((e=>{jS.KeyExchange(\"[KeyExchange: start()] Error sending KEY_HANDSHAKE_START\",e)})),this.clean())}setStep(t){this.step=t,this.emit(e.EventType.KEY_INFO,t)}checkStep(e){e.length>0&&-1===e.indexOf(this.step.toString())&&console.warn(`[KeyExchange: checkStep()] Wrong Step \"${this.step}\" not within ${e}`)}setRelayPersistence({localKey:e,otherKey:t}){this.otherPublicKey=t,this.myECIES=new UE({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){jS.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\"}(e.MessageType||(e.MessageType={})),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\"}(ZE||(ZE={}));const JE=(t,n,r)=>nS(void 0,void 0,void 0,(function*(){var i,o,a,s,u,l;const{remote:c,state:d}=t,{channelId:f,isOriginator:h}=d;if(\"error_terminated\"===n)return jS.SocketService(`handleJoinChannelResults: Channel ${f} terminated`),void t.emit(e.EventType.TERMINATE);if(!r)return void jS.SocketService(`handleJoinChannelResults: No result for channel ${f}`);const{persistence:p,walletKey:m,rejected:g}=r;if(jS.SocketService(`handleJoinChannelResults: Channel ${f} persistence=${p} walletKey=${m} rejected=${g}`),g)return jS.SocketService(`handleJoinChannelResults: Channel ${f} rejected`),yield t.remote.disconnect({terminate:!0}),t.remote.emit(e.EventType.REJECTED,{channelId:f}),void t.remote.emitServiceStatusEvent();if(m&&!(null===(i=c.state.channelConfig)||void 0===i?void 0:i.otherKey)){t.getKeyExchange().setOtherPublicKey(m),null===(o=t.state.keyExchange)||void 0===o||o.setKeysExchanged(!0),c.state.ready=!0,c.state.authorized=!0,c.emit(e.EventType.AUTHORIZED);const{communicationLayer:n,storageManager:r}=c.state,i=Object.assign(Object.assign({},c.state.channelConfig),{channelId:null!==(a=c.state.channelId)&&void 0!==a?a:\"\",validUntil:Date.now()+HE,localKey:null==n?void 0:n.getKeyInfo().ecies.private,otherKey:m});t.sendMessage({type:GE.KEY_HANDSHAKE_ACK}).catch((e=>{console.error(e)})),null===(s=t.state.socket)||void 0===s||s.emit(e.MessageType.PING,{id:f,clientType:h?\"dapp\":\"wallet\",context:\"on_channel_reconnect\",message:\"\"}),yield null==r?void 0:r.persistChannelConfig(i),c.emitServiceStatusEvent(),c.setConnectionStatus(e.ConnectionStatus.LINKED)}p&&(t.emit(e.EventType.CHANNEL_PERSISTENCE),null===(u=t.state.keyExchange)||void 0===u||u.setKeysExchanged(!0),c.state.ready=!0,c.state.authorized=!0,c.emit(e.EventType.AUTHORIZED),KS(Object.assign(Object.assign({id:null!=f?f:\"\",event:h?ZE.CONNECTED:ZE.CONNECTED_MOBILE},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:FE.version,walletVersion:null===(l=t.remote.state.walletInfo)||void 0===l?void 0:l.version}),d.communicationServerUrl).catch((e=>{console.error(\"Cannot send analytics\",e)})))})),XE=e=>new Promise((t=>{setTimeout(t,e)})),ek=(e,t,n=200)=>nS(void 0,void 0,void 0,(function*(){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 XE(n)}throw new Error(`RPC ${e} timed out`)})),tk=t=>nS(void 0,void 0,void 0,(function*(){const{state:n}=t,{socket:r,channelId:i,context:o,isOriginator:a,isReconnecting:s}=n;if(s)return jS.SocketService(\"[SocketService: reconnectSocket()] Reconnection already in progress, skipping\",t),!1;if(!r)return jS.SocketService(\"[SocketService: reconnectSocket()] socket is not defined\",t),!1;if(!i)return!1;const{connected:u}=r;n.isReconnecting=!0,n.reconnectionAttempts=0,jS.SocketService(`[SocketService: reconnectSocket()] connected=${u} trying to reconnect after socketio disconnection`,t);try{for(;n.reconnectionAttempts<3;){if(jS.SocketService(`[SocketService: reconnectSocket()] Attempt ${n.reconnectionAttempts+1} of 3`,t),yield XE(200),r.connected)return jS.SocketService(\"Socket already connected --- ping to retrieve messages\"),r.emit(e.MessageType.PING,{id:i,clientType:a?\"dapp\":\"wallet\",context:\"on_channel_config\",message:\"\"}),!0;n.resumed=!0,r.connect(),t.emit(e.EventType.SOCKET_RECONNECT);try{if(yield new Promise(((n,s)=>{r.emit(e.EventType.JOIN_CHANNEL,{channelId:i,context:`${o}connect_again`,clientType:a?\"dapp\":\"wallet\"},((e,r)=>nS(void 0,void 0,void 0,(function*(){try{yield JE(t,e,r),n()}catch(e){s(e)}}))))})),yield XE(100),r.connected)return jS.SocketService(`Reconnection successful on attempt ${n.reconnectionAttempts+1}`),!0}catch(e){jS.SocketService(`Error during reconnection attempt ${n.reconnectionAttempts+1}:`,e)}n.reconnectionAttempts+=1,n.reconnectionAttempts<3&&(yield XE(200))}return jS.SocketService(\"Failed to reconnect after 3 attempts\"),!1}finally{n.isReconnecting=!1,n.reconnectionAttempts=0}}));function nk(t,n){var r;return nS(this,void 0,void 0,(function*(){const i=null===(r=t.state.keyExchange)||void 0===r?void 0:r.encryptMessage(JSON.stringify(n)),o={id:t.state.channelId,context:t.state.context,clientType:t.state.isOriginator?\"dapp\":\"wallet\",message:i,plaintext:t.state.hasPlaintext?JSON.stringify(n):void 0};return jS.SocketService(`[SocketService: encryptAndSendMessage()] context=${t.state.context}`,o),n.type===e.MessageType.TERMINATE&&(t.state.manualDisconnect=!0),new Promise(((n,r)=>{var i;null===(i=t.state.socket)||void 0===i||i.emit(e.EventType.MESSAGE,o,((e,t)=>{var i;e&&(jS.SocketService(`[SocketService: encryptAndSendMessage()] error=${e}`),r(e)),jS.SocketService(\"[encryptAndSendMessage] response\",t),n(null!==(i=null==t?void 0:t.success)&&void 0!==i&&i)}))}))}))}var rk;!function(e){e.RPC_CHECK=\"rpcCheck\",e.SKIPPED_RPC=\"skippedRpc\"}(rk||(rk={}));const ik=[\"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()));function ok(t,n){var r,i,o;return nS(this,void 0,void 0,(function*(){if(!t.state.channelId)throw jS.SocketService(\"handleSendMessage: no channelId - Create a channel first\"),new Error(\"Create a channel first\");if(jS.SocketService(`[SocketService: handleSendMessage()] context=${t.state.context} areKeysExchanged=${null===(r=t.state.keyExchange)||void 0===r?void 0:r.areKeysExchanged()}`,n),null===(i=null==n?void 0:n.type)||void 0===i?void 0:i.startsWith(\"key_handshake\"))return function(t,n){var r;jS.SocketService(`[SocketService: handleKeyHandshake()] context=${t.state.context}`,n),null===(r=t.state.socket)||void 0===r||r.emit(e.EventType.MESSAGE,{id:t.state.channelId,context:t.state.context,clientType:t.state.isOriginator?\"dapp\":\"wallet\",message:n})}(t,n),!0;!function(e,t){var n;if(!(null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&!e.remote.state.relayPersistence)throw jS.SocketService(`[SocketService: validateKeyExchange()] context=${e.state.context} ERROR keys not exchanged`,t),console.error(\"[SocketService: validateKeyExchange()] ERROR keys not exchanged\",t),new Error(\"Keys not exchanged BBB\")}(t,n),function(t,n){var r;const i=null!==(r=null==n?void 0:n.method)&&void 0!==r?r:\"\",o=null==n?void 0:n.id;t.state.isOriginator&&o&&(t.state.rpcMethodTracker[o]={id:o,timestamp:Date.now(),method:i},t.emit(e.EventType.RPC_UPDATE,t.state.rpcMethodTracker[o]))}(t,n);const a=yield nk(t,n);return t.remote.state.analytics&&t.remote.state.isOriginator&&n.method&&ik.includes(n.method.toLowerCase())&&KS({id:null!==(o=t.remote.state.channelId)&&void 0!==o?o:\"\",event:ZE.SDK_RPC_REQUEST,params:{method:n.method,from:\"mobile\"}},t.remote.state.communicationServerUrl).catch((e=>{console.error(\"[handleSendMessage] Cannot send analytics\",e)})),function(t,n){var r;return nS(this,void 0,void 0,(function*(){const i=null==n?void 0:n.id,o=null!==(r=null==n?void 0:n.method)&&void 0!==r?r:\"\";if(t.state.isOriginator&&i)try{const r=ek(i,t.state.rpcMethodTracker,200).then((e=>({type:rk.RPC_CHECK,result:e}))),a=(()=>nS(this,void 0,void 0,(function*(){const e=yield(({rpcId:e,instance:t})=>nS(void 0,void 0,void 0,(function*(){for(;t.state.lastRpcId===e||void 0===t.state.lastRpcId;)yield XE(200);return t.state.lastRpcId})))({instance:t,rpcId:i}),n=yield ek(e,t.state.rpcMethodTracker,200);return{type:rk.SKIPPED_RPC,result:n}})))(),s=yield Promise.race([r,a]);if(s.type===rk.RPC_CHECK){const e=s.result;jS.SocketService(`[SocketService:handleRpcReplies()] id=${n.id} ${o} ( ${e.elapsedTime} ms)`,e.result)}else{if(s.type!==rk.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${i}`);{const{result:n}=s;console.warn(`[SocketService handleRpcReplies()] RPC METHOD HAS BEEN SKIPPED rpcid=${i} method=${o}`,n);const r=Object.assign(Object.assign({},t.state.rpcMethodTracker[i]),{error:new Error(\"SDK_CONNECTION_ISSUE\")});t.emit(e.EventType.RPC_UPDATE,r);const a={data:Object.assign(Object.assign({},r),{jsonrpc:\"2.0\"}),name:\"metamask-provider\"};t.emit(e.EventType.MESSAGE,{message:a})}}}catch(e){throw console.warn(`[SocketService handleRpcReplies()] Error rpcId=${n.id} ${o}`,e),e}}))}(t,n).catch((e=>{console.warn(\"[handleSendMessage] Error handleRpcReplies\",e)})),a}))}const ak=[{event:e.EventType.CLIENTS_CONNECTED,handler:function(t,n){return r=>nS(this,void 0,void 0,(function*(){var r,i,o,a,s,u,l,c,d,f,h;const p=null!==(i=null===(r=t.remote.state.channelConfig)||void 0===r?void 0:r.relayPersistence)&&void 0!==i&&i;if(jS.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected-${n}' relayPersistence=${p} resumed=${t.state.resumed} clientsPaused=${t.state.clientsPaused} keysExchanged=${null===(o=t.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged()} isOriginator=${t.state.isOriginator}`),t.emit(e.EventType.CLIENTS_CONNECTED,{isOriginator:t.state.isOriginator,keysExchanged:null===(a=t.state.keyExchange)||void 0===a?void 0:a.areKeysExchanged(),context:t.state.context}),t.state.resumed)t.state.isOriginator||(jS.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} 'clients_connected' / keysExchanged=${null===(s=t.state.keyExchange)||void 0===s?void 0:s.areKeysExchanged()} -- backward compatibility`),null===(u=t.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(l=t.state.isOriginator)&&void 0!==l&&l})),t.state.resumed=!1;else if(t.state.clientsPaused)jS.SocketService(\"[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause\");else if(!t.state.isOriginator){const e=!p;jS.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${null===(c=t.state.keyExchange)||void 0===c?void 0:c.areKeysExchanged()} -- force=${e} -- backward compatibility`),jS.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${null===(d=t.state.keyExchange)||void 0===d?void 0:d.areKeysExchanged()} -- force=${e} -- backward compatibility`),null===(f=t.state.keyExchange)||void 0===f||f.start({isOriginator:null!==(h=t.state.isOriginator)&&void 0!==h&&h,force:e})}t.state.clientsConnected=!0,t.state.clientsPaused=!1}))}},{event:e.EventType.CHANNEL_CREATED,handler:function(t,n){return r=>{jS.SocketService(`[SocketService: handleChannelCreated()] context=${t.state.context} on 'channel_created-${n}'`,r),t.emit(e.EventType.CHANNEL_CREATED,r)}}},{event:e.EventType.CLIENTS_DISCONNECTED,handler:function(t,n){return()=>{var r;t.state.clientsConnected=!1,jS.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${n}'`),t.remote.state.relayPersistence?jS.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${n}' - relayPersistence enabled, skipping key exchange cleanup.`):(t.state.isOriginator&&!t.state.clientsPaused&&(null===(r=t.state.keyExchange)||void 0===r||r.clean()),t.emit(e.EventType.CLIENTS_DISCONNECTED,n))}}},{event:e.EventType.CONFIG,handler:function(t,n){return r=>nS(this,void 0,void 0,(function*(){var i,o,a;jS.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${n}'`,r);const{persistence:s,walletKey:u}=r;t.state.isOriginator&&t.remote.state.channelConfig?(r.walletKey&&!t.remote.state.channelConfig.otherKey&&(jS.SocketService(`Setting wallet key ${u}`),t.remote.state.channelConfig.otherKey=u,t.getKeyExchange().setOtherPublicKey(r.walletKey),null===(i=t.state.keyExchange)||void 0===i||i.setKeysExchanged(!0),yield t.remote.sendMessage({type:GE.KEY_HANDSHAKE_ACK}),yield t.remote.sendMessage({type:e.MessageType.PING}),yield null===(o=t.remote.state.storageManager)||void 0===o?void 0:o.persistChannelConfig(t.remote.state.channelConfig)),!0!==s||t.remote.state.channelConfig.relayPersistence||(jS.SocketService(`Setting relay persistence ${s}`),t.remote.state.channelConfig.relayPersistence=s,t.remote.state.relayPersistence=!0,t.remote.emit(e.EventType.CHANNEL_PERSISTENCE),t.remote.state.authorized=!0,t.remote.state.ready=!0,t.remote.emit(e.EventType.AUTHORIZED),yield null===(a=t.remote.state.storageManager)||void 0===a?void 0:a.persistChannelConfig(t.remote.state.channelConfig))):t.state.isOriginator||r.persistence&&(t.remote.state.relayPersistence=!0,t.remote.emit(e.EventType.CHANNEL_PERSISTENCE))}))}},{event:e.EventType.MESSAGE,handler:function(t,n){return r=>{var i,o,a,s,u,l,c,d,f,h,p,m,g,v,b,y,w,_;const{ackId:S,message:E,error:k}=r,M=null!==(i=t.remote.state.relayPersistence)&&void 0!==i&&i;if(jS.SocketService(`[SocketService handleMessage()] relayPersistence=${M} context=${t.state.context} on 'message' ${n} keysExchanged=${null===(o=t.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged()}`,r),k)throw jS.SocketService(`\\n [SocketService handleMessage()] context=${t.state.context}::on 'message' error=${k}`),new Error(k);const C=\"string\"==typeof E;if(!C&&(null==E?void 0:E.type)===GE.KEY_HANDSHAKE_START)return M?void console.warn(\"[SocketService handleMessage()] Ignoring key exchange message because relay persistence is activated\",E):(jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received HANDSHAKE_START isOriginator=${t.state.isOriginator}`,E),void(null===(a=t.state.keyExchange)||void 0===a||a.start({isOriginator:null!==(s=t.state.isOriginator)&&void 0!==s&&s,force:!0})));if(!C&&(null===(u=null==E?void 0:E.type)||void 0===u?void 0:u.startsWith(\"key_handshake\")))return M?void console.warn(\"[SocketService handleMessage()] Ignoring key exchange message because relay persistence is activated\",E):(jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' emit KEY_EXCHANGE`,E),void t.emit(YE.KEY_EXCHANGE,{message:E,context:t.state.context}));if(C&&!(null===(l=t.state.keyExchange)||void 0===l?void 0:l.areKeysExchanged())){let e=!1;try{jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' trying to decrypt message`),null===(c=t.state.keyExchange)||void 0===c||c.decryptMessage(E),e=!0}catch(e){jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' error`,e)}if(!e)return t.state.isOriginator?null===(f=t.state.keyExchange)||void 0===f||f.start({isOriginator:null!==(h=t.state.isOriginator)&&void 0!==h&&h}):t.sendMessage({type:GE.KEY_HANDSHAKE_START}).catch((e=>{console.error(`[SocketService handleMessage()] context=${t.state.context}::on 'message' error`,e)})),void jS.SocketService(`Message ignored because invalid key exchange status. step=${null===(p=t.state.keyExchange)||void 0===p?void 0:p.getKeyInfo().step}`,null===(m=t.state.keyExchange)||void 0===m?void 0:m.getKeyInfo(),E);jS.SocketService(\"Invalid key exchange status detected --- updating it.\"),null===(d=t.state.keyExchange)||void 0===d||d.setKeysExchanged(!0)}else if(!C&&(null==E?void 0:E.type))return console.warn(\"[SocketService handleMessage() ::on 'message' received non encrypted unkwown message\"),void t.emit(e.EventType.MESSAGE,E);if(!C)return console.warn(\"[SocketService handleMessage() ::on 'message' received unkwown message\",E),void t.emit(e.EventType.MESSAGE,E);const x=null===(g=t.state.keyExchange)||void 0===g?void 0:g.decryptMessage(E),A=JSON.parse(null!=x?x:\"{}\");if(S&&(null==S?void 0:S.length)>0&&(jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' ackid=${S} channelId=${n}`),null===(v=t.state.socket)||void 0===v||v.emit(e.EventType.MESSAGE_ACK,{ackId:S,channelId:n,clientType:t.state.isOriginator?\"dapp\":\"wallet\"})),(null==A?void 0:A.type)===e.MessageType.PAUSE?t.state.clientsPaused=!0:t.state.clientsPaused=!1,t.state.isOriginator&&A.data){const n=A.data,r=t.state.rpcMethodTracker[n.id];if(r){const i=Date.now()-r.timestamp;jS.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received answer for id=${n.id} method=${r.method} responseTime=${i}`,A),t.remote.state.analytics&&ik.includes(r.method.toLowerCase())&&KS(Object.assign(Object.assign({id:null!==(b=t.remote.state.channelId)&&void 0!==b?b:\"\",event:ZE.SDK_RPC_REQUEST_DONE,sdkVersion:t.remote.state.sdkVersion,commLayerVersion:FE.version},t.remote.state.originatorInfo),{walletVersion:null===(y=t.remote.state.walletInfo)||void 0===y?void 0:y.version,params:{method:r.method,from:\"mobile\"}}),t.remote.state.communicationServerUrl).catch((e=>{console.error(\"Cannot send analytics\",e)}));const o=Object.assign(Object.assign({},r),{result:n.result,error:n.error?{code:null===(w=n.error)||void 0===w?void 0:w.code,message:null===(_=n.error)||void 0===_?void 0:_.message}:void 0,elapsedTime:i});t.state.rpcMethodTracker[n.id]=o,t.emit(e.EventType.RPC_UPDATE,o)}}t.emit(e.EventType.MESSAGE,{message:A})}}},{event:e.EventType.REJECTED,handler:function(t,n){return r=>nS(this,void 0,void 0,(function*(){var r;t.state.isOriginator&&!t.remote.state.ready?(jS.SocketService(`[SocketService: handleChannelRejected()] context=${t.state.context} channelId=${n} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`,t.remote.state.originatorInfo),KS(Object.assign(Object.assign({id:n,event:ZE.REJECTED},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:FE.version,walletVersion:null===(r=t.remote.state.walletInfo)||void 0===r?void 0:r.version}),t.remote.state.communicationServerUrl).catch((e=>{console.error(\"handleChannelRejected:: Error emitting analytics event\",e)})),yield t.remote.disconnect({terminate:!0}),t.remote.emit(e.EventType.REJECTED,{channelId:n}),t.remote.setConnectionStatus(e.ConnectionStatus.DISCONNECTED)):jS.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${n} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`)}))}},{event:\"clients_waiting_to_join\",handler:function(t,n){return r=>{jS.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${t.state.context} on 'clients_waiting_to_join-${n}'`,r),t.emit(e.EventType.CLIENTS_WAITING,r)}}}],sk=[{event:e.EventType.KEY_INFO,handler:function(t){return n=>{jS.SocketService(\"[SocketService: handleKeyInfo()] on 'KEY_INFO'\",n),t.emit(e.EventType.KEY_INFO,n)}}},{event:e.EventType.KEYS_EXCHANGED,handler:function(t){return()=>{var n,r,i;jS.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${null===(n=t.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`);const{channelConfig:o}=t.remote.state;if(o){const e=t.getKeyExchange().getKeyInfo().ecies;o.localKey=e.private,o.otherKey=e.otherPubKey,t.remote.state.channelConfig=o,null===(r=t.remote.state.storageManager)||void 0===r||r.persistChannelConfig(o).catch((e=>{console.error(\"Error persisting channel config\",e)}))}t.emit(e.EventType.KEYS_EXCHANGED,{keysExchanged:null===(i=t.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged(),isOriginator:t.state.isOriginator});const a={keyInfo:t.getKeyInfo()};t.emit(e.EventType.SERVICE_STATUS,a)}}}];function uk(t,n){jS.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} setting socket listeners for channel ${n}...`);const{socket:r}=t.state,{keyExchange:i}=t.state;r&&t.state.isOriginator&&(t.state.debug&&(null==r||r.io.on(\"error\",(e=>{jS.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=error`,e)})),null==r||r.io.on(\"reconnect\",(e=>{jS.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect`,e),tk(t).catch((e=>{}))})),null==r||r.io.on(\"reconnect_error\",(e=>{jS.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_error`,e)})),null==r||r.io.on(\"reconnect_failed\",(()=>{jS.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_failed`)}))),null==r||r.on(\"disconnect\",(n=>(jS.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${n}' begin recovery...`),function(t){return n=>{jS.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${t.state.manualDisconnect}`,n),t.state.manualDisconnect||(t.emit(e.EventType.SOCKET_DISCONNECTED),tk(t).catch((e=>{console.error(\"SocketService::handleDisconnect Error reconnecting socket\",e)})))}}(t)(n))))),ak.forEach((({event:e,handler:i})=>{const o=`${e}-${n}`;null==r||r.on(o,i(t,n))})),sk.forEach((({event:e,handler:n})=>{null==i||i.on(e,n(t))})),t.state.setupChannelListeners=!0}class lk extends xw.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:a}=e;this.state.resumed=t,this.state.context=i,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=n,this.state.debug=!0===(null==a?void 0:a.serviceLayer),this.remote=o,!0===(null==a?void 0:a.serviceLayer)&&LS.enable(\"SocketService:Layer\"),this.state.communicationServerUrl=r,this.state.hasPlaintext=this.state.communicationServerUrl!==KE&&!0===(null==a?void 0:a.plaintext),jS.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:qE,withCredentials:!0},o=this.state.communicationServerUrl;jS.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=tS(o,i),function(e){if(\"undefined\"!=typeof window&&\"undefined\"!=typeof document&&(jS.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,e),!e.state.focusListenerAdded)){const t=()=>{jS.SocketService(\"Document has focus --- reconnecting socket\"),tk(e).catch((e=>{console.error(\"setupSocketFocusListeners Error reconnecting socket\",e)}))};window.addEventListener(\"focus\",t),e.state.focusListenerAdded=!0,e.state.removeFocusListener=()=>{window.removeEventListener(\"focus\",t),e.state.focusListenerAdded=!1}}}(this);const a={communicationLayer:this,otherPublicKey:t,sendPublicKey:!1,context:null!==(e=this.state.context)&&void 0!==e?e:\"\",ecies:n,logging:r};this.state.keyExchange=new QE(a)}resetKeys(){return this,jS.SocketService(\"[SocketService: resetKeys()] Resetting keys.\"),void(null===(e=this.state.keyExchange)||void 0===e||e.resetKeys());var e}createChannel(){return nS(this,void 0,void 0,(function*(){return function(t){var n,r,i;return nS(this,void 0,void 0,(function*(){if(jS.SocketService(`[SocketService: createChannel()] context=${t.state.context}`),t.state.socket||t.initSocket(),null===(n=t.state.socket)||void 0===n?void 0:n.connected)throw console.error(\"[SocketService: createChannel()] socket already connected\"),new Error(\"socket already connected\");null===(r=t.state.socket)||void 0===r||r.connect(),t.state.manualDisconnect=!1,t.state.isOriginator=!0;const o=Ow();t.state.channelId=o,uk(t,o),yield new Promise(((n,r)=>{var i;null===(i=t.state.socket)||void 0===i||i.emit(e.EventType.JOIN_CHANNEL,{channelId:o,context:`${t.state.context}createChannel`,clientType:\"dapp\"},((e,i)=>nS(this,void 0,void 0,(function*(){try{yield JE(t,e,i),n()}catch(e){r(e)}}))))}));const a=null===(i=t.state.keyExchange)||void 0===i?void 0:i.getKeyInfo();return{channelId:o,pubKey:(null==a?void 0:a.ecies.public)||\"\",privKey:(null==a?void 0:a.ecies.private)||\"\"}}))}(this)}))}connectToChannel({channelId:t,withKeyExchange:n=!1,authorized:r}){return function({options:t,instance:n}){return nS(this,void 0,void 0,(function*(){const{channelId:r,authorized:i,withKeyExchange:o}=t,{state:a,remote:s}=n,{isOriginator:u=!1,socket:l,keyExchange:c}=a,{channelConfig:d}=s.state;if(null==l?void 0:l.connected)throw console.error(\"[SocketService: connectToChannel()] socket already connected\"),new Error(\"socket already connected\");if(u&&(null==d?void 0:d.relayPersistence)){const{localKey:e,otherKey:t}=d;e&&t?null==c||c.setRelayPersistence({localKey:e,otherKey:t}):console.warn(\"Missing keys in relay persistence\",d)}return Object.assign(a,{manualDisconnect:!1,withKeyExchange:o,isOriginator:u,channelId:r}),null==l||l.connect(),uk(n,r),!u&&i&&(null==c||c.setKeysExchanged(!0),Object.assign(s.state,{ready:!0,authorized:!0})),new Promise((t=>{var o;const s=null===(o=null==c?void 0:c.getKeyInfo())||void 0===o?void 0:o.ecies.public,d=i&&!u?s:void 0;null==l||l.emit(e.EventType.JOIN_CHANNEL,{channelId:r,context:`${a.context}_connectToChannel`,clientType:u?\"dapp\":\"wallet\",publicKey:d},((e,r)=>nS(this,void 0,void 0,(function*(){yield JE(n,e,r),t()}))))}))}))}({options:{channelId:t,withKeyExchange:n,authorized:r},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var t,n;null===(n=(t=this).state.socket)||void 0===n||n.emit(e.EventType.MESSAGE,{id:t.state.channelId,context:t.state.context,message:{type:GE.KEY_HANDSHAKE_CHECK,pubkey:t.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return nS(this,void 0,void 0,(function*(){return ok(this,e)}))}ping(){return function(t){var n,r;return nS(this,void 0,void 0,(function*(){jS.SocketService(`[SocketService: ping()] context=${t.state.context} originator=${t.state.isOriginator} keysExchanged=${null===(n=t.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`),null===(r=t.state.socket)||void 0===r||r.emit(e.MessageType.PING,{id:t.state.channelId,context:\"ping\",clientType:t.remote.state.isOriginator?\"dapp\":\"wallet\",message:\"\"})}))}(this)}pause(){return function(t){var n,r;return nS(this,void 0,void 0,(function*(){jS.SocketService(`[SocketService: pause()] context=${t.state.context}`),t.state.manualDisconnect=!0,(null===(n=t.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&(yield t.sendMessage({type:e.MessageType.PAUSE})),null===(r=t.state.socket)||void 0===r||r.disconnect()}))}(this)}isConnected(){var e;return null===(e=this.state.socket)||void 0===e?void 0:e.connected}resume(){return function(t){return nS(this,void 0,void 0,(function*(){const{state:n,remote:r}=t,{socket:i,channelId:o,context:a,keyExchange:s,isOriginator:u}=n,{isOriginator:l}=r.state;if(jS.SocketService(`[SocketService: resume()] channelId=${o} context=${a} connected=${null==i?void 0:i.connected} manualDisconnect=${n.manualDisconnect} resumed=${n.resumed} keysExchanged=${null==s?void 0:s.areKeysExchanged()}`),!o)throw jS.SocketService(\"[SocketService: resume()] channelId is not defined\"),new Error(\"ChannelId is not defined\");(null==i?void 0:i.connected)?(jS.SocketService(\"[SocketService: resume()] already connected.\"),i.emit(e.MessageType.PING,{id:o,clientType:l?\"dapp\":\"wallet\",context:\"on_channel_config\",message:\"\"}),r.hasRelayPersistence()||(null==s?void 0:s.areKeysExchanged())||(u?yield t.sendMessage({type:e.MessageType.READY}):null==s||s.start({isOriginator:!1}))):(null==i||i.connect(),jS.SocketService(`[SocketService: resume()] after connecting socket --\\x3e connected=${null==i?void 0:i.connected}`),null==i||i.emit(e.EventType.JOIN_CHANNEL,{channelId:o,context:`${a}_resume`,clientType:l?\"dapp\":\"wallet\"},((e,n)=>nS(this,void 0,void 0,(function*(){try{yield JE(t,e,n)}catch(e){console.warn(\"Error reconnecting to channel\",e)}}))))),n.manualDisconnect=!1,n.resumed=!0}))}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(e,t){var n,r,i,o,a;jS.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===(a=e.state.socket)||void 0===a||a.disconnect()}(this,e)}}var ck;function dk(t){return()=>nS(this,void 0,void 0,(function*(){var n,r,i;const{state:o}=t;if(o.authorized)return;yield(()=>nS(this,void 0,void 0,(function*(){for(;!o.walletInfo;)yield XE(500)})))();const a=\"7.3\".localeCompare((null===(n=o.walletInfo)||void 0===n?void 0:n.version)||\"\");if(jS.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${null===(r=o.walletInfo)||void 0===r?void 0:r.version} compareValue=${a}`),1!==a)return;const s=o.platformType===e.PlatformType.MobileWeb||o.platformType===e.PlatformType.ReactNative||o.platformType===e.PlatformType.MetaMaskMobileWebview;jS.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${o.platformType} secure=${s} channel=${o.channelId} walletVersion=${null===(i=o.walletInfo)||void 0===i?void 0:i.version}`),s&&(o.authorized=!0,t.emit(e.EventType.AUTHORIZED))}))}function fk(t){return n=>{const{state:r}=t;jS.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${r.context} on 'channel_created' channelId=${n}`),t.emit(e.EventType.CHANNEL_CREATED,n)}}function hk(t,n){return()=>{var r,i,o,a;const{state:s}=t;if(jS.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${s.channelId} keysExchanged=${null===(i=null===(r=s.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.keysExchanged}`),s.analytics){const e=s.isOriginator?ZE.REQUEST:ZE.REQUEST_MOBILE;KS(Object.assign(Object.assign({id:null!==(o=s.channelId)&&void 0!==o?o:\"\",event:s.reconnection?ZE.RECONNECT:e},s.originatorInfo),{commLayer:n,sdkVersion:s.sdkVersion,walletVersion:null===(a=s.walletInfo)||void 0===a?void 0:a.version,commLayerVersion:FE.version}),s.communicationServerUrl).catch((e=>{console.error(\"Cannot send analytics\",e)}))}s.clientsConnected=!0,s.originatorInfoSent=!1,t.emit(e.EventType.CLIENTS_CONNECTED)}}function pk(t){return n=>{const{state:r}=t;jS.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${r.context} on 'clients_disconnected' channelId=${n}`),r.relayPersistence||(r.clientsConnected=!1,r.ready=!1,r.authorized=!1),t.emit(e.EventType.CLIENTS_DISCONNECTED,r.channelId),t.setConnectionStatus(e.ConnectionStatus.DISCONNECTED)}}function mk(t){return n=>{var r;const{state:i}=t;if(jS.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${i.context} on 'clients_waiting' numberUsers=${n} ready=${i.ready} autoStarted=${i.originatorConnectStarted}`),t.setConnectionStatus(e.ConnectionStatus.WAITING),t.emit(e.EventType.CLIENTS_WAITING,n),i.originatorConnectStarted){jS.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${i.originatorConnectStarted} timeout`,i.autoConnectOptions);const n=(null===(r=i.autoConnectOptions)||void 0===r?void 0:r.timeout)||3e3,o=setTimeout((()=>{jS.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${n}) terminate channelConfig`,i.autoConnectOptions),i.originatorConnectStarted=!1,i.ready||t.setConnectionStatus(e.ConnectionStatus.TIMEOUT),clearTimeout(o)}),n)}}}function gk(t,n){return r=>{var i,o,a,s,u,l,c,d;const{state:f}=t;if(jS.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${f.context} on commLayer.'keys_exchanged' channel=${f.channelId}`,r),null===(o=null===(i=f.communicationLayer)||void 0===i?void 0:i.getKeyInfo())||void 0===o?void 0:o.keysExchanged){const n=Object.assign(Object.assign({},f.channelConfig),{channelId:null!==(a=f.channelId)&&void 0!==a?a:\"\",validUntil:(null===(s=f.channelConfig)||void 0===s?void 0:s.validUntil)||HE,localKey:f.communicationLayer.getKeyInfo().ecies.private,otherKey:f.communicationLayer.getKeyInfo().ecies.otherPubKey});null===(u=f.storageManager)||void 0===u||u.persistChannelConfig(n).catch((e=>{console.error(\"Error persisting channel config\",e)})),t.setConnectionStatus(e.ConnectionStatus.LINKED)}!function(e,t){var n,r,i,o,a,s,u,l;const{state:c}=e;jS.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${c.channelId}`,t);const d=Object.assign(Object.assign({},c.channelConfig),{channelId:null!==(n=c.channelId)&&void 0!==n?n:\"\",validUntil:null!==(i=null===(r=c.channelConfig)||void 0===r?void 0:r.validUntil)&&void 0!==i?i:0,relayPersistence:c.relayPersistence,localKey:null===(a=null===(o=c.communicationLayer)||void 0===o?void 0:o.state.keyExchange)||void 0===a?void 0:a.getKeyInfo().ecies.private,otherKey:null===(u=null===(s=c.communicationLayer)||void 0===s?void 0:s.state.keyExchange)||void 0===u?void 0:u.getKeyInfo().ecies.otherPubKey,lastActive:t.getTime()});null===(l=c.storageManager)||void 0===l||l.persistChannelConfig(d)}(t,new Date),f.analytics&&f.channelId&&KS(Object.assign(Object.assign({id:f.channelId,event:r.isOriginator?ZE.CONNECTED:ZE.CONNECTED_MOBILE},f.originatorInfo),{sdkVersion:f.sdkVersion,commLayer:n,commLayerVersion:FE.version,walletVersion:null===(l=f.walletInfo)||void 0===l?void 0:l.version}),f.communicationServerUrl).catch((e=>{console.error(\"Cannot send analytics\",e)})),f.isOriginator=r.isOriginator,r.isOriginator||(null===(c=f.communicationLayer)||void 0===c||c.sendMessage({type:e.MessageType.READY}),f.ready=!0,f.paused=!1),r.isOriginator&&!f.originatorInfoSent&&(null===(d=f.communicationLayer)||void 0===d||d.sendMessage({type:e.MessageType.ORIGINATOR_INFO,originatorInfo:f.originatorInfo,originator:f.originatorInfo}),f.originatorInfoSent=!0)}}function vk(t){return n=>{let r=n;n.message&&(r=r.message),function(t,n){const{state:r}=n;if(jS.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${r.context} on 'message' typeof=${typeof t}`,t),n.state.ready=!0,r.isOriginator||t.type!==e.MessageType.ORIGINATOR_INFO)if(r.isOriginator&&t.type===e.MessageType.WALLET_INFO)!function(e,t){const{state:n}=e;n.walletInfo=t.walletInfo,n.paused=!1}(n,t);else{if(r.isOriginator&&t.type===e.MessageType.WALLET_INIT)(function(t,n){var r,i,o;return nS(this,void 0,void 0,(function*(){const{state:a}=t;if(a.isOriginator){const a=n.data||{};if(\"object\"==typeof a&&\"accounts\"in a&&\"chainId\"in a&&\"walletKey\"in a)try{const{channelConfig:n}=t.state;if(jS.RemoteCommunication(\"WALLET_INIT: channelConfig\",JSON.stringify(n,null,2)),n){const e=a.accounts,s=a.chainId,u=a.walletKey;let l,c=!1;\"deeplinkProtocol\"in a&&(c=Boolean(a.deeplinkProtocol),t.state.deeplinkProtocolAvailable=c),\"walletVersion\"in a&&(l=a.walletVersion),yield null===(r=t.state.storageManager)||void 0===r?void 0:r.persistChannelConfig(Object.assign(Object.assign({},n),{otherKey:u,walletVersion:l,deeplinkProtocolAvailable:c,relayPersistence:!0})),yield null===(i=t.state.storageManager)||void 0===i?void 0:i.persistAccounts(e),yield null===(o=t.state.storageManager)||void 0===o?void 0:o.persistChainId(s)}t.emit(e.EventType.WALLET_INIT,{accounts:a.accounts,chainId:a.chainId})}catch(e){console.error('RemoteCommunication::on \"wallet_init\" -- error',e)}else console.error('RemoteCommunication::on \"wallet_init\" -- invalid data format',a)}}))})(n,t).catch((e=>{jS.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(t.type===e.MessageType.TERMINATE)(function(t){return nS(this,void 0,void 0,(function*(){const{state:n}=t;n.isOriginator&&(yield Sk({options:{terminate:!0,sendMessage:!1},instance:t}),t.emit(e.EventType.TERMINATE))}))})(n).catch((e=>{jS.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(t.type===e.MessageType.PAUSE)!function(t){const{state:n}=t;n.paused=!0,t.setConnectionStatus(e.ConnectionStatus.PAUSED)}(n);else if(t.type===e.MessageType.READY&&r.isOriginator)!function(t){const{state:n}=t;t.setConnectionStatus(e.ConnectionStatus.LINKED);const r=n.paused;n.paused=!1,t.emit(e.EventType.CLIENTS_READY,{isOriginator:n.isOriginator,walletInfo:n.walletInfo}),r&&(n.authorized=!0,t.emit(e.EventType.AUTHORIZED))}(n);else{if(t.type===e.MessageType.OTP&&r.isOriginator)return void function(t,n){var r;const{state:i}=t;t.emit(e.EventType.OTP,n.otpAnswer),1===\"6.6\".localeCompare((null===(r=i.walletInfo)||void 0===r?void 0:r.version)||\"\")&&(console.warn(\"RemoteCommunication::on 'otp' -- backward compatibility <6.6 -- triger eth_requestAccounts\"),t.emit(e.EventType.SDK_RPC_CALL,{method:$E.ETH_REQUESTACCOUNTS,params:[]}))}(n,t);t.type===e.MessageType.AUTHORIZED&&r.isOriginator&&function(t){const{state:n}=t;n.authorized=!0,t.emit(e.EventType.AUTHORIZED)}(n)}n.emit(e.EventType.MESSAGE,t)}else!function(t,n){var r;const{state:i}=t;null===(r=i.communicationLayer)||void 0===r||r.sendMessage({type:e.MessageType.WALLET_INFO,walletInfo:i.walletInfo}),i.originatorInfo=n.originatorInfo||n.originator,t.emit(e.EventType.CLIENTS_READY,{isOriginator:i.isOriginator,originatorInfo:i.originatorInfo}),i.paused=!1}(n,t)}(r,t)}}function bk(e){return()=>{const{state:t}=e;jS.RemoteCommunication(\"[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false\"),t.ready=!1,t.authorized=!1,VE(t),e.emitServiceStatusEvent({context:\"socket_reconnect\"})}}function yk(e){return()=>{const{state:t}=e;jS.RemoteCommunication(\"[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false\"),t.ready=!1}}function wk(t){return()=>nS(this,void 0,void 0,(function*(){var n,r,i,o,a,s,u;const{state:l}=t;jS.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${l.context}`),t.state.ready=!0,t.state.clientsConnected=!0,t.state.authorized=!0,t.state.relayPersistence=!0,null===(n=t.state.communicationLayer)||void 0===n||n.getKeyExchange().setKeysExchanged(!0),t.emit(e.EventType.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),t.emit(e.EventType.AUTHORIZED),t.emit(e.EventType.CLIENTS_READY),t.emit(e.EventType.CHANNEL_PERSISTENCE);try{l.channelConfig=Object.assign(Object.assign({},l.channelConfig),{localKey:null===(r=l.communicationLayer)||void 0===r?void 0:r.getKeyExchange().getKeyInfo().ecies.private,otherKey:null===(i=l.communicationLayer)||void 0===i?void 0:i.getKeyExchange().getOtherPublicKey(),channelId:null!==(o=l.channelId)&&void 0!==o?o:\"\",validUntil:null!==(s=null===(a=l.channelConfig)||void 0===a?void 0:a.validUntil)&&void 0!==s?s:HE,relayPersistence:!0}),yield null===(u=l.storageManager)||void 0===u?void 0:u.persistChannelConfig(l.channelConfig)}catch(e){console.error(\"Error persisting channel config\",e)}}))}function _k({communicationLayerPreference:t,otherPublicKey:n,reconnect:r,ecies:i,communicationServerUrl:o=KE,instance:a}){var s,u,l,c,d,f,h,p,m,g,v;const{state:b}=a;if(jS.RemoteCommunication(\"[initCommunicationLayer()] \",JSON.stringify(b,null,2)),t!==e.CommunicationLayerPreference.SOCKET)throw new Error(\"Invalid communication protocol\");b.communicationLayer=new lk({communicationLayerPreference:t,otherPublicKey:n,reconnect:r,transports:b.transports,communicationServerUrl:o,context:b.context,ecies:i,logging:b.logging,remote:a});let y=\"undefined\"!=typeof document&&document.URL||\"\",w=\"undefined\"!=typeof document&&document.title||\"\";(null===(s=b.dappMetadata)||void 0===s?void 0:s.url)&&(y=b.dappMetadata.url),(null===(u=b.dappMetadata)||void 0===u?void 0:u.name)&&(w=b.dappMetadata.name);const _=null!==(f=null!==(c=null===(l=b.dappMetadata)||void 0===l?void 0:l.name)&&void 0!==c?c:null===(d=b.dappMetadata)||void 0===d?void 0:d.url)&&void 0!==f?f:\"N/A\",S=\"undefined\"!=typeof window&&void 0!==window.location&&null!==(h=window.location.hostname)&&void 0!==h?h:_,E={url:y,title:w,source:null===(p=b.dappMetadata)||void 0===p?void 0:p.source,dappId:S,icon:(null===(m=b.dappMetadata)||void 0===m?void 0:m.iconUrl)||(null===(g=b.dappMetadata)||void 0===g?void 0:g.base64Icon),platform:b.platformType,apiVersion:FE.version,connector:null===(v=b.dappMetadata)||void 0===v?void 0:v.connector};b.originatorInfo=E;const k={[e.EventType.AUTHORIZED]:dk(a),[e.EventType.MESSAGE]:vk(a),[e.EventType.CHANNEL_PERSISTENCE]:wk(a),[e.EventType.CLIENTS_CONNECTED]:hk(a,t),[e.EventType.KEYS_EXCHANGED]:gk(a,t),[e.EventType.SOCKET_DISCONNECTED]:yk(a),[e.EventType.SOCKET_RECONNECT]:bk(a),[e.EventType.CLIENTS_DISCONNECTED]:pk(a),[e.EventType.KEY_INFO]:()=>{},[e.EventType.CHANNEL_CREATED]:fk(a),[e.EventType.CLIENTS_WAITING]:mk(a),[e.EventType.RPC_UPDATE]:t=>{a.emit(e.EventType.RPC_UPDATE,t)}};for(const[e,t]of Object.entries(k))try{b.communicationLayer.on(e,t)}catch(n){console.error(`Error registering handler for ${e}:`,n)}}function Sk({options:t,instance:n}){return nS(this,void 0,void 0,(function*(){const{state:r}=n;return jS.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${r.channelId}`,t),new Promise(((i,o)=>{var a,s,u,l,c,d;(null==t?void 0:t.terminate)?(n.state.ready&&KS({id:null!==(a=n.state.channelId)&&void 0!==a?a:\"\",event:ZE.TERMINATED},n.state.communicationServerUrl).catch((e=>{console.error(\"[handleSendMessage] Cannot send analytics\",e)})),r.ready=!1,r.paused=!1,null===(s=r.storageManager)||void 0===s||s.terminate(null!==(u=r.channelId)&&void 0!==u?u:\"\"),n.state.terminated=!0,t.sendMessage?(null===(l=r.communicationLayer)||void 0===l?void 0:l.getKeyInfo().keysExchanged)&&n.state.communicationLayer&&nk(n.state.communicationLayer,{type:e.MessageType.TERMINATE}).then((()=>{console.warn(\"[disconnect] Terminate message sent to the other peer\"),i(!0)})).catch((e=>{o(e)})):i(!0),r.authorized=!1,r.relayPersistence=!1,r.channelId=Ow(),t.channelId=r.channelId,r.channelConfig=void 0,r.originatorConnectStarted=!1,null===(c=r.communicationLayer)||void 0===c||c.disconnect(t),n.setConnectionStatus(e.ConnectionStatus.TERMINATED)):(null===(d=r.communicationLayer)||void 0===d||d.disconnect(t),n.setConnectionStatus(e.ConnectionStatus.DISCONNECTED),i(!0))}))}))}e.CommunicationLayerPreference=void 0,e.PlatformType=void 0,function(e){e.SOCKET=\"socket\"}(e.CommunicationLayerPreference||(e.CommunicationLayerPreference={})),function(e){e.NonBrowser=\"nodejs\",e.MetaMaskMobileWebview=\"in-app-browser\",e.DesktopWeb=\"web-desktop\",e.MobileWeb=\"web-mobile\",e.ReactNative=\"react-native\"}(e.PlatformType||(e.PlatformType={}));class Ek extends xw.EventEmitter2{constructor(t){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:KE,context:\"\",persist:!1,clientsConnected:!1,sessionDuration:HE,originatorConnectStarted:!1,debug:!1,_connectionStatus:e.ConnectionStatus.DISCONNECTED},this._options=t;const{platformType:n,communicationLayerPreference:r,otherPublicKey:i,reconnect:o,walletInfo:a,dappMetadata:s,protocolVersion:u,transports:l,context:c,relayPersistence:d,ecies:f,analytics:h=!1,storage:p,sdkVersion:m,communicationServerUrl:g=KE,logging:v,autoConnect:b={timeout:WE}}=t;this.state.otherPublicKey=i,this.state.dappMetadata=s,this.state.walletInfo=a,this.state.transports=l,this.state.platformType=n,this.state.analytics=h,this.state.protocolVersion=null!=u?u:1,this.state.isOriginator=!i,this.state.relayPersistence=d,this.state.communicationServerUrl=g,this.state.context=c,this.state.terminated=!1,this.state.sdkVersion=m,this.setMaxListeners(50),this.setConnectionStatus(e.ConnectionStatus.DISCONNECTED),(null==p?void 0:p.duration)&&(this.state.sessionDuration=HE),this.state.storageOptions=p,this.state.autoConnectOptions=b,this.state.debug=!0===(null==v?void 0:v.remoteLayer),!0===(null==v?void 0:v.remoteLayer)&&LS.enable(\"RemoteCommunication:Layer\"),!0===(null==v?void 0:v.serviceLayer)&&LS.enable(\"SocketService:Layer\"),!0===(null==v?void 0:v.eciesLayer)&&LS.enable(\"ECIES:Layer\"),!0===(null==v?void 0:v.keyExchangeLayer)&&LS.enable(\"KeyExchange:Layer\"),this.state.logging=v,(null==p?void 0:p.storageManager)&&(this.state.storageManager=p.storageManager),jS.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${u} relayPersistence=${d} isOriginator=${this.state.isOriginator} communicationLayerPreference=${r} otherPublicKey=${i} reconnect=${o}`),this.state.isOriginator||_k({communicationLayerPreference:r,otherPublicKey:i,reconnect:o,ecies:f,communicationServerUrl:g,instance:this}),this.emitServiceStatusEvent({context:\"constructor\"})}initFromDappStorage(){var t;return nS(this,void 0,void 0,(function*(){if(this.state.storageManager){const n=yield this.state.storageManager.getPersistedChannelConfig({});n&&(this.state.channelConfig=n,this.state.channelId=n.channelId,this.state.deeplinkProtocolAvailable=null!==(t=n.deeplinkProtocolAvailable)&&void 0!==t&&t,n.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(e.ConnectionStatus.LINKED),yield this.connectToChannel({channelId:n.channelId})))}_k({communicationLayerPreference:e.CommunicationLayerPreference.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return nS(this,void 0,void 0,(function*(){return yield function(e){var t;return nS(this,void 0,void 0,(function*(){const{state:n}=e;if(!n.storageManager)return void jS.RemoteCommunication(\"[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip\");const r=yield n.storageManager.getPersistedChannelConfig({});if(jS.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${n.originatorConnectStarted} channelConfig`,r),null===(t=n.communicationLayer)||void 0===t?void 0:t.isConnected())return jS.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;jS.RemoteCommunication(\"[RemoteCommunication: autoConnect()] Session has expired\")}n.originatorConnectStarted=!1}))}(this)}))}generateChannelIdConnect(){return nS(this,void 0,void 0,(function*(){return function(e){var t,n,r,i,o,a;return nS(this,void 0,void 0,(function*(){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===(a=null===(o=e.communicationLayer)||void 0===o?void 0:o.getKeyInfo())||void 0===a?void 0:a.ecies.public};jS.RemoteCommunication(\"[RemoteCommunication: generateChannelId()]\");const s=yield e.communicationLayer.createChannel();jS.RemoteCommunication(\"[RemoteCommunication: generateChannelId()] channel created\",s);const u=Object.assign(Object.assign({},e.channelConfig),{channelId:s.channelId,localKey:s.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=s.channelId,e.channelConfig=u,{channelId:e.channelId,pubKey:s.pubKey,privKey:s.privKey}}))}(this.state)}))}clean(){return VE(this.state)}connectToChannel({channelId:e,withKeyExchange:t,authorized:n}){return function({channelId:e,withKeyExchange:t,authorized:n,state:r}){var i,o,a;return nS(this,void 0,void 0,(function*(){if(!Pw(e))throw jS.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(jS.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} channelId=${e} withKeyExchange=${t}`),null===(i=r.communicationLayer)||void 0===i?void 0:i.isConnected())return void jS.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} already connected - interrupt connection.`);r.channelId=e,yield null===(o=r.communicationLayer)||void 0===o?void 0:o.connectToChannel({channelId:e,authorized:n,withKeyExchange:t});const s=Object.assign(Object.assign({},r.channelConfig),{channelId:e,validUntil:Date.now()+r.sessionDuration});r.channelConfig=s,null===(a=r.storageManager)||void 0===a||a.persistChannelConfig(s)}))}({channelId:e,authorized:n,withKeyExchange:t,state:this.state})}sendMessage(t){return function(t,n){var r,i;return nS(this,void 0,void 0,(function*(){const{state:o}=t;jS.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${o.context} paused=${o.paused} ready=${o.ready} relayPersistence=${o.relayPersistence} authorized=${o.authorized} socket=${null===(r=o.communicationLayer)||void 0===r?void 0:r.isConnected()} clientsConnected=${o.clientsConnected} status=${o._connectionStatus}`,n),o.relayPersistence||o.ready&&(null===(i=o.communicationLayer)||void 0===i?void 0:i.isConnected())&&o.clientsConnected||(jS.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${o.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((n=>{t.once(e.EventType.CLIENTS_READY,n)})),jS.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${o.context} AFTER SKIP / READY -- sending pending message`));try{const r=yield function(t,n){return nS(this,void 0,void 0,(function*(){return new Promise((r=>{var i;const{state:o}=t;jS.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${o.context} ready=${o.ready} authorized=${o.authorized} method=${n.method}`),!o.isOriginator||o.authorized||o.relayPersistence?null===(i=o.communicationLayer)||void 0===i||i.sendMessage(n).then((e=>{r(e)})).catch((e=>{console.error(`[RemoteCommunication: handleAuthorization()] context=${o.context} ERROR`,e),r(!1)})):t.once(e.EventType.AUTHORIZED,(()=>{var e;jS.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${o.context} AFTER SKIP / AUTHORIZED -- sending pending message`),null===(e=o.communicationLayer)||void 0===e||e.sendMessage(n).then((e=>{r(e)})).catch((e=>{console.error(`[RemoteCommunication: handleAuthorization()] context=${o.context} ERROR`,e),r(!1)}))}))}))}))}(t,n);return r}catch(e){throw console.error(`[RemoteCommunication: sendMessage()] context=${o.context} ERROR`,e),e}}))}(this,t)}testStorage(){return nS(this,void 0,void 0,(function*(){return function(e){var t;return nS(this,void 0,void 0,(function*(){const n=yield null===(t=e.storageManager)||void 0===t?void 0:t.getPersistedChannelConfig();jS.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(){var e;return nS(this,void 0,void 0,(function*(){jS.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.ping()}))}testLogger(){jS.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),jS.SocketService(`testLogger() channel=${this.state.channelId}`),jS.Ecies(`testLogger() channel=${this.state.channelId}`),jS.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;jS.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),null===(e=this.state.communicationLayer)||void 0===e||e.keyCheck()}setConnectionStatus(t){this.state._connectionStatus!==t&&(this.state._connectionStatus=t,this.emit(e.EventType.CONNECTION_STATUS,t),this.emitServiceStatusEvent({context:\"setConnectionStatus\"}))}emitServiceStatusEvent(t={}){this.emit(e.EventType.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(){var t;return nS(this,void 0,void 0,(function*(){jS.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield null===(t=this.state.communicationLayer)||void 0===t?void 0:t.pause(),this.setConnectionStatus(e.ConnectionStatus.PAUSED)}))}getVersion(){return FE.version}hasRelayPersistence(){var e;return null!==(e=this.state.relayPersistence)&&void 0!==e&&e}resume(){return nS(this,void 0,void 0,(function*(){return function(t){var n;return nS(this,void 0,void 0,(function*(){const{state:r}=t;jS.RemoteCommunication(`[RemoteCommunication: resume()] channel=${r.channelId}`),yield null===(n=r.communicationLayer)||void 0===n?void 0:n.resume(),t.setConnectionStatus(e.ConnectionStatus.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:t}){return function({channelId:t,state:n}){var r,i,o;return nS(this,void 0,void 0,(function*(){if(!Pw(t))throw jS.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${n.context} invalid channel channelId=${t}`),new Error(`Invalid channel ${t}`);if(n.isOriginator)return void jS.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} isOriginator=${n.isOriginator} channelId=${t}`);const{socket:a}=null!==(i=null===(r=n.communicationLayer)||void 0===r?void 0:r.state)&&void 0!==i?i:{};(null==a?void 0:a.connected)||(jS.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket already connected`),null==a||a.connect()),KS(Object.assign(Object.assign({id:t,event:ZE.REJECTED},n.originatorInfo),{sdkVersion:n.sdkVersion,commLayerVersion:FE.version,walletVersion:null===(o=n.walletInfo)||void 0===o?void 0:o.version}),n.communicationServerUrl).catch((e=>{console.error(\"rejectChannel:: Error emitting analytics event\",e)})),yield new Promise(((r,i)=>{null==a||a.emit(e.EventType.REJECTED,{channelId:t},((e,t)=>{jS.RemoteCommunication(`[RemoteCommunication: reject()] context=${n.context} socket=${null==a?void 0:a.id}`,{error:e,response:t}),e?i(e):r(t)}))}))}))}({channelId:t,state:this.state})}disconnect(e){return nS(this,void 0,void 0,(function*(){return Sk({options:e,instance:this})}))}}function kk(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function Mk(e,t,n,r){if(\"a\"===n&&!r)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof t?e!==t||!r:!t.has(e))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===n?r:\"a\"===n?r.call(e):r?r.value:t.get(e)}function Ck(e,t,n,r,i){if(\"m\"===r)throw new TypeError(\"Private method is not writable\");if(\"a\"===r&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof t?e!==t||!i:!t.has(e))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}!function(e){e.RENEW=\"renew\",e.LINK=\"link\"}(ck||(ck={})),\"function\"==typeof SuppressedError&&SuppressedError;var xk=\"ERC721\",Ak=\"ERC1155\",Rk={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.\"}},Tk=Rk;function Pk(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&&[xk,Ak].includes(n.params?.type||\"\")&&(e.warn(Tk.warnings.rpc.walletWatchAssetNFTExperimental),t.walletWatchAssetNFTExperimental=!0):(e.warn(Tk.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),t.ethGetEncryptionPublicKeyDeprecation=!0):(e.warn(Tk.warnings.rpc.ethDecryptDeprecation),t.ethDecryptDeprecation=!0),i()}}var Lk=4294967295,Ik=Math.floor(Math.random()*Lk);function Ok(){return(e,t,n,r)=>{const i=e.id,o=Ik=(Ik+1)%Lk;e.id=o,t.id=o,n((n=>{e.id=i,t.id=i,n()}))}}var Nk=(e,t,n)=>{if(!t.has(e))throw TypeError(\"Cannot \"+n)},Dk=(e,t,n)=>(Nk(e,t,\"read from private field\"),n?n.call(e):t.get(e)),jk=(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)},Bk=(e,t,n,r)=>(Nk(e,t,\"write to private field\"),r?r.call(e,n):t.set(e,n),n),zk=(e,t,n)=>(Nk(e,t,\"access private method\"),n),Uk={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},Fk={\"-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 Kk(e){return Boolean(e)&&\"object\"==typeof e&&!Array.isArray(e)}var qk=(e,t)=>Object.hasOwnProperty.call(e,t);class Hk extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...o}=e,{path:a}=e,s=0===a.length?r:`At path: ${a.join(\".\")} -- ${r}`;super(i??s),null!=i&&(this.cause=s),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function Wk(e){return\"object\"==typeof e&&null!=e}function $k(e){return\"symbol\"==typeof e?e.toString():\"string\"==typeof e?JSON.stringify(e):`${e}`}function Vk(e,t,n,r){if(!0===e)return;!1===e?e={}:\"string\"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:a}=n,{refinement:s,message:u=`Expected a value of type \\`${a}\\`${s?` with refinement \\`${s}\\``:\"\"}, but received: \\`${$k(r)}\\``}=e;return{value:r,type:a,refinement:s,key:i[i.length-1],path:i,branch:o,...e,message:u}}function*Yk(e,t,n,r){(function(e){return Wk(e)&&\"function\"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Vk(i,t,n,r);e&&(yield e)}}function*Gk(e,t,n={}){const{path:r=[],branch:i=[e],coerce:o=!1,mask:a=!1}=n,s={path:r,branch:i};if(o&&(e=t.coercer(e,s),a&&\"type\"!==t.type&&Wk(t.schema)&&Wk(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let u=\"valid\";for(const r of t.validator(e,s))r.explanation=n.message,u=\"not_valid\",yield[r,void 0];for(let[l,c,d]of t.entries(e,s)){const t=Gk(c,d,{path:void 0===l?r:[...r,l],branch:void 0===l?i:[...i,c],coerce:o,mask:a,message:n.message});for(const n of t)n[0]?(u=null!=n[0].refinement?\"not_refined\":\"not_valid\",yield[n[0],void 0]):o&&(c=n[1],void 0===l?e=c:e instanceof Map?e.set(l,c):e instanceof Set?e.add(c):Wk(e)&&(void 0!==c||l in e)&&(e[l]=c))}if(\"not_valid\"!==u)for(const r of t.refiner(e,s))r.explanation=n.message,u=\"not_refined\",yield[r,void 0];\"valid\"===u&&(yield[void 0,e])}class Zk{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,this.validator=r?(e,t)=>Yk(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Yk(i(e,t),t,this,e):()=>[]}assert(e,t){return Qk(e,this,t)}create(e,t){return Jk(e,this,t)}is(e){return Xk(e,this)}mask(e,t){return function(e,t,n){const r=eM(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return eM(e,this,t)}}function Qk(e,t,n){const r=eM(e,t,{message:n});if(r[0])throw r[0]}function Jk(e,t,n){const r=eM(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function Xk(e,t){return!eM(e,t)[0]}function eM(e,t,n={}){const r=Gk(e,t,n),i=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(i[0]){return[new Hk(i[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}function tM(e,t){return new Zk({type:e,schema:null,validator:t})}function nM(e){let t;return new Zk({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 rM(e){return new Zk({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: ${$k(e)}`})}function iM(e){const t=$k(e),n=typeof e;return new Zk({type:\"literal\",schema:\"string\"===n||\"number\"===n||\"boolean\"===n?e:null,validator:n=>n===e||`Expected the literal \\`${t}\\`, but received: ${$k(n)}`})}function oM(){return tM(\"number\",(e=>\"number\"==typeof e&&!isNaN(e)||`Expected a number, but received: ${$k(e)}`))}function aM(e){const t=e?Object.keys(e):[],n=tM(\"never\",(()=>!1));return new Zk({type:\"object\",schema:e||null,*entries(r){if(e&&Wk(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=>Wk(e)||`Expected an object, but received: ${$k(e)}`,coercer:e=>Wk(e)?{...e}:e})}function sM(e){return new Zk({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function uM(e,t){return new Zk({type:\"record\",schema:null,*entries(n){if(Wk(n))for(const r in n){const i=n[r];yield[r,r,e],yield[r,i,t]}},validator:e=>Wk(e)||`Expected an object, but received: ${$k(e)}`})}function lM(){return tM(\"string\",(e=>\"string\"==typeof e||`Expected a string, but received: ${$k(e)}`))}function cM(e){const t=e.map((e=>e.type)).join(\" | \");return new Zk({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]=Gk(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: ${$k(n)}`,...i]}})}function dM(e){return function(e){return function(e){return\"object\"==typeof e&&null!==e&&\"message\"in e}(e)&&\"string\"==typeof e.message?e.message:function(e){return null==e}(e)?\"\":String(e)}(e).replace(/\\.$/u,\"\")}function fM(e,t){return n=e,Boolean(\"string\"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}var hM=class extends Error{constructor(e){super(e.message),this.code=\"ERR_ASSERTION\"}};var pM=e=>aM(e);function mM({path:e,branch:t}){const n=e[e.length-1];return qk(t[t.length-2],n)}function gM(e){return new Zk({...e,type:`optional ${e.type}`,validator:(t,n)=>!mM(n)||e.validator(t,n),refiner:(t,n)=>!mM(n)||e.refiner(t,n)})}var vM,bM,yM,wM=cM([iM(null),tM(\"boolean\",(e=>\"boolean\"==typeof e)),tM(\"finite number\",(e=>Xk(e,oM())&&Number.isFinite(e))),lM(),rM(nM((()=>wM))),uM(lM(),nM((()=>wM)))]),_M=(vM=wM,bM=tM(\"any\",(()=>!0)),yM=e=>(function(e,t,n=\"Assertion failed\",r=hM){try{Qk(e,t)}catch(e){throw fM(r,`${n}: ${dM(e)}.`)}}(e,wM),JSON.parse(JSON.stringify(e,((e,t)=>{if(\"__proto__\"!==e&&\"constructor\"!==e)return t})))),new Zk({...vM,coercer:(e,t)=>Xk(e,bM)?vM.coercer(yM(e,t),t):vM.coercer(e,t)}));function SM(e){try{return function(e){Jk(e,_M)}(e),!0}catch{return!1}}var EM=iM(\"2.0\"),kM=function(e){return new Zk({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}(cM([oM(),lM()])),MM=pM({code:tM(\"integer\",(e=>\"number\"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${$k(e)}`)),message:lM(),data:gM(_M),stack:gM(lM())}),CM=cM([uM(lM(),_M),rM(_M)]),xM=pM({id:kM,jsonrpc:EM,method:lM(),params:gM(CM)}),AM=pM({jsonrpc:EM,method:lM(),params:gM(CM)});function RM(e){return Xk(e,xM)}function TM(e){return Xk(e,MM)}aM({id:kM,jsonrpc:EM,result:sM(tM(\"unknown\",(()=>!0))),error:sM(MM)}),cM([pM({id:kM,jsonrpc:EM,result:_M}),pM({id:kM,jsonrpc:EM,error:MM})]);var PM,LM,IM={exports:{}};function OM(){if(LM)return PM;LM=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function a(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+\" \"+r+(i?\"s\":\"\")}return PM=function(s,u){u=u||{};var l=typeof s;if(\"string\"===l&&s.length>0)return function(a){if((a=String(a)).length>100)return;var s=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!s)return;var u=parseFloat(s[1]);switch((s[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return u*o;case\"weeks\":case\"week\":case\"w\":return u*i;case\"days\":case\"day\":case\"d\":return u*r;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return u*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return u*t;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return u*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return u;default:return}}(s);if(\"number\"===l&&isFinite(s))return u.long?function(i){var o=Math.abs(i);if(o>=r)return a(i,o,r,\"day\");if(o>=n)return a(i,o,n,\"hour\");if(o>=t)return a(i,o,t,\"minute\");if(o>=e)return a(i,o,e,\"second\");return i+\" ms\"}(s):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\"}(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))}}var NM=function(e){function t(e){let r,i,o,a=null;function s(...e){if(!s.enabled)return;const n=s,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 a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if(\"%%\"===r)return\"%\";a++;const o=t.formatters[i];if(\"function\"==typeof o){const t=e[a];r=o.call(n,t),e.splice(a,1),a--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof t.init&&t.init(s),s}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{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{\"%%\"!==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&&void 0!==je&&\"env\"in je&&(e=je.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=NM(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}}(IM,IM.exports);var DM=r(IM.exports),jM=Uk.internal,BM=\"Unspecified error message. This is a bug, please report it.\",zM={code:jM,message:FM(jM)},UM=\"Unspecified server error.\";function FM(e,t=BM){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(qk(Fk,t))return Fk[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return UM}return t}function KM(e,{fallbackError:t=zM,shouldIncludeStack:n=!0}={}){if(!TM(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(TM(e))return e;const n=qM(e),r={...t,data:{cause:n}};return r}(e,t);return n||delete r.stack,r}function qM(e){return Array.isArray(e)?e.map((e=>SM(e)?e:Kk(e)?HM(e):null)):Kk(e)?HM(e):SM(e)?e:null}function HM(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return SM(r)&&(t[n]=r),t}),{})}var WM=QM;QM.default=QM,QM.stable=tC,QM.stableStringify=tC;var $M=\"[...]\",VM=\"[Circular]\",YM=[],GM=[];function ZM(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function QM(e,t,n,r){var i;void 0===r&&(r=ZM()),XM(e,\"\",0,[],void 0,0,r);try{i=0===GM.length?JSON.stringify(e,t,n):JSON.stringify(e,rC(t),n)}catch(e){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==YM.length;){var o=YM.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function JM(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:e}),YM.push([r,n,t,i])):GM.push([t,n,e]):(r[n]=e,YM.push([r,n,t]))}function XM(e,t,n,r,i,o,a){var s;if(o+=1,\"object\"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void JM($M,e,t,i);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void JM($M,e,t,i);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function tC(e,t,n,r){void 0===r&&(r=ZM());var i,o=nC(e,\"\",0,[],void 0,0,r)||e;try{i=0===GM.length?JSON.stringify(o,t,n):JSON.stringify(o,rC(t),n)}catch(e){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==YM.length;){var a=YM.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return i}function nC(e,t,n,r,i,o,a){var s;if(o+=1,\"object\"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void JM($M,e,t,i);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void JM($M,e,t,i);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;ruC(Uk.invalidRequest,e);function uC(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 oC(e,n??FM(e),r)}var lC={};Object.defineProperty(lC,\"__esModule\",{value:!0});const cC=nt;function dC(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}let fC=class extends cC.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)dC(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r{\"destroy\"in e&&\"function\"==typeof e.destroy&&e.destroy()})),Bk(this,pC,[]),Bk(this,hC,!0)}push(e){zk(this,gC,vC).call(this),Dk(this,pC).push(e)}handle(e,t){if(zk(this,gC,vC).call(this),t&&\"function\"!=typeof t)throw new Error('\"callback\" must be a function if provided.');return Array.isArray(e)?t?zk(this,bC,yC).call(this,e,t):zk(this,bC,yC).call(this,e):t?zk(this,wC,_C).call(this,e,t):this._promiseHandle(e)}asMiddleware(){return zk(this,gC,vC).call(this),async(t,n,r,i)=>{var o,a;try{const[s,u,l]=await zk(o=e,kC,MC).call(o,t,n,Dk(this,pC));return u?(await zk(a=e,AC,RC).call(a,l),i(s)):r((async t=>{var n;try{await zk(n=e,AC,RC).call(n,l)}catch(e){return t(e)}return t()}))}catch(e){return i(e)}}}async _promiseHandle(e){return new Promise(((t,n)=>{zk(this,wC,_C).call(this,e,((e,r)=>{e&&void 0===r?n(e):t(r)})).catch(n)}))}};hC=new WeakMap,pC=new WeakMap,mC=new WeakMap,gC=new WeakSet,vC=function(){if(Dk(this,hC))throw new Error(\"This engine is destroyed and can no longer be used.\")},bC=new WeakSet,yC=async function(e,t){try{if(0===e.length){const e=[{id:null,jsonrpc:\"2.0\",error:new oC(Uk.invalidRequest,\"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}},wC=new WeakSet,_C=async function(e,t){var n;if(!e||Array.isArray(e)||\"object\"!=typeof e){const n=new oC(Uk.invalidRequest,\"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 oC(Uk.invalidRequest,\"Must specify a string method. Received: \"+typeof e.method,{request:e});return Dk(this,mC)&&!RM(e)?t(null):t(n,{id:e.id??null,jsonrpc:\"2.0\",error:n})}if(Dk(this,mC)&&function(e){return Xk(e,AM)}(e)&&!RM(e)){try{await Dk(this,mC).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 zk(n=IC,SC,EC).call(n,i,o,Dk(this,pC))}catch(e){r=e}return r&&(delete o.result,o.error||(o.error=KM(r))),t(r,o)},SC=new WeakSet,EC=async function(e,t,n){var r,i,o;const[a,s,u]=await zk(r=IC,kC,MC).call(r,e,t,n);if(zk(i=IC,TC,PC).call(i,e,t,s),await zk(o=IC,AC,RC).call(o,u),a)throw a},kC=new WeakSet,MC=async function(e,t,n){var r;const i=[];let o=null,a=!1;for(const s of n)if([o,a]=await zk(r=IC,CC,xC).call(r,e,t,s,i),a)break;return[o,a,i.reverse()]},CC=new WeakSet,xC=async function(e,t,n,r){return new Promise((i=>{const o=e=>{const n=e||t.error;n&&(t.error=KM(n)),i([n,!0])},a=n=>{t.error?o(t.error):(n&&(\"function\"!=typeof n&&o(new oC(Uk.internal,`JsonRpcEngine: \"next\" return handlers must be functions. Received \"${typeof n}\" for request:\\n${NC(e)}`,{request:e})),r.push(n)),i([null,!1]))};try{n(e,t,a,o)}catch(e){o(e)}}))},AC=new WeakSet,RC=async function(e){for(const t of e)await new Promise(((e,n)=>{t((t=>t?n(t):e()))}))},TC=new WeakSet,PC=function(e,t,n){if(!qk(t,\"result\")&&!qk(t,\"error\"))throw new oC(Uk.internal,`JsonRpcEngine: Response has no error or result for request:\\n${NC(e)}`,{request:e});if(!n)throw new oC(Uk.internal,`JsonRpcEngine: Nothing ended request:\\n${NC(e)}`,{request:e})},jk(IC,SC),jk(IC,kC),jk(IC,CC),jk(IC,AC),jk(IC,TC);var OC=IC;function NC(e){return JSON.stringify(e,null,2)}var DC=Object.freeze([\"eth_subscription\"]),jC=(e=console)=>[Ok(),BC(e),Pk(e)];function BC(e){return(t,n,r)=>{\"string\"==typeof t.method&&t.method||(n.error=sC({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 zC=(e,t,n=!0)=>(r,i)=>{r||i.error?t(r||i.error):!n||Array.isArray(i)?e(i):e(i.result)},UC=e=>Boolean(e)&&\"string\"==typeof e&&e.startsWith(\"0x\"),FC=()=>{};async function KC(e,t){try{const t=await async function(){return{name:qC(window),icon:await HC(window)}}();e.handle({jsonrpc:\"2.0\",id:1,method:\"metamask_sendDomainMetadata\",params:t},FC)}catch(e){t.error({message:Tk.errors.sendSiteMetadata(),originalError:e})}}function qC(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 HC(e){const{document:t}=e,n=t.querySelectorAll('head > link[rel~=\"icon\"]');for(const e of Array.from(n))if(e&&await WC(e.href))return e.href;return null}async function WC(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 $C=(e,t,n)=>{if(!t.has(e))throw TypeError(\"Cannot \"+n)},VC=(e,t,n)=>($C(e,t,\"read from private field\"),n?n.call(e):t.get(e)),YC=(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)},GC=(e,t,n,r)=>($C(e,t,\"write to private field\"),r?r.call(e,n):t.set(e,n),n);function ZC(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}class QC extends Ze{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)ZC(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;ri.push(e))),this._rpcEngine=i}get chainId(){return VC(this,JC)}get selectedAddress(){return VC(this,XC)}isConnected(){return this._state.isConnected}async request(e){if(!e||\"object\"!=typeof e||Array.isArray(e))throw sC({message:Tk.errors.invalidRequestArgs(),data:e});const{method:t,params:n}=e;if(\"string\"!=typeof t||0===t.length)throw sC({message:Tk.errors.invalidRequestMethod(),data:e});if(void 0!==n&&!Array.isArray(n)&&(\"object\"!=typeof n||null===n))throw sC({message:Tk.errors.invalidRequestParams(),data:e});const r=null==n?{method:t}:{method:t,params:n};return new Promise(((e,t)=>{this._rpcRequest(r,zC(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(Tk.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let n;this._state.isConnected=!1,e?(n=new oC(1013,t??Tk.errors.disconnected()),this._log.debug(n)):(n=new oC(1011,t??Tk.errors.permanentlyDisconnected()),this._log.error(n),GC(this,JC,null),this._state.accounts=null,GC(this,XC,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit(\"disconnect\",n)}}_handleChainChanged({chainId:e}={}){UC(e)?(this._handleConnect(e),e!==VC(this,JC)&&(GC(this,JC,e),this._state.initialized&&this.emit(\"chainChanged\",VC(this,JC)))):this._log.error(Tk.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(!tx(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,VC(this,XC)!==n[0]&&GC(this,XC,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.\")}};JC=new WeakMap,XC=new WeakMap,nx._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var rx=nx;function ix(e={}){const t={},n=new Hn.Duplex({objectMode:!0,read:()=>{},write:function(n,o,a){let s=null;try{!n.id?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):function(e){const{id:n}=e;if(null===n)return;const r=t[n];if(!r)return void console.warn(`StreamMiddleware - Unknown response id \"${n}\"`);delete t[n],Object.assign(r.res,e),setTimeout(r.end)}(n)}catch(e){s=e}a(s)}}),r=new LC;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)}}var ox={},ax={exports:{}},sx=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;nt.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]=yx}_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!==yx&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream \"${r}\"`),n())}};ox.ObjectMultiplex=wx;var _x=r(ox.ObjectMultiplex);const Sx=e=>null!==e&&\"object\"==typeof e&&\"function\"==typeof e.pipe;Sx.writable=e=>Sx(e)&&!1!==e.writable&&\"function\"==typeof e._write&&\"object\"==typeof e._writableState,Sx.readable=e=>Sx(e)&&!1!==e.readable&&\"function\"==typeof e._read&&\"object\"==typeof e._readableState,Sx.duplex=e=>Sx.writable(e)&&Sx.readable(e),Sx.transform=e=>Sx.duplex(e)&&\"function\"==typeof e._transform;var Ex,kx=Sx,Mx=class extends rx{constructor(e,{jsonRpcStreamName:t,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!kx.duplex(e))throw new Error(Tk.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new _x;Hn.pipeline(e,o,e,this._handleStreamDisconnect.bind(this,\"MetaMask\")),this._jsonRpcConnection=ix({retryOnMessage:\"METAMASK_EXTENSION_CONNECT_CAN_RETRY\"}),Hn.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):DC.includes(n)?this.emit(\"message\",{type:n,data:r}):\"METAMASK_STREAM_FAILURE\"===n&&e.destroy(new Error(Tk.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}={}){UC(e)&&(e=>Boolean(e)&&\"string\"==typeof e)(t)?\"loading\"===t?this._handleDisconnect(!0):super._handleChainChanged({chainId:e}):this._log.error(Tk.errors.invalidNetworkParams(),{chainId:e,networkVersion:t})}},Cx=class extends Mx{constructor(e,{jsonRpcStreamName:t=\"metamask-provider\",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(e,{jsonRpcStreamName:t,logger:n,maxEventListeners:r,rpcMiddleware:jC(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},YC(this,Ex,void 0),this._initializeStateAsync(),GC(this,Ex,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;DC.includes(t)&&(this.emit(\"data\",e),this.emit(\"notification\",e.params.result))})),i)if(\"complete\"===document.readyState)KC(this._rpcEngine,this._log);else{const e=()=>{KC(this._rpcEngine,this._log),window.removeEventListener(\"DOMContentLoaded\",e)};window.addEventListener(\"DOMContentLoaded\",e)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Tk.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Tk.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),VC(this,Ex)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Tk.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),VC(this,Ex)&&!e&&GC(this,Ex,null)}_warnOfDeprecation(e){!1===this._sentWarnings?.events[e]&&(this._log.warn(Tk.warnings.events[e]),this._sentWarnings.events[e]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Tk.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((e,t)=>{try{this._rpcRequest({method:\"eth_requestAccounts\",params:[]},zC(e,t))}catch(e){t(e)}}))}send(e,t){return this._sentWarnings.send||(this._log.warn(Tk.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},zC(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,FC),t=!0;break;case\"net_version\":t=VC(this,Ex)??null;break;default:throw new Error(Tk.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 sC({message:\"Batch requests must be made with an array of request objects.\",data:e});return new Promise(((t,n)=>{this._rpcRequest(e,zC(t,n))}))}},{get:(e,t,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Tk.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!==VC(this,Ex)&&(GC(this,Ex,t),this._state.initialized&&this.emit(\"networkChanged\",VC(this,Ex)))}};Ex=new WeakMap;const xx=DM(\"MM_SDK\");xx.color=\"#FFAC1C\";var Ax={},Rx={};Object.defineProperty(Rx,\"__esModule\",{value:!0}),Rx.EthereumProviderError=Rx.EthereumRpcError=void 0;const Tx=WM;class Px 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 Tx.default(this.serialize(),Lx,2)}}Rx.EthereumRpcError=Px;function Lx(e,t){if(\"[Circular]\"!==t)return t}Rx.EthereumProviderError=class extends Px{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 Ix={},Ox={};Object.defineProperty(Ox,\"__esModule\",{value:!0}),Ox.errorValues=Ox.errorCodes=void 0,Ox.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}},Ox.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=Ox,n=Rx,r=t.errorCodes.rpc.internal,i=\"Unspecified error message. This is a bug, please report it.\",o={code:r,message:a(r)};function a(n,r=i){if(Number.isInteger(n)){const r=n.toString();if(c(t.errorValues,r))return t.errorValues[r].message;if(u(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]||!!u(e)}function u(e){return e>=-32099&&e<=-32e3}function l(e){return e&&\"object\"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE=\"Unspecified server error.\",e.getMessageFromCode=a,e.isValidCode=s,e.serializeError=function(e,{fallbackError:t=o,shouldIncludeStack:r=!1}={}){var i,u;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 d={};if(e&&\"object\"==typeof e&&!Array.isArray(e)&&c(e,\"code\")&&s(e.code)){const t=e;d.code=t.code,t.message&&\"string\"==typeof t.message?(d.message=t.message,c(t,\"data\")&&(d.data=t.data)):(d.message=a(d.code),d.data={originalError:l(e)})}else{d.code=t.code;const n=null===(i=e)||void 0===i?void 0:i.message;d.message=n&&\"string\"==typeof n?n:t.message,d.data={originalError:l(e)}}const f=null===(u=e)||void 0===u?void 0:u.stack;return r&&e&&f&&\"string\"==typeof f&&(d.stack=f),d}}(Ix);var Nx={};Object.defineProperty(Nx,\"__esModule\",{value:!0}),Nx.ethErrors=void 0;const Dx=Rx,jx=Ix,Bx=Ox;function zx(e,t){const[n,r]=Fx(t);return new Dx.EthereumRpcError(e,n||jx.getMessageFromCode(e),r)}function Ux(e,t){const[n,r]=Fx(t);return new Dx.EthereumProviderError(e,n||jx.getMessageFromCode(e),r)}function Fx(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[]}Nx.ethErrors={rpc:{parse:e=>zx(Bx.errorCodes.rpc.parse,e),invalidRequest:e=>zx(Bx.errorCodes.rpc.invalidRequest,e),invalidParams:e=>zx(Bx.errorCodes.rpc.invalidParams,e),methodNotFound:e=>zx(Bx.errorCodes.rpc.methodNotFound,e),internal:e=>zx(Bx.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 zx(t,e)},invalidInput:e=>zx(Bx.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>zx(Bx.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>zx(Bx.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>zx(Bx.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>zx(Bx.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>zx(Bx.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>Ux(Bx.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>Ux(Bx.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>Ux(Bx.errorCodes.provider.unsupportedMethod,e),disconnected:e=>Ux(Bx.errorCodes.provider.disconnected,e),chainDisconnected:e=>Ux(Bx.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 Dx.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=Rx;Object.defineProperty(e,\"EthereumRpcError\",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,\"EthereumProviderError\",{enumerable:!0,get:function(){return t.EthereumProviderError}});const n=Ix;Object.defineProperty(e,\"serializeError\",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(e,\"getMessageFromCode\",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=Nx;Object.defineProperty(e,\"ethErrors\",{enumerable:!0,get:function(){return r.ethErrors}});const i=Ox;Object.defineProperty(e,\"errorCodes\",{enumerable:!0,get:function(){return i.errorCodes}})}(Ax);const Kx={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\"},qx={[Kx.ETH_REQUESTACCOUNTS]:!0,[Kx.ETH_SENDTRANSACTION]:!0,[Kx.ETH_SIGNTRANSACTION]:!0,[Kx.ETH_SIGN]:!0,[Kx.PERSONAL_SIGN]:!0,[Kx.ETH_ACCOUNTS]:!1,[Kx.ETH_CHAINID]:!1,[Kx.PERSONAL_SIGN]:!0,[Kx.ETH_SIGNTYPEDDATA]:!0,[Kx.ETH_SIGNTYPEDDATA_V3]:!0,[Kx.ETH_SIGNTYPEDDATA_V4]:!0,[Kx.WALLET_REQUESTPERMISSIONS]:!0,[Kx.WALLET_GETPERMISSIONS]:!0,[Kx.WALLET_WATCHASSET]:!0,[Kx.WALLET_ADDETHEREUMCHAIN]:!0,[Kx.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[Kx.METAMASK_CONNECTSIGN]:!0,[Kx.METAMASK_CONNECTWITH]:!0,[Kx.PERSONAL_EC_RECOVER]:!0,[Kx.METAMASK_BATCH]:!0,[Kx.METAMASK_OPEN]:!0},Hx=Object.keys(qx).map((e=>e.toLowerCase())),Wx=[\"eth_signTypedData\",\"eth_signTypedData_v3\",\"eth_signTypedData_v4\",\"eth_sign\"].map((e=>e.toLowerCase())),$x=\".sdk-comm\",Vx=\"providerType\",Yx=\".MMSDK_cached_address\",Gx=\".MMSDK_cached_chainId\",Zx={CHAIN_CHANGED:\"chainChanged\",ACCOUNTS_CHANGED:\"accountsChanged\",DISCONNECT:\"disconnect\",CONNECT:\"connect\",CONNECTED:\"connected\"};class Qx{constructor({enabled:e}={enabled:!1}){this.enabled=!1,this.enabled=e}persistChannelConfig(e){return kk(this,void 0,void 0,(function*(){const t=JSON.stringify(e);xx(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,e),localStorage.setItem($x,t)}))}getPersistedChannelConfig(){return kk(this,void 0,void 0,(function*(){let e;try{if(xx(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),e=localStorage.getItem($x),xx(\"[StorageManagerWeb: getPersistedChannelConfig()]\",e),!e)return;const t=JSON.parse(e);return xx(\"[StorageManagerWeb: getPersistedChannelConfig()] channelConfig\",t),t}catch(e){return void console.error(\"[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config\",e)}}))}persistAccounts(e){return kk(this,void 0,void 0,(function*(){xx(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,e);const t=JSON.stringify(e);localStorage.setItem(Yx,t)}))}getCachedAccounts(){return kk(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Yx);return e?JSON.parse(e):[]}catch(e){throw console.error(\"[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts\",e),e}}))}persistChainId(e){return kk(this,void 0,void 0,(function*(){xx(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,e),localStorage.setItem(Gx,e)}))}getCachedChainId(){return kk(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Gx);return null!=e?e:void 0}catch(e){throw console.error(\"[StorageManagerWeb: getCachedChainId()] Error reading cached chainId\",e),e}}))}terminate(){return kk(this,void 0,void 0,(function*(){xx(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem($x)}))}}const Jx=e=>new Qx(e);class Xx extends Cx{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:\"\"},xx(`[SDKProvider: constructor()] autoRequestAccounts=${n}`),this.state.autoRequestAccounts=n}forceInitializeState(){return kk(this,void 0,void 0,(function*(){return xx(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){xx(\"[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())||\"\":(xx(\"[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;xx(`[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\",Ax.ethErrors.provider.disconnected()),n.providerStateRequested=!1}({terminate:e,instance:this})}_initializeStateAsync(){return kk(this,void 0,void 0,(function*(){return function(e){var t,n;return kk(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)xx(\"[SDKProvider: initializeStateAsync()] initialization already in progress\");else{let o;r.providerStateRequested=!0;let a=null,s=!1,u=!1;const l=Jx({enabled:!0});if(l){const e=yield l.getPersistedChannelConfig({});s=null!==(t=null==e?void 0:e.relayPersistence)&&void 0!==t&&t,o=yield l.getCachedChainId();const n=yield l.getCachedAccounts();n.length>0&&(a=n[0])}if(xx(`[SDKProvider: initializeStateAsync()] relayPersistence=${s}`,{relayPersistence:s,cachedChainId:o,cachedSelectedAddress:a}),s)if(o&&a)i={accounts:[a],chainId:o,isUnlocked:!1},u=!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{xx(\"[SDKProvider: initializeStateAsync()] Fetch accounts remotely.\");const t=yield e.request({method:\"eth_requestAccounts\",params:[]});i.accounts=t}e._initializeState(i),r.providerStateRequested=!1,u&&(e._state.isConnected=!0,e.emit(\"connect\",{chainId:null==i?void 0:i.chainId}))}}))}(this)}))}_initializeState(e){return xx(\"[SDKProvider: _initializeState()]\",e),function(e,t,n){return xx(\"[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}){xx(`[SDKProvider: handleChainChanged()] chainId=${t} networkVersion=${n}`);let i=n;n||(xx(\"[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 eA={exports:{}};!function(e,t){!function(t){var n=Object.hasOwnProperty,r=Array.isArray?Array.isArray:function(e){return\"[object Array]\"===Object.prototype.toString.call(e)},i=\"object\"==typeof je&&!0,o=\"function\"==typeof Symbol,a=\"object\"==typeof Reflect,s=\"function\"==typeof setImmediate?setImmediate:setTimeout,u=o?a&&\"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 l(){this._events={},this._conf&&c.call(this,this._conf)}function c(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(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+\".\"),void 0!==je&&je.emitWarning){var r=new Error(n);r.name=\"MaxListenersExceededWarning\",r.emitter=this,r.count=e,je.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var f=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 h(e,n){for(var r={},i=e.length,o=n?n.length:0,a=0;a0;)if(o===e[a])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,a=this._listeners,s=function(){var r=f.apply(null,arguments),a={data:r,name:t,original:e};n?!1!==n.call(i,a)&&o.emit.apply(o,[a.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(a[e])throw Error(\"Event '\"+e+\"' is already listening\");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===a[e]&&(a[e]=s,r._on.call(i,e,s))},o.on(\"newListener\",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&a[e]&&(a[e]=null,r._off.call(i,e,s))},a[e]=null,o.on(\"removeListener\",this._onRemoveListener)):(a[e]=s,r._on.call(i,e,s))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,a=this._emitter,s=this._off,l=this._target;if(e&&\"string\"!=typeof e)throw TypeError(\"event must be a string\");function c(){i._onNewListener&&(a.off(\"newListener\",i._onNewListener),a.off(\"removeListener\",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=o[e]))return;s.call(l,e,t),delete o[e],--this._listenersCount||c()}else{for(r=(n=u(o)).length;r-- >0;)e=n[r],s.call(l,e,o[e]);this._listeners={},this._listenersCount=0,c()}}});var b=v([\"function\"]),y=v([\"object\",\"function\"]);function w(e,t,n){var r,i,o,a=0,s=new e((function(u,l,c){function d(){i&&(i=null),a&&(clearTimeout(a),a=0)}n=m(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 c;var f=function(e){d(),u(e)},h=function(e){d(),l(e)};r?t(f,h,c):(i=[function(e){h(e||Error(\"canceled\"))}],t(f,h,(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&&(a=setTimeout((function(){var e=Error(\"timeout\");e.code=\"ETIMEDOUT\",a=0,s.cancel(e),l(e)}),n.timeout))}));return r||(s.cancel=function(e){if(i){for(var t=i.length,n=1;n0;)\"_listeners\"!==(h=b[s])&&(y=S(e,t,n[h],r+1,i))&&(w?w.push.apply(w,y):w=y);return w}if(\"**\"===_){for((v=r+1===i||r+2===i&&\"*\"===E)&&n._listeners&&(w=S(e,t,n,i,i)),s=(b=u(n)).length;s-- >0;)\"_listeners\"!==(h=b[s])&&(\"*\"===h||\"**\"===h?(n[h]._listeners&&!v&&(y=S(e,t,n[h],i,i))&&(w?w.push.apply(w,y):w=y),y=S(e,t,n[h],r,i)):y=S(e,t,n[h],h===E?r+2:r,i),y&&(w?w.push.apply(w,y):w=y));return w}n[_]&&(w=S(e,t,n[_],r+1,i))}if((p=n[\"*\"])&&S(e,t,p,r+1,i),m=n[\"**\"])if(r0;)\"_listeners\"!==(h=b[s])&&(h===E?S(e,t,m[h],r+2,i):h===_?S(e,t,m[h],r+1,i):((g={})[h]=m[h],S(e,t,{\"**\":g},r+1,i)));else m._listeners?S(e,t,m,i,i):m[\"*\"]&&m[\"*\"]._listeners&&S(e,t,m[\"*\"],i,i);return w}function E(e,t,n){var r,i,o=0,a=0,s=this.delimiter,u=s.length;if(\"string\"==typeof e)if(-1!==(r=e.indexOf(s))){i=new Array(5);do{i[o++]=e.slice(a,r),a=r+u}while(-1!==(r=e.indexOf(s,a)));i[o++]=e.slice(a)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+10&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,d.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}function k(e,t,n,r){for(var i,o,a,s,l=u(e),c=l.length,d=e._listeners;c-- >0;)i=e[o=l[c]],a=\"_listeners\"===o?n:n?n.concat(o):[o],s=r||\"symbol\"==typeof o,d&&t.push(s?a:a.join(this.delimiter)),\"object\"==typeof i&&k.call(this,i,t,a,s);return t}function M(e){for(var t,n,r,i=u(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,\"_listeners\"===n||M(t)||delete e[n]);return r}function C(e,t,n){this.emitter=e,this.event=t,this.listener=n}function x(e,n,r){if(!0===r)a=!0;else if(!1===r)o=!0;else{if(!r||\"object\"!=typeof r)throw TypeError(\"options should be an object or true\");var o=r.async,a=r.promisify,u=r.nextTick,l=r.objectify}if(o||u||a){var c=n,d=n._origin||n;if(u&&!i)throw Error(\"process.nextTick is not supported\");a===t&&(a=\"AsyncFunction\"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?u?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,c.apply(t,e)})):(u?Ee:s)((function(){t.event=n,c.apply(t,e)}))},n._async=!0,n._origin=d}return[n,l?new C(this,e,n):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,e)}C.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},A.EventEmitter2=A,A.prototype.listenTo=function(e,n,i){if(\"object\"!=typeof e)throw TypeError(\"target musts be an object\");var o=this;function a(t){if(\"object\"!=typeof t)throw TypeError(\"events must be an object\");var n,r=i.reducers,a=_.call(o,e);n=-1===a?new p(o,e,i):o._observers[a];for(var s,l=u(t),c=l.length,d=\"function\"==typeof r,f=0;f0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},A.prototype.delimiter=\".\",A.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event=\"\",A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.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 a(){return 0==--t&&o.off(e,a),n.apply(this,arguments)}return a._origin=n,this._on(e,a,r,i)},A.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var e,t,n,r,i,a,s=arguments[0],u=this.wildcard;if(\"newListener\"===s&&!this._newListener&&!this._events.newListener)return!1;if(u&&(e=s,\"newListener\"!==s&&\"removeListener\"!==s&&\"object\"==typeof s)){if(n=s.length,o)for(r=0;r3)for(t=new Array(d-1),i=1;i3)for(n=new Array(f-1),a=1;a0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=n,a)},A.prototype.off=function(e,t){if(\"function\"!=typeof t)throw new Error(\"removeListener only takes instances of Function\");var n,i=[];if(this.wildcard){var o=\"string\"==typeof e?e.split(this.delimiter):e.slice();if(!(i=S.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var a=0;a0){for(n=0,r=(t=this._all).length;n0;)\"function\"==typeof(r=s[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var l=[],c=\"string\"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,l,c,a,0),l}return s&&(r=s[e])?\"function\"==typeof r?[r]:r:[]},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?k.call(this,this.listenerTree,[],null,e):t?u(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(e){if(this.wildcard){var n=[],r=\"string\"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?u(i).length:i[e]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(e,n){var r=this,i=typeof n;return\"number\"===i?n={timeout:n}:\"function\"===i&&(n={filter:n}),w((n=m(n,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:b,Promise:g})).Promise,(function(t,i,o){function a(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(e,a),n.handleError){var s=arguments[0];s?i(s):t(f.apply(null,arguments).slice(1))}else t(f.apply(null,arguments))}o((function(){r.off(e,a)})),r._on(e,a,!1)}),{timeout:n.timeout,overload:n.overload})};var R=A.prototype;Object.defineProperties(A,{defaultMaxListeners:{get:function(){return R._maxListeners},set:function(e){if(\"number\"!=typeof e||e<0||Number.isNaN(e))throw TypeError(\"n must be a non-negative number\");R._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=m(n,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,(function(n,r,i){var o;if(\"function\"==typeof e.addEventListener)return o=function(){n(f.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var a,s=function(){a&&e.removeListener(\"error\",a),n(f.apply(null,arguments))};\"error\"!==t&&(a=function(n){e.removeListener(t,s),r(n)},e.once(\"error\",a)),i((function(){a&&e.removeListener(\"error\",a),e.removeListener(t,s)})),e.once(t,s)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(R,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),\"function\"==typeof t&&t.amd?t((function(){return A})):e.exports=A}()}(eA);var tA=r(eA.exports);const nA={type:\"logger\",log(e){this.output(\"log\",e)},warn(e){this.output(\"warn\",e)},error(e){this.output(\"error\",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class rA{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.init(e,t)}init(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||\"i18next:\",this.logger=e||nA,this.options=t,this.debug=t.debug}log(){for(var e=arguments.length,t=new Array(e),n=0;n{this.observers[e]||(this.observers[e]=new Map);const n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)})),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{let[t,r]=e;for(let e=0;e{let[r,i]=t;for(let t=0;t{e=n,t=r}));return n.resolve=e,n.reject=t,n}function sA(e){return null==e?\"\":\"\"+e}const uA=/###/g;function lA(e,t,n){function r(e){return e&&e.indexOf(\"###\")>-1?e.replace(uA,\".\"):e}function i(){return!e||\"string\"==typeof e}const o=\"string\"!=typeof t?t:t.split(\".\");let a=0;for(;a\":\">\",'\"':\""\",\"'\":\"'\",\"/\":\"/\"};function mA(e){return\"string\"==typeof e?e.replace(/[&<>\"'\\/]/g,(e=>pA[e])):e}const gA=[\" \",\",\",\"?\",\"!\",\";\"],vA=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}(20);function bA(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:\".\";if(!e)return;if(e[t])return e[t];const r=t.split(n);let i=e;for(let e=0;e-1&&a0?e.replace(\"_\",\"-\"):e}class wA extends oA{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:[\"translation\"],defaultNS:\"translation\"};super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator=\".\"),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(\".\")>-1?a=e.split(\".\"):(a=[e,t],n&&(Array.isArray(n)?a.push(...n):\"string\"==typeof n&&i?a.push(...n.split(i)):a.push(n)));const s=dA(this.data,a);return!s&&!t&&!n&&e.indexOf(\".\")>-1&&(e=a[0],t=a[1],n=a.slice(2).join(\".\")),s||!o||\"string\"!=typeof n?s:bA(this.data&&this.data[e]&&this.data[e][t],n,i)}addResource(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator;let a=[e,t];n&&(a=a.concat(o?n.split(o):n)),e.indexOf(\".\")>-1&&(a=e.split(\".\"),r=t,t=a[1]),this.addNamespaces(t),cA(this.data,a,r),i.silent||this.emit(\"added\",e,t,n,r)}addResources(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const r in n)(\"string\"==typeof n[r]||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(\"added\",e,t,n)}addResourceBundle(e,t,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1,skipCopy:!1},a=[e,t];e.indexOf(\".\")>-1&&(a=e.split(\".\"),r=n,n=t,t=a[1]),this.addNamespaces(t);let s=dA(this.data,a)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?fA(s,n,i):s={...s,...n},cA(this.data,a,s),o.silent||this.emit(\"added\",e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(\"removed\",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),\"v1\"===this.options.compatibilityAPI?{...this.getResource(e,t)}:this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((e=>t[e]&&Object.keys(t[e]).length>0))}toJSON(){return this.data}}var _A={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach((e=>{this.processors[e]&&(t=this.processors[e].process(t,n,r,i))})),t}};const SA={};class EA extends oA{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),function(e,t,n){e.forEach((e=>{t[e]&&(n[e]=t[e])}))}([\"resourceStore\",\"languageUtils\",\"pluralResolver\",\"interpolator\",\"backendConnector\",\"i18nFormat\",\"utils\"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator=\".\"),this.logger=iA.create(\"translator\")}changeLanguage(e){e&&(this.language=e)}exists(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;const n=this.resolve(e,t);return n&&void 0!==n.res}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=\":\");const r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let i=t.ns||this.options.defaultNS||[];const o=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||\"\",n=n||\"\";const r=gA.filter((e=>t.indexOf(e)<0&&n.indexOf(e)<0));if(0===r.length)return!0;const i=vA.getRegExp(`(${r.map((e=>\"?\"===e?\"\\\\?\":e)).join(\"|\")})`);let o=!i.test(e);if(!o){const t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(o=!0)}return o}(e,n,r));if(o&&!a){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:i};const o=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(r)}return\"string\"==typeof i&&(i=[i]),{key:e,namespaces:i}}translate(e,t,n){if(\"object\"!=typeof t&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),\"object\"==typeof t&&(t={...t}),t||(t={}),null==e)return\"\";Array.isArray(e)||(e=[String(e)]);const r=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,{key:o,namespaces:a}=this.extractFromKey(e[e.length-1],t),s=a[a.length-1],u=t.lng||this.language,l=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&\"cimode\"===u.toLowerCase()){if(l){const e=t.nsSeparator||this.options.nsSeparator;return r?{res:`${s}${e}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:s,usedParams:this.getUsedParamsDetails(t)}:`${s}${e}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:s,usedParams:this.getUsedParamsDetails(t)}:o}const c=this.resolve(e,t);let d=c&&c.res;const f=c&&c.usedKey||o,h=c&&c.exactUsedKey||o,p=Object.prototype.toString.apply(d),m=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject;if(g&&d&&(\"string\"!=typeof d&&\"boolean\"!=typeof d&&\"number\"!=typeof d)&&[\"[object Number]\",\"[object Function]\",\"[object RegExp]\"].indexOf(p)<0&&(\"string\"!=typeof m||!Array.isArray(d))){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(\"accessing an object - but returnObjects options is not enabled!\");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,d,{...t,ns:a}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(c.res=e,c.usedParams=this.getUsedParamsDetails(t),c):e}if(i){const e=Array.isArray(d),n=e?[]:{},r=e?h:f;for(const e in d)if(Object.prototype.hasOwnProperty.call(d,e)){const o=`${r}${i}${e}`;n[e]=this.translate(o,{...t,joinArrays:!1,ns:a}),n[e]===o&&(n[e]=d[e])}d=n}}else if(g&&\"string\"==typeof m&&Array.isArray(d))d=d.join(m),d&&(d=this.extendTranslation(d,e,t,n));else{let r=!1,a=!1;const l=void 0!==t.count&&\"string\"!=typeof t.count,f=EA.hasDefaultValue(t),h=l?this.pluralResolver.getSuffix(u,t.count,t):\"\",p=t.ordinal&&l?this.pluralResolver.getSuffix(u,t.count,{ordinal:!1}):\"\",m=l&&!t.ordinal&&0===t.count&&this.pluralResolver.shouldUseIntlApi(),g=m&&t[`defaultValue${this.options.pluralSeparator}zero`]||t[`defaultValue${h}`]||t[`defaultValue${p}`]||t.defaultValue;!this.isValidLookup(d)&&f&&(r=!0,d=g),this.isValidLookup(d)||(a=!0,d=o);const v=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:d,b=f&&g!==d&&this.options.updateMissing;if(a||r||b){if(this.logger.log(b?\"updateKey\":\"missingKey\",u,s,o,b?g:d),i){const e=this.resolve(o,{...t,keySeparator:!1});e&&e.res&&this.logger.warn(\"Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.\")}let e=[];const n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if(\"fallback\"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t{const i=f&&r!==d?r:v;this.options.missingKeyHandler?this.options.missingKeyHandler(e,s,n,i,b,t):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(e,s,n,i,b,t),this.emit(\"missingKey\",e,s,n,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&l?e.forEach((e=>{const n=this.pluralResolver.getSuffixes(e,t);m&&t[`defaultValue${this.options.pluralSeparator}zero`]&&n.indexOf(`${this.options.pluralSeparator}zero`)<0&&n.push(`${this.options.pluralSeparator}zero`),n.forEach((n=>{r([e],o+n,t[`defaultValue${n}`]||g)}))})):r(e,o,g))}d=this.extendTranslation(d,e,t,c,n),a&&d===o&&this.options.appendNamespaceToMissingKey&&(d=`${s}:${o}`),(a||r)&&this.options.parseMissingKeyHandler&&(d=\"v1\"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${s}:${o}`:o,r?d:void 0):this.options.parseMissingKeyHandler(d))}return r?(c.res=d,c.usedParams=this.getUsedParamsDetails(t),c):d}extendTranslation(e,t,n,r,i){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const a=\"string\"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let s;if(a){const t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let u=n.replace&&\"string\"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,n.lng||this.language,n),a){const t=e.match(this.interpolator.nestingRegexp);s<(t&&t.length)&&(n.nest=!1)}!n.lng&&\"v1\"!==this.options.compatibilityAPI&&r&&r.res&&(n.lng=r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,r=new Array(e),a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return\"string\"==typeof e&&(e=[e]),e.forEach((e=>{if(this.isValidLookup(t))return;const s=this.extractFromKey(e,a),u=s.key;n=u;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));const c=void 0!==a.count&&\"string\"!=typeof a.count,d=c&&!a.ordinal&&0===a.count&&this.pluralResolver.shouldUseIntlApi(),f=void 0!==a.context&&(\"string\"==typeof a.context||\"number\"==typeof a.context)&&\"\"!==a.context,h=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);l.forEach((e=>{this.isValidLookup(t)||(o=e,!SA[`${h[0]}-${e}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(SA[`${h[0]}-${e}`]=!0,this.logger.warn(`key \"${n}\" for languages \"${h.join(\", \")}\" won't get resolved as namespace \"${o}\" was not yet loaded`,\"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!\")),h.forEach((n=>{if(this.isValidLookup(t))return;i=n;const o=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,u,n,e,a);else{let e;c&&(e=this.pluralResolver.getSuffix(n,a.count,a));const t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(o.push(u+e),a.ordinal&&0===e.indexOf(r)&&o.push(u+e.replace(r,this.options.pluralSeparator)),d&&o.push(u+t)),f){const n=`${u}${this.options.contextSeparator}${a.context}`;o.push(n),c&&(o.push(n+e),a.ordinal&&0===e.indexOf(r)&&o.push(n+e.replace(r,this.options.pluralSeparator)),d&&o.push(n+t))}}let s;for(;s=o.pop();)this.isValidLookup(t)||(r=s,t=this.getResource(n,e,s,a))})))}))})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:o}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&\"\"===e)}getResource(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[\"defaultValue\",\"ordinal\",\"context\",\"replace\",\"lng\",\"lngs\",\"fallbackLng\",\"ns\",\"keySeparator\",\"nsSeparator\",\"returnObjects\",\"returnDetails\",\"joinArrays\",\"postProcess\",\"interpolation\"],n=e.replace&&\"string\"!=typeof e.replace;let r=n?e.replace:e;if(n&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(const e of t)delete r[e]}return r}static hasDefaultValue(e){const t=\"defaultValue\";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,12)&&void 0!==e[n])return!0;return!1}}function kA(e){return e.charAt(0).toUpperCase()+e.slice(1)}class MA{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iA.create(\"languageUtils\")}getScriptPartFromCode(e){if(!(e=yA(e))||e.indexOf(\"-\")<0)return null;const t=e.split(\"-\");return 2===t.length?null:(t.pop(),\"x\"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join(\"-\")))}getLanguagePartFromCode(e){if(!(e=yA(e))||e.indexOf(\"-\")<0)return e;const t=e.split(\"-\");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(\"string\"==typeof e&&e.indexOf(\"-\")>-1){const t=[\"hans\",\"hant\",\"latn\",\"cyrl\",\"cans\",\"mong\",\"arab\"];let n=e.split(\"-\");return this.options.lowerCaseLng?n=n.map((e=>e.toLowerCase())):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=kA(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),\"sgn\"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=kA(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=kA(n[2].toLowerCase()))),n.join(\"-\")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(\"languageOnly\"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach((e=>{if(t)return;const n=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(n)||(t=n)})),!t&&this.options.supportedLngs&&e.forEach((e=>{if(t)return;const n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find((e=>e===n?e:e.indexOf(\"-\")<0&&n.indexOf(\"-\")<0?void 0:e.indexOf(\"-\")>0&&n.indexOf(\"-\")<0&&e.substring(0,e.indexOf(\"-\"))===n||0===e.indexOf(n)&&n.length>1?e:void 0))})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(\"function\"==typeof e&&(e=e(t)),\"string\"==typeof e&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return\"string\"==typeof e&&(e.indexOf(\"-\")>-1||e.indexOf(\"_\")>-1)?(\"languageOnly\"!==this.options.load&&i(this.formatLanguageCode(e)),\"languageOnly\"!==this.options.load&&\"currentOnly\"!==this.options.load&&i(this.getScriptPartFromCode(e)),\"currentOnly\"!==this.options.load&&i(this.getLanguagePartFromCode(e))):\"string\"==typeof e&&i(this.formatLanguageCode(e)),n.forEach((e=>{r.indexOf(e)<0&&i(this.formatLanguageCode(e))})),r}}let CA=[{lngs:[\"ach\",\"ak\",\"am\",\"arn\",\"br\",\"fil\",\"gun\",\"ln\",\"mfe\",\"mg\",\"mi\",\"oc\",\"pt\",\"pt-BR\",\"tg\",\"tl\",\"ti\",\"tr\",\"uz\",\"wa\"],nr:[1,2],fc:1},{lngs:[\"af\",\"an\",\"ast\",\"az\",\"bg\",\"bn\",\"ca\",\"da\",\"de\",\"dev\",\"el\",\"en\",\"eo\",\"es\",\"et\",\"eu\",\"fi\",\"fo\",\"fur\",\"fy\",\"gl\",\"gu\",\"ha\",\"hi\",\"hu\",\"hy\",\"ia\",\"it\",\"kk\",\"kn\",\"ku\",\"lb\",\"mai\",\"ml\",\"mn\",\"mr\",\"nah\",\"nap\",\"nb\",\"ne\",\"nl\",\"nn\",\"no\",\"nso\",\"pa\",\"pap\",\"pms\",\"ps\",\"pt-PT\",\"rm\",\"sco\",\"se\",\"si\",\"so\",\"son\",\"sq\",\"sv\",\"sw\",\"ta\",\"te\",\"tk\",\"ur\",\"yo\"],nr:[1,2],fc:2},{lngs:[\"ay\",\"bo\",\"cgg\",\"fa\",\"ht\",\"id\",\"ja\",\"jbo\",\"ka\",\"km\",\"ko\",\"ky\",\"lo\",\"ms\",\"sah\",\"su\",\"th\",\"tt\",\"ug\",\"vi\",\"wo\",\"zh\"],nr:[1],fc:3},{lngs:[\"be\",\"bs\",\"cnr\",\"dz\",\"hr\",\"ru\",\"sr\",\"uk\"],nr:[1,2,5],fc:4},{lngs:[\"ar\"],nr:[0,1,2,3,11,100],fc:5},{lngs:[\"cs\",\"sk\"],nr:[1,2,5],fc:6},{lngs:[\"csb\",\"pl\"],nr:[1,2,5],fc:7},{lngs:[\"cy\"],nr:[1,2,3,8],fc:8},{lngs:[\"fr\"],nr:[1,2],fc:9},{lngs:[\"ga\"],nr:[1,2,3,7,11],fc:10},{lngs:[\"gd\"],nr:[1,2,3,20],fc:11},{lngs:[\"is\"],nr:[1,2],fc:12},{lngs:[\"jv\"],nr:[0,1],fc:13},{lngs:[\"kw\"],nr:[1,2,3,4],fc:14},{lngs:[\"lt\"],nr:[1,2,10],fc:15},{lngs:[\"lv\"],nr:[1,2,0],fc:16},{lngs:[\"mk\"],nr:[1,2],fc:17},{lngs:[\"mnk\"],nr:[0,1,2],fc:18},{lngs:[\"mt\"],nr:[1,2,11,20],fc:19},{lngs:[\"or\"],nr:[2,1],fc:2},{lngs:[\"ro\"],nr:[1,2,20],fc:20},{lngs:[\"sl\"],nr:[5,1,2,3],fc:21},{lngs:[\"he\",\"iw\"],nr:[1,2,20,21],fc:22}],xA={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}};const AA=[\"v1\",\"v2\",\"v3\"],RA=[\"v4\"],TA={zero:0,one:1,two:2,few:3,many:4,other:5};class PA{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=iA.create(\"pluralResolver\"),this.options.compatibilityJSON&&!RA.includes(this.options.compatibilityJSON)||\"undefined\"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON=\"v3\",this.logger.error(\"Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.\")),this.rules=function(){const e={};return CA.forEach((t=>{t.lngs.forEach((n=>{e[n]={numbers:t.nr,plurals:xA[t.fc]}}))})),e}()}addRule(e,t){this.rules[e]=t}getRule(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(yA(\"dev\"===e?\"en\":e),{type:t.ordinal?\"ordinal\":\"cardinal\"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}getPluralFormsOfKey(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((e=>`${t}${e}`))}getSuffixes(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.getRule(e,t);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(((e,t)=>TA[e]-TA[t])).map((e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:\"\"}${e}`)):n.numbers.map((n=>this.getSuffix(e,n,t))):[]}getSuffix(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=this.getRule(e,n);return r?this.shouldUseIntlApi()?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:\"\"}${r.select(t)}`:this.getSuffixRetroCompatible(r,t):(this.logger.warn(`no plural rule found for: ${e}`),\"\")}getSuffixRetroCompatible(e,t){const n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t));let r=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r=\"plural\":1===r&&(r=\"\"));const i=()=>this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString();return\"v1\"===this.options.compatibilityJSON?1===r?\"\":\"number\"==typeof r?`_plural_${r.toString()}`:i():\"v2\"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}shouldUseIntlApi(){return!AA.includes(this.options.compatibilityJSON)}}function LA(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:\".\",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(e,t,n){const r=dA(e,n);return void 0!==r?r:dA(t,n)}(e,t,n);return!o&&i&&\"string\"==typeof n&&(o=bA(e,n,r),void 0===o&&(o=bA(t,n,r))),o}class IA{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=iA.create(\"interpolator\"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(e=>e),this.init(e)}init(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:o,suffix:a,suffixEscaped:s,formatSeparator:u,unescapeSuffix:l,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:h,nestingSuffixEscaped:p,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:v}=e.interpolation;this.escape=void 0!==t?t:mA,this.escapeValue=void 0===n||n,this.useRawValueToEscape=void 0!==r&&r,this.prefix=i?hA(i):o||\"{{\",this.suffix=a?hA(a):s||\"}}\",this.formatSeparator=u||\",\",this.unescapePrefix=l?\"\":c||\"-\",this.unescapeSuffix=this.unescapePrefix?\"\":l||\"\",this.nestingPrefix=d?hA(d):f||hA(\"$t(\"),this.nestingSuffix=h?hA(h):p||hA(\")\"),this.nestingOptionsSeparator=m||\",\",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e&&e.source===t?(e.lastIndex=0,e):new RegExp(t,\"g\");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,o,a;const s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\\$/g,\"$$$$\")}const l=e=>{if(e.indexOf(this.formatSeparator)<0){const i=LA(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}const i=e.split(this.formatSeparator),o=i.shift().trim(),a=i.join(this.formatSeparator).trim();return this.format(LA(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),a,n,{...r,...t,interpolationkey:o})};this.resetRegExp();const c=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,d=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>u(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?u(this.escape(e)):u(e)}].forEach((t=>{for(a=0;i=t.regex.exec(e);){const n=i[1].trim();if(o=l(n),void 0===o)if(\"function\"==typeof c){const t=c(e,i,r);o=\"string\"==typeof t?t:\"\"}else if(r&&Object.prototype.hasOwnProperty.call(r,n))o=\"\";else{if(d){o=i[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),o=\"\"}else\"string\"==typeof o||this.useRawValueToEscape||(o=sA(o));const s=t.safeValue(o);if(e=e.replace(i[0],s),d?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),e}nest(e,t){let n,r,i,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(e,t){const n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;const r=e.split(new RegExp(`${n}[ ]*{`));let o=`{${r[1]}`;e=r[0],o=this.interpolate(o,i);const a=o.match(/'/g),s=o.match(/\"/g);(a&&a.length%2==0&&!s||s.length%2!=0)&&(o=o.replace(/'/g,'\"'));try{i=JSON.parse(o),t&&(i={...t,...i})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){let s=[];i={...o},i=i.replace&&\"string\"!=typeof i.replace?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let u=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){const e=n[1].split(this.formatSeparator).map((e=>e.trim()));n[1]=e.shift(),s=e,u=!0}if(r=t(a.call(this,n[1].trim(),i),i),r&&n[0]===e&&\"string\"!=typeof r)return r;\"string\"!=typeof r&&(r=sA(r)),r||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),r=\"\"),u&&(r=s.reduce(((e,t)=>this.format(e,t,o.lng,{...o,interpolationkey:n[1].trim()})),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}function OA(e){const t={};return function(n,r,i){const o=r+JSON.stringify(i);let a=t[o];return a||(a=e(yA(r),i),t[o]=a),a(n)}}class NA{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=iA.create(\"formatter\"),this.options=e,this.formats={number:OA(((e,t)=>{const n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)})),currency:OA(((e,t)=>{const n=new Intl.NumberFormat(e,{...t,style:\"currency\"});return e=>n.format(e)})),datetime:OA(((e,t)=>{const n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)})),relativetime:OA(((e,t)=>{const n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||\"day\")})),list:OA(((e,t)=>{const n=new Intl.ListFormat(e,{...t});return e=>n.format(e)}))},this.init(e)}init(e){const t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||\",\"}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=OA(t)}format(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=t.split(this.formatSeparator).reduce(((e,t)=>{const{formatName:i,formatOptions:o}=function(e){let t=e.toLowerCase().trim();const n={};if(e.indexOf(\"(\")>-1){const r=e.split(\"(\");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);\"currency\"===t&&i.indexOf(\":\")<0?n.currency||(n.currency=i.trim()):\"relativetime\"===t&&i.indexOf(\":\")<0?n.range||(n.range=i.trim()):i.split(\";\").forEach((e=>{if(e){const[t,...r]=e.split(\":\"),i=r.join(\":\").trim().replace(/^'+|'+$/g,\"\"),o=t.trim();n[o]||(n[o]=i),\"false\"===i&&(n[o]=!1),\"true\"===i&&(n[o]=!0),isNaN(i)||(n[o]=parseInt(i,10))}}))}return{formatName:t,formatOptions:n}}(t);if(this.formats[i]){let t=e;try{const a=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{},s=a.locale||a.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...o,...r,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e}),e);return i}}class DA extends oA{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=iA.create(\"backendConnector\"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(n,r.backend,r)}queueLoad(e,t,n,r){const i={},o={},a={},s={};return e.forEach((e=>{let r=!0;t.forEach((t=>{const a=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,r=!1,void 0===o[a]&&(o[a]=!0),void 0===i[a]&&(i[a]=!0),void 0===s[t]&&(s[t]=!0)))})),r||(a[e]=!0)})),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){const r=e.split(\"|\"),i=r[0],o=r[1];t&&this.emit(\"failedLoading\",i,o,t),n&&this.store.addResourceBundle(i,o,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2;const a={};this.queue.forEach((n=>{!function(e,t,n,r){const{obj:i,k:o}=lA(e,t,Object);i[o]=i[o]||[],r&&(i[o]=i[o].concat(n)),r||i[o].push(n)}(n.loaded,[i],o),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((e=>{a[e]||(a[e]={});const t=n.loaded[e];t.length&&t.forEach((t=>{void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit(\"loaded\",a),this.queue=this.queue.filter((e=>!e.done))}read(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:o});this.readingCalls++;const a=(a,s)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&s&&r{this.read.call(this,e,t,n,r+1,2*i,o)}),i):o(a,s)},s=this.backend[n].bind(this.backend);if(2!==s.length)return s(e,t,a);try{const n=s(e,t);n&&\"function\"==typeof n.then?n.then((e=>a(null,e))).catch(a):a(null,n)}catch(e){a(e)}}prepareLoading(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn(\"No backend was added via i18next.use. Will not load resources.\"),r&&r();\"string\"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),\"string\"==typeof t&&(t=[t]);const i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach((e=>{this.loadOne(e)}))}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:\"\";const n=e.split(\"|\"),r=n[0],i=n[1];this.read(r,i,\"read\",void 0,void 0,((n,o)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&o&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,o),this.loaded(e,n,o)}))}saveMissing(e,t,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn(`did not save key \"${n}\" as the namespace \"${t}\" was not yet loaded`,\"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!\");else if(null!=n&&\"\"!==n){if(this.backend&&this.backend.create){const s={...o,isUpdate:i},u=this.backend.create.bind(this.backend);if(u.length<6)try{let i;i=5===u.length?u(e,t,n,r,s):u(e,t,n,r),i&&\"function\"==typeof i.then?i.then((e=>a(null,e))).catch(a):a(null,i)}catch(e){a(e)}else u(e,t,n,r,a,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}function jA(){return{debug:!1,initImmediate:!0,ns:[\"translation\"],defaultNS:[\"translation\"],fallbackLng:[\"dev\"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:\"all\",preload:!1,simplifyPluralSuffix:!0,keySeparator:\".\",nsSeparator:\":\",pluralSeparator:\"_\",contextSeparator:\"_\",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:\"fallback\",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){let t={};if(\"object\"==typeof e[1]&&(t=e[1]),\"string\"==typeof e[1]&&(t.defaultValue=e[1]),\"string\"==typeof e[2]&&(t.tDescription=e[2]),\"object\"==typeof e[2]||\"object\"==typeof e[3]){const n=e[3]||e[2];Object.keys(n).forEach((e=>{t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:\"{{\",suffix:\"}}\",formatSeparator:\",\",unescapePrefix:\"-\",nestingPrefix:\"$t(\",nestingSuffix:\")\",nestingOptionsSeparator:\",\",maxReplaces:1e3,skipOnVariables:!0}}}function BA(e){return\"string\"==typeof e.ns&&(e.ns=[e.ns]),\"string\"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),\"string\"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf(\"cimode\")<0&&(e.supportedLngs=e.supportedLngs.concat([\"cimode\"])),e}function zA(){}class UA extends oA{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;var n;if(super(),this.options=BA(e),this.services={},this.logger=iA,this.modules={external:[]},n=this,Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((e=>{\"function\"==typeof n[e]&&(n[e]=n[e].bind(n))})),t&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,t),this;setTimeout((()=>{this.init(e,t)}),0)}}init(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,\"function\"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&(\"string\"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf(\"translation\")<0&&(t.defaultNS=t.ns[0]));const r=jA();function i(e){return e?\"function\"==typeof e?new e:e:null}if(this.options={...r,...this.options,...BA(t)},\"v1\"!==this.options.compatibilityAPI&&(this.options.interpolation={...r.interpolation,...this.options.interpolation}),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){let t;this.modules.logger?iA.init(i(this.modules.logger),this.options):iA.init(null,this.options),this.modules.formatter?t=this.modules.formatter:\"undefined\"!=typeof Intl&&(t=NA);const n=new MA(this.options);this.store=new wA(this.options.resources,this.options);const o=this.services;o.logger=iA,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new PA(n,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!t||this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format||(o.formatter=i(t),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new IA(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new DA(i(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on(\"*\",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;i{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,n||(n=zA),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&\"dev\"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn(\"init: no languageDetector is used and no lng is defined\");[\"getResource\",\"hasResourceBundle\",\"getResourceBundle\",\"getDataByLanguage\"].forEach((t=>{this[t]=function(){return e.store[t](...arguments)}}));[\"addResource\",\"addResources\",\"addResourceBundle\",\"removeResourceBundle\"].forEach((t=>{this[t]=function(){return e.store[t](...arguments),e}}));const o=aA(),a=()=>{const e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(\"init: i18next is already initialized. You should call init just once!\"),this.isInitialized=!0,this.options.isClone||this.logger.log(\"initialized\",this.options),this.emit(\"initialized\",this.options),o.resolve(t),n(e,t)};if(this.languages&&\"v1\"!==this.options.compatibilityAPI&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initImmediate?a():setTimeout(a,0),o}loadResources(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zA;const n=\"string\"==typeof e?e:this.language;if(\"function\"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&\"cimode\"===n.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return t();const e=[],r=t=>{if(!t)return;if(\"cimode\"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach((t=>{\"cimode\"!==t&&e.indexOf(t)<0&&e.push(t)}))};if(n)r(n);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e=>r(e)))}this.options.preload&&this.options.preload.forEach((e=>r(e))),this.services.backendConnector.load(e,this.options.ns,(e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)}))}else t(null)}reloadResources(e,t,n){const r=aA();return e||(e=this.languages),t||(t=this.options.ns),n||(n=zA),this.services.backendConnector.reload(e,t,(e=>{r.resolve(),n(e)})),r}use(e){if(!e)throw new Error(\"You are passing an undefined module! Please check the object you are passing to i18next.use()\");if(!e.type)throw new Error(\"You are passing a wrong module! Please check the object you are passing to i18next.use()\");return\"backend\"===e.type&&(this.modules.backend=e),(\"logger\"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),\"languageDetector\"===e.type&&(this.modules.languageDetector=e),\"i18nFormat\"===e.type&&(this.modules.i18nFormat=e),\"postProcessor\"===e.type&&_A.addPostProcessor(e),\"formatter\"===e.type&&(this.modules.formatter=e),\"3rdParty\"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!([\"cimode\",\"dev\"].indexOf(e)>-1))for(let e=0;e-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}}changeLanguage(e,t){var n=this;this.isLanguageChangingTo=e;const r=aA();this.emit(\"languageChanging\",e);const i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(e,o)=>{o?(i(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit(\"languageChanged\",o),this.logger.log(\"languageChanged\",o)):this.isLanguageChangingTo=void 0,r.resolve((function(){return n.t(...arguments)})),t&&t(e,(function(){return n.t(...arguments)}))},a=t=>{e||t||!this.services.languageDetector||(t=[]);const n=\"string\"==typeof t?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||i(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(n)),this.loadResources(n,(e=>{o(e,n)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),r}getFixedT(e,t,n){var r=this;const i=function(e,t){let o;if(\"object\"!=typeof t){for(var a=arguments.length,s=new Array(a>2?a-2:0),u=2;u`${o.keyPrefix}${l}${e}`)):o.keyPrefix?`${o.keyPrefix}${l}${e}`:e,r.t(c,o)};return\"string\"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn(\"hasLoadedNamespace: i18next was not initialized\",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(\"hasLoadedNamespace: i18n.languages were undefined or empty\",this.languages),!1;const n=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if(\"cimode\"===n.toLowerCase())return!0;const o=(e,t)=>{const n=this.services.backendConnector.state[`${e}|${t}`];return-1===n||2===n};if(t.precheck){const e=t.precheck(this,o);if(void 0!==e)return e}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(n,e)||r&&!o(i,e)))}loadNamespaces(e,t){const n=aA();return this.options.ns?(\"string\"==typeof e&&(e=[e]),e.forEach((e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)})),this.loadResources((e=>{n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){const n=aA();\"string\"==typeof e&&(e=[e]);const r=this.options.preload||[],i=e.filter((e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e)));return i.length?(this.options.preload=r.concat(i),this.loadResources((e=>{n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return\"rtl\";const t=this.services&&this.services.languageUtils||new MA(jA());return[\"ar\",\"shu\",\"sqr\",\"ssh\",\"xaa\",\"yhd\",\"yud\",\"aao\",\"abh\",\"abv\",\"acm\",\"acq\",\"acw\",\"acx\",\"acy\",\"adf\",\"ads\",\"aeb\",\"aec\",\"afb\",\"ajp\",\"apc\",\"apd\",\"arb\",\"arq\",\"ars\",\"ary\",\"arz\",\"auz\",\"avl\",\"ayh\",\"ayl\",\"ayn\",\"ayp\",\"bbz\",\"pga\",\"he\",\"iw\",\"ps\",\"pbt\",\"pbu\",\"pst\",\"prp\",\"prd\",\"ug\",\"ur\",\"ydd\",\"yds\",\"yih\",\"ji\",\"yi\",\"hbo\",\"men\",\"xmn\",\"fa\",\"jpr\",\"peo\",\"pes\",\"prs\",\"dv\",\"sam\",\"ckb\"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf(\"-arab\")>1?\"rtl\":\"ltr\"}static createInstance(){return new UA(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zA;const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},i=new UA(r);void 0===e.debug&&void 0===e.prefix||(i.logger=i.logger.clone(e));return[\"store\",\"services\",\"language\"].forEach((e=>{i[e]=this[e]})),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},n&&(i.store=new wA(this.store.data,r),i.services.resourceStore=i.store),i.translator=new EA(i.services,r),i.translator.on(\"*\",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rsecp256k1\":!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\"}(qA||(qA={}));const WA=\"direct\",$A=\"https://metamask.app.link/connect\",VA=\"metamask://connect\",YA={NAME:\"MetaMask\",RDNS:\"io.metamask\"},GA=/(?:^[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;const ZA={Initialized:\"initialized\",DisplayURI:\"display_uri\",ProviderUpdate:\"provider_update\",ConnectWithResponse:\"connectWithResponse\",ConnectionStatus:\"connection_status\",ServiceStatus:\"service_status\"};var QA;e.PROVIDER_UPDATE_TYPE=void 0,(QA=e.PROVIDER_UPDATE_TYPE||(e.PROVIDER_UPDATE_TYPE={})).TERMINATE=\"terminate\",QA.EXTENSION=\"extension\",QA.INITIALIZED=\"initialized\";const JA=\"undefined\"!=typeof window&&window.localStorage;function XA({instance:e,msg:t}){return kk(this,void 0,void 0,(function*(){if(e._initialized||(xx(\"[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()\"),yield e.init()),xx(`[MetaMaskSDK: connectAndSign()] activeProvider=${e.activeProvider}`),!e.activeProvider)throw new Error(\"SDK state invalid -- undefined provider\");const n=function(e){return/^0x([0-9A-Fa-f]{2})*$/u.test(e)}(t)?t:function(e){let t;if(\"undefined\"!=typeof Buffer)t=Buffer.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 global||!(\"Buffer\"in global))throw new Error(\"Unable to convert string to hex: No available method.\");t=global.Buffer.from(e,\"utf8\").toString(\"hex\")}return`0x${t}`}(t);return e.activeProvider.request({method:Kx.METAMASK_CONNECTWITH,params:[{method:Kx.PERSONAL_SIGN,params:[n]}]})}))}function eR(t){var n,r;return kk(this,void 0,void 0,(function*(){xx(\"[MetaMaskSDK: connectWithExtensionProvider()] \",t),t.sdkProvider=t.activeProvider,t.activeProvider=window.extension,window.ethereum=window.extension;try{const e=yield null===(n=window.extension)||void 0===n?void 0:n.request({method:\"eth_requestAccounts\"});xx(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${e}`)}catch(e){return void console.warn(\"[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error\",e)}localStorage.setItem(Vx,\"extension\"),t.extensionActive=!0,t.emit(ZA.ProviderUpdate,e.PROVIDER_UPDATE_TYPE.EXTENSION),t.options.enableAnalytics&&(null===(r=t.analytics)||void 0===r||r.send({event:ZE.SDK_USE_EXTENSION}))}))}function tR(e){return tR=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},tR(e)}function nR(e){var t=function(e,t){if(\"object\"!==tR(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||\"default\");if(\"object\"!==tR(r))return r;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===t?String:Number)(e)}(e,\"string\");return\"symbol\"===tR(t)?t:String(t)}function rR(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:{path:\"/\",sameSite:\"strict\"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+60*n*1e3)),r&&(i.domain=r),document.cookie=function(e,t,n){var r=n||{};r.path=r.path||\"/\";var i=encodeURIComponent(t),o=\"\".concat(e,\"=\").concat(i);if(r.maxAge>0){var a=r.maxAge-0;if(Number.isNaN(a))throw new Error(\"maxAge should be a Number\");o+=\"; Max-Age=\".concat(Math.floor(a))}if(r.domain){if(!sR.test(r.domain))throw new TypeError(\"option domain is invalid\");o+=\"; Domain=\".concat(r.domain)}if(r.path){if(!sR.test(r.path))throw new TypeError(\"option path is invalid\");o+=\"; Path=\".concat(r.path)}if(r.expires){if(\"function\"!=typeof r.expires.toUTCString)throw new TypeError(\"option expires is invalid\");o+=\"; Expires=\".concat(r.expires.toUTCString())}if(r.httpOnly&&(o+=\"; HttpOnly\"),r.secure&&(o+=\"; Secure\"),r.sameSite)switch(\"string\"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:o+=\"; SameSite=Strict\";break;case\"lax\":o+=\"; SameSite=Lax\";break;case\"strict\":o+=\"; SameSite=Strict\";break;case\"none\":o+=\"; SameSite=None\";break;default:throw new TypeError(\"option sameSite is invalid\")}return o}(e,encodeURIComponent(t),i)},lR=function(e){for(var t=\"\".concat(e,\"=\"),n=document.cookie.split(\";\"),r=0;r-1&&(n=window.location.hash.substring(window.location.hash.indexOf(\"?\")));for(var r=n.substring(1).split(\"&\"),i=0;i0)r[i].substring(0,o)===e.lookupQuerystring&&(t=r[i].substring(o+1))}}return t}},fR=null,hR=function(){if(null!==fR)return fR;try{fR=\"undefined\"!==window&&null!==window.localStorage;var e=\"i18next.translate.boo\";window.localStorage.setItem(e,\"foo\"),window.localStorage.removeItem(e)}catch(e){fR=!1}return fR},pR={name:\"localStorage\",lookup:function(e){var t;if(e.lookupLocalStorage&&hR()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&hR()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},mR=null,gR=function(){if(null!==mR)return mR;try{mR=\"undefined\"!==window&&null!==window.sessionStorage;var e=\"i18next.translate.boo\";window.sessionStorage.setItem(e,\"foo\"),window.sessionStorage.removeItem(e)}catch(e){mR=!1}return mR},vR={name:\"sessionStorage\",lookup:function(e){var t;if(e.lookupSessionStorage&&gR()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&gR()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},bR={name:\"navigator\",lookup:function(e){var t=[];if(\"undefined\"!=typeof navigator){if(navigator.languages)for(var n=0;n0?t:void 0}},yR={name:\"htmlTag\",lookup:function(e){var t,n=e.htmlTag||(\"undefined\"!=typeof document?document.documentElement:null);return n&&\"function\"==typeof n.getAttribute&&(t=n.getAttribute(\"lang\")),t}},wR={name:\"path\",lookup:function(e){var t;if(\"undefined\"!=typeof window){var n=window.location.pathname.match(/\\/([a-zA-Z-]*)/g);if(n instanceof Array)if(\"number\"==typeof e.lookupFromPathIndex){if(\"string\"!=typeof n[e.lookupFromPathIndex])return;t=n[e.lookupFromPathIndex].replace(\"/\",\"\")}else t=n[0].replace(\"/\",\"\")}return t}},_R={name:\"subdomain\",lookup:function(e){var t=\"number\"==typeof e.lookupFromSubdomainIndex?e.lookupFromSubdomainIndex+1:1,n=\"undefined\"!=typeof window&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\\w{2,5})\\.(([a-z0-9-]{1,63}\\.[a-z]{2,6})|localhost)/i);if(n)return n[t]}};var SR=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.type=\"languageDetector\",this.detectors={},this.init(t,n)}var t,n,r;return t=e,n=[{key:\"init\",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e||{languageUtils:{}},this.options=function(e){return oR.call(aR.call(arguments,1),(function(t){if(t)for(var n in t)void 0===e[n]&&(e[n]=t[n])})),e}(t,this.options||{},{order:[\"querystring\",\"cookie\",\"localStorage\",\"sessionStorage\",\"navigator\",\"htmlTag\"],lookupQuerystring:\"lng\",lookupCookie:\"i18next\",lookupLocalStorage:\"i18nextLng\",lookupSessionStorage:\"i18nextLng\",caches:[\"localStorage\"],excludeCacheFor:[\"cimode\"],convertDetectedLanguage:function(e){return e}}),\"string\"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf(\"15897\")>-1&&(this.options.convertDetectedLanguage=function(e){return e.replace(\"-\",\"_\")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(cR),this.addDetector(dR),this.addDetector(pR),this.addDetector(vR),this.addDetector(bR),this.addDetector(yR),this.addDetector(wR),this.addDetector(_R)}},{key:\"addDetector\",value:function(e){this.detectors[e.name]=e}},{key:\"detect\",value:function(e){var t=this;e||(e=this.options.order);var n=[];return e.forEach((function(e){if(t.detectors[e]){var r=t.detectors[e].lookup(t.options);r&&\"string\"==typeof r&&(r=[r]),r&&(n=n.concat(r))}})),n=n.map((function(e){return t.options.convertDetectedLanguage(e)})),this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}},{key:\"cacheUserLanguage\",value:function(e,t){var n=this;t||(t=this.options.caches),t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach((function(t){n.detectors[t]&&n.detectors[t].cacheUserLanguage(e,n.options)})))}}],n&&rR(t.prototype,n),r&&rR(t,r),Object.defineProperty(t,\"prototype\",{writable:!1}),e}();SR.type=\"languageDetector\";var ER={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\"}},kR={DESKTOP:\"Escritorio\",MOBILE:\"Móvil\",META_MASK_MOBILE_APP:\"Aplicación móvil de MetaMask\",SCAN_TO_CONNECT:\"Escanear para conectar y firmar con\",CONNECT_WITH_EXTENSION:\"Conectar con la Extensión de MetaMask\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"Confiado por más de 30 millones de usuarios para comprar, almacenar, enviar e intercambiar cripto de manera segura\",LEADING_CRYPTO_WALLET:\"La principal billetera de criptomonedas y pasarela hacia aplicaciones blockchain construidas en Ethereum Mainnet, Polygon, Optimism y muchas otras redes\",CONTROL_DIGITAL_INTERACTIONS:\"Te da el control de tus interacciones digitales al hacer que el poder de la criptografía sea más accesible\",INSTALL_META_MASK_EXTENSION:\"Instalar la Extensión de MetaMask\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"Por favor, abre la aplicación de billetera MetaMask y selecciona el código en la pantalla O desconecta\",OPEN_META_MASK_CONTINUE:\"Abre la aplicación de MetaMask para continuar con tu sesión.\",NUMBER_AFTER_OPEN_NOTICE:\"Si no aparece un número después de abrir MetaMask, por favor haz clic en desconectar y vuelve a escanear el código QR.\",DISCONNECT:\"Desconectar\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"Toma el control de tu cripto y explora la blockchain con la billetera en la que confían más de 30 millones de personas en todo el mundo\"},META_MASK_MODAL:{ADDRESS_COPIED:\"¡Dirección copiada al portapapeles!\",DISCONNECT:\"Desconectar\",ACTIVE_NETWORK:\"Red activa\"}},MR={DESKTOP:\"Bureau\",MOBILE:\"Mobile\",META_MASK_MOBILE_APP:\"Application mobile MetaMask\",SCAN_TO_CONNECT:\"Scannez pour vous connecter et signer avec\",CONNECT_WITH_EXTENSION:\"Connectez-vous avec l'extension MetaMask\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"Fait confiance à plus de 30 millions d'utilisateurs pour acheter, stocker, envoyer et échanger des crypto en toute sécurité\",LEADING_CRYPTO_WALLET:\"Le portefeuille crypto leader et la passerelle vers des applications blockchain basées sur Ethereum Mainnet, Polygon, Optimism, et de nombreux autres réseaux\",CONTROL_DIGITAL_INTERACTIONS:\"Vous donne le contrôle de vos interactions numériques en rendant la puissance de la cryptographie plus accessible\",INSTALL_META_MASK_EXTENSION:\"Installez l'extension MetaMask\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"Veuillez ouvrir l'application MetaMask et sélectionnez le code à l'écran OU déconnectez-vous\",OPEN_META_MASK_CONTINUE:\"Ouvrez l'application MetaMask pour continuer votre session.\",NUMBER_AFTER_OPEN_NOTICE:\"Si un numéro n'apparaît pas après avoir ouvert MetaMask, veuillez cliquer sur déconnecter et rescanner le QRCode.\",DISCONNECT:\"Déconnecter\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"Prenez le contrôle de votre crypto et explorez la blockchain avec le portefeuille fait confiance par plus de 30 millions de personnes à travers le monde\"},META_MASK_MODAL:{ADDRESS_COPIED:\"Adresse copiée dans le presse-papiers!\",DISCONNECT:\"Déconnecter\",ACTIVE_NETWORK:\"Réseau actif\"}},CR={DESKTOP:\"שולחן עבודה\",MOBILE:\"נייד\",META_MASK_MOBILE_APP:\"אפליקציית מטא מאסק לנייד\",SCAN_TO_CONNECT:\"סרוק כדי להתחבר ולחתום עם\",CONNECT_WITH_EXTENSION:\"התחבר עם התוסף של מטא מאסק\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"מהימנים על ידי למעלה מ-30 מיליון משתמשים לקנות, לאחסן, לשלוח ולהחליף מטבע קריפטוגרפי בבטחה\",LEADING_CRYPTO_WALLET:\"ארנק הקריפטו המוביל והשער ליישומי בלוקצ'יין המתוכנתים על אתריום, פוליגון, ורשתות רבות נוספות\",CONTROL_DIGITAL_INTERACTIONS:\"מכניס אותך לשליטה על האינטראקציות הדיגיטליות שלך על ידי הפיכת כוח הקריפטוגרפיה לנגיש יותר\",INSTALL_META_MASK_EXTENSION:\"התקן את ההרחבה של מטא מאסק\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"אנא פתח את אפליקציית ארנק מטא מאסק ובחר את הקוד שמופיע על המסך או התנתק\",OPEN_META_MASK_CONTINUE:\"פתח את האפליקציה של מטא מאסק כדי להמשיך בפעולה שלך.\",NUMBER_AFTER_OPEN_NOTICE:\"אם מספר אינו מופיע לאחר פתיחת מטא מאסק, אנא לחץ על התנתקות וסרוק מחדש את ה-QRCode.\",DISCONNECT:\"התנתק\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"קח שליטה על הקריפטו שלך וחקור את הבלוקצ'יין עם הארנק האמין שבשימוש על ידי למעלה מ-30 מיליון אנשים ברחבי העולם\"},META_MASK_MODAL:{ADDRESS_COPIED:\"הכתובת הועתקה ללוח!\",DISCONNECT:\"התנתק\",ACTIVE_NETWORK:\"רשת פעילה\"}},xR={DESKTOP:\"Desktop\",MOBILE:\"Mobile\",META_MASK_MOBILE_APP:\"App mobile MetaMask\",SCAN_TO_CONNECT:\"Scansiona per connetterti e firmare con\",CONNECT_WITH_EXTENSION:\"Connettiti con l'estensione MetaMask\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"Ritenuto affidabile da oltre 30 milioni di utenti per acquistare, conservare, inviare e scambiare cripto in modo sicuro\",LEADING_CRYPTO_WALLET:\"Il principale portafoglio cripto e gateway per applicazioni blockchain funzionanti su Ethereum Mainnet, Polygon, Optimism e molte altre reti\",CONTROL_DIGITAL_INTERACTIONS:\"Ti da il controllo delle tue interazioni digitali rendendo piu' accessibile il potere della crittografia\",INSTALL_META_MASK_EXTENSION:\"Installa l'estensione MetaMask\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"Si prega di aprire l'app mobile MetaMask Wallet e selezionare il codice sullo schermo OPPURE scollegarsi\",OPEN_META_MASK_CONTINUE:\"Apri l'app mobile MetaMask per continuare con la tua sessione.\",NUMBER_AFTER_OPEN_NOTICE:\"Se, dopo aver aperto MetaMask, non appare alcun numero, si prega di fare clic su disconnetti e ris canzionare il QRCode.\",DISCONNECT:\"Disconnetti\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"Prendi il controllo delle tue cripto e esplora la blockchain con il portafoglio ritenuto affidabile da oltre 30 milioni di persone in tutto il mondo\"},META_MASK_MODAL:{ADDRESS_COPIED:\"Indirizzo copiato negli appunti!\",DISCONNECT:\"Disconnetti\",ACTIVE_NETWORK:\"Rete attiva\"}},AR={DESKTOP:\"Desktop\",MOBILE:\"Móvel\",META_MASK_MOBILE_APP:\"Aplicativo móvel MetaMask\",SCAN_TO_CONNECT:\"Escanear para conectar e assinar com\",CONNECT_WITH_EXTENSION:\"Conectar com a extensão MetaMask\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"Confiado por mais de 30 milhões de usuários para comprar, armazenar, enviar e trocar cripto com segurança\",LEADING_CRYPTO_WALLET:\"A principal carteira de cripto & portal para aplicativos blockchain construídos em Ethereum Mainnet, Polygon, Optimism, e muitas outras redes\",CONTROL_DIGITAL_INTERACTIONS:\"Coloca você no controle de suas interações digitais, tornando o poder da criptografia mais acessível\",INSTALL_META_MASK_EXTENSION:\"Instalar a extensão MetaMask\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"Por favor, abra o aplicativo MetaMask e selecione o código na tela OU desconecte\",OPEN_META_MASK_CONTINUE:\"Abra o aplicativo MetaMask para continuar sua sessão.\",NUMBER_AFTER_OPEN_NOTICE:\"Se um número não aparecer após abrir o MetaMask, por favor clique em desconectar e re-escaneie o QRCode.\",DISCONNECT:\"Desconectar\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"Assuma o controle de sua cripto e explore a blockchain com a carteira confiada por mais de 30 milhões de pessoas em todo o mundo\"},META_MASK_MODAL:{ADDRESS_COPIED:\"Endereço copiado para a área de transferência!\",DISCONNECT:\"Desconectar\",ACTIVE_NETWORK:\"Rede ativa\"}},RR={DESKTOP:\"Masaüstü\",MOBILE:\"Mobil\",META_MASK_MOBILE_APP:\"MetaMask mobil uygulama\",SCAN_TO_CONNECT:\"Bağlanmak ve imzalamak için tarayın\",CONNECT_WITH_EXTENSION:\"MetaMask Eklentisi ile Bağlan\",INSTALL_MODAL:{TRUSTED_BY_USERS:\"Kriptoyu güvenle satın almak, saklamak, göndermek ve değiştirmek için 30 milyondan fazla kullanıcı tarafından güvenilir\",LEADING_CRYPTO_WALLET:\"Ethereum Ana Ağı, Polygon, Optimism ve birçok diğer ağda kurulu blockchain uygulamalarına erişim sağlayan öncü kripto cüzdanı\",CONTROL_DIGITAL_INTERACTIONS:\"Kriptografinin gücünü daha erişilebilir kılarak dijital etkileşimlerinizin kontrolünü size verir\",INSTALL_META_MASK_EXTENSION:\"MetaMask Eklentisini Yükleyin\"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:\"Lütfen MetaMask cüzdan uygulamasını açın ve ekrandaki kodu seçin YA DA bağlantıyı kesin\",OPEN_META_MASK_CONTINUE:\"Oturumunuzla devam etmek için MetaMask uygulamasını açın.\",NUMBER_AFTER_OPEN_NOTICE:\"MetaMask'ı açtıktan sonra bir numara görünmezse, lütfen bağlantıyı kesin ve QR Kodunu tekrar tarayın.\",DISCONNECT:\"Bağlantıyı Kes\"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:\"Kriptonuzu kontrol edin ve dünya genelinde 30 milyondan fazla kişi tarafından güvenilen cüzdanla blockchain'i keşfedin\"},META_MASK_MODAL:{ADDRESS_COPIED:\"Adres panoya kopyalandı!\",DISCONNECT:\"Bağlantıyı Kes\",ACTIVE_NETWORK:\"Aktif Ağ\"}};function TR(e){let t;if(\"undefined\"!=typeof Buffer)t=Buffer.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 global||!(\"Buffer\"in global))throw new Error(\"Unable to base64 encode: No available method.\");t=global.Buffer.from(e,\"utf8\").toString(\"base64\")}return t}class PR{constructor({shouldSetOnWindow:e,connectionStream:t,shouldSendMetadata:n=!1,shouldShimWeb3:r,sdkInstance:i}){const o=new Xx({connectionStream:t,shouldSendMetadata:n,shouldSetOnWindow:e,shouldShimWeb3:r,autoRequestAccounts:!1}),a=new Proxy(o,{deleteProperty:()=>!0});var s;this.provider=a,this.sdkInstance=i,e&&\"undefined\"!=typeof window&&(s=o,window.ethereum=s,window.dispatchEvent(new Event(\"ethereum#initialized\"))),r&&\"undefined\"!=typeof window&&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,a,...s)=>(\"currentProvider\"!==a||n?\"currentProvider\"===a||a===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,a,...s)),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),this.provider.on(\"display_uri\",(e=>{this.sdkInstance.emit(ZA.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(ZA.Initialized,e),xx(\"[Ethereum: constructor()] provider initialized\",e)}))}static init(e){var t;return xx(\"[Ethereum: init()] Initializing Ethereum service\"),this.instance=new PR(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}}function LR(e,t,n,r){var i,o,a,s,u,l,c,d,f,h,p,m,g,v,b,y,w,S,E,k;return kk(this,void 0,void 0,(function*(){const n=null===(i=e.state.remote)||void 0===i?void 0:i.isReady(),M=null===(o=e.state.remote)||void 0===o?void 0:o.isConnected(),C=null===(a=e.state.remote)||void 0===a?void 0:a.isPaused(),x=PR.getProvider(),A=null===(s=e.state.remote)||void 0===s?void 0:s.getChannelId(),R=null===(u=e.state.remote)||void 0===u?void 0:u.isAuthorized(),{deeplinkProtocol:T}=e.state,{method:P,data:L,triggeredInstaller:I}=(e=>{var t,n,r,i;let o;_.isBuffer(e)?(o=e.toJSON(),o._isBuffer=!0):o=e;const a=null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.method;let s=!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)&&(s=!0,o.data.params=o.data.params.wrappedParams),{method:a,data:o,triggeredInstaller:s}})(t);if(xx(`[RCPMS: write()] method='${P}' isRemoteReady=${n} channelId=${A} isSocketConnected=${M} isRemotePaused=${C} providerConnected=${x.isConnected()}`,t),!A)return P!==Kx.METAMASK_GETPROVIDERSTATE&&xx(`[RCPMS: write()] ${P} --\\x3e channelId is undefined`),r(new Error(\"disconnected\"));xx(`[RCPMS: write()] remote.isPaused()=${null===(l=e.state.remote)||void 0===l?void 0:l.isPaused()} authorized=${R} ready=${n} socketConnected=${M}`,t);const O=null===(c=e.state.platformManager)||void 0===c?void 0:c.isSecure(),N=null!==(f=null===(d=e.state.platformManager)||void 0===d?void 0:d.isMobileWeb())&&void 0!==f&&f,D=null!==(p=null===(h=e.state.remote)||void 0===h?void 0:h.hasDeeplinkProtocol())&&void 0!==p&&p&&N&&R;try{if(D&&!I||null===(m=e.state.remote)||void 0===m||m.sendMessage(null==L?void 0:L.data).then((()=>{xx(`[RCPMS: _write()] ${P} sent successfully`)})).catch((e=>{xx(\"[RCPMS: _write()] error sending message\",e)})),!O)return xx(`[RCPMS: _write()] unsecure platform for method ${P} -- return callback`),r();if(I)return xx(\"[RCPMS: _write()] prevent deeplink -- installation completed separately.\"),r();const t=null!==(b=null===(v=null===(g=e.state.remote)||void 0===g?void 0:g.getKeyInfo())||void 0===v?void 0:v.ecies.public)&&void 0!==b?b:\"\";let n=encodeURI(`channelId=${A}&pubkey=${t}&comm=socket&t=d&v=2`);if(D){const t=JSON.stringify(null==L?void 0:L.data),i=null===(y=e.state.remote)||void 0===y?void 0:y.encrypt(t);if(!i)return xx(\"[RCPMS: _write()] error encrypting message\"),r(new Error(\"RemoteCommunicationPostMessageStream - disconnected\"));n+=`&scheme=${T}&rpc=${TR(i)}`}if(!(null===(w=e.state.platformManager)||void 0===w?void 0:w.isMetaMaskInstalled()))return xx(\"[RCPMS: _write()] prevent deeplink until installation is completed.\"),r();qx[P]?(xx(`[RCPMS: _write()] redirect link for '${P}' socketConnected=${M} connect?${n}`),null===(S=e.state.platformManager)||void 0===S||S.openDeeplink(`${$A}?${n}`,`${VA}?${n}`,\"_self\")):(null===(E=e.state.remote)||void 0===E?void 0:E.isPaused())?(xx(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${P}`),null===(k=e.state.platformManager)||void 0===k||k.openDeeplink(`${$A}?redirect=true&${n}`,`${VA}?redirect=true&${n}`,\"_self\")):xx(`[RCPMS: _write()] method ${P} doesn't need redirect.`)}catch(e){return xx(\"[RCPMS: _write()] error sending message\",e),r(new Error(\"RemoteCommunicationPostMessageStream - disconnected\"))}return r()}))}class IR extends Hn.Duplex{constructor({name:t,remote:n,deeplinkProtocol:r,platformManager:i}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=t,this.state.remote=n,this.state.deeplinkProtocol=r,this.state.platformManager=i,this._onMessage=this._onMessage.bind(this),this.state.remote.on(e.EventType.MESSAGE,this._onMessage)}_write(e,t,n){return kk(this,void 0,void 0,(function*(){return LR(this,e,0,n)}))}_read(){}_onMessage(e){return function(e,t){try{if(xx(\"[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 xx(\"[RCPMS: onMessage()] ignore message without name\",t);if((null==t?void 0:t.name)!==qA.PROVIDER)return void xx(`[RCPMS: onMessage()] ignore message with wrong name message=${t}`);if(_.isBuffer(t)){const n=_.from(t);e.push(n)}else e.push(t)}catch(e){xx(`[RCPMS: onMessage()] ignore message error err=${e}`)}}(this,e)}start(){}}var OR={exports:{}};!function(e,t){var r=\"undefined\"!=typeof globalThis&&globalThis||\"undefined\"!=typeof self&&self||void 0!==n&&n,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=\"URLSearchParams\"in n,i=\"Symbol\"in n&&\"iterator\"in Symbol,o=\"FileReader\"in n&&\"Blob\"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),a=\"FormData\"in n,s=\"ArrayBuffer\"in n;if(s)var u=[\"[object Int8Array]\",\"[object Uint8Array]\",\"[object Uint8ClampedArray]\",\"[object Int16Array]\",\"[object Uint16Array]\",\"[object Int32Array]\",\"[object Uint32Array]\",\"[object Float32Array]\",\"[object Float64Array]\"],l=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function c(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 d(e){return\"string\"!=typeof e&&(e=String(e)),e}function f(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError(\"Already read\"));e.bodyUsed=!0}function m(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function g(e){var t=new FileReader,n=m(t);return t.readAsArrayBuffer(e),n}function v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?\"string\"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=v(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&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set(\"content-type\",\"application/x-www-form-urlencoded;charset=UTF-8\"))},o&&(this.blob=function(){var e=p(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=p(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(g)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=m(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-1?t:e}(t.method||this.method||\"GET\"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(\"GET\"===this.method||\"HEAD\"===this.method)&&n)throw new TypeError(\"Body not allowed for GET or HEAD requests\");if(this._initBody(n),!(\"GET\"!==this.method&&\"HEAD\"!==this.method||\"no-store\"!==t.cache&&\"no-cache\"!==t.cache)){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,\"$1_=\"+(new Date).getTime());else{this.url+=(/\\?/.test(this.url)?\"&\":\"?\")+\"_=\"+(new Date).getTime()}}}function _(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 S(e,t){if(!(this instanceof S))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 h(t.headers),this.url=t.url||\"\",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:\"\"});return e.type=\"error\",e};var E=[301,302,303,307,308];S.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError(\"Invalid status code\");return new S(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 k(e,r){return new Promise((function(i,a){var u=new w(e,r);if(u.signal&&u.signal.aborted)return a(new t.DOMException(\"Aborted\",\"AbortError\"));var l=new XMLHttpRequest;function c(){l.abort()}l.onload=function(){var e,t,n={status:l.status,statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||\"\",t=new h,e.replace(/\\r?\\n[\\t ]+/g,\" \").split(\"\\r\").map((function(e){return 0===e.indexOf(\"\\n\")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(\":\"),r=n.shift().trim();if(r){var i=n.join(\":\").trim();t.append(r,i)}})),t)};n.url=\"responseURL\"in l?l.responseURL:n.headers.get(\"X-Request-URL\");var r=\"response\"in l?l.response:l.responseText;setTimeout((function(){i(new S(r,n))}),0)},l.onerror=function(){setTimeout((function(){a(new TypeError(\"Network request failed\"))}),0)},l.ontimeout=function(){setTimeout((function(){a(new TypeError(\"Network request failed\"))}),0)},l.onabort=function(){setTimeout((function(){a(new t.DOMException(\"Aborted\",\"AbortError\"))}),0)},l.open(u.method,function(e){try{return\"\"===e&&n.location.href?n.location.href:e}catch(t){return e}}(u.url),!0),\"include\"===u.credentials?l.withCredentials=!0:\"omit\"===u.credentials&&(l.withCredentials=!1),\"responseType\"in l&&(o?l.responseType=\"blob\":s&&u.headers.get(\"Content-Type\")&&-1!==u.headers.get(\"Content-Type\").indexOf(\"application/octet-stream\")&&(l.responseType=\"arraybuffer\")),!r||\"object\"!=typeof r.headers||r.headers instanceof h?u.headers.forEach((function(e,t){l.setRequestHeader(t,e)})):Object.getOwnPropertyNames(r.headers).forEach((function(e){l.setRequestHeader(e,d(r.headers[e]))})),u.signal&&(u.signal.addEventListener(\"abort\",c),l.onreadystatechange=function(){4===l.readyState&&u.signal.removeEventListener(\"abort\",c)}),l.send(void 0===u._bodyInit?null:u._bodyInit)}))}k.polyfill=!0,n.fetch||(n.fetch=k,n.Headers=h,n.Request=w,n.Response=S),t.Headers=h,t.Request=w,t.Response=S,t.fetch=k}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t}(OR,OR.exports);var NR=r(OR.exports);let DR=1;const jR=e=>new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),BR=({checkInstallationOnAllCalls:t=!1,communicationLayerPreference:n,injectProvider:r,shouldShimWeb3:i,platformManager:o,installer:a,sdk:s,remoteConnection:u,debug:l})=>kk(void 0,void 0,void 0,(function*(){var c,d;const f=(({name:e,remoteConnection:t})=>{if(!t||!(null==t?void 0:t.getConnector()))throw new Error(\"Missing remote connection parameter\");return new IR({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:qA.INPAGE,target:qA.CONTENT_SCRIPT,platformManager:o,communicationLayerPreference:n,remoteConnection:u}),h=o.getPlatformType(),p=s.options.dappMetadata,m=`Sdk/Javascript SdkVersion/${HA.version} Platform/${h} dApp/${null!==(c=p.url)&&void 0!==c?c:p.name} dAppTitle/${p.name}`;let g=null,v=null;const b=null===(d=s.options.storage)||void 0===d?void 0:d.storageManager;if(b){try{const e=yield b.getCachedAccounts();e.length>0&&(g=e[0])}catch(e){console.error(`[initializeMobileProvider] failed to get cached addresses: ${e}`)}try{const e=yield b.getCachedChainId();e&&(v=e)}catch(e){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${e}`)}}xx(`[initializeMobileProvider] cachedAccountAddress: ${g}, cachedChainId: ${v}`);const y=!(!r||h===e.PlatformType.NonBrowser||h===e.PlatformType.ReactNative),w=PR.init({shouldSetOnWindow:y,connectionStream:f,shouldShimWeb3:i,sdkInstance:s});let _=!1;const S=e=>{console.log(`[initializeMobileProvider] setInitializing: ${e}`),_=e},E=()=>_,k=(n,r,i,l)=>kk(void 0,void 0,void 0,(function*(){var c,d,f,h,p,y,w,k,M;const C=PR.getProvider();if(_){C.emit(\"display_uri\",(null==u?void 0:u.state.qrcodeLink)||\"\"),null==u||u.showActiveModal();let e=E();for(;e;){const t=E(),n=null==u?void 0:u.isAuthorized();e=t&&!n,xx(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${t} authorized: ${n}`),yield jR(1e3)}return xx(\"[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider\"),i(...r)}const x=o.isMetaMaskInstalled(),A=null==u?void 0:u.isConnected();let R=null,T=null,P=null;if(R=null!==(c=C.getSelectedAddress())&&void 0!==c?c:g,P=C.getChainId()||v,R&&b&&R!==g&&b.persistAccounts([R]).catch((e=>{console.error(`[initializeMobileProvider] failed to persist account: ${e}`)})),P&&(v=P,b&&b.persistChainId(P).catch((e=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${e}`)}))),xx(\"[initializeMobileProvider: sendRequest()]\",{selectedAddress:R,chainId:P}),l&&xx(`[initializeMobileProvider: sendRequest()] method=${n} ongoing=${_} selectedAddress=${R} isInstalled=${x} checkInstallationOnAllCalls=${t} socketConnected=${A}`),R&&n.toLowerCase()===Kx.ETH_ACCOUNTS.toLowerCase())return[R];if(P&&n.toLowerCase()===Kx.ETH_CHAINID.toLowerCase())return P;const L=[Kx.ETH_REQUESTACCOUNTS,Kx.WALLET_REQUESTPERMISSIONS,Kx.METAMASK_CONNECTSIGN,Kx.METAMASK_CONNECTWITH],I=!qx[n],O=null===(d=s.options.readonlyRPCMap)||void 0===d?void 0:d[P];if(O&&I)try{const e=null===(f=null==r?void 0:r[0])||void 0===f?void 0:f.params,t=yield(({rpcEndpoint:e,method:t,sdkInfo:n,params:r})=>kk(void 0,void 0,void 0,(function*(){const i=JSON.stringify({jsonrpc:\"2.0\",method:t,params:r,id:(DR+=1,DR)}),o={Accept:\"application/json\",\"Content-Type\":\"application/json\"};let a;e.includes(\"infura\")&&(o[\"Metamask-Sdk-Info\"]=n);try{a=yield NR(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:O,sdkInfo:m,method:n,params:e||[]});return l&&xx(`initializeProvider::ReadOnlyRPCResponse ${t}`),t}catch(e){console.warn(`[initializeMobileProvider: sendRequest()] method=${n} readOnlyRPCRequest failed:`,e)}if((!x||x&&!A)&&n!==Kx.METAMASK_GETPROVIDERSTATE){const l=(null===(h=null==r?void 0:r[0])||void 0===h?void 0:h.params)||[];if(-1!==L.indexOf(n)||t){S(!0);const t=n===Kx.METAMASK_CONNECTWITH,o=`${Date.now()}`;try{yield a.start({wait:!1,connectWith:t?{method:n,id:o,params:l}:void 0}),yield new Promise(((t,n)=>{(null==u?void 0:u.isAuthorized())&&(xx(\"[initializeMobileProvider: sendRequest()] already authorized\"),t(!0)),null==u||u.getConnector().once(e.EventType.AUTHORIZED,(()=>{t(!0)})),s.once(e.EventType.PROVIDER_UPDATE,(t=>{xx(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${t}`),t===e.PROVIDER_UPDATE_TYPE.EXTENSION?n(e.EventType.PROVIDER_UPDATE):n(new Error(\"Connection Terminated\"))}))}))}catch(t){if(e.PROVIDER_UPDATE_TYPE.EXTENSION===t){if(xx(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${n} on the active provider`),n.toLowerCase()===Kx.METAMASK_CONNECTSIGN.toLowerCase()){const e=yield null===(p=s.getProvider())||void 0===p?void 0:p.request({method:Kx.ETH_REQUESTACCOUNTS,params:[]});if(!e.length)throw new Error(\"SDK state invalid -- undefined accounts\");const t=yield null===(y=s.getProvider())||void 0===y?void 0:y.request({method:Kx.PERSONAL_SIGN,params:[l[0],e[0]]});return s.emit(ZA.ConnectWithResponse,t),t}if(n.toLowerCase()===Kx.METAMASK_CONNECTWITH.toLowerCase()){const[e]=l,t=yield(({method:e,sdk:t,params:n})=>kk(void 0,void 0,void 0,(function*(){var r,i,o,a;if(!t.isExtensionActive())throw new Error(\"SDK state invalid -- extension is not active\");xx(\"[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method\",e,n);const s=yield null===(r=t.getProvider())||void 0===r?void 0:r.request({method:Kx.ETH_REQUESTACCOUNTS,params:[]});if(!s.length)throw new Error(\"SDK state invalid -- undefined accounts\");if((null==e?void 0:e.toLowerCase())===Kx.PERSONAL_SIGN.toLowerCase()){const r={method:e,params:[n[0],s[0]]};return yield null===(i=t.getProvider())||void 0===i?void 0:i.request(r)}if((null==e?void 0:e.toLowerCase())===Kx.ETH_SENDTRANSACTION.toLowerCase()){const r={method:e,params:[Object.assign(Object.assign({},n[0]),{from:s[0]})]};return yield null===(o=t.getProvider())||void 0===o?void 0:o.request(r)}return Wx.includes(e.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${e} -- not handled by the extension -- call separately`),s):yield null===(a=t.getProvider())||void 0===a?void 0:a.request({method:e,params:n})})))({method:e.method,sdk:s,params:e.params});return s.emit(ZA.ConnectWithResponse,t),t}return xx(`[initializeMobileProvider: sendRequest()] sending '${n}' on active provider`,l),yield null===(w=s.getProvider())||void 0===w?void 0:w.request({method:n,params:l})}if(t===e.EventType.REJECTED)throw null==u||u.closeModal(),null===(k=s.getProvider())||void 0===k||k.handleDisconnect({terminate:!1}),Object.assign(new Error(\"User rejected connection\"),{code:4001});throw xx(`[initializeMobileProvider: sendRequest()] failed to start installer: ${t}`),t}finally{S(!1)}if(n===Kx.ETH_REQUESTACCOUNTS)return T=yield new Promise((e=>{const t=setInterval((()=>{const{accounts:n}=C.getState();n&&(clearInterval(t),e(n))}),100)})),xx(`[initializeMobileProvider: sendRequest()] selectedAddress: ${R} --- SKIP rpc call`),T;if(n===Kx.METAMASK_CONNECTWITH)try{let t=0;const n=5,r=({resolve:e,reject:r})=>{t+=1;const i=null==u?void 0:u.getConnector().getRPCMethodTracker(),a=null==i?void 0:i[o];return xx(`TRACKER: update method ${o}`,a),(null==a?void 0:a.result)?(xx(\"[initializeMobileProvider: sendRequest()] found result\",a.result),s.emit(ZA.ConnectWithResponse,a.result),void e(a.result)):(null==a?void 0:a.error)?(xx(\"[initializeMobileProvider: sendRequest()] found error\",a.error),void r(a.error)):t>=n?(xx(\"[initializeMobileProvider: sendRequest()] max message count reached without result\"),void r(new Error(\"Max message count reached without result\"))):void xx(\"[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update\")};let i,a;const l=yield new Promise(((t,n)=>{const s=null==u?void 0:u.getConnector().getRPCMethodTracker();xx(`TRACKER: method ${o}`,s),(null==s?void 0:s[o].result)?(xx(\"[initializeMobileProvider: sendRequest()] found result\",null==s?void 0:s[o].result),t(null==s?void 0:s[o].result)):(null==s?void 0:s[o].error)&&(xx(\"[initializeMobileProvider: sendRequest()] found error\",null==s?void 0:s[o].error),n(null==s?void 0:s[o].error)),a=()=>r({resolve:t,reject:n}),i=null==u?void 0:u.getConnector().on(e.EventType.RPC_UPDATE,a)}));return a&&(null==i||i.off(e.EventType.RPC_UPDATE,a)),xx(\"TRACKER: result\",l),l}catch(e){throw xx(\"[initializeMobileProvider: sendRequest()] error:\",e),e}r[0]&&\"object\"==typeof r[0]&&(r[0].params={__triggeredInstaller:!0,wrappedParams:r[0].params});return i(...r)}if(o.isSecure()&&qx[n])return i(...r);if(s.isExtensionActive())return xx(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${n}' to it`,r,l),yield null===(M=s.getProvider())||void 0===M?void 0:M.request({method:n,params:l});throw xx(`[initializeMobileProvider: sendRequest()] method=${n} --- skip --- not connected/installed`),new Error(\"MetaMask is not connected/installed, please call eth_requestAccounts to connect first.\")}try{const e=yield i(...r);if(xx(`[initializeMobileProvider: sendRequest()] method=${n} rpcResponse`,e),n===Kx.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}),[]);xx(\"[initializeMobileProvider: sendRequest()] accountsToPersist:\",t),t.length>0&&(C.handleAccountsChanged(t,!1),null==b||b.persistAccounts(t))}return e}catch(e){throw console.error(\"[initializeMobileProvider: sendRequest()] error:\",e),e}})),{request:M}=w;w.request=(...e)=>kk(void 0,void 0,void 0,(function*(){return k(null==e?void 0:e[0].method,e,M,l)}));const{send:C}=w;return w.send=(...e)=>kk(void 0,void 0,void 0,(function*(){return k(null==e?void 0:e[0],e,C,l)})),xx(\"[initializeMobileProvider: sendRequest()] metamaskStream.start()\"),f.start(),w}));function zR(t){var n,r,i,o;return kk(this,void 0,void 0,(function*(){const{options:a}=t,s={communicationLayerPreference:null!==(n=a.communicationLayerPreference)&&void 0!==n?n:e.CommunicationLayerPreference.SOCKET,platformManager:t.platformManager,sdk:t,checkInstallationOnAllCalls:a.checkInstallationOnAllCalls,injectProvider:null===(r=a.injectProvider)||void 0===r||r,shouldShimWeb3:null===(i=a.shouldShimWeb3)||void 0===i||i,extensionOnly:null===(o=a.extensionOnly)||void 0===o||o,installer:t.installer,remoteConnection:t.remoteConnection,debug:t.debug},u=yield BR(s);t.activeProvider=u,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(ZA.ConnectionStatus,(t=>{e.emit(ZA.ConnectionStatus,t)})),null===(i=null===(r=e.remoteConnection)||void 0===r?void 0:r.getConnector())||void 0===i||i.on(ZA.ServiceStatus,(t=>{e.emit(ZA.ServiceStatus,t)}))}(t)}))}var UR,FR,KR;const qR=\"sdk\";class HR{constructor({serverUrl:e,enabled:t,originatorInfo:n}){UR.set(this,KE),FR.set(this,void 0),KR.set(this,void 0),Ck(this,UR,e,\"f\"),Ck(this,KR,n,\"f\"),Ck(this,FR,null==t||t,\"f\")}send({event:e,params:t}){if(!Mk(this,FR,\"f\"))return;const n=Object.assign(Object.assign({id:qR,event:e,sdkVersion:HA.version},Mk(this,KR,\"f\")),{params:t});xx(`[Analytics: send()] event: ${e}`,n),KS(n,Mk(this,UR,\"f\")).catch((e=>{xx(`[Analytics: send()] error: ${e}`)}))}}UR=new WeakMap,FR=new WeakMap,KR=new WeakMap;const WR=()=>{if(\"undefined\"==typeof document)return;let e;const t=document.getElementsByTagName(\"link\");for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:0,n=(QR[e[t+0]]+QR[e[t+1]]+QR[e[t+2]]+QR[e[t+3]]+\"-\"+QR[e[t+4]]+QR[e[t+5]]+\"-\"+QR[e[t+6]]+QR[e[t+7]]+\"-\"+QR[e[t+8]]+QR[e[t+9]]+\"-\"+QR[e[t+10]]+QR[e[t+11]]+QR[e[t+12]]+QR[e[t+13]]+QR[e[t+14]]+QR[e[t+15]]).toLowerCase();if(!function(e){return\"string\"==typeof e&&ZR.test(e)}(n))throw TypeError(\"Stringified UUID is invalid\");return n}function eT(e,t,n){var r=(e=e||{}).random||(e.rng||GR)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return XR(r)}function tT(t){var n,r,i;const{dappMetadata:o}=t,a=function({url:e,name:t}){var n;const r=e+t,i=TR(r);if(!localStorage)return\"\";let o=null!==(n=localStorage.getItem(i))&&void 0!==n?n:\"\";if(!o){o=eT();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\"}),s=null===(i=t.platformManager)||void 0===i?void 0:i.getPlatformType(),u=s===e.PlatformType.DesktopWeb,l=s===e.PlatformType.MetaMaskMobileWebview;let c=\"N/A\";return u?c=\"extension\":l&&(c=\"mobile\"),{id:a,from:c}}const nT=({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 kk(this,void 0,void 0,(function*(){xx(\"[wrapExtensionProvider()] Overwriting request method\",e);const{method:o,params:a}=e,s=Hx.includes(o.toLowerCase()),{id:u,from:l}=tT(t);if(s&&(null===(r=t.analytics)||void 0===r||r.send({event:ZE.SDK_RPC_REQUEST,params:{method:o,from:l,id:u}})),o===Kx.METAMASK_BATCH&&Array.isArray(a))return(({target:e,args:t,trackEvent:n,sdkInstance:r})=>kk(void 0,void 0,void 0,(function*(){var i,o;if(\"metamask_batch\"!==t.method)throw new Error(\"Invalid usage\");const a=[],s=null!==(i=null==t?void 0:t.params)&&void 0!==i?i:[];for(const t of s){const n=yield null==e?void 0:e.request({method:t.method,params:t.params});a.push(n)}const{id:u,from:l}=tT(r);return n&&(null===(o=r.analytics)||void 0===o||o.send({event:ZE.SDK_RPC_REQUEST_DONE,params:{method:t.method,from:l,id:u}})),a})))({target:n,args:e,trackEvent:s,sdkInstance:t});if(o.toLowerCase()===Kx.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(a))return(({target:e,params:t})=>kk(void 0,void 0,void 0,(function*(){const n=yield e.request({method:Kx.ETH_REQUESTACCOUNTS,params:[]});if(!n.length)throw new Error(\"SDK state invalid -- undefined accounts\");return yield e.request({method:Kx.PERSONAL_SIGN,params:[t[0],n[0]]})})))({target:n,params:a});if(o.toLowerCase()===Kx.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(a))return(({target:e,params:t})=>kk(void 0,void 0,void 0,(function*(){const[n]=t,r=n.method,i=n.params,o=yield e.request({method:Kx.ETH_REQUESTACCOUNTS,params:[]});if(!o.length)throw new Error(\"SDK state invalid -- undefined accounts\");return(null==r?void 0:r.toLowerCase())===Kx.PERSONAL_SIGN.toLowerCase()?yield e.request({method:r,params:[i[0],o[0]]}):(null==r?void 0:r.toLowerCase())===Kx.ETH_SENDTRANSACTION.toLowerCase()?yield e.request({method:r,params:[Object.assign(Object.assign({},i[0]),{from:o[0]})]}):Wx.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:a});let c;try{return c=yield n.request(e),c}finally{s&&(null===(i=t.analytics)||void 0===i||i.send({event:ZE.SDK_RPC_REQUEST_DONE,params:{method:o,from:l,id:u}}))}}))}:\"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 rT;function iT({mustBeMetaMask:e,sdkInstance:t}){return kk(this,void 0,void 0,(function*(){if(\"undefined\"==typeof window)throw new Error(\"window not available\");let n;try{return n=yield new Promise(((e,t)=>{const n=setTimeout((()=>{t(new Error(\"eip6963RequestProvider timed out\"))}),500);window.addEventListener(rT.Announce,(t=>{const r=t,{detail:{info:i,provider:o}={}}=r,{name:a,rdns:s,uuid:u}=null!=i?i:{};GA.test(u)&&a.startsWith(YA.NAME)&&s===YA.RDNS&&(clearTimeout(n),e(o))})),window.dispatchEvent(new Event(rT.Request))})),nT({provider:n,sdkInstance:t})}catch(n){const{ethereum:r}=window;if(!r)throw new Error(\"Ethereum not found in window object\");if(\"providers\"in r){if(Array.isArray(r.providers)){const n=e?r.providers.find((e=>oT(e))):r.providers[0];if(!n)throw new Error(\"No suitable provider found\");return nT({provider:n,sdkInstance:t})}}else if(e&&!oT(r))throw new Error(\"MetaMask provider not found in Ethereum\");return nT({provider:r,sdkInstance:t})}}))}function oT(e){if(!e.isMetaMask)return!1;if(e.isBraveWallet&&!e._events&&!e._state)return!1;const t=[\"isApexWallet\",\"isAvalanche\",\"isBitKeep\",\"isBlockWallet\",\"isKuCoinWallet\",\"isMathWallet\",\"isOkxWallet\",\"isOKExWallet\",\"isOneInchIOSWallet\",\"isOneInchAndroidWallet\",\"isOpera\",\"isPortal\",\"isRabby\",\"isTokenPocket\",\"isTokenary\",\"isUniswapWallet\",\"isZerion\"];for(const n of t)if(e[n])return!1;return!0}!function(e){e.Announce=\"eip6963:announceProvider\",e.Request=\"eip6963:requestProvider\"}(rT||(rT={}));const aT=e=>kk(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}`,\"0x2a\":`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}));var sT={exports:{}};!function(e,t){e.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),a=Math.max(i,o),s=0,u=e.map([t,n],(function(t){var n=a-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&&(s=a-Math.min(i,o)),a-=1;a>=s;){if(u[0][a]>u[1][a])return 1;if(u[0][a]===u[1][a]){if(a===s)return 0;a-=1}else if(u[0][a]1?i-1:0),a=1;a0){var a=Object.keys(n),u=s.default.find(a,(function(e){return t.isOS(e)}));if(u){var l=this.satisfies(n[u]);if(void 0!==l)return l}var c=s.default.find(a,(function(e){return t.isPlatform(e)}));if(c){var d=this.satisfies(n[c]);if(void 0!==d)return d}}if(o>0){var f=Object.keys(i),h=s.default.find(f,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=s.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(s.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,a=[{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=a,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),a=[{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=a,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),a=[{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=a,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),a=[{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=a,e.exports=t.default}})}(sT);var uT=r(sT.exports);class lT{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;xx(`[PlatfformManager: openDeeplink()] universalLink --\\x3e ${t}`),xx(`[PlatfformManager: openDeeplink()] deepLink --\\x3e ${n}`);try{if(i.preferredOpenLink)return void i.preferredOpenLink(i.useDeeplink?n:t,r);if(xx(`[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=PR.getProvider()||(null===window||void 0===window?void 0:window.ethereum);return xx(`[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=uT.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===e.PlatformType.MobileWeb}isNotBrowser(){var e;return\"undefined\"==typeof window||!(null===window||void 0===window?void 0:window.navigator)||\"undefined\"!=typeof global&&\"ReactNative\"===(null===(e=null===global||void 0===global?void 0:global.navigator)||void 0===e?void 0:e.product)||\"ReactNative\"===(null===navigator||void 0===navigator?void 0:navigator.product)}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isBrowser(){return!this.isNotBrowser()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(t){const{state:n}=t;return n.platformType?n.platformType:t.isReactNative()?e.PlatformType.ReactNative:t.isNotBrowser()?e.PlatformType.NonBrowser:t.isMetaMaskMobileWebView()?e.PlatformType.MetaMaskMobileWebview:t.isMobile()?e.PlatformType.MobileWeb:e.PlatformType.DesktopWeb}(this)}}const cT=e=>kk(void 0,void 0,void 0,(function*(){const{options:t}=e,{readonlyRPCMap:n}=t;if(n)try{xx(\"[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers\",n),e.setReadOnlyRPCCalls(!0)}catch(e){throw new Error(\"Invalid Infura Settings\")}}));\n/*! *****************************************************************************\n Copyright (c) Microsoft Corporation.\n\n Permission to use, copy, modify, and/or distribute this software for any\n purpose with or without fee is hereby granted.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n PERFORMANCE OF THIS SOFTWARE.\n ***************************************************************************** */\nfunction dT(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function fT(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1?t-1:0),r=1;r1?t-1:0),r=1;r1){for(var c=Array(l),d=0;d1){for(var f=Array(d),h=0;h import('./MyComponent'))\\n\\nDid you accidentally put curly braces around the import?\",r),\"default\"in r||L(\"lazy: Expected the result of a dynamic import() call. Instead received: %s\\n\\nYour code should look like: \\n const MyComponent = lazy(() => import('./MyComponent'))\",r),r.default}throw e._result}function Ee(e){return\"string\"==typeof e||\"function\"==typeof e||(!!(e===i||e===a||R||e===o||e===c||e===d||A||e===p||M||C||x)||\"object\"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===f||e.$$typeof===s||e.$$typeof===u||e.$$typeof===l||e.$$typeof===ve||void 0!==e.getModuleId))}function ke(){var e=b.current;return null===e&&L(\"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\\n1. You might have mismatching versions of React and the renderer (such as React DOM)\\n2. You might be breaking the Rules of Hooks\\n3. You might have more than one copy of React in the same app\\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.\"),e}ve=Symbol.for(\"react.module.reference\");var Me,Ce,xe,Ae,Re,Te,Pe,Le=0;function Ie(){}Ie.__reactDisabledLog=!0;var Oe,Ne=T.ReactCurrentDispatcher;function De(e,t,n){if(void 0===Oe)try{throw Error()}catch(e){var r=e.stack.trim().match(/\\n( *(at )?)/);Oe=r&&r[1]||\"\"}return\"\\n\"+Oe+e}var je,Be=!1,ze=\"function\"==typeof WeakMap?WeakMap:Map;function Ue(e,t){if(!e||Be)return\"\";var n,r=je.get(e);if(void 0!==r)return r;Be=!0;var i,o=Error.prepareStackTrace;Error.prepareStackTrace=void 0,i=Ne.current,Ne.current=null,function(){if(0===Le){Me=console.log,Ce=console.info,xe=console.warn,Ae=console.error,Re=console.group,Te=console.groupCollapsed,Pe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ie,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Le++}();try{if(t){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,\"props\",{set:function(){throw Error()}}),\"object\"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(e){n=e}Reflect.construct(e,[],a)}else{try{a.call()}catch(e){n=e}e.call(a.prototype)}}else{try{throw Error()}catch(e){n=e}e()}}catch(t){if(t&&n&&\"string\"==typeof t.stack){for(var s=t.stack.split(\"\\n\"),u=n.stack.split(\"\\n\"),l=s.length-1,c=u.length-1;l>=1&&c>=0&&s[l]!==u[c];)c--;for(;l>=1&&c>=0;l--,c--)if(s[l]!==u[c]){if(1!==l||1!==c)do{if(l--,--c<0||s[l]!==u[c]){var d=\"\\n\"+s[l].replace(\" at new \",\" at \");return e.displayName&&d.includes(\"\")&&(d=d.replace(\"\",e.displayName)),\"function\"==typeof e&&je.set(e,d),d}}while(l>=1&&c>=0);break}}}finally{Be=!1,Ne.current=i,function(){if(0==--Le){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},e,{value:Me}),info:j({},e,{value:Ce}),warn:j({},e,{value:xe}),error:j({},e,{value:Ae}),group:j({},e,{value:Re}),groupCollapsed:j({},e,{value:Te}),groupEnd:j({},e,{value:Pe})})}Le<0&&L(\"disabledDepth fell below zero. This is a bug in React. Please file an issue.\")}(),Error.prepareStackTrace=o}var f=e?e.displayName||e.name:\"\",h=f?De(f):\"\";return\"function\"==typeof e&&je.set(e,h),h}function Fe(e,t,n){if(null==e)return\"\";if(\"function\"==typeof e)return Ue(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if(\"string\"==typeof e)return De(e);switch(e){case c:return De(\"Suspense\");case d:return De(\"SuspenseList\")}if(\"object\"==typeof e)switch(e.$$typeof){case l:return Ue(e.render,!1);case f:return Fe(e.type,t,n);case h:var r=e,i=r._payload,o=r._init;try{return Fe(o(i),t,n)}catch(e){}}return\"\"}je=new ze;var Ke,qe={},He=T.ReactDebugCurrentFrame;function We(e){if(e){var t=e._owner,n=Fe(e.type,e._source,t?t.type:null);He.setExtraStackFrame(n)}else He.setExtraStackFrame(null)}function $e(e){if(e){var t=e._owner;k(Fe(e.type,e._source,t?t.type:null))}else k(null)}function Ve(){if(_.current){var e=Q(_.current.type);if(e)return\"\\n\\nCheck the render method of `\"+e+\"`.\"}return\"\"}Ke=!1;var Ye={};function Ge(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=Ve();if(!t){var n=\"string\"==typeof e?e:e.displayName||e.name;n&&(t=\"\\n\\nCheck the top-level render call using <\"+n+\">.\")}return t}(t);if(!Ye[n]){Ye[n]=!0;var r=\"\";e&&e._owner&&e._owner!==_.current&&(r=\" It was passed a child from \"+Q(e._owner.type)+\".\"),$e(e),L('Each child in a list should have a unique \"key\" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),$e(null)}}}function Ze(e,t){if(\"object\"==typeof e)if(V(e))for(var n=0;n\",u=\" Did you accidentally export a JSX literal instead of a component?\"):l=typeof e,L(\"React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s\",l,u)}var d=ae.apply(this,arguments);if(null==d)return d;if(s)for(var f=2;f ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.\"));var t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(void 0)}}tt(t)}((function(){0===i.length?(w.current=null,n(t)):ot(t,n,r)}))}catch(e){r(e)}else n(t)}var at=!1;function st(e){if(!at){at=!0;var t=0;try{for(;t is not supported and will be removed in a future major release. Did you mean to render instead?\")),t.Provider},set:function(e){t.Provider=e}},_currentValue:{get:function(){return t._currentValue},set:function(e){t._currentValue=e}},_currentValue2:{get:function(){return t._currentValue2},set:function(e){t._currentValue2=e}},_threadCount:{get:function(){return t._threadCount},set:function(e){t._threadCount=e}},Consumer:{get:function(){return n||(n=!0,L(\"Rendering is not supported and will be removed in a future major release. Did you mean to render instead?\")),t.Consumer}},displayName:{get:function(){return t.displayName},set:function(e){i||(P(\"Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.\",e),i=!0)}}}),t.Consumer=o,t._currentRenderer=null,t._currentRenderer2=null,t},t.createElement=ut,t.createFactory=ct,t.createRef=function(){var e={current:null};return Object.seal(e),e},t.forwardRef=function(e){null!=e&&e.$$typeof===f?L(\"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).\"):\"function\"!=typeof e?L(\"forwardRef requires a render function but was given %s.\",null===e?\"null\":typeof e):0!==e.length&&2!==e.length&&L(\"forwardRef render functions accept exactly two parameters: props and ref. %s\",1===e.length?\"Did you forget to use the ref parameter?\":\"Any additional parameter will be undefined.\"),null!=e&&(null==e.defaultProps&&null==e.propTypes||L(\"forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?\"));var t,n={$$typeof:l,render:e};return Object.defineProperty(n,\"displayName\",{enumerable:!1,configurable:!0,get:function(){return t},set:function(n){t=n,e.name||e.displayName||(e.displayName=n)}}),n},t.isValidElement=ue,t.lazy=function(e){var t,n,r={$$typeof:h,_payload:{_status:be,_result:e},_init:Se};return Object.defineProperties(r,{defaultProps:{configurable:!0,get:function(){return t},set:function(e){L(\"React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.\"),t=e,Object.defineProperty(r,\"defaultProps\",{enumerable:!0})}},propTypes:{configurable:!0,get:function(){return n},set:function(e){L(\"React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.\"),n=e,Object.defineProperty(r,\"propTypes\",{enumerable:!0})}}}),r},t.memo=function(e,t){Ee(e)||L(\"memo: The first argument must be a component. Instead received: %s\",null===e?\"null\":typeof e);var n,r={$$typeof:f,type:e,compare:void 0===t?null:t};return Object.defineProperty(r,\"displayName\",{enumerable:!1,configurable:!0,get:function(){return n},set:function(t){n=t,e.name||e.displayName||(e.displayName=t)}}),r},t.startTransition=function(e,t){var n=y.transition;y.transition={};var r=y.transition;y.transition._updatedFibers=new Set;try{e()}finally{if(y.transition=n,null===n&&r._updatedFibers)r._updatedFibers.size>10&&P(\"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.\"),r._updatedFibers.clear()}},t.unstable_act=function(e){var t=nt;nt++,null===w.current&&(w.current=[]);var n,r=w.isBatchingLegacy;try{if(w.isBatchingLegacy=!0,n=e(),!r&&w.didScheduleLegacyUpdate){var i=w.current;null!==i&&(w.didScheduleLegacyUpdate=!1,st(i))}}catch(e){throw it(t),e}finally{w.isBatchingLegacy=r}if(null!==n&&\"object\"==typeof n&&\"function\"==typeof n.then){var o=n,a=!1,s={then:function(e,n){a=!0,o.then((function(r){it(t),0===nt?ot(r,e,n):e(r)}),(function(e){it(t),n(e)}))}};return rt||\"undefined\"==typeof Promise||Promise.resolve().then((function(){})).then((function(){a||(rt=!0,L(\"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);\"))})),s}var u=n;if(it(t),0===nt){var l=w.current;return null!==l&&(st(l),w.current=null),{then:function(e,t){null===w.current?(w.current=[],ot(u,e,t)):e(u)}}}return{then:function(e,t){e(u)}}},t.useCallback=function(e,t){return ke().useCallback(e,t)},t.useContext=function(e){var t=ke();if(void 0!==e._context){var n=e._context;n.Consumer===e?L(\"Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?\"):n.Provider===e&&L(\"Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?\")}return t.useContext(e)},t.useDebugValue=function(e,t){return ke().useDebugValue(e,t)},t.useDeferredValue=function(e){return ke().useDeferredValue(e)},t.useEffect=function(e,t){return ke().useEffect(e,t)},t.useId=function(){return ke().useId()},t.useImperativeHandle=function(e,t,n){return ke().useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return ke().useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return ke().useLayoutEffect(e,t)},t.useMemo=function(e,t){return ke().useMemo(e,t)},t.useReducer=function(e,t,n){return ke().useReducer(e,t,n)},t.useRef=function(e){return ke().useRef(e)},t.useState=function(e){return ke().useState(e)},t.useSyncExternalStore=function(e,t,n){return ke().useSyncExternalStore(e,t,n)},t.useTransition=function(){return ke().useTransition()},t.version=\"18.2.0\",\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}(PT,PT.exports)),PT.exports}function IT(){return TT||(TT=1,\"production\"===je.env.NODE_ENV?CT.exports=AT():CT.exports=LT()),CT.exports}PT.exports;var OT,NT={},DT={exports:{}},jT={},BT={exports:{}},zT={};var UT,FT,KT,qT={};function HT(){return UT||(UT=1,function(e){\"production\"!==je.env.NODE_ENV&&function(){\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=!1,n=!1;function r(e,t){var n=e.length;e.push(t),function(e,t,n){var r=n;for(;r>0;){var i=r-1>>>1,o=e[i];if(!(a(o,t)>0))return;e[i]=t,e[r]=o,r=i}}(e,t,n)}function i(e){return 0===e.length?null:e[0]}function o(e){if(0===e.length)return null;var t=e[0],n=e.pop();return n!==t&&(e[0]=n,function(e,t,n){var r=n,i=e.length,o=i>>>1;for(;ra)||n&&!R());){var s=h.callback;if(\"function\"==typeof s){h.callback=null,p=h.priorityLevel;var u=s(h.expirationTime<=a);a=e.unstable_now(),\"function\"==typeof u?h.callback=u:h===i(c)&&o(c),_(a)}else o(c);h=i(c)}if(null!==h)return!0;var l=i(d);return null!==l&&N(S,l.startTime-a),!1}(r,a)}finally{h=null,p=s,m=!1}}\"undefined\"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k=!1,M=null,C=-1,x=5,A=-1;function R(){return!(e.unstable_now()-A125?console.error(\"forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported\"):x=e>0?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return i(c)},e.unstable_next=function(e){var t;switch(p){case 1:case 2:case 3:t=3;break;default:t=p}var n=p;p=t;try{return e()}finally{p=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=j,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=p;p=e;try{return t()}finally{p=n}},e.unstable_scheduleCallback=function(t,n,o){var a,s,u=e.unstable_now();if(\"object\"==typeof o&&null!==o){var l=o.delay;a=\"number\"==typeof l&&l>0?u+l:u}else a=u;switch(t){case 1:s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}var h=a+s,p={id:f++,callback:n,priorityLevel:t,startTime:a,expirationTime:h,sortIndex:-1};return a>u?(p.sortIndex=a,r(d,p),null===i(c)&&p===i(d)&&(v?D():v=!0,N(S,a-u))):(p.sortIndex=h,r(c,p),g||m||(g=!0,O(E))),p},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}},\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}(qT)),qT}function WT(){return FT||(FT=1,\"production\"===je.env.NODE_ENV?BT.exports=(OT||(OT=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0>>1,o=e[r];if(!(0>>1;ri(u,n))li(c,u)?(e[r]=c,e[l]=n,r=l):(e[r]=u,e[s]=n,r=s);else{if(!(li(c,n)))break e;e[r]=c,e[l]=n,r=l}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(\"object\"==typeof performance&&\"function\"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,s=a.now();e.unstable_now=function(){return a.now()-s}}var u=[],l=[],c=1,d=null,f=3,h=!1,p=!1,m=!1,g=\"function\"==typeof setTimeout?setTimeout:null,v=\"function\"==typeof clearTimeout?clearTimeout:null,b=\"undefined\"!=typeof setImmediate?setImmediate:null;function y(e){for(var i=n(l);null!==i;){if(null===i.callback)r(l);else{if(!(i.startTime<=e))break;r(l),i.sortIndex=i.expirationTime,t(u,i)}i=n(l)}}function w(e){if(m=!1,y(e),!p)if(null!==n(u))p=!0,L(_);else{var t=n(l);null!==t&&I(w,t.startTime-e)}}function _(t,i){p=!1,m&&(m=!1,v(M),M=-1),h=!0;var o=f;try{for(y(i),d=n(u);null!==d&&(!(d.expirationTime>i)||t&&!A());){var a=d.callback;if(\"function\"==typeof a){d.callback=null,f=d.priorityLevel;var s=a(d.expirationTime<=i);i=e.unstable_now(),\"function\"==typeof s?d.callback=s:d===n(u)&&r(u),y(i)}else r(u);d=n(u)}if(null!==d)var c=!0;else{var g=n(l);null!==g&&I(w,g.startTime-i),c=!1}return c}finally{d=null,f=o,h=!1}}\"undefined\"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var S,E=!1,k=null,M=-1,C=5,x=-1;function A(){return!(e.unstable_now()-xe||125a?(r.sortIndex=o,t(l,r),null===n(u)&&r===n(l)&&(m?(v(M),M=-1):m=!0,I(w,o-a))):(r.sortIndex=s,t(u,r),p||h||(p=!0,L(_))),r},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}}(zT)),zT):BT.exports=HT()),BT.exports}\n/**\n * @license React\n * react-dom.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */function $T(){if(KT)return jT;KT=1;var e=IT(),t=WT();function n(e){for(var t=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,n=1;n